Emit DebugTypePointer when non-semantic debug info is enabled

This commit is contained in:
Sajjad Mirza 2023-12-28 08:00:37 -08:00 committed by GitHub
parent 89824a83b7
commit e17ecb0e80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 9174 additions and 8925 deletions

View file

@ -242,6 +242,11 @@ Id Builder::makePointer(StorageClass storageClass, Id pointee)
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
if (emitNonSemanticShaderDebugInfo) {
const Id debugResultId = makePointerDebugType(storageClass, pointee);
debugId[type->getResultId()] = debugResultId;
}
return type->getResultId();
}
@ -1070,6 +1075,34 @@ Id Builder::makeCompositeDebugType(std::vector<Id> const& memberTypes, char cons
return type->getResultId();
}
Id Builder::makePointerDebugType(StorageClass storageClass, Id const baseType)
{
const Id debugBaseType = debugId[baseType];
if (!debugBaseType) {
return makeDebugInfoNone();
}
const Id scID = makeUintConstant(storageClass);
for (Instruction* otherType : groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypePointer]) {
if (otherType->getIdOperand(2) == debugBaseType &&
otherType->getIdOperand(3) == scID) {
return otherType->getResultId();
}
}
Instruction* type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypePointer);
type->addIdOperand(debugBaseType);
type->addIdOperand(scID);
type->addIdOperand(makeUintConstant(0));
groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypePointer].push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
}
Id Builder::makeDebugSource(const Id fileName) {
if (debugSourceId.find(fileName) != debugSourceId.end())
return debugSourceId[fileName];