Open llvmbot opened 9 years ago
I think Rafael is correct, any single global marked unnamed_addr does not care how its address compares to other globals. Thus you can merge it into another one that isn't unnamed_addr.
Mergefunc should be taught to do this, in the same sense that mergefunc should be taught to merge constants as well as functions. (Why do that? Consider the case that two functions are different because they refer to different vtables, and two vtables are different because the refer to different functions. But really you could merge the vtables and the functions. In this case, it would be smart for mergefunc to also do thunk removal as part of that folding, to permit more constant and function merging.)
Should @bar be unnamed_addr as well?
I think the optimization is still valid. You only can't do it if both are not unnamed_addr if I remember the rules correctly.
Should @bar be unnamed_addr as well?
Extended Description
opt -O3 will not modify
declare void @bar() define linkonce_odr void @foo() unnamed_addr { call void @bar() ret void } @v = global void()* @foo
but it could change it to
declare void @bar() @v = global void()* @bar