[LLVMdev] InstructionCombining forgets alignment of globals

Duncan Sands baldrick at free.fr
Thu Jul 10 05:40:41 PDT 2008


Hi Nicolas,

>   if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
> 
>     unsigned Align = GV->getAlignment();
> 
>     if (Align == 0 && TD && GV->getType()->getElementType()->isSized()) 
> 
>       Align = TD->getPrefTypeAlignment(GV->getType()->getElementType());
>
> It assumes that global values are always optimally aligned. I think this is
> incorrect and the bottom two lines should be removed.

I don't understand - if Align is zero it means that GV was marked
as having preferred alignment (that's what Align == 0 means), so
it is not wrong to change it explicitly to the preferred alignment
for the target.

Ciao,

Duncan.



More information about the llvm-dev mailing list