From dce4a407a24b04eebc6a376f8e62b41aaa7b071f Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Thu, 29 May 2014 02:49:00 -0700 Subject: Update LLVM for 3.5 rebase (r209712). Change-Id: I149556c940fb7dc92d075273c87ff584f400941f --- unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp') diff --git a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp index 3813d59..20d3f13 100644 --- a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp +++ b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp @@ -28,6 +28,7 @@ using namespace llvm; static bool didCallAllocateCodeSection; static bool didAllocateCompactUnwindSection; +static bool didCallYield; static uint8_t *roundTripAllocateCodeSection(void *object, uintptr_t size, unsigned alignment, @@ -64,6 +65,10 @@ static void roundTripDestroy(void *object) { delete static_cast(object); } +static void yield(LLVMContextRef, void *) { + didCallYield = true; +} + namespace { // memory manager to test reserve allocation space callback @@ -142,6 +147,7 @@ protected: virtual void SetUp() { didCallAllocateCodeSection = false; didAllocateCompactUnwindSection = false; + didCallYield = false; Module = 0; Function = 0; Engine = 0; @@ -429,3 +435,24 @@ TEST_F(MCJITCAPITest, reserve_allocation_space) { EXPECT_TRUE(MM->UsedCodeSize > 0); EXPECT_TRUE(MM->UsedDataSizeRW > 0); } + +TEST_F(MCJITCAPITest, yield) { + SKIP_UNSUPPORTED_PLATFORM; + + buildSimpleFunction(); + buildMCJITOptions(); + buildMCJITEngine(); + LLVMContextRef C = LLVMGetGlobalContext(); + LLVMContextSetYieldCallback(C, yield, NULL); + buildAndRunPasses(); + + union { + void *raw; + int (*usable)(); + } functionPointer; + functionPointer.raw = LLVMGetPointerToGlobal(Engine, Function); + + EXPECT_EQ(42, functionPointer.usable()); + EXPECT_TRUE(didCallYield); +} + -- cgit v1.1