@@ -27,8 +27,8 @@ using namespace llvm;
2727
2828Instruction::Instruction (Type *ty, unsigned it, Use *Ops, unsigned NumOps,
2929 InstListType::iterator InsertBefore)
30- : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent( nullptr ) {
31-
30+ : User(ty, Value::InstructionVal + it, Ops, NumOps) {
31+ setParent ( nullptr );
3232 // When called with an iterator, there must be a block to insert into.
3333 BasicBlock *BB = InsertBefore->getParent ();
3434 assert (BB && " Instruction to insert before is not in a basic block!" );
@@ -37,7 +37,8 @@ Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
3737
3838Instruction::Instruction (Type *ty, unsigned it, Use *Ops, unsigned NumOps,
3939 Instruction *InsertBefore)
40- : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(nullptr ) {
40+ : User(ty, Value::InstructionVal + it, Ops, NumOps) {
41+ setParent (nullptr );
4142
4243 // If requested, insert this instruction into a basic block...
4344 if (InsertBefore) {
@@ -49,15 +50,15 @@ Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
4950
5051Instruction::Instruction (Type *ty, unsigned it, Use *Ops, unsigned NumOps,
5152 BasicBlock *InsertAtEnd)
52- : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent( nullptr ) {
53-
53+ : User(ty, Value::InstructionVal + it, Ops, NumOps) {
54+ setParent ( nullptr );
5455 // If requested, append this instruction into the basic block.
5556 if (InsertAtEnd)
5657 insertInto (InsertAtEnd, InsertAtEnd->end ());
5758}
5859
5960Instruction::~Instruction () {
60- assert (!Parent && " Instruction still linked in the program!" );
61+ assert (!getParent () && " Instruction still linked in the program!" );
6162
6263 // Replace any extant metadata uses of this instruction with undef to
6364 // preserve debug info accuracy. Some alternatives include:
@@ -76,9 +77,7 @@ Instruction::~Instruction() {
7677 setMetadata (LLVMContext::MD_DIAssignID, nullptr );
7778}
7879
79- void Instruction::setParent (BasicBlock *P) {
80- Parent = P;
81- }
80+ void Instruction::setParent (BasicBlock *P) { setNodeBaseParent (P); }
8281
8382const Module *Instruction::getModule () const {
8483 return getParent ()->getModule ();
@@ -96,7 +95,7 @@ void Instruction::removeFromParent() {
9695}
9796
9897void Instruction::handleMarkerRemoval () {
99- if (!Parent ->IsNewDbgInfoFormat || !DebugMarker)
98+ if (!getParent () ->IsNewDbgInfoFormat || !DebugMarker)
10099 return ;
101100
102101 DebugMarker->removeMarker ();
@@ -329,11 +328,12 @@ void Instruction::dropOneDbgRecord(DbgRecord *DVR) {
329328}
330329
331330bool Instruction::comesBefore (const Instruction *Other) const {
332- assert (Parent && Other->Parent &&
331+ assert (getParent () && Other->getParent () &&
333332 " instructions without BB parents have no order" );
334- assert (Parent == Other->Parent && " cross-BB instruction order comparison" );
335- if (!Parent->isInstrOrderValid ())
336- Parent->renumberInstructions ();
333+ assert (getParent () == Other->getParent () &&
334+ " cross-BB instruction order comparison" );
335+ if (!getParent ()->isInstrOrderValid ())
336+ const_cast <BasicBlock *>(getParent ())->renumberInstructions ();
337337 return Order < Other->Order ;
338338}
339339
0 commit comments