summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DataLayout.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-02-25 20:01:08 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-02-25 20:01:08 +0000
commitf863ee2949e1dec8f9444cc47983c6030034bb93 (patch)
treee41e034974eab9b211942bf8736ca45d5b2ef423 /llvm/lib/IR/DataLayout.cpp
parent5689a217e303bc4fbba514cbe0491ac44b7081ef (diff)
downloadbcm5719-llvm-f863ee2949e1dec8f9444cc47983c6030034bb93.tar.gz
bcm5719-llvm-f863ee2949e1dec8f9444cc47983c6030034bb93.zip
Store a DataLayout in Module.
Now that DataLayout is not a pass, store one in Module. Since the C API expects to be able to get a char* to the datalayout description, we have to keep a std::string somewhere. This patch keeps it in Module and also uses it to represent modules without a DataLayout. Once DataLayout is mandatory, we should probably move the string to DataLayout itself since it won't be necessary anymore to represent the special case of a module without a DataLayout. llvm-svn: 202190
Diffstat (limited to 'llvm/lib/IR/DataLayout.cpp')
-rw-r--r--llvm/lib/IR/DataLayout.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 44410ceb684..d60c79f52e8 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -344,7 +344,13 @@ void DataLayout::parseSpecifier(StringRef Desc) {
}
}
-DataLayout::DataLayout(const Module *M) { init(M->getDataLayout()); }
+DataLayout::DataLayout(const Module *M) {
+ const DataLayout *Other = M->getDataLayout();
+ if (Other)
+ *this = *Other;
+ else
+ init("");
+}
void
DataLayout::setAlignment(AlignTypeEnum align_type, unsigned abi_align,
OpenPOWER on IntegriCloud