mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-16 00:33:10 +00:00
Reapply r146481 with a fix to create the Builder value in the correct place and
with the correct iterator. <rdar://problem/10530851> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146600 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c3fc3136a1
commit
69fdcd7f90
@ -69,6 +69,8 @@ namespace {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool setupEntryBlockAndCallSites(Function &F);
|
bool setupEntryBlockAndCallSites(Function &F);
|
||||||
|
void substituteLPadValues(LandingPadInst *LPI, Value *ExnVal,
|
||||||
|
Value *SelVal);
|
||||||
Value *setupFunctionContext(Function &F, ArrayRef<LandingPadInst*> LPads);
|
Value *setupFunctionContext(Function &F, ArrayRef<LandingPadInst*> LPads);
|
||||||
void lowerIncomingArguments(Function &F);
|
void lowerIncomingArguments(Function &F);
|
||||||
void lowerAcrossUnwindEdges(Function &F, ArrayRef<InvokeInst*> Invokes);
|
void lowerAcrossUnwindEdges(Function &F, ArrayRef<InvokeInst*> Invokes);
|
||||||
@ -138,6 +140,38 @@ static void MarkBlocksLiveIn(BasicBlock *BB,
|
|||||||
MarkBlocksLiveIn(*PI, LiveBBs);
|
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) {
|
||||||
|
SmallVector<Value*, 8> UseWorkList(LPI->use_begin(), LPI->use_end());
|
||||||
|
while (!UseWorkList.empty()) {
|
||||||
|
Value *Val = UseWorkList.pop_back_val();
|
||||||
|
ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(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);
|
||||||
|
IRBuilder<>
|
||||||
|
Builder(llvm::next(BasicBlock::iterator(cast<Instruction>(SelVal))));
|
||||||
|
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
|
/// setupFunctionContext - Allocate the function context on the stack and fill
|
||||||
/// it with all of the data that we know at this point.
|
/// it with all of the data that we know at this point.
|
||||||
Value *SjLjEHPass::
|
Value *SjLjEHPass::
|
||||||
@ -189,12 +223,7 @@ setupFunctionContext(Function &F, ArrayRef<LandingPadInst*> LPads) {
|
|||||||
ExnVal = Builder.CreateIntToPtr(ExnVal, Type::getInt8PtrTy(F.getContext()));
|
ExnVal = Builder.CreateIntToPtr(ExnVal, Type::getInt8PtrTy(F.getContext()));
|
||||||
Value *SelVal = Builder.CreateLoad(SelectorAddr, true, "exn_selector_val");
|
Value *SelVal = Builder.CreateLoad(SelectorAddr, true, "exn_selector_val");
|
||||||
|
|
||||||
Type *LPadType = LPI->getType();
|
substituteLPadValues(LPI, ExnVal, SelVal);
|
||||||
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
|
// Personality function
|
||||||
|
Loading…
x
Reference in New Issue
Block a user