//===- MCJITMultipeModuleTest.cpp - Unit tests for the MCJIT ----*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This test suite verifies MCJIT for handling multiple modules in a single // ExecutionEngine by building multiple modules, making function calls across // modules, accessing global variables, etc. //===----------------------------------------------------------------------===// #include "MCJITTestBase.h" #include "llvm/ExecutionEngine/MCJIT.h" #include "gtest/gtest.h" usingnamespacellvm; namespace { class MCJITMultipleModuleTest : public testing::Test, public MCJITTestBase { … }; // FIXME: ExecutionEngine has no support empty modules /* TEST_F(MCJITMultipleModuleTest, multiple_empty_modules) { SKIP_UNSUPPORTED_PLATFORM; createJIT(M.take()); // JIT-compile EXPECT_NE(0, TheJIT->getObjectImage()) << "Unable to generate executable loaded object image"; TheJIT->addModule(createEmptyModule("<other module>")); TheJIT->addModule(createEmptyModule("<other other module>")); // JIT again EXPECT_NE(0, TheJIT->getObjectImage()) << "Unable to generate executable loaded object image"; } */ // Helper Function to test add operation void checkAdd(uint64_t ptr) { … } void checkAccumulate(uint64_t ptr) { … } // FIXME: ExecutionEngine has no support empty modules /* TEST_F(MCJITMultipleModuleTest, multiple_empty_modules) { SKIP_UNSUPPORTED_PLATFORM; createJIT(M.take()); // JIT-compile EXPECT_NE(0, TheJIT->getObjectImage()) << "Unable to generate executable loaded object image"; TheJIT->addModule(createEmptyModule("<other module>")); TheJIT->addModule(createEmptyModule("<other other module>")); // JIT again EXPECT_NE(0, TheJIT->getObjectImage()) << "Unable to generate executable loaded object image"; } */ // Module A { Function FA }, // Module B { Function FB }, // execute FA then FB TEST_F(MCJITMultipleModuleTest, two_module_case) { … } // Module A { Function FA }, // Module B { Function FB }, // execute FB then FA TEST_F(MCJITMultipleModuleTest, two_module_reverse_case) { … } // Module A { Function FA }, // Module B { Extern FA, Function FB which calls FA }, // execute FB then FA TEST_F(MCJITMultipleModuleTest, two_module_extern_reverse_case) { … } // Module A { Function FA }, // Module B { Extern FA, Function FB which calls FA }, // execute FA then FB TEST_F(MCJITMultipleModuleTest, two_module_extern_case) { … } // Module A { Function FA1, Function FA2 which calls FA1 }, // Module B { Extern FA1, Function FB which calls FA1 }, // execute FB then FA2 TEST_F(MCJITMultipleModuleTest, two_module_consecutive_call_case) { … } // TODO: // Module A { Extern Global GVB, Global Variable GVA, Function FA loads GVB }, // Module B { Extern Global GVA, Global Variable GVB, Function FB loads GVA }, // Module A { Global Variable GVA, Function FA loads GVA }, // Module B { Global Variable GVB, Internal Global GVC, Function FB loads GVB }, // execute FB then FA, also check that the global variables are properly accesible // through the ExecutionEngine APIs TEST_F(MCJITMultipleModuleTest, two_module_global_variables_case) { … } // Module A { Function FA }, // Module B { Extern FA, Function FB which calls FA }, // Module C { Extern FA, Function FC which calls FA }, // execute FC, FB, FA TEST_F(MCJITMultipleModuleTest, three_module_case) { … } // Module A { Function FA }, // Module B { Extern FA, Function FB which calls FA }, // Module C { Extern FA, Function FC which calls FA }, // execute FA, FB, FC TEST_F(MCJITMultipleModuleTest, three_module_case_reverse_order) { … } // Module A { Function FA }, // Module B { Extern FA, Function FB which calls FA }, // Module C { Extern FB, Function FC which calls FB }, // execute FC, FB, FA TEST_F(MCJITMultipleModuleTest, three_module_chain_case) { … } // Module A { Function FA }, // Module B { Extern FA, Function FB which calls FA }, // Module C { Extern FB, Function FC which calls FB }, // execute FA, FB, FC TEST_F(MCJITMultipleModuleTest, three_modules_chain_case_reverse_order) { … } // Module A { Extern FB, Function FA which calls FB1 }, // Module B { Extern FA, Function FB1, Function FB2 which calls FA }, // execute FA, then FB1 // FIXME: this test case is not supported by MCJIT TEST_F(MCJITMultipleModuleTest, cross_module_dependency_case) { … } // Module A { Extern FB, Function FA which calls FB1 }, // Module B { Extern FA, Function FB1, Function FB2 which calls FA }, // execute FB1 then FA // FIXME: this test case is not supported by MCJIT TEST_F(MCJITMultipleModuleTest, cross_module_dependency_case_reverse_order) { … } // Module A { Extern FB1, Function FA which calls FB1 }, // Module B { Extern FA, Function FB1, Function FB2 which calls FA }, // execute FB1 then FB2 // FIXME: this test case is not supported by MCJIT TEST_F(MCJITMultipleModuleTest, cross_module_dependency_case3) { … } // Test that FindFunctionNamed finds the definition of // a function in the correct module. We check two functions // in two different modules, to make sure that for at least // one of them MCJIT had to ignore the extern declaration. TEST_F(MCJITMultipleModuleTest, FindFunctionNamed_test) { … } } // end anonymous namespace