Skip to content

[DebugInfo] Add default true return for unexpected types in isUnsignedType #8438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) {
// FIXME: Enums without a fixed underlying type have unknown signedness
// here, leading to incorrectly emitted constants.
return false;
}
// (Pieces of) aggregate types that get hacked apart by SROA may be
// represented by a constant. Encode them as unsigned bytes.
return true;
} else
// (Pieces of) aggregate types that get hacked apart by SROA may be
// represented by a constant. Encode them as unsigned bytes.
return true;
}

if (auto *DTy = dyn_cast<DIDerivedType>(Ty)) {
Expand All @@ -215,22 +215,26 @@ bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) {
return isUnsignedDIType(DTy->getBaseType());
}

auto *BTy = cast<DIBasicType>(Ty);
unsigned Encoding = BTy->getEncoding();
assert((Encoding == dwarf::DW_ATE_unsigned ||
Encoding == dwarf::DW_ATE_unsigned_char ||
Encoding == dwarf::DW_ATE_signed ||
Encoding == dwarf::DW_ATE_signed_char ||
Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF ||
Encoding == dwarf::DW_ATE_boolean ||
Encoding == dwarf::DW_ATE_complex_float ||
(Ty->getTag() == dwarf::DW_TAG_unspecified_type &&
Ty->getName() == "decltype(nullptr)")) &&
"Unsupported encoding");
return Encoding == dwarf::DW_ATE_unsigned ||
Encoding == dwarf::DW_ATE_unsigned_char ||
Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean ||
Ty->getTag() == dwarf::DW_TAG_unspecified_type;
if (auto *BTy = dyn_cast<DIBasicType>(Ty)) {
unsigned Encoding = BTy->getEncoding();
assert((Encoding == dwarf::DW_ATE_unsigned ||
Encoding == dwarf::DW_ATE_unsigned_char ||
Encoding == dwarf::DW_ATE_signed ||
Encoding == dwarf::DW_ATE_signed_char ||
Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF ||
Encoding == dwarf::DW_ATE_boolean ||
Encoding == dwarf::DW_ATE_complex_float ||
(Ty->getTag() == dwarf::DW_TAG_unspecified_type &&
Ty->getName() == "decltype(nullptr)")) &&
"Unsupported encoding");
return Encoding == dwarf::DW_ATE_unsigned ||
Encoding == dwarf::DW_ATE_unsigned_char ||
Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean ||
Ty->getTag() == dwarf::DW_TAG_unspecified_type;
}
// FIXME: the signedness should come from the expression where the type is
// used in, not the type itself.
return true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On which code path dis this originally crash? Just checking whether this still addresses the original issue you wanted to solve.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was originally a DICompositeType with an DW_TAG_enumeration_type tag, whose base type was another DICompositeType.

}

static bool hasDebugInfo(const MachineModuleInfo *MMI,
Expand Down