aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2013-02-05 18:23:10 +0000
committerChad Rosier <mcrosier@apple.com>2013-02-05 18:23:10 +0000
commit92a54f6d4c011db58c28577efbab99c961b59f5c (patch)
treee37cdd02d0b446700b78159fdc9398e035cb18fb /llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
parent4acf7dd86694ab11d56d9d62e0362c531719af3b (diff)
downloadllvm-92a54f6d4c011db58c28577efbab99c961b59f5c.zip
llvm-92a54f6d4c011db58c28577efbab99c961b59f5c.tar.gz
llvm-92a54f6d4c011db58c28577efbab99c961b59f5c.tar.bz2
[SjLj Prepare] When demoting an invoke instructions to the stack, if the normal
edge is critical, then split it so we can insert the store. rdar://13126179 llvm-svn: 174418
Diffstat (limited to 'llvm/lib/Transforms/Utils/DemoteRegToStack.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/DemoteRegToStack.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp b/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
index d5c41f5..db525cd 100644
--- a/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
+++ b/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/Function.h"
@@ -78,12 +79,21 @@ AllocaInst *llvm::DemoteRegToStack(Instruction &I, bool VolatileLoads,
InsertPt = &I;
++InsertPt;
} else {
- // We cannot demote invoke instructions to the stack if their normal edge
- // is critical.
InvokeInst &II = cast<InvokeInst>(I);
- assert(II.getNormalDest()->getSinglePredecessor() &&
- "Cannot demote invoke with a critical successor!");
- InsertPt = II.getNormalDest()->begin();
+ if (II.getNormalDest()->getSinglePredecessor())
+ InsertPt = II.getNormalDest()->getFirstInsertionPt();
+ else {
+ // We cannot demote invoke instructions to the stack if their normal edge
+ // is critical. Therefore, split the critical edge and insert the store
+ // in the newly created basic block.
+ unsigned SuccNum = GetSuccessorNumber(I.getParent(), II.getNormalDest());
+ TerminatorInst *TI = &cast<TerminatorInst>(I);
+ assert (isCriticalEdge(TI, SuccNum) &&
+ "Expected a critical edge!");
+ BasicBlock *BB = SplitCriticalEdge(TI, SuccNum);
+ assert (BB && "Unable to split critical edge.");
+ InsertPt = BB->getFirstInsertionPt();
+ }
}
for (; isa<PHINode>(InsertPt) || isa<LandingPadInst>(InsertPt); ++InsertPt)