[PATCH] D150741: [FS-AFDO] Clean up non-zero discriminator for pseudo probes at the first FS discriminator pass.
Hongtao Yu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 16 17:49:43 PDT 2023
hoy updated this revision to Diff 522859.
hoy edited the summary of this revision.
hoy added a comment.
Updating D150741 <https://reviews.llvm.org/D150741>: [FS-AFDO] Clean up non-zero discriminator for pseudo probes at the first FS discriminator pass.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150741/new/
https://reviews.llvm.org/D150741
Files:
llvm/include/llvm/CodeGen/MIRFSDiscriminator.h
llvm/lib/CodeGen/MIRFSDiscriminator.cpp
llvm/test/CodeGen/X86/fsafdo_probe.ll
Index: llvm/test/CodeGen/X86/fsafdo_probe.ll
===================================================================
--- llvm/test/CodeGen/X86/fsafdo_probe.ll
+++ llvm/test/CodeGen/X86/fsafdo_probe.ll
@@ -65,7 +65,8 @@
!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 5, type: !7, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
!7 = !DISubroutineType(types: !2)
!8 = !DILocation(line: 7, column: 15, scope: !9)
-!9 = !DILexicalBlockFile(scope: !6, file: !1, discriminator: 0)
+;; The discriminator with value 2 is to test that it can be cleaned up by the first FS discriminator pass.
+!9 = !DILexicalBlockFile(scope: !6, file: !1, discriminator: 2)
!10 = !DILocation(line: 7, column: 3, scope: !9)
!11 = !DILocation(line: 9, column: 5, scope: !9)
!12 = !DILocation(line: 14, column: 3, scope: !6)
Index: llvm/lib/CodeGen/MIRFSDiscriminator.cpp
===================================================================
--- llvm/lib/CodeGen/MIRFSDiscriminator.cpp
+++ llvm/lib/CodeGen/MIRFSDiscriminator.cpp
@@ -150,6 +150,12 @@
if (LineNo == 0)
continue;
unsigned Discriminator = DIL->getDiscriminator();
+ // Clean up discriminators for pseudo probes at the first FS discriminator
+ // pass as their discriminators should not ever be used.
+ if ((Pass == FSDiscriminatorPass::Pass1) && I.isPseudoProbe()) {
+ Discriminator = 0;
+ I.setDebugLoc(DIL->cloneWithDiscriminator(0));
+ }
uint64_t CallStackHashVal = 0;
if (ImprovedFSDiscriminator)
CallStackHashVal = getCallStackHash(DIL);
Index: llvm/include/llvm/CodeGen/MIRFSDiscriminator.h
===================================================================
--- llvm/include/llvm/CodeGen/MIRFSDiscriminator.h
+++ llvm/include/llvm/CodeGen/MIRFSDiscriminator.h
@@ -31,6 +31,7 @@
using namespace sampleprof;
class MIRAddFSDiscriminators : public MachineFunctionPass {
MachineFunction *MF = nullptr;
+ FSDiscriminatorPass Pass;
unsigned LowBit;
unsigned HighBit;
@@ -38,7 +39,7 @@
static char ID;
/// PassNum is the sequence number this pass is called, start from 1.
MIRAddFSDiscriminators(FSDiscriminatorPass P = FSDiscriminatorPass::Pass1)
- : MachineFunctionPass(ID) {
+ : MachineFunctionPass(ID), Pass(P) {
LowBit = getFSPassBitBegin(P);
HighBit = getFSPassBitEnd(P);
assert(LowBit < HighBit && "HighBit needs to be greater than Lowbit");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150741.522859.patch
Type: text/x-patch
Size: 2506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230517/ba8e0d53/attachment.bin>
More information about the llvm-commits
mailing list