aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-06-25 14:10:05 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-06-25 14:10:05 -0700
commit35d0901ac239469021a36f21e488cf20484f2095 (patch)
treee071c53b6a03c913cc7a37ad4df84c49ac733a9e /lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
parente93df18eccc8d9cad27853b805a5a22b124b416d (diff)
PNaCl wire format: Remove the top-level DATALAYOUT record
PNaCl only supports a fixed data layout, so treat this as implicit in the pexe file. Add the data layout field back at read time, to prevent accidentally using any architecture-specific backend data layout when translating, and to ensure that any IR passes that use the data layout work correctly. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3505 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17591014
Diffstat (limited to 'lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp')
-rw-r--r--lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
index 8fe6274a15..bd6ddcb020 100644
--- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
+++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
@@ -1477,13 +1477,6 @@ bool NaClBitcodeReader::ParseModule(bool Resume) {
}
break;
}
- case naclbitc::MODULE_CODE_DATALAYOUT: { // DATALAYOUT: [strchr x N]
- std::string S;
- if (ConvertToString(Record, 0, S))
- return Error("Invalid MODULE_CODE_DATALAYOUT record");
- TheModule->setDataLayout(S);
- break;
- }
case naclbitc::MODULE_CODE_ASM: { // ASM: [strchr x N]
std::string S;
if (ConvertToString(Record, 0, S))
@@ -1630,6 +1623,16 @@ bool NaClBitcodeReader::ParseModule(bool Resume) {
bool NaClBitcodeReader::ParseBitcodeInto(Module *M) {
TheModule = 0;
+ // PNaCl does not support different DataLayouts in pexes, so we
+ // implicitly set the DataLayout to the following default.
+ //
+ // This is not usually needed by the backend, but it might be used
+ // by IR passes that the PNaCl translator runs. We set this in the
+ // reader rather than in pnacl-llc so that 'opt' will also use the
+ // correct DataLayout if it is run on a pexe.
+ M->setDataLayout("e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
+ "f32:32:32-f64:64:64-p:32:32:32-v128:32:32");
+
if (InitStream()) return true;
// We expect a number of well-defined blocks, though we don't necessarily