-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
LLVM should support symbol aliasing #1389
Comments
assigned to @asl |
Sorry, I was wrong. alias is function attribute (in accordance to So, maybe it will be better just to emit stub? |
Can you include a link to spec that describes what aliases and weak aliases do, and how they are handled |
The codegen for aliases seems to be higly platform-dependend. However, I've
void my_memcpy(void* outp, const void* inp, size_t length)
2.1 Mingw32 (note, there is no "weak" attribute here, since there are no weak .globl _my_memcpy 2.1 Linux In terms of LLVM, my_memcpy gets external weak linkage, since there is no code The documentation for .set is here: http://sourceware.org/binutils/docs-2.17/as/Pseudo-Ops.html#Pseudo-Ops |
Well. It was much discussion about symbol aliases in llvm-commits. Let's move here. Terminology:
Examples:
Features: |
My last proposal was:
|
Proposed solution Also it does some ugly code cleanup and formatting cleanup. Hope, this won't |
Patch also lacks some comments describing methods. They will be added. |
Overall, this approach is better than extending function or globalvar with information. However, the bad What is wrong with having a list of GlobalAlias objects in Module? -Chris |
DAE shouldn't touch aliases, because they are external declarations. I don't see |
However, I agree, that code should be reviewed about creation of GV "copies". |
Actually, it makes a huge difference. Consider the following: static void foo(int X) alias 'bar' { no uses of X } In this case, DAE will delete the X argument to foo, even though foo is aliased to bar, and external I propose that you model the code like this: @bar = alias void @foo(i32) In this design, bar is an instance of the GlobalAlias class. The global alias class is required to have a Also, because the alias uses the global as an operand, things like replacealluseswith would update the What is the disadvantage of this approach? -Chris |
FWIW, the design Chris just proposed sounds right to me. Its close to what I was In some cases, however, it might still be possible to have DAE alter an aliased
|
If the alias were internal, some other pass should have RAUW'd it with the target, then deleted it.
In practice, this probably isn't worth it. Even if it were, DAE could do this today for any address- -Chris |
New solution Example syntax: @foo = external global i32 declare i32 @foo_f() define i32 @test() { Unfortunately I had to force linkage for aliases use same syntax as GV's |
The syntax will be changed to: @foo = external global i32 declare i32 @foo_f() define i32 @test() { I won't resubmit patch, since this change won't affect the review. |
Looks great. Just to check, this is legal too right: call i32 @bar_f() -Chris |
Hmm. This seems to be illegal, because aliases are "seen" as externals. So, in %tmp_f = load %FunTy** @bar_f Should this behaviour be fixed with function aliases? |
I thought aliases are "another name for" the global. If so, you should be able to refer to the global or the -Chris |
Yes, definitely. Fixed. |
mentioned in issue #1215 |
Update file ISO_Fortran_binding.h with "CFI" types for Fortran REAL and COMPLEX kinds 2, 3, 10, 16, and modify KIND=16 IO to use descriptors.
Extended Description
LLVM should support symbol aliasing (the one, produced via
attribute((alias)) in gcc).
It seems, this is the main reason of #1378 , since compatibility is achieved via
symbol aliasing.
Aliasing, seems, can be done in some painless way for functions: just clone it
or output the "stub", which will call original one.
Anyway, this is just cheap workaround. Aliasing should be introduced for GV's also.
The text was updated successfully, but these errors were encountered: