[PATCH] D80101: [StackColoring] When remapping alloca's move the To alloca if the From alloca is before it.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 17 22:52:40 PDT 2020


craig.topper created this revision.
craig.topper added reviewers: efriedma, jdoerfert.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

If To is after From its possible that there's a use of From
between them.

I'm not sure if this is the right fix, but wanted to start here
for discussion. Also not sure how to test this since we're in
the Machine IR section of the pipeline, but modifying IR.

Fixes issue reported here http://lists.llvm.org/pipermail/llvm-dev/2020-May/141421.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80101

Files:
  llvm/lib/CodeGen/StackColoring.cpp


Index: llvm/lib/CodeGen/StackColoring.cpp
===================================================================
--- llvm/lib/CodeGen/StackColoring.cpp
+++ llvm/lib/CodeGen/StackColoring.cpp
@@ -912,6 +912,8 @@
     const AllocaInst *To = MFI->getObjectAllocation(SI.second);
     assert(To && From && "Invalid allocation object");
     Allocas[From] = To;
+    if (From->comesBefore(To))
+      const_cast<AllocaInst*>(To)->moveBefore(const_cast<AllocaInst*>(From));
 
     // AA might be used later for instruction scheduling, and we need it to be
     // able to deduce the correct aliasing releationships between pointers


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80101.264535.patch
Type: text/x-patch
Size: 623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200518/c8fe5469/attachment.bin>


More information about the llvm-commits mailing list