================
@@ -3251,10 +3252,39 @@ void DwarfDebug::emitDebugLocValue(const AsmPrinter
&AP, const DIBasicType *BT,
&AP](const DbgValueLocEntry &Entry,
DIExpressionCursor &Cursor) -> bool {
if (Entry.isInt()) {
- if (BT && (BT->getEncoding() == dwarf::DW_ATE_boolean))
+ if (BT && (BT->getEncoding() == dwarf::DW_ATE_boolean)) {
DwarfExpr.addBooleanConstant(Entry.getInt());
- else if (BT && (BT->getEncoding() == dwarf::DW_ATE_signed ||
- BT->getEncoding() == dwarf::DW_ATE_signed_char))
+ return true;
+ }
+
+ bool IsSigned = BT && (BT->getEncoding() == dwarf::DW_ATE_signed ||
+ BT->getEncoding() == dwarf::DW_ATE_signed_char);
+ if (BT && AP.getDwarfVersion() >= 4 &&
+ !AP.getDwarfDebug()->tuneForSCE() && !Cursor) {
+ // DW_OP_const* pushes a generic, address-sized value. For a wider
+ // source integer value that cannot fit in the generic type, use
+ // DW_OP_implicit_value to preserve the source bytes instead. Keep this
+ // limited to complete constant values: SCE tuning already avoids
+ // DW_OP_implicit_value for compatibility, and expressions with
+ // remaining operations may need a scalar stack value rather than an
+ // implicit value block.
+ unsigned GenericBitSize = AP.MAI.getCodePointerSize() * 8;
+ uint64_t TypeBitSize = BT->getSizeInBits();
+ bool IsByteSized = TypeBitSize % 8 == 0;
+ bool IsOutOfRange =
+ IsSigned ? !isIntN(GenericBitSize, Entry.getInt())
+ : !isUIntN(GenericBitSize,
+ static_cast<uint64_t>(Entry.getInt()));
+ if (TypeBitSize > GenericBitSize && IsByteSized && IsOutOfRange) {
+ DwarfExpr.addImplicitValue(
+ APInt(static_cast<unsigned>(TypeBitSize),
+ static_cast<uint64_t>(Entry.getInt()), IsSigned),
----------------
bevin-hansson wrote:
We're seeing assertion failures on this downstream. If `64 > TypeBitSize >
GenericBitSize` and `Entry.getInt()` has bits outside of `TypeBitSize`, APInt
triggers an assertion as `ImplicitTrunc` is false by default.
https://github.com/llvm/llvm-project/pull/204353
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits