LLVM API Documentation

include/llvm/ExecutionEngine/Interpreter.h
Go to the documentation of this file.
00001 //===-- Interpreter.h - Abstract Execution Engine Interface -----*- 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 file forces the interpreter to link in on certain operating systems.
00011 // (Windows).
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_EXECUTIONENGINE_INTERPRETER_H
00016 #define LLVM_EXECUTIONENGINE_INTERPRETER_H
00017 
00018 #include "llvm/ExecutionEngine/ExecutionEngine.h"
00019 #include <cstdlib>
00020 
00021 extern "C" void LLVMLinkInInterpreter();
00022 
00023 namespace {
00024   struct ForceInterpreterLinking {
00025     ForceInterpreterLinking() {
00026       // We must reference the interpreter in such a way that compilers will not
00027       // delete it all as dead code, even with whole program optimization,
00028       // yet is effectively a NO-OP. As the compiler isn't smart enough
00029       // to know that getenv() never returns -1, this will do the job.
00030       if (std::getenv("bar") != (char*) -1)
00031         return;
00032 
00033       LLVMLinkInInterpreter();
00034     }
00035   } ForceInterpreterLinking;
00036 }
00037 
00038 #endif