Skip to content

Commit

Permalink
Fixup r364512
Browse files Browse the repository at this point in the history
Fix stack-use-after-scope errors from r364512. One instance was already
fixed in r364611 - this patch simplifies that fix and addresses one more
instance of similar code.

Discussed in: https://reviews.llvm.org/D63905

llvm-svn: 364778
  • Loading branch information
rovka committed Jul 1, 2019
1 parent 2814573 commit 2ba1601
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1566,16 +1566,16 @@ bool IRTranslator::translateCall(const User &U, MachineIRBuilder &MIRBuilder) {
ArrayRef<Register> Res = getOrCreateVRegs(CI);

SmallVector<ArrayRef<Register>, 8> Args;
SmallVector<Register, 8> InVRegs;
Register SwiftInVReg = 0;
Register SwiftErrorVReg = 0;
for (auto &Arg: CI.arg_operands()) {
if (CLI->supportSwiftError() && isSwiftError(Arg)) {
assert(SwiftInVReg == 0 && "Expected only one swift error argument");
LLT Ty = getLLTForType(*Arg->getType(), *DL);
InVRegs.push_back(MRI->createGenericVirtualRegister(Ty));
MIRBuilder.buildCopy(
InVRegs.back(),
SwiftError.getOrCreateVRegUseAt(&CI, &MIRBuilder.getMBB(), Arg));
Args.emplace_back(llvm::makeArrayRef(InVRegs.back()));
SwiftInVReg = MRI->createGenericVirtualRegister(Ty);
MIRBuilder.buildCopy(SwiftInVReg, SwiftError.getOrCreateVRegUseAt(
&CI, &MIRBuilder.getMBB(), Arg));
Args.emplace_back(makeArrayRef(SwiftInVReg));
SwiftErrorVReg =
SwiftError.getOrCreateVRegDefAt(&CI, &MIRBuilder.getMBB(), Arg);
continue;
Expand Down Expand Up @@ -1669,13 +1669,15 @@ bool IRTranslator::translateInvoke(const User &U,
Res = getOrCreateVRegs(I);
SmallVector<ArrayRef<Register>, 8> Args;
Register SwiftErrorVReg = 0;
Register SwiftInVReg = 0;
for (auto &Arg : I.arg_operands()) {
if (CLI->supportSwiftError() && isSwiftError(Arg)) {
assert(SwiftInVReg == 0 && "Expected only one swift error argument");
LLT Ty = getLLTForType(*Arg->getType(), *DL);
Register InVReg = MRI->createGenericVirtualRegister(Ty);
MIRBuilder.buildCopy(InVReg, SwiftError.getOrCreateVRegUseAt(
&I, &MIRBuilder.getMBB(), Arg));
Args.push_back(InVReg);
SwiftInVReg = MRI->createGenericVirtualRegister(Ty);
MIRBuilder.buildCopy(SwiftInVReg, SwiftError.getOrCreateVRegUseAt(
&I, &MIRBuilder.getMBB(), Arg));
Args.push_back(makeArrayRef(SwiftInVReg));
SwiftErrorVReg =
SwiftError.getOrCreateVRegDefAt(&I, &MIRBuilder.getMBB(), Arg);
continue;
Expand Down

0 comments on commit 2ba1601

Please sign in to comment.