class FunctionImportGlobalProcessing

Declaration

class FunctionImportGlobalProcessing { /* full declaration omitted */ };

Description

Class to handle necessary GlobalValue changes required by ThinLTO function importing, including linkage changes and any necessary renaming.

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:25

Member Variables

private llvm::Module& M
The Module which we are exporting or importing functions from.
private const llvm::ModuleSummaryIndex& ImportIndex
Module summary index passed in for function importing/exporting handling.
private SetVector<llvm::GlobalValue*>* GlobalsToImport
Globals to import from this module, all other functions will be imported as declarations instead of definitions.
private bool HasExportedFunctions = false
Set to true if the given ModuleSummaryIndex contains any functions from this source module, in which case we must conservatively assume that any of its functions may be imported into another module as part of a different backend compilation process.
private bool ClearDSOLocalOnDeclarations
This flag should not be set for -fno-pic or -fpie, which would unnecessarily disable direct access.
private SmallPtrSet<llvm::GlobalValue*, 4> Used
Set of llvm.*used values, in order to validate that we don't try to promote any non-renamable values.
private DenseMap<const llvm::Comdat*, llvm::Comdat*> RenamedComdats
Keep track of any COMDATs that require renaming (because COMDAT leader was promoted and renamed). Maps from original COMDAT to one with new name.

Method Overview

Methods

FunctionImportGlobalProcessing(
    llvm::Module& M,
    const llvm::ModuleSummaryIndex& Index,
    SetVector<llvm::GlobalValue*>*
        GlobalsToImport,
    bool ClearDSOLocalOnDeclarations)

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:101

Parameters

llvm::Module& M
const llvm::ModuleSummaryIndex& Index
SetVector<llvm::GlobalValue*>* GlobalsToImport
bool ClearDSOLocalOnDeclarations

bool doImportAsDefinition(
    const llvm::GlobalValue* SGV)

Description

If we are importing from the source module, checks if we should import SGV as a definition, otherwise import as a declaration.

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:81

Parameters

const llvm::GlobalValue* SGV

GlobalValue::LinkageTypes getLinkage(
    const llvm::GlobalValue* SGV,
    bool DoPromote)

Description

Get the new linkage for SGV that should be used in the linked destination module. Specifically, for ThinLTO importing or exporting it may need to be adjusted. When \p DoPromote is true then we must adjust the linkage for a required promotion of a local to global scope.

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:98

Parameters

const llvm::GlobalValue* SGV
bool DoPromote

std::string getPromotedName(
    const llvm::GlobalValue* SGV)

Description

Get the name for a local SGV that should be promoted and renamed to global scope in the linked destination module.

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:85

Parameters

const llvm::GlobalValue* SGV

bool isModuleExporting() const

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:77

bool isNonRenamableLocal(
    const llvm::GlobalValue& GV) const

Description

Check if the given value is a local that can't be renamed (promoted). Only used in assertion checking, and disabled under NDEBUG since the Used set will not be populated.

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:71

Parameters

const llvm::GlobalValue& GV

bool isPerformingImport() const

Description

Helper methods to check if we are importing from or potentially exporting from the current source module.

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:76

void processGlobalForThinLTO(
    llvm::GlobalValue& GV)

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:92

Parameters

llvm::GlobalValue& GV

void processGlobalsForThinLTO()

Description

Process globals so that they can be used in ThinLTO. This includes promoting local variables so that they can be reference externally by thin lto imported globals and converting strong external globals to available_externally.

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:91

bool run()

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:123

bool shouldPromoteLocalToGlobal(
    const llvm::GlobalValue* SGV,
    llvm::ValueInfo VI)

Description

Check if we should promote the given local value to global scope.

Declared at: llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h:65

Parameters

const llvm::GlobalValue* SGV
llvm::ValueInfo VI