[PATCH] Fix bug in llvm::DemoteRegToStack

Akira Hatanaka ahatanak at gmail.com
Thu Jan 15 16:44:29 PST 2015


Patch updated.

I moved the piece of code which splits the critical edge before the while loop which replaces all the user of I. I believe this should work, although this is probably different from the solution you suggested. Please let me know if I completely misunderstood your comments.

I didn't quite understand your comment about creating the store instruction and inserting it later. You can create the store without inserting it into the basic block, but you are still adding the store to the use list of instruction "I", no? If so, the while loop which replaces all the uses of "I" has to replace the value operand of the store (because the loop won't terminate otherwise), which is not what we want to do.

Also, in the case where the use immediately follows the def, I think the insertion point of the store has to be recomputed after the use is replaced and the load is inserted (I'm assuming it's legitimate to use DemoteRegToStack in such case).

1. before transformation.

v0 = Def
Use v0 <- store's insertPt

2. after replacing use of v0.

v0 = Def
v1 = load stackslot 
Use v1 <- store's insertPt

3. after inserting store.

v0 = Def
v1 = load stackslot 
store v0, stackslot <- this should be inserted before the load
Use v1


http://reviews.llvm.org/D6729

Files:
  lib/Transforms/Utils/DemoteRegToStack.cpp
  test/CodeGen/ARM/sjlj-prepare-critical-edge.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6729.18271.patch
Type: text/x-patch
Size: 10469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150116/0a901e36/attachment.bin>


More information about the llvm-commits mailing list