diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-03-20 11:40:34 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-06-04 11:58:51 +0000 |
| commit | 4b6eb0e63c698094db5506763df44cc83c19f643 (patch) | |
| tree | f1d30b8c10bc6db323b91538745ae8ab8b593910 /contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp | |
| parent | 76886853f03395abb680824bcc74e98f83bd477a (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp index c81288c0e460..4df34d2c9402 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp @@ -174,21 +174,26 @@ uint64_t DebugHandlerBase::getBaseTypeSize(const DIType *Ty) { } bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) { - // SROA may generate dbg value intrinsics to assign an unsigned value to a - // Fortran CHARACTER(1) type variables. Make them as unsigned. if (isa<DIStringType>(Ty)) { - assert((Ty->getSizeInBits()) == 8 && "Not a valid unsigned type!"); + // Some transformations (e.g. instcombine) may decide to turn a Fortran + // character object into an integer, and later ones (e.g. SROA) may + // further inject a constant integer in a llvm.dbg.value call to track + // the object's value. Here we trust the transformations are doing the + // right thing, and treat the constant as unsigned to preserve that value + // (i.e. avoid sign extension). return true; } - if (auto *CTy = dyn_cast<DICompositeType>(Ty)) { - // FIXME: Enums without a fixed underlying type have unknown signedness - // here, leading to incorrectly emitted constants. - if (CTy->getTag() == dwarf::DW_TAG_enumeration_type) - 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; + if (auto *CTy = dyn_cast<DICompositeType>(Ty)) { + if (CTy->getTag() == dwarf::DW_TAG_enumeration_type) { + if (!(Ty = CTy->getBaseType())) + // FIXME: Enums without a fixed underlying type have unknown signedness + // here, leading to incorrectly emitted constants. + return false; + } 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)) { |
