Skip to content

Support alias attribute on functions #1048

@dkolsen-pgi

Description

@dkolsen-pgi

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()

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions