LinkAllAsmWriterComponents.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //===- llvm/Codegen/LinkAllAsmWriterComponents.h ----------------*- 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 assembler writer related passes for tools like
  10. // llc that need this functionality.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
  14. #define LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
  15. #include "llvm/IR/BuiltinGCs.h"
  16. #include <cstdlib>
  17. namespace {
  18. struct ForceAsmWriterLinking {
  19. ForceAsmWriterLinking() {
  20. // We must reference the plug-ins in such a way that compilers will not
  21. // delete it all as dead code, even with whole program optimization,
  22. // yet is effectively a NO-OP. As the compiler isn't smart enough
  23. // to know that getenv() never returns -1, this will do the job.
  24. if (std::getenv("bar") != (char*) -1)
  25. return;
  26. llvm::linkOcamlGCPrinter();
  27. llvm::linkErlangGCPrinter();
  28. }
  29. } ForceAsmWriterLinking; // Force link by creating a global definition.
  30. }
  31. #endif // LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H