|
LLVM 24.0.0git
|
#include "llvm/Transforms/IPO/ElimAvailExtern.h"#include "IPOOptions.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/CtxProfAnalysis.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/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 (NumFunctionsConverted, "Number of functions converted") | |
| STATISTIC (NumGlobalVariablesConverted, "Number of global variables converted") | |
| STATISTIC (NumVariables, "Number of global variables removed") | |
| void | deleteFunction (Function &F) |
| static std::string | getNewName (Module &M, const GlobalValue &GV) |
| 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 void | convertToLocalCopy (Module &M, GlobalVariable &GV) |
| Similar to the function above, this is to convert an externally available global variable to local. | |
| static bool | eliminateAvailableExternally (Module &M, bool Convert) |
| #define DEBUG_TYPE "elim-avail-extern" |
Definition at line 31 of file ElimAvailExtern.cpp.
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(), getNewName(), llvm::GlobalValue::InternalLinkage, and llvm::isa().
Referenced by eliminateAvailableExternally().
|
static |
Similar to the function above, this is to convert an externally available global variable to local.
Definition at line 93 of file ElimAvailExtern.cpp.
References assert(), getNewName(), llvm::GlobalValue::hasAvailableExternallyLinkage(), llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::setLinkage(), and llvm::Value::setName().
| void deleteFunction | ( | Function & | F | ) |
Definition at line 38 of file ElimAvailExtern.cpp.
References F.
Referenced by convertToLocalCopy(), and eliminateAvailableExternally().
Definition at line 100 of file ElimAvailExtern.cpp.
References Changed, convertToLocalCopy(), deleteFunction(), llvm::GlobalValue::ExternalLinkage, F, llvm::getIPOOptions(), llvm::isSafeToDestroyConstant(), and llvm::make_early_inc_range().
Referenced by llvm::EliminateAvailableExternallyPass::run().
|
static |
Definition at line 44 of file ElimAvailExtern.cpp.
References llvm::Value::getName(), llvm::getUniqueModuleId(), and llvm::StringRef::str().
Referenced by convertToLocalCopy(), and convertToLocalCopy().
| STATISTIC | ( | NumFunctionsConverted | , |
| "Number of functions converted" | ) |
| STATISTIC | ( | NumGlobalVariablesConverted | , |
| "Number of global variables converted" | ) |
| STATISTIC | ( | NumRemovals | , |
| "Number of functions removed" | ) |
| STATISTIC | ( | NumVariables | , |
| "Number of global variables removed" | ) |