aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-05-29 20:37:19 +0000
committerBill Wendling <isanbard@gmail.com>2013-05-29 20:37:19 +0000
commitcc5a882c96af6e36bc029b7ff69f62f94e2d041d (patch)
treec26c2846093ad1eee8ab7a5ccb5998af8019a392
parentaae0fa998af0f65221d7b98630162be6d88f05dc (diff)
downloadexternal_llvm-cc5a882c96af6e36bc029b7ff69f62f94e2d041d.zip
external_llvm-cc5a882c96af6e36bc029b7ff69f62f94e2d041d.tar.gz
external_llvm-cc5a882c96af6e36bc029b7ff69f62f94e2d041d.tar.bz2
Don't reach into the middle of TargetMachine and cache one of its ivars.
Not only does this break encapsulation, it's gross. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182876 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Target/Mangler.h13
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp2
-rw-r--r--lib/Target/Mangler.cpp3
-rw-r--r--lib/Target/NVPTX/NVPTXAsmPrinter.cpp2
-rw-r--r--tools/lto/LTOCodeGenerator.cpp2
-rw-r--r--tools/lto/LTOModule.cpp2
6 files changed, 13 insertions, 11 deletions
diff --git a/include/llvm/Target/Mangler.h b/include/llvm/Target/Mangler.h
index 9500f1c..986244f 100644
--- a/include/llvm/Target/Mangler.h
+++ b/include/llvm/Target/Mangler.h
@@ -17,12 +17,13 @@
#include "llvm/ADT/DenseMap.h"
namespace llvm {
-class Twine;
+
class GlobalValue;
-template <typename T> class SmallVectorImpl;
class MCContext;
class MCSymbol;
-class DataLayout;
+template <typename T> class SmallVectorImpl;
+class TargetMachine;
+class Twine;
class Mangler {
public:
@@ -34,7 +35,7 @@ public:
private:
MCContext &Context;
- const DataLayout &TD;
+ const TargetMachine *TM;
/// AnonGlobalIDs - We need to give global values the same name every time
/// they are mangled. This keeps track of the number we give to anonymous
@@ -47,8 +48,8 @@ private:
unsigned NextAnonGlobalID;
public:
- Mangler(MCContext &context, const DataLayout &td)
- : Context(context), TD(td), NextAnonGlobalID(1) {}
+ Mangler(MCContext &Context, const TargetMachine *TM)
+ : Context(Context), TM(TM), NextAnonGlobalID(1) {}
/// getSymbol - Return the MCSymbol for the specified global value. This
/// symbol is the main label that is the address of the global.
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 7ad4f57..5a83ed6 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -163,7 +163,7 @@ bool AsmPrinter::doInitialization(Module &M) {
const_cast<TargetLoweringObjectFile&>(getObjFileLowering())
.Initialize(OutContext, TM);
- Mang = new Mangler(OutContext, *TM.getDataLayout());
+ Mang = new Mangler(OutContext, &TM);
// Allow the target to emit any magic that it wants at the start of the file.
EmitStartOfAsmFile(M);
diff --git a/lib/Target/Mangler.cpp b/lib/Target/Mangler.cpp
index d31efa8..2269b73 100644
--- a/lib/Target/Mangler.cpp
+++ b/lib/Target/Mangler.cpp
@@ -19,6 +19,7 @@
#include "llvm/IR/Function.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
+#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -226,7 +227,7 @@ void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
// "Pure" variadic functions do not receive @0 suffix.
(!FT->isVarArg() || FT->getNumParams() == 0 ||
(FT->getNumParams() == 1 && F->hasStructRetAttr())))
- AddFastCallStdCallSuffix(OutName, F, TD);
+ AddFastCallStdCallSuffix(OutName, F, *TM->getDataLayout());
}
}
}
diff --git a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index 229e4e5..6cc52bd 100644
--- a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -912,7 +912,7 @@ bool NVPTXAsmPrinter::doInitialization(Module &M) {
const_cast<TargetLoweringObjectFile &>(getObjFileLowering())
.Initialize(OutContext, TM);
- Mang = new Mangler(OutContext, *TM.getDataLayout());
+ Mang = new Mangler(OutContext, &TM);
// Emit header before any dwarf directives are emitted below.
emitHeader(M, OS1);
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 8b339ee..465ccb4 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -310,7 +310,7 @@ void LTOCodeGenerator::applyScopeRestrictions() {
// mark which symbols can not be internalized
MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(),NULL);
- Mangler mangler(Context, *_target->getDataLayout());
+ Mangler mangler(Context, _target);
std::vector<const char*> mustPreserveList;
SmallPtrSet<GlobalValue*, 8> asmUsed;
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp
index 21cf4a6..2c308b6 100644
--- a/tools/lto/LTOModule.cpp
+++ b/tools/lto/LTOModule.cpp
@@ -158,7 +158,7 @@ SSPBufferSize("stack-protector-buffer-size", cl::init(8),
LTOModule::LTOModule(llvm::Module *m, llvm::TargetMachine *t)
: _module(m), _target(t),
_context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(), NULL),
- _mangler(_context, *_target->getDataLayout()) {}
+ _mangler(_context, t) {}
/// isBitcodeFile - Returns 'true' if the file (or memory contents) is LLVM
/// bitcode.