hoy updated this revision to Diff 313566. hoy edited the summary of this revision. hoy added a comment.
Checking pipeline in clang test. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93656/new/ https://reviews.llvm.org/D93656 Files: clang/lib/CodeGen/BackendUtil.cpp clang/test/CodeGen/unique-internal-linkage-names.cpp llvm/include/llvm/Passes/PassBuilder.h llvm/lib/Passes/PassBuilder.cpp llvm/test/Transforms/UniqueLinkageNames/unique-internal-linkage-names.ll
Index: llvm/test/Transforms/UniqueLinkageNames/unique-internal-linkage-names.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/UniqueLinkageNames/unique-internal-linkage-names.ll @@ -0,0 +1,37 @@ +; RUN: opt -S -unique-internal-linkage-names < %s | FileCheck %s +; RUN: opt -S -passes=unique-internal-linkage-names < %s | FileCheck %s + +define internal i32 @foo() !dbg !15 { +entry: + ret i32 0, !dbg !18 +} + +define dso_local i32 (...)* @bar() !dbg !7 { +entry: + ret i32 (...)* bitcast (i32 ()* @foo to i32 (...)*), !dbg !14 +} + +!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} +!7 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 9, type: !8, scopeLine: 9, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!8 = !DISubroutineType(types: !9) +!9 = !{!10} +!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64) +!11 = !DISubroutineType(types: !12) +!12 = !{!13, null} +!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!14 = !DILocation(line: 10, column: 3, scope: !7) +!15 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 5, type: !16, scopeLine: 5, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !2) +!16 = !DISubroutineType(types: !17) +!17 = !{!13} +!18 = !DILocation(line: 6, column: 3, scope: !15) + +; CHECK: define internal i32 @foo.__uniq.{{[0-9a-f]+}}() +; CHECK: ret {{.*}} @foo.__uniq.{{[0-9a-f]+}} {{.*}} Index: llvm/lib/Passes/PassBuilder.cpp =================================================================== --- llvm/lib/Passes/PassBuilder.cpp +++ llvm/lib/Passes/PassBuilder.cpp @@ -284,6 +284,7 @@ LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap; CallGraphProfile = true; MergeFunctions = false; + UniqueLinkageNames = false; } extern cl::opt<bool> EnableConstraintElimination; @@ -1001,6 +1002,11 @@ ThinLTOPhase 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 && @@ -1764,6 +1770,11 @@ 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( Index: llvm/include/llvm/Passes/PassBuilder.h =================================================================== --- llvm/include/llvm/Passes/PassBuilder.h +++ llvm/include/llvm/Passes/PassBuilder.h @@ -127,6 +127,9 @@ /// 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. Index: clang/test/CodeGen/unique-internal-linkage-names.cpp =================================================================== --- clang/test/CodeGen/unique-internal-linkage-names.cpp +++ clang/test/CodeGen/unique-internal-linkage-names.cpp @@ -1,10 +1,10 @@ // This test checks if internal linkage symbols get unique names with // -funique-internal-linkage-names option. // RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -o - < %s | FileCheck %s --check-prefix=PLAIN -// RUN: %clang_cc1 -triple x86_64 -x c++ -O0 -S -emit-llvm -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUE -// RUN: %clang_cc1 -triple x86_64 -x c++ -O1 -S -emit-llvm -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUEO1 -// RUN: %clang_cc1 -triple x86_64 -x c++ -O0 -S -emit-llvm -fexperimental-new-pass-manager -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUE -// RUN: %clang_cc1 -triple x86_64 -x c++ -O1 -S -emit-llvm -fexperimental-new-pass-manager -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUEO1 +// RUN: %clang_cc1 -triple x86_64 -x c++ -O0 -S -emit-llvm -funique-internal-linkage-names -mllvm -debug-pass=Structure -o - < %s 2>&1 | FileCheck %s --check-prefix=LPIPELINE --check-prefix=UNIQUE +// RUN: %clang_cc1 -triple x86_64 -x c++ -O1 -S -emit-llvm -funique-internal-linkage-names -mllvm -debug-pass=Structure -o - < %s 2>&1 | FileCheck %s --check-prefix=LPIPELINE --check-prefix=UNIQUEO1 +// RUN: %clang_cc1 -triple x86_64 -x c++ -O0 -S -emit-llvm -fexperimental-new-pass-manager -funique-internal-linkage-names -fdebug-pass-manager -o - < %s 2>&1 | FileCheck %s --check-prefix=NPIPELINE --check-prefix=UNIQUE +// RUN: %clang_cc1 -triple x86_64 -x c++ -O1 -S -emit-llvm -fexperimental-new-pass-manager -funique-internal-linkage-names -fdebug-pass-manager -o - < %s 2>&1 | FileCheck %s --check-prefix=NPIPELINE --check-prefix=UNIQUEO1 static int glob; static int foo() { @@ -45,6 +45,8 @@ return mver(); } +// LPIPELINE: Unique Internal Linkage Names +// NPIPELINE: Running pass: UniqueInternalLinkageNamesPass // PLAIN: @_ZL4glob = internal global // PLAIN: @_ZZ8retAnonMvE5fGlob = internal global // PLAIN: @_ZN12_GLOBAL__N_16anon_mE = internal global Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -1144,6 +1144,7 @@ // non-integrated assemblers don't recognize .cgprofile section. PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS; PTO.Coroutines = LangOpts.Coroutines; + PTO.UniqueLinkageNames = CodeGenOpts.UniqueInternalLinkageNames; PassInstrumentationCallbacks PIC; StandardInstrumentations SI(CodeGenOpts.DebugPassManager); @@ -1325,11 +1326,6 @@ MPM = PB.buildPerModuleDefaultPipeline(Level); } - // Add UniqueInternalLinkageNames Pass which renames internal linkage - // symbols with unique names. - if (CodeGenOpts.UniqueInternalLinkageNames) - MPM.addPass(UniqueInternalLinkageNamesPass()); - if (!CodeGenOpts.MemoryProfileOutput.empty()) { MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass())); MPM.addPass(ModuleMemProfilerPass());
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits