Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/IR/Instruction.cpp
Show All 37 Lines | Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps, | ||||
// append this instruction into the basic block | // append this instruction into the basic block | ||||
assert(InsertAtEnd && "Basic block to append to may not be NULL!"); | assert(InsertAtEnd && "Basic block to append to may not be NULL!"); | ||||
InsertAtEnd->getInstList().push_back(this); | InsertAtEnd->getInstList().push_back(this); | ||||
} | } | ||||
Instruction::~Instruction() { | Instruction::~Instruction() { | ||||
assert(!Parent && "Instruction still linked in the program!"); | assert(!Parent && "Instruction still linked in the program!"); | ||||
// Replace any extant metadata uses of this instruction with undef to | |||||
// preserve debug info accuracy. Some alternatives include: | |||||
// - Treat Instruction like any other Value, and point its extant metadata | |||||
// uses to an empty ValueAsMetadata node. This makes extant dbg.value uses | |||||
// trivially dead (i.e. fair game for deletion in many passes), leading to | |||||
// stale dbg.values being in effect for too long. | |||||
// - Call salvageDebugInfoOrMarkUndef. Not needed to make instruction removal | |||||
// correct. OTOH results in wasted work in some common cases (e.g. when all | |||||
// instructions in a BasicBlock are deleted). | |||||
if (isUsedByMetadata()) | |||||
ValueAsMetadata::handleRAUW(this, UndefValue::get(getType())); | |||||
if (hasMetadataHashEntry()) | if (hasMetadataHashEntry()) | ||||
clearMetadataHashEntries(); | clearMetadataHashEntries(); | ||||
} | } | ||||
void Instruction::setParent(BasicBlock *P) { | void Instruction::setParent(BasicBlock *P) { | ||||
Parent = P; | Parent = P; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 714 Lines • Show Last 20 Lines |