forked from OSchip/llvm-project
Revert "[DebugInfo] Refactor code for emitting DWARF expressions for FP constants"
The commit introduced a crash when emitting (debug info for) complex floats (pr48277).
This commit is contained in:
parent
c3a331646e
commit
bce2ac9f6d
|
@ -2466,11 +2466,24 @@ void DwarfDebug::emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
|
|||
// TODO TargetIndexLocation is a target-independent. Currently only the WebAssembly-specific
|
||||
// encoding is supported.
|
||||
DwarfExpr.addWasmLocation(Loc.Index, static_cast<uint64_t>(Loc.Offset));
|
||||
DwarfExpr.addExpression(std::move(ExprCursor));
|
||||
return;
|
||||
DwarfExpr.addExpression(std::move(ExprCursor));
|
||||
return;
|
||||
} else if (Value.isConstantFP()) {
|
||||
DwarfExpr.addConstantFP(Value.getConstantFP()->getValueAPF(), AP);
|
||||
return;
|
||||
if (AP.getDwarfVersion() >= 4 && !AP.getDwarfDebug()->tuneForSCE()) {
|
||||
DwarfExpr.addConstantFP(Value.getConstantFP()->getValueAPF(), AP);
|
||||
return;
|
||||
} else if (Value.getConstantFP()
|
||||
->getValueAPF()
|
||||
.bitcastToAPInt()
|
||||
.getBitWidth() <= 64 /*bits*/)
|
||||
DwarfExpr.addUnsignedConstant(
|
||||
Value.getConstantFP()->getValueAPF().bitcastToAPInt());
|
||||
else
|
||||
LLVM_DEBUG(
|
||||
dbgs()
|
||||
<< "Skipped DwarfExpression creation for ConstantFP of size"
|
||||
<< Value.getConstantFP()->getValueAPF().bitcastToAPInt().getBitWidth()
|
||||
<< " bits\n");
|
||||
}
|
||||
DwarfExpr.addExpression(std::move(ExprCursor));
|
||||
}
|
||||
|
|
|
@ -200,29 +200,10 @@ void DwarfExpression::addUnsignedConstant(uint64_t Value) {
|
|||
emitConstu(Value);
|
||||
}
|
||||
|
||||
void DwarfExpression::addUnsignedConstant(APInt Value, const AsmPrinter &AP) {
|
||||
void DwarfExpression::addUnsignedConstant(const APInt &Value) {
|
||||
assert(isImplicitLocation() || isUnknownLocation());
|
||||
LocationKind = Implicit;
|
||||
|
||||
if (AP.getDwarfVersion() >= 4 && !AP.getDwarfDebug()->tuneForSCE()) {
|
||||
int NumBytes = Value.getBitWidth() / 8;
|
||||
emitOp(dwarf::DW_OP_implicit_value);
|
||||
emitUnsigned(NumBytes /*Size of the block in bytes*/);
|
||||
|
||||
// The loop below is emitting the value starting at least significant
|
||||
// byte, so we need to perform a byte-swap to get the byte order correct
|
||||
// in case of a big-endian target.
|
||||
if (AP.getDataLayout().isBigEndian())
|
||||
Value = Value.byteSwap();
|
||||
|
||||
for (int i = 0; i < NumBytes; ++i) {
|
||||
emitData1(Value.getRawData()[0] & 0xFF);
|
||||
Value = Value.lshr(8);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned Size = Value.getBitWidth();
|
||||
const uint64_t *Data = Value.getRawData();
|
||||
|
||||
|
@ -231,9 +212,9 @@ void DwarfExpression::addUnsignedConstant(APInt Value, const AsmPrinter &AP) {
|
|||
unsigned Offset = 0;
|
||||
while (Offset < Size) {
|
||||
addUnsignedConstant(*Data++);
|
||||
addStackValue();
|
||||
if (Offset == 0 && Size <= 64)
|
||||
break;
|
||||
addStackValue();
|
||||
addOpPiece(std::min(Size - Offset, 64u), Offset);
|
||||
Offset += 64;
|
||||
}
|
||||
|
@ -243,13 +224,27 @@ void DwarfExpression::addConstantFP(const APFloat &APF, const AsmPrinter &AP) {
|
|||
assert(isImplicitLocation() || isUnknownLocation());
|
||||
APInt API = APF.bitcastToAPInt();
|
||||
int NumBytes = API.getBitWidth() / 8;
|
||||
// FIXME: Add support for `long double`.
|
||||
if (NumBytes <= 8 /*double*/)
|
||||
addUnsignedConstant(API, AP);
|
||||
else
|
||||
LLVM_DEBUG(
|
||||
dbgs() << "Skipped DwarfExpression creation for ConstantFP of size"
|
||||
<< API.getBitWidth() << " bits\n");
|
||||
if (NumBytes == 4 /*float*/ || NumBytes == 8 /*double*/) {
|
||||
// FIXME: Add support for `long double`.
|
||||
emitOp(dwarf::DW_OP_implicit_value);
|
||||
emitUnsigned(NumBytes /*Size of the block in bytes*/);
|
||||
|
||||
// The loop below is emitting the value starting at least significant byte,
|
||||
// so we need to perform a byte-swap to get the byte order correct in case
|
||||
// of a big-endian target.
|
||||
if (AP.getDataLayout().isBigEndian())
|
||||
API = API.byteSwap();
|
||||
|
||||
for (int i = 0; i < NumBytes; ++i) {
|
||||
emitData1(API.getZExtValue() & 0xFF);
|
||||
API = API.lshr(8);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
LLVM_DEBUG(
|
||||
dbgs() << "Skipped DW_OP_implicit_value creation for ConstantFP of size: "
|
||||
<< API.getBitWidth() << " bits\n");
|
||||
}
|
||||
|
||||
bool DwarfExpression::addMachineRegExpression(const TargetRegisterInfo &TRI,
|
||||
|
|
|
@ -297,7 +297,7 @@ public:
|
|||
void addUnsignedConstant(uint64_t Value);
|
||||
|
||||
/// Emit an unsigned constant.
|
||||
void addUnsignedConstant(APInt Value, const AsmPrinter &AP);
|
||||
void addUnsignedConstant(const APInt &Value);
|
||||
|
||||
/// Emit an floating point constant.
|
||||
void addConstantFP(const APFloat &Value, const AsmPrinter &AP);
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
; RUN: llc -debugger-tune=gdb -filetype=obj %s -o - | llvm-dwarfdump - \
|
||||
; RUN: | FileCheck %s --check-prefixes=GDB,BOTH
|
||||
; RUN: llc -debugger-tune=sce -filetype=obj %s -o - | llvm-dwarfdump - \
|
||||
; RUN: | FileCheck %s --check-prefixes=SCE,BOTH
|
||||
|
||||
; BOTH: DW_TAG_variable
|
||||
; BOTH-NEXT: DW_AT_location
|
||||
; GDB-NEXT: {{.*}}: DW_OP_implicit_value 0x2 0xe0 0x51
|
||||
; SCE-NEXT: {{.*}}: DW_OP_constu 0x51e0, DW_OP_stack_value
|
||||
; GDB-NEXT: {{.*}}: DW_OP_implicit_value 0x2 0x40 0x51
|
||||
; SCE-NEXT: {{.*}}: DW_OP_constu 0x5140, DW_OP_stack_value
|
||||
; BOTH-NEXT: DW_AT_name ("a")
|
||||
|
||||
source_filename = "-"
|
||||
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "armv7-unknown-unknown"
|
||||
|
||||
define dso_local arm_aapcscc void @f() local_unnamed_addr !dbg !8 {
|
||||
entry:
|
||||
call void @llvm.dbg.value(metadata half 0xH51E0, metadata !13, metadata !DIExpression()), !dbg !15
|
||||
call arm_aapcscc void bitcast (void (...)* @g to void ()*)(), !dbg !15
|
||||
call void @llvm.dbg.value(metadata half 0xH5140, metadata !13, metadata !DIExpression()), !dbg !15
|
||||
call arm_aapcscc void bitcast (void (...)* @g to void ()*)(), !dbg !15
|
||||
ret void, !dbg !15
|
||||
}
|
||||
|
||||
declare dso_local arm_aapcscc void @g(...) local_unnamed_addr
|
||||
|
||||
declare void @llvm.dbg.value(metadata, metadata, metadata) #2
|
||||
|
||||
attributes #2 = { nofree nosync nounwind readnone speculatable willreturn }
|
||||
|
||||
!llvm.dbg.cu = !{!0}
|
||||
!llvm.module.flags = !{!3, !4, !5, !6}
|
||||
!llvm.ident = !{!7}
|
||||
|
||||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug, enums: !2)
|
||||
!1 = !DIFile(filename: "-", directory: "/")
|
||||
!2 = !{}
|
||||
!3 = !{i32 7, !"Dwarf Version", i32 4}
|
||||
!4 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!5 = !{i32 1, !"wchar_size", i32 4}
|
||||
!6 = !{i32 1, !"min_enum_size", i32 4}
|
||||
!7 = !{!"clang version 12.0.0"}
|
||||
!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, type: !10, unit: !0)
|
||||
!10 = !DISubroutineType(types: !11)
|
||||
!11 = !{null}
|
||||
!12 = !{!13}
|
||||
!13 = !DILocalVariable(name: "a", scope: !8, file: !1, type: !14)
|
||||
!14 = !DIBasicType(name: "_Float16", size: 16, encoding: DW_ATE_float)
|
||||
!15 = !DILocation(line: 0, scope: !8)
|
Loading…
Reference in New Issue