[llvm] r242384 - Redirect pointerSize query to the TargetMachine in ASMPrinter
Mehdi Amini
mehdi.amini at apple.com
Wed Jul 15 22:59:26 PDT 2015
Author: mehdi_amini
Date: Thu Jul 16 00:59:25 2015
New Revision: 242384
URL: http://llvm.org/viewvc/llvm-project?rev=242384&view=rev
Log:
Redirect pointerSize query to the TargetMachine in ASMPrinter
Summary:
Because llvm-dsymutil is using ASMPrinter without any MachineFunction
of Module available.
This change is part of a series of commits dedicated to have a single
DataLayout during compilation by using always the one owned by the
module.
Reviewers: echristo
Subscribers: yaron.keren, rafael, llvm-commits
Differential Revision: http://reviews.llvm.org/D11078
From: Mehdi Amini <mehdi.amini at apple.com>
Modified:
llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=242384&r1=242383&r2=242384&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Thu Jul 16 00:59:25 2015
@@ -165,6 +165,9 @@ public:
/// Return information about data layout.
const DataLayout &getDataLayout() const;
+ /// Return the pointer size from the TargetMachine
+ unsigned getPointerSize() const;
+
/// Return information about subtarget.
const MCSubtargetInfo &getSubtargetInfo() const;
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=242384&r1=242383&r2=242384&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Jul 16 00:59:25 2015
@@ -140,6 +140,8 @@ const DataLayout &AsmPrinter::getDataLay
return *TM.getDataLayout();
}
+unsigned AsmPrinter::getPointerSize() const { return TM.getDataLayout()->getPointerSize(); }
+
const MCSubtargetInfo &AsmPrinter::getSubtargetInfo() const {
assert(MF && "getSubtargetInfo requires a valid MachineFunction!");
return MF->getSubtarget<MCSubtargetInfo>();
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=242384&r1=242383&r2=242384&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Thu Jul 16 00:59:25 2015
@@ -264,7 +264,8 @@ void DIEInteger::EmitValue(const AsmPrin
case dwarf::DW_FORM_udata: Asm->EmitULEB128(Integer); return;
case dwarf::DW_FORM_sdata: Asm->EmitSLEB128(Integer); return;
case dwarf::DW_FORM_addr:
- Size = Asm->getDataLayout().getPointerSize(); break;
+ Size = Asm->getPointerSize();
+ break;
case dwarf::DW_FORM_ref_addr:
Size = SizeOf(Asm, dwarf::DW_FORM_ref_addr);
break;
@@ -294,10 +295,11 @@ unsigned DIEInteger::SizeOf(const AsmPri
case dwarf::DW_FORM_GNU_addr_index: return getULEB128Size(Integer);
case dwarf::DW_FORM_udata: return getULEB128Size(Integer);
case dwarf::DW_FORM_sdata: return getSLEB128Size(Integer);
- case dwarf::DW_FORM_addr: return AP->getDataLayout().getPointerSize();
+ case dwarf::DW_FORM_addr:
+ return AP->getPointerSize();
case dwarf::DW_FORM_ref_addr:
if (AP->OutStreamer->getContext().getDwarfVersion() == 2)
- return AP->getDataLayout().getPointerSize();
+ return AP->getPointerSize();
return sizeof(int32_t);
default: llvm_unreachable("DIE Value form not supported yet");
}
@@ -326,7 +328,7 @@ unsigned DIEExpr::SizeOf(const AsmPrinte
if (Form == dwarf::DW_FORM_data4) return 4;
if (Form == dwarf::DW_FORM_sec_offset) return 4;
if (Form == dwarf::DW_FORM_strp) return 4;
- return AP->getDataLayout().getPointerSize();
+ return AP->getPointerSize();
}
#ifndef NDEBUG
@@ -352,7 +354,7 @@ unsigned DIELabel::SizeOf(const AsmPrint
if (Form == dwarf::DW_FORM_data4) return 4;
if (Form == dwarf::DW_FORM_sec_offset) return 4;
if (Form == dwarf::DW_FORM_strp) return 4;
- return AP->getDataLayout().getPointerSize();
+ return AP->getPointerSize();
}
#ifndef NDEBUG
@@ -375,7 +377,7 @@ unsigned DIEDelta::SizeOf(const AsmPrint
if (Form == dwarf::DW_FORM_data4) return 4;
if (Form == dwarf::DW_FORM_sec_offset) return 4;
if (Form == dwarf::DW_FORM_strp) return 4;
- return AP->getDataLayout().getPointerSize();
+ return AP->getPointerSize();
}
#ifndef NDEBUG
@@ -472,7 +474,7 @@ unsigned DIEEntry::getRefAddrSize(const
const DwarfDebug *DD = AP->getDwarfDebug();
assert(DD && "Expected Dwarf Debug info to be available");
if (DD->getDwarfVersion() == 2)
- return AP->getDataLayout().getPointerSize();
+ return AP->getPointerSize();
return sizeof(int32_t);
}
@@ -608,7 +610,7 @@ unsigned DIELocList::SizeOf(const AsmPri
return 4;
if (Form == dwarf::DW_FORM_sec_offset)
return 4;
- return AP->getDataLayout().getPointerSize();
+ return AP->getPointerSize();
}
/// EmitValue - Emit label value.
More information about the llvm-commits
mailing list