summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-09-21 22:14:28 +0000
committerBill Wendling <isanbard@gmail.com>2011-09-21 22:14:28 +0000
commit7b3fc8ee38e7c6d7a9cb980009f900672408619b (patch)
tree1766d4698b8e517f1e7e7271475e73e52a7312c2
parente5e189f669326194d03cb499f906a905c41bd767 (diff)
downloadbcm5719-llvm-7b3fc8ee38e7c6d7a9cb980009f900672408619b.tar.gz
bcm5719-llvm-7b3fc8ee38e7c6d7a9cb980009f900672408619b.zip
Attempt to update the shadow stack GC pass to the new EH model.
This inserts a cleanup landingpad instruction and a resume to mimic the old unwind instruction. llvm-svn: 140277
-rw-r--r--llvm/lib/CodeGen/ShadowStackGC.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/ShadowStackGC.cpp b/llvm/lib/CodeGen/ShadowStackGC.cpp
index bccb3b9927a..e2919d3583c 100644
--- a/llvm/lib/CodeGen/ShadowStackGC.cpp
+++ b/llvm/lib/CodeGen/ShadowStackGC.cpp
@@ -109,7 +109,7 @@ namespace {
State = 1;
case 1:
- // Find all 'return' and 'unwind' instructions.
+ // Find all 'return', 'resume', and 'unwind' instructions.
while (StateBB != StateE) {
BasicBlock *CurBB = StateBB++;
@@ -141,9 +141,21 @@ namespace {
return 0;
// Create a cleanup block.
- BasicBlock *CleanupBB = BasicBlock::Create(F.getContext(),
- CleanupBBName, &F);
- UnwindInst *UI = new UnwindInst(F.getContext(), CleanupBB);
+ LLVMContext &C = F.getContext();
+ BasicBlock *CleanupBB = BasicBlock::Create(C, CleanupBBName, &F);
+ Type *ExnTy = StructType::get(Type::getInt8PtrTy(C),
+ Type::getInt32Ty(C), NULL);
+ // FIXME: Assuming the C++ personality function probably isn't the best
+ // thing in the world.
+ Constant *PersFn =
+ F.getParent()->
+ getOrInsertFunction("__gxx_personality_v0",
+ FunctionType::get(Type::getInt32Ty(C), true));
+ LandingPadInst *LPad = LandingPadInst::Create(ExnTy, PersFn, 1,
+ "cleanup.lpad",
+ CleanupBB);
+ LPad->setCleanup(true);
+ ResumeInst *RI = ResumeInst::Create(LPad, CleanupBB);
// Transform the 'call' instructions into 'invoke's branching to the
// cleanup block. Go in reverse order to make prettier BB names.
@@ -174,7 +186,7 @@ namespace {
delete CI;
}
- Builder.SetInsertPoint(UI->getParent(), UI);
+ Builder.SetInsertPoint(RI->getParent(), RI);
return &Builder;
}
}
OpenPOWER on IntegriCloud