[llvm] [PseudoProbe] Fix cleanup for pseudo probe after annotation (PR #119660)
Haohai Wen via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 11 22:16:30 PST 2024
================
@@ -2138,13 +2138,25 @@ bool SampleProfileLoader::rejectHighStalenessProfile(
return false;
}
-void SampleProfileLoader::removePseudoProbeInsts(Module &M) {
+void SampleProfileLoader::removePseudoProbeInstsDiscriminator(Module &M) {
for (auto &F : M) {
std::vector<Instruction *> InstsToDel;
for (auto &BB : F) {
for (auto &I : BB) {
if (isa<PseudoProbeInst>(&I))
InstsToDel.push_back(&I);
+ else if (isa<CallBase>(&I))
+ if (const DILocation *DIL = I.getDebugLoc().get()) {
+ // Restore dwarf discriminator for call.
+ unsigned Discriminator = DIL->getDiscriminator();
+ if (DILocation::isPseudoProbeDiscriminator(Discriminator)) {
+ std::optional<uint32_t> DwarfDiscriminator =
+ PseudoProbeDwarfDiscriminator::extractDwarfBaseDiscriminator(
+ Discriminator);
+ I.setDebugLoc(DIL->cloneWithDiscriminator(
+ DwarfDiscriminator ? *DwarfDiscriminator : 0));
----------------
HaohaiWen wrote:
Is zero discriminator same effect as no discriminator in DILexicalBlockFile?
https://github.com/llvm/llvm-project/pull/119660
More information about the llvm-commits
mailing list