|
37 | 37 | //===----------------------------------------------------------------------===// |
38 | 38 |
|
39 | 39 | #include "SPIRVToLLVMDbgTran.h" |
| 40 | +#include "SPIRV.debug.h" |
40 | 41 | #include "SPIRVEntry.h" |
41 | 42 | #include "SPIRVFunction.h" |
42 | 43 | #include "SPIRVInstruction.h" |
@@ -1214,32 +1215,47 @@ DINode *SPIRVToLLVMDbgTran::transTypedef(const SPIRVExtInst *DebugInst) { |
1214 | 1215 |
|
1215 | 1216 | DINode *SPIRVToLLVMDbgTran::transTypeInheritance(const SPIRVExtInst *DebugInst, |
1216 | 1217 | DIType *ChildClass) { |
1217 | | - if (isNonSemanticDebugInfo(DebugInst->getExtSetKind()) && !ChildClass) { |
1218 | | - // Will be translated later when processing TypeMember's parent |
1219 | | - return nullptr; |
1220 | | - } |
1221 | 1218 | using namespace SPIRVDebug::Operand::TypeInheritance; |
| 1219 | + // The value is used when assertions are enabled |
| 1220 | + [[maybe_unused]] unsigned OperandCount; |
| 1221 | + unsigned ParentIdx, OffsetIdx, FlagsIdx; |
| 1222 | + if (isNonSemanticDebugInfo(DebugInst->getExtSetKind())) { |
| 1223 | + if (!ChildClass) { |
| 1224 | + // Will be translated later when processing TypeMember's parent |
| 1225 | + return nullptr; |
| 1226 | + } |
| 1227 | + OperandCount = NonSemantic::OperandCount; |
| 1228 | + ParentIdx = NonSemantic::ParentIdx; |
| 1229 | + OffsetIdx = NonSemantic::OffsetIdx; |
| 1230 | + FlagsIdx = NonSemantic::FlagsIdx; |
| 1231 | + } else { |
| 1232 | + OperandCount = NonSemantic::OperandCount; |
| 1233 | + ParentIdx = OpenCL::ParentIdx; |
| 1234 | + OffsetIdx = OpenCL::OffsetIdx; |
| 1235 | + FlagsIdx = OpenCL::FlagsIdx; |
| 1236 | + } |
1222 | 1237 | const SPIRVWordVec &Ops = DebugInst->getArguments(); |
1223 | | - assert(Ops.size() >= MinOperandCount && "Invalid number of operands"); |
1224 | | - // No Child operand for NonSemantic debug spec |
1225 | | - SPIRVWord Offset = isNonSemanticDebugInfo(DebugInst->getExtSetKind()) ? 1 : 0; |
| 1238 | + assert(Ops.size() >= OperandCount && "Invalid number of operands"); |
1226 | 1239 | DIType *Parent = |
1227 | | - transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[ParentIdx - Offset])); |
1228 | | - DIType *Child = |
1229 | | - isNonSemanticDebugInfo(DebugInst->getExtSetKind()) |
1230 | | - ? ChildClass |
1231 | | - : transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[ChildIdx])); |
| 1240 | + transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[ParentIdx])); |
1232 | 1241 | DINode::DIFlags Flags = DINode::FlagZero; |
1233 | | - SPIRVWord SPIRVFlags = getConstantValueOrLiteral(Ops, FlagsIdx - Offset, |
1234 | | - DebugInst->getExtSetKind()); |
| 1242 | + SPIRVWord SPIRVFlags = |
| 1243 | + getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind()); |
1235 | 1244 | if ((SPIRVFlags & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsPublic) |
1236 | 1245 | Flags |= llvm::DINode::FlagPublic; |
1237 | 1246 | if ((SPIRVFlags & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsProtected) |
1238 | 1247 | Flags |= llvm::DINode::FlagProtected; |
1239 | 1248 | if ((SPIRVFlags & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsPrivate) |
1240 | 1249 | Flags |= llvm::DINode::FlagPrivate; |
1241 | 1250 | uint64_t OffsetVal = |
1242 | | - BM->get<SPIRVConstant>(Ops[OffsetIdx - Offset])->getZExtIntValue(); |
| 1251 | + BM->get<SPIRVConstant>(Ops[OffsetIdx])->getZExtIntValue(); |
| 1252 | + DIType *Child; |
| 1253 | + if (isNonSemanticDebugInfo(DebugInst->getExtSetKind())) { |
| 1254 | + Child = ChildClass; |
| 1255 | + } else { |
| 1256 | + Child = |
| 1257 | + transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[OpenCL::ChildIdx])); |
| 1258 | + } |
1243 | 1259 | return getDIBuilder(DebugInst).createInheritance(Child, Parent, OffsetVal, 0, |
1244 | 1260 | Flags); |
1245 | 1261 | } |
|
0 commit comments