LinkAllAsmWriterComponents.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/Codegen/LinkAllAsmWriterComponents.h ----------------*- 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 assembler writer related passes for tools like
  15. // llc that need this functionality.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
  19. #define LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
  20. #include "llvm/IR/BuiltinGCs.h"
  21. #include <cstdlib>
  22. namespace {
  23. struct ForceAsmWriterLinking {
  24. ForceAsmWriterLinking() {
  25. // We must reference the plug-ins in such a way that compilers will not
  26. // delete it all as dead code, even with whole program optimization,
  27. // yet is effectively a NO-OP. As the compiler isn't smart enough
  28. // to know that getenv() never returns -1, this will do the job.
  29. // This is so that globals in the translation units where these functions
  30. // are defined are forced to be initialized, populating various
  31. // registries.
  32. if (std::getenv("bar") != (char*) -1)
  33. return;
  34. llvm::linkOcamlGCPrinter();
  35. llvm::linkErlangGCPrinter();
  36. }
  37. } ForceAsmWriterLinking; // Force link by creating a global definition.
  38. }
  39. #endif // LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
  40. #ifdef __GNUC__
  41. #pragma GCC diagnostic pop
  42. #endif