LLVM API Documentation
#include "llvm/Linker.h"#include "llvm/Constants.h"#include "llvm/DerivedTypes.h"#include "llvm/Module.h"#include "llvm/TypeSymbolTable.h"#include "llvm/ValueSymbolTable.h"#include "llvm/Instructions.h"#include "llvm/Assembly/Writer.h"#include "llvm/Support/Streams.h"#include "llvm/System/Path.h"#include "llvm/ADT/DenseMap.h"#include <sstream>
Go to the source code of this file.
Functions | |
| static bool | Error (std::string *E, const std::string &Message) |
| static bool | ResolveTypes (const Type *DestTy, const Type *SrcTy) |
| static bool | RecursiveResolveTypesI (const Type *DstTy, const Type *SrcTy, LinkerTypeMap &Pointers) |
| static bool | RecursiveResolveTypes (const Type *DestTy, const Type *SrcTy) |
| 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 void | CopyGVAttributes (GlobalValue *DestGV, const GlobalValue *SrcGV) |
| static bool | GetLinkageResult (GlobalValue *Dest, const GlobalValue *Src, GlobalValue::LinkageTypes <, bool &LinkFromSrc, std::string *Err) |
| static bool | LinkGlobals (Module *Dest, const Module *Src, std::map< const Value *, Value * > &ValueMap, std::multimap< std::string, GlobalVariable * > &AppendingVars, std::string *Err) |
| static GlobalValue::LinkageTypes | CalculateAliasLinkage (const GlobalValue *SGV, const GlobalValue *DGV) |
| static bool | LinkAlias (Module *Dest, const Module *Src, std::map< const Value *, Value * > &ValueMap, 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::string *Err) |
| static bool | LinkFunctionBody (Function *Dest, Function *Src, std::map< const Value *, Value * > &ValueMap, 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 | ResolveAliases (Module *Dest) |
| static GlobalValue::LinkageTypes CalculateAliasLinkage | ( | const GlobalValue * | SGV, | |
| const GlobalValue * | DGV | |||
| ) | [static] |
Definition at line 685 of file LinkModules.cpp.
References llvm::GlobalValue::hasExternalLinkage(), llvm::GlobalValue::hasInternalLinkage(), llvm::GlobalValue::hasPrivateLinkage(), and llvm::GlobalValue::hasWeakLinkage().
Referenced by LinkAlias().
| static void CopyGVAttributes | ( | GlobalValue * | DestGV, | |
| const GlobalValue * | SrcGV | |||
| ) | [static] |
CopyGVAttributes - copy additional attributes (those not needed to construct a GlobalValue) from the SrcGV to the DestGV.
Definition at line 430 of file LinkModules.cpp.
References Alignment, llvm::GlobalValue::copyAttributesFrom(), llvm::GlobalValue::getAlignment(), and llvm::GlobalValue::setAlignment().
Referenced by LinkAlias(), LinkAppendingVars(), LinkFunctionProtos(), and LinkGlobals().
| static bool Error | ( | std::string * | E, | |
| const std::string & | Message | |||
| ) | [inline, static] |
Definition at line 35 of file LinkModules.cpp.
Referenced by llvm::JIT::createJIT(), GetLinkageResult(), LinkAlias(), LinkAppendingVars(), LinkFunctionProtos(), LinkGlobalInits(), LinkGlobals(), LLVMCreateExecutionEngine(), LLVMCreateInterpreter(), LLVMCreateJITCompiler(), LLVMCreateMemoryBufferWithContentsOfFile(), LLVMRemoveModuleProvider(), llvm::PluginLoader::operator=(), 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 412 of file LinkModules.cpp.
References llvm::Value::getName(), llvm::GlobalValue::getParent(), llvm::Module::getValueSymbolTable(), llvm::Value::setName(), and llvm::Value::takeName().
Referenced by LinkAlias(), LinkFunctionProtos(), and LinkGlobals().
| static bool GetLinkageResult | ( | GlobalValue * | Dest, | |
| const 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. It also performs visibility checks: we cannot link together two symbols with different visibilities.
Definition at line 444 of file LinkModules.cpp.
References Error(), llvm::GlobalValue::getLinkage(), llvm::Value::getName(), llvm::GlobalValue::getVisibility(), llvm::GlobalValue::hasAppendingLinkage(), llvm::GlobalValue::hasCommonLinkage(), llvm::GlobalValue::hasDLLExportLinkage(), llvm::GlobalValue::hasDLLImportLinkage(), llvm::GlobalValue::hasExternalLinkage(), llvm::GlobalValue::hasExternalWeakLinkage(), llvm::GlobalValue::hasLinkOnceLinkage(), llvm::GlobalValue::hasLocalLinkage(), llvm::GlobalValue::hasWeakLinkage(), llvm::GlobalValue::isDeclaration(), and llvm::GlobalValue::mayBeOverridden().
Referenced by LinkFunctionProtos(), and LinkGlobals().
| static bool LinkAlias | ( | Module * | Dest, | |
| const Module * | Src, | |||
| std::map< const Value *, Value * > & | ValueMap, | |||
| std::string * | Err | |||
| ) | [static] |
Definition at line 702 of file LinkModules.cpp.
References llvm::Module::alias_begin(), llvm::Module::alias_end(), CalculateAliasLinkage(), CopyGVAttributes(), DF, E, Error(), ForceRenaming(), llvm::GlobalAlias::getAliasedGlobal(), llvm::Module::getFunction(), llvm::Module::getGlobalVariable(), llvm::GlobalValue::getLinkage(), llvm::Value::getName(), llvm::Module::getNamedAlias(), llvm::GlobalValue::getType(), llvm::GlobalValue::hasLocalLinkage(), and RecursiveResolveTypes().
Referenced by llvm::Linker::LinkModules().
| static bool LinkAppendingVars | ( | Module * | M, | |
| std::multimap< std::string, GlobalVariable * > & | AppendingVars, | |||
| std::string * | ErrorMsg | |||
| ) | [static] |
Definition at line 1084 of file LinkModules.cpp.
References CopyGVAttributes(), Error(), llvm::PointerType::getAddressSpace(), llvm::GlobalValue::getAlignment(), llvm::SequentialType::getElementType(), llvm::Module::getGlobalList(), llvm::GlobalVariable::getInitializer(), llvm::GlobalValue::getLinkage(), llvm::ArrayType::getNumElements(), llvm::GlobalValue::getSection(), llvm::GlobalValue::getType(), llvm::GlobalValue::getVisibility(), llvm::GlobalVariable::isConstant(), llvm::GlobalVariable::isThreadLocal(), 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 1062 of file LinkModules.cpp.
References llvm::Module::begin(), DF, llvm::dyn_cast(), E, llvm::Module::end(), llvm::Function::isDeclaration(), and LinkFunctionBody().
Referenced by llvm::Linker::LinkModules().
| static bool LinkFunctionBody | ( | Function * | Dest, | |
| Function * | Src, | |||
| std::map< const Value *, Value * > & | ValueMap, | |||
| std::string * | Err | |||
| ) | [static] |
Definition at line 1020 of file LinkModules.cpp.
References llvm::Function::arg_begin(), llvm::Function::arg_end(), BB, llvm::MachineBasicBlock::begin(), llvm::Function::begin(), E, llvm::MachineBasicBlock::end(), llvm::Function::end(), llvm::Function::getBasicBlockList(), llvm::Function::isDeclaration(), and RemapOperand().
Referenced by LinkFunctionBodies().
| static bool LinkFunctionProtos | ( | Module * | Dest, | |
| const Module * | Src, | |||
| std::map< const Value *, Value * > & | ValueMap, | |||
| std::string * | Err | |||
| ) | [static] |
Definition at line 905 of file LinkModules.cpp.
References llvm::Module::begin(), CopyGVAttributes(), E, llvm::Module::end(), Error(), ForceRenaming(), llvm::Function::getFunctionType(), llvm::GlobalValue::getLinkage(), GetLinkageResult(), llvm::Value::getName(), llvm::Value::getNameEnd(), llvm::Value::getNameStart(), llvm::GlobalValue::getType(), llvm::Module::getValueSymbolTable(), llvm::GlobalValue::getVisibility(), llvm::GlobalValue::hasLocalLinkage(), llvm::Value::hasName(), llvm::Function::isDeclaration(), llvm::GlobalValue::isDeclaration(), llvm::ValueSymbolTable::lookup(), llvm::GlobalValue::mayBeOverridden(), RecursiveResolveTypes(), llvm::Value::replaceAllUsesWith(), llvm::GlobalValue::setLinkage(), and llvm::GlobalValue::setVisibility().
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 850 of file LinkModules.cpp.
References E, Error(), llvm::GlobalVariable::getInitializer(), llvm::Value::getName(), llvm::Module::global_begin(), llvm::Module::global_end(), llvm::GlobalValue::hasExternalLinkage(), llvm::GlobalVariable::hasInitializer(), llvm::GlobalValue::mayBeOverridden(), and RemapOperand().
Referenced by llvm::Linker::LinkModules().
| static bool LinkGlobals | ( | Module * | Dest, | |
| const Module * | Src, | |||
| std::map< const Value *, Value * > & | ValueMap, | |||
| std::multimap< std::string, GlobalVariable * > & | AppendingVars, | |||
| std::string * | Err | |||
| ) | [static] |
Definition at line 525 of file LinkModules.cpp.
References CopyGVAttributes(), E, Error(), ForceRenaming(), llvm::PointerType::getAddressSpace(), llvm::GlobalValue::getAlignment(), llvm::SequentialType::getElementType(), llvm::GlobalValue::getLinkage(), GetLinkageResult(), llvm::Value::getName(), llvm::Value::getNameEnd(), llvm::Value::getNameStart(), llvm::GlobalValue::getType(), llvm::Module::getValueSymbolTable(), llvm::GlobalValue::getVisibility(), llvm::Module::global_begin(), llvm::Module::global_end(), llvm::GlobalValue::hasAppendingLinkage(), llvm::GlobalValue::hasDLLImportLinkage(), llvm::GlobalValue::hasExternalLinkage(), llvm::GlobalValue::hasExternalWeakLinkage(), llvm::GlobalVariable::hasInitializer(), llvm::GlobalValue::hasLocalLinkage(), llvm::Value::hasName(), llvm::GlobalVariable::isConstant(), llvm::GlobalVariable::isDeclaration(), llvm::GlobalValue::isDeclaration(), llvm::ValueSymbolTable::lookup(), llvm::GlobalValue::mayBeOverridden(), RecursiveResolveTypes(), llvm::Value::replaceAllUsesWith(), llvm::GlobalValue::setAlignment(), llvm::GlobalVariable::setConstant(), llvm::GlobalValue::setLinkage(), and llvm::GlobalValue::setVisibility().
Referenced by llvm::Linker::LinkModules().
Definition at line 259 of file LinkModules.cpp.
References llvm::TypeSymbolTable::begin(), llvm::TypeSymbolTable::end(), Entry, llvm::Module::getTypeSymbolTable(), llvm::TypeSymbolTable::insert(), llvm::TypeSymbolTable::lookup(), Name, RecursiveResolveTypes(), ResolveTypes(), and RHS.
Referenced by llvm::Linker::LinkModules().
Definition at line 336 of file LinkModules.cpp.
References llvm::cerr(), and E.
Referenced by RemapOperand().
Definition at line 250 of file LinkModules.cpp.
References PointerTypes, and RecursiveResolveTypesI().
Referenced by LinkAlias(), LinkFunctionProtos(), LinkGlobals(), and LinkTypes().
| static bool RecursiveResolveTypesI | ( | const Type * | DstTy, | |
| const Type * | SrcTy, | |||
| LinkerTypeMap & | Pointers | |||
| ) | [static] |
Definition at line 155 of file LinkModules.cpp.
References DE, DT, llvm::PointerType::getAddressSpace(), llvm::SequentialType::getElementType(), llvm::Type::getNumContainedTypes(), llvm::VectorType::getNumElements(), llvm::ArrayType::getNumElements(), llvm::Type::getTypeID(), llvm::Type::isAbstract(), llvm::FunctionType::isVarArg(), ResolveTypes(), and SE.
Referenced by RecursiveResolveTypes().
| static Value* RemapOperand | ( | const Value * | In, | |
| std::map< const Value *, Value * > & | ValueMap | |||
| ) | [static] |
Definition at line 350 of file LinkModules.cpp.
References llvm::cerr(), CP, llvm::User::getNumOperands(), llvm::Constant::getOperand(), if(), and PrintMap().
Referenced by LinkFunctionBody(), and LinkGlobalInits().
| static bool ResolveAliases | ( | Module * | Dest | ) | [static] |
Definition at line 1185 of file LinkModules.cpp.
References llvm::Module::alias_begin(), llvm::Module::alias_end(), E, GV, and llvm::GlobalValue::isDeclaration().
Referenced by llvm::Linker::LinkModules().
Definition at line 56 of file LinkModules.cpp.
Referenced by LinkTypes(), and RecursiveResolveTypesI().
| TheMapTy TheMap |
Definition at line 77 of file LinkModules.cpp.
Referenced by llvm::AnnotationManager::getName(), llvm::TargetData::getStructLayout(), and llvm::TargetData::~TargetData().