summaryrefslogtreecommitdiffstats
path: root/llvm/examples
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-02-25 23:25:17 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-02-25 23:25:17 +0000
commit339430f9935c4d3bb620f5e63be7ea3a7b3ea5ae (patch)
tree4c0929b332b0844dd8142e2eaf33885b332c6248 /llvm/examples
parent11918cff19ad106e16e851637e3dfef515c4861e (diff)
downloadbcm5719-llvm-339430f9935c4d3bb620f5e63be7ea3a7b3ea5ae.tar.gz
bcm5719-llvm-339430f9935c4d3bb620f5e63be7ea3a7b3ea5ae.zip
Use DataLayout from the module when easily available.
Eventually DataLayoutPass should go away, but for now that is the only easy way to get a DataLayout in some APIs. This patch only changes the ones that have easy access to a Module. One interesting issue with sometimes using DataLayoutPass and sometimes fetching it from the Module is that we have to make sure they are equivalent. We can get most of the way there by always constructing the pass with a Module. In fact, the pass could be changed to point to an external DataLayout instead of owning one to make this stricter. Unfortunately, the C api passes a DataLayout, so it has to be up to the caller to make sure the pass and the module are in sync. llvm-svn: 202204
Diffstat (limited to 'llvm/examples')
-rw-r--r--llvm/examples/ExceptionDemo/ExceptionDemo.cpp3
-rw-r--r--llvm/examples/Kaleidoscope/Chapter4/toy.cpp3
-rw-r--r--llvm/examples/Kaleidoscope/Chapter5/toy.cpp3
-rw-r--r--llvm/examples/Kaleidoscope/Chapter6/toy.cpp3
-rw-r--r--llvm/examples/Kaleidoscope/Chapter7/toy.cpp3
5 files changed, 10 insertions, 5 deletions
diff --git a/llvm/examples/ExceptionDemo/ExceptionDemo.cpp b/llvm/examples/ExceptionDemo/ExceptionDemo.cpp
index 4b7023faef2..24e538cacf2 100644
--- a/llvm/examples/ExceptionDemo/ExceptionDemo.cpp
+++ b/llvm/examples/ExceptionDemo/ExceptionDemo.cpp
@@ -1976,7 +1976,8 @@ int main(int argc, char *argv[]) {
// Set up the optimizer pipeline.
// Start with registering info about how the
// target lays out data structures.
- fpm.add(new llvm::DataLayoutPass(*executionEngine->getDataLayout()));
+ module->setDataLayout(executionEngine->getDataLayout());
+ fpm.add(new llvm::DataLayoutPass(module));
// Optimizations turned on
#ifdef ADD_OPT_PASSES
diff --git a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
index fd94592513a..a8f59428c0d 100644
--- a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
@@ -586,7 +586,8 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
- OurFPM.add(new DataLayoutPass(*TheExecutionEngine->getDataLayout()));
+ TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
+ OurFPM.add(new DataLayoutPass(TheModule));
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Do simple "peephole" optimizations and bit-twiddling optzns.
diff --git a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
index 3f3f0a019c6..a31b5b4792a 100644
--- a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
@@ -831,7 +831,8 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
- OurFPM.add(new DataLayoutPass(*TheExecutionEngine->getDataLayout()));
+ TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
+ OurFPM.add(new DataLayoutPass(TheModule));
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Do simple "peephole" optimizations and bit-twiddling optzns.
diff --git a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp
index c45292251d3..5a3bd2e3147 100644
--- a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp
@@ -949,7 +949,8 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
- OurFPM.add(new DataLayoutPass(*TheExecutionEngine->getDataLayout()));
+ TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
+ OurFPM.add(new DataLayoutPass(TheModule));
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Do simple "peephole" optimizations and bit-twiddling optzns.
diff --git a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
index 48d24c0508d..c2c337c9008 100644
--- a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
@@ -1113,7 +1113,8 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
- OurFPM.add(new DataLayoutPass(*TheExecutionEngine->getDataLayout()));
+ TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
+ OurFPM.add(new DataLayoutPass(TheModule));
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Promote allocas to registers.
OpenPOWER on IntegriCloud