LLVM API Documentation

LinkModules.cpp File Reference

#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>

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 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 &LT, 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)


Function Documentation

static GlobalValue::LinkageTypes CalculateAliasLinkage ( const GlobalValue *  SGV,
const GlobalValue *  DGV 
) [static]

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]

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]

static bool LinkAppendingVars ( Module *  M,
std::multimap< std::string, GlobalVariable * > &  AppendingVars,
std::string *  ErrorMsg 
) [static]

static bool LinkFunctionBodies ( Module *  Dest,
Module *  Src,
std::map< const Value *, Value * > &  ValueMap,
std::string *  Err 
) [static]

static bool LinkFunctionBody ( Function *  Dest,
Function *  Src,
std::map< const Value *, Value * > &  ValueMap,
std::string *  Err 
) [static]

static bool LinkFunctionProtos ( Module *  Dest,
const Module *  Src,
std::map< const Value *, Value * > &  ValueMap,
std::string *  Err 
) [static]

static bool LinkGlobalInits ( Module *  Dest,
const Module *  Src,
std::map< const Value *, Value * > &  ValueMap,
std::string *  Err 
) [static]

static bool LinkGlobals ( Module *  Dest,
const Module *  Src,
std::map< const Value *, Value * > &  ValueMap,
std::multimap< std::string, GlobalVariable * > &  AppendingVars,
std::string *  Err 
) [static]

static bool LinkTypes ( Module *  Dest,
const Module *  Src,
std::string *  Err 
) [static]

static void PrintMap ( const std::map< const Value *, Value * > &  M  )  [static]

Definition at line 336 of file LinkModules.cpp.

References llvm::cerr(), and E.

Referenced by RemapOperand().

static bool RecursiveResolveTypes ( const Type *  DestTy,
const Type *  SrcTy 
) [static]

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]

static Value* RemapOperand ( const Value *  In,
std::map< const Value *, Value * > &  ValueMap 
) [static]

static bool ResolveAliases ( Module *  Dest  )  [static]

static bool ResolveTypes ( const Type *  DestTy,
const Type *  SrcTy 
) [static]

Definition at line 56 of file LinkModules.cpp.

Referenced by LinkTypes(), and RecursiveResolveTypesI().


Variable Documentation

TheMapTy TheMap