[llvm] c5fafc1 - [CSSPGO] Tweakes to lower pseudo probe runtime overhead

Hongtao Yu via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 17 12:28:16 PDT 2021


Author: Hongtao Yu
Date: 2021-09-17T12:28:09-07:00
New Revision: c5fafc1e73bcdbb8eaf899d13c5566f37f9580ac

URL: https://github.com/llvm/llvm-project/commit/c5fafc1e73bcdbb8eaf899d13c5566f37f9580ac
DIFF: https://github.com/llvm/llvm-project/commit/c5fafc1e73bcdbb8eaf899d13c5566f37f9580ac.diff

LOG: [CSSPGO] Tweakes to lower pseudo probe runtime overhead

A couple tweaks to

1. allow more thinlto importing by excluding probe intrinsics from IR size in module summary

2. Allow general default attributes (nofree nosync nounwind) for pseudo probe intrinsic. Without those attributes, pseudo probes will be basically treated as unknown calls which will in turn block their containing functions from annotated with those attributes.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D109976

Added: 
    

Modified: 
    llvm/include/llvm/IR/Intrinsics.td
    llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
    llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index b0e8ef4ee9275..5032c7c374014 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -1334,7 +1334,7 @@ def int_sideeffect : DefaultAttrsIntrinsic<[], [], [IntrInaccessibleMemOnly, Int
 // Like the sideeffect intrinsic defined above, this intrinsic is treated by the
 // optimizer as having opaque side effects so that it won't be get rid of or moved
 // out of the block it probes.
-def int_pseudoprobe : Intrinsic<[], [llvm_i64_ty, llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
+def int_pseudoprobe : DefaultAttrsIntrinsic<[], [llvm_i64_ty, llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
                                     [IntrInaccessibleMemOnly, IntrWillReturn]>;
 
 // Arithmetic fence intrinsic.

diff  --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index a85dd7553b086..6a5320e8b876a 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -279,7 +279,7 @@ static void computeFunctionSummary(
     }
 
     for (const Instruction &I : BB) {
-      if (isa<DbgInfoIntrinsic>(I))
+      if (I.isDebugOrPseudoInst())
         continue;
       ++NumInsts;
       // Regular LTO module doesn't participate in ThinLTO import,

diff  --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
index da5d46a32287f..55cf453997e77 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
@@ -64,6 +64,9 @@ entry:
   ret void
 }
 
+; CHECK-IL: Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn
+; CHECK-IL-NEXT: declare void @llvm.pseudoprobe(i64, i64, i32, i64)
+
 ; CHECK-IL: ![[#FOO:]] = distinct !DISubprogram(name: "foo"
 ; CHECK-IL: ![[#FAKELINE]] = !DILocation(line: 0, scope: ![[#FOO]])
 ; CHECK-IL: ![[#REALLINE]] = !DILocation(line: 2, scope: ![[#FOO]])


        


More information about the llvm-commits mailing list