Skip to content

Commit 1f20eee

Browse files
[SPIR-V] Emit OpConstant instead of OpConstantNull to conform to NonSemantic.Shader.DebugInfo.100 DebugTypeBasic's flags definition (#118333)
This PR is to fix #118011 by emitting OpConstant instead of OpConstantNull to conform to NonSemantic.Shader.DebugInfo.100 DebugTypeBasic's flags definition.
1 parent af31aa4 commit 1f20eee

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitNonSemanticDI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ bool SPIRVEmitNonSemanticDI::emitGlobalDI(MachineFunction &MF) {
268268
// We aren't extracting any DebugInfoFlags now so we
269269
// emitting zero to use as <id>Flags argument for DebugBasicType
270270
const Register I32ZeroReg =
271-
GR->buildConstantInt(0, MIRBuilder, I32Ty, false);
271+
GR->buildConstantInt(0, MIRBuilder, I32Ty, false, false);
272272

273273
// We need to store pairs because further instructions reference
274274
// the DIBasicTypes and size will be always small so there isn't

llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ Register SPIRVGlobalRegistry::getOrCreateConstInt(uint64_t Val, MachineInstr &I,
325325

326326
Register SPIRVGlobalRegistry::buildConstantInt(uint64_t Val,
327327
MachineIRBuilder &MIRBuilder,
328-
SPIRVType *SpvType,
329-
bool EmitIR) {
328+
SPIRVType *SpvType, bool EmitIR,
329+
bool ZeroAsNull) {
330330
assert(SpvType);
331331
auto &MF = MIRBuilder.getMF();
332332
const IntegerType *LLVMIntTy =
@@ -348,7 +348,7 @@ Register SPIRVGlobalRegistry::buildConstantInt(uint64_t Val,
348348
} else {
349349
Register SpvTypeReg = getSPIRVTypeID(SpvType);
350350
MachineInstrBuilder MIB;
351-
if (Val) {
351+
if (Val || !ZeroAsNull) {
352352
MIB = MIRBuilder.buildInstr(SPIRV::OpConstantI)
353353
.addDef(Res)
354354
.addUse(SpvTypeReg);

llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,8 @@ class SPIRVGlobalRegistry {
509509

510510
public:
511511
Register buildConstantInt(uint64_t Val, MachineIRBuilder &MIRBuilder,
512-
SPIRVType *SpvType, bool EmitIR = true);
512+
SPIRVType *SpvType, bool EmitIR = true,
513+
bool ZeroAsNull = true);
513514
Register getOrCreateConstInt(uint64_t Val, MachineInstr &I,
514515
SPIRVType *SpvType, const SPIRVInstrInfo &TII,
515516
bool ZeroAsNull = true);

llvm/test/CodeGen/SPIRV/debug-info/debug-type-basic.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
; CHECK-MIR-DAG: [[type_i32:%[0-9]+\:type]] = OpTypeInt 32, 0
1111
; CHECK-MIR-DAG: [[encoding_signedchar:%[0-9]+\:iid\(s32\)]] = OpConstantI [[type_i32]], 5
1212
; CHECK-MIR-DAG: [[encoding_float:%[0-9]+\:iid\(s32\)]] = OpConstantI [[type_i32]], 3
13-
; CHECK-MIR-DAG: [[flag_zero:%[0-9]+\:iid\(s32\)]] = OpConstantNull [[type_i32]]
13+
; CHECK-MIR-DAG: [[flag_zero:%[0-9]+\:iid\(s32\)]] = OpConstantI [[type_i32]], 0
1414
; CHECK-MIR-DAG: [[str_bool:%[0-9]+\:id\(s32\)]] = OpString 1819242338, 0
1515
; CHECK-MIR-DAG: [[size_8bits:%[0-9]+\:iid\(s32\)]] = OpConstantI [[type_i32]], 8
1616
; CHECK-MIR-DAG: [[encoding_boolean:%[0-9]+\:iid\(s32\)]] = OpConstantI [[type_i32]], 2
@@ -63,7 +63,7 @@
6363
; CHECK-SPIRV-DAG: [[type_int16:%[0-9]+]] = OpTypeInt 16 0
6464
; CHECK-SPIRV-DAG: [[type_int32:%[0-9]+]] = OpTypeInt 32 0
6565
; CHECK-SPIRV-DAG: [[encoding_signedchar:%[0-9]+]] = OpConstant [[type_int32]] 5
66-
; CHECK-SPIRV-DAG: [[flag_zero:%[0-9]+]] = OpConstantNull [[type_int32]]
66+
; CHECK-SPIRV-DAG: [[flag_zero:%[0-9]+]] = OpConstant [[type_int32]] 0
6767
; CHECK-SPIRV-DAG: [[encoding_float:%[0-9]+]] = OpConstant [[type_int32]] 3
6868
; CHECK-SPIRV-DAG: [[size_8bit:%[0-9]+]] = OpConstant [[type_int32]] 8
6969
; CHECK-SPIRV-DAG: [[encoding_boolean:%[0-9]+]] = OpConstant [[type_int32]] 2

0 commit comments

Comments
 (0)