LLVM API Documentation
#include "llvm/Linker.h"#include "llvm/Constants.h"#include "llvm/DerivedTypes.h"#include "llvm/LLVMContext.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/Support/ErrorHandling.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 Twine &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, LLVMContext &Context) |
| 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 void | LinkNamedMDNodes (Module *Dest, Module *Src) |
| 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 720 of file LinkModules.cpp.
References llvm::GlobalValue::getLinkage().
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 447 of file LinkModules.cpp.
References Alignment, llvm::GlobalValue::copyAttributesFrom(), llvm::GlobalValue::getAlignment(), and llvm::GlobalValue::setAlignment().
Referenced by LinkAlias(), LinkAppendingVars(), LinkFunctionProtos(), and LinkGlobals().
Definition at line 37 of file LinkModules.cpp.
References llvm::Twine::str().
Referenced by GetLinkageResult(), LinkAlias(), LinkAppendingVars(), LinkFunctionProtos(), LinkGlobalInits(), LinkGlobals(), LLVMCreateExecutionEngine(), LLVMCreateInterpreter(), LLVMCreateJITCompiler(), LLVMCreateMemoryBufferWithContentsOfFile(), LLVMRemoveModuleProvider(), llvm::PluginLoader::operator=(), llvm::AsmPrinter::printInlineAsm(), and llvm::JIT::selectTarget().
| 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 429 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 461 of file LinkModules.cpp.
References Error(), llvm::GlobalValue::getLinkage(), llvm::Value::getName(), llvm::GlobalValue::getVisibility(), llvm::GlobalValue::hasAppendingLinkage(), llvm::GlobalValue::hasAvailableExternallyLinkage(), 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::isWeakForLinker().
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 747 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 1130 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 1108 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 1066 of file LinkModules.cpp.
References llvm::Function::arg_begin(), llvm::Function::arg_end(), BB, llvm::MachineBasicBlock::begin(), llvm::Function::begin(), E, llvm::Function::end(), llvm::MachineBasicBlock::end(), llvm::Function::getBasicBlockList(), llvm::Function::getContext(), 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 951 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::GlobalValue::getType(), llvm::Module::getValueSymbolTable(), llvm::GlobalValue::getVisibility(), llvm::GlobalValue::hasLocalLinkage(), llvm::Value::hasName(), llvm::GlobalValue::isDeclaration(), llvm::Function::isDeclaration(), llvm::GlobalValue::isWeakForLinker(), llvm::ValueSymbolTable::lookup(), 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 895 of file LinkModules.cpp.
References E, Error(), llvm::Module::getContext(), llvm::GlobalVariable::getInitializer(), llvm::Value::getName(), llvm::Module::global_begin(), llvm::Module::global_end(), llvm::GlobalValue::hasExternalLinkage(), llvm::GlobalVariable::hasInitializer(), llvm::GlobalValue::isWeakForLinker(), llvm_unreachable, 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 559 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::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::GlobalValue::isWeakForLinker(), llvm::ValueSymbolTable::lookup(), 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 542 of file LinkModules.cpp.
References llvm::NamedMDNode::addElement(), E, llvm::NamedMDNode::getElement(), llvm::Value::getName(), llvm::Module::getNamedMetadata(), llvm::NamedMDNode::getNumElements(), llvm::Module::named_metadata_begin(), and llvm::Module::named_metadata_end().
Referenced by llvm::Linker::LinkModules().
Definition at line 261 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 338 of file LinkModules.cpp.
References llvm::cerr(), and E.
Referenced by RemapOperand().
Definition at line 252 of file LinkModules.cpp.
References RecursiveResolveTypesI().
Referenced by LinkAlias(), LinkFunctionProtos(), LinkGlobals(), and LinkTypes().
| static bool RecursiveResolveTypesI | ( | const Type * | DstTy, | |
| const Type * | SrcTy, | |||
| LinkerTypeMap & | Pointers | |||
| ) | [static] |
Definition at line 157 of file LinkModules.cpp.
References DE, DT, llvm::PointerType::getAddressSpace(), llvm::SequentialType::getElementType(), llvm::Type::getNumContainedTypes(), llvm::ArrayType::getNumElements(), llvm::VectorType::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, | |||
| LLVMContext & | Context | |||
| ) | [static] |
Definition at line 352 of file LinkModules.cpp.
References llvm::cerr(), CP, llvm::User::getNumOperands(), llvm::Constant::getOperand(), if(), llvm_unreachable, and PrintMap().
Referenced by LinkFunctionBody(), and LinkGlobalInits().
Definition at line 1234 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 58 of file LinkModules.cpp.
Referenced by LinkTypes(), and RecursiveResolveTypesI().
| TheMapTy TheMap |
Definition at line 79 of file LinkModules.cpp.
Referenced by llvm::TargetData::getStructLayout(), and llvm::TargetData::~TargetData().