[clang] [llvm] [PseudoProbe] Support emitting to COFF object (PR #123870)

Haohai Wen via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 05:55:25 PST 2025


https://github.com/HaohaiWen updated https://github.com/llvm/llvm-project/pull/123870

>From 7c531922f20bf284a5cd83b20e94cb624ef031d2 Mon Sep 17 00:00:00 2001
From: Haohai Wen <haohai.wen at intel.com>
Date: Thu, 9 Jan 2025 15:29:33 +0800
Subject: [PATCH 1/3] [COFF] Preserve UniqueID used to create MCSectionCOFF

This UniqueID can be used later to create associative section.
e.g. A .pseudo_probe associated to the section of the corresponding
function.
---
 llvm/include/llvm/MC/MCSectionCOFF.h | 9 +++++++--
 llvm/lib/MC/MCContext.cpp            | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/MC/MCSectionCOFF.h b/llvm/include/llvm/MC/MCSectionCOFF.h
index 97540d985dbd1d..9c79c27f2a9152 100644
--- a/llvm/include/llvm/MC/MCSectionCOFF.h
+++ b/llvm/include/llvm/MC/MCSectionCOFF.h
@@ -47,16 +47,19 @@ class MCSectionCOFF final : public MCSection {
   /// section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0
   mutable int Selection;
 
+  unsigned UniqueID;
+
 private:
   friend class MCContext;
   // The storage of Name is owned by MCContext's COFFUniquingMap.
   MCSectionCOFF(StringRef Name, unsigned Characteristics,
-                MCSymbol *COMDATSymbol, int Selection, MCSymbol *Begin)
+                MCSymbol *COMDATSymbol, int Selection, unsigned UniqueID,
+                MCSymbol *Begin)
       : MCSection(SV_COFF, Name, Characteristics & COFF::IMAGE_SCN_CNT_CODE,
                   Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA,
                   Begin),
         Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
-        Selection(Selection) {
+        Selection(Selection), UniqueID(UniqueID) {
     assert((Characteristics & 0x00F00000) == 0 &&
            "alignment must not be set upon section creation");
   }
@@ -72,6 +75,8 @@ class MCSectionCOFF final : public MCSection {
 
   void setSelection(int Selection) const;
 
+  unsigned getUniqueID() const { return UniqueID; }
+
   void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
                             raw_ostream &OS,
                             uint32_t Subsection) const override;
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 46222fcaa5b152..56aba5de4445e4 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -718,7 +718,7 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
   StringRef CachedName = Iter->first.SectionName;
   MCSymbol *Begin = getOrCreateSectionSymbol<MCSymbolCOFF>(Section);
   MCSectionCOFF *Result = new (COFFAllocator.Allocate()) MCSectionCOFF(
-      CachedName, Characteristics, COMDATSymbol, Selection, Begin);
+      CachedName, Characteristics, COMDATSymbol, Selection, UniqueID, Begin);
   Iter->second = Result;
   auto *F = allocInitialFragment(*Result);
   Begin->setFragment(F);

>From 5c201436acb13e3d0893893eabd6e128ccdff346 Mon Sep 17 00:00:00 2001
From: Haohai Wen <haohai.wen at intel.com>
Date: Tue, 21 Jan 2025 11:44:50 +0800
Subject: [PATCH 2/3] [PseudoProbe] Support emitting to COFF object

Support emitting pseudo probe to .pseudo_probe and .pseudo_probe_desc
COFF sections.
---
 clang/include/clang/Driver/Options.td         |   2 +-
 clang/test/Driver/cl-options.c                |   1 +
 .../llvm/Target/TargetLoweringObjectFile.h    |   3 +
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  |  24 +-
 llvm/lib/MC/MCAsmStreamer.cpp                 |   3 +-
 llvm/lib/MC/MCContext.cpp                     |   8 +
 llvm/lib/MC/MCObjectFileInfo.cpp              |  81 ++++--
 llvm/lib/Target/TargetLoweringObjectFile.cpp  |  27 ++
 .../pseudo-probe-callee-profile-mismatch.ll   |   4 +-
 .../SampleProfile/pseudo-probe-dangle.ll      |   2 +-
 .../SampleProfile/pseudo-probe-dangle2.ll     |   2 +-
 .../SampleProfile/pseudo-probe-desc-guid.ll   |   2 +-
 .../SampleProfile/pseudo-probe-eh.ll          |   2 +-
 .../SampleProfile/pseudo-probe-emit-inline.ll |  73 ++++--
 .../SampleProfile/pseudo-probe-emit.ll        | 233 +++++++++++++-----
 .../SampleProfile/pseudo-probe-icp-factor.ll  |   2 +-
 .../SampleProfile/pseudo-probe-inline.ll      |   2 +-
 .../SampleProfile/pseudo-probe-instsched.ll   |   2 +-
 .../SampleProfile/pseudo-probe-invoke.ll      |   4 +-
 .../pseudo-probe-missing-probe.ll             |   2 +-
 .../pseudo-probe-no-debug-info.ll             |   2 +-
 .../SampleProfile/pseudo-probe-peep.ll        |   2 +-
 .../pseudo-probe-profile-mismatch-error.ll    |   2 +-
 .../pseudo-probe-profile-mismatch-thinlto.ll  |   2 +-
 .../pseudo-probe-profile-mismatch.ll          |   4 +-
 .../pseudo-probe-selectionDAG.ll              |   2 +-
 .../SampleProfile/pseudo-probe-slotindex.ll   |   4 +-
 ...pseudo-probe-stale-profile-matching-LCS.ll |   4 +-
 ...pseudo-probe-stale-profile-matching-lto.ll |   4 +-
 .../pseudo-probe-stale-profile-matching.ll    |   4 +-
 ...-probe-stale-profile-renaming-recursive.ll |   4 +-
 .../pseudo-probe-stale-profile-renaming.ll    |   4 +-
 .../pseudo-probe-stale-profile-toplev-func.ll |   4 +-
 .../SampleProfile/pseudo-probe-twoaddr.ll     |   2 +-
 .../SampleProfile/pseudo-probe-verify.ll      |   2 +-
 35 files changed, 363 insertions(+), 162 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index d38dd2b4e3cf09..dd051eb1e3f328 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1890,7 +1890,7 @@ defm pseudo_probe_for_profiling : BoolFOption<"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 forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">,
     Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption]>,
diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 29a0fcbc17ac60..f298716a0b1449 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -720,6 +720,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 4864ba843f4886..83cd9b23046cef 100644
--- a/llvm/include/llvm/Target/TargetLoweringObjectFile.h
+++ b/llvm/include/llvm/Target/TargetLoweringObjectFile.h
@@ -91,6 +91,9 @@ class TargetLoweringObjectFile : public MCObjectFileInfo {
   /// Emit Call Graph Profile metadata.
   void emitCGProfileMetadata(MCStreamer &Streamer, Module &M) const;
 
+  /// Emit pseudo_probe_desc metadata.
+  void emitPseudoProbeDescMetadata(MCStreamer &Streamer, Module &M) const;
+
   /// Get the module-level metadata that the platform cares about.
   virtual void getModuleMetadata(Module &M) {}
 
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index be243c0e74e9db..e51531b5219bc8 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -335,28 +335,7 @@ void TargetLoweringObjectFileELF::emitModuleMetadata(MCStreamer &Streamer,
     }
   }
 
-  if (NamedMDNode *FuncInfo = M.getNamedMetadata(PseudoProbeDescMetadataName)) {
-    // Emit a descriptor for every function including functions that have an
-    // available external linkage. We may not want this for imported functions
-    // that has code in another thinLTO module but we don't have a good way to
-    // tell them apart from inline functions defined in header files. Therefore
-    // we put each descriptor in a separate comdat section and rely on the
-    // linker to deduplicate.
-    for (const auto *Operand : FuncInfo->operands()) {
-      const auto *MD = cast<MDNode>(Operand);
-      auto *GUID = mdconst::dyn_extract<ConstantInt>(MD->getOperand(0));
-      auto *Hash = mdconst::dyn_extract<ConstantInt>(MD->getOperand(1));
-      auto *Name = cast<MDString>(MD->getOperand(2));
-      auto *S = C.getObjectFileInfo()->getPseudoProbeDescSection(
-          TM->getFunctionSections() ? Name->getString() : StringRef());
-
-      Streamer.switchSection(S);
-      Streamer.emitInt64(GUID->getZExtValue());
-      Streamer.emitInt64(Hash->getZExtValue());
-      Streamer.emitULEB128IntValue(Name->getString().size());
-      Streamer.emitBytes(Name->getString());
-    }
-  }
+  emitPseudoProbeDescMetadata(Streamer, M);
 
   if (NamedMDNode *LLVMStats = M.getNamedMetadata("llvm.stats")) {
     // Emit the metadata for llvm statistics into .llvm_stats section, which is
@@ -1864,6 +1843,7 @@ void TargetLoweringObjectFileCOFF::emitModuleMetadata(MCStreamer &Streamer,
   }
 
   emitCGProfileMetadata(Streamer, M);
+  emitPseudoProbeDescMetadata(Streamer, M);
 }
 
 void TargetLoweringObjectFileCOFF::emitLinkerDirectives(
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index dd8058c6d5cd80..f691e204cf7bb9 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -2492,7 +2492,8 @@ void MCAsmStreamer::emitPseudoProbe(uint64_t Guid, uint64_t Index,
   for (const auto &Site : InlineStack)
     OS << " @ " << std::get<0>(Site) << ":" << std::get<1>(Site);
 
-  OS << " " << FnSym->getName();
+  OS << " ";
+  FnSym->print(OS, MAI);
 
   EmitEOL();
 }
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 56aba5de4445e4..1353ddc07e7f8f 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -23,6 +23,7 @@
 #include "llvm/MC/MCFragment.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCLabel.h"
+#include "llvm/MC/MCObjectFileInfo.h"
 #include "llvm/MC/MCSectionCOFF.h"
 #include "llvm/MC/MCSectionDXContainer.h"
 #include "llvm/MC/MCSectionELF.h"
@@ -722,6 +723,13 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
   Iter->second = Result;
   auto *F = allocInitialFragment(*Result);
   Begin->setFragment(F);
+  // Normally the comdat symbol is function begin label and will be set a
+  // fragment in emitLabel. It is not hold for a pseudo_probe_desc comdat
+  // symbol, so we need to set its fragment here.
+  if (COMDATSymbol && !COMDATSymbol->getFragment() &&
+      Section == MOFI->getPseudoProbeDescSection("")->getName()) {
+    COMDATSymbol->setFragment(F);
+  }
   return Result;
 }
 
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index 150e38a94db6a6..f847a9dc076527 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -792,6 +792,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) {
@@ -1141,41 +1151,68 @@ MCObjectFileInfo::getKCFITrapSection(const MCSection &TextSec) const {
 
 MCSection *
 MCObjectFileInfo::getPseudoProbeSection(const MCSection &TextSec) const {
-  if (Ctx->getObjectFileType() != MCContext::IsELF)
-    return PseudoProbeSection;
+  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;
+    }
 
-  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(),
+                              cast<MCSymbolELF>(TextSec.getBeginSymbol()));
+  } else if (ObjFileType == MCContext::IsCOFF) {
+    StringRef COMDATSymName = "";
+    int Selection = 0;
+    unsigned Characteristics =
+        COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE |
+        COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_LNK_COMDAT;
+    auto &COFFSec = cast<MCSectionCOFF>(TextSec);
+    if (const MCSymbol *COMDATSym = COFFSec.getCOMDATSymbol()) {
+      // Associate .pseudo_probe to its function section.
+      COMDATSymName = COMDATSym->getName();
+      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(),
-                            cast<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 different
-    // 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()) {
+  // Create a separate comdat group for each function's descriptor in order
+  // for the linker to deduplicate. The duplication, must be from different
+  // 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 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) {
+      unsigned Characteristics = COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
+                                 COFF::IMAGE_SCN_MEM_DISCARDABLE |
+                                 COFF::IMAGE_SCN_MEM_READ |
+                                 COFF::IMAGE_SCN_LNK_COMDAT;
+      auto *S = cast<MCSectionCOFF>(PseudoProbeDescSection);
+      std::string COMDATSymName = (S->getName() + "_" + FuncName).str();
+      return Ctx->getCOFFSection(S->getName(), Characteristics, COMDATSymName,
+                                 COFF::IMAGE_COMDAT_SELECT_ANY);
     }
   }
   return PseudoProbeDescSection;
diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp
index 4fe9d13d062265..9cb659f803a23c 100644
--- a/llvm/lib/Target/TargetLoweringObjectFile.cpp
+++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp
@@ -192,6 +192,33 @@ void TargetLoweringObjectFile::emitCGProfileMetadata(MCStreamer &Streamer,
   }
 }
 
+void TargetLoweringObjectFile::emitPseudoProbeDescMetadata(MCStreamer &Streamer,
+                                                           Module &M) const {
+  if (NamedMDNode *FuncInfo = M.getNamedMetadata(PseudoProbeDescMetadataName)) {
+    // Emit a descriptor for every function including functions that have an
+    // available external linkage. We may not want this for imported functions
+    // that has code in another thinLTO module but we don't have a good way to
+    // tell them apart from inline functions defined in header files. Therefore
+    // we put each descriptor in a separate comdat section and rely on the
+    // linker to deduplicate.
+    auto &C = getContext();
+    for (const auto *Operand : FuncInfo->operands()) {
+      const auto *MD = cast<MDNode>(Operand);
+      auto *GUID = mdconst::dyn_extract<ConstantInt>(MD->getOperand(0));
+      auto *Hash = mdconst::dyn_extract<ConstantInt>(MD->getOperand(1));
+      auto *Name = cast<MDString>(MD->getOperand(2));
+      auto *S = C.getObjectFileInfo()->getPseudoProbeDescSection(
+          TM->getFunctionSections() ? Name->getString() : StringRef());
+
+      Streamer.switchSection(S);
+      Streamer.emitInt64(GUID->getZExtValue());
+      Streamer.emitInt64(Hash->getZExtValue());
+      Streamer.emitULEB128IntValue(Name->getString().size());
+      Streamer.emitBytes(Name->getString());
+    }
+  }
+}
+
 /// getKindForGlobal - This is a top-level target-independent classifier for
 /// a global object.  Given a global variable and information from the TM, this
 /// function classifies the global in a target independent manner. This function
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 43be142e7cf98f..c8ce29928930d1 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-callee-profile-mismatch.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-callee-profile-mismatch.ll
@@ -1,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; REQUIRES: asserts
 ; 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 -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl  -pass-remarks=inline 2>&1 | FileCheck %s
 
@@ -14,7 +14,7 @@
 
 
 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"
+target triple = "x86_64-unknown--"
 
 define available_externally i32 @main() #0 {
   %1 = call i32 @bar(), !dbg !13
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle.ll
index f0b6fdf62d9696..fb6056cb87aece 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle.ll
@@ -1,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; 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
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle2.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-dangle2.ll
index b9cb3273728444..a156277a096684 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: target={{x86_64-.*-(linux|windows).*}}
 ; 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 68bf54f2ebd79c..85de7475c61f37 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: target={{x86_64-.*-(linux|windows).*}}
 ; 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-eh.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-eh.ll
index 9954914bca4380..0d21c85233e9ff 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-eh.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-eh.ll
@@ -1,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; RUN: opt < %s -passes=pseudo-probe -function-sections -S -o - | FileCheck %s
 
 ;; Check the generation of pseudoprobe intrinsic call for non-EH blocks only.
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll
index 0bde361018f7d2..587372446f37e9 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
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; RUN: opt < %s -passes='pseudo-probe,cgscc(inline)' -function-sections -mtriple=x86_64-unknown-linux-gnu -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--linux <%t -filetype=asm -o %t1
+; RUN: FileCheck %s < %t1 --check-prefixes=CHECK-ASM,CHECK-ASM-ELF
+; RUN: llc -function-sections -mtriple=x86_64--linux <%t -filetype=obj -o %t2
+; RUN: llvm-objdump --section-headers %t2 | FileCheck %s --check-prefix=CHECK-OBJ
+; RUN: llvm-mc -triple=x86_64--linux -filetype=asm <%t1 -o %t3
+; RUN: FileCheck %s < %t3 --check-prefixes=CHECK-ASM,CHECK-ASM-ELF
+; RUN: llvm-mc -triple=x86_64--linux -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--windows <%t -filetype=asm -o %t1
+; RUN: FileCheck %s < %t1 --check-prefixes=CHECK-ASM,CHECK-ASM-COFF
+; RUN: llc -function-sections -mtriple=x86_64--windows <%t -filetype=obj -o %t2
+; RUN: llvm-objdump --section-headers %t2 | FileCheck %s --check-prefixes=CHECK-OBJ
+; RUN: llvm-mc -triple=x86_64--windows -filetype=asm <%t1 -o %t3
+; RUN: FileCheck %s < %t3 --check-prefixes=CHECK-ASM,CHECK-ASM-COFF
+; RUN: llvm-mc -triple=x86_64--windows -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,36 @@ define dso_local i32 @entry() !dbg !14 {
 
 
 ; Check the generation of .pseudo_probe_desc section
-; CHECK-ASM: .section .pseudo_probe_desc,"G", at 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", at 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", at 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", at 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", at 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", at 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",discard,.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",discard,.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",discard,.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 62d3d8255a1757..293aceb8a2f3a2 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
@@ -1,17 +1,28 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; 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
+; For ELF.
+; RUN: llc %t -function-sections -mtriple=x86_64--linux -filetype=asm -o %t1
+; RUN: FileCheck %s < %t1 --check-prefixes=CHECK-ASM,CHECK-ASM-ELF
+; RUN: llc %t -function-sections -mtriple=x86_64--linux -filetype=obj -o %t2
+; RUN: llvm-readelf -S -g %t2 | FileCheck %s --check-prefix=CHECK-SEC-ELF
+; RUN: llvm-mc %t1 -triple=x86_64--linux -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--linux -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--windows -filetype=asm -o %t1
+; RUN: FileCheck %s < %t1 --check-prefixes=CHECK-ASM,CHECK-ASM-COFF
+; RUN: llc %t -function-sections -mtriple=x86_64--windows -filetype=obj -o %t2
+; RUN: llvm-readobj -Ss %t2 | FileCheck %s --check-prefix=CHECK-SEC-COFF
+; RUN: llvm-mc %t1 -triple=x86_64--windows -filetype=obj -o %t3
+; RUN: llvm-readobj -Ss %t3 | FileCheck %s --check-prefix=CHECK-SEC-COFF
+
+; RUN: llc %t -function-sections -mtriple=x86_64--windows -unique-section-names=0 -filetype=obj -o %t4
+; RUN: llvm-readobj -Ss %t4 | FileCheck %s --check-prefix=CHECK-SEC-COFF
 ;; Check the generation of pseudoprobe intrinsic call.
 
 @a = dso_local global i32 0, align 4
@@ -93,54 +104,162 @@ entry:
 ; CHECK-IL: ![[#SCOPE1]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 455082015)
 
 ; Check the generation of .pseudo_probe_desc section
-; CHECK-ASM: .section .pseudo_probe_desc,"G", at 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", at 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", at 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", at 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",discard,.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",discard,.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-COUNT-4: Section {
+; CHECK-SEC-COFF-NEXT:      Number: 4
+; CHECK-SEC-COFF-NEXT:      Name: .text (2E 74 65 78 74 00 00 00)
+; CHECK-SEC-COFF:         Section {
+; CHECK-SEC-COFF-NEXT:      Number: 5
+; CHECK-SEC-COFF-NEXT:      Name: .text (2E 74 65 78 74 00 00 00)
+; CHECK-SEC-COFF:         Section {
+; CHECK-SEC-COFF-NEXT:      Number: 6
+; CHECK-SEC-COFF-NEXT:      Name: .text (2E 74 65 78 74 00 00 00)
+; CHECK-SEC-COFF:         Section {
+; CHECK-SEC-COFF-NEXT:      Number: 7
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe_desc (2F 34 31 00 00 00 00 00)
+; CHECK-SEC-COFF:           Characteristics [ (0x42101040)
+; CHECK-SEC-COFF:             IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_LNK_COMDAT (0x1000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_DISCARDABLE (0x2000000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_READ (0x40000000)
+; CHECK-SEC-COFF:         Section {
+; CHECK-SEC-COFF-NEXT:      Number: 8
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe_desc (2F 34 31 00 00 00 00 00)
+; CHECK-SEC-COFF:           Characteristics [ (0x42101040)
+; CHECK-SEC-COFF:             IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_LNK_COMDAT (0x1000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_DISCARDABLE (0x2000000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_READ (0x40000000)
+; CHECK-SEC-COFF:         Section {
+; CHECK-SEC-COFF-NEXT:      Number: 9
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe_desc (2F 34 31 00 00 00 00 00)
+; CHECK-SEC-COFF:           Characteristics [ (0x42101040)
+; CHECK-SEC-COFF:             IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_LNK_COMDAT (0x1000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_DISCARDABLE (0x2000000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_READ (0x40000000)
+; CHECK-SEC-COFF-COUNT-3: Section {
+; CHECK-SEC-COFF-NEXT:      Number: 12
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe (2F 32 37 00 00 00 00 00)
+; CHECK-SEC-COFF:           Characteristics [ (0x42101040)
+; CHECK-SEC-COFF:             IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_LNK_COMDAT (0x1000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_DISCARDABLE (0x2000000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_READ (0x40000000)
+; CHECK-SEC-COFF:         Section {
+; CHECK-SEC-COFF-NEXT:      Number: 13
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe (2F 32 37 00 00 00 00 00)
+; CHECK-SEC-COFF:           Characteristics [ (0x42101040)
+; CHECK-SEC-COFF:             IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_LNK_COMDAT (0x1000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_DISCARDABLE (0x2000000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_READ (0x40000000)
+; CHECK-SEC-COFF:         Section {
+; CHECK-SEC-COFF-NEXT:      Number: 14
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe (2F 32 37 00 00 00 00 00)
+; CHECK-SEC-COFF:           Characteristics [ (0x42101040)
+; CHECK-SEC-COFF:             IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_LNK_COMDAT (0x1000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_DISCARDABLE (0x2000000)
+; CHECK-SEC-COFF-NEXT:        IMAGE_SCN_MEM_READ (0x40000000)
+; COMDAT symbols
+; CHECK-SEC-COFF-COUNT-5: Symbol {
+; CHECK-SEC-COFF-NEXT:      Name: foo
+; CHECK-SEC-COFF:           Section: .text (4)
+; CHECK-SEC-COFF-COUNT-2: Symbol {
+; CHECK-SEC-COFF-NEXT:      Name: foo2
+; CHECK-SEC-COFF:           Section: .text (5)
+; CHECK-SEC-COFF-COUNT-3: Symbol {
+; CHECK-SEC-COFF-NEXT:      Name: foo3
+; CHECK-SEC-COFF:           Section: .text (6)
+; CHECK-SEC-COFF-COUNT-2: Symbol {
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe_desc_foo
+; CHECK-SEC-COFF:           Section: .pseudo_probe_desc (7)
+; CHECK-SEC-COFF:           StorageClass: Static (0x3)
+; CHECK-SEC-COFF-COUNT-2: Symbol {
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe_desc_foo2
+; CHECK-SEC-COFF:           Section: .pseudo_probe_desc (8)
+; CHECK-SEC-COFF:           StorageClass: Static (0x3)
+; CHECK-SEC-COFF-COUNT-2: Symbol {
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe_desc_foo3
+; CHECK-SEC-COFF:           Section: .pseudo_probe_desc (9)
+; CHECK-SEC-COFF:           StorageClass: Static (0x3)
+; Section symbols
+; CHECK-SEC-COFF-COUNT-2: Symbol {
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe
+; CHECK-SEC-COFF:           Section: .pseudo_probe (12)
+; CHECK-SEC-COFF:           AuxSectionDef {
+; CHECK-SEC-COFF:             Selection: Associative (0x5)
+; CHECK-SEC-COFF-NEXT:        AssocSection: .text (4)
+; CHECK-SEC-COFF:         Symbol {
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe
+; CHECK-SEC-COFF:           Section: .pseudo_probe (13)
+; CHECK-SEC-COFF:           AuxSectionDef {
+; CHECK-SEC-COFF:             Selection: Associative (0x5)
+; CHECK-SEC-COFF-NEXT:        AssocSection: .text (5)
+; CHECK-SEC-COFF:         Symbol {
+; CHECK-SEC-COFF-NEXT:      Name: .pseudo_probe
+; CHECK-SEC-COFF:           Section: .pseudo_probe (14)
+; CHECK-SEC-COFF:           AuxSectionDef {
+; CHECK-SEC-COFF:             Selection: Associative (0x5)
+; 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-icp-factor.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-icp-factor.ll
index b662efab9b2f2f..b39fb40150005e 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-icp-factor.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-icp-factor.ll
@@ -1,7 +1,7 @@
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-icp-factor.prof -S -sample-profile-prioritized-inline=1 2>&1 | FileCheck %s
 
 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"
+target triple = "x86_64-unknown--"
 
 @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
 
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll
index df3bc61d025202..a597d74f034a06 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll
@@ -12,7 +12,7 @@
 ; 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"
+target triple = "x86_64-unknown--"
 
 @factor = dso_local global i32 3, align 4
 
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-instsched.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-instsched.ll
index 569ab3522b1411..02326ee7d798e5 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-instsched.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-instsched.ll
@@ -1,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-- -O3 | FileCheck %s
 
 define float @foo(float %x) #0 {
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll
index 03bb64bf06916f..484b1388aeaff1 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll
@@ -1,8 +1,8 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; 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"
+target triple = "x86_64-unknown--"
 
 $__clang_call_terminate = comdat any
 
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-missing-probe.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-missing-probe.ll
index 3d559f2fb0159a..174f6994e360e4 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-missing-probe.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-missing-probe.ll
@@ -7,7 +7,7 @@
 ; 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"
+target triple = "x86_64-unknown--"
 
 @x = dso_local global i32 0, align 4, !dbg !0
 
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 6be3eb868bd2aa..9fefd990eae897 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-no-debug-info.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-no-debug-info.ll
@@ -12,7 +12,7 @@
 
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
+target triple = "x86_64-unknown--"
 
 @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 8c007d73e3bb26..8ad405cd08f30c 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: target={{x86_64-.*-(linux|windows).*}}
 ; 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 2bb8f677f40ca8..33638622cdf82c 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: target={{x86_64-.*-(linux|windows).*}}
 ; 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 bf33df2481044b..043fb5301b90e6 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: target={{x86_64-.*-(linux|windows).*}}
 ; RUN: opt < %S/pseudo-probe-stale-profile-matching-lto.ll -passes='thinlto<O2>' -pgo-kind=pgo-sample-use-pipeline -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-profile-mismatch.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll
index 6efd9f511e1372..2228bb81dd8c35 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll
@@ -1,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-mismatch.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
@@ -61,7 +61,7 @@
 
 
 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"
+target triple = "x86_64-unknown--"
 
 @x = dso_local global i32 0, align 4, !dbg !0
 
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-selectionDAG.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-selectionDAG.ll
index 5d01e78221e38d..34220a5eb59918 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-selectionDAG.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-selectionDAG.ll
@@ -1,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; 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 4dd5af2bc99c19..c4e30071ffbeda 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-slotindex.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-slotindex.ll
@@ -1,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; RUN: llc -print-after=slotindexes -stop-after=slotindexes -mtriple=x86_64-- %s -filetype=asm -o %t 2>&1 | FileCheck %s
 
 define void @foo(ptr %p) {
@@ -19,4 +19,4 @@ define void @foo(ptr %p) {
 
 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 cdd365b6fb6730..37217e021d0bcd 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,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; REQUIRES: asserts
 ; 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
@@ -32,7 +32,7 @@
 ; 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"
+target triple = "x86_64-unknown--"
 
 @c = external global i32, align 4
 
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 7aabeeca2585b6..120c4c9774bb6e 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,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; REQUIRES: asserts
 ; 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
 
@@ -23,7 +23,7 @@
 
 
 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"
+target triple = "x86_64-unknown--"
 
 @x = internal global i32 1, align 4, !dbg !0
 
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 20be0c2fec7f2a..a0a9c067cf4cb9 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching.ll
@@ -1,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; REQUIRES: asserts
 ; 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
 
@@ -102,7 +102,7 @@
 
 
 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"
+target triple = "x86_64-unknown--"
 
 @x = dso_local global i32 1, align 4, !dbg !0
 
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 d9db804b563644..8fa48808b8dd4d 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,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; REQUIRES: asserts
 ; 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
 
@@ -19,7 +19,7 @@
 
 
 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"
+target triple = "x86_64-unknown--"
 
 @x = dso_local global i32 0, align 4, !dbg !0
 
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 a549812f46ef6b..baf4f0aae65478 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming.ll
@@ -1,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; REQUIRES: asserts
 ; 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 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
@@ -32,7 +32,7 @@
 
 
 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"
+target triple = "x86_64-unknown--"
 
 @x = dso_local global i32 0, align 4, !dbg !0
 
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 c839364f235536..c7a2bcdda22abb 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,4 +1,4 @@
-; REQUIRES: x86_64-linux
+; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; REQUIRES: asserts
 ; 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
@@ -31,7 +31,7 @@
 
 
 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"
+target triple = "x86_64-unknown--"
 
 @x = dso_local global i32 0, align 4, !dbg !0
 
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-twoaddr.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-twoaddr.ll
index 4a3e21c6d4e1a4..8cc1e164ff14ba 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: target={{x86_64-.*-(linux|windows).*}}
 ; 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 dccd37e9de99d9..481d681a1bf21a 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: target={{x86_64-.*-(linux|windows).*}}
 ; 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
 

>From 642cf19388a496c2d228f7a0de5c0b467ea99422 Mon Sep 17 00:00:00 2001
From: Haohai Wen <haohai.wen at intel.com>
Date: Wed, 22 Jan 2025 21:48:26 +0800
Subject: [PATCH 3/3] Remove triple and datalayout

---
 .../SampleProfile/pseudo-probe-callee-profile-mismatch.ll     | 3 ---
 llvm/test/Transforms/SampleProfile/pseudo-probe-icp-factor.ll | 3 ---
 llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll     | 3 ---
 llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll     | 3 ---
 .../Transforms/SampleProfile/pseudo-probe-missing-probe.ll    | 3 ---
 .../Transforms/SampleProfile/pseudo-probe-no-debug-info.ll    | 3 ---
 .../Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll | 4 ++--
 .../SampleProfile/pseudo-probe-stale-profile-matching-LCS.ll  | 3 ---
 .../SampleProfile/pseudo-probe-stale-profile-matching-lto.ll  | 3 ---
 .../SampleProfile/pseudo-probe-stale-profile-matching.ll      | 3 ---
 .../pseudo-probe-stale-profile-renaming-recursive.ll          | 3 ---
 .../SampleProfile/pseudo-probe-stale-profile-renaming.ll      | 3 ---
 .../SampleProfile/pseudo-probe-stale-profile-toplev-func.ll   | 3 ---
 13 files changed, 2 insertions(+), 38 deletions(-)

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 c8ce29928930d1..7512756f8150c7 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-callee-profile-mismatch.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-callee-profile-mismatch.ll
@@ -13,9 +13,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--"
-
 define available_externally i32 @main() #0 {
   %1 = call i32 @bar(), !dbg !13
   ret i32 0
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-icp-factor.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-icp-factor.ll
index b39fb40150005e..4b8cbace41b481 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-icp-factor.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-icp-factor.ll
@@ -1,8 +1,5 @@
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-icp-factor.prof -S -sample-profile-prioritized-inline=1 2>&1 | FileCheck %s
 
-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--"
-
 @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
 
 ; Function Attrs: nounwind uwtable
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll
index a597d74f034a06..b4083f26d9912e 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--"
-
 @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-invoke.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll
index 484b1388aeaff1..92e56db3258dcd 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-invoke.ll
@@ -1,9 +1,6 @@
 ; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
 ; 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--"
-
 $__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 174f6994e360e4..ff64e5bde2f9f2 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--"
-
 @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 9fefd990eae897..e45ddb11c3f418 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--"
-
 @a = common global i32 0, align 4
 @b = common global i32 0, align 4
 
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll
index 2228bb81dd8c35..6efd9f511e1372 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll
@@ -1,4 +1,4 @@
-; REQUIRES: target={{x86_64-.*-(linux|windows).*}}
+; REQUIRES: x86_64-linux
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-mismatch.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
@@ -61,7 +61,7 @@
 
 
 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--"
+target triple = "x86_64-unknown-linux-gnu"
 
 @x = dso_local global i32 0, align 4, !dbg !0
 
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 37217e021d0bcd..677ccdb272c809 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
@@ -31,9 +31,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--"
-
 @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 120c4c9774bb6e..acf0c571eefd80 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
@@ -22,9 +22,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--"
-
 @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 a0a9c067cf4cb9..55f795b1a201e6 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching.ll
@@ -101,9 +101,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--"
-
 @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 8fa48808b8dd4d..930920eea80d05 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
@@ -18,9 +18,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--"
-
 @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 baf4f0aae65478..1fa8990819539a 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming.ll
@@ -31,9 +31,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--"
-
 @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 c7a2bcdda22abb..a0d5bd464ad47b 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
@@ -30,9 +30,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--"
-
 @x = dso_local global i32 0, align 4, !dbg !0
 
 ; Function Attrs: noinline nounwind uwtable



More information about the llvm-commits mailing list