Remove beforeExecuteLTOPasses callback
This callback had very unclear semantics and the current use was suprising.
Specifically, it took a PassManager parameter, but adding anything to this pass
manager would cause the passes to be executed after the other LTO passes The
only way to execute passes before the LTO passes, was to create a new pass
manager that executes a pass right before all LTO passes (that have already
being queued in the pass manager passed in as a parameter) will be executed.
The very same behavior can be achieved by just adding our passes to the
normal pass manager using the "BeforeAddLTOPasses" callback.
We used this callback to schedule the ForEachExpand pass. This pass is now
moved to the beforeAddLTOPasses callback.
Change-Id: I3916543a4ee282e403174b90dc7b7588baab9ea3
diff --git a/lib/Renderscript/RSCompiler.cpp b/lib/Renderscript/RSCompiler.cpp
index 618c1c3..9acc455 100644
--- a/lib/Renderscript/RSCompiler.cpp
+++ b/lib/Renderscript/RSCompiler.cpp
@@ -29,7 +29,7 @@
using namespace bcc;
-bool RSCompiler::beforeAddLTOPasses(Script &pScript, llvm::PassManager &pPM) {
+bool RSCompiler::addInternalizeSymbolsPass(Script &pScript, llvm::PassManager &pPM) {
// Add a pass to internalize the symbols that don't need to have global
// visibility.
RSScript &script = static_cast<RSScript &>(pScript);
@@ -87,11 +87,7 @@
return true;
}
-bool RSCompiler::beforeExecuteLTOPasses(Script &pScript,
- llvm::PassManager &pPM) {
- // Execute a pass to expand foreach-able functions
- llvm::PassManager rs_passes;
-
+bool RSCompiler::addExpandForEachPass(Script &pScript, llvm::PassManager &pPM) {
// Script passed to RSCompiler must be a RSScript.
RSScript &script = static_cast<RSScript &>(pScript);
const RSInfo *info = script.getInfo();
@@ -104,14 +100,21 @@
}
// Expand ForEach on CPU path to reduce launch overhead.
- rs_passes.add(createRSForEachExpandPass(info->getExportForeachFuncs(),
- /* pEnableStepOpt */ true));
- if (script.getEmbedInfo()) {
- rs_passes.add(createRSEmbedInfoPass(info));
- }
+ bool pEnableStepOpt = true;
+ pPM.add(createRSForEachExpandPass(info->getExportForeachFuncs(),
+ pEnableStepOpt));
+ if (script.getEmbedInfo())
+ pPM.add(createRSEmbedInfoPass(info));
- // Execute the pass.
- rs_passes.run(module);
+ return true;
+}
+
+bool RSCompiler::beforeAddLTOPasses(Script &pScript, llvm::PassManager &pPM) {
+ if (!addExpandForEachPass(pScript, pPM))
+ return false;
+
+ if (!addInternalizeSymbolsPass(pScript, pPM))
+ return false;
return true;
}