llvm/llvm/lib/Linker/IRMover.cpp

//===- lib/Linker/IRMover.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

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

//===----------------------------------------------------------------------===//
// TypeMap implementation.
//===----------------------------------------------------------------------===//

namespace {
class TypeMapTy : public ValueMapTypeRemapper {};
}

void TypeMapTy::addTypeMapping(Type *DstTy, Type *SrcTy) {}

/// Recursively walk this pair of types, returning true if they are isomorphic,
/// false if they are not.
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 {}

//===----------------------------------------------------------------------===//
// IRLinker implementation.
//===----------------------------------------------------------------------===//

namespace {
class IRLinker;

/// Creates prototypes for functions that are lazily linked on the fly. This
/// speeds up linking for modules with many/ lazily linked functions of which
/// few get used.
class GlobalValueMaterializer final : public ValueMaterializer {};

class LocalValueMaterializer final : public ValueMaterializer {};

/// Type of the Metadata map in \a ValueToValueMapTy.
MDMapT;

/// This is responsible for keeping track of the state used for moving data
/// from SrcM to DstM.
class IRLinker {};
}

/// 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.
static void forceRenaming(GlobalValue *GV, StringRef Name) {}

Value *GlobalValueMaterializer::materialize(Value *SGV) {}

Value *LocalValueMaterializer::materialize(Value *SGV) {}

Value *IRLinker::materialize(Value *V, bool ForIndirectSymbol) {}

/// Loop through the global variables in the src module and merge them into the
/// dest module.
GlobalVariable *IRLinker::copyGlobalVariableProto(const GlobalVariable *SGVar) {}

AttributeList IRLinker::mapAttributeTypes(LLVMContext &C, AttributeList Attrs) {}

/// Link the function in the source module into the destination module if
/// needed, setting up mapping information.
Function *IRLinker::copyFunctionProto(const Function *SF) {}

/// Set up prototypes for any indirect symbols that come over from the source
/// module.
GlobalValue *IRLinker::copyIndirectSymbolProto(const GlobalValue *SGV) {}

GlobalValue *IRLinker::copyGlobalValueProto(const GlobalValue *SGV,
                                            bool ForDefinition) {}

static StringRef getTypeNamePrefix(StringRef Name) {}

/// Loop over all of the linked values to compute type mappings.  For example,
/// if we link "extern Foo *x" and "Foo *x = NULL", then we have two struct
/// types 'Foo' but one got renamed when the module was loaded into the same
/// LLVMContext.
void IRLinker::computeTypeMapping() {}

static void getArrayElements(const Constant *C,
                             SmallVectorImpl<Constant *> &Dest) {}

/// If there were any appending global variables, link them together now.
Expected<Constant *>
IRLinker::linkAppendingVarProto(GlobalVariable *DstGV,
                                const GlobalVariable *SrcGV) {}

bool IRLinker::shouldLink(GlobalValue *DGV, GlobalValue &SGV) {}

Expected<Constant *> IRLinker::linkGlobalValueProto(GlobalValue *SGV,
                                                    bool ForIndirectSymbol) {}

/// Update the initializers in the Dest module now that all globals that may be
/// referenced are in Dest.
void IRLinker::linkGlobalVariable(GlobalVariable &Dst, GlobalVariable &Src) {}

/// Copy the source function over into the dest function and fix up references
/// to values. At this point we know that Dest is an external function, and
/// that Src is not.
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() {}

/// Insert all of the named MDNodes in Src into the Dest module.
void IRLinker::linkNamedMDNodes() {}

/// Merge the linker flags in Src into the Dest module.
Error IRLinker::linkModuleFlagsMetadata() {}

/// Return InlineAsm adjusted with target-specific directives if required.
/// For ARM and Thumb, we have to add directives to select the appropriate ISA
/// to support mixing module-level inline assembly from ARM and Thumb modules.
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) {}