mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-12 05:56:28 +00:00
Rename NameAnonFunctions to NameAnonGlobals to match what it is doing (NFC)
llvm-svn: 281745
This commit is contained in:
parent
55d44fcce3
commit
21a9844262
@ -244,7 +244,7 @@ void initializeMergedLoadStoreMotionLegacyPassPass(PassRegistry &);
|
||||
void initializeMetaRenamerPass(PassRegistry&);
|
||||
void initializeModuleDebugInfoPrinterPass(PassRegistry&);
|
||||
void initializeModuleSummaryIndexWrapperPassPass(PassRegistry &);
|
||||
void initializeNameAnonFunctionLegacyPassPass(PassRegistry &);
|
||||
void initializeNameAnonGlobalLegacyPassPass(PassRegistry &);
|
||||
void initializeNaryReassociateLegacyPassPass(PassRegistry &);
|
||||
void initializeNoAAPass(PassRegistry&);
|
||||
void initializeObjCARCAAWrapperPassPass(PassRegistry&);
|
||||
|
@ -516,7 +516,7 @@ FunctionPass *createLoopVersioningPass();
|
||||
FunctionPass *createLoopDataPrefetchPass();
|
||||
|
||||
///===---------------------------------------------------------------------===//
|
||||
ModulePass *createNameAnonFunctionPass();
|
||||
ModulePass *createNameAnonGlobalPass();
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
|
@ -55,9 +55,9 @@ std::pair<Function *, Function *> createSanitizerCtorAndInitFunctions(
|
||||
ArrayRef<Type *> InitArgTypes, ArrayRef<Value *> InitArgs,
|
||||
StringRef VersionCheckName = StringRef());
|
||||
|
||||
/// Rename all the anon functions in the module using a hash computed from
|
||||
/// Rename all the anon globals in the module using a hash computed from
|
||||
/// the list of public globals in the module.
|
||||
bool nameUnamedFunctions(Module &M);
|
||||
bool nameUnamedGlobals(Module &M);
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- NameAnonFunctions.h - Anonymous Function Naming Pass ----*- C++ -*-===//
|
||||
//===-- NameAnonGlobals.h - Anonymous Global Naming Pass ----*- C++ -*-=======//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,25 +7,25 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements naming anonymous function to make sure they can be
|
||||
// This file implements naming anonymous globals to make sure they can be
|
||||
// referred to by ThinLTO.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TRANSFORMS_UTILS_NAMEANONFUNCTIONS_H
|
||||
#define LLVM_TRANSFORMS_UTILS_NAMEANONFUNCTIONS_H
|
||||
#ifndef LLVM_TRANSFORMS_UTILS_NAMEANONGLOBALSS_H
|
||||
#define LLVM_TRANSFORMS_UTILS_NAMEANONGLOBALSS_H
|
||||
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// Simple pass that provides a name to every anonymous function.
|
||||
class NameAnonFunctionPass : public PassInfoMixin<NameAnonFunctionPass> {
|
||||
/// Simple pass that provides a name to every anonymous globals.
|
||||
class NameAnonGlobalPass : public PassInfoMixin<NameAnonGlobalPass> {
|
||||
public:
|
||||
NameAnonFunctionPass() {}
|
||||
NameAnonGlobalPass() {}
|
||||
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // LLVM_TRANSFORMS_UTILS_NAMEANONFUNCTIONS_H
|
||||
#endif // LLVM_TRANSFORMS_UTILS_NAMEANONGLOBALS_H
|
@ -24,11 +24,11 @@
|
||||
#include "llvm/Analysis/BlockFrequencyInfo.h"
|
||||
#include "llvm/Analysis/BlockFrequencyInfoImpl.h"
|
||||
#include "llvm/Analysis/BranchProbabilityInfo.h"
|
||||
#include "llvm/Analysis/CFGPrinter.h"
|
||||
#include "llvm/Analysis/CFLAndersAliasAnalysis.h"
|
||||
#include "llvm/Analysis/CFLSteensAliasAnalysis.h"
|
||||
#include "llvm/Analysis/CGSCCPassManager.h"
|
||||
#include "llvm/Analysis/CallGraph.h"
|
||||
#include "llvm/Analysis/CFGPrinter.h"
|
||||
#include "llvm/Analysis/DemandedBits.h"
|
||||
#include "llvm/Analysis/DependenceAnalysis.h"
|
||||
#include "llvm/Analysis/DominanceFrontier.h"
|
||||
@ -125,7 +125,7 @@
|
||||
#include "llvm/Transforms/Utils/LowerInvoke.h"
|
||||
#include "llvm/Transforms/Utils/Mem2Reg.h"
|
||||
#include "llvm/Transforms/Utils/MemorySSA.h"
|
||||
#include "llvm/Transforms/Utils/NameAnonFunctions.h"
|
||||
#include "llvm/Transforms/Utils/NameAnonGlobals.h"
|
||||
#include "llvm/Transforms/Utils/SimplifyInstructions.h"
|
||||
#include "llvm/Transforms/Utils/SymbolRewriter.h"
|
||||
#include "llvm/Transforms/Vectorize/LoopVectorize.h"
|
||||
|
@ -54,7 +54,7 @@ MODULE_PASS("internalize", InternalizePass())
|
||||
MODULE_PASS("invalidate<all>", InvalidateAllAnalysesPass())
|
||||
MODULE_PASS("ipsccp", IPSCCPPass())
|
||||
MODULE_PASS("lowertypetests", LowerTypeTestsPass())
|
||||
MODULE_PASS("name-anon-functions", NameAnonFunctionPass())
|
||||
MODULE_PASS("name-global-functions", NameAnonGlobalPass())
|
||||
MODULE_PASS("no-op-module", NoOpModulePass())
|
||||
MODULE_PASS("partial-inliner", PartialInlinerPass())
|
||||
MODULE_PASS("pgo-icall-prom", PGOIndirectCallPromotion())
|
||||
|
@ -491,8 +491,8 @@ void PassManagerBuilder::populateModulePassManager(
|
||||
if (PrepareForThinLTO) {
|
||||
// Reduce the size of the IR as much as possible.
|
||||
MPM.add(createGlobalOptimizerPass());
|
||||
// Rename anon function to be able to export them in the summary.
|
||||
MPM.add(createNameAnonFunctionPass());
|
||||
// Rename anon globals to be able to export them in the summary.
|
||||
MPM.add(createNameAnonGlobalPass());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ add_llvm_library(LLVMTransformUtils
|
||||
MemorySSA.cpp
|
||||
MetaRenamer.cpp
|
||||
ModuleUtils.cpp
|
||||
NameAnonFunctions.cpp
|
||||
NameAnonGlobals.cpp
|
||||
PromoteMemoryToRegister.cpp
|
||||
SSAUpdater.cpp
|
||||
SanitizerStats.cpp
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- NameAnonFunctions.cpp - ThinLTO Summary-based Function Import ------===//
|
||||
//===- NameAnonGlobals.cpp - ThinLTO Support: Name Unnamed Globals --------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,12 +7,12 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements naming anonymous function to make sure they can be
|
||||
// refered to by ThinLTO.
|
||||
// This file implements naming anonymous globals to make sure they can be
|
||||
// referred to by ThinLTO.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Transforms/Utils/NameAnonFunctions.h"
|
||||
#include "llvm/Transforms/Utils/NameAnonGlobals.h"
|
||||
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
@ -23,7 +23,7 @@ using namespace llvm;
|
||||
|
||||
namespace {
|
||||
// Compute a "unique" hash for the module based on the name of the public
|
||||
// functions.
|
||||
// globals.
|
||||
class ModuleHasher {
|
||||
Module &TheModule;
|
||||
std::string TheHash;
|
||||
@ -62,12 +62,12 @@ public:
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
// Rename all the anon functions in the module
|
||||
bool llvm::nameUnamedFunctions(Module &M) {
|
||||
// Rename all the anon globals in the module
|
||||
bool llvm::nameUnamedGlobals(Module &M) {
|
||||
bool Changed = false;
|
||||
ModuleHasher ModuleHash(M);
|
||||
int count = 0;
|
||||
auto RenameIfNeed = [&] (GlobalValue &GV) {
|
||||
auto RenameIfNeed = [&](GlobalValue &GV) {
|
||||
if (GV.hasName())
|
||||
return;
|
||||
GV.setName(Twine("anon.") + ModuleHash.get() + "." + Twine(count++));
|
||||
@ -83,39 +83,39 @@ bool llvm::nameUnamedFunctions(Module &M) {
|
||||
|
||||
namespace {
|
||||
|
||||
// Legacy pass that provides a name to every anon function.
|
||||
class NameAnonFunctionLegacyPass : public ModulePass {
|
||||
// Legacy pass that provides a name to every anon globals.
|
||||
class NameAnonGlobalLegacyPass : public ModulePass {
|
||||
|
||||
public:
|
||||
/// Pass identification, replacement for typeid
|
||||
static char ID;
|
||||
|
||||
/// Specify pass name for debug output
|
||||
const char *getPassName() const override { return "Name Anon Functions"; }
|
||||
const char *getPassName() const override { return "Name Anon Globals"; }
|
||||
|
||||
explicit NameAnonFunctionLegacyPass() : ModulePass(ID) {}
|
||||
explicit NameAnonGlobalLegacyPass() : ModulePass(ID) {}
|
||||
|
||||
bool runOnModule(Module &M) override { return nameUnamedFunctions(M); }
|
||||
bool runOnModule(Module &M) override { return nameUnamedGlobals(M); }
|
||||
};
|
||||
char NameAnonFunctionLegacyPass::ID = 0;
|
||||
char NameAnonGlobalLegacyPass::ID = 0;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
PreservedAnalyses NameAnonFunctionPass::run(Module &M,
|
||||
ModuleAnalysisManager &AM) {
|
||||
if (!nameUnamedFunctions(M))
|
||||
PreservedAnalyses NameAnonGlobalPass::run(Module &M,
|
||||
ModuleAnalysisManager &AM) {
|
||||
if (!nameUnamedGlobals(M))
|
||||
return PreservedAnalyses::all();
|
||||
|
||||
return PreservedAnalyses::none();
|
||||
}
|
||||
|
||||
INITIALIZE_PASS_BEGIN(NameAnonFunctionLegacyPass, "name-anon-functions",
|
||||
"Provide a name to nameless functions", false, false)
|
||||
INITIALIZE_PASS_END(NameAnonFunctionLegacyPass, "name-anon-functions",
|
||||
"Provide a name to nameless functions", false, false)
|
||||
INITIALIZE_PASS_BEGIN(NameAnonGlobalLegacyPass, "name-anon-globals",
|
||||
"Provide a name to nameless globals", false, false)
|
||||
INITIALIZE_PASS_END(NameAnonGlobalLegacyPass, "name-anon-globals",
|
||||
"Provide a name to nameless globals", false, false)
|
||||
|
||||
namespace llvm {
|
||||
ModulePass *createNameAnonFunctionPass() {
|
||||
return new NameAnonFunctionLegacyPass();
|
||||
ModulePass *createNameAnonGlobalPass() {
|
||||
return new NameAnonGlobalLegacyPass();
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ void llvm::initializeTransformUtils(PassRegistry &Registry) {
|
||||
initializeLoopSimplifyPass(Registry);
|
||||
initializeLowerInvokeLegacyPassPass(Registry);
|
||||
initializeLowerSwitchPass(Registry);
|
||||
initializeNameAnonFunctionLegacyPassPass(Registry);
|
||||
initializeNameAnonGlobalLegacyPassPass(Registry);
|
||||
initializePromoteLegacyPassPass(Registry);
|
||||
initializeUnifyFunctionExitNodesPass(Registry);
|
||||
initializeInstSimplifierPass(Registry);
|
||||
|
Loading…
Reference in New Issue
Block a user