From dbdc616ed5eb1c92d75465333b0d96b0185f8c8f Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 14 Dec 2011 02:18:26 +0000 Subject: Revert r146481 to review possible miscompilations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146546 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SjLjEHPrepare.cpp | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) (limited to 'lib/CodeGen/SjLjEHPrepare.cpp') diff --git a/lib/CodeGen/SjLjEHPrepare.cpp b/lib/CodeGen/SjLjEHPrepare.cpp index ac99cca27b..c8651926c2 100644 --- a/lib/CodeGen/SjLjEHPrepare.cpp +++ b/lib/CodeGen/SjLjEHPrepare.cpp @@ -69,8 +69,6 @@ namespace { private: bool setupEntryBlockAndCallSites(Function &F); - void substituteLPadValues(LandingPadInst *LPI, Value *ExnVal, - Value *SelVal, IRBuilder<> &Builder); Value *setupFunctionContext(Function &F, ArrayRef LPads); void lowerIncomingArguments(Function &F); void lowerAcrossUnwindEdges(Function &F, ArrayRef Invokes); @@ -140,36 +138,6 @@ static void MarkBlocksLiveIn(BasicBlock *BB, MarkBlocksLiveIn(*PI, LiveBBs); } -/// substituteLPadValues - Substitute the values returned by the landingpad -/// instruction with those returned by the personality function. -void SjLjEHPass::substituteLPadValues(LandingPadInst *LPI, Value *ExnVal, - Value *SelVal, IRBuilder<> &Builder) { - SmallVector UseWorkList(LPI->use_begin(), LPI->use_end()); - while (!UseWorkList.empty()) { - Value *Val = UseWorkList.pop_back_val(); - ExtractValueInst *EVI = dyn_cast(Val); - if (!EVI) continue; - if (EVI->getNumIndices() != 1) continue; - if (*EVI->idx_begin() == 0) - EVI->replaceAllUsesWith(ExnVal); - else if (*EVI->idx_begin() == 1) - EVI->replaceAllUsesWith(SelVal); - if (EVI->getNumUses() == 0) - EVI->eraseFromParent(); - } - - if (LPI->getNumUses() == 0) return; - - // There are still some uses of LPI. Construct an aggregate with the exception - // values and replace the LPI with that aggregate. - Type *LPadType = LPI->getType(); - Value *LPadVal = UndefValue::get(LPadType); - LPadVal = Builder.CreateInsertValue(LPadVal, ExnVal, 0, "lpad.val"); - LPadVal = Builder.CreateInsertValue(LPadVal, SelVal, 1, "lpad.val"); - - LPI->replaceAllUsesWith(LPadVal); -} - /// setupFunctionContext - Allocate the function context on the stack and fill /// it with all of the data that we know at this point. Value *SjLjEHPass:: @@ -221,7 +189,12 @@ setupFunctionContext(Function &F, ArrayRef LPads) { ExnVal = Builder.CreateIntToPtr(ExnVal, Type::getInt8PtrTy(F.getContext())); Value *SelVal = Builder.CreateLoad(SelectorAddr, true, "exn_selector_val"); - substituteLPadValues(LPI, ExnVal, SelVal, Builder); + Type *LPadType = LPI->getType(); + Value *LPadVal = UndefValue::get(LPadType); + LPadVal = Builder.CreateInsertValue(LPadVal, ExnVal, 0, "lpad.val"); + LPadVal = Builder.CreateInsertValue(LPadVal, SelVal, 1, "lpad.val"); + + LPI->replaceAllUsesWith(LPadVal); } // Personality function -- cgit v1.2.3