llvm-project/llvm/test/CodeGen/WebAssembly/externref-globalget.ll
Heejin Ahn 5c92f2331c
[WebAssembly] Fix MIR printing of reference types (#113028)
When printing a memory operand in MIR, this line

d37bc32a65/llvm/lib/CodeGen/MachineOperand.cpp (L1247)
calls this
d37bc32a65/llvm/include/llvm/Support/Alignment.h (L238)
which assumes `Rhs` (the size in this case) is positive.

But Wasm reference types' size is set to 0:
d37bc32a65/llvm/include/llvm/CodeGen/ValueTypes.td (L326-L328)

`getSize() > 0` condition was added with the Wasm reference types
support in
46667a1003,
and it looks it was removed in #84751. This revives the condition so
that Wasm reference types will not crash the MIR printer.
2024-10-22 13:48:00 -07:00

22 lines
885 B
LLVM

; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
; Test for MIR printing of reference types in other address spaces. This should
; not error out.
; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types -print-after=finalize-isel | FileCheck %s
%externref = type ptr addrspace(10) ;; addrspace 10 is nonintegral
@externref_global = local_unnamed_addr addrspace(1) global %externref undef
define %externref @return_externref_global() {
;; this generates a global.get of @externref_global
%ref = load %externref, ptr addrspace(1) @externref_global
ret %externref %ref
}
; CHECK-LABEL: return_externref_global:
; CHECK-NEXT: functype return_externref_global () -> (externref)
; CHECK-NEXT: global.get externref_global
; CHECK-NEXT: end_function
; CHECK: .globl externref_global