blob: 75a5c359630e218cf075de088c0f7e4c118a55c9 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- llvm/Codegen/LinkAllAsmWriterComponents.h ----------------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
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
14#ifndef LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
15#define LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
16
Andrew Walbran16937d02019-10-22 13:54:20 +010017#include "llvm/CodeGen/BuiltinGCs.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010018#include <cstdlib>
19
20namespace {
21 struct ForceAsmWriterLinking {
22 ForceAsmWriterLinking() {
23 // We must reference the plug-ins in such a way that compilers will not
24 // delete it all as dead code, even with whole program optimization,
25 // yet is effectively a NO-OP. As the compiler isn't smart enough
26 // to know that getenv() never returns -1, this will do the job.
27 if (std::getenv("bar") != (char*) -1)
28 return;
29
30 llvm::linkOcamlGCPrinter();
31 llvm::linkErlangGCPrinter();
32
33 }
34 } ForceAsmWriterLinking; // Force link by creating a global definition.
35}
36
37#endif // LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H