diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp --- a/llvm/lib/CodeGen/StackColoring.cpp +++ b/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(To)->moveBefore(const_cast(From)); // AA might be used later for instruction scheduling, and we need it to be // able to deduce the correct aliasing releationships between pointers