mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
CodeGen: Remove implicit ilist iterator conversions, NFC
Finish removing implicit ilist iterator conversions from LLVMCodeGen. I'm sure there are lots more of these in lib/CodeGen/*/. llvm-svn: 249915
This commit is contained in:
parent
b8bce812e5
commit
9b3d2610e4
@ -179,8 +179,8 @@ void SjLjEHPrepare::substituteLPadValues(LandingPadInst *LPI, Value *ExnVal,
|
|||||||
// values and replace the LPI with that aggregate.
|
// values and replace the LPI with that aggregate.
|
||||||
Type *LPadType = LPI->getType();
|
Type *LPadType = LPI->getType();
|
||||||
Value *LPadVal = UndefValue::get(LPadType);
|
Value *LPadVal = UndefValue::get(LPadType);
|
||||||
IRBuilder<> Builder(
|
auto *SelI = cast<Instruction>(SelVal);
|
||||||
std::next(BasicBlock::iterator(cast<Instruction>(SelVal))));
|
IRBuilder<> Builder(SelI->getParent(), std::next(SelI->getIterator()));
|
||||||
LPadVal = Builder.CreateInsertValue(LPadVal, ExnVal, 0, "lpad.val");
|
LPadVal = Builder.CreateInsertValue(LPadVal, ExnVal, 0, "lpad.val");
|
||||||
LPadVal = Builder.CreateInsertValue(LPadVal, SelVal, 1, "lpad.val");
|
LPadVal = Builder.CreateInsertValue(LPadVal, SelVal, 1, "lpad.val");
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ void SjLjEHPrepare::substituteLPadValues(LandingPadInst *LPI, Value *ExnVal,
|
|||||||
/// 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 *SjLjEHPrepare::setupFunctionContext(Function &F,
|
Value *SjLjEHPrepare::setupFunctionContext(Function &F,
|
||||||
ArrayRef<LandingPadInst *> LPads) {
|
ArrayRef<LandingPadInst *> LPads) {
|
||||||
BasicBlock *EntryBB = F.begin();
|
BasicBlock *EntryBB = &F.front();
|
||||||
|
|
||||||
// Create an alloca for the incoming jump buffer ptr and the new jump buffer
|
// Create an alloca for the incoming jump buffer ptr and the new jump buffer
|
||||||
// that needs to be restored on all exits from the function. This is an alloca
|
// that needs to be restored on all exits from the function. This is an alloca
|
||||||
@ -199,12 +199,13 @@ Value *SjLjEHPrepare::setupFunctionContext(Function &F,
|
|||||||
auto &DL = F.getParent()->getDataLayout();
|
auto &DL = F.getParent()->getDataLayout();
|
||||||
unsigned Align = DL.getPrefTypeAlignment(FunctionContextTy);
|
unsigned Align = DL.getPrefTypeAlignment(FunctionContextTy);
|
||||||
FuncCtx = new AllocaInst(FunctionContextTy, nullptr, Align, "fn_context",
|
FuncCtx = new AllocaInst(FunctionContextTy, nullptr, Align, "fn_context",
|
||||||
EntryBB->begin());
|
&EntryBB->front());
|
||||||
|
|
||||||
// Fill in the function context structure.
|
// Fill in the function context structure.
|
||||||
for (unsigned I = 0, E = LPads.size(); I != E; ++I) {
|
for (unsigned I = 0, E = LPads.size(); I != E; ++I) {
|
||||||
LandingPadInst *LPI = LPads[I];
|
LandingPadInst *LPI = LPads[I];
|
||||||
IRBuilder<> Builder(LPI->getParent()->getFirstInsertionPt());
|
IRBuilder<> Builder(LPI->getParent(),
|
||||||
|
LPI->getParent()->getFirstInsertionPt());
|
||||||
|
|
||||||
// Reference the __data field.
|
// Reference the __data field.
|
||||||
Value *FCData =
|
Value *FCData =
|
||||||
@ -251,21 +252,20 @@ void SjLjEHPrepare::lowerIncomingArguments(Function &F) {
|
|||||||
while (isa<AllocaInst>(AfterAllocaInsPt) &&
|
while (isa<AllocaInst>(AfterAllocaInsPt) &&
|
||||||
isa<ConstantInt>(cast<AllocaInst>(AfterAllocaInsPt)->getArraySize()))
|
isa<ConstantInt>(cast<AllocaInst>(AfterAllocaInsPt)->getArraySize()))
|
||||||
++AfterAllocaInsPt;
|
++AfterAllocaInsPt;
|
||||||
|
assert(AfterAllocaInsPt != F.front().end());
|
||||||
|
|
||||||
for (Function::arg_iterator AI = F.arg_begin(), AE = F.arg_end(); AI != AE;
|
for (auto &AI : F.args()) {
|
||||||
++AI) {
|
Type *Ty = AI.getType();
|
||||||
Type *Ty = AI->getType();
|
|
||||||
|
|
||||||
// Use 'select i8 true, %arg, undef' to simulate a 'no-op' instruction.
|
// Use 'select i8 true, %arg, undef' to simulate a 'no-op' instruction.
|
||||||
Value *TrueValue = ConstantInt::getTrue(F.getContext());
|
Value *TrueValue = ConstantInt::getTrue(F.getContext());
|
||||||
Value *UndefValue = UndefValue::get(Ty);
|
Value *UndefValue = UndefValue::get(Ty);
|
||||||
Instruction *SI = SelectInst::Create(TrueValue, AI, UndefValue,
|
Instruction *SI = SelectInst::Create(
|
||||||
AI->getName() + ".tmp",
|
TrueValue, &AI, UndefValue, AI.getName() + ".tmp", &*AfterAllocaInsPt);
|
||||||
AfterAllocaInsPt);
|
AI.replaceAllUsesWith(SI);
|
||||||
AI->replaceAllUsesWith(SI);
|
|
||||||
|
|
||||||
// Reset the operand, because it was clobbered by the RAUW above.
|
// Reset the operand, because it was clobbered by the RAUW above.
|
||||||
SI->setOperand(1, AI);
|
SI->setOperand(1, &AI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ void SjLjEHPrepare::lowerAcrossUnwindEdges(Function &F,
|
|||||||
// Ignore obvious cases we don't have to handle. In particular, most
|
// Ignore obvious cases we don't have to handle. In particular, most
|
||||||
// instructions either have no uses or only have a single use inside the
|
// instructions either have no uses or only have a single use inside the
|
||||||
// current block. Ignore them quickly.
|
// current block. Ignore them quickly.
|
||||||
Instruction *Inst = II;
|
Instruction *Inst = &*II;
|
||||||
if (Inst->use_empty())
|
if (Inst->use_empty())
|
||||||
continue;
|
continue;
|
||||||
if (Inst->hasOneUse() &&
|
if (Inst->hasOneUse() &&
|
||||||
@ -361,7 +361,7 @@ void SjLjEHPrepare::lowerAcrossUnwindEdges(Function &F,
|
|||||||
DemotePHIToStack(PN);
|
DemotePHIToStack(PN);
|
||||||
|
|
||||||
// Move the landingpad instruction back to the top of the landing pad block.
|
// Move the landingpad instruction back to the top of the landing pad block.
|
||||||
LPI->moveBefore(UnwindBlock->begin());
|
LPI->moveBefore(&UnwindBlock->front());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ bool SjLjEHPrepare::setupEntryBlockAndCallSites(Function &F) {
|
|||||||
|
|
||||||
Value *FuncCtx =
|
Value *FuncCtx =
|
||||||
setupFunctionContext(F, makeArrayRef(LPads.begin(), LPads.end()));
|
setupFunctionContext(F, makeArrayRef(LPads.begin(), LPads.end()));
|
||||||
BasicBlock *EntryBB = F.begin();
|
BasicBlock *EntryBB = &F.front();
|
||||||
IRBuilder<> Builder(EntryBB->getTerminator());
|
IRBuilder<> Builder(EntryBB->getTerminator());
|
||||||
|
|
||||||
// Get a reference to the jump buffer.
|
// Get a reference to the jump buffer.
|
||||||
@ -475,7 +475,7 @@ bool SjLjEHPrepare::setupEntryBlockAndCallSites(Function &F) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Instruction *StackAddr = CallInst::Create(StackAddrFn, "sp");
|
Instruction *StackAddr = CallInst::Create(StackAddrFn, "sp");
|
||||||
StackAddr->insertAfter(I);
|
StackAddr->insertAfter(&*I);
|
||||||
Instruction *StoreStackAddr = new StoreInst(StackAddr, StackPtr, true);
|
Instruction *StoreStackAddr = new StoreInst(StackAddr, StackPtr, true);
|
||||||
StoreStackAddr->insertAfter(StackAddr);
|
StoreStackAddr->insertAfter(StackAddr);
|
||||||
}
|
}
|
||||||
|
@ -187,9 +187,9 @@ bool SpillPlacement::runOnMachineFunction(MachineFunction &mf) {
|
|||||||
BlockFrequencies.resize(mf.getNumBlockIDs());
|
BlockFrequencies.resize(mf.getNumBlockIDs());
|
||||||
MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
|
MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
|
||||||
setThreshold(MBFI->getEntryFreq());
|
setThreshold(MBFI->getEntryFreq());
|
||||||
for (MachineFunction::iterator I = mf.begin(), E = mf.end(); I != E; ++I) {
|
for (auto &I : mf) {
|
||||||
unsigned Num = I->getNumber();
|
unsigned Num = I.getNumber();
|
||||||
BlockFrequencies[Num] = MBFI->getBlockFreq(I);
|
BlockFrequencies[Num] = MBFI->getBlockFreq(&I);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We never change the function.
|
// We never change the function.
|
||||||
|
@ -177,10 +177,11 @@ bool SplitAnalysis::calcLiveBlockInfo() {
|
|||||||
UseE = UseSlots.end();
|
UseE = UseSlots.end();
|
||||||
|
|
||||||
// Loop over basic blocks where CurLI is live.
|
// Loop over basic blocks where CurLI is live.
|
||||||
MachineFunction::iterator MFI = LIS.getMBBFromIndex(LVI->start);
|
MachineFunction::iterator MFI =
|
||||||
|
LIS.getMBBFromIndex(LVI->start)->getIterator();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
BlockInfo BI;
|
BlockInfo BI;
|
||||||
BI.MBB = MFI;
|
BI.MBB = &*MFI;
|
||||||
SlotIndex Start, Stop;
|
SlotIndex Start, Stop;
|
||||||
std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB);
|
std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB);
|
||||||
|
|
||||||
@ -260,7 +261,7 @@ bool SplitAnalysis::calcLiveBlockInfo() {
|
|||||||
if (LVI->start < Stop)
|
if (LVI->start < Stop)
|
||||||
++MFI;
|
++MFI;
|
||||||
else
|
else
|
||||||
MFI = LIS.getMBBFromIndex(LVI->start);
|
MFI = LIS.getMBBFromIndex(LVI->start)->getIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(getNumLiveBlocks() == countLiveBlocks(CurLI) && "Bad block count");
|
assert(getNumLiveBlocks() == countLiveBlocks(CurLI) && "Bad block count");
|
||||||
@ -276,8 +277,9 @@ unsigned SplitAnalysis::countLiveBlocks(const LiveInterval *cli) const {
|
|||||||
unsigned Count = 0;
|
unsigned Count = 0;
|
||||||
|
|
||||||
// Loop over basic blocks where li is live.
|
// Loop over basic blocks where li is live.
|
||||||
MachineFunction::const_iterator MFI = LIS.getMBBFromIndex(LVI->start);
|
MachineFunction::const_iterator MFI =
|
||||||
SlotIndex Stop = LIS.getMBBEndIdx(MFI);
|
LIS.getMBBFromIndex(LVI->start)->getIterator();
|
||||||
|
SlotIndex Stop = LIS.getMBBEndIdx(&*MFI);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
++Count;
|
++Count;
|
||||||
LVI = li->advanceTo(LVI, Stop);
|
LVI = li->advanceTo(LVI, Stop);
|
||||||
@ -285,7 +287,7 @@ unsigned SplitAnalysis::countLiveBlocks(const LiveInterval *cli) const {
|
|||||||
return Count;
|
return Count;
|
||||||
do {
|
do {
|
||||||
++MFI;
|
++MFI;
|
||||||
Stop = LIS.getMBBEndIdx(MFI);
|
Stop = LIS.getMBBEndIdx(&*MFI);
|
||||||
} while (Stop <= LVI->start);
|
} while (Stop <= LVI->start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -865,9 +867,9 @@ bool SplitEditor::transferValues() {
|
|||||||
// This value has multiple defs in RegIdx, but it wasn't rematerialized,
|
// This value has multiple defs in RegIdx, but it wasn't rematerialized,
|
||||||
// so the live range is accurate. Add live-in blocks in [Start;End) to the
|
// so the live range is accurate. Add live-in blocks in [Start;End) to the
|
||||||
// LiveInBlocks.
|
// LiveInBlocks.
|
||||||
MachineFunction::iterator MBB = LIS.getMBBFromIndex(Start);
|
MachineFunction::iterator MBB = LIS.getMBBFromIndex(Start)->getIterator();
|
||||||
SlotIndex BlockStart, BlockEnd;
|
SlotIndex BlockStart, BlockEnd;
|
||||||
std::tie(BlockStart, BlockEnd) = LIS.getSlotIndexes()->getMBBRange(MBB);
|
std::tie(BlockStart, BlockEnd) = LIS.getSlotIndexes()->getMBBRange(&*MBB);
|
||||||
|
|
||||||
// The first block may be live-in, or it may have its own def.
|
// The first block may be live-in, or it may have its own def.
|
||||||
if (Start != BlockStart) {
|
if (Start != BlockStart) {
|
||||||
@ -876,7 +878,7 @@ bool SplitEditor::transferValues() {
|
|||||||
DEBUG(dbgs() << ':' << VNI->id << "*BB#" << MBB->getNumber());
|
DEBUG(dbgs() << ':' << VNI->id << "*BB#" << MBB->getNumber());
|
||||||
// MBB has its own def. Is it also live-out?
|
// MBB has its own def. Is it also live-out?
|
||||||
if (BlockEnd <= End)
|
if (BlockEnd <= End)
|
||||||
LRC.setLiveOutValue(MBB, VNI);
|
LRC.setLiveOutValue(&*MBB, VNI);
|
||||||
|
|
||||||
// Skip to the next block for live-in.
|
// Skip to the next block for live-in.
|
||||||
++MBB;
|
++MBB;
|
||||||
@ -887,23 +889,23 @@ bool SplitEditor::transferValues() {
|
|||||||
assert(Start <= BlockStart && "Expected live-in block");
|
assert(Start <= BlockStart && "Expected live-in block");
|
||||||
while (BlockStart < End) {
|
while (BlockStart < End) {
|
||||||
DEBUG(dbgs() << ">BB#" << MBB->getNumber());
|
DEBUG(dbgs() << ">BB#" << MBB->getNumber());
|
||||||
BlockEnd = LIS.getMBBEndIdx(MBB);
|
BlockEnd = LIS.getMBBEndIdx(&*MBB);
|
||||||
if (BlockStart == ParentVNI->def) {
|
if (BlockStart == ParentVNI->def) {
|
||||||
// This block has the def of a parent PHI, so it isn't live-in.
|
// This block has the def of a parent PHI, so it isn't live-in.
|
||||||
assert(ParentVNI->isPHIDef() && "Non-phi defined at block start?");
|
assert(ParentVNI->isPHIDef() && "Non-phi defined at block start?");
|
||||||
VNInfo *VNI = LR.extendInBlock(BlockStart, std::min(BlockEnd, End));
|
VNInfo *VNI = LR.extendInBlock(BlockStart, std::min(BlockEnd, End));
|
||||||
assert(VNI && "Missing def for complex mapped parent PHI");
|
assert(VNI && "Missing def for complex mapped parent PHI");
|
||||||
if (End >= BlockEnd)
|
if (End >= BlockEnd)
|
||||||
LRC.setLiveOutValue(MBB, VNI); // Live-out as well.
|
LRC.setLiveOutValue(&*MBB, VNI); // Live-out as well.
|
||||||
} else {
|
} else {
|
||||||
// This block needs a live-in value. The last block covered may not
|
// This block needs a live-in value. The last block covered may not
|
||||||
// be live-out.
|
// be live-out.
|
||||||
if (End < BlockEnd)
|
if (End < BlockEnd)
|
||||||
LRC.addLiveInBlock(LR, MDT[MBB], End);
|
LRC.addLiveInBlock(LR, MDT[&*MBB], End);
|
||||||
else {
|
else {
|
||||||
// Live-through, and we don't know the value.
|
// Live-through, and we don't know the value.
|
||||||
LRC.addLiveInBlock(LR, MDT[MBB]);
|
LRC.addLiveInBlock(LR, MDT[&*MBB]);
|
||||||
LRC.setLiveOutValue(MBB, nullptr);
|
LRC.setLiveOutValue(&*MBB, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BlockStart = BlockEnd;
|
BlockStart = BlockEnd;
|
||||||
|
@ -373,7 +373,7 @@ bool StackProtector::InsertStackProtectors() {
|
|||||||
Value *StackGuardVar = nullptr; // The stack guard variable.
|
Value *StackGuardVar = nullptr; // The stack guard variable.
|
||||||
|
|
||||||
for (Function::iterator I = F->begin(), E = F->end(); I != E;) {
|
for (Function::iterator I = F->begin(), E = F->end(); I != E;) {
|
||||||
BasicBlock *BB = I++;
|
BasicBlock *BB = &*I++;
|
||||||
ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator());
|
ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator());
|
||||||
if (!RI)
|
if (!RI)
|
||||||
continue;
|
continue;
|
||||||
@ -433,7 +433,7 @@ bool StackProtector::InsertStackProtectors() {
|
|||||||
BasicBlock *FailBB = CreateFailBB();
|
BasicBlock *FailBB = CreateFailBB();
|
||||||
|
|
||||||
// Split the basic block before the return instruction.
|
// Split the basic block before the return instruction.
|
||||||
BasicBlock *NewBB = BB->splitBasicBlock(RI, "SP_return");
|
BasicBlock *NewBB = BB->splitBasicBlock(RI->getIterator(), "SP_return");
|
||||||
|
|
||||||
// Update the dominator tree if we need to.
|
// Update the dominator tree if we need to.
|
||||||
if (DT && DT->isReachableFromEntry(BB)) {
|
if (DT && DT->isReachableFromEntry(BB)) {
|
||||||
|
@ -161,7 +161,7 @@ void TailDuplicatePass::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
|
|
||||||
static void VerifyPHIs(MachineFunction &MF, bool CheckExtra) {
|
static void VerifyPHIs(MachineFunction &MF, bool CheckExtra) {
|
||||||
for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ++I) {
|
for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ++I) {
|
||||||
MachineBasicBlock *MBB = I;
|
MachineBasicBlock *MBB = &*I;
|
||||||
SmallSetVector<MachineBasicBlock*, 8> Preds(MBB->pred_begin(),
|
SmallSetVector<MachineBasicBlock*, 8> Preds(MBB->pred_begin(),
|
||||||
MBB->pred_end());
|
MBB->pred_end());
|
||||||
MachineBasicBlock::iterator MI = MBB->begin();
|
MachineBasicBlock::iterator MI = MBB->begin();
|
||||||
@ -322,7 +322,7 @@ bool TailDuplicatePass::TailDuplicateBlocks(MachineFunction &MF) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) {
|
for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) {
|
||||||
MachineBasicBlock *MBB = I++;
|
MachineBasicBlock *MBB = &*I++;
|
||||||
|
|
||||||
if (NumTails == TailDupLimit)
|
if (NumTails == TailDupLimit)
|
||||||
break;
|
break;
|
||||||
@ -689,7 +689,7 @@ TailDuplicatePass::duplicateSimpleBB(MachineBasicBlock *TailBB,
|
|||||||
<< "From simple Succ: " << *TailBB);
|
<< "From simple Succ: " << *TailBB);
|
||||||
|
|
||||||
MachineBasicBlock *NewTarget = *TailBB->succ_begin();
|
MachineBasicBlock *NewTarget = *TailBB->succ_begin();
|
||||||
MachineBasicBlock *NextBB = std::next(MachineFunction::iterator(PredBB));
|
MachineBasicBlock *NextBB = &*std::next(PredBB->getIterator());
|
||||||
|
|
||||||
// Make PredFBB explicit.
|
// Make PredFBB explicit.
|
||||||
if (PredCond.empty())
|
if (PredCond.empty())
|
||||||
@ -846,7 +846,7 @@ TailDuplicatePass::TailDuplicate(MachineBasicBlock *TailBB,
|
|||||||
// If TailBB was duplicated into all its predecessors except for the prior
|
// If TailBB was duplicated into all its predecessors except for the prior
|
||||||
// block, which falls through unconditionally, move the contents of this
|
// block, which falls through unconditionally, move the contents of this
|
||||||
// block into the prior block.
|
// block into the prior block.
|
||||||
MachineBasicBlock *PrevBB = std::prev(MachineFunction::iterator(TailBB));
|
MachineBasicBlock *PrevBB = &*std::prev(TailBB->getIterator());
|
||||||
MachineBasicBlock *PriorTBB = nullptr, *PriorFBB = nullptr;
|
MachineBasicBlock *PriorTBB = nullptr, *PriorFBB = nullptr;
|
||||||
SmallVector<MachineOperand, 4> PriorCond;
|
SmallVector<MachineOperand, 4> PriorCond;
|
||||||
// This has to check PrevBB->succ_size() because EH edges are ignored by
|
// This has to check PrevBB->succ_size() because EH edges are ignored by
|
||||||
|
@ -699,9 +699,10 @@ TwoAddressInstructionPass::convertInstTo3Addr(MachineBasicBlock::iterator &mi,
|
|||||||
unsigned RegA, unsigned RegB,
|
unsigned RegA, unsigned RegB,
|
||||||
unsigned Dist) {
|
unsigned Dist) {
|
||||||
// FIXME: Why does convertToThreeAddress() need an iterator reference?
|
// FIXME: Why does convertToThreeAddress() need an iterator reference?
|
||||||
MachineFunction::iterator MFI = MBB;
|
MachineFunction::iterator MFI = MBB->getIterator();
|
||||||
MachineInstr *NewMI = TII->convertToThreeAddress(MFI, mi, LV);
|
MachineInstr *NewMI = TII->convertToThreeAddress(MFI, mi, LV);
|
||||||
assert(MBB == MFI && "convertToThreeAddress changed iterator reference");
|
assert(MBB->getIterator() == MFI &&
|
||||||
|
"convertToThreeAddress changed iterator reference");
|
||||||
if (!NewMI)
|
if (!NewMI)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1643,7 +1644,7 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &Func) {
|
|||||||
TiedOperandMap TiedOperands;
|
TiedOperandMap TiedOperands;
|
||||||
for (MachineFunction::iterator MBBI = MF->begin(), MBBE = MF->end();
|
for (MachineFunction::iterator MBBI = MF->begin(), MBBE = MF->end();
|
||||||
MBBI != MBBE; ++MBBI) {
|
MBBI != MBBE; ++MBBI) {
|
||||||
MBB = MBBI;
|
MBB = &*MBBI;
|
||||||
unsigned Dist = 0;
|
unsigned Dist = 0;
|
||||||
DistanceMap.clear();
|
DistanceMap.clear();
|
||||||
SrcRegMap.clear();
|
SrcRegMap.clear();
|
||||||
|
@ -71,8 +71,8 @@ bool UnreachableBlockElim::runOnFunction(Function &F) {
|
|||||||
// in them.
|
// in them.
|
||||||
std::vector<BasicBlock*> DeadBlocks;
|
std::vector<BasicBlock*> DeadBlocks;
|
||||||
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
|
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
|
||||||
if (!Reachable.count(I)) {
|
if (!Reachable.count(&*I)) {
|
||||||
BasicBlock *BB = I;
|
BasicBlock *BB = &*I;
|
||||||
DeadBlocks.push_back(BB);
|
DeadBlocks.push_back(BB);
|
||||||
while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) {
|
while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) {
|
||||||
PN->replaceAllUsesWith(Constant::getNullValue(PN->getType()));
|
PN->replaceAllUsesWith(Constant::getNullValue(PN->getType()));
|
||||||
@ -131,7 +131,7 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
|
|||||||
// in them.
|
// in them.
|
||||||
std::vector<MachineBasicBlock*> DeadBlocks;
|
std::vector<MachineBasicBlock*> DeadBlocks;
|
||||||
for (MachineFunction::iterator I = F.begin(), E = F.end(); I != E; ++I) {
|
for (MachineFunction::iterator I = F.begin(), E = F.end(); I != E; ++I) {
|
||||||
MachineBasicBlock *BB = I;
|
MachineBasicBlock *BB = &*I;
|
||||||
|
|
||||||
// Test for deadness.
|
// Test for deadness.
|
||||||
if (!Reachable.count(BB)) {
|
if (!Reachable.count(BB)) {
|
||||||
@ -167,7 +167,7 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
|
|||||||
|
|
||||||
// Cleanup PHI nodes.
|
// Cleanup PHI nodes.
|
||||||
for (MachineFunction::iterator I = F.begin(), E = F.end(); I != E; ++I) {
|
for (MachineFunction::iterator I = F.begin(), E = F.end(); I != E; ++I) {
|
||||||
MachineBasicBlock *BB = I;
|
MachineBasicBlock *BB = &*I;
|
||||||
// Prune unneeded PHI entries.
|
// Prune unneeded PHI entries.
|
||||||
SmallPtrSet<MachineBasicBlock*, 8> preds(BB->pred_begin(),
|
SmallPtrSet<MachineBasicBlock*, 8> preds(BB->pred_begin(),
|
||||||
BB->pred_end());
|
BB->pred_end());
|
||||||
|
@ -355,7 +355,7 @@ void VirtRegRewriter::rewrite() {
|
|||||||
DEBUG(MBBI->print(dbgs(), Indexes));
|
DEBUG(MBBI->print(dbgs(), Indexes));
|
||||||
for (MachineBasicBlock::instr_iterator
|
for (MachineBasicBlock::instr_iterator
|
||||||
MII = MBBI->instr_begin(), MIE = MBBI->instr_end(); MII != MIE;) {
|
MII = MBBI->instr_begin(), MIE = MBBI->instr_end(); MII != MIE;) {
|
||||||
MachineInstr *MI = MII;
|
MachineInstr *MI = &*MII;
|
||||||
++MII;
|
++MII;
|
||||||
|
|
||||||
for (MachineInstr::mop_iterator MOI = MI->operands_begin(),
|
for (MachineInstr::mop_iterator MOI = MI->operands_begin(),
|
||||||
|
@ -541,7 +541,7 @@ static Instruction *findBeginCatchSplitPoint(BasicBlock *BB,
|
|||||||
void WinEHPrepare::findCXXEHReturnPoints(
|
void WinEHPrepare::findCXXEHReturnPoints(
|
||||||
Function &F, SetVector<BasicBlock *> &EHReturnBlocks) {
|
Function &F, SetVector<BasicBlock *> &EHReturnBlocks) {
|
||||||
for (auto BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI) {
|
for (auto BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI) {
|
||||||
BasicBlock *BB = BBI;
|
BasicBlock *BB = &*BBI;
|
||||||
for (Instruction &I : *BB) {
|
for (Instruction &I : *BB) {
|
||||||
if (match(&I, m_Intrinsic<Intrinsic::eh_begincatch>())) {
|
if (match(&I, m_Intrinsic<Intrinsic::eh_begincatch>())) {
|
||||||
Instruction *SplitPt =
|
Instruction *SplitPt =
|
||||||
@ -564,7 +564,7 @@ void WinEHPrepare::findCXXEHReturnPoints(
|
|||||||
isa<PHINode>(Br->getSuccessor(0)->begin())) {
|
isa<PHINode>(Br->getSuccessor(0)->begin())) {
|
||||||
DEBUG(dbgs() << "splitting block " << BB->getName()
|
DEBUG(dbgs() << "splitting block " << BB->getName()
|
||||||
<< " with llvm.eh.endcatch\n");
|
<< " with llvm.eh.endcatch\n");
|
||||||
BBI = SplitBlock(BB, I.getNextNode(), DT);
|
BBI = SplitBlock(BB, I.getNextNode(), DT)->getIterator();
|
||||||
}
|
}
|
||||||
// The next BB is normal control flow.
|
// The next BB is normal control flow.
|
||||||
EHReturnBlocks.insert(BB->getTerminator()->getSuccessor(0));
|
EHReturnBlocks.insert(BB->getTerminator()->getSuccessor(0));
|
||||||
@ -588,7 +588,7 @@ static bool isCatchAllLandingPad(const BasicBlock *BB) {
|
|||||||
void WinEHPrepare::findSEHEHReturnPoints(
|
void WinEHPrepare::findSEHEHReturnPoints(
|
||||||
Function &F, SetVector<BasicBlock *> &EHReturnBlocks) {
|
Function &F, SetVector<BasicBlock *> &EHReturnBlocks) {
|
||||||
for (auto BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI) {
|
for (auto BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI) {
|
||||||
BasicBlock *BB = BBI;
|
BasicBlock *BB = &*BBI;
|
||||||
// If the landingpad is a catch-all, treat the whole lpad as if it is
|
// If the landingpad is a catch-all, treat the whole lpad as if it is
|
||||||
// reachable from normal control flow.
|
// reachable from normal control flow.
|
||||||
// FIXME: This is imprecise. We need a better way of identifying where a
|
// FIXME: This is imprecise. We need a better way of identifying where a
|
||||||
@ -608,8 +608,9 @@ void WinEHPrepare::findSEHEHReturnPoints(
|
|||||||
if (!CatchHandler->getSinglePredecessor()) {
|
if (!CatchHandler->getSinglePredecessor()) {
|
||||||
DEBUG(dbgs() << "splitting EH return edge from " << BB->getName()
|
DEBUG(dbgs() << "splitting EH return edge from " << BB->getName()
|
||||||
<< " to " << CatchHandler->getName() << '\n');
|
<< " to " << CatchHandler->getName() << '\n');
|
||||||
BBI = CatchHandler = SplitCriticalEdge(
|
CatchHandler = SplitCriticalEdge(
|
||||||
BB, std::find(succ_begin(BB), succ_end(BB), CatchHandler));
|
BB, std::find(succ_begin(BB), succ_end(BB), CatchHandler));
|
||||||
|
BBI = CatchHandler->getIterator();
|
||||||
}
|
}
|
||||||
EHReturnBlocks.insert(CatchHandler);
|
EHReturnBlocks.insert(CatchHandler);
|
||||||
}
|
}
|
||||||
@ -759,7 +760,7 @@ void WinEHPrepare::demoteValuesLiveAcrossHandlers(
|
|||||||
// FIXME: This demotion is inefficient. We should insert spills at the point
|
// FIXME: This demotion is inefficient. We should insert spills at the point
|
||||||
// of definition, insert one reload in each handler that uses the value, and
|
// of definition, insert one reload in each handler that uses the value, and
|
||||||
// insert reloads in the BB used to rejoin normal control flow.
|
// insert reloads in the BB used to rejoin normal control flow.
|
||||||
Instruction *AllocaInsertPt = F.getEntryBlock().getFirstInsertionPt();
|
Instruction *AllocaInsertPt = &*F.getEntryBlock().getFirstInsertionPt();
|
||||||
for (Instruction *I : InstrsToDemote)
|
for (Instruction *I : InstrsToDemote)
|
||||||
DemoteRegToStack(*I, false, AllocaInsertPt);
|
DemoteRegToStack(*I, false, AllocaInsertPt);
|
||||||
|
|
||||||
@ -822,7 +823,7 @@ bool WinEHPrepare::prepareExceptionHandlers(
|
|||||||
// FIXME: Switch the ehptr type to i32 and then switch this.
|
// FIXME: Switch the ehptr type to i32 and then switch this.
|
||||||
SEHExceptionCodeSlot =
|
SEHExceptionCodeSlot =
|
||||||
new AllocaInst(Int8PtrType, nullptr, "seh_exception_code",
|
new AllocaInst(Int8PtrType, nullptr, "seh_exception_code",
|
||||||
F.getEntryBlock().getFirstInsertionPt());
|
&*F.getEntryBlock().getFirstInsertionPt());
|
||||||
}
|
}
|
||||||
|
|
||||||
// In order to handle the case where one outlined catch handler returns
|
// In order to handle the case where one outlined catch handler returns
|
||||||
@ -1042,7 +1043,7 @@ bool WinEHPrepare::prepareExceptionHandlers(
|
|||||||
|
|
||||||
BasicBlock *Entry = &F.getEntryBlock();
|
BasicBlock *Entry = &F.getEntryBlock();
|
||||||
IRBuilder<> Builder(F.getParent()->getContext());
|
IRBuilder<> Builder(F.getParent()->getContext());
|
||||||
Builder.SetInsertPoint(Entry->getFirstInsertionPt());
|
Builder.SetInsertPoint(Entry, Entry->getFirstInsertionPt());
|
||||||
|
|
||||||
Function *FrameEscapeFn =
|
Function *FrameEscapeFn =
|
||||||
Intrinsic::getDeclaration(M, Intrinsic::localescape);
|
Intrinsic::getDeclaration(M, Intrinsic::localescape);
|
||||||
@ -1243,10 +1244,10 @@ void WinEHPrepare::completeNestedLandingPad(Function *ParentFn,
|
|||||||
// and remap return instructions in the nested handlers that should return
|
// and remap return instructions in the nested handlers that should return
|
||||||
// to an address in the outlined handler.
|
// to an address in the outlined handler.
|
||||||
Function *OutlinedHandlerFn = OutlinedBB->getParent();
|
Function *OutlinedHandlerFn = OutlinedBB->getParent();
|
||||||
BasicBlock::const_iterator II = OriginalLPad;
|
BasicBlock::const_iterator II = OriginalLPad->getIterator();
|
||||||
++II;
|
++II;
|
||||||
// The instruction after the landing pad should now be a call to eh.actions.
|
// The instruction after the landing pad should now be a call to eh.actions.
|
||||||
const Instruction *Recover = II;
|
const Instruction *Recover = &*II;
|
||||||
const IntrinsicInst *EHActions = cast<IntrinsicInst>(Recover);
|
const IntrinsicInst *EHActions = cast<IntrinsicInst>(Recover);
|
||||||
|
|
||||||
// Remap the return target in the nested handler.
|
// Remap the return target in the nested handler.
|
||||||
@ -1349,7 +1350,8 @@ static bool isSelectorDispatch(BasicBlock *BB, BasicBlock *&CatchHandler,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool isCatchBlock(BasicBlock *BB) {
|
static bool isCatchBlock(BasicBlock *BB) {
|
||||||
for (BasicBlock::iterator II = BB->getFirstNonPHIOrDbg(), IE = BB->end();
|
for (BasicBlock::iterator II = BB->getFirstNonPHIOrDbg()->getIterator(),
|
||||||
|
IE = BB->end();
|
||||||
II != IE; ++II) {
|
II != IE; ++II) {
|
||||||
if (match(cast<Value>(II), m_Intrinsic<Intrinsic::eh_begincatch>()))
|
if (match(cast<Value>(II), m_Intrinsic<Intrinsic::eh_begincatch>()))
|
||||||
return true;
|
return true;
|
||||||
@ -1533,7 +1535,7 @@ bool WinEHPrepare::outlineHandler(ActionHandler *Action, Function *SrcFn,
|
|||||||
// Skip over PHIs and, if applicable, landingpad instructions.
|
// Skip over PHIs and, if applicable, landingpad instructions.
|
||||||
II = StartBB->getFirstInsertionPt();
|
II = StartBB->getFirstInsertionPt();
|
||||||
|
|
||||||
CloneAndPruneIntoFromInst(Handler, SrcFn, II, VMap,
|
CloneAndPruneIntoFromInst(Handler, SrcFn, &*II, VMap,
|
||||||
/*ModuleLevelChanges=*/false, Returns, "",
|
/*ModuleLevelChanges=*/false, Returns, "",
|
||||||
&OutlinedFunctionInfo, Director.get());
|
&OutlinedFunctionInfo, Director.get());
|
||||||
|
|
||||||
@ -1544,10 +1546,10 @@ bool WinEHPrepare::outlineHandler(ActionHandler *Action, Function *SrcFn,
|
|||||||
// predecessors. Any other block wouldn't have been cloned if it didn't
|
// predecessors. Any other block wouldn't have been cloned if it didn't
|
||||||
// have a predecessor which was also cloned.
|
// have a predecessor which was also cloned.
|
||||||
Function::iterator ClonedIt = std::next(Function::iterator(Entry));
|
Function::iterator ClonedIt = std::next(Function::iterator(Entry));
|
||||||
while (!pred_empty(ClonedIt))
|
while (!pred_empty(&*ClonedIt))
|
||||||
++ClonedIt;
|
++ClonedIt;
|
||||||
BasicBlock *ClonedEntryBB = ClonedIt;
|
assert(ClonedIt != Entry->getParent()->end());
|
||||||
assert(ClonedEntryBB);
|
BasicBlock *ClonedEntryBB = &*ClonedIt;
|
||||||
Entry->getInstList().splice(Entry->end(), ClonedEntryBB->getInstList());
|
Entry->getInstList().splice(Entry->end(), ClonedEntryBB->getInstList());
|
||||||
ClonedEntryBB->eraseFromParent();
|
ClonedEntryBB->eraseFromParent();
|
||||||
|
|
||||||
@ -1579,7 +1581,8 @@ bool WinEHPrepare::outlineHandler(ActionHandler *Action, Function *SrcFn,
|
|||||||
auto *Branch = dyn_cast<BranchInst>(Pred->getTerminator());
|
auto *Branch = dyn_cast<BranchInst>(Pred->getTerminator());
|
||||||
if (!Branch || !Branch->isUnconditional() || Pred->size() <= 1)
|
if (!Branch || !Branch->isUnconditional() || Pred->size() <= 1)
|
||||||
continue;
|
continue;
|
||||||
BasicBlock::iterator II = const_cast<BranchInst *>(Branch);
|
BasicBlock::iterator II =
|
||||||
|
const_cast<BranchInst *>(Branch)->getIterator();
|
||||||
--II;
|
--II;
|
||||||
if (match(cast<Value>(II), m_Intrinsic<Intrinsic::eh_endcatch>())) {
|
if (match(cast<Value>(II), m_Intrinsic<Intrinsic::eh_endcatch>())) {
|
||||||
// This would indicate that a nested landing pad wants to return
|
// This would indicate that a nested landing pad wants to return
|
||||||
@ -1615,9 +1618,9 @@ void WinEHPrepare::processSEHCatchHandler(CatchHandler *CatchAction,
|
|||||||
} else {
|
} else {
|
||||||
// This must be a catch-all. Split the block after the landingpad.
|
// This must be a catch-all. Split the block after the landingpad.
|
||||||
assert(CatchAction->getSelector()->isNullValue() && "expected catch-all");
|
assert(CatchAction->getSelector()->isNullValue() && "expected catch-all");
|
||||||
HandlerBB = SplitBlock(StartBB, StartBB->getFirstInsertionPt(), DT);
|
HandlerBB = SplitBlock(StartBB, &*StartBB->getFirstInsertionPt(), DT);
|
||||||
}
|
}
|
||||||
IRBuilder<> Builder(HandlerBB->getFirstInsertionPt());
|
IRBuilder<> Builder(&*HandlerBB->getFirstInsertionPt());
|
||||||
Function *EHCodeFn = Intrinsic::getDeclaration(
|
Function *EHCodeFn = Intrinsic::getDeclaration(
|
||||||
StartBB->getParent()->getParent(), Intrinsic::eh_exceptioncode_old);
|
StartBB->getParent()->getParent(), Intrinsic::eh_exceptioncode_old);
|
||||||
Value *Code = Builder.CreateCall(EHCodeFn, {}, "sehcode");
|
Value *Code = Builder.CreateCall(EHCodeFn, {}, "sehcode");
|
||||||
@ -2042,9 +2045,9 @@ WinEHFrameVariableMaterializer::WinEHFrameVariableMaterializer(
|
|||||||
|
|
||||||
// New allocas should be inserted in the entry block, but after the parent FP
|
// New allocas should be inserted in the entry block, but after the parent FP
|
||||||
// is established if it is an instruction.
|
// is established if it is an instruction.
|
||||||
Instruction *InsertPoint = EntryBB->getFirstInsertionPt();
|
BasicBlock::iterator InsertPoint = EntryBB->getFirstInsertionPt();
|
||||||
if (auto *FPInst = dyn_cast<Instruction>(ParentFP))
|
if (auto *FPInst = dyn_cast<Instruction>(ParentFP))
|
||||||
InsertPoint = FPInst->getNextNode();
|
InsertPoint = std::next(FPInst->getIterator());
|
||||||
Builder.SetInsertPoint(EntryBB, InsertPoint);
|
Builder.SetInsertPoint(EntryBB, InsertPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2441,9 +2444,10 @@ void WinEHPrepare::findCleanupHandlers(LandingPadActions &Actions,
|
|||||||
if (!Insert1)
|
if (!Insert1)
|
||||||
return createCleanupHandler(Actions, CleanupHandlerMap, BB);
|
return createCleanupHandler(Actions, CleanupHandlerMap, BB);
|
||||||
}
|
}
|
||||||
for (BasicBlock::iterator II = BB->getFirstNonPHIOrDbg(), IE = BB->end();
|
for (BasicBlock::iterator II = BB->getFirstNonPHIOrDbg()->getIterator(),
|
||||||
|
IE = BB->end();
|
||||||
II != IE; ++II) {
|
II != IE; ++II) {
|
||||||
Instruction *Inst = II;
|
Instruction *Inst = &*II;
|
||||||
if (LPadMap && LPadMap->isLandingPadSpecificInst(Inst))
|
if (LPadMap && LPadMap->isLandingPadSpecificInst(Inst))
|
||||||
continue;
|
continue;
|
||||||
if (Inst == Insert1 || Inst == Insert2 || Inst == Resume)
|
if (Inst == Insert1 || Inst == Insert2 || Inst == Resume)
|
||||||
@ -2465,9 +2469,10 @@ void WinEHPrepare::findCleanupHandlers(LandingPadActions &Actions,
|
|||||||
CmpInst *Compare = dyn_cast<CmpInst>(Branch->getCondition());
|
CmpInst *Compare = dyn_cast<CmpInst>(Branch->getCondition());
|
||||||
if (!Compare || !Compare->isEquality())
|
if (!Compare || !Compare->isEquality())
|
||||||
return createCleanupHandler(Actions, CleanupHandlerMap, BB);
|
return createCleanupHandler(Actions, CleanupHandlerMap, BB);
|
||||||
for (BasicBlock::iterator II = BB->getFirstNonPHIOrDbg(), IE = BB->end();
|
for (BasicBlock::iterator II = BB->getFirstNonPHIOrDbg()->getIterator(),
|
||||||
|
IE = BB->end();
|
||||||
II != IE; ++II) {
|
II != IE; ++II) {
|
||||||
Instruction *Inst = II;
|
Instruction *Inst = &*II;
|
||||||
if (LPadMap && LPadMap->isLandingPadSpecificInst(Inst))
|
if (LPadMap && LPadMap->isLandingPadSpecificInst(Inst))
|
||||||
continue;
|
continue;
|
||||||
if (Inst == Compare || Inst == Branch)
|
if (Inst == Compare || Inst == Branch)
|
||||||
@ -2532,9 +2537,10 @@ void WinEHPrepare::findCleanupHandlers(LandingPadActions &Actions,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Anything else is either a catch block or interesting cleanup code.
|
// Anything else is either a catch block or interesting cleanup code.
|
||||||
for (BasicBlock::iterator II = BB->getFirstNonPHIOrDbg(), IE = BB->end();
|
for (BasicBlock::iterator II = BB->getFirstNonPHIOrDbg()->getIterator(),
|
||||||
|
IE = BB->end();
|
||||||
II != IE; ++II) {
|
II != IE; ++II) {
|
||||||
Instruction *Inst = II;
|
Instruction *Inst = &*II;
|
||||||
if (LPadMap && LPadMap->isLandingPadSpecificInst(Inst))
|
if (LPadMap && LPadMap->isLandingPadSpecificInst(Inst))
|
||||||
continue;
|
continue;
|
||||||
// Unconditional branches fall through to this loop.
|
// Unconditional branches fall through to this loop.
|
||||||
@ -3163,11 +3169,11 @@ void WinEHPrepare::demotePHIsOnFunclets(Function &F) {
|
|||||||
// Strip PHI nodes off of EH pads.
|
// Strip PHI nodes off of EH pads.
|
||||||
SmallVector<PHINode *, 16> PHINodes;
|
SmallVector<PHINode *, 16> PHINodes;
|
||||||
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
|
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
|
||||||
BasicBlock *BB = FI++;
|
BasicBlock *BB = &*FI++;
|
||||||
if (!BB->isEHPad())
|
if (!BB->isEHPad())
|
||||||
continue;
|
continue;
|
||||||
for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) {
|
for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) {
|
||||||
Instruction *I = BI++;
|
Instruction *I = &*BI++;
|
||||||
auto *PN = dyn_cast<PHINode>(I);
|
auto *PN = dyn_cast<PHINode>(I);
|
||||||
// Stop at the first non-PHI.
|
// Stop at the first non-PHI.
|
||||||
if (!PN)
|
if (!PN)
|
||||||
@ -3191,10 +3197,10 @@ void WinEHPrepare::demotePHIsOnFunclets(Function &F) {
|
|||||||
void WinEHPrepare::demoteUsesBetweenFunclets(Function &F) {
|
void WinEHPrepare::demoteUsesBetweenFunclets(Function &F) {
|
||||||
// Turn all inter-funclet uses of a Value into loads and stores.
|
// Turn all inter-funclet uses of a Value into loads and stores.
|
||||||
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
|
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
|
||||||
BasicBlock *BB = FI++;
|
BasicBlock *BB = &*FI++;
|
||||||
std::set<BasicBlock *> &ColorsForBB = BlockColors[BB];
|
std::set<BasicBlock *> &ColorsForBB = BlockColors[BB];
|
||||||
for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) {
|
for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) {
|
||||||
Instruction *I = BI++;
|
Instruction *I = &*BI++;
|
||||||
// Funclets are permitted to use static allocas.
|
// Funclets are permitted to use static allocas.
|
||||||
if (auto *AI = dyn_cast<AllocaInst>(I))
|
if (auto *AI = dyn_cast<AllocaInst>(I))
|
||||||
if (AI->isStaticAlloca())
|
if (AI->isStaticAlloca())
|
||||||
@ -3398,7 +3404,7 @@ void WinEHPrepare::cleanupPreparedFunclets(Function &F) {
|
|||||||
// Clean-up some of the mess we made by removing useles PHI nodes, trivial
|
// Clean-up some of the mess we made by removing useles PHI nodes, trivial
|
||||||
// branches, etc.
|
// branches, etc.
|
||||||
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
|
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
|
||||||
BasicBlock *BB = FI++;
|
BasicBlock *BB = &*FI++;
|
||||||
SimplifyInstructionsInBlock(BB);
|
SimplifyInstructionsInBlock(BB);
|
||||||
ConstantFoldTerminator(BB, /*DeleteDeadConditions=*/true);
|
ConstantFoldTerminator(BB, /*DeleteDeadConditions=*/true);
|
||||||
MergeBlockIntoPredecessor(BB);
|
MergeBlockIntoPredecessor(BB);
|
||||||
@ -3469,9 +3475,9 @@ AllocaInst *WinEHPrepare::insertPHILoads(PHINode *PN, Function &F) {
|
|||||||
// Insert a load in place of the PHI and replace all uses.
|
// Insert a load in place of the PHI and replace all uses.
|
||||||
SpillSlot = new AllocaInst(PN->getType(), nullptr,
|
SpillSlot = new AllocaInst(PN->getType(), nullptr,
|
||||||
Twine(PN->getName(), ".wineh.spillslot"),
|
Twine(PN->getName(), ".wineh.spillslot"),
|
||||||
F.getEntryBlock().begin());
|
&F.getEntryBlock().front());
|
||||||
Value *V = new LoadInst(SpillSlot, Twine(PN->getName(), ".wineh.reload"),
|
Value *V = new LoadInst(SpillSlot, Twine(PN->getName(), ".wineh.reload"),
|
||||||
PHIBlock->getFirstInsertionPt());
|
&*PHIBlock->getFirstInsertionPt());
|
||||||
PN->replaceAllUsesWith(V);
|
PN->replaceAllUsesWith(V);
|
||||||
return SpillSlot;
|
return SpillSlot;
|
||||||
}
|
}
|
||||||
@ -3582,7 +3588,7 @@ void WinEHPrepare::demoteNonlocalUses(Value *V,
|
|||||||
// because we can't insert the store AFTER the terminator instruction.
|
// because we can't insert the store AFTER the terminator instruction.
|
||||||
BasicBlock::iterator InsertPt;
|
BasicBlock::iterator InsertPt;
|
||||||
if (isa<Argument>(V)) {
|
if (isa<Argument>(V)) {
|
||||||
InsertPt = F.getEntryBlock().getTerminator();
|
InsertPt = F.getEntryBlock().getTerminator()->getIterator();
|
||||||
} else if (isa<TerminatorInst>(V)) {
|
} else if (isa<TerminatorInst>(V)) {
|
||||||
auto *II = cast<InvokeInst>(V);
|
auto *II = cast<InvokeInst>(V);
|
||||||
// We cannot demote invoke instructions to the stack if their normal
|
// We cannot demote invoke instructions to the stack if their normal
|
||||||
@ -3602,13 +3608,13 @@ void WinEHPrepare::demoteNonlocalUses(Value *V,
|
|||||||
}
|
}
|
||||||
InsertPt = II->getNormalDest()->getFirstInsertionPt();
|
InsertPt = II->getNormalDest()->getFirstInsertionPt();
|
||||||
} else {
|
} else {
|
||||||
InsertPt = cast<Instruction>(V);
|
InsertPt = cast<Instruction>(V)->getIterator();
|
||||||
++InsertPt;
|
++InsertPt;
|
||||||
// Don't insert before PHI nodes or EH pad instrs.
|
// Don't insert before PHI nodes or EH pad instrs.
|
||||||
for (; isa<PHINode>(InsertPt) || InsertPt->isEHPad(); ++InsertPt)
|
for (; isa<PHINode>(InsertPt) || InsertPt->isEHPad(); ++InsertPt)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
new StoreInst(V, SpillSlot, InsertPt);
|
new StoreInst(V, SpillSlot, &*InsertPt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3619,7 +3625,7 @@ void WinEHPrepare::replaceUseWithLoad(Value *V, Use &U, AllocaInst *&SpillSlot,
|
|||||||
if (!SpillSlot)
|
if (!SpillSlot)
|
||||||
SpillSlot = new AllocaInst(V->getType(), nullptr,
|
SpillSlot = new AllocaInst(V->getType(), nullptr,
|
||||||
Twine(V->getName(), ".wineh.spillslot"),
|
Twine(V->getName(), ".wineh.spillslot"),
|
||||||
F.getEntryBlock().begin());
|
&F.getEntryBlock().front());
|
||||||
|
|
||||||
auto *UsingInst = cast<Instruction>(U.getUser());
|
auto *UsingInst = cast<Instruction>(U.getUser());
|
||||||
if (auto *UsingPHI = dyn_cast<PHINode>(UsingInst)) {
|
if (auto *UsingPHI = dyn_cast<PHINode>(UsingInst)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user