LLVM 20.0.0git
Macros | Functions | Variables
ElimAvailExtern.cpp File Reference
#include "llvm/Transforms/IPO/ElimAvailExtern.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/GlobalStatus.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "elim-avail-extern"
 

Functions

 STATISTIC (NumRemovals, "Number of functions removed")
 
 STATISTIC (NumConversions, "Number of functions converted")
 
 STATISTIC (NumVariables, "Number of global variables removed")
 
void deleteFunction (Function &F)
 
static void convertToLocalCopy (Module &M, Function &F)
 Create a copy of the thinlto import, mark it local, and redirect direct calls to the copy.
 
static bool eliminateAvailableExternally (Module &M)
 

Variables

cl::opt< boolConvertToLocal ("avail-extern-to-local", cl::Hidden, cl::desc("Convert available_externally into locals, renaming them " "to avoid link-time clashes."))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "elim-avail-extern"

Definition at line 31 of file ElimAvailExtern.cpp.

Function Documentation

◆ convertToLocalCopy()

static void convertToLocalCopy ( Module M,
Function F 
)
static

Create a copy of the thinlto import, mark it local, and redirect direct calls to the copy.

Only direct calls are replaced, so that e.g. indirect call function pointer tests would use the global identity of the function.

Currently, Value Profiling ("VP") MD_prof data isn't updated to refer to the clone's GUID (which will be different, because the name and linkage is different), under the assumption that the last consumer of this data is upstream the pipeline (e.g. ICP).

Definition at line 56 of file ElimAvailExtern.cpp.

References assert(), llvm::Function::Create(), deleteFunction(), llvm::GlobalValue::ExternalLinkage, F, llvm::find_if(), llvm::MDString::get(), llvm::getUniqueModuleId(), and llvm::GlobalValue::InternalLinkage.

Referenced by eliminateAvailableExternally().

◆ deleteFunction()

void deleteFunction ( Function F)

Definition at line 42 of file ElimAvailExtern.cpp.

References F.

Referenced by convertToLocalCopy(), and eliminateAvailableExternally().

◆ eliminateAvailableExternally()

static bool eliminateAvailableExternally ( Module M)
static

◆ STATISTIC() [1/3]

STATISTIC ( NumConversions  ,
"Number of functions converted"   
)

◆ STATISTIC() [2/3]

STATISTIC ( NumRemovals  ,
"Number of functions removed"   
)

◆ STATISTIC() [3/3]

STATISTIC ( NumVariables  ,
"Number of global variables removed"   
)

Variable Documentation

◆ ConvertToLocal

cl::opt< bool > ConvertToLocal("avail-extern-to-local", cl::Hidden, cl::desc("Convert available_externally into locals, renaming them " "to avoid link-time clashes.")) ( "avail-extern-to-local"  ,
cl::Hidden  ,
cl::desc("Convert available_externally into locals, renaming them " "to avoid link-time clashes.")   
)