Skip to content

Commit

Permalink
[Hexagon] Only handle simple types memory accesses (#120654)
Browse files Browse the repository at this point in the history
The code was asserting because allowsMemoryAccess() was called with
Extended Value Type INVALID_SIMPLE_VALUE_TYPE in
HexagonISelLowering.cpp.
Fixes #118881

(cherry picked from commit 8177bf5)
  • Loading branch information
iajbar authored and llvmbot committed Dec 24, 2024
1 parent e21dc4b commit 173656b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3796,6 +3796,8 @@ EVT HexagonTargetLowering::getOptimalMemOpType(
bool HexagonTargetLowering::allowsMemoryAccess(
LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace,
Align Alignment, MachineMemOperand::Flags Flags, unsigned *Fast) const {
if (!VT.isSimple())
return false;
MVT SVT = VT.getSimpleVT();
if (Subtarget.isHVXVectorType(SVT, true))
return allowsHvxMemoryAccess(SVT, Flags, Fast);
Expand All @@ -3806,6 +3808,8 @@ bool HexagonTargetLowering::allowsMemoryAccess(
bool HexagonTargetLowering::allowsMisalignedMemoryAccesses(
EVT VT, unsigned AddrSpace, Align Alignment, MachineMemOperand::Flags Flags,
unsigned *Fast) const {
if (!VT.isSimple())
return false;
MVT SVT = VT.getSimpleVT();
if (Subtarget.isHVXVectorType(SVT, true))
return allowsHvxMisalignedMemoryAccesses(SVT, Flags, Fast);
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/Hexagon/simple-types-mem.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; RUN: llc -march=hexagon < %s
; REQUIRES: asserts

; Only simple types memory accesses are handled.

target triple = "hexagon"

%struct.hoge = type { i320 }

define dso_local void @widget() {
bb:
%tmp = alloca %struct.hoge, align 1
%tmp1 = bitcast %struct.hoge* %tmp to i320*
%tmp2 = load i320, i320* %tmp1, align 1
%tmp3 = and i320 %tmp2, -18446744073709551616
%tmp4 = or i320 %tmp3, 0
store i320 %tmp4, i320* %tmp1, align 1
call void @llvm.trap()
unreachable
}

declare void @llvm.trap()

0 comments on commit 173656b

Please sign in to comment.