diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-05-11 15:06:20 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-05-11 15:06:20 +0000 |
commit | 958647c36decf8670f8dbfa27de4ffe48ea9f38e (patch) | |
tree | fb30d2502c3b36b9bc306e164c457003782c85af /llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | |
parent | 062bf473c142e4f2000177acded090a7c5e2eab0 (diff) | |
download | bcm5719-llvm-958647c36decf8670f8dbfa27de4ffe48ea9f38e.tar.gz bcm5719-llvm-958647c36decf8670f8dbfa27de4ffe48ea9f38e.zip |
DebugInfo: Simplify constant value emission.
This code looks to have become dead at some time in the past. I tried to
reproduce cases where LLVM would emit constants with dataN, but could
not. Upon inspection it seems the code doesn't do that anymore - the
only time a size is provided by isTypeSigned is when the type is signed,
and in those cases we use sdata. dataN is only used for unsigned types
and isTypeSigned doesn't provide a value for sizeInBits in that case.
Remove the dead cases/size plumbing.
llvm-svn: 208494
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 2d7e1c93dd5..cfaa8bcfe23 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -746,17 +746,14 @@ void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die, } /// isTypeSigned - Return true if the type is signed. -static bool isTypeSigned(DwarfDebug *DD, DIType Ty, int *SizeInBits) { +static bool isTypeSigned(DwarfDebug *DD, DIType Ty) { if (Ty.isDerivedType()) - return isTypeSigned(DD, DD->resolve(DIDerivedType(Ty).getTypeDerivedFrom()), - SizeInBits); - if (Ty.isBasicType()) - if (DIBasicType(Ty).getEncoding() == dwarf::DW_ATE_signed || - DIBasicType(Ty).getEncoding() == dwarf::DW_ATE_signed_char) { - *SizeInBits = Ty.getSizeInBits(); - return true; - } - return false; + return isTypeSigned(DD, + DD->resolve(DIDerivedType(Ty).getTypeDerivedFrom())); + + return Ty.isBasicType() && + (DIBasicType(Ty).getEncoding() == dwarf::DW_ATE_signed || + DIBasicType(Ty).getEncoding() == dwarf::DW_ATE_signed_char); } /// Return true if type encoding is unsigned. @@ -809,39 +806,12 @@ static uint64_t getBaseTypeSize(DwarfDebug *DD, DIDerivedType Ty) { void DwarfUnit::addConstantValue(DIE &Die, const MachineOperand &MO, DIType Ty) { // FIXME: This is a bit conservative/simple - it emits negative values at - // their maximum bit width which is a bit unfortunate (& doesn't prefer - // udata/sdata over dataN as suggested by the DWARF spec) + // their maximum bit width which is a bit unfortunate. assert(MO.isImm() && "Invalid machine operand!"); - int SizeInBits = -1; - bool SignedConstant = isTypeSigned(DD, Ty, &SizeInBits); - dwarf::Form Form; - - // If we're a signed constant definitely use sdata. - if (SignedConstant) { - addSInt(Die, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, MO.getImm()); - return; - } - // Else use data for now unless it's larger than we can deal with. - switch (SizeInBits) { - case 8: - Form = dwarf::DW_FORM_data1; - break; - case 16: - Form = dwarf::DW_FORM_data2; - break; - case 32: - Form = dwarf::DW_FORM_data4; - break; - case 64: - Form = dwarf::DW_FORM_data8; - break; - default: - Form = dwarf::DW_FORM_udata; - addUInt(Die, dwarf::DW_AT_const_value, Form, MO.getImm()); - return; - } - addUInt(Die, dwarf::DW_AT_const_value, Form, MO.getImm()); + addUInt(Die, dwarf::DW_AT_const_value, + isTypeSigned(DD, Ty) ? dwarf::DW_FORM_sdata : dwarf::DW_FORM_udata, + MO.getImm()); } /// addConstantFPValue - Add constant value entry in variable DIE. |