109467b48Spatrick //===-- MCJIT.h - MC-Based Just-In-Time Execution Engine --------*- C++ -*-===// 209467b48Spatrick // 309467b48Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 409467b48Spatrick // See https://llvm.org/LICENSE.txt for license information. 509467b48Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 609467b48Spatrick // 709467b48Spatrick //===----------------------------------------------------------------------===// 809467b48Spatrick // 909467b48Spatrick // This file forces the MCJIT to link in on certain operating systems. 1009467b48Spatrick // (Windows). 1109467b48Spatrick // 1209467b48Spatrick //===----------------------------------------------------------------------===// 1309467b48Spatrick 1409467b48Spatrick #ifndef LLVM_EXECUTIONENGINE_MCJIT_H 1509467b48Spatrick #define LLVM_EXECUTIONENGINE_MCJIT_H 1609467b48Spatrick 1709467b48Spatrick #include "llvm/ExecutionEngine/ExecutionEngine.h" 1809467b48Spatrick #include <cstdlib> 1909467b48Spatrick 2009467b48Spatrick extern "C" void LLVMLinkInMCJIT(); 2109467b48Spatrick 2209467b48Spatrick namespace { 2309467b48Spatrick struct ForceMCJITLinking { ForceMCJITLinkingForceMCJITLinking2409467b48Spatrick ForceMCJITLinking() { 2509467b48Spatrick // We must reference MCJIT in such a way that compilers will not 2609467b48Spatrick // delete it all as dead code, even with whole program optimization, 2709467b48Spatrick // yet is effectively a NO-OP. As the compiler isn't smart enough 2809467b48Spatrick // to know that getenv() never returns -1, this will do the job. 29*d415bd75Srobert // This is so that globals in the translation units where these functions 30*d415bd75Srobert // are defined are forced to be initialized, populating various 31*d415bd75Srobert // registries. 3209467b48Spatrick if (std::getenv("bar") != (char*) -1) 3309467b48Spatrick return; 3409467b48Spatrick 3509467b48Spatrick LLVMLinkInMCJIT(); 3609467b48Spatrick } 3709467b48Spatrick } ForceMCJITLinking; 3809467b48Spatrick } 3909467b48Spatrick 4009467b48Spatrick #endif 41