aboutsummaryrefslogtreecommitdiff
path: root/tools/lto
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-11-04 09:24:40 +0000
committerBill Wendling <isanbard@gmail.com>2011-11-04 09:24:40 +0000
commitb9bff969e96a24da18d6c5d0d623a7d790d41fa2 (patch)
tree5ecb8fb2c3a2fa35f7fad9c032a56549aaa59356 /tools/lto
parent018262768f8df65f47ab43d8c0731c68d0a5b172 (diff)
Refactor the MCContext so that it's an ivar instead of a local which is passed
around. This is important for some future work as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143688 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r--tools/lto/LTOModule.cpp15
-rw-r--r--tools/lto/LTOModule.h11
2 files changed, 13 insertions, 13 deletions
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp
index 8deaf4c427..4d648a5b2d 100644
--- a/tools/lto/LTOModule.cpp
+++ b/tools/lto/LTOModule.cpp
@@ -32,7 +32,6 @@
#include "llvm/Support/system_error.h"
#include "llvm/Target/Mangler.h"
#include "llvm/MC/MCAsmInfo.h"
-#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCParser/MCAsmParser.h"
@@ -82,7 +81,8 @@ bool LTOModule::isTargetMatch(MemoryBuffer *buffer, const char *triplePrefix) {
LTOModule::LTOModule(Module *m, TargetMachine *t)
- : _module(m), _target(t)
+ : _module(m), _target(t),
+ _context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(), NULL)
{
}
@@ -613,17 +613,17 @@ namespace {
};
}
-bool LTOModule::addAsmGlobalSymbols(MCContext &Context, std::string &errMsg) {
+bool LTOModule::addAsmGlobalSymbols(std::string &errMsg) {
const std::string &inlineAsm = _module->getModuleInlineAsm();
if (inlineAsm.empty())
return false;
- OwningPtr<RecordStreamer> Streamer(new RecordStreamer(Context));
+ OwningPtr<RecordStreamer> Streamer(new RecordStreamer(_context));
MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(inlineAsm);
SourceMgr SrcMgr;
SrcMgr.AddNewSourceBuffer(Buffer, SMLoc());
OwningPtr<MCAsmParser> Parser(createMCAsmParser(SrcMgr,
- Context, *Streamer,
+ _context, *Streamer,
*_target->getMCAsmInfo()));
OwningPtr<MCSubtargetInfo> STI(_target->getTarget().
createMCSubtargetInfo(_target->getTargetTriple(),
@@ -671,8 +671,7 @@ static bool isAliasToDeclaration(const GlobalAlias &V) {
bool LTOModule::ParseSymbols(std::string &errMsg) {
// Use mangler to add GlobalPrefix to names to match linker names.
- MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(),NULL);
- Mangler mangler(Context, *_target->getTargetData());
+ Mangler mangler(_context, *_target->getTargetData());
// add functions
for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
@@ -692,7 +691,7 @@ bool LTOModule::ParseSymbols(std::string &errMsg) {
}
// add asm globals
- if (addAsmGlobalSymbols(Context, errMsg))
+ if (addAsmGlobalSymbols(errMsg))
return true;
// add aliases
diff --git a/tools/lto/LTOModule.h b/tools/lto/LTOModule.h
index ca08aea90a..63e5e37109 100644
--- a/tools/lto/LTOModule.h
+++ b/tools/lto/LTOModule.h
@@ -15,8 +15,9 @@
#define LTO_MODULE_H
#include "llvm/Module.h"
-#include "llvm/ADT/OwningPtr.h"
+#include "llvm/MC/MCContext.h"
#include "llvm/Target/TargetMachine.h"
+#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringMap.h"
#include "llvm-c/lto.h"
@@ -83,11 +84,10 @@ private:
void addPotentialUndefinedSymbol(llvm::GlobalValue* decl,
llvm::Mangler &mangler);
void addDefinedFunctionSymbol(llvm::Function* f,
- llvm::Mangler &mangler);
+ llvm::Mangler &mangler);
void addDefinedDataSymbol(llvm::GlobalValue* v,
- llvm::Mangler &mangler);
- bool addAsmGlobalSymbols(llvm::MCContext &Context,
- std::string &errMsg);
+ llvm::Mangler &mangler);
+ bool addAsmGlobalSymbols(std::string &errMsg);
void addAsmGlobalSymbol(const char *,
lto_symbol_attributes scope);
void addAsmGlobalSymbolUndef(const char *);
@@ -118,6 +118,7 @@ private:
StringSet _defines;
llvm::StringMap<NameAndAttributes> _undefines;
std::vector<const char*> _asm_undefines;
+ llvm::MCContext _context;
};
#endif // LTO_MODULE_H