[PATCH] Ensure SROA doesn't prematurely promote an alloca that's being revisited

Evan Cheng evan.cheng at apple.com
Wed Jan 8 12:10:35 PST 2014


Attached is a patch (and the test case) that fix a SROA edge case. An alloca can be added back to the worklist to be revisited during rewrite of a MemTransferInst. If the alloca is added to the "promotable" queue and then added again when it's revisited, mem2reg will crash. The patch simply prevents promotion of an alloca that is scheduled to be revisited.

The patch isn't ideal. It's following the AllocaSliceRewriter::isUsedByRewrittenSpeculatableInstructions() example by caching a boolean state. But it's correct and as clean a patch as I can come up with.

Evan

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.txt
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140108/53b4d7f0/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: revisit.ll
Type: application/octet-stream
Size: 1216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140108/53b4d7f0/attachment.obj>


More information about the llvm-commits mailing list