-
Notifications
You must be signed in to change notification settings - Fork 0
Missing alias definitions #135
Comments
For the sake of completeness, there is an identical problem with functions: define i32 @c() !repo_definition !0 {
entry:
ret i32 64
}
@d = alias i32(), i32()* @c
!repo.definitions = !{!0}
!0 = !RepoDefinition(name: "c", digest: [16 x i8] c"cccccccccccccccc", linkage: external,
visibility: default, pruned: false) Compile and dump the two versions:
|
The issues are caused by the input IR codes. To contain a definition of 'b' or ‘d’ in the section, the RepoDefinitions of ‘b’ and ‘d’ need to be given in the IR codes. |
Two things need to be clarified:
|
They don’t, but both aliases could have been created as the result of optimization. I don’t know if such optimizations are performed by the compiler ATM, but they’re not too hard to imagine: int f() { return 1; }
int g() { return 1; } Could become: int f() { return 1; }
alias g = f; (Obviously this second example isn’t legal C!) We already create hashes for global objects created as a result of optimization. Shouldn’t aliases be handled in the same way? Futhermore, if we imagine that RepoDefinition metadata is provided, what would happen if the digests given for the two objects (the alias and the aliasee) happened to be different? (This might happen as the result of a bug or an error in hand-written IR). |
Consider the following IR:
Then:
Compile to ELF and dump the symbols from the compiler’s object file:
Compile to a repo, and dump the compilation that is produced:
As you can see, the repo does not contain a definition of 'b'. In the ELF case above both symbols point to the first four bytes of the .data section. This may later result in errors such as ”symbol not found” from the linker. Fully replicating the ELF output (with multiple symbols pointing to the same data in the output) will also require issue #64 to be resolved.
The text was updated successfully, but these errors were encountered: