LLVM API Documentation
#include "llvm/Linker.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
#include "llvm/Instructions.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/System/Path.h"
#include <iostream>
#include <sstream>
Include dependency graph for LinkModules.cpp:
Go to the source code of this file.
Functions | |
static bool | Error (std::string *E, const std::string &Message) |
static std::string | ToStr (const Type *Ty, const Module *M) |
static bool | ResolveTypes (const Type *DestTy, const Type *SrcTy, SymbolTable *DestST, const std::string &Name) |
static const FunctionType * | getFT (const PATypeHolder &TH) |
static const StructType * | getST (const PATypeHolder &TH) |
static bool | RecursiveResolveTypesI (const PATypeHolder &DestTy, const PATypeHolder &SrcTy, SymbolTable *DestST, const std::string &Name, std::vector< std::pair< PATypeHolder, PATypeHolder > > &Pointers) |
static bool | RecursiveResolveTypes (const PATypeHolder &DestTy, const PATypeHolder &SrcTy, SymbolTable *DestST, const std::string &Name) |
static bool | LinkTypes (Module *Dest, const Module *Src, std::string *Err) |
static void | PrintMap (const std::map< const Value *, Value * > &M) |
static Value * | RemapOperand (const Value *In, std::map< const Value *, Value * > &ValueMap) |
static void | ForceRenaming (GlobalValue *GV, const std::string &Name) |
static bool | GetLinkageResult (GlobalValue *Dest, GlobalValue *Src, GlobalValue::LinkageTypes <, bool &LinkFromSrc, std::string *Err) |
static bool | LinkGlobals (Module *Dest, Module *Src, std::map< const Value *, Value * > &ValueMap, std::multimap< std::string, GlobalVariable * > &AppendingVars, std::map< std::string, GlobalValue * > &GlobalsByName, std::string *Err) |
static bool | LinkGlobalInits (Module *Dest, const Module *Src, std::map< const Value *, Value * > &ValueMap, std::string *Err) |
static bool | LinkFunctionProtos (Module *Dest, const Module *Src, std::map< const Value *, Value * > &ValueMap, std::map< std::string, GlobalValue * > &GlobalsByName, std::string *Err) |
static bool | LinkFunctionBody (Function *Dest, Function *Src, std::map< const Value *, Value * > &GlobalMap, std::string *Err) |
static bool | LinkFunctionBodies (Module *Dest, Module *Src, std::map< const Value *, Value * > &ValueMap, std::string *Err) |
static bool | LinkAppendingVars (Module *M, std::multimap< std::string, GlobalVariable * > &AppendingVars, std::string *ErrorMsg) |
static bool Error | ( | std::string * | E, | |
const std::string & | Message | |||
) | [inline, static] |
Definition at line 33 of file LinkModules.cpp.
Referenced by llvm::JIT::create(), GetLinkageResult(), LinkAppendingVars(), LinkFunctionProtos(), LinkGlobalInits(), and llvm::AsmPrinter::printInlineAsm().
static void ForceRenaming | ( | GlobalValue * | GV, | |
const std::string & | Name | |||
) | [static] |
ForceRenaming - The LLVM SymbolTable class autorenames globals that conflict in the symbol table. This is good for all clients except for us. Go through the trouble to force this back.
Definition at line 370 of file LinkModules.cpp.
References llvm::Value::getName(), llvm::GlobalValue::getParent(), llvm::Module::getSymbolTable(), llvm::GlobalValue::getType(), GV, llvm::GlobalValue::hasInternalLinkage(), llvm::SymbolTable::lookup(), and llvm::Value::setName().
Referenced by LinkFunctionProtos(), and LinkGlobals().
static const FunctionType* getFT | ( | const PATypeHolder & | TH | ) | [static] |
Definition at line 84 of file LinkModules.cpp.
References llvm::PATypeHolder::get().
Referenced by RecursiveResolveTypesI().
static bool GetLinkageResult | ( | GlobalValue * | Dest, | |
GlobalValue * | Src, | |||
GlobalValue::LinkageTypes & | LT, | |||
bool & | LinkFromSrc, | |||
std::string * | Err | |||
) | [static] |
GetLinkageResult - This analyzes the two global values and determines what the result will look like in the destination module. In particular, it computes the resultant linkage type, computes whether the global in the source should be copied over to the destination (replacing the existing one), and computes whether this linkage is an error or not.
Definition at line 393 of file LinkModules.cpp.
References Dest, Error(), and Src.
Referenced by LinkGlobals().
static const StructType* getST | ( | const PATypeHolder & | TH | ) | [static] |
Definition at line 87 of file LinkModules.cpp.
References llvm::PATypeHolder::get().
Referenced by RecursiveResolveTypesI().
static bool LinkAppendingVars | ( | Module * | M, | |
std::multimap< std::string, GlobalVariable * > & | AppendingVars, | |||
std::string * | ErrorMsg | |||
) | [static] |
Definition at line 741 of file LinkModules.cpp.
References Error(), llvm::SequentialType::getElementType(), llvm::Module::getGlobalList(), llvm::GlobalVariable::getInitializer(), llvm::GlobalValue::getLinkage(), llvm::ArrayType::getNumElements(), llvm::GlobalValue::getType(), I, llvm::GlobalVariable::isConstant(), M, llvm::Value::replaceAllUsesWith(), llvm::GlobalVariable::setInitializer(), and llvm::Value::setName().
Referenced by llvm::Linker::LinkModules().
static bool LinkFunctionBodies | ( | Module * | Dest, | |
Module * | Src, | |||
std::map< const Value *, Value * > & | ValueMap, | |||
std::string * | Err | |||
) | [static] |
Definition at line 718 of file LinkModules.cpp.
References llvm::X86II::DF, E, LinkFunctionBody(), and Src.
Referenced by llvm::Linker::LinkModules().
static bool LinkFunctionBody | ( | Function * | Dest, | |
Function * | Src, | |||
std::map< const Value *, Value * > & | GlobalMap, | |||
std::string * | Err | |||
) | [static] |
Definition at line 677 of file LinkModules.cpp.
References BB, llvm::BasicBlock::begin(), Dest, E, llvm::BasicBlock::end(), I, OE, OI, RemapOperand(), and Src.
Referenced by LinkFunctionBodies().
static bool LinkFunctionProtos | ( | Module * | Dest, | |
const Module * | Src, | |||
std::map< const Value *, Value * > & | ValueMap, | |||
std::map< std::string, GlobalValue * > & | GlobalsByName, | |||
std::string * | Err | |||
) | [static] |
Definition at line 598 of file LinkModules.cpp.
References Dest, llvm::X86II::DF, E, EF, Error(), ForceRenaming(), I, RecursiveResolveTypes(), Src, and ToStr().
Referenced by llvm::Linker::LinkModules().
static bool LinkGlobalInits | ( | Module * | Dest, | |
const Module * | Src, | |||
std::map< const Value *, Value * > & | ValueMap, | |||
std::string * | Err | |||
) | [static] |
Definition at line 554 of file LinkModules.cpp.
References E, Error(), llvm::GlobalVariable::getInitializer(), llvm::GlobalValue::hasAppendingLinkage(), llvm::GlobalVariable::hasInitializer(), llvm::GlobalValue::hasLinkOnceLinkage(), llvm::GlobalValue::hasWeakLinkage(), I, RemapOperand(), llvm::GlobalVariable::setInitializer(), Src, and ToStr().
Referenced by llvm::Linker::LinkModules().
static bool LinkGlobals | ( | Module * | Dest, | |
Module * | Src, | |||
std::map< const Value *, Value * > & | ValueMap, | |||
std::multimap< std::string, GlobalVariable * > & | AppendingVars, | |||
std::map< std::string, GlobalValue * > & | GlobalsByName, | |||
std::string * | Err | |||
) | [static] |
Definition at line 441 of file LinkModules.cpp.
References Dest, E, llvm::GlobalVariable::eraseFromParent(), ForceRenaming(), llvm::GlobalValue::getLinkage(), GetLinkageResult(), llvm::Value::getName(), llvm::GlobalValue::getType(), llvm::GlobalValue::hasAppendingLinkage(), llvm::GlobalValue::hasInternalLinkage(), I, llvm::GlobalVariable::isConstant(), llvm::GlobalVariable::isExternal(), RecursiveResolveTypes(), llvm::Value::replaceAllUsesWith(), llvm::GlobalVariable::setConstant(), llvm::GlobalVariable::setInitializer(), llvm::GlobalValue::setLinkage(), and Src.
Referenced by llvm::Linker::LinkModules().
Definition at line 176 of file LinkModules.cpp.
References Dest, llvm::SymbolTable::lookupType(), Name, RecursiveResolveTypes(), ResolveTypes(), Src, llvm::SymbolTable::type_begin(), and llvm::SymbolTable::type_end().
Referenced by llvm::Linker::LinkModules().
static bool RecursiveResolveTypes | ( | const PATypeHolder & | DestTy, | |
const PATypeHolder & | SrcTy, | |||
SymbolTable * | DestST, | |||
const std::string & | Name | |||
) | [static] |
Definition at line 165 of file LinkModules.cpp.
References PointerTypes, and RecursiveResolveTypesI().
Referenced by LinkFunctionProtos(), LinkGlobals(), and LinkTypes().
static bool RecursiveResolveTypesI | ( | const PATypeHolder & | DestTy, | |
const PATypeHolder & | SrcTy, | |||
SymbolTable * | DestST, | |||
const std::string & | Name, | |||
std::vector< std::pair< PATypeHolder, PATypeHolder > > & | Pointers | |||
) | [static] |
Definition at line 94 of file LinkModules.cpp.
References first, llvm::PATypeHolder::get(), llvm::SequentialType::getElementType(), getFT(), llvm::ArrayType::getNumElements(), getST(), and ResolveTypes().
Referenced by RecursiveResolveTypes().
static Value* RemapOperand | ( | const Value * | In, | |
std::map< const Value *, Value * > & | ValueMap | |||
) | [static] |
Definition at line 266 of file LinkModules.cpp.
References CP, llvm::User::getNumOperands(), llvm::Constant::getOperand(), I, Idx, llvm::InsertElement, PrintMap(), llvm::Select, and V.
Referenced by LinkFunctionBody(), and LinkGlobalInits().
static bool ResolveTypes | ( | const Type * | DestTy, | |
const Type * | SrcTy, | |||
SymbolTable * | DestST, | |||
const std::string & | Name | |||
) | [static] |
Definition at line 63 of file LinkModules.cpp.
References llvm::SymbolTable::insert().
Referenced by LinkTypes(), and RecursiveResolveTypesI().
Definition at line 39 of file LinkModules.cpp.
References M, OS, Ty, and llvm::WriteTypeSymbolic().
Referenced by LinkFunctionProtos(), and LinkGlobalInits().