-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[PseudoProbe] Support emitting to COFF object #123870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This UniqueID can be used later to create associative section. e.g. A .pseudo_probe associated to the section of the corresponding function.
Support emitting pseudo probe to .pseudo_probe and .pseudo_probe_desc COFF sections.
@llvm/pr-subscribers-clang @llvm/pr-subscribers-llvm-transforms Author: Haohai Wen (HaohaiWen) ChangesRFC: https://discourse.llvm.org/t/rfc-support-pseudo-probe-for-windows-coff/83820 Patch is 52.29 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/123870.diff 36 Files Affected:
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/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/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 46222fcaa5b152..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"
@@ -718,10 +719,17 @@ 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);
+ // 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 vo...
[truncated]
|
Depends on #123869 |
Iter->second = Result; | ||
auto *F = allocInitialFragment(*Result); | ||
Begin->setFragment(F); | ||
// Normally the comdat symbol is function begin label and will be set a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks little bit ugly here. Any better solution?
We must support create pseudo_probe_desc section from asm so it can't be simply implemented in getPseudoProbeDescSection
@@ -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--" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Triples with unknown OS default to ELF, so this doesn't really test COFF.
You'll have to invoke both opt -mtriple=x86_64
and opt -mtriple=x86_64-windows
and omit datalayout/triple in IR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we simply remove target triple
and target datalayout
in IR?
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.