Fix setting LLVM data layout before optimizations passes
The data layout was only being set right before lowering to machine
code. The optimization passes need accurate data layout info as well.
Bug: b/135691587
Change-Id: Ic1524d57bb6d8d0eb725e33d27e100a6286f1571
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/33309
Tested-by: Nicolas Capens <nicolascapens@google.com>
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index d709d3c..d19cf52 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -678,6 +678,7 @@
void startSession()
{
::module = new llvm::Module("", *::context);
+ ::module->setDataLayout(dataLayout);
}
void endSession()
@@ -705,7 +706,6 @@
// been freed.
std::unique_ptr<llvm::Module> mod(::module);
::module = nullptr;
- mod->setDataLayout(dataLayout);
auto moduleKey = session.allocateVModule();