[llvm] 0ba1ebc - Remove original implementation of UniqueInternalLinkageNames pass.
Sriraman Tallam via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 10 12:04:07 PST 2021
Author: Sriraman Tallam
Date: 2021-03-10T11:57:40-08:00
New Revision: 0ba1ebcbb7751ad53d7be4704f815503837a75f8
URL: https://github.com/llvm/llvm-project/commit/0ba1ebcbb7751ad53d7be4704f815503837a75f8
DIFF: https://github.com/llvm/llvm-project/commit/0ba1ebcbb7751ad53d7be4704f815503837a75f8.diff
LOG: 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
Added:
Modified:
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Passes/PassBuilder.h
llvm/include/llvm/Transforms/Utils.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Utils/CMakeLists.txt
llvm/lib/Transforms/Utils/Utils.cpp
llvm/tools/opt/NewPMDriver.cpp
llvm/utils/gn/secondary/llvm/lib/Transforms/Utils/BUILD.gn
Removed:
llvm/include/llvm/Transforms/Utils/UniqueInternalLinkageNames.h
llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp
llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll
llvm/test/Transforms/UniqueInternalLinkageNames/unique_symbol_names.ll
################################################################################
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index 36a2053a6dff..085cf5fe340e 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -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&);
diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h
index 9bff0a4d9302..5209b57f7f41 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -128,9 +128,6 @@ class PipelineTuningOptions {
/// 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.
diff --git a/llvm/include/llvm/Transforms/Utils.h b/llvm/include/llvm/Transforms/Utils.h
index 9162a86183db..1e9c0a040ad2 100644
--- a/llvm/include/llvm/Transforms/Utils.h
+++ b/llvm/include/llvm/Transforms/Utils.h
@@ -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
diff --git a/llvm/include/llvm/Transforms/Utils/UniqueInternalLinkageNames.h b/llvm/include/llvm/Transforms/Utils/UniqueInternalLinkageNames.h
deleted file mode 100644
index 637b5d8e8e51..000000000000
--- a/llvm/include/llvm/Transforms/Utils/UniqueInternalLinkageNames.h
+++ /dev/null
@@ -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
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 12ed8ee8b05f..3a325277e370 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -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(
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index 5d8a1a076343..579143d3c1c8 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -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())
diff --git a/llvm/lib/Transforms/Utils/CMakeLists.txt b/llvm/lib/Transforms/Utils/CMakeLists.txt
index 7eb2d51a0593..4a0f17739d77 100644
--- a/llvm/lib/Transforms/Utils/CMakeLists.txt
+++ b/llvm/lib/Transforms/Utils/CMakeLists.txt
@@ -69,7 +69,6 @@ add_llvm_component_library(LLVMTransformUtils
SymbolRewriter.cpp
UnifyFunctionExitNodes.cpp
UnifyLoopExits.cpp
- UniqueInternalLinkageNames.cpp
Utils.cpp
ValueMapper.cpp
VNCoercion.cpp
diff --git a/llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp b/llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp
deleted file mode 100644
index c57cec6be676..000000000000
--- a/llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp
+++ /dev/null
@@ -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
diff --git a/llvm/lib/Transforms/Utils/Utils.cpp b/llvm/lib/Transforms/Utils/Utils.cpp
index 73c0532f3fd5..3ca36a1cad91 100644
--- a/llvm/lib/Transforms/Utils/Utils.cpp
+++ b/llvm/lib/Transforms/Utils/Utils.cpp
@@ -45,7 +45,6 @@ void llvm::initializeTransformUtils(PassRegistry &Registry) {
initializeInjectTLIMappingsLegacyPass(Registry);
initializeFixIrreduciblePass(Registry);
initializeUnifyLoopExitsLegacyPassPass(Registry);
- initializeUniqueInternalLinkageNamesLegacyPassPass(Registry);
}
/// LLVMInitializeTransformUtils - C binding for initializeTransformUtilsPasses.
diff --git a/llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll b/llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll
deleted file mode 100644
index dcb49d9b7a51..000000000000
--- a/llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll
+++ /dev/null
@@ -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: ![[#]]
diff --git a/llvm/test/Transforms/UniqueInternalLinkageNames/unique_symbol_names.ll b/llvm/test/Transforms/UniqueInternalLinkageNames/unique_symbol_names.ll
deleted file mode 100644
index 492c716a0bb1..000000000000
--- a/llvm/test/Transforms/UniqueInternalLinkageNames/unique_symbol_names.ll
+++ /dev/null
@@ -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"
-
- at 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()
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 1c6da3822451..1071cb6cb39b 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -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);
diff --git a/llvm/utils/gn/secondary/llvm/lib/Transforms/Utils/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Transforms/Utils/BUILD.gn
index a3d88df7ca9e..479f7e8e98fc 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Transforms/Utils/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/Transforms/Utils/BUILD.gn
@@ -76,7 +76,6 @@ static_library("Utils") {
"SymbolRewriter.cpp",
"UnifyFunctionExitNodes.cpp",
"UnifyLoopExits.cpp",
- "UniqueInternalLinkageNames.cpp",
"Utils.cpp",
"VNCoercion.cpp",
"ValueMapper.cpp",
More information about the llvm-commits
mailing list