#include "llvm/Linker/IRMover.h"
#include "LinkDiagnosticInfo.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/IR/AutoUpgrade.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GVMaterializer.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PseudoProbe.h"
#include "llvm/IR/TypeFinder.h"
#include "llvm/Object/ModuleSymbolTable.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Path.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
#include <optional>
#include <utility>
usingnamespacellvm;
namespace {
class TypeMapTy : public ValueMapTypeRemapper { … };
}
void TypeMapTy::addTypeMapping(Type *DstTy, Type *SrcTy) { … }
bool TypeMapTy::areTypesIsomorphic(Type *DstTy, Type *SrcTy) { … }
void TypeMapTy::linkDefinedTypeBodies() { … }
void TypeMapTy::finishType(StructType *DTy, StructType *STy,
ArrayRef<Type *> ETypes) { … }
Type *TypeMapTy::get(Type *Ty) { … }
Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) { … }
LinkDiagnosticInfo::LinkDiagnosticInfo(DiagnosticSeverity Severity,
const Twine &Msg)
: … { … }
void LinkDiagnosticInfo::print(DiagnosticPrinter &DP) const { … }
namespace {
class IRLinker;
class GlobalValueMaterializer final : public ValueMaterializer { … };
class LocalValueMaterializer final : public ValueMaterializer { … };
MDMapT;
class IRLinker { … };
}
static void forceRenaming(GlobalValue *GV, StringRef Name) { … }
Value *GlobalValueMaterializer::materialize(Value *SGV) { … }
Value *LocalValueMaterializer::materialize(Value *SGV) { … }
Value *IRLinker::materialize(Value *V, bool ForIndirectSymbol) { … }
GlobalVariable *IRLinker::copyGlobalVariableProto(const GlobalVariable *SGVar) { … }
AttributeList IRLinker::mapAttributeTypes(LLVMContext &C, AttributeList Attrs) { … }
Function *IRLinker::copyFunctionProto(const Function *SF) { … }
GlobalValue *IRLinker::copyIndirectSymbolProto(const GlobalValue *SGV) { … }
GlobalValue *IRLinker::copyGlobalValueProto(const GlobalValue *SGV,
bool ForDefinition) { … }
static StringRef getTypeNamePrefix(StringRef Name) { … }
void IRLinker::computeTypeMapping() { … }
static void getArrayElements(const Constant *C,
SmallVectorImpl<Constant *> &Dest) { … }
Expected<Constant *>
IRLinker::linkAppendingVarProto(GlobalVariable *DstGV,
const GlobalVariable *SrcGV) { … }
bool IRLinker::shouldLink(GlobalValue *DGV, GlobalValue &SGV) { … }
Expected<Constant *> IRLinker::linkGlobalValueProto(GlobalValue *SGV,
bool ForIndirectSymbol) { … }
void IRLinker::linkGlobalVariable(GlobalVariable &Dst, GlobalVariable &Src) { … }
Error IRLinker::linkFunctionBody(Function &Dst, Function &Src) { … }
void IRLinker::linkAliasAliasee(GlobalAlias &Dst, GlobalAlias &Src) { … }
void IRLinker::linkIFuncResolver(GlobalIFunc &Dst, GlobalIFunc &Src) { … }
Error IRLinker::linkGlobalValueBody(GlobalValue &Dst, GlobalValue &Src) { … }
void IRLinker::flushRAUWWorklist() { … }
void IRLinker::prepareCompileUnitsForImport() { … }
void IRLinker::linkNamedMDNodes() { … }
Error IRLinker::linkModuleFlagsMetadata() { … }
static std::string adjustInlineAsm(const std::string &InlineAsm,
const Triple &Triple) { … }
void IRLinker::updateAttributes(GlobalValue &GV) { … }
Error IRLinker::run() { … }
IRMover::StructTypeKeyInfo::KeyTy::KeyTy(ArrayRef<Type *> E, bool P)
: … { … }
IRMover::StructTypeKeyInfo::KeyTy::KeyTy(const StructType *ST)
: … { … }
bool IRMover::StructTypeKeyInfo::KeyTy::operator==(const KeyTy &That) const { … }
bool IRMover::StructTypeKeyInfo::KeyTy::operator!=(const KeyTy &That) const { … }
StructType *IRMover::StructTypeKeyInfo::getEmptyKey() { … }
StructType *IRMover::StructTypeKeyInfo::getTombstoneKey() { … }
unsigned IRMover::StructTypeKeyInfo::getHashValue(const KeyTy &Key) { … }
unsigned IRMover::StructTypeKeyInfo::getHashValue(const StructType *ST) { … }
bool IRMover::StructTypeKeyInfo::isEqual(const KeyTy &LHS,
const StructType *RHS) { … }
bool IRMover::StructTypeKeyInfo::isEqual(const StructType *LHS,
const StructType *RHS) { … }
void IRMover::IdentifiedStructTypeSet::addNonOpaque(StructType *Ty) { … }
void IRMover::IdentifiedStructTypeSet::switchToNonOpaque(StructType *Ty) { … }
void IRMover::IdentifiedStructTypeSet::addOpaque(StructType *Ty) { … }
StructType *
IRMover::IdentifiedStructTypeSet::findNonOpaque(ArrayRef<Type *> ETypes,
bool IsPacked) { … }
bool IRMover::IdentifiedStructTypeSet::hasType(StructType *Ty) { … }
IRMover::IRMover(Module &M) : … { … }
Error IRMover::move(std::unique_ptr<Module> Src,
ArrayRef<GlobalValue *> ValuesToLink,
LazyCallback AddLazyFor, bool IsPerformingImport) { … }