LinkAllIR.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===----- LinkAllIR.h - Reference All VMCore Code --------------*- 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 header file pulls in all the object modules of the VMCore library so
  15. // that tools like llc, opt, and lli can ensure they are linked with all symbols
  16. // from libVMCore.a It should only be used from a tool's main program.
  17. //
  18. //===----------------------------------------------------------------------===//
  19. #ifndef LLVM_LINKALLIR_H
  20. #define LLVM_LINKALLIR_H
  21. #include "llvm/BinaryFormat/Dwarf.h"
  22. #include "llvm/IR/InlineAsm.h"
  23. #include "llvm/IR/Instructions.h"
  24. #include "llvm/IR/LLVMContext.h"
  25. #include "llvm/IR/Module.h"
  26. #include "llvm/IR/Verifier.h"
  27. #include "llvm/Support/DynamicLibrary.h"
  28. #include "llvm/Support/MathExtras.h"
  29. #include "llvm/Support/Memory.h"
  30. #include "llvm/Support/Mutex.h"
  31. #include "llvm/Support/Path.h"
  32. #include "llvm/Support/Process.h"
  33. #include "llvm/Support/Program.h"
  34. #include "llvm/Support/Signals.h"
  35. #include <cstdlib>
  36. namespace {
  37. struct ForceVMCoreLinking {
  38. ForceVMCoreLinking() {
  39. // We must reference VMCore in such a way that compilers will not
  40. // delete it all as dead code, even with whole program optimization,
  41. // yet is effectively a NO-OP. As the compiler isn't smart enough
  42. // to know that getenv() never returns -1, this will do the job.
  43. // This is so that globals in the translation units where these functions
  44. // are defined are forced to be initialized, populating various
  45. // registries.
  46. if (std::getenv("bar") != (char*) -1)
  47. return;
  48. llvm::LLVMContext Context;
  49. (void)new llvm::Module("", Context);
  50. (void)new llvm::UnreachableInst(Context);
  51. (void) llvm::createVerifierPass();
  52. }
  53. } ForceVMCoreLinking;
  54. }
  55. #endif
  56. #ifdef __GNUC__
  57. #pragma GCC diagnostic pop
  58. #endif