PATCH + test for PR18032 (InstCombine issue)

Stepan Dyatkovskiy stpworld at narod.ru
Fri Dec 20 03:45:56 PST 2013


Hi all,
Please find in attachment my PR18032 fix for review.

Issue description:
InstCombine Pass emits wrong alignment for 'load' instruction with 'null' as
address.
Problem was in Local.cpp, llvm::getOrEnforceKnownAlignment method.
Method analyzes trailing zeroes in address values and suggest its own
aligment.
For example: for address 0x123123a8 we have 3 binary trailing zeroes, and
thus, method will suggest you 8 bytes alignment.
Doing same logic, it will suggest you maximum possible alignment (2^29) for
'null' pointer.
Then InstCombiner::visitLoadInst method will select maximum alignment of 
what
was given in IR and what was suggested by getOrEnforceKnownAlignment; these
strings:
    if (KnownAlign > EffectiveLoadAlign)
      LI.setAlignment(KnownAlign);
So, finally we got align of 536870912 bytes:

The fix:
Add one more special case for getOrEnforceKnownAlignment. If address is 0,
we don't need to anylize trailing zeroes,
just return alignment known already (PrefAlign value).

-Stepan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr18032-2013-12-20.patch
Type: text/x-diff
Size: 2784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131220/03e6dd5e/attachment.patch>


More information about the llvm-commits mailing list