summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-09-24 01:23:51 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-09-24 01:23:51 +0000
commit8685daf23e8da4d2201ee0e1b47f7ca732950eee (patch)
tree35bf16bdf4bb5e1a648cfda288869f1a1a92db98 /llvm/lib
parentc3096249c1563af20cf9d955c68ecc7d5f979079 (diff)
downloadbcm5719-llvm-8685daf23e8da4d2201ee0e1b47f7ca732950eee.tar.gz
bcm5719-llvm-8685daf23e8da4d2201ee0e1b47f7ca732950eee.zip
[safestack] Fix compiler crash in the presence of stack restores.
A use can be emitted before def in a function with stack restore points but no static allocas. llvm-svn: 248455
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Instrumentation/SafeStack.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SafeStack.cpp b/llvm/lib/Transforms/Instrumentation/SafeStack.cpp
index b28ae8fc4a9..d80cf3e650f 100644
--- a/llvm/lib/Transforms/Instrumentation/SafeStack.cpp
+++ b/llvm/lib/Transforms/Instrumentation/SafeStack.cpp
@@ -210,7 +210,7 @@ class SafeStack : public FunctionPass {
/// \returns A local variable in which to maintain the dynamic top of the
/// unsafe stack if needed.
AllocaInst *
- createStackRestorePoints(Function &F,
+ createStackRestorePoints(IRBuilder<> &IRB, Function &F,
ArrayRef<Instruction *> StackRestorePoints,
Value *StaticTop, bool NeedDynamicTop);
@@ -332,16 +332,12 @@ void SafeStack::findInsts(Function &F,
}
AllocaInst *
-SafeStack::createStackRestorePoints(Function &F,
+SafeStack::createStackRestorePoints(IRBuilder<> &IRB, Function &F,
ArrayRef<Instruction *> StackRestorePoints,
Value *StaticTop, bool NeedDynamicTop) {
if (StackRestorePoints.empty())
return nullptr;
- IRBuilder<> IRB(StaticTop
- ? cast<Instruction>(StaticTop)->getNextNode()
- : (Instruction *)F.getEntryBlock().getFirstInsertionPt());
-
// We need the current value of the shadow stack pointer to restore
// after longjmp or exception catching.
@@ -613,7 +609,7 @@ bool SafeStack::runOnFunction(Function &F) {
// FIXME: a better alternative might be to store the unsafe stack pointer
// before setjmp / invoke instructions.
AllocaInst *DynamicTop = createStackRestorePoints(
- F, StackRestorePoints, StaticTop, !DynamicAllocas.empty());
+ IRB, F, StackRestorePoints, StaticTop, !DynamicAllocas.empty());
// Handle dynamic allocas.
moveDynamicAllocasToUnsafeStack(F, UnsafeStackPtr, DynamicTop,
OpenPOWER on IntegriCloud