1193323Sed//===- llvm/Codegen/LinkAllAsmWriterComponents.h ----------------*- C++ -*-===//
2193323Sed//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6193323Sed//
7193323Sed//===----------------------------------------------------------------------===//
8193323Sed//
9193323Sed// This header file pulls in all assembler writer related passes for tools like
10193323Sed// llc that need this functionality.
11193323Sed//
12193323Sed//===----------------------------------------------------------------------===//
13193323Sed
14193323Sed#ifndef LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
15193323Sed#define LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
16193323Sed
17344779Sdim#include "llvm/CodeGen/BuiltinGCs.h"
18199481Srdivacky#include <cstdlib>
19193323Sed
20193323Sednamespace {
21193323Sed  struct ForceAsmWriterLinking {
22193323Sed    ForceAsmWriterLinking() {
23193323Sed      // We must reference the plug-ins in such a way that compilers will not
24193323Sed      // delete it all as dead code, even with whole program optimization,
25193323Sed      // yet is effectively a NO-OP. As the compiler isn't smart enough
26193323Sed      // to know that getenv() never returns -1, this will do the job.
27193323Sed      if (std::getenv("bar") != (char*) -1)
28193323Sed        return;
29193323Sed
30193323Sed      llvm::linkOcamlGCPrinter();
31249423Sdim      llvm::linkErlangGCPrinter();
32193323Sed
33193323Sed    }
34193323Sed  } ForceAsmWriterLinking; // Force link by creating a global definition.
35193323Sed}
36193323Sed
37193323Sed#endif // LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
38