From 1911a50fae8a441b445eb835b98950710d28fc88 Mon Sep 17 00:00:00 2001 From: Rahman Lavaee Date: Wed, 25 Sep 2024 12:03:38 -0700 Subject: [PATCH] Deprecate the `-fbasic-block-sections=labels` option. (#107494) This feature is supported via the newer option `-fbasic-block-address-map`. Using the old option still works by delegating to the newer option, while a warning is printed to show deprecation. --- clang/docs/UsersManual.rst | 12 +++++++----- clang/include/clang/Basic/CodeGenOptions.h | 9 ++------- clang/include/clang/Driver/Options.td | 4 ++-- clang/lib/CodeGen/BackendUtil.cpp | 1 - clang/lib/Driver/ToolChains/Clang.cpp | 10 +++++++--- clang/test/Driver/fbasic-block-sections.c | 3 ++- llvm/docs/CommandGuide/llvm-objdump.rst | 2 +- llvm/docs/Extensions.rst | 2 +- llvm/include/llvm/CodeGen/MachineFunction.h | 5 ----- llvm/include/llvm/Target/TargetOptions.h | 3 --- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 11 +++++------ llvm/lib/CodeGen/BasicBlockSections.cpp | 7 ------- llvm/lib/CodeGen/CommandFlags.cpp | 2 -- llvm/lib/CodeGen/MIRParser/MIParser.cpp | 9 +-------- llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 4 +--- llvm/lib/CodeGen/MachineFunction.cpp | 8 +++----- ...ock.ll => basic-block-address-map-empty-block.ll} | 2 +- ....ll => basic-block-address-map-empty-function.ll} | 4 ++-- .../X86/basic-block-address-map-function-sections.ll | 1 - ...rse.mir => basic-block-address-map-mir-parse.mir} | 4 ++-- ...es.ll => basic-block-address-map-pgo-features.ll} | 10 +++++----- llvm/test/CodeGen/X86/basic-block-address-map.ll | 4 +--- .../CodeGen/X86/basic-block-sections-mir-print.ll | 10 +++++----- 23 files changed, 48 insertions(+), 79 deletions(-) rename llvm/test/CodeGen/X86/{basic-block-sections-labels-empty-block.ll => basic-block-address-map-empty-block.ll} (83%) rename llvm/test/CodeGen/X86/{basic-block-sections-labels-empty-function.ll => basic-block-address-map-empty-function.ll} (68%) rename llvm/test/CodeGen/X86/{basic-block-labels-mir-parse.mir => basic-block-address-map-mir-parse.mir} (97%) rename llvm/test/CodeGen/X86/{basic-block-sections-labels-pgo-features.ll => basic-block-address-map-pgo-features.ll} (88%) diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 57d78f867bab..4f03388bc87b 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -2369,14 +2369,16 @@ are listed below. $ cd $P/bar && clang -c -funique-internal-linkage-names name_conflict.c $ cd $P && clang foo/name_conflict.o && bar/name_conflict.o -.. option:: -fbasic-block-sections=[labels, all, list=, none] +.. option:: -f[no]-basic-block-address-map: + Emits a ``SHT_LLVM_BB_ADDR_MAP`` section which includes address offsets for each + basic block in the program, relative to the parent function address. + + +.. option:: -fbasic-block-sections=[all, list=, none] Controls how Clang emits text sections for basic blocks. With values ``all`` and ``list=``, each basic block or a subset of basic blocks can be placed - in its own unique section. With the "labels" value, normal text sections are - emitted, but a ``.bb_addr_map`` section is emitted which includes address - offsets for each basic block in the program, relative to the parent function - address. + in its own unique section. With the ``list=`` option, a file containing the subset of basic blocks that need to placed in unique sections can be specified. The format of the diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index f2a707a8ba8d..814d4d4c99e5 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -107,18 +107,13 @@ public: // This field stores one of the allowed values for the option // -fbasic-block-sections=. The allowed values with this option are: - // {"labels", "all", "list=", "none"}. + // {"all", "list=", "none"}. // - // "labels": Only generate basic block symbols (labels) for all basic - // blocks, do not generate unique sections for basic blocks. - // Use the machine basic block id in the symbol name to - // associate profile info from virtual address to machine - // basic block. // "all" : Generate basic block sections for all basic blocks. // "list=": Generate basic block sections for a subset of basic blocks. // The functions and the machine basic block ids are specified // in the file. - // "none": Disable sections/labels for basic blocks. + // "none": Disable sections for basic blocks. std::string BBSections; // If set, override the default value of MCAsmInfo::BinutilsVersion. If diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 23bd686a85f5..c22b07e9f8a6 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4244,8 +4244,8 @@ defm basic_block_address_map : BoolFOption<"basic-block-address-map", def fbasic_block_sections_EQ : Joined<["-"], "fbasic-block-sections=">, Group, Visibility<[ClangOption, CC1Option, CC1AsOption]>, HelpText<"Place each function's basic blocks in unique sections (ELF Only)">, - DocBrief<[{Generate labels for each basic block or place each basic block or a subset of basic blocks in its own section.}]>, - Values<"all,labels,none,list=">, + DocBrief<[{Place each basic block or a subset of basic blocks in its own section.}]>, + Values<"all,none,list=">, MarshallingInfoString, [{"none"}]>; defm data_sections : BoolFOption<"data-sections", CodeGenOpts<"DataSections">, DefaultFalse, diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 916c92adb893..62c6a57e8b7c 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -429,7 +429,6 @@ static bool initTargetOptions(DiagnosticsEngine &Diags, Options.BBSections = llvm::StringSwitch(CodeGenOpts.BBSections) .Case("all", llvm::BasicBlockSection::All) - .Case("labels", llvm::BasicBlockSection::Labels) .StartsWith("list=", llvm::BasicBlockSection::List) .Case("none", llvm::BasicBlockSection::None) .Default(llvm::BasicBlockSection::None); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 0bab48caf1a5..9525f3739e22 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -6228,9 +6228,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) { StringRef Val = A->getValue(); - if (Triple.isX86() && Triple.isOSBinFormatELF()) { - if (Val != "all" && Val != "labels" && Val != "none" && - !Val.starts_with("list=")) + if (Val == "labels") { + D.Diag(diag::warn_drv_deprecated_arg) + << A->getAsString(Args) << /*hasReplacement=*/true + << "-fbasic-block-address-map"; + CmdArgs.push_back("-fbasic-block-address-map"); + } else if (Triple.isX86() && Triple.isOSBinFormatELF()) { + if (Val != "all" && Val != "none" && !Val.starts_with("list=")) D.Diag(diag::err_drv_invalid_value) << A->getAsString(Args) << A->getValue(); else diff --git a/clang/test/Driver/fbasic-block-sections.c b/clang/test/Driver/fbasic-block-sections.c index e13cc81e910b..6dfba5f404ce 100644 --- a/clang/test/Driver/fbasic-block-sections.c +++ b/clang/test/Driver/fbasic-block-sections.c @@ -22,7 +22,8 @@ // CHECK-OPT-NONE: "-fbasic-block-sections=none" // CHECK-OPT-ALL: "-fbasic-block-sections=all" // CHECK-OPT-LIST: "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c" -// CHECK-OPT-LABELS: "-fbasic-block-sections=labels" +// CHECK-OPT-LABELS: warning: argument '-fbasic-block-sections=labels' is deprecated, use '-fbasic-block-address-map' instead +// CHECK-OPT-LABELS: "-fbasic-block-address-map" // CHECK-TRIPLE: error: unsupported option '-fbasic-block-sections=all' for target // CHECK-INVALID-VALUE: error: invalid value {{[^ ]*}} in '-fbasic-block-sections={{.*}}' // CHECK-OPT-NULL-LIST: "-fbasic-block-sections=list=" diff --git a/llvm/docs/CommandGuide/llvm-objdump.rst b/llvm/docs/CommandGuide/llvm-objdump.rst index 7f8def756c69..ab9f583e96ec 100644 --- a/llvm/docs/CommandGuide/llvm-objdump.rst +++ b/llvm/docs/CommandGuide/llvm-objdump.rst @@ -272,7 +272,7 @@ OPTIONS When printing a PC-relative global symbol reference, print it as an offset from the leading symbol. When a bb-address-map section is present (i.e., the object file is built with - ``-fbasic-block-sections=labels``), labels are retrieved from that section + ``-fbasic-block-address-map``), labels are retrieved from that section instead. If a pgo-analysis-map is present alongside the bb-address-map, any available analyses are printed after the relevant block label. By default, any analysis with a special representation (i.e. BlockFrequency, diff --git a/llvm/docs/Extensions.rst b/llvm/docs/Extensions.rst index abc34bc3202c..ea267842cdc3 100644 --- a/llvm/docs/Extensions.rst +++ b/llvm/docs/Extensions.rst @@ -401,7 +401,7 @@ the symbol that belongs to the partition. It may be constructed as follows: This section stores the binary address of basic blocks along with other related metadata. This information can be used to map binary profiles (like perf profiles) directly to machine basic blocks. -This section is emitted with ``-basic-block-sections=labels`` and will contain +This section is emitted with ``-basic-block-address-map`` and will contain a BB address map table for every function. The ``SHT_LLVM_BB_ADDR_MAP`` type provides backward compatibility to allow diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index 5c1da4fa762e..997960fcd5d0 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -699,11 +699,6 @@ public: BBSectionsType == BasicBlockSection::Preset); } - /// Returns true if basic block labels are to be generated for this function. - bool hasBBLabels() const { - return BBSectionsType == BasicBlockSection::Labels; - } - void setBBSectionsType(BasicBlockSection V) { BBSectionsType = V; } /// Assign IsBeginSection IsEndSection fields for basic blocks in this diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h index 94e0fa2404d6..88f253805ca9 100644 --- a/llvm/include/llvm/Target/TargetOptions.h +++ b/llvm/include/llvm/Target/TargetOptions.h @@ -64,9 +64,6 @@ namespace llvm { List, // Get list of functions & BBs from a file. Selectively enables // basic block sections for a subset of basic blocks which can be // used to control object size bloats from creating sections. - Labels, // Do not use Basic Block Sections but label basic blocks. This - // is useful when associating profile counts from virtual addresses - // to basic blocks. Preset, // Similar to list but the blocks are identified by passes which // seek to use Basic Block Sections, e.g. MachineFunctionSplitter. // This option cannot be set via the command line. diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index d17800d375b7..317278911b28 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1432,7 +1432,7 @@ void AsmPrinter::emitBBAddrMapSection(const MachineFunction &MF) { OutStreamer->AddComment("BB id"); // Emit the BB ID for this basic block. // We only emit BaseID since CloneID is unset for - // basic-block-sections=labels. + // -basic-block-adress-map. // TODO: Emit the full BBID when labels and sections can be mixed // together. OutStreamer->emitULEB128IntValue(MBB.getBBID()->BaseID); @@ -1866,7 +1866,7 @@ void AsmPrinter::emitFunctionBody() { // We must emit temporary symbol for the end of this basic block, if either // we have BBLabels enabled or if this basic blocks marks the end of a // section. - if (MF->hasBBLabels() || MF->getTarget().Options.BBAddrMap || + if (MF->getTarget().Options.BBAddrMap || (MAI->hasDotTypeDotSizeDirective() && MBB.isEndSection())) OutStreamer->emitLabel(MBB.getEndSymbol()); @@ -2021,7 +2021,7 @@ void AsmPrinter::emitFunctionBody() { // Emit section containing BB address offsets and their metadata, when // BB labels are requested for this function. Skip empty functions. if (HasAnyRealCode) { - if (MF->hasBBLabels() || MF->getTarget().Options.BBAddrMap) + if (MF->getTarget().Options.BBAddrMap) emitBBAddrMapSection(*MF); else if (PgoAnalysisMapFeatures.getBits() != 0) MF->getContext().reportWarning( @@ -2620,7 +2620,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { F.hasFnAttribute("xray-instruction-threshold") || needFuncLabels(MF, *this) || NeedsLocalForSize || MF.getTarget().Options.EmitStackSizeSection || - MF.getTarget().Options.BBAddrMap || MF.hasBBLabels()) { + MF.getTarget().Options.BBAddrMap) { CurrentFnBegin = createTempSymbol("func_begin"); if (NeedsLocalForSize) CurrentFnSymForSize = CurrentFnBegin; @@ -4155,8 +4155,7 @@ bool AsmPrinter::shouldEmitLabelForBasicBlock( // With `-fbasic-block-sections=`, a label is needed for every non-entry block // in the labels mode (option `=labels`) and every section beginning in the // sections mode (`=all` and `=list=`). - if ((MF->hasBBLabels() || MF->getTarget().Options.BBAddrMap || - MBB.isBeginSection()) && + if ((MF->getTarget().Options.BBAddrMap || MBB.isBeginSection()) && !MBB.isEntryBlock()) return true; // A label is needed for any block with at least one predecessor (when that diff --git a/llvm/lib/CodeGen/BasicBlockSections.cpp b/llvm/lib/CodeGen/BasicBlockSections.cpp index 0071284c8620..1eedfc4b2591 100644 --- a/llvm/lib/CodeGen/BasicBlockSections.cpp +++ b/llvm/lib/CodeGen/BasicBlockSections.cpp @@ -311,11 +311,6 @@ bool BasicBlockSections::handleBBSections(MachineFunction &MF) { // original layout positions and finding the original fallthroughs. MF.RenumberBlocks(); - if (BBSectionsType == BasicBlockSection::Labels) { - MF.setBBSectionsType(BBSectionsType); - return true; - } - DenseMap FuncClusterInfo; if (BBSectionsType == BasicBlockSection::List) { auto [HasProfile, ClusterInfo] = @@ -382,8 +377,6 @@ bool BasicBlockSections::handleBBSections(MachineFunction &MF) { // avoids the need to store basic block IDs in the BB address map section, since // they can be determined implicitly. bool BasicBlockSections::handleBBAddrMap(MachineFunction &MF) { - if (MF.getTarget().getBBSectionsType() == BasicBlockSection::Labels) - return false; if (!MF.getTarget().Options.BBAddrMap) return false; MF.RenumberBlocks(); diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp index 9e42deb94903..d180cfcea658 100644 --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -525,8 +525,6 @@ llvm::BasicBlockSection codegen::getBBSectionsMode(llvm::TargetOptions &Options) { if (getBBSections() == "all") return BasicBlockSection::All; - else if (getBBSections() == "labels") - return BasicBlockSection::Labels; else if (getBBSections() == "none") return BasicBlockSection::None; else { diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 27f0a9331a3e..a0f0e27478d0 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -780,7 +780,7 @@ bool MIParser::parseBasicBlockDefinition( "' is not defined in the function '" + MF.getName() + "'"); } - auto *MBB = MF.CreateMachineBasicBlock(BB); + auto *MBB = MF.CreateMachineBasicBlock(BB, BBID); MF.insert(MF.end(), MBB); bool WasInserted = MBBSlots.insert(std::make_pair(ID, MBB)).second; if (!WasInserted) @@ -799,13 +799,6 @@ bool MIParser::parseBasicBlockDefinition( MBB->setSectionID(*SectionID); MF.setBBSectionsType(BasicBlockSection::List); } - if (BBID.has_value()) { - // BBSectionsType is set to `List` if any basic blocks has `SectionID`. - // Here, we set it to `Labels` if it hasn't been set above. - if (!MF.hasBBSections()) - MF.setBBSectionsType(BasicBlockSection::Labels); - MBB->setBBID(BBID.value()); - } MBB->setCallFrameSize(CallFrameSize); return false; } diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp index be07fbf478b1..997c428ca77d 100644 --- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp @@ -569,9 +569,7 @@ MIRParserImpl::initializeMachineFunction(const yaml::MachineFunction &YamlMF, return true; } // Check Basic Block Section Flags. - if (MF.getTarget().getBBSectionsType() == BasicBlockSection::Labels) { - MF.setBBSectionsType(BasicBlockSection::Labels); - } else if (MF.hasBBSections()) { + if (MF.hasBBSections()) { MF.assignBeginEndSections(); } PFS.SM = &SM; diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index ab45663436ce..b56888a0f71f 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -465,11 +465,9 @@ MachineFunction::CreateMachineBasicBlock(const BasicBlock *BB, MachineBasicBlock *MBB = new (BasicBlockRecycler.Allocate(Allocator)) MachineBasicBlock(*this, BB); - // Set BBID for `-basic-block=sections=labels` and - // `-basic-block-sections=list` to allow robust mapping of profiles to basic - // blocks. - if (Target.getBBSectionsType() == BasicBlockSection::Labels || - Target.Options.BBAddrMap || + // Set BBID for `-basic-block-sections=list` and `-basic-block-address-map` to + // allow robust mapping of profiles to basic blocks. + if (Target.Options.BBAddrMap || Target.getBBSectionsType() == BasicBlockSection::List) MBB->setBBID(BBID.has_value() ? *BBID : UniqueBBID{NextBBID++, 0}); return MBB; diff --git a/llvm/test/CodeGen/X86/basic-block-sections-labels-empty-block.ll b/llvm/test/CodeGen/X86/basic-block-address-map-empty-block.ll similarity index 83% rename from llvm/test/CodeGen/X86/basic-block-sections-labels-empty-block.ll rename to llvm/test/CodeGen/X86/basic-block-address-map-empty-block.ll index 8e0f4fa7bc92..84948b7ecf6e 100644 --- a/llvm/test/CodeGen/X86/basic-block-sections-labels-empty-block.ll +++ b/llvm/test/CodeGen/X86/basic-block-address-map-empty-block.ll @@ -1,5 +1,5 @@ ;; This test verifies that with -gc-empty-basic-blocks SHT_LLVM_BB_ADDR_MAP will not include entries for empty blocks. -; RUN: llc < %s -mtriple=x86_64 -O0 -basic-block-sections=labels -gc-empty-basic-blocks | FileCheck --check-prefix=CHECK %s +; RUN: llc < %s -mtriple=x86_64 -O0 -basic-block-address-map -gc-empty-basic-blocks | FileCheck --check-prefix=CHECK %s define void @foo(i1 zeroext %0) nounwind { br i1 %0, label %2, label %empty_block diff --git a/llvm/test/CodeGen/X86/basic-block-sections-labels-empty-function.ll b/llvm/test/CodeGen/X86/basic-block-address-map-empty-function.ll similarity index 68% rename from llvm/test/CodeGen/X86/basic-block-sections-labels-empty-function.ll rename to llvm/test/CodeGen/X86/basic-block-address-map-empty-function.ll index 42d09212e669..444655fc5299 100644 --- a/llvm/test/CodeGen/X86/basic-block-sections-labels-empty-function.ll +++ b/llvm/test/CodeGen/X86/basic-block-address-map-empty-function.ll @@ -1,6 +1,6 @@ ;; Verify that the BB address map is not emitted for empty functions. -; RUN: llc < %s -mtriple=x86_64 -basic-block-sections=labels | FileCheck %s --check-prefixes=CHECK,BASIC -; RUN: llc < %s -mtriple=x86_64 -basic-block-sections=labels -pgo-analysis-map=func-entry-count,bb-freq | FileCheck %s --check-prefixes=CHECK,PGO +; RUN: llc < %s -mtriple=x86_64 -basic-block-address-map | FileCheck %s --check-prefixes=CHECK,BASIC +; RUN: llc < %s -mtriple=x86_64 -basic-block-address-map -pgo-analysis-map=func-entry-count,bb-freq | FileCheck %s --check-prefixes=CHECK,PGO define void @empty_func() { entry: diff --git a/llvm/test/CodeGen/X86/basic-block-address-map-function-sections.ll b/llvm/test/CodeGen/X86/basic-block-address-map-function-sections.ll index d7678604cffa..9ff96381c205 100644 --- a/llvm/test/CodeGen/X86/basic-block-address-map-function-sections.ll +++ b/llvm/test/CodeGen/X86/basic-block-address-map-function-sections.ll @@ -1,4 +1,3 @@ -; RUN: llc < %s -mtriple=x86_64 -function-sections -basic-block-sections=labels | FileCheck %s ; RUN: llc < %s -mtriple=x86_64 -function-sections -basic-block-address-map | FileCheck %s $_Z4fooTIiET_v = comdat any diff --git a/llvm/test/CodeGen/X86/basic-block-labels-mir-parse.mir b/llvm/test/CodeGen/X86/basic-block-address-map-mir-parse.mir similarity index 97% rename from llvm/test/CodeGen/X86/basic-block-labels-mir-parse.mir rename to llvm/test/CodeGen/X86/basic-block-address-map-mir-parse.mir index 6408f0a30af7..86f5f27494ec 100644 --- a/llvm/test/CodeGen/X86/basic-block-labels-mir-parse.mir +++ b/llvm/test/CodeGen/X86/basic-block-address-map-mir-parse.mir @@ -1,5 +1,5 @@ # Start after bbsections0-prepare and check that the BB address map is generated. -# RUN: llc -mtriple x86_64-unknown-linux-gnu -start-after=bbsections-prepare %s -o - | FileCheck %s -check-prefix=CHECK +# RUN: llc -mtriple x86_64-unknown-linux-gnu -start-after=bbsections-prepare -basic-block-address-map %s -o - | FileCheck %s -check-prefix=CHECK # How to generate the input: # foo.cc @@ -9,7 +9,7 @@ # } # # clang -O0 -S -emit-llvm foo.cc -# llc < foo.ll -stop-after=bbsections-prepare -basic-block-sections=labels +# llc < foo.ll -stop-after=bbsections-prepare -basic-block-address-map # CHECK: .section .llvm_bb_addr_map,"o",@llvm_bb_addr_map,.text --- | diff --git a/llvm/test/CodeGen/X86/basic-block-sections-labels-pgo-features.ll b/llvm/test/CodeGen/X86/basic-block-address-map-pgo-features.ll similarity index 88% rename from llvm/test/CodeGen/X86/basic-block-sections-labels-pgo-features.ll rename to llvm/test/CodeGen/X86/basic-block-address-map-pgo-features.ll index 92d3c88b4f60..73fe4f6ffedb 100644 --- a/llvm/test/CodeGen/X86/basic-block-sections-labels-pgo-features.ll +++ b/llvm/test/CodeGen/X86/basic-block-address-map-pgo-features.ll @@ -1,13 +1,13 @@ ; Check the basic block sections labels option -; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-sections=labels | FileCheck %s --check-prefixes=CHECK,BASIC +; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map | FileCheck %s --check-prefixes=CHECK,BASIC ;; Also verify this holds for all PGO features enabled -; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-sections=labels -pgo-analysis-map=func-entry-count,bb-freq,br-prob | FileCheck %s --check-prefixes=CHECK,PGO-ALL,PGO-FEC,PGO-BBF,PGO-BRP +; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map -pgo-analysis-map=func-entry-count,bb-freq,br-prob | FileCheck %s --check-prefixes=CHECK,PGO-ALL,PGO-FEC,PGO-BBF,PGO-BRP ;; Also verify that pgo extension only includes the enabled feature -; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-sections=labels -pgo-analysis-map=func-entry-count | FileCheck %s --check-prefixes=CHECK,PGO-FEC,FEC-ONLY -; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-sections=labels -pgo-analysis-map=bb-freq | FileCheck %s --check-prefixes=CHECK,PGO-BBF,BBF-ONLY -; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-sections=labels -pgo-analysis-map=br-prob | FileCheck %s --check-prefixes=CHECK,PGO-BRP,BRP-ONLY +; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map -pgo-analysis-map=func-entry-count | FileCheck %s --check-prefixes=CHECK,PGO-FEC,FEC-ONLY +; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map -pgo-analysis-map=bb-freq | FileCheck %s --check-prefixes=CHECK,PGO-BBF,BBF-ONLY +; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map -pgo-analysis-map=br-prob | FileCheck %s --check-prefixes=CHECK,PGO-BRP,BRP-ONLY define void @_Z3bazb(i1 zeroext, i1 zeroext) personality ptr @__gxx_personality_v0 !prof !0 { diff --git a/llvm/test/CodeGen/X86/basic-block-address-map.ll b/llvm/test/CodeGen/X86/basic-block-address-map.ll index 6ab24b494936..4f12258eeeea 100644 --- a/llvm/test/CodeGen/X86/basic-block-address-map.ll +++ b/llvm/test/CodeGen/X86/basic-block-address-map.ll @@ -1,9 +1,7 @@ ; Check the basic block sections labels option ; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map | FileCheck %s --check-prefixes=CHECK,UNIQ -; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-sections=labels | FileCheck %s --check-prefixes=CHECK,UNIQ ; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=false -basic-block-address-map | FileCheck %s --check-prefixes=CHECK,NOUNIQ -; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=false -basic-block-sections=labels | FileCheck %s --check-prefixes=CHECK,NOUNIQ -; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-sections=labels -split-machine-functions | FileCheck %s --check-prefixes=CHECK,UNIQ +; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map -split-machine-functions | FileCheck %s --check-prefixes=CHECK,UNIQ define void @_Z3bazb(i1 zeroext, i1 zeroext) personality ptr @__gxx_personality_v0 { br i1 %0, label %3, label %8 diff --git a/llvm/test/CodeGen/X86/basic-block-sections-mir-print.ll b/llvm/test/CodeGen/X86/basic-block-sections-mir-print.ll index 1767903561ce..fec87656be19 100644 --- a/llvm/test/CodeGen/X86/basic-block-sections-mir-print.ll +++ b/llvm/test/CodeGen/X86/basic-block-sections-mir-print.ll @@ -1,5 +1,5 @@ ; Stop after bbsections-prepare and check MIR output for section type. -; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=labels -stop-after=bbsections-prepare | FileCheck %s -check-prefix=BBLABELS +; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-address-map -stop-after=bbsections-prepare | FileCheck %s -check-prefix=BBADDRMAP ; RUN: echo '!_Z3foob' > %t ; RUN: echo '!!1' >> %t ; RUN: echo '!!2' >> %t @@ -33,7 +33,7 @@ define dso_local i32 @_Z3foob(i1 zeroext %0) { ; BBSECTIONS: bb.1 (%ir-block.7, bb_id 1) ; BBSECTIONS: bb.2 (%ir-block.8, bbsections 1, bb_id 2): -; BBLABELS: bb.0 (%ir-block.1, bb_id 0): -; BBLABELS: bb.1 (%ir-block.7, bb_id 1): -; BBLABELS: bb.2 (%ir-block.8, bb_id 2): -; BBLABELS: bb.3 (%ir-block.9, bb_id 3): +; BBADDRMAP: bb.0 (%ir-block.1, bb_id 0): +; BBADDRMAP: bb.1 (%ir-block.7, bb_id 1): +; BBADDRMAP: bb.2 (%ir-block.8, bb_id 2): +; BBADDRMAP: bb.3 (%ir-block.9, bb_id 3):