Fix const parameter debug types

Constant qualified parameter types were not being correctly added to
the DebugTypeFunction instruction.

Fix #3095.
This commit is contained in:
Jeremy Hayes 2022-12-21 14:20:44 -07:00
parent f9b760e6c7
commit bec8359bf7
4 changed files with 115 additions and 7 deletions

View file

@ -650,8 +650,12 @@ Id Builder::makeDebugFunctionType(Id returnType, const std::vector<Id>& paramTyp
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic));
type->addIdOperand(debugId[returnType]);
for (auto const paramType : paramTypes) {
assert(isPointerType(paramType) || isArrayType(paramType));
type->addIdOperand(debugId[getContainedTypeId(paramType)]);
if (isPointerType(paramType) || isArrayType(paramType)) {
type->addIdOperand(debugId[getContainedTypeId(paramType)]);
}
else {
type->addIdOperand(debugId[paramType]);
}
}
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
@ -2062,11 +2066,16 @@ Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const
assert(paramTypes.size() == paramNames.size());
for(size_t p = 0; p < paramTypes.size(); ++p)
{
auto const& paramType = paramTypes[p];
assert(isPointerType(paramType) || isArrayType(paramType));
assert(debugId[getContainedTypeId(paramType)] != 0);
auto getParamTypeId = [this](Id const& typeId) {
if (isPointerType(typeId) || isArrayType(typeId)) {
return getContainedTypeId(typeId);
}
else {
return typeId;
}
};
auto const& paramName = paramNames[p];
auto const debugLocalVariableId = createDebugLocalVariable(debugId[getContainedTypeId(paramType)], paramName, p+1);
auto const debugLocalVariableId = createDebugLocalVariable(debugId[getParamTypeId(paramTypes[p])], paramName, p+1);
debugId[firstParamId + p] = debugLocalVariableId;
makeDebugDeclare(debugLocalVariableId, firstParamId + p);