[llvm-commits] [patch] Don't use alignment of global if global is weak in instcombine

Richard Osborne richard at xmos.com
Mon Sep 17 10:53:15 PDT 2012


Hi Duncan, thanks for you comments. My replies are inline.

On 17/09/12 18:10, Duncan Sands wrote:
>
> How about
>   if (GV->hasDefinitiveInitializer())
>      ...
> instead?
>
> I say this because !GV->isDeclaration() is the same as 
> GV->hasInitializer(),
> and thus the difference is in the linkage types accepted:
> GV->hasDefinitiveInitializer() will accept weak linkage if the ODR 
> applies,
> while your test will not.
The my logic matches the logic in ComputeMaskedBits in 
ValueTracking.cpp, so if hasDefinitiveInitializer() should be used here 
then then ValueTracking.cpp should also be updated.
> So for my suggestion to be correct it is necessary
> that the ODR implies that other (weak) instances of this global will 
> be at
> least as aligned as this instance.  Do you think this is the case?
I'm not sure. Would it be a valid for another optimization pass to 
increase the alignment of a ODR global by explicitly setting the 
alignment if it decided that this was profitable? If this was the case 
then you can't rely on the other globals being at least as aligned since 
the same optimization might not have been done in the other translation 
unit.
>
> Ciao, Duncan.
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


-- 
Richard Osborne | XMOS
http://www.xmos.com




More information about the llvm-commits mailing list