@@ -99,32 +99,25 @@ ValueBase::getDefiningInstructionResult() {
99
99
}
100
100
101
101
SILBasicBlock *SILNode::getParentBlock () const {
102
- auto *CanonicalNode =
103
- const_cast <SILNode *>(this )->getRepresentativeSILNodeInObject ();
104
- if (auto *Inst = dyn_cast<SILInstruction>(CanonicalNode))
102
+ if (auto *Inst = dyn_cast<SILInstruction>(this ))
105
103
return Inst->getParent ();
106
- if (auto *Arg = dyn_cast<SILArgument>(CanonicalNode ))
104
+ if (auto *Arg = dyn_cast<SILArgument>(this ))
107
105
return Arg->getParent ();
106
+ if (auto *MVR = dyn_cast<MultipleValueInstructionResult>(this )) {
107
+ return MVR->getParent ()->getParent ();
108
+ }
108
109
return nullptr ;
109
110
}
110
111
111
112
SILFunction *SILNode::getFunction () const {
112
- auto *CanonicalNode =
113
- const_cast <SILNode *>(this )->getRepresentativeSILNodeInObject ();
114
- if (auto *Inst = dyn_cast<SILInstruction>(CanonicalNode))
115
- return Inst->getFunction ();
116
- if (auto *Arg = dyn_cast<SILArgument>(CanonicalNode))
117
- return Arg->getFunction ();
113
+ if (auto *parentBlock = getParentBlock ())
114
+ return parentBlock->getParent ();
118
115
return nullptr ;
119
116
}
120
117
121
118
SILModule *SILNode::getModule () const {
122
- auto *CanonicalNode =
123
- const_cast <SILNode *>(this )->getRepresentativeSILNodeInObject ();
124
- if (auto *Inst = dyn_cast<SILInstruction>(CanonicalNode))
125
- return &Inst->getModule ();
126
- if (auto *Arg = dyn_cast<SILArgument>(CanonicalNode))
127
- return &Arg->getModule ();
119
+ if (SILFunction *func = getFunction ())
120
+ return &func->getModule ();
128
121
return nullptr ;
129
122
}
130
123
0 commit comments