Skip to content

Commit 8177bf5

Browse files
authored
[Hexagon] Only handle simple types memory accesses (llvm#120654)
The code was asserting because allowsMemoryAccess() was called with Extended Value Type INVALID_SIMPLE_VALUE_TYPE in HexagonISelLowering.cpp. Fixes llvm#118881
1 parent 56ffcd4 commit 8177bf5

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3793,6 +3793,8 @@ EVT HexagonTargetLowering::getOptimalMemOpType(
37933793
bool HexagonTargetLowering::allowsMemoryAccess(
37943794
LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace,
37953795
Align Alignment, MachineMemOperand::Flags Flags, unsigned *Fast) const {
3796+
if (!VT.isSimple())
3797+
return false;
37963798
MVT SVT = VT.getSimpleVT();
37973799
if (Subtarget.isHVXVectorType(SVT, true))
37983800
return allowsHvxMemoryAccess(SVT, Flags, Fast);
@@ -3803,6 +3805,8 @@ bool HexagonTargetLowering::allowsMemoryAccess(
38033805
bool HexagonTargetLowering::allowsMisalignedMemoryAccesses(
38043806
EVT VT, unsigned AddrSpace, Align Alignment, MachineMemOperand::Flags Flags,
38053807
unsigned *Fast) const {
3808+
if (!VT.isSimple())
3809+
return false;
38063810
MVT SVT = VT.getSimpleVT();
38073811
if (Subtarget.isHVXVectorType(SVT, true))
38083812
return allowsHvxMisalignedMemoryAccesses(SVT, Flags, Fast);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc -march=hexagon < %s
2+
; REQUIRES: asserts
3+
4+
; Only simple types memory accesses are handled.
5+
6+
target triple = "hexagon"
7+
8+
%struct.hoge = type { i320 }
9+
10+
define dso_local void @widget() {
11+
bb:
12+
%tmp = alloca %struct.hoge, align 1
13+
%tmp1 = bitcast %struct.hoge* %tmp to i320*
14+
%tmp2 = load i320, i320* %tmp1, align 1
15+
%tmp3 = and i320 %tmp2, -18446744073709551616
16+
%tmp4 = or i320 %tmp3, 0
17+
store i320 %tmp4, i320* %tmp1, align 1
18+
call void @llvm.trap()
19+
unreachable
20+
}
21+
22+
declare void @llvm.trap()

0 commit comments

Comments
 (0)