[llvm] 16312c5 - [MCJIT][test] Use new pass manager API
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 28 12:24:24 PST 2022
Author: Arthur Eubanks
Date: 2022-11-28T12:23:42-08:00
New Revision: 16312c5d7a7c4d209199c9fc69be8eccf61f0246
URL: https://github.com/llvm/llvm-project/commit/16312c5d7a7c4d209199c9fc69be8eccf61f0246
DIFF: https://github.com/llvm/llvm-project/commit/16312c5d7a7c4d209199c9fc69be8eccf61f0246.diff
LOG: [MCJIT][test] Use new pass manager API
Added:
Modified:
llvm/unittests/ExecutionEngine/MCJIT/CMakeLists.txt
llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
llvm/utils/gn/secondary/llvm/unittests/ExecutionEngine/MCJIT/BUILD.gn
Removed:
################################################################################
diff --git a/llvm/unittests/ExecutionEngine/MCJIT/CMakeLists.txt b/llvm/unittests/ExecutionEngine/MCJIT/CMakeLists.txt
index 6f333454b0e9e..8aef62aa599c2 100644
--- a/llvm/unittests/ExecutionEngine/MCJIT/CMakeLists.txt
+++ b/llvm/unittests/ExecutionEngine/MCJIT/CMakeLists.txt
@@ -2,10 +2,9 @@ set(LLVM_LINK_COMPONENTS
Analysis
Core
ExecutionEngine
- IPO
- InstCombine
MC
MCJIT
+ Passes
RuntimeDyld
ScalarOpts
Support
diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp b/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
index 085e8f801db4a..dcb79c381c426 100644
--- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
+++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
@@ -16,8 +16,7 @@
#include "llvm-c/Core.h"
#include "llvm-c/ExecutionEngine.h"
#include "llvm-c/Target.h"
-#include "llvm-c/Transforms/PassManagerBuilder.h"
-#include "llvm-c/Transforms/Scalar.h"
+#include "llvm-c/Transforms/PassBuilder.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Host.h"
@@ -286,40 +285,29 @@ class MCJITCAPITest : public testing::Test, public MCJITTestAPICommon {
}
void buildAndRunPasses() {
- LLVMPassManagerRef pass = LLVMCreatePassManager();
- LLVMAddInstructionCombiningPass(pass);
- LLVMRunPassManager(pass, Module);
- LLVMDisposePassManager(pass);
+ LLVMPassBuilderOptionsRef Options = LLVMCreatePassBuilderOptions();
+ if (LLVMErrorRef E =
+ LLVMRunPasses(Module, "instcombine", nullptr, Options)) {
+ char *Msg = LLVMGetErrorMessage(E);
+ LLVMConsumeError(E);
+ LLVMDisposePassBuilderOptions(Options);
+ FAIL() << "Failed to run passes: " << Msg;
+ }
+
+ LLVMDisposePassBuilderOptions(Options);
}
void buildAndRunOptPasses() {
- LLVMPassManagerBuilderRef passBuilder;
-
- passBuilder = LLVMPassManagerBuilderCreate();
- LLVMPassManagerBuilderSetOptLevel(passBuilder, 2);
- LLVMPassManagerBuilderSetSizeLevel(passBuilder, 0);
-
- LLVMPassManagerRef functionPasses =
- LLVMCreateFunctionPassManagerForModule(Module);
- LLVMPassManagerRef modulePasses =
- LLVMCreatePassManager();
-
- LLVMPassManagerBuilderPopulateFunctionPassManager(passBuilder,
- functionPasses);
- LLVMPassManagerBuilderPopulateModulePassManager(passBuilder, modulePasses);
-
- LLVMPassManagerBuilderDispose(passBuilder);
-
- LLVMInitializeFunctionPassManager(functionPasses);
- for (LLVMValueRef value = LLVMGetFirstFunction(Module);
- value; value = LLVMGetNextFunction(value))
- LLVMRunFunctionPassManager(functionPasses, value);
- LLVMFinalizeFunctionPassManager(functionPasses);
-
- LLVMRunPassManager(modulePasses, Module);
-
- LLVMDisposePassManager(functionPasses);
- LLVMDisposePassManager(modulePasses);
+ LLVMPassBuilderOptionsRef Options = LLVMCreatePassBuilderOptions();
+ if (LLVMErrorRef E =
+ LLVMRunPasses(Module, "default<O2>", nullptr, Options)) {
+ char *Msg = LLVMGetErrorMessage(E);
+ LLVMConsumeError(E);
+ LLVMDisposePassBuilderOptions(Options);
+ FAIL() << "Failed to run passes: " << Msg;
+ }
+
+ LLVMDisposePassBuilderOptions(Options);
}
LLVMModuleRef Module;
diff --git a/llvm/utils/gn/secondary/llvm/unittests/ExecutionEngine/MCJIT/BUILD.gn b/llvm/utils/gn/secondary/llvm/unittests/ExecutionEngine/MCJIT/BUILD.gn
index aa1f38c39a73f..765f1621895b7 100644
--- a/llvm/utils/gn/secondary/llvm/unittests/ExecutionEngine/MCJIT/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/unittests/ExecutionEngine/MCJIT/BUILD.gn
@@ -8,12 +8,10 @@ unittest("MCJITTests") {
"//llvm/lib/ExecutionEngine/RuntimeDyld",
"//llvm/lib/IR",
"//llvm/lib/MC",
+ "//llvm/lib/Passes",
"//llvm/lib/Support",
"//llvm/lib/Target",
"//llvm/lib/Target:NativeTarget",
- "//llvm/lib/Transforms/IPO",
- "//llvm/lib/Transforms/InstCombine",
- "//llvm/lib/Transforms/Scalar",
]
sources = [
"MCJITCAPITest.cpp",
More information about the llvm-commits
mailing list