summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@apple.com>2014-04-28 18:19:25 +0000
committerJuergen Ributzka <juergen@apple.com>2014-04-28 18:19:25 +0000
commit4989255432a7954ce8c3937a3561595891edf83d (patch)
tree3708381fd96f0ffcca677eb497a7bb1745af51a8 /llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
parent4482dcd0721794fc7560b6b5022e47a69df901c2 (diff)
downloadbcm5719-llvm-4989255432a7954ce8c3937a3561595891edf83d.tar.gz
bcm5719-llvm-4989255432a7954ce8c3937a3561595891edf83d.zip
[PM] Add pass run listeners to the pass manager.
This commit provides the necessary C/C++ APIs and infastructure to enable fine- grain progress report and safe suspension points after each pass in the pass manager. Clients can provide a callback function to the pass manager to call after each pass. This can be used in a variety of ways (progress report, dumping of IR between passes, safe suspension of threads, etc). The run listener list is maintained in the LLVMContext, which allows a multi- threaded client to be only informed for it's own thread. This of course assumes that the client created a LLVMContext for each thread. This fixes <rdar://problem/16728690> llvm-svn: 207430
Diffstat (limited to 'llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp')
-rw-r--r--llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp b/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
index 3813d59dbd1..c8e0c882299 100644
--- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
+++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
@@ -28,6 +28,7 @@ using namespace llvm;
static bool didCallAllocateCodeSection;
static bool didAllocateCompactUnwindSection;
+static bool didCallPassRunListener;
static uint8_t *roundTripAllocateCodeSection(void *object, uintptr_t size,
unsigned alignment,
@@ -64,6 +65,12 @@ static void roundTripDestroy(void *object) {
delete static_cast<SectionMemoryManager*>(object);
}
+static void passRunListenerCallback(LLVMContextRef C, LLVMPassRef P,
+ LLVMModuleRef M, LLVMValueRef F,
+ LLVMBasicBlockRef BB) {
+ didCallPassRunListener = true;
+}
+
namespace {
// memory manager to test reserve allocation space callback
@@ -142,6 +149,7 @@ protected:
virtual void SetUp() {
didCallAllocateCodeSection = false;
didAllocateCompactUnwindSection = false;
+ didCallPassRunListener = false;
Module = 0;
Function = 0;
Engine = 0;
@@ -429,3 +437,23 @@ TEST_F(MCJITCAPITest, reserve_allocation_space) {
EXPECT_TRUE(MM->UsedCodeSize > 0);
EXPECT_TRUE(MM->UsedDataSizeRW > 0);
}
+
+TEST_F(MCJITCAPITest, pass_run_listener) {
+ SKIP_UNSUPPORTED_PLATFORM;
+
+ buildSimpleFunction();
+ buildMCJITOptions();
+ buildMCJITEngine();
+ LLVMContextRef C = LLVMGetGlobalContext();
+ LLVMAddPassRunListener(C, passRunListenerCallback);
+ buildAndRunPasses();
+
+ union {
+ void *raw;
+ int (*usable)();
+ } functionPointer;
+ functionPointer.raw = LLVMGetPointerToGlobal(Engine, Function);
+
+ EXPECT_EQ(42, functionPointer.usable());
+ EXPECT_TRUE(didCallPassRunListener);
+}
OpenPOWER on IntegriCloud