forked from OSchip/llvm-project
Don't reach into the middle of TargetMachine and cache one of its ivars.
Not only does this break encapsulation, it's gross. llvm-svn: 182876
This commit is contained in:
parent
467441d511
commit
70b1400e6d
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue