diff options
author | Bill Wendling <isanbard@gmail.com> | 2011-09-21 22:14:28 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2011-09-21 22:14:28 +0000 |
commit | 3ca2ad11567f83883ae2719c5fac5afc30c7b3d1 (patch) | |
tree | 7acfc18972ec86d3ff824d2ee1386d1538ea2132 /lib/CodeGen | |
parent | 15c9a1f60c2e9d9cb854d5c0072755be91d1cc96 (diff) | |
download | external_llvm-3ca2ad11567f83883ae2719c5fac5afc30c7b3d1.zip external_llvm-3ca2ad11567f83883ae2719c5fac5afc30c7b3d1.tar.gz external_llvm-3ca2ad11567f83883ae2719c5fac5afc30c7b3d1.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140277 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/ShadowStackGC.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/CodeGen/ShadowStackGC.cpp b/lib/CodeGen/ShadowStackGC.cpp index bccb3b9..e2919d3 100644 --- a/lib/CodeGen/ShadowStackGC.cpp +++ b/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; } } |