[PATCH] Fix for incorrect address sinking in the presence of potential overflows

Louis Gerbarg lgg at apple.com
Fri Mar 21 16:24:50 PDT 2014


The attached patch is a fix for errors that can occur when sinking an address from another basic block. Essentially what happens is that sunkaddr is a manually lowered GEP, but that when using an integer whose width is less than a pointer an overflow can happen that leads to invalid address generation. Technically one can still legally do the operation on constrained ranges or if the add has nsw/nuw annotations, but as a practical matter this is an edge case that almost never occurs and the data necessary to figure out if the transform is legal is not available at the point where it needs to be made, so in the cases where the address generation can be incorrect I am just backing out the optimization.

The included regression test will generate malformed code when run on trunk. I am attaching samples of both the correct and the malformed code.

The performance impact of this should be essentially non-existent, this type of address sinking with type expansion happens only once or twice in the entirety of the regression tests and LNT.

Louis

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-for-incorrect-address-sinking-in-the-presence-of.patch
Type: application/octet-stream
Size: 2069 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140321/68c956ba/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: good.s
Type: application/octet-stream
Size: 243 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140321/68c956ba/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bad.s
Type: application/octet-stream
Size: 351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140321/68c956ba/attachment-0002.obj>


More information about the llvm-commits mailing list