Changeset View
Changeset View
Standalone View
Standalone View
lib/Transforms/Utils/SimplifyCFG.cpp
Show First 20 Lines • Show All 1,521 Lines • ▼ Show 20 Lines | static bool sinkLastInstruction(ArrayRef<BasicBlock*> Blocks) { | ||||
} | } | ||||
// Arbitrarily use I0 as the new "common" instruction; remap its operands | // Arbitrarily use I0 as the new "common" instruction; remap its operands | ||||
// and move it to the start of the successor block. | // and move it to the start of the successor block. | ||||
for (unsigned O = 0, E = I0->getNumOperands(); O != E; ++O) | for (unsigned O = 0, E = I0->getNumOperands(); O != E; ++O) | ||||
I0->getOperandUse(O).set(NewOperands[O]); | I0->getOperandUse(O).set(NewOperands[O]); | ||||
I0->moveBefore(&*BBEnd->getFirstInsertionPt()); | I0->moveBefore(&*BBEnd->getFirstInsertionPt()); | ||||
// Update metadata. | // Update metadata and IR flags. | ||||
for (auto *I : Insts) | for (auto *I : Insts) | ||||
if (I != I0) | if (I != I0) { | ||||
combineMetadataForCSE(I0, I); | combineMetadataForCSE(I0, I); | ||||
I0->andIRFlags(I); | |||||
} | |||||
if (!isa<StoreInst>(I0)) { | if (!isa<StoreInst>(I0)) { | ||||
// canSinkLastInstruction checked that all instructions were used by | // canSinkLastInstruction checked that all instructions were used by | ||||
// one and only one PHI node. Find that now, RAUW it to our common | // one and only one PHI node. Find that now, RAUW it to our common | ||||
// instruction and nuke it. | // instruction and nuke it. | ||||
assert(I0->hasOneUse()); | assert(I0->hasOneUse()); | ||||
auto *PN = cast<PHINode>(*I0->user_begin()); | auto *PN = cast<PHINode>(*I0->user_begin()); | ||||
PN->replaceAllUsesWith(I0); | PN->replaceAllUsesWith(I0); | ||||
▲ Show 20 Lines • Show All 4,387 Lines • Show Last 20 Lines |