summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2015-07-24 01:44:39 +0000
committerMehdi Amini <mehdi.amini@apple.com>2015-07-24 01:44:39 +0000
commitb4bc424c9acd787fbfcd1506aadd6e49113f6b1c (patch)
tree9c2ce064903e369eb131334f15d93d259e2a7bbd /llvm/tools
parentf95da49f25fcccc9a3dd515d0ef0d6493e5f5e2a (diff)
downloadbcm5719-llvm-b4bc424c9acd787fbfcd1506aadd6e49113f6b1c.tar.gz
bcm5719-llvm-b4bc424c9acd787fbfcd1506aadd6e49113f6b1c.zip
Remove access to the DataLayout in the TargetMachine
Summary: Replace getDataLayout() with a createDataLayout() method to make explicit that it is intended to create a DataLayout only and not accessing it for other purpose. This change is the last 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: jholewinski, llvm-commits, rafael, yaron.keren Differential Revision: http://reviews.llvm.org/D11103 (cherry picked from commit 5609fc56bca971e5a7efeaa6ca4676638eaec5ea) From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 243083
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llc/llc.cpp3
-rw-r--r--llvm/tools/lli/OrcLazyJIT.cpp3
-rw-r--r--llvm/tools/lli/OrcLazyJIT.h26
3 files changed, 16 insertions, 16 deletions
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index e33cd795d3a..c51c012391b 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -312,8 +312,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
PM.add(new TargetLibraryInfoWrapperPass(TLII));
// Add the target data from the target machine, if it exists, or the module.
- if (const DataLayout *DL = Target->getDataLayout())
- M->setDataLayout(*DL);
+ M->setDataLayout(Target->createDataLayout());
// Override function attributes based on CPUStr, FeaturesStr, and command line
// flags.
diff --git a/llvm/tools/lli/OrcLazyJIT.cpp b/llvm/tools/lli/OrcLazyJIT.cpp
index ae276e6cda8..718b3903822 100644
--- a/llvm/tools/lli/OrcLazyJIT.cpp
+++ b/llvm/tools/lli/OrcLazyJIT.cpp
@@ -136,7 +136,8 @@ int llvm::runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]) {
}
// Everything looks good. Build the JIT.
- OrcLazyJIT J(std::move(TM), Context, CallbackMgrBuilder);
+ auto &DL = M->getDataLayout();
+ OrcLazyJIT J(std::move(TM), DL, Context, CallbackMgrBuilder);
// Add the module, look up main and run it.
auto MainHandle = J.addModule(std::move(M));
diff --git a/llvm/tools/lli/OrcLazyJIT.h b/llvm/tools/lli/OrcLazyJIT.h
index fe86adbf951..5019523c7f0 100644
--- a/llvm/tools/lli/OrcLazyJIT.h
+++ b/llvm/tools/lli/OrcLazyJIT.h
@@ -46,16 +46,17 @@ public:
CallbackManagerBuilder;
static CallbackManagerBuilder createCallbackManagerBuilder(Triple T);
-
- OrcLazyJIT(std::unique_ptr<TargetMachine> TM, LLVMContext &Context,
- CallbackManagerBuilder &BuildCallbackMgr)
- : TM(std::move(TM)),
- ObjectLayer(),
- CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)),
- IRDumpLayer(CompileLayer, createDebugDumper()),
- CCMgr(BuildCallbackMgr(IRDumpLayer, CCMgrMemMgr, Context)),
- CODLayer(IRDumpLayer, *CCMgr, false),
- CXXRuntimeOverrides([this](const std::string &S) { return mangle(S); }) {}
+ const DataLayout &DL;
+
+ OrcLazyJIT(std::unique_ptr<TargetMachine> TM, const DataLayout &DL,
+ LLVMContext &Context, CallbackManagerBuilder &BuildCallbackMgr)
+ : DL(DL), TM(std::move(TM)), ObjectLayer(),
+ CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)),
+ IRDumpLayer(CompileLayer, createDebugDumper()),
+ CCMgr(BuildCallbackMgr(IRDumpLayer, CCMgrMemMgr, Context)),
+ CODLayer(IRDumpLayer, *CCMgr, false),
+ CXXRuntimeOverrides(
+ [this](const std::string &S) { return mangle(S); }) {}
~OrcLazyJIT() {
// Run any destructors registered with __cxa_atexit.
@@ -73,7 +74,7 @@ public:
ModuleHandleT addModule(std::unique_ptr<Module> M) {
// Attach a data-layout if one isn't already present.
if (M->getDataLayout().isDefault())
- M->setDataLayout(*TM->getDataLayout());
+ M->setDataLayout(DL);
// Record the static constructors and destructors. We have to do this before
// we hand over ownership of the module to the JIT.
@@ -131,12 +132,11 @@ public:
}
private:
-
std::string mangle(const std::string &Name) {
std::string MangledName;
{
raw_string_ostream MangledNameStream(MangledName);
- Mangler::getNameWithPrefix(MangledNameStream, Name, *TM->getDataLayout());
+ Mangler::getNameWithPrefix(MangledNameStream, Name, DL);
}
return MangledName;
}
OpenPOWER on IntegriCloud