SPIRVEntry *LLVMToSPIRVDbgTran::transDbgBaseType(const DIBasicType *BT) {
using namespace SPIRVDebug::Operand::TypeBasic;
- SPIRVWordVec Ops(OperandCount);
+ SPIRVWordVec Ops(OperandCountOCL);
Ops[NameIdx] = BM->getString(BT->getName().str())->getId();
ConstantInt *Size = getUInt(M, BT->getSizeInBits());
Ops[SizeIdx] = SPIRVWriter->transValue(Size, nullptr)->getId();
DIBasicType *SPIRVToLLVMDbgTran::transTypeBasic(const SPIRVExtInst *DebugInst) {
using namespace SPIRVDebug::Operand::TypeBasic;
const SPIRVWordVec &Ops = DebugInst->getArguments();
- assert(Ops.size() == OperandCount && "Invalid number of operands");
+ assert((Ops.size() == OperandCountOCL ||
+ Ops.size() == OperandCountNonSemantic) &&
+ "Invalid number of operands");
StringRef Name = getString(Ops[NameIdx]);
auto Tag = static_cast<SPIRVDebug::EncodingTag>(
getConstantValueOrLiteral(Ops, EncodingIdx, DebugInst->getExtSetKind()));
};
enum Flag {
- FlagIsProtected = 1 << 0,
- FlagIsPrivate = 1 << 1,
- FlagIsPublic = FlagIsPrivate | FlagIsProtected,
- FlagAccess = FlagIsPublic,
- FlagIsLocal = 1 << 2,
- FlagIsDefinition = 1 << 3,
- FlagIsFwdDecl = 1 << 4,
- FlagIsArtificial = 1 << 5,
- FlagIsExplicit = 1 << 6,
- FlagIsPrototyped = 1 << 7,
- FlagIsObjectPointer = 1 << 8,
- FlagIsStaticMember = 1 << 9,
- FlagIsIndirectVariable = 1 << 10,
- FlagIsLValueReference = 1 << 11,
- FlagIsRValueReference = 1 << 12,
- FlagIsOptimized = 1 << 13,
- FlagIsEnumClass = 1 << 14,
- FlagTypePassByValue = 1 << 15,
- FlagTypePassByReference = 1 << 16,
+ FlagIsProtected = 1 << 0,
+ FlagIsPrivate = 1 << 1,
+ FlagIsPublic = FlagIsPrivate | FlagIsProtected,
+ FlagAccess = FlagIsPublic,
+ FlagIsLocal = 1 << 2,
+ FlagIsDefinition = 1 << 3,
+ FlagIsFwdDecl = 1 << 4,
+ FlagIsArtificial = 1 << 5,
+ FlagIsExplicit = 1 << 6,
+ FlagIsPrototyped = 1 << 7,
+ FlagIsObjectPointer = 1 << 8,
+ FlagIsStaticMember = 1 << 9,
+ FlagIsIndirectVariable = 1 << 10,
+ FlagIsLValueReference = 1 << 11,
+ FlagIsRValueReference = 1 << 12,
+ FlagIsOptimized = 1 << 13,
+ FlagIsEnumClass = 1 << 14,
+ FlagTypePassByValue = 1 << 15,
+ FlagTypePassByReference = 1 << 16,
+ FlagUnknownPhysicalLayout = 1 << 17,
};
enum EncodingTag {
namespace TypeBasic {
enum {
- NameIdx = 0,
- SizeIdx = 1,
- EncodingIdx = 2,
- OperandCount = 3
+ NameIdx = 0,
+ SizeIdx = 1,
+ EncodingIdx = 2,
+ // For NonSemantic Specs
+ FlagsIdx = 3,
+ OperandCountOCL = 3,
+ OperandCountNonSemantic = 4
};
}
--- /dev/null
+;; This test checks, that SPIR-V module generated by another SPIR-V producer
+;; containing FlagUnknownPhysicalLayout flag of DebugTypeBasic can be
+;; consumed without issues
+
+; RUN: llvm-spirv %s -to-binary -o %t.spv
+; RUN: llvm-spirv -r %t.spv
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM
+
+; CHECK-LLVM: DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+
+119734787 65792 393230 56 0
+2 Capability Addresses
+2 Capability Linkage
+2 Capability Kernel
+2 Capability Int8
+8 Extension "SPV_KHR_non_semantic_info"
+5 ExtInstImport 1 "OpenCL.std"
+11 ExtInstImport 2 "NonSemantic.Shader.DebugInfo.100"
+3 MemoryModel 2 2
+8 String 25 "foo.cpp"
+4 String 30 "int"
+3 String 35 "A"
+3 String 36 "b"
+3 String 44 "foo"
+5 String 45 "_Z3fooP1A"
+3 String 51 "a"
+3 Source 0 0
+5 Name 7 "_Z3fooP1A"
+3 Name 8 "a"
+4 Name 9 "entry"
+4 Name 11 "a.addr"
+5 Name 16 "struct.A"
+3 Name 23 "b"
+
+15 ModuleProcessed "Debug info producer: clang version 3.1 (trunk 150996)"
+7 Decorate 7 LinkageAttributes "_Z3fooP1A" Export
+4 Decorate 11 Alignment 8
+4 TypeInt 3 32 0
+4 TypeInt 4 8 0
+4 Constant 3 21 0
+4 Constant 3 27 65536
+4 Constant 3 28 6
+4 Constant 3 31 32
+4 Constant 3 32 4
+4 Constant 3 37 1
+4 Constant 3 38 2
+4 Constant 3 41 4294967295
+4 Constant 3 46 3
+4 Constant 3 47 136
+4 Constant 3 49 16
+4 Constant 3 56 131072 ;; FlagUnknownPhysicalLayout
+4 TypePointer 5 7 4
+4 TypeFunction 6 3 5
+4 TypePointer 10 7 5
+2 TypeVoid 13
+3 TypeStruct 16 3
+
+4 TypePointer 17 7 16
+4 TypePointer 18 7 17
+4 TypePointer 22 7 3
+
+
+5 ExtInst 13 14 2 DebugInfoNone
+7 ExtInst 13 26 2 DebugSource 25 14
+9 ExtInst 13 29 2 DebugCompilationUnit 27 21 26 28
+9 ExtInst 13 33 2 DebugTypeBasic 30 31 32 56
+14 ExtInst 13 39 2 DebugTypeMember 36 33 26 37 21 34 21 31 38
+15 ExtInst 13 34 2 DebugTypeComposite 35 21 26 37 21 29 14 31 21 39
+8 ExtInst 13 42 2 DebugTypePointer 34 41 21
+8 ExtInst 13 43 2 DebugTypeFunction 21 33 42
+15 ExtInst 13 48 2 DebugFunction 44 43 26 46 21 29 45 47 46 14
+9 ExtInst 13 50 2 DebugLexicalBlock 26 46 49 48
+13 ExtInst 13 52 2 DebugLocalVariable 51 42 26 46 21 48 21 1
+5 ExtInst 13 53 2 DebugExpression
+
+5 Function 3 7 0 6
+3 FunctionParameter 5 8
+
+2 Label 9
+7 ExtInst 13 57 2 DebugFunctionDefinition 48 7
+4 Variable 10 11 7
+4 Bitcast 10 12 11
+5 Store 12 8 2 8
+6 ExtInst 13 54 2 DebugScope 48
+4 Line 25 3 13
+8 ExtInst 13 15 2 DebugDeclare 52 11 53
+6 ExtInst 13 55 2 DebugScope 50
+4 Line 25 4 3
+4 Bitcast 18 19 11
+6 Load 17 20 19 2 8
+6 InBoundsPtrAccessChain 22 23 20 21 21
+6 Load 3 24 23 2 4
+2 ReturnValue 24
+
+1 FunctionEnd
+