Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | |||||
/// Combiner aware instruction erasure. | /// Combiner aware instruction erasure. | ||||
/// | /// | ||||
/// When dealing with an instruction that has side effects or produces a void | /// When dealing with an instruction that has side effects or produces a void | ||||
/// value, we can't rely on DCE to delete the instruction. Instead, visit | /// value, we can't rely on DCE to delete the instruction. Instead, visit | ||||
/// methods should return the value returned by this function. | /// methods should return the value returned by this function. | ||||
Instruction *eraseInstFromFunction(Instruction &I) { | Instruction *eraseInstFromFunction(Instruction &I) { | ||||
LLVM_DEBUG(dbgs() << "IC: ERASE " << I << '\n'); | LLVM_DEBUG(dbgs() << "IC: ERASE " << I << '\n'); | ||||
assert(I.use_empty() && "Cannot erase instruction that is used!"); | assert(I.use_empty() && "Cannot erase instruction that is used!"); | ||||
salvageDebugInfoOrMarkUndef(I); | salvageDebugInfo(I); | ||||
// Make sure that we reprocess all operands now that we reduced their | // Make sure that we reprocess all operands now that we reduced their | ||||
// use counts. | // use counts. | ||||
for (Use &Operand : I.operands()) | for (Use &Operand : I.operands()) | ||||
if (auto *Inst = dyn_cast<Instruction>(Operand)) | if (auto *Inst = dyn_cast<Instruction>(Operand)) | ||||
Worklist.add(Inst); | Worklist.add(Inst); | ||||
Worklist.remove(&I); | Worklist.remove(&I); | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |