@@ -27,8 +27,8 @@ using namespace llvm;
27
27
28
28
Instruction::Instruction (Type *ty, unsigned it, Use *Ops, unsigned NumOps,
29
29
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 );
32
32
// When called with an iterator, there must be a block to insert into.
33
33
BasicBlock *BB = InsertBefore->getParent ();
34
34
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,
37
37
38
38
Instruction::Instruction (Type *ty, unsigned it, Use *Ops, unsigned NumOps,
39
39
Instruction *InsertBefore)
40
- : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(nullptr ) {
40
+ : User(ty, Value::InstructionVal + it, Ops, NumOps) {
41
+ setParent (nullptr );
41
42
42
43
// If requested, insert this instruction into a basic block...
43
44
if (InsertBefore) {
@@ -49,15 +50,15 @@ Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
49
50
50
51
Instruction::Instruction (Type *ty, unsigned it, Use *Ops, unsigned NumOps,
51
52
BasicBlock *InsertAtEnd)
52
- : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent( nullptr ) {
53
-
53
+ : User(ty, Value::InstructionVal + it, Ops, NumOps) {
54
+ setParent ( nullptr );
54
55
// If requested, append this instruction into the basic block.
55
56
if (InsertAtEnd)
56
57
insertInto (InsertAtEnd, InsertAtEnd->end ());
57
58
}
58
59
59
60
Instruction::~Instruction () {
60
- assert (!Parent && " Instruction still linked in the program!" );
61
+ assert (!getParent () && " Instruction still linked in the program!" );
61
62
62
63
// Replace any extant metadata uses of this instruction with undef to
63
64
// preserve debug info accuracy. Some alternatives include:
@@ -76,9 +77,7 @@ Instruction::~Instruction() {
76
77
setMetadata (LLVMContext::MD_DIAssignID, nullptr );
77
78
}
78
79
79
- void Instruction::setParent (BasicBlock *P) {
80
- Parent = P;
81
- }
80
+ void Instruction::setParent (BasicBlock *P) { setNodeBaseParent (P); }
82
81
83
82
const Module *Instruction::getModule () const {
84
83
return getParent ()->getModule ();
@@ -96,7 +95,7 @@ void Instruction::removeFromParent() {
96
95
}
97
96
98
97
void Instruction::handleMarkerRemoval () {
99
- if (!Parent ->IsNewDbgInfoFormat || !DebugMarker)
98
+ if (!getParent () ->IsNewDbgInfoFormat || !DebugMarker)
100
99
return ;
101
100
102
101
DebugMarker->removeMarker ();
@@ -329,11 +328,12 @@ void Instruction::dropOneDbgRecord(DbgRecord *DVR) {
329
328
}
330
329
331
330
bool Instruction::comesBefore (const Instruction *Other) const {
332
- assert (Parent && Other->Parent &&
331
+ assert (getParent () && Other->getParent () &&
333
332
" 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 ();
337
337
return Order < Other->Order ;
338
338
}
339
339
0 commit comments