Skip to content

Commit ed929f1

Browse files
committed
--Changes made as per review comments
1 parent e2413dd commit ed929f1

File tree

1 file changed

+13
-93
lines changed

1 file changed

+13
-93
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitNonSemanticDI.cpp

Lines changed: 13 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ struct SPIRVEmitNonSemanticDI : public MachineFunctionPass {
196196
SPIRVCodeGenContext &Ctx,
197197
const DenseMap<StringRef, Register> &MacroDefRegs);
198198

199-
void emitDebugTypeEnum(
200-
const SmallPtrSetImpl<const DICompositeType *> &EnumTypes,
201-
SPIRVCodeGenContext &Ctx);
199+
void
200+
emitDebugTypeEnum(const SmallPtrSetImpl<const DICompositeType *> &EnumTypes,
201+
SPIRVCodeGenContext &Ctx);
202202

203203
void emitDebugQualifiedTypes(
204204
const SmallPtrSetImpl<DIDerivedType *> &QualifiedDerivedTypes,
@@ -618,17 +618,8 @@ void SPIRVEmitNonSemanticDI::emitDebugTypeEnum(
618618
bool UnderlyingTypeIsFwd = false;
619619
Register UnderlyingTypeReg = findBaseTypeRegisterRecursive(
620620
EnumTy->getBaseType(), Ctx, UnderlyingTypeIsFwd);
621-
if (!UnderlyingTypeReg.isValid()) {
622-
UnderlyingTypeReg = EmitDIInstruction(
623-
SPIRV::NonSemanticExtInst::DebugInfoNone, {}, Ctx, false);
624-
UnderlyingTypeIsFwd = false;
625-
}
626621
Register SourceReg =
627622
findRegisterFromMap(EnumTy->getFile(), Ctx.SourceRegPairs);
628-
if (!SourceReg.isValid()) {
629-
SourceReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone,
630-
{}, Ctx, false);
631-
}
632623
Register Line = Ctx.GR->buildConstantInt(EnumTy->getLine(), Ctx.MIRBuilder,
633624
Ctx.I32Ty, false);
634625
Register Column =
@@ -639,10 +630,6 @@ void SPIRVEmitNonSemanticDI::emitDebugTypeEnum(
639630
llvm::errs() << "Warning: Could not find Parent scope register for Enum: "
640631
<< EnumTy->getName() << "\n";
641632
ParentReg = Ctx.GR->getDebugValue(EnumTy->getFile());
642-
if (!ParentReg.isValid()) {
643-
ParentReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone,
644-
{}, Ctx, false);
645-
}
646633
}
647634
Register Size = Ctx.GR->buildConstantInt(EnumTy->getSizeInBits(),
648635
Ctx.MIRBuilder, Ctx.I32Ty, false);
@@ -904,12 +891,12 @@ void SPIRVEmitNonSemanticDI::emitDebugPointerTypes(
904891
Ctx.I32Ty, false, false);
905892

906893
const DIType *BaseTy = PointerDerivedType->getBaseType();
907-
bool HasForwardRef = false;
894+
bool HasForwardRef = false;
908895
Register BaseTypeReg =
909896
findBaseTypeRegisterRecursive(BaseTy, Ctx, HasForwardRef);
910897

911898
if (!BaseTypeReg.isValid()) {
912-
llvm::errs() << "Warning: Failed to find or create placeholder for base "
899+
llvm::errs() << "Warning: Failed to find or create placeholder for base"
913900
"type of pointer.\n";
914901
BaseTypeReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone,
915902
{}, Ctx, false);
@@ -1102,14 +1089,6 @@ void SPIRVEmitNonSemanticDI::emitDebugQualifiedTypes(
11021089
Register BaseTypeReg = findBaseTypeRegisterRecursive(
11031090
QualifiedDT->getBaseType(), Ctx, IsForwardRef);
11041091

1105-
if (!BaseTypeReg.isValid()) {
1106-
llvm::errs()
1107-
<< "Warning: Could not find base type for DebugTypeQualifier.\n";
1108-
BaseTypeReg = EmitDIInstruction(
1109-
SPIRV::NonSemanticExtInst::DebugInfoNone, {}, Ctx, false);
1110-
IsForwardRef = false;
1111-
}
1112-
11131092
const uint32_t QualifierValue =
11141093
mapTagToQualifierEncoding(QualifiedDT->getTag());
11151094
const Register QualifierConstReg = Ctx.GR->buildConstantInt(
@@ -1134,14 +1113,6 @@ void SPIRVEmitNonSemanticDI::emitDebugTypedefs(
11341113
Register BaseTypeReg = findBaseTypeRegisterRecursive(
11351114
TypedefDT->getBaseType(), Ctx, HasForwardRef);
11361115

1137-
if (!BaseTypeReg.isValid()) {
1138-
llvm::errs() << "Warning: Could not find base type for Typedef: "
1139-
<< TypedefDT->getName() << "\n";
1140-
BaseTypeReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone,
1141-
{}, Ctx, false);
1142-
HasForwardRef = false;
1143-
}
1144-
11451116
Register DefReg = Ctx.GR->getDebugValue(TypedefDT);
11461117

11471118
Register DebugSourceReg =
@@ -1173,8 +1144,14 @@ void SPIRVEmitNonSemanticDI::emitDebugImportedEntities(
11731144
findRegisterFromMap(Imported->getFile(), Ctx.SourceRegPairs);
11741145
// TODO: Handle Entity as there are no current instructions for DINamespace,
11751146
// so replaced by DebugInfoNone
1176-
const Register EntityReg = EmitDIInstruction(
1177-
SPIRV::NonSemanticExtInst::DebugInfoNone, {}, Ctx, false);
1147+
const DINode *Entity = Imported->getEntity();
1148+
bool HasForwardRef = false;
1149+
Register EntityReg;
1150+
if (auto *Ty = dyn_cast<DIType>(Entity))
1151+
EntityReg = findBaseTypeRegisterRecursive(Ty, Ctx, HasForwardRef);
1152+
else
1153+
EntityReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone,
1154+
{}, Ctx, false);
11781155
const Register LineReg = Ctx.GR->buildConstantInt(
11791156
Imported->getLine(), Ctx.MIRBuilder, Ctx.I32Ty, false, false);
11801157
const Register ColumnReg =
@@ -1234,30 +1211,11 @@ Register SPIRVEmitNonSemanticDI::emitDebugGlobalVariable(
12341211
const DIType *Ty = DIGV->getType();
12351212
bool HasForwardRef = false;
12361213
Register TypeReg = findBaseTypeRegisterRecursive(Ty, Ctx, HasForwardRef);
1237-
1238-
if (!TypeReg.isValid()) {
1239-
llvm::errs() << "Warning: Could not find type for Global Variable: " << Name
1240-
<< "\n";
1241-
TypeReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone, {},
1242-
Ctx, false);
1243-
HasForwardRef = false;
1244-
}
1245-
12461214
Register DebugSourceReg =
12471215
findRegisterFromMap(DIGV->getFile(), Ctx.SourceRegPairs);
12481216
Register ParentReg;
12491217
if (ParentScope) {
12501218
ParentReg = Ctx.GR->getDebugValue(ParentScope);
1251-
if (!ParentReg.isValid()) {
1252-
llvm::errs() << "Warning: Could not find parent scope register for "
1253-
"Global Variable.\n";
1254-
ParentReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone,
1255-
{}, Ctx, false);
1256-
}
1257-
} else {
1258-
llvm::errs() << "Warning: DIGlobalVariable has no parent scope\n";
1259-
ParentReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone, {},
1260-
Ctx, false);
12611219
}
12621220
// TODO: Handle Variable Location operand
12631221
Register VariableReg = EmitDIInstruction(
@@ -1286,14 +1244,6 @@ void SPIRVEmitNonSemanticDI::emitDebugArrayTypes(
12861244
Register BaseTypeReg =
12871245
findBaseTypeRegisterRecursive(ElementType, Ctx, HasForwardRef);
12881246

1289-
if (!BaseTypeReg.isValid()) {
1290-
llvm::errs()
1291-
<< "Warning: Could not find element type for Array/Vector.\n";
1292-
BaseTypeReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone,
1293-
{}, Ctx, false);
1294-
HasForwardRef = false;
1295-
}
1296-
12971247
DINodeArray Subranges = ArrayTy->getElements();
12981248
if (ArrayTy->isVector()) {
12991249
assert(Subranges.size() == 1 && "Only 1D vectors supported!");
@@ -1383,14 +1333,6 @@ void SPIRVEmitNonSemanticDI::emitAllTemplateDebugInstructions(
13831333
TypeReg = findBaseTypeRegisterRecursive(TTP->getType(), Ctx,
13841334
ParamHasForwardRef);
13851335

1386-
if (!TypeReg.isValid()) {
1387-
llvm::errs()
1388-
<< "Warning: Could not find type for DITemplateTypeParameter: "
1389-
<< TTP->getName() << "\n";
1390-
TypeReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone,
1391-
{}, Ctx, false);
1392-
ParamHasForwardRef = false;
1393-
}
13941336
if (ParamHasForwardRef)
13951337
HasForwardRef = true;
13961338

@@ -1415,14 +1357,6 @@ void SPIRVEmitNonSemanticDI::emitAllTemplateDebugInstructions(
14151357
HasForwardRef = true;
14161358
}
14171359

1418-
if (!TypeReg.isValid()) {
1419-
llvm::errs()
1420-
<< "Warning: Could not find type for DITemplateValueParameter: "
1421-
<< TVP->getName() << "\n";
1422-
TypeReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone,
1423-
{}, Ctx, false);
1424-
}
1425-
14261360
int64_t ActualValue = 0;
14271361
if (auto *CAM = dyn_cast_or_null<ConstantAsMetadata>(TVP->getValue())) {
14281362
if (auto *CI = dyn_cast<ConstantInt>(CAM->getValue())) {
@@ -1650,26 +1584,12 @@ void SPIRVEmitNonSemanticDI::emitDebugTypePtrToMember(
16501584
bool MemberTypeIsFwd = false;
16511585
Register MemberTypeReg =
16521586
findBaseTypeRegisterRecursive(BaseTy, Ctx, MemberTypeIsFwd);
1653-
if (!MemberTypeReg.isValid()) {
1654-
llvm::errs()
1655-
<< "Warning: Could not find Member Type for PtrToMember.\n";
1656-
MemberTypeReg = EmitDIInstruction(
1657-
SPIRV::NonSemanticExtInst::DebugInfoNone, {}, Ctx, false);
1658-
MemberTypeIsFwd = false;
1659-
}
16601587
if (MemberTypeIsFwd)
16611588
OpHasForwardRef = true;
16621589
const DIType *ClassTy = PtrToMemberType->getClassType();
16631590
bool ParentTypeIsFwd = false;
16641591
Register ParentReg =
16651592
findBaseTypeRegisterRecursive(ClassTy, Ctx, ParentTypeIsFwd);
1666-
if (!ParentReg.isValid()) {
1667-
llvm::errs()
1668-
<< "Warning: Could not find Parent Type for PtrToMember.\n";
1669-
ParentReg = EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone,
1670-
{}, Ctx, false);
1671-
ParentTypeIsFwd = false;
1672-
}
16731593
if (ParentTypeIsFwd)
16741594
OpHasForwardRef = true;
16751595

0 commit comments

Comments
 (0)