
This PR continues https://github.com/llvm/llvm-project/pull/101732 changes in virtual register processing aimed to improve correctness of emitted MIR between passes from the perspective of MachineVerifier. Namely, the following changes are introduced: * register classes (lib/Target/SPIRV/SPIRVRegisterInfo.td) and instruction patterns (lib/Target/SPIRV/SPIRVInstrInfo.td) are corrected and simplified (by removing unnecessary sophisticated options) -- e.g., this PR gets rid of duplicating 32/64 bits patterns, removes ANYID register class and simplifies definition of the rest of register classes, * hardcoded LLT scalar types in passes before instruction selection are corrected -- the goal is to have correct bit width before instruction selection, and use 64 bits registers for pattern matching in the instruction selection pass; 32-bit registers remain where they are described in such terms by SPIR-V specification (like, for example, creation of virtual registers for scope/mem semantics operands), * rework virtual register type/class assignment for calls/builtins lowering, * a series of minor changes to fix validity of emitted code between passes: - ensure that that bitcast changes the type, - fix the pattern for instruction selection for OpExtInst, - simplify inline asm operands usage, - account for arbitrary integer sizes / update legalizer rules; * add '-verify-machineinstrs' to existed test cases. See also https://github.com/llvm/llvm-project/issues/88129 that this PR may resolve. This PR fixes a great number of issues reported by MachineVerifier and, as a result, reduces a number of failed test cases for the mode with expensive checks set on from ~200 to ~57.
87 lines
1.9 KiB
LLVM
87 lines
1.9 KiB
LLVM
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
|
|
|
|
;; FIXME: Are there any attributes that would make the IR invalid for SPIR-V?
|
|
|
|
;; Names:
|
|
; CHECK-DAG: OpName %[[#FN1:]] "fn1"
|
|
; CHECK-DAG: OpName %[[#FN2:]] "fn2"
|
|
; CHECK-DAG: OpName %[[#FN3:]] "fn3"
|
|
; CHECK-DAG: OpName %[[#FN4:]] "fn4"
|
|
; CHECK-DAG: OpName %[[#FN5:]] "fn5"
|
|
; CHECK-DAG: OpName %[[#FN6:]] "fn6"
|
|
; CHECK-DAG: OpName %[[#FN7:]] "fn7"
|
|
; CHECK-DAG: OpName %[[#FN8:]] "fn8"
|
|
; CHECK-DAG: OpName %[[#FN9:]] "fn9"
|
|
|
|
;; Types:
|
|
; CHECK: %[[#VOID:]] = OpTypeVoid
|
|
; CHECK: %[[#FN:]] = OpTypeFunction %[[#VOID]]
|
|
|
|
|
|
;; Functions:
|
|
|
|
define void @fn1() noinline {
|
|
ret void
|
|
}
|
|
; CHECK: %[[#FN1]] = OpFunction %[[#VOID]] DontInline %[[#FN]]
|
|
; CHECK-NOT: OpFunctionParameter
|
|
; CHECK: OpFunctionEnd
|
|
|
|
|
|
attributes #0 = { noinline }
|
|
define void @fn2() #0 {
|
|
ret void
|
|
}
|
|
; CHECK: %[[#FN2]] = OpFunction %[[#VOID]] DontInline %[[#FN]]
|
|
; CHECK: OpFunctionEnd
|
|
|
|
|
|
define void @fn3() alwaysinline {
|
|
ret void
|
|
}
|
|
; CHECK: %[[#FN3]] = OpFunction %[[#VOID]] Inline %[[#FN]]
|
|
; CHECK: OpFunctionEnd
|
|
|
|
|
|
;; NOTE: inlinehint is not an actual requirement.
|
|
define void @fn4() inlinehint {
|
|
ret void
|
|
}
|
|
; CHECK: %[[#FN4]] = OpFunction %[[#VOID]] None %[[#FN]]
|
|
; CHECK: OpFunctionEnd
|
|
|
|
|
|
define void @fn5() readnone {
|
|
ret void
|
|
}
|
|
; CHECK: %[[#FN5]] = OpFunction %[[#VOID]] Pure %[[#FN]]
|
|
; CHECK: OpFunctionEnd
|
|
|
|
|
|
define void @fn6() memory(none) {
|
|
ret void
|
|
}
|
|
; CHECK: %[[#FN6]] = OpFunction %[[#VOID]] Pure %[[#FN]]
|
|
; CHECK: OpFunctionEnd
|
|
|
|
|
|
define void @fn7() readonly {
|
|
ret void
|
|
}
|
|
; CHECK: %[[#FN7]] = OpFunction %[[#VOID]] Const %[[#FN]]
|
|
; CHECK: OpFunctionEnd
|
|
|
|
|
|
define void @fn8() memory(read) {
|
|
ret void
|
|
}
|
|
; CHECK: %[[#FN8]] = OpFunction %[[#VOID]] Const %[[#FN]]
|
|
; CHECK: OpFunctionEnd
|
|
|
|
|
|
define void @fn9() alwaysinline readnone {
|
|
ret void
|
|
}
|
|
; CHECK: %[[#FN9]] = OpFunction %[[#VOID]] Inline|Pure %[[#FN]]
|
|
; CHECK: OpFunctionEnd
|