1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

Remove original implementation of UniqueInternalLinkageNames pass.

D96109 was recently submitted which contains the refactored implementation of
-funique-internal-linakge-names by adding the unique suffixes in clang rather
than as an LLVM pass. Deleting the former implementation in this change.

Differential Revision: https://reviews.llvm.org/D98234
This commit is contained in:
Sriraman Tallam 2021-03-08 22:33:00 -08:00
parent e6e544ffd4
commit af0d8fe721
13 changed files with 0 additions and 245 deletions

View File

@ -318,7 +318,6 @@ void initializeModuloScheduleTestPass(PassRegistry&);
void initializeMustExecutePrinterPass(PassRegistry&);
void initializeMustBeExecutedContextPrinterPass(PassRegistry&);
void initializeNameAnonGlobalLegacyPassPass(PassRegistry&);
void initializeUniqueInternalLinkageNamesLegacyPassPass(PassRegistry &);
void initializeNaryReassociateLegacyPassPass(PassRegistry&);
void initializeNewGVNLegacyPassPass(PassRegistry&);
void initializeObjCARCAAWrapperPassPass(PassRegistry&);

View File

@ -128,9 +128,6 @@ public:
/// Tuning option to enable/disable function merging. Its default value is
/// false.
bool MergeFunctions;
/// Uniquefy function linkage name. Its default value is false.
bool UniqueLinkageNames;
};
/// This class provides access to building LLVM's passes.

View File

@ -25,12 +25,6 @@ class Pass;
//
ModulePass *createMetaRenamerPass();
//===----------------------------------------------------------------------===//
// createUniqueInternalLinkageNamesPass - Make internal linkage symbol names
// unique.
//
ModulePass *createUniqueInternalLinkageNamesPass();
//===----------------------------------------------------------------------===//
//
// LowerInvoke - This pass removes invoke instructions, converting them to call

View File

@ -1,31 +0,0 @@
//===-- UniqueInternalLinkageNames.h - Uniq. Int. Linkage Names -*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file implements unique naming of internal linkage symbols with option
// -funique-internal-linkage-symbols.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TRANSFORMS_UTILS_UNIQUEINTERNALLINKAGENAMES_H
#define LLVM_TRANSFORMS_UTILS_UNIQUEINTERNALLINKAGENAMES_H
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
/// Simple pass that provides a name to every anonymous globals.
class UniqueInternalLinkageNamesPass
: public PassInfoMixin<UniqueInternalLinkageNamesPass> {
public:
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
};
} // end namespace llvm
#endif // LLVM_TRANSFORMS_UTILS_UNIQUEINTERNALLINKAGENAMES_H

View File

@ -232,7 +232,6 @@
#include "llvm/Transforms/Utils/SymbolRewriter.h"
#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
#include "llvm/Transforms/Utils/UnifyLoopExits.h"
#include "llvm/Transforms/Utils/UniqueInternalLinkageNames.h"
#include "llvm/Transforms/Vectorize/LoadStoreVectorizer.h"
#include "llvm/Transforms/Vectorize/LoopVectorize.h"
#include "llvm/Transforms/Vectorize/SLPVectorizer.h"
@ -290,7 +289,6 @@ PipelineTuningOptions::PipelineTuningOptions() {
LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap;
CallGraphProfile = true;
MergeFunctions = false;
UniqueLinkageNames = false;
}
extern cl::opt<bool> ExtraVectorizerPasses;
@ -1019,11 +1017,6 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
ThinOrFullLTOPhase Phase) {
ModulePassManager MPM(DebugLogging);
// Add UniqueInternalLinkageNames Pass which renames internal linkage
// symbols with unique names.
if (PTO.UniqueLinkageNames)
MPM.addPass(UniqueInternalLinkageNamesPass());
// Place pseudo probe instrumentation as the first pass of the pipeline to
// minimize the impact of optimization changes.
if (PGOOpt && PGOOpt->PseudoProbeForProfiling &&
@ -1878,11 +1871,6 @@ ModulePassManager PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
ModulePassManager MPM(DebugLogging);
// Add UniqueInternalLinkageNames Pass which renames internal linkage
// symbols with unique names.
if (PTO.UniqueLinkageNames)
MPM.addPass(UniqueInternalLinkageNamesPass());
if (PGOOpt && (PGOOpt->Action == PGOOptions::IRInstr ||
PGOOpt->Action == PGOOptions::IRUse))
addPGOInstrPassesForO0(

View File

@ -108,7 +108,6 @@ MODULE_PASS("strip-debug-declare", StripDebugDeclarePass())
MODULE_PASS("strip-nondebug", StripNonDebugSymbolsPass())
MODULE_PASS("strip-nonlinetable-debuginfo", StripNonLineTableDebugInfoPass())
MODULE_PASS("synthetic-counts-propagation", SyntheticCountsPropagation())
MODULE_PASS("unique-internal-linkage-names", UniqueInternalLinkageNamesPass())
MODULE_PASS("verify", VerifierPass())
MODULE_PASS("wholeprogramdevirt", WholeProgramDevirtPass())
MODULE_PASS("dfsan", DataFlowSanitizerPass())

View File

@ -69,7 +69,6 @@ add_llvm_component_library(LLVMTransformUtils
SymbolRewriter.cpp
UnifyFunctionExitNodes.cpp
UnifyLoopExits.cpp
UniqueInternalLinkageNames.cpp
Utils.cpp
ValueMapper.cpp
VNCoercion.cpp

View File

@ -1,118 +0,0 @@
//===- UniqueInternalLinkageNames.cpp - Unique Internal Linkage Sym Names -===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file implements unique naming of internal linkage symbols with option
// -funique-internal-linkage-symbols.
//
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Utils/UniqueInternalLinkageNames.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MD5.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
using namespace llvm;
static bool uniqueifyInternalLinkageNames(Module &M) {
llvm::MD5 Md5;
Md5.update(M.getSourceFileName());
llvm::MD5::MD5Result R;
Md5.final(R);
SmallString<32> Str;
llvm::MD5::stringifyResult(R, Str);
// Convert MD5hash to Decimal. Demangler suffixes can either contain numbers
// or characters but not both.
APInt IntHash = APInt(128, Str.str(), 16);
// Prepend "__uniq" before the hash for tools like profilers to understand that
// this symbol is of internal linkage type.
std::string ModuleNameHash = (Twine(".__uniq.") + Twine(IntHash.toString(10, false))).str();
bool Changed = false;
MDBuilder MDB(M.getContext());
// Append the module hash to all internal linkage functions.
for (auto &F : M) {
if (F.hasInternalLinkage()) {
F.setName(F.getName() + ModuleNameHash);
F.addFnAttr("sample-profile-suffix-elision-policy", "selected");
// Replace linkage names in the debug metadata.
if (DISubprogram *SP = F.getSubprogram()) {
if (SP->getRawLinkageName()) {
auto *Name = MDB.createString(F.getName());
SP->replaceRawLinkageName(Name);
if (DISubprogram *SPDecl = SP->getDeclaration()) {
if (SPDecl->getRawLinkageName())
SPDecl->replaceRawLinkageName(Name);
}
}
}
Changed = true;
}
}
// Append the module hash to all internal linkage globals.
for (auto &GV : M.globals()) {
if (GV.hasInternalLinkage()) {
GV.setName(GV.getName() + ModuleNameHash);
Changed = true;
}
}
return Changed;
}
namespace {
// Legacy pass that provides a name to every anon globals.
class UniqueInternalLinkageNamesLegacyPass : public ModulePass {
public:
/// Pass identification, replacement for typeid
static char ID;
/// Specify pass name for debug output
StringRef getPassName() const override {
return "Unique Internal Linkage Names";
}
explicit UniqueInternalLinkageNamesLegacyPass() : ModulePass(ID) {
initializeUniqueInternalLinkageNamesLegacyPassPass(
*PassRegistry::getPassRegistry());
}
bool runOnModule(Module &M) override {
return uniqueifyInternalLinkageNames(M);
}
};
char UniqueInternalLinkageNamesLegacyPass::ID = 0;
} // anonymous namespace
PreservedAnalyses
UniqueInternalLinkageNamesPass::run(Module &M, ModuleAnalysisManager &AM) {
if (!uniqueifyInternalLinkageNames(M))
return PreservedAnalyses::all();
return PreservedAnalyses::none();
}
INITIALIZE_PASS_BEGIN(UniqueInternalLinkageNamesLegacyPass,
"unique-internal-linkage-names",
"Uniqueify internal linkage names", false, false)
INITIALIZE_PASS_END(UniqueInternalLinkageNamesLegacyPass,
"unique-internal-linkage-names",
"Uniqueify Internal linkage names", false, false)
namespace llvm {
ModulePass *createUniqueInternalLinkageNamesPass() {
return new UniqueInternalLinkageNamesLegacyPass();
}
} // namespace llvm

View File

@ -45,7 +45,6 @@ void llvm::initializeTransformUtils(PassRegistry &Registry) {
initializeInjectTLIMappingsLegacyPass(Registry);
initializeFixIrreduciblePass(Registry);
initializeUnifyLoopExitsLegacyPassPass(Registry);
initializeUniqueInternalLinkageNamesLegacyPassPass(Registry);
}
/// LLVMInitializeTransformUtils - C binding for initializeTransformUtilsPasses.

View File

@ -1,51 +0,0 @@
; RUN: opt -S -passes='default<O0>' -new-pm-pseudo-probe-for-profiling -new-pm-unique-internal-linkage-names -debug-pass-manager < %s 2>&1 | FileCheck %s --check-prefix=O0 --check-prefix=UNIQUE
; RUN: opt -S -passes='default<O1>' -new-pm-pseudo-probe-for-profiling -new-pm-unique-internal-linkage-names -debug-pass-manager < %s 2>&1 | FileCheck %s --check-prefix=O2 --check-prefix=UNIQUE
; RUN: opt -S -passes='default<O2>' -new-pm-pseudo-probe-for-profiling -new-pm-unique-internal-linkage-names -debug-pass-manager < %s 2>&1 | FileCheck %s --check-prefix=O2 --check-prefix=UNIQUE
; RUN: opt -S -passes='thinlto-pre-link<O1>' -new-pm-pseudo-probe-for-profiling -new-pm-unique-internal-linkage-names -debug-pass-manager < %s 2>&1 | FileCheck %s --check-prefix=O2 --check-prefix=UNIQUE
; RUN: opt -S -passes='thinlto-pre-link<O2>' -new-pm-pseudo-probe-for-profiling -new-pm-unique-internal-linkage-names -debug-pass-manager < %s 2>&1 | FileCheck %s --check-prefix=O2 --check-prefix=UNIQUE
; RUN: opt -S -passes=unique-internal-linkage-names < %s -o - | FileCheck %s --check-prefix=DBG
define internal i32 @foo() !dbg !15 {
entry:
ret i32 0
}
define dso_local i32 (...)* @bar() {
entry:
ret i32 (...)* bitcast (i32 ()* @foo to i32 (...)*)
}
define internal i32 @go() !dbg !19 {
entry:
ret i32 0
}
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, enums: !2)
!1 = !DIFile(filename: "test.c", directory: "")
!2 = !{}
!3 = !{i32 7, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!15 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 5, type: !16, scopeLine: 5, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, declaration: !18, retainedNodes: !2)
!16 = !DISubroutineType(types: !17)
!17 = !{!13}
!18 = !DISubprogram(name: "foo", linkageName: "foo", scope: !1, isDefinition: false, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
!19 = distinct !DISubprogram(name: "go", scope: !1, file: !1, line: 5, type: !16, scopeLine: 5, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, declaration: !18, retainedNodes: !2)
; O0: Running pass: UniqueInternalLinkageNamesPass
;; Check UniqueInternalLinkageNamesPass is scheduled before SampleProfileProbePass.
; O2: Running pass: UniqueInternalLinkageNamesPass
; O2: Running pass: SampleProfileProbePass
; UNIQUE: define internal i32 @foo.__uniq.{{[0-9]+}}() [[ATTR:#[0-9]+]]
; UNIQUE: ret {{.*}} @foo.__uniq.{{[0-9]+}} {{.*}}
; UNIQUE: attributes [[ATTR]] = {{{.*}} "sample-profile-suffix-elision-policy"="selected" {{.*}}}
; DBG: distinct !DISubprogram(name: "foo", linkageName: "foo.__uniq.{{[0-9]+}}", scope: ![[#]]
; DBG: !DISubprogram(name: "foo", linkageName: "foo.__uniq.{{[0-9]+}}", scope: ![[#]]
; DBG: distinct !DISubprogram(name: "go", scope: ![[#]]

View File

@ -1,14 +0,0 @@
; RUN: opt -S -unique-internal-linkage-names < %s | FileCheck %s
; RUN: opt -S -passes=unique-internal-linkage-names < %s | FileCheck %s
source_filename = "foo.c"
@glob = internal global i32 0
define internal i32 @foo() {
entry:
ret i32 0
}
; CHECK: @glob.__uniq.142098474322525230676991677820000238157 = internal global
; CHECK: define internal i32 @foo.__uniq.142098474322525230676991677820000238157()

View File

@ -137,10 +137,6 @@ static cl::opt<bool> DebugInfoForProfiling(
static cl::opt<bool> PseudoProbeForProfiling(
"new-pm-pseudo-probe-for-profiling", cl::init(false), cl::Hidden,
cl::desc("Emit pseudo probes to enable PGO profile generation."));
static cl::opt<bool> UniqueInternalLinkageNames(
"new-pm-unique-internal-linkage-names", cl::init(false), cl::Hidden,
cl::desc("Uniqueify Internal Linkage Symbol Names by appending the MD5 "
"hash of the module path."));
/// @}}
template <typename PassManagerT>
@ -292,7 +288,6 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
// option has been enabled.
PTO.LoopUnrolling = !DisableLoopUnrolling;
PTO.Coroutines = Coroutines;
PTO.UniqueLinkageNames = UniqueInternalLinkageNames;
PassBuilder PB(DebugPM, TM, PTO, P, &PIC);
registerEPCallbacks(PB);

View File

@ -76,7 +76,6 @@ static_library("Utils") {
"SymbolRewriter.cpp",
"UnifyFunctionExitNodes.cpp",
"UnifyLoopExits.cpp",
"UniqueInternalLinkageNames.cpp",
"Utils.cpp",
"VNCoercion.cpp",
"ValueMapper.cpp",