Author: Haohai Wen Date: 2025-09-01T08:31:40+08:00 New Revision: 2e122990391b2ba062e6308a12cfedf7206270ba
URL: https://github.com/llvm/llvm-project/commit/2e122990391b2ba062e6308a12cfedf7206270ba DIFF: https://github.com/llvm/llvm-project/commit/2e122990391b2ba062e6308a12cfedf7206270ba.diff LOG: [PseudoProbe] Support emitting to COFF object (#123870) RFC: https://discourse.llvm.org/t/rfc-support-pseudo-probe-for-windows-coff/83820 Support emitting pseudo probe to .pseudo_probe and .pseudo_probe_desc COFF sections. Added: Modified: clang/include/clang/Driver/Options.td clang/test/Driver/cl-options.c llvm/include/llvm/Target/TargetLoweringObjectFile.h llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm/lib/MC/MCObjectFileInfo.cpp llvm/lib/Target/TargetLoweringObjectFile.cpp llvm/test/Transforms/SampleProfile/pseudo-probe-callee-profile-mismatch.ll llvm/test/Transforms/SampleProfile/pseudo-probe-dangle.ll llvm/test/Transforms/SampleProfile/pseudo-probe-dangle2.ll llvm/test/Transforms/SampleProfile/pseudo-probe-desc-guid.ll llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll llvm/test/Transforms/SampleProfile/pseudo-probe-instsched.ll llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll llvm/test/Transforms/SampleProfile/pseudo-probe-missing-probe.ll llvm/test/Transforms/SampleProfile/pseudo-probe-no-debug-info.ll llvm/test/Transforms/SampleProfile/pseudo-probe-peep.ll llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-error.ll llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-thinlto.ll llvm/test/Transforms/SampleProfile/pseudo-probe-selectionDAG.ll llvm/test/Transforms/SampleProfile/pseudo-probe-slotindex.ll llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching-LCS.ll llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching-lto.ll llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching.ll llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming-recursive.ll llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming.ll llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll llvm/test/Transforms/SampleProfile/pseudo-probe-twoaddr.ll llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll Removed: ################################################################################ diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 781673df040c2..f507968d30670 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1851,7 +1851,7 @@ defm pseudo_probe_for_profiling CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse, PosFlag<SetTrue, [], [ClangOption], "Emit">, NegFlag<SetFalse, [], [ClangOption], "Do not emit">, - BothFlags<[], [ClangOption, CC1Option], + BothFlags<[], [ClangOption, CC1Option, CLOption], " pseudo probes for sample profiling">>; def fprofile_list_EQ : Joined<["-"], "fprofile-list=">, Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption]>, diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index 57e16e8795a28..e9708688a6e3d 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/test/Driver/cl-options.c @@ -728,6 +728,7 @@ // RUN: -fno-profile-instr-use \ // RUN: -fcs-profile-generate \ // RUN: -fcs-profile-generate=dir \ +// RUN: -fpseudo-probe-for-profiling \ // RUN: -ftime-trace \ // RUN: -fmodules \ // RUN: -fno-modules \ diff --git a/llvm/include/llvm/Target/TargetLoweringObjectFile.h b/llvm/include/llvm/Target/TargetLoweringObjectFile.h index 397239b1685fb..4d6cbc5540131 100644 --- a/llvm/include/llvm/Target/TargetLoweringObjectFile.h +++ b/llvm/include/llvm/Target/TargetLoweringObjectFile.h @@ -94,7 +94,9 @@ class LLVM_ABI TargetLoweringObjectFile : public MCObjectFileInfo { void emitCGProfileMetadata(MCStreamer &Streamer, Module &M) const; /// Emit pseudo_probe_desc metadata. - void emitPseudoProbeDescMetadata(MCStreamer &Streamer, Module &M) const; + void emitPseudoProbeDescMetadata(MCStreamer &Streamer, Module &M, + std::function<void(MCStreamer &Streamer)> + COMDATSymEmitter = nullptr) const; /// Process linker options metadata and emit platform-specific bits. virtual void emitLinkerDirectives(MCStreamer &Streamer, Module &M) const {} diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 739dcc7f4c868..ae681b9aebdfb 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1920,6 +1920,13 @@ void TargetLoweringObjectFileCOFF::emitModuleMetadata(MCStreamer &Streamer, } emitCGProfileMetadata(Streamer, M); + emitPseudoProbeDescMetadata(Streamer, M, [](MCStreamer &Streamer) { + if (MCSymbol *Sym = + static_cast<MCSectionCOFF *>(Streamer.getCurrentSectionOnly()) + ->getCOMDATSymbol()) + if (Sym->isUndefined()) + Streamer.emitLabel(Sym); + }); } void TargetLoweringObjectFileCOFF::emitLinkerDirectives( diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index d505ac6dd4bf2..a0cd09b11d8de 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -849,6 +849,16 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) { StackMapSection = Ctx->getCOFFSection(".llvm_stackmaps", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ); + + // Set IMAGE_SCN_MEM_DISCARDABLE so that lld will not truncate section name. + PseudoProbeSection = Ctx->getCOFFSection( + ".pseudo_probe", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | + COFF::IMAGE_SCN_MEM_DISCARDABLE | + COFF::IMAGE_SCN_MEM_READ); + PseudoProbeDescSection = Ctx->getCOFFSection( + ".pseudo_probe_desc", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | + COFF::IMAGE_SCN_MEM_DISCARDABLE | + COFF::IMAGE_SCN_MEM_READ); } void MCObjectFileInfo::initSPIRVMCObjectFileInfo(const Triple &T) { @@ -1220,44 +1230,68 @@ MCObjectFileInfo::getKCFITrapSection(const MCSection &TextSec) const { MCSection * MCObjectFileInfo::getPseudoProbeSection(const MCSection &TextSec) const { - if (Ctx->getObjectFileType() != MCContext::IsELF) - return PseudoProbeSection; - - const auto &ElfSec = static_cast<const MCSectionELF &>(TextSec); - unsigned Flags = ELF::SHF_LINK_ORDER; - StringRef GroupName; - if (const MCSymbol *Group = ElfSec.getGroup()) { - GroupName = Group->getName(); - Flags |= ELF::SHF_GROUP; + auto ObjFileType = Ctx->getObjectFileType(); + if (ObjFileType == MCContext::IsELF) { + const auto &ElfSec = static_cast<const MCSectionELF &>(TextSec); + unsigned Flags = ELF::SHF_LINK_ORDER; + StringRef GroupName; + if (const MCSymbol *Group = ElfSec.getGroup()) { + GroupName = Group->getName(); + Flags |= ELF::SHF_GROUP; + } + return Ctx->getELFSection( + PseudoProbeSection->getName(), ELF::SHT_PROGBITS, Flags, 0, GroupName, + true, ElfSec.getUniqueID(), + static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol())); + } else if (ObjFileType == MCContext::IsCOFF) { + StringRef COMDATSymName = ""; + int Selection = 0; + unsigned Characteristics = + static_cast<MCSectionCOFF *>(PseudoProbeSection)->getCharacteristics(); + const auto &COFFSec = static_cast<const MCSectionCOFF &>(TextSec); + if (const MCSymbol *COMDATSym = COFFSec.getCOMDATSymbol()) { + // Associate .pseudo_probe to its function section. + COMDATSymName = COMDATSym->getName(); + Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT; + Selection = COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE; + } + return Ctx->getCOFFSection(PseudoProbeSection->getName(), Characteristics, + COMDATSymName, Selection, COFFSec.getUniqueID()); } - return Ctx->getELFSection( - PseudoProbeSection->getName(), ELF::SHT_PROGBITS, Flags, 0, GroupName, - true, ElfSec.getUniqueID(), - static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol())); + return PseudoProbeSection; } MCSection * MCObjectFileInfo::getPseudoProbeDescSection(StringRef FuncName) const { - if (Ctx->getObjectFileType() == MCContext::IsELF) { - // Create a separate comdat group for each function's descriptor in order - // for the linker to deduplicate. The duplication, must be from diff erent - // tranlation unit, can come from: - // 1. Inline functions defined in header files; - // 2. ThinLTO imported funcions; - // 3. Weak-linkage definitions. - // Use a concatenation of the section name and the function name as the - // group name so that descriptor-only groups won't be folded with groups of - // code. - if (Ctx->getTargetTriple().supportsCOMDAT() && !FuncName.empty()) { - auto *S = static_cast<MCSectionELF *>(PseudoProbeDescSection); - auto Flags = S->getFlags() | ELF::SHF_GROUP; - return Ctx->getELFSection(S->getName(), S->getType(), Flags, - S->getEntrySize(), - S->getName() + "_" + FuncName, - /*IsComdat=*/true); - } + if (!Ctx->getTargetTriple().supportsCOMDAT() || FuncName.empty()) + return PseudoProbeDescSection; + + // Create a separate comdat group for each function's descriptor in order + // for the linker to deduplicate. The duplication, must be from diff erent + // tranlation unit, can come from: + // 1. Inline functions defined in header files; + // 2. ThinLTO imported funcions; + // 3. Weak-linkage definitions. + // Use a concatenation of the section name and the function name as the + // group name so that descriptor-only groups won't be folded with groups of + // code. + auto ObjFileType = Ctx->getObjectFileType(); + if (ObjFileType == MCContext::IsELF) { + auto *S = static_cast<MCSectionELF *>(PseudoProbeDescSection); + auto Flags = S->getFlags() | ELF::SHF_GROUP; + return Ctx->getELFSection(S->getName(), S->getType(), Flags, + S->getEntrySize(), S->getName() + "_" + FuncName, + /*IsComdat=*/true); + } else if (ObjFileType == MCContext::IsCOFF) { + auto *S = static_cast<MCSectionCOFF *>(PseudoProbeDescSection); + unsigned Characteristics = + S->getCharacteristics() | COFF::IMAGE_SCN_LNK_COMDAT; + std::string COMDATSymName = (S->getName() + "_" + FuncName).str(); + return Ctx->getCOFFSection(S->getName(), Characteristics, COMDATSymName, + COFF::IMAGE_COMDAT_SELECT_EXACT_MATCH); } + return PseudoProbeDescSection; } diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp index 28495e7c57195..343bcce80e3a1 100644 --- a/llvm/lib/Target/TargetLoweringObjectFile.cpp +++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp @@ -191,8 +191,9 @@ void TargetLoweringObjectFile::emitCGProfileMetadata(MCStreamer &Streamer, } } -void TargetLoweringObjectFile::emitPseudoProbeDescMetadata(MCStreamer &Streamer, - Module &M) const { +void TargetLoweringObjectFile::emitPseudoProbeDescMetadata( + MCStreamer &Streamer, Module &M, + std::function<void(MCStreamer &Streamer)> COMDATSymEmitter) const { NamedMDNode *FuncInfo = M.getNamedMetadata(PseudoProbeDescMetadataName); if (!FuncInfo) return; @@ -213,6 +214,11 @@ void TargetLoweringObjectFile::emitPseudoProbeDescMetadata(MCStreamer &Streamer, TM->getFunctionSections() ? Name->getString() : StringRef()); Streamer.switchSection(S); + + // emit COFF COMDAT symbol. + if (COMDATSymEmitter) + COMDATSymEmitter(Streamer); + Streamer.emitInt64(GUID->getZExtValue()); Streamer.emitInt64(Hash->getZExtValue()); Streamer.emitULEB128IntValue(Name->getString().size()); diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-callee-profile-mismatch.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-callee-profile-mismatch.ll index dd86c7b81c5a3..0c7f3ac2a0d5e 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-callee-profile-mismatch.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-callee-profile-mismatch.ll @@ -1,5 +1,4 @@ -; REQUIRES: x86_64-linux -; REQUIRES: asserts +; REQUIRES: asserts && x86-registered-target ; RUN: opt < %s -passes='thinlto<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/pseudo-probe-callee-profile-mismatch.prof --salvage-stale-profile --salvage-unused-profile=false -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline 2>&1 | FileCheck %s ; There is no profile-checksum-mismatch attr, even the checksum is mismatched in the pseudo_probe_desc, it doesn't run the matching. @@ -13,9 +12,6 @@ ; CHECK: Profile is invalid due to CFG mismatch for Function bar -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - define available_externally i32 @main() #0 { %1 = call i32 @bar(), !dbg !13 ret i32 0 diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle.ll index f0b6fdf62d969..ec619577c68e7 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle.ll @@ -1,9 +1,10 @@ -; REQUIRES: x86_64-linux +; REQUIRES: x86-registered-target ; RUN: opt < %s -passes='pseudo-probe,jump-threading' -S -o %t ; RUN: FileCheck %s < %t --check-prefix=JT -; RUN: llc -function-sections <%t -filetype=asm | FileCheck %s --check-prefix=ASM +; RUN: llc -mtriple=x86_64-unknown-linux-gnu -function-sections <%t -filetype=asm | FileCheck %s --check-prefix=ASM +; RUN: llc -mtriple=x86_64-unknown-windows-msvc -function-sections <%t -filetype=asm | FileCheck %s --check-prefix=ASM ; RUN: opt < %s -passes='pseudo-probe' -S -o %t1 -; RUN: llc -stop-after=tailduplication <%t1 | FileCheck %s --check-prefix=MIR-tail +; RUN: llc -mtriple=x86_64-- -stop-after=tailduplication <%t1 | FileCheck %s --check-prefix=MIR-tail ; RUN: opt < %s -passes='pseudo-probe,simplifycfg' -S | FileCheck %s --check-prefix=SC declare i32 @f1() diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle2.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle2.ll index b9cb327372844..f0c29d1553cb9 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle2.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle2.ll @@ -1,4 +1,4 @@ -; REQUIRES: x86_64-linux +; REQUIRES: x86-registered-target ; RUN: opt < %s -passes=simplifycfg -S -o %t ; RUN: FileCheck %s < %t diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-desc-guid.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-desc-guid.ll index 68bf54f2ebd79..b0040f445d9e0 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-desc-guid.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-desc-guid.ll @@ -1,4 +1,4 @@ -; REQUIRES: x86_64-linux +; REQUIRES: x86-registered-target ; RUN: opt < %s -passes=pseudo-probe -S -o - | FileCheck %s ; CHECK: ![[#]] = !{i64 -3345296970173352005, i64 [[#]], !"foo.dbg"} diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll index 0bde361018f7d..a5c456bf81917 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll @@ -1,14 +1,24 @@ -; REQUIRES: x86_64-linux -; RUN: opt < %s -passes='pseudo-probe,cgscc(inline)' -function-sections -mtriple=x86_64-unknown-linux-gnu -S -o %t +; REQUIRES: x86-registered-target +; RUN: opt < %s -passes='pseudo-probe,cgscc(inline)' -function-sections -S -o %t ; RUN: FileCheck %s < %t --check-prefix=CHECK-IL -; RUN: llc -function-sections <%t -filetype=asm -o %t1 -; RUN: FileCheck %s < %t1 --check-prefix=CHECK-ASM -; RUN: llc -function-sections <%t -filetype=obj -o %t2 -; RUN: llvm-objdump --section-headers %t2 | FileCheck %s --check-prefix=CHECK-OBJ -; RUN: llvm-mc -filetype=asm <%t1 -o %t3 -; RUN: FileCheck %s < %t3 --check-prefix=CHECK-ASM -; RUN: llvm-mc -filetype=obj <%t1 -o %t4 -; RUN: llvm-objdump --section-headers %t4 | FileCheck %s --check-prefix=CHECK-OBJ +; For ELF. +; RUN: llc -function-sections -mtriple=x86_64-unknown-linux-gnu <%t -filetype=asm -o %t1 +; RUN: FileCheck %s < %t1 --check-prefixes=CHECK-ASM,CHECK-ASM-ELF +; RUN: llc -function-sections -mtriple=x86_64-unknown-linux-gnu <%t -filetype=obj -o %t2 +; RUN: llvm-objdump --section-headers %t2 | FileCheck %s --check-prefix=CHECK-OBJ +; RUN: llvm-mc -triple=x86_64-unknown-linux-gnu -filetype=asm <%t1 -o %t3 +; RUN: FileCheck %s < %t3 --check-prefixes=CHECK-ASM,CHECK-ASM-ELF +; RUN: llvm-mc -triple=x86_64-unknown-linux-gnu -filetype=obj <%t1 -o %t4 +; RUN: llvm-objdump --section-headers %t4 | FileCheck %s --check-prefix=CHECK-OBJ +; For COFF. +; RUN: llc -function-sections -mtriple=x86_64-unknown-windows-msvc <%t -filetype=asm -o %t1 +; RUN: FileCheck %s < %t1 --check-prefixes=CHECK-ASM,CHECK-ASM-COFF +; RUN: llc -function-sections -mtriple=x86_64-unknown-windows-msvc <%t -filetype=obj -o %t2 +; RUN: llvm-objdump --section-headers %t2 | FileCheck %s --check-prefixes=CHECK-OBJ +; RUN: llvm-mc -triple=x86_64-unknown-windows-msvc -filetype=asm <%t1 -o %t3 +; RUN: FileCheck %s < %t3 --check-prefixes=CHECK-ASM,CHECK-ASM-COFF +; RUN: llvm-mc -triple=x86_64-unknown-windows-msvc -filetype=obj <%t1 -o %t4 +; RUN: llvm-objdump --section-headers %t4 | FileCheck %s --check-prefixes=CHECK-OBJ define dso_local void @foo2() !dbg !7 { @@ -54,21 +64,39 @@ define dso_local i32 @entry() !dbg !14 { ; Check the generation of .pseudo_probe_desc section -; CHECK-ASM: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo2,comdat -; CHECK-ASM-NEXT: .quad [[#GUID1]] -; CHECK-ASM-NEXT: .quad [[#HASH1:]] -; CHECK-ASM-NEXT: .byte 4 -; CHECK-ASM-NEXT: .ascii "foo2" -; CHECK-ASM-NEXT: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo,comdat -; CHECK-ASM-NEXT: .quad [[#GUID2]] -; CHECK-ASM-NEXT: .quad [[#HASH2:]] -; CHECK-ASM-NEXT: .byte 3 -; CHECK-ASM-NEXT: .ascii "foo" -; CHECK-ASM-NEXT: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_entry,comdat -; CHECK-ASM-NEXT: .quad [[#GUID3]] -; CHECK-ASM-NEXT: .quad [[#HASH3:]] -; CHECK-ASM-NEXT: .byte 5 -; CHECK-ASM-NEXT: .ascii "entry" +; CHECK-ASM-ELF: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo2,comdat +; CHECK-ASM-ELF-NEXT: .quad [[#GUID1]] +; CHECK-ASM-ELF-NEXT: .quad [[#HASH1:]] +; CHECK-ASM-ELF-NEXT: .byte 4 +; CHECK-ASM-ELF-NEXT: .ascii "foo2" +; CHECK-ASM-ELF-NEXT: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo,comdat +; CHECK-ASM-ELF-NEXT: .quad [[#GUID2]] +; CHECK-ASM-ELF-NEXT: .quad [[#HASH2:]] +; CHECK-ASM-ELF-NEXT: .byte 3 +; CHECK-ASM-ELF-NEXT: .ascii "foo" +; CHECK-ASM-ELF-NEXT: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_entry,comdat +; CHECK-ASM-ELF-NEXT: .quad [[#GUID3]] +; CHECK-ASM-ELF-NEXT: .quad [[#HASH3:]] +; CHECK-ASM-ELF-NEXT: .byte 5 +; CHECK-ASM-ELF-NEXT: .ascii "entry" +; CHECK-ASM-COFF: .section .pseudo_probe_desc,"drD",same_contents,.pseudo_probe_desc_foo2 +; CHECK-ASM-COFF-NEXT: .pseudo_probe_desc_foo2: +; CHECK-ASM-COFF-NEXT: .quad [[#GUID1]] +; CHECK-ASM-COFF-NEXT: .quad [[#HASH1:]] +; CHECK-ASM-COFF-NEXT: .byte 4 +; CHECK-ASM-COFF-NEXT: .ascii "foo2" +; CHECK-ASM-COFF-NEXT: .section .pseudo_probe_desc,"drD",same_contents,.pseudo_probe_desc_foo +; CHECK-ASM-COFF: .pseudo_probe_desc_foo: +; CHECK-ASM-COFF-NEXT: .quad [[#GUID2]] +; CHECK-ASM-COFF-NEXT: .quad [[#HASH2:]] +; CHECK-ASM-COFF-NEXT: .byte 3 +; CHECK-ASM-COFF-NEXT: .ascii "foo" +; CHECK-ASM-COFF-NEXT: .section .pseudo_probe_desc,"drD",same_contents,.pseudo_probe_desc_entry +; CHECK-ASM-COFF: .pseudo_probe_desc_entry: +; CHECK-ASM-COFF-NEXT: .quad [[#GUID3]] +; CHECK-ASM-COFF-NEXT: .quad [[#HASH3:]] +; CHECK-ASM-COFF-NEXT: .byte 5 +; CHECK-ASM-COFF-NEXT: .ascii "entry" ; CHECK-OBJ: .pseudo_probe_desc ; CHECK-OBJ: .pseudo_probe diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll index 62d3d8255a175..1aa0f65ce3367 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll @@ -1,17 +1,25 @@ -; REQUIRES: x86_64-linux +; REQUIRES: x86-registered-target ; RUN: opt < %s -passes=pseudo-probe -function-sections -S -o %t ; RUN: FileCheck %s < %t --check-prefix=CHECK-IL -; RUN: llc %t -stop-after=pseudo-probe-inserter -o - | FileCheck %s --check-prefix=CHECK-MIR -; RUN: llc %t -function-sections -filetype=asm -o %t1 -; RUN: FileCheck %s < %t1 --check-prefix=CHECK-ASM -; RUN: llc %t -function-sections -filetype=obj -o %t2 -; RUN: llvm-readelf -S -g %t2 | FileCheck %s --check-prefix=CHECK-SEC -; RUN: llvm-mc %t1 -filetype=obj -o %t3 -; RUN: llvm-readelf -S -g %t3 | FileCheck %s --check-prefix=CHECK-SEC +; RUN: llc %t -mtriple=x86_64-- -stop-after=pseudo-probe-inserter -o - | FileCheck %s --check-prefix=CHECK-MIR +; For ELF. +; RUN: llc %t -function-sections -mtriple=x86_64-unknown-linux-gnu -filetype=asm -o %t1 +; RUN: FileCheck %s < %t1 --check-prefixes=CHECK-ASM,CHECK-ASM-ELF +; RUN: llc %t -function-sections -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t2 +; RUN: llvm-readelf -S -g %t2 | FileCheck %s --check-prefix=CHECK-SEC-ELF +; RUN: llvm-mc %t1 -triple=x86_64-unknown-linux-gnu -filetype=obj -o %t3 +; RUN: llvm-readelf -S -g %t3 | FileCheck %s --check-prefix=CHECK-SEC-ELF -; RUN: llc %t -function-sections -unique-section-names=0 -filetype=obj -o %t4 -; RUN: llvm-readelf -S %t4 | FileCheck %s --check-prefix=CHECK-SEC2 +; RUN: llc %t -function-sections -mtriple=x86_64-unknown-linux-gnu -unique-section-names=0 -filetype=obj -o %t4 +; RUN: llvm-readelf -S %t4 | FileCheck %s --check-prefix=CHECK-SEC2-ELF +; For COFF. +; RUN: llc %t -function-sections -mtriple=x86_64-unknown-windows-msvc -filetype=asm -o %t1 +; RUN: FileCheck %s < %t1 --check-prefixes=CHECK-ASM,CHECK-ASM-COFF +; RUN: llc %t -function-sections -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t2 +; RUN: llvm-readobj -Ss %t2 | FileCheck %s --check-prefix=CHECK-SEC-COFF +; RUN: llvm-mc %t1 -triple=x86_64-unknown-windows-msvc -filetype=obj -o %t3 +; RUN: llvm-readobj -Ss %t3 | FileCheck %s --check-prefix=CHECK-SEC-COFF ;; Check the generation of pseudoprobe intrinsic call. @a = dso_local global i32 0, align 4 @@ -93,54 +101,156 @@ entry: ; CHECK-IL: ![[#SCOPE1]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 455082015) ; Check the generation of .pseudo_probe_desc section -; CHECK-ASM: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo,comdat -; CHECK-ASM-NEXT: .quad [[#GUID]] -; CHECK-ASM-NEXT: .quad [[#HASH:]] -; CHECK-ASM-NEXT: .byte 3 -; CHECK-ASM-NEXT: .ascii "foo" -; CHECK-ASM-NEXT: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo2,comdat -; CHECK-ASM-NEXT: .quad [[#GUID2]] -; CHECK-ASM-NEXT: .quad [[#HASH2:]] -; CHECK-ASM-NEXT: .byte 4 -; CHECK-ASM-NEXT: .ascii "foo2" - -; CHECK-SEC: [Nr] Name Type {{.*}} ES Flg Lk Inf Al -; CHECK-SEC: [ 3] .text.foo PROGBITS {{.*}} 00 AX 0 0 16 -; CHECK-SEC: [ 5] .text.foo2 PROGBITS {{.*}} 00 AX 0 0 16 -; CHECK-SEC: [ 8] .text.foo3 PROGBITS {{.*}} 00 AXG 0 0 16 -; CHECK-SEC-COUNT-3: .pseudo_probe_desc PROGBITS -; CHECK-SEC: .pseudo_probe PROGBITS {{.*}} 00 L 3 0 1 -; CHECK-SEC-NEXT: .pseudo_probe PROGBITS {{.*}} 00 L 5 0 1 -; CHECK-SEC-NEXT: .pseudo_probe PROGBITS {{.*}} 00 LG 8 0 1 -; CHECK-SEC-NOT: .rela.pseudo_probe - -; CHECK-SEC: COMDAT group section [ 7] `.group' [foo3] contains 2 sections: -; CHECK-SEC-NEXT: [Index] Name -; CHECK-SEC-NEXT: [ 8] .text.foo3 -; CHECK-SEC-NEXT: [ 21] .pseudo_probe -; CHECK-SEC-EMPTY: -; CHECK-SEC-NEXT: COMDAT group section [ 10] `.group' [.pseudo_probe_desc_foo] contains 1 sections: -; CHECK-SEC-NEXT: [Index] Name -; CHECK-SEC-NEXT: [ 11] .pseudo_probe_desc -; CHECK-SEC-EMPTY: -; CHECK-SEC-NEXT: COMDAT group section [ 12] `.group' [.pseudo_probe_desc_foo2] contains 1 sections: -; CHECK-SEC-NEXT: [Index] Name -; CHECK-SEC-NEXT: [ 13] .pseudo_probe_desc -; CHECK-SEC-EMPTY: -; CHECK-SEC-NEXT: COMDAT group section [ 14] `.group' [.pseudo_probe_desc_foo3] contains 1 sections: -; CHECK-SEC-NEXT: [Index] Name -; CHECK-SEC-NEXT: [ 15] .pseudo_probe_desc - - -; CHECK-SEC2: [Nr] Name Type {{.*}} ES Flg Lk Inf Al -; CHECK-SEC2: [ 3] .text PROGBITS {{.*}} 00 AX 0 0 16 -; CHECK-SEC2: [ 5] .text PROGBITS {{.*}} 00 AX 0 0 16 -; CHECK-SEC2: [ 8] .text PROGBITS {{.*}} 00 AXG 0 0 16 -; CHECK-SEC2-COUNT-3: .pseudo_probe_desc PROGBITS -; CHECK-SEC2: .pseudo_probe PROGBITS {{.*}} 00 L 3 0 1 -; CHECK-SEC2-NEXT: .pseudo_probe PROGBITS {{.*}} 00 L 5 0 1 -; CHECK-SEC2-NEXT: .pseudo_probe PROGBITS {{.*}} 00 LG 8 0 1 -; CHECK-SEC2-NOT: .rela.pseudo_probe +; CHECK-ASM-ELF: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo,comdat +; CHECK-ASM-ELF-NEXT: .quad [[#GUID]] +; CHECK-ASM-ELF-NEXT: .quad [[#HASH:]] +; CHECK-ASM-ELF-NEXT: .byte 3 +; CHECK-ASM-ELF-NEXT: .ascii "foo" +; CHECK-ASM-ELF-NEXT: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo2,comdat +; CHECK-ASM-ELF-NEXT: .quad [[#GUID2]] +; CHECK-ASM-ELF-NEXT: .quad [[#HASH2:]] +; CHECK-ASM-ELF-NEXT: .byte 4 +; CHECK-ASM-ELF-NEXT: .ascii "foo2" +; CHECK-ASM-COFF: .section .pseudo_probe_desc,"drD",same_contents,.pseudo_probe_desc_foo +; CHECK-ASM-COFF-NEXT: .pseudo_probe_desc_foo: +; CHECK-ASM-COFF-NEXT: .quad [[#GUID]] +; CHECK-ASM-COFF-NEXT: .quad [[#HASH:]] +; CHECK-ASM-COFF-NEXT: .byte 3 +; CHECK-ASM-COFF-NEXT: .ascii "foo" +; CHECK-ASM-COFF-NEXT: .section .pseudo_probe_desc,"drD",same_contents,.pseudo_probe_desc_foo2 +; CHECK-ASM-COFF-NEXT: .pseudo_probe_desc_foo2: +; CHECK-ASM-COFF-NEXT: .quad [[#GUID2]] +; CHECK-ASM-COFF-NEXT: .quad [[#HASH2:]] +; CHECK-ASM-COFF-NEXT: .byte 4 +; CHECK-ASM-COFF-NEXT: .ascii "foo2" + +; CHECK-SEC-ELF: [Nr] Name Type {{.*}} ES Flg Lk Inf Al +; CHECK-SEC-ELF: [ 3] .text.foo PROGBITS {{.*}} 00 AX 0 0 16 +; CHECK-SEC-ELF: [ 5] .text.foo2 PROGBITS {{.*}} 00 AX 0 0 16 +; CHECK-SEC-ELF: [ 8] .text.foo3 PROGBITS {{.*}} 00 AXG 0 0 16 +; CHECK-SEC-ELF-COUNT-3: .pseudo_probe_desc PROGBITS +; CHECK-SEC-ELF: .pseudo_probe PROGBITS {{.*}} 00 L 3 0 1 +; CHECK-SEC-ELF-NEXT: .pseudo_probe PROGBITS {{.*}} 00 L 5 0 1 +; CHECK-SEC-ELF-NEXT: .pseudo_probe PROGBITS {{.*}} 00 LG 8 0 1 +; CHECK-SEC-ELF-NOT: .rela.pseudo_probe + +; CHECK-SEC-ELF: COMDAT group section [ 7] `.group' [foo3] contains 2 sections: +; CHECK-SEC-ELF-NEXT: [Index] Name +; CHECK-SEC-ELF-NEXT: [ 8] .text.foo3 +; CHECK-SEC-ELF-NEXT: [ 21] .pseudo_probe +; CHECK-SEC-ELF-EMPTY: +; CHECK-SEC-ELF-NEXT: COMDAT group section [ 10] `.group' [.pseudo_probe_desc_foo] contains 1 sections: +; CHECK-SEC-ELF-NEXT: [Index] Name +; CHECK-SEC-ELF-NEXT: [ 11] .pseudo_probe_desc +; CHECK-SEC-ELF-EMPTY: +; CHECK-SEC-ELF-NEXT: COMDAT group section [ 12] `.group' [.pseudo_probe_desc_foo2] contains 1 sections: +; CHECK-SEC-ELF-NEXT: [Index] Name +; CHECK-SEC-ELF-NEXT: [ 13] .pseudo_probe_desc +; CHECK-SEC-ELF-EMPTY: +; CHECK-SEC-ELF-NEXT: COMDAT group section [ 14] `.group' [.pseudo_probe_desc_foo3] contains 1 sections: +; CHECK-SEC-ELF-NEXT: [Index] Name +; CHECK-SEC-ELF-NEXT: [ 15] .pseudo_probe_desc + +; CHECK-SEC2-ELF: [Nr] Name Type {{.*}} ES Flg Lk Inf Al +; CHECK-SEC2-ELF: [ 3] .text PROGBITS {{.*}} 00 AX 0 0 16 +; CHECK-SEC2-ELF: [ 5] .text PROGBITS {{.*}} 00 AX 0 0 16 +; CHECK-SEC2-ELF: [ 8] .text PROGBITS {{.*}} 00 AXG 0 0 16 +; CHECK-SEC2-ELF-COUNT-3: .pseudo_probe_desc PROGBITS +; CHECK-SEC2-ELF: .pseudo_probe PROGBITS {{.*}} 00 L 3 0 1 +; CHECK-SEC2-ELF-NEXT: .pseudo_probe PROGBITS {{.*}} 00 L 5 0 1 +; CHECK-SEC2-ELF-NEXT: .pseudo_probe PROGBITS {{.*}} 00 LG 8 0 1 +; CHECK-SEC2-ELF-NOT: .rela.pseudo_probe + +; CHECK-SEC-COFF-LABEL: Sections [ +; CHECK-SEC-COFF: Number: 4 +; CHECK-SEC-COFF-NEXT: Name: .text +; CHECK-SEC-COFF: Number: 5 +; CHECK-SEC-COFF-NEXT: Name: .text +; CHECK-SEC-COFF: Number: 6 +; CHECK-SEC-COFF-NEXT: Name: .text +; CHECK-SEC-COFF: Number: 7 +; CHECK-SEC-COFF-NEXT: Name: .pseudo_probe_desc +; CHECK-SEC-COFF: Characteristics [ +; CHECK-SEC-COFF: IMAGE_SCN_CNT_INITIALIZED_DATA +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_LNK_COMDAT +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_DISCARDABLE +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_READ +; CHECK-SEC-COFF: Number: 8 +; CHECK-SEC-COFF-NEXT: Name: .pseudo_probe_desc +; CHECK-SEC-COFF: Characteristics [ +; CHECK-SEC-COFF: IMAGE_SCN_CNT_INITIALIZED_DATA +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_LNK_COMDAT +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_DISCARDABLE +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_READ +; CHECK-SEC-COFF: Number: 9 +; CHECK-SEC-COFF-NEXT: Name: .pseudo_probe_desc +; CHECK-SEC-COFF: Characteristics [ +; CHECK-SEC-COFF: IMAGE_SCN_CNT_INITIALIZED_DATA +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_LNK_COMDAT +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_DISCARDABLE +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_READ +; CHECK-SEC-COFF: Number: 13 +; CHECK-SEC-COFF-NEXT: Name: .pseudo_probe +; CHECK-SEC-COFF: Characteristics [ +; CHECK-SEC-COFF: IMAGE_SCN_CNT_INITIALIZED_DATA +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_LNK_COMDAT +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_DISCARDABLE +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_READ +; CHECK-SEC-COFF: Number: 14 +; CHECK-SEC-COFF-NEXT: Name: .pseudo_probe +; CHECK-SEC-COFF: Characteristics [ +; CHECK-SEC-COFF: IMAGE_SCN_CNT_INITIALIZED_DATA +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_LNK_COMDAT +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_DISCARDABLE +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_READ +; CHECK-SEC-COFF: Number: 15 +; CHECK-SEC-COFF-NEXT: Name: .pseudo_probe +; CHECK-SEC-COFF: Characteristics [ +; CHECK-SEC-COFF: IMAGE_SCN_CNT_INITIALIZED_DATA +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_LNK_COMDAT +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_DISCARDABLE +; CHECK-SEC-COFF-NEXT: IMAGE_SCN_MEM_READ +; COMDAT symbols +; CHECK-SEC-COFF-LABEL: Symbols [ +; CHECK-SEC-COFF: Name: foo +; CHECK-SEC-COFF: Section: .text (4) +; CHECK-SEC-COFF: } +; CHECK-SEC-COFF: Name: foo2 +; CHECK-SEC-COFF: Section: .text (5) +; CHECK-SEC-COFF: } +; CHECK-SEC-COFF: Name: foo3 +; CHECK-SEC-COFF: Section: .text (6) +; CHECK-SEC-COFF: } +; CHECK-SEC-COFF: Name: .pseudo_probe_desc_foo +; CHECK-SEC-COFF: Section: .pseudo_probe_desc (7) +; CHECK-SEC-COFF: StorageClass: Static +; CHECK-SEC-COFF: } +; CHECK-SEC-COFF: Name: .pseudo_probe_desc_foo2 +; CHECK-SEC-COFF: Section: .pseudo_probe_desc (8) +; CHECK-SEC-COFF: StorageClass: Static +; CHECK-SEC-COFF: } +; CHECK-SEC-COFF: Name: .pseudo_probe_desc_foo3 +; CHECK-SEC-COFF: Section: .pseudo_probe_desc (9) +; CHECK-SEC-COFF: StorageClass: Static +; CHECK-SEC-COFF: } +; Section symbols +; CHECK-SEC-COFF: Name: .pseudo_probe +; CHECK-SEC-COFF: Section: .pseudo_probe (13) +; CHECK-SEC-COFF: AuxSectionDef { +; CHECK-SEC-COFF: Selection: Associative +; CHECK-SEC-COFF-NEXT: AssocSection: .text (4) +; CHECK-SEC-COFF: } +; CHECK-SEC-COFF: Name: .pseudo_probe +; CHECK-SEC-COFF: Section: .pseudo_probe (14) +; CHECK-SEC-COFF: AuxSectionDef { +; CHECK-SEC-COFF: Selection: Associative +; CHECK-SEC-COFF-NEXT: AssocSection: .text (5) +; CHECK-SEC-COFF: } +; CHECK-SEC-COFF: Name: .pseudo_probe +; CHECK-SEC-COFF: Section: .pseudo_probe (15) +; CHECK-SEC-COFF: AuxSectionDef { +; CHECK-SEC-COFF: Selection: Associative +; CHECK-SEC-COFF-NEXT: AssocSection: .text (6) !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!9, !10} diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll index df3bc61d02520..b4083f26d9912 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll @@ -11,9 +11,6 @@ ; RUN: opt < %s -passes=pseudo-probe,sample-profile -annotate-sample-profile-inline-phase=true -sample-profile-file=%t2 -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output=%t4.opt.yaml 2>&1 | FileCheck %s ; RUN: FileCheck %s -check-prefixes=YAML,YAML-ANNOTATE < %t4.opt.yaml -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - @factor = dso_local global i32 3, align 4 define dso_local i32 @foo(i32 %x) #0 !dbg !12 { diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-instsched.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-instsched.ll index 569ab3522b141..852f8d2469785 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-instsched.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-instsched.ll @@ -1,5 +1,6 @@ -; REQUIRES: x86_64-linux -; RUN: llc < %s -mcpu=generic -mtriple=x86_64-- -O3 | FileCheck %s +; REQUIRES: x86-registered-target +; RUN: llc < %s -mcpu=generic -mtriple=x86_64-unknown-linux-gnu -O3 | FileCheck %s +; RUN: llc < %s -mcpu=generic -mtriple=x86_64-unknown-windows-msvc -O3 | FileCheck %s define float @foo(float %x) #0 { %tmp1 = fmul float %x, 3.000000e+00 diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll index 03bb64bf06916..632f14d5c2ffc 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll @@ -1,9 +1,6 @@ -; REQUIRES: x86_64-linux +; REQUIRES: x86-registered-target ; RUN: opt < %s -passes=pseudo-probe -S -o - | FileCheck %s -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - $__clang_call_terminate = comdat any @x = dso_local global i32 0, align 4, !dbg !0 diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-missing-probe.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-missing-probe.ll index 3d559f2fb0159..ff64e5bde2f9f 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-missing-probe.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-missing-probe.ll @@ -6,9 +6,6 @@ ; Verify the else branch is not set to a zero count ; CHECK-NOT: [[#PROF]] = !{!"branch_weights", i32 1698, i32 0} -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - @x = dso_local global i32 0, align 4, !dbg !0 ; Function Attrs: nofree noinline norecurse nounwind memory(readwrite, argmem: none) uwtable diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-no-debug-info.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-no-debug-info.ll index 6be3eb868bd2a..e45ddb11c3f41 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-no-debug-info.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-no-debug-info.ll @@ -11,9 +11,6 @@ ; CHECK: call void @llvm.pseudoprobe({{.*}}) -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - @a = common global i32 0, align 4 @b = common global i32 0, align 4 diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-peep.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-peep.ll index 8c007d73e3bb2..a59e74a719549 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-peep.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-peep.ll @@ -1,4 +1,4 @@ -; REQUIRES: x86_64-linux +; REQUIRES: x86-registered-target ; RUN: llc -mtriple=x86_64-- -stop-after=peephole-opt -o - %s | FileCheck %s define internal i32 @arc_compare(i1 %c) { diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-error.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-error.ll index 2bb8f677f40ca..7f07375081594 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-error.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-error.ll @@ -1,4 +1,4 @@ -; REQUIRES: x86_64-linux +; REQUIRES: x86-registered-target ; RUN: not opt < %S/pseudo-probe-profile-mismatch.ll -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-mismatch.prof -min-functions-for-staleness-error=1 -precent-mismatch-for-staleness-error=1 -S 2>&1 | FileCheck %s ; RUN: opt < %S/pseudo-probe-profile-mismatch.ll -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-mismatch.prof -min-functions-for-staleness-error=3 -precent-mismatch-for-staleness-error=70 -S 2>&1 ; RUN: opt < %S/pseudo-probe-profile-mismatch.ll -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-mismatch.prof -min-functions-for-staleness-error=4 -precent-mismatch-for-staleness-error=1 -S 2>&1 diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-thinlto.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-thinlto.ll index 16616c39401b3..9131c571b0b48 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-thinlto.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-thinlto.ll @@ -1,4 +1,4 @@ -; REQUIRES: x86_64-linux +; REQUIRES: x86-registered-target ; RUN: opt < %S/pseudo-probe-stale-profile-matching-lto.ll -passes='thinlto<O2>' -pgo-kind=pgo-sample-use-pipeline --salvage-unused-profile=false -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-matching-lto.prof -report-profile-staleness -persist-profile-staleness -S 2>%t -o %t.ll ; RUN: FileCheck %s --input-file %t ; RUN: FileCheck %s --input-file %t.ll -check-prefix=CHECK-MD diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-selectionDAG.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-selectionDAG.ll index 5d01e78221e38..abb04719010be 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-selectionDAG.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-selectionDAG.ll @@ -1,5 +1,5 @@ -; REQUIRES: x86_64-linux -; RUN: opt < %s -codegenprepare -mtriple=x86_64 -S -o %t +; REQUIRES: x86-registered-target +; RUN: opt < %s -codegenprepare -mtriple=x86_64 -S -o %t ; RUN: FileCheck %s < %t --check-prefix=IR ; RUN: llc -mtriple=x86_64-- -stop-after=finalize-isel %t -o - | FileCheck %s --check-prefix=MIR diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-slotindex.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-slotindex.ll index 4dd5af2bc99c1..969002863a280 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-slotindex.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-slotindex.ll @@ -1,5 +1,6 @@ -; REQUIRES: x86_64-linux -; RUN: llc -print-after=slotindexes -stop-after=slotindexes -mtriple=x86_64-- %s -filetype=asm -o %t 2>&1 | FileCheck %s +; REQUIRES: x86-registered-target +; RUN: llc -print-after=slotindexes -stop-after=slotindexes -mtriple=x86_64-unknown-linux-gnu %s -filetype=asm -o %t 2>&1 | FileCheck %s +; RUN: llc -print-after=slotindexes -stop-after=slotindexes -mtriple=x86_64-unknown-windows-msvc %s -filetype=asm -o %t 2>&1 | FileCheck %s define void @foo(ptr %p) { store i32 0, ptr %p @@ -12,11 +13,11 @@ define void @foo(ptr %p) { ;CHECK: IR Dump {{.*}} ;CHECK: # Machine code for function foo{{.*}} ;CHECK: {{[0-9]+}}B bb.0 (%ir-block.0) -;CHECK: {{[0-9]+}}B %0:gr64 = COPY killed $rdi +;CHECK: {{[0-9]+}}B %0:gr64 = COPY killed $r{{di|cx}} ;CHECK: {{^}} PSEUDO_PROBE 5116412291814990879 ;CHECK: {{[0-9]+}}B MOV32mi ;CHECK: {{[0-9]+}}B RET 0 declare void @llvm.pseudoprobe(i64, i64, i32, i64) #0 -attributes #0 = { inaccessiblememonly nounwind willreturn } \ No newline at end of file +attributes #0 = { inaccessiblememonly nounwind willreturn } diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching-LCS.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching-LCS.ll index c0976dea3c580..cda66b1ecf6d2 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching-LCS.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching-LCS.ll @@ -1,5 +1,4 @@ -; REQUIRES: x86_64-linux -; REQUIRES: asserts +; REQUIRES: asserts && x86-registered-target ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-matching-LCS.prof --salvage-stale-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl 2>&1 | FileCheck %s ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-matching-LCS.prof --salvage-stale-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl --salvage-stale-profile-max-callsites=6 2>&1 | FileCheck %s -check-prefix=CHECK-MAX-CALLSITES @@ -31,9 +30,6 @@ ; CHECK-MAX-CALLSITES: Skip stale profile matching for test_direct_call ; CHECK-MAX-CALLSITES-NOT: Skip stale profile matching for test_indirect_call -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - @c = external global i32, align 4 ; Function Attrs: nounwind uwtable diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching-lto.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching-lto.ll index 7aabeeca2585b..f58dc75490194 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching-lto.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching-lto.ll @@ -1,5 +1,4 @@ -; REQUIRES: x86_64-linux -; REQUIRES: asserts +; REQUIRES: asserts && x86-registered-target ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-matching-lto.prof --salvage-stale-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl 2>&1 | FileCheck %s @@ -22,9 +21,6 @@ ; CHECK: Callsite with callee:bar is matched from 15 to 9 -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - @x = internal global i32 1, align 4, !dbg !0 ; Function Attrs: nounwind uwtable diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching.ll index 0c38d9cad4520..02c8a8cd6f827 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching.ll @@ -1,5 +1,4 @@ -; REQUIRES: x86_64-linux -; REQUIRES: asserts +; REQUIRES: asserts && x86-registered-target ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-matching.prof --salvage-stale-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl 2>&1 | FileCheck %s ; The profiled source code: @@ -101,9 +100,6 @@ ; CHECK: 1: call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 1, i32 0, i64 -1), !dbg ![[#]] - weight: 0 - factor: 1.00) -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - @x = dso_local global i32 1, align 4, !dbg !0 ; Function Attrs: noinline nounwind uwtable diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming-recursive.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming-recursive.ll index e246d260c60e0..69e9bce2ceb0e 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming-recursive.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming-recursive.ll @@ -1,5 +1,4 @@ -; REQUIRES: x86_64-linux -; REQUIRES: asserts +; REQUIRES: asserts && x86-registered-target ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-renaming-recursive.prof --salvage-stale-profile --salvage-unused-profile -report-profile-staleness -persist-profile-staleness -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline --min-call-count-for-cg-matching=0 --min-func-count-for-cg-matching=0 2>&1 | FileCheck %s ; CHECK: Run stale profile matching for main @@ -18,9 +17,6 @@ -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - @x = dso_local global i32 0, align 4, !dbg !0 ; Function Attrs: nounwind uwtable diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming.ll index d1c5a9d9bc2a3..f7d51d02327d4 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming.ll @@ -1,5 +1,4 @@ -; REQUIRES: x86_64-linux -; REQUIRES: asserts +; REQUIRES: asserts && x86-registered-target ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-renaming.prof --salvage-stale-profile --salvage-unused-profile -report-profile-staleness -persist-profile-staleness -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline --min-call-count-for-cg-matching=0 --min-func-count-for-cg-matching=0 --func-profile-similarity-threshold=70 2>&1 | FileCheck %s ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-renaming.prof --salvage-stale-profile --salvage-unused-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl --min-call-count-for-cg-matching=10 --min-func-count-for-cg-matching=10 2>&1 | FileCheck %s --check-prefix=TINY-FUNC @@ -31,9 +30,6 @@ ; TINY-FUNC-NOT: Function:new_block_only matches profile:block_only -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - @x = dso_local global i32 0, align 4, !dbg !0 ; Function Attrs: noinline nounwind uwtable diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll index 2ed187227e186..15a19477f7509 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll @@ -1,5 +1,4 @@ -; REQUIRES: x86_64-linux -; REQUIRES: asserts +; REQUIRES: asserts && x86-registered-target ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-toplev-func.prof --salvage-stale-profile --salvage-unused-profile -report-profile-staleness -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline --min-call-count-for-cg-matching=0 --min-func-count-for-cg-matching=0 --load-func-profile-for-cg-matching 2>&1 | FileCheck %s -check-prefix=CHECK-TEXT ; RUN: llvm-profdata merge --sample %S/Inputs/pseudo-probe-stale-profile-toplev-func.prof -extbinary -o %t.extbinary ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.extbinary --salvage-stale-profile --salvage-unused-profile -report-profile-staleness -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline --min-call-count-for-cg-matching=0 --min-func-count-for-cg-matching=0 --load-func-profile-for-cg-matching 2>&1 | FileCheck %s -check-prefix=CHECK-EXTBIN @@ -30,9 +29,6 @@ ; CHECK-EXTBIN: 2: %call = call i32 @bar(i32 noundef %0), !dbg ![[#]] - weight: 452674 -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - @x = dso_local global i32 0, align 4, !dbg !0 ; Function Attrs: noinline nounwind uwtable diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-twoaddr.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-twoaddr.ll index 4a3e21c6d4e1a..3570a7cc18518 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-twoaddr.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-twoaddr.ll @@ -1,4 +1,4 @@ -; REQUIRES: x86_64-linux +; REQUIRES: x86-registered-target ; RUN: llc -stop-after=twoaddressinstruction -mtriple=x86_64-- -o - %s | FileCheck %s diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll index dccd37e9de99d..c42133394910b 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll @@ -1,4 +1,4 @@ -; REQUIRES: x86_64-linux +; REQUIRES: x86-registered-target ; RUN: opt < %s -passes='pseudo-probe,loop-unroll-full' -verify-pseudo-probe -S -o %t 2>&1 | FileCheck %s --check-prefix=VERIFY ; RUN: FileCheck %s < %t _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits