blob: 4f4af7187be451905c6db29b75598385a6763390 [file] [log] [blame]
Jakub Staszak7ccad362013-01-10 21:55:02 +00001//===----- LinkAllIR.h - Reference All VMCore Code --------------*- C++ -*-===//
Reid Spencer6df60a92006-06-07 20:00:19 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner7ed47a12007-12-29 19:59:42 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Reid Spencer6df60a92006-06-07 20:00:19 +00007//
8//===----------------------------------------------------------------------===//
9//
Reid Spencer454d85b2006-06-07 22:09:38 +000010// This header file pulls in all the object modules of the VMCore library so
11// that tools like llc, opt, and lli can ensure they are linked with all symbols
12// from libVMCore.a It should only be used from a tool's main program.
Reid Spencer6df60a92006-06-07 20:00:19 +000013//
14//===----------------------------------------------------------------------===//
15
Jakub Staszak7ccad362013-01-10 21:55:02 +000016#ifndef LLVM_LINKALLIR_H
17#define LLVM_LINKALLIR_H
Reid Spencer6df60a92006-06-07 20:00:19 +000018
Zachary Turner19ca2b02017-06-07 03:48:56 +000019#include "llvm/BinaryFormat/Dwarf.h"
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000020#include "llvm/IR/InlineAsm.h"
21#include "llvm/IR/Instructions.h"
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000022#include "llvm/IR/LLVMContext.h"
23#include "llvm/IR/Module.h"
Chandler Carruth56e13942014-01-13 09:26:24 +000024#include "llvm/IR/Verifier.h"
Michael J. Spencer1f6efa32010-11-29 18:16:10 +000025#include "llvm/Support/DynamicLibrary.h"
Chandler Carruth255f89f2012-12-03 17:02:12 +000026#include "llvm/Support/MathExtras.h"
Michael J. Spencer1f6efa32010-11-29 18:16:10 +000027#include "llvm/Support/Memory.h"
28#include "llvm/Support/Mutex.h"
29#include "llvm/Support/Path.h"
30#include "llvm/Support/Process.h"
31#include "llvm/Support/Program.h"
32#include "llvm/Support/Signals.h"
Chris Lattner7896c9f2009-12-03 00:50:42 +000033#include <cstdlib>
Reid Spencer6df60a92006-06-07 20:00:19 +000034
35namespace {
36 struct ForceVMCoreLinking {
37 ForceVMCoreLinking() {
Reid Spencer454d85b2006-06-07 22:09:38 +000038 // We must reference VMCore in such a way that compilers will not
Reid Spencer6df60a92006-06-07 20:00:19 +000039 // delete it all as dead code, even with whole program optimization,
40 // yet is effectively a NO-OP. As the compiler isn't smart enough
41 // to know that getenv() never returns -1, this will do the job.
42 if (std::getenv("bar") != (char*) -1)
43 return;
Mehdi Amini8be77072016-04-14 21:59:01 +000044 llvm::LLVMContext Context;
45 (void)new llvm::Module("", Context);
46 (void)new llvm::UnreachableInst(Context);
Fangrui Songaf7b1832018-07-30 19:41:25 +000047 (void) llvm::createVerifierPass();
Reid Spencer6df60a92006-06-07 20:00:19 +000048 }
49 } ForceVMCoreLinking;
50}
51
52#endif