Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support alias attribute on functions #1048

Open
dkolsen-pgi opened this issue Nov 1, 2024 · 2 comments
Open

Support alias attribute on functions #1048

dkolsen-pgi opened this issue Nov 1, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@dkolsen-pgi
Copy link
Collaborator

Test program:

void herp_derp() {}
[[gnu::alias("_Z9herp_derpv")]] void frobble();
int main() {
    frobble();
}

Clang and GCC compile and link this successfully. But ClangIR doesn't process the alias attribute and fails to link:

$ cir alias.cpp
/usr/bin/ld: /tmp/alias-7b2e15.o: in function `main':
/local/home/dolsen/upstream/llvm-project/test/alias.cpp:4: undefined reference to `frobble()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

The bug can be seen in the LLVM IR. Clang creates an alias directive for frobble:

@_Z7frobblev = dso_local alias void (), ptr @_Z9herp_derpv

while ClangIR merely declares the function:

declare !dbg !8 void @_Z7frobblev()
@bcardosolopes
Copy link
Member

bcardosolopes commented Nov 5, 2024

I just hit this while working through an issue, so I might as well fix it while there.

@bcardosolopes bcardosolopes self-assigned this Nov 5, 2024
@bcardosolopes
Copy link
Member

bcardosolopes commented Nov 6, 2024

While working at this, I noticed that LLVM IR dialect GlobalOp does not yet support alias, so we cannot yet lower this information down. Let me file another issue for that.

For now, I'm going to emit a global but not yet set the alias, won't be much better than what we currently have but it's a first step - later on we can just set the alias when MLIR support comes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants