LLVM API Documentation

LinkAllIR.h
Go to the documentation of this file.
00001 //===----- LinkAllIR.h - Reference All VMCore Code --------------*- C++ -*-===//
00002 //
00003 //                      The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This header file pulls in all the object modules of the VMCore library so
00011 // that tools like llc, opt, and lli can ensure they are linked with all symbols
00012 // from libVMCore.a It should only be used from a tool's main program.
00013 //
00014 //===----------------------------------------------------------------------===//
00015 
00016 #ifndef LLVM_LINKALLIR_H
00017 #define LLVM_LINKALLIR_H
00018 
00019 #include "llvm/IR/InlineAsm.h"
00020 #include "llvm/IR/Instructions.h"
00021 #include "llvm/IR/IntrinsicInst.h"
00022 #include "llvm/IR/LLVMContext.h"
00023 #include "llvm/IR/Module.h"
00024 #include "llvm/IR/Verifier.h"
00025 #include "llvm/Support/Dwarf.h"
00026 #include "llvm/Support/DynamicLibrary.h"
00027 #include "llvm/Support/MathExtras.h"
00028 #include "llvm/Support/Memory.h"
00029 #include "llvm/Support/Mutex.h"
00030 #include "llvm/Support/Path.h"
00031 #include "llvm/Support/Process.h"
00032 #include "llvm/Support/Program.h"
00033 #include "llvm/Support/Signals.h"
00034 #include "llvm/Support/TimeValue.h"
00035 #include <cstdlib>
00036 
00037 namespace {
00038   struct ForceVMCoreLinking {
00039     ForceVMCoreLinking() {
00040       // We must reference VMCore in such a way that compilers will not
00041       // delete it all as dead code, even with whole program optimization,
00042       // yet is effectively a NO-OP. As the compiler isn't smart enough
00043       // to know that getenv() never returns -1, this will do the job.
00044       if (std::getenv("bar") != (char*) -1)
00045         return;
00046       (void)new llvm::Module("", llvm::getGlobalContext());
00047       (void)new llvm::UnreachableInst(llvm::getGlobalContext());
00048       (void)    llvm::createVerifierPass(); 
00049     }
00050   } ForceVMCoreLinking;
00051 }
00052 
00053 #endif