forked from OSchip/llvm-project
GlobalISel: rework getOrCreateVReg to avoid double lookup. NFC.
Thanks to Quentin for suggesting the refactoring. llvm-svn: 293087
This commit is contained in:
parent
5d27063eb4
commit
9e35f1e21c
|
@ -60,8 +60,10 @@ void IRTranslator::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||
|
||||
unsigned IRTranslator::getOrCreateVReg(const Value &Val) {
|
||||
unsigned &ValReg = ValToVReg[&Val];
|
||||
// Check if this is the first time we see Val.
|
||||
if (!ValReg) {
|
||||
|
||||
if (ValReg)
|
||||
return ValReg;
|
||||
|
||||
// Fill ValRegsSequence with the sequence of registers
|
||||
// we need to concat together to produce the value.
|
||||
assert(Val.getType()->isSized() &&
|
||||
|
@ -80,10 +82,8 @@ unsigned IRTranslator::getOrCreateVReg(const Value &Val) {
|
|||
reportTranslationError(Val, "unable to translate constant");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Look Val up again in case the reference has been invalidated since.
|
||||
return ValToVReg[&Val];
|
||||
return VReg;
|
||||
}
|
||||
|
||||
int IRTranslator::getOrCreateFrameIndex(const AllocaInst &AI) {
|
||||
|
|
Loading…
Reference in New Issue