MCJIT.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- MCJIT.h - MC-Based Just-In-Time Execution Engine --------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file forces the MCJIT to link in on certain operating systems.
  15. // (Windows).
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_EXECUTIONENGINE_MCJIT_H
  19. #define LLVM_EXECUTIONENGINE_MCJIT_H
  20. #include "llvm/ExecutionEngine/ExecutionEngine.h"
  21. #include <cstdlib>
  22. extern "C" void LLVMLinkInMCJIT();
  23. namespace {
  24. struct ForceMCJITLinking {
  25. ForceMCJITLinking() {
  26. // We must reference MCJIT in such a way that compilers will not
  27. // delete it all as dead code, even with whole program optimization,
  28. // yet is effectively a NO-OP. As the compiler isn't smart enough
  29. // to know that getenv() never returns -1, this will do the job.
  30. // This is so that globals in the translation units where these functions
  31. // are defined are forced to be initialized, populating various
  32. // registries.
  33. if (std::getenv("bar") != (char*) -1)
  34. return;
  35. LLVMLinkInMCJIT();
  36. }
  37. } ForceMCJITLinking;
  38. }
  39. #endif
  40. #ifdef __GNUC__
  41. #pragma GCC diagnostic pop
  42. #endif