LinkAllIR.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //===----- LinkAllIR.h - Reference All VMCore Code --------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This header file pulls in all the object modules of the VMCore library so
  10. // that tools like llc, opt, and lli can ensure they are linked with all symbols
  11. // from libVMCore.a It should only be used from a tool's main program.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_LINKALLIR_H
  15. #define LLVM_LINKALLIR_H
  16. #include "llvm/BinaryFormat/Dwarf.h"
  17. #include "llvm/IR/InlineAsm.h"
  18. #include "llvm/IR/Instructions.h"
  19. #include "llvm/IR/LLVMContext.h"
  20. #include "llvm/IR/Module.h"
  21. #include "llvm/IR/Verifier.h"
  22. #include "llvm/Support/DynamicLibrary.h"
  23. #include "llvm/Support/MathExtras.h"
  24. #include "llvm/Support/Memory.h"
  25. #include "llvm/Support/Mutex.h"
  26. #include "llvm/Support/Path.h"
  27. #include "llvm/Support/Process.h"
  28. #include "llvm/Support/Program.h"
  29. #include "llvm/Support/Signals.h"
  30. #include <cstdlib>
  31. namespace {
  32. struct ForceVMCoreLinking {
  33. ForceVMCoreLinking() {
  34. // We must reference VMCore in such a way that compilers will not
  35. // delete it all as dead code, even with whole program optimization,
  36. // yet is effectively a NO-OP. As the compiler isn't smart enough
  37. // to know that getenv() never returns -1, this will do the job.
  38. if (std::getenv("bar") != (char*) -1)
  39. return;
  40. llvm::LLVMContext Context;
  41. (void)new llvm::Module("", Context);
  42. (void)new llvm::UnreachableInst(Context);
  43. (void) llvm::createVerifierPass();
  44. }
  45. } ForceVMCoreLinking;
  46. }
  47. #endif