Skip to content

Commit 81eb1c1

Browse files
arsenmzmodem
authored andcommitted
AArch64/GlobalISel: Reduced patch for bug 47619
This is the relevant portions of an assert fixed by b98f902.
1 parent e9adcbf commit 81eb1c1

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

llvm/lib/CodeGen/GlobalISel/CallLowering.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,15 @@ bool CallLowering::handleAssignments(CCState &CCInfo,
375375
<< "Load/store a split arg to/from the stack not implemented yet");
376376
return false;
377377
}
378-
MVT VT = MVT::getVT(Args[i].Ty);
379-
unsigned Size = VT == MVT::iPTR ? DL.getPointerSize()
380-
: alignTo(VT.getSizeInBits(), 8) / 8;
378+
379+
EVT LocVT = VA.getValVT();
380+
unsigned MemSize = LocVT == MVT::iPTR ? DL.getPointerSize()
381+
: LocVT.getStoreSize();
382+
381383
unsigned Offset = VA.getLocMemOffset();
382384
MachinePointerInfo MPO;
383-
Register StackAddr = Handler.getStackAddress(Size, Offset, MPO);
384-
Handler.assignValueToAddress(Args[i], StackAddr, Size, MPO, VA);
385+
Register StackAddr = Handler.getStackAddress(MemSize, Offset, MPO);
386+
Handler.assignValueToAddress(Args[i], StackAddr, MemSize, MPO, VA);
385387
} else {
386388
// FIXME: Support byvals and other weirdness
387389
return false;

llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,17 @@ struct IncomingArgHandler : public CallLowering::ValueHandler {
129129
}
130130
}
131131

132-
void assignValueToAddress(Register ValVReg, Register Addr, uint64_t Size,
132+
void assignValueToAddress(Register ValVReg, Register Addr, uint64_t MemSize,
133133
MachinePointerInfo &MPO, CCValAssign &VA) override {
134134
MachineFunction &MF = MIRBuilder.getMF();
135135

136+
// The reported memory location may be wider than the value.
137+
const LLT RegTy = MRI.getType(ValVReg);
138+
MemSize = std::min(static_cast<uint64_t>(RegTy.getSizeInBytes()), MemSize);
139+
136140
// FIXME: Get alignment
137141
auto MMO = MF.getMachineMemOperand(
138-
MPO, MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant, Size,
142+
MPO, MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant, MemSize,
139143
inferAlignFromPtrInfo(MF, MPO));
140144
MIRBuilder.buildLoad(ValVReg, Addr, *MMO);
141145
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2+
; RUN: llc -global-isel -mtriple=aarch64-unknown-unknown -stop-after=irtranslator %s -o - | FileCheck %s
3+
4+
; Make sure the i3 %arg8 value is correctly handled. This was trying
5+
; to use MVT for EVT values passed on the stack and asserting before
6+
; b98f902f1877c3d679f77645a267edc89ffcd5d6
7+
define i3 @bug47619(i64 %arg, i64 %arg1, i64 %arg2, i64 %arg3, i64 %arg4, i64 %arg5, i64 %arg6, i64 %arg7, i3 %arg8) {
8+
; CHECK-LABEL: name: bug47619
9+
; CHECK: bb.1.bb:
10+
; CHECK: liveins: $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7
11+
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
12+
; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
13+
; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
14+
; CHECK: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
15+
; CHECK: [[COPY4:%[0-9]+]]:_(s64) = COPY $x4
16+
; CHECK: [[COPY5:%[0-9]+]]:_(s64) = COPY $x5
17+
; CHECK: [[COPY6:%[0-9]+]]:_(s64) = COPY $x6
18+
; CHECK: [[COPY7:%[0-9]+]]:_(s64) = COPY $x7
19+
; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
20+
; CHECK: [[LOAD:%[0-9]+]]:_(s3) = G_LOAD [[FRAME_INDEX]](p0) :: (invariant load 4 from %fixed-stack.0, align 16)
21+
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[LOAD]](s3)
22+
; CHECK: $w0 = COPY [[ANYEXT]](s32)
23+
; CHECK: RET_ReallyLR implicit $w0
24+
bb:
25+
ret i3 %arg8
26+
}

0 commit comments

Comments
 (0)