[llvm] r265330 - [PGO] Avoid instrumenting direct callee's at value sites.

Betul Buyukkurt via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 11:56:36 PDT 2016


Author: betulb
Date: Mon Apr  4 13:56:36 2016
New Revision: 265330

URL: http://llvm.org/viewvc/llvm-project?rev=265330&view=rev
Log:
[PGO] Avoid instrumenting direct callee's at value sites.

Direct callees' that are cast to other function prototypes,
show up in the Call/Invoke instructions as ConstantExpr's.
Currently llvm::CallSite's getCalledFunction() fails
to return the callees in such expressions as direct calls.
Value profiling should avoid instrumenting such cases. Mostly NFC.


Modified:
    llvm/trunk/lib/Transforms/Instrumentation/IndirectCallSiteVisitor.h
    llvm/trunk/test/Transforms/PGOProfile/do-not-instrument.ll

Modified: llvm/trunk/lib/Transforms/Instrumentation/IndirectCallSiteVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/IndirectCallSiteVisitor.h?rev=265330&r1=265329&r2=265330&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/IndirectCallSiteVisitor.h (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/IndirectCallSiteVisitor.h Mon Apr  4 13:56:36 2016
@@ -28,6 +28,8 @@ struct PGOIndirectCallSiteVisitor
       if (CI->isInlineAsm())
         return;
     }
+    if (isa<Constant>(CS.getCalledValue()))
+      return;
     IndirectCallInsts.push_back(I);
   }
 };

Modified: llvm/trunk/test/Transforms/PGOProfile/do-not-instrument.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/do-not-instrument.ll?rev=265330&r1=265329&r2=265330&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/PGOProfile/do-not-instrument.ll (original)
+++ llvm/trunk/test/Transforms/PGOProfile/do-not-instrument.ll Mon Apr  4 13:56:36 2016
@@ -14,4 +14,14 @@ entry:
   ret i32 0
 }
 
+define i32 @f2() {
+entry:
+; CHECK: call void @llvm.instrprof.increment
+; CHECK-NOT: call void @llvm.instrprof.value.profile
+  call void (i32, ...) bitcast (void (...)* @foo to void (i32, ...)*)(i32 21)
+  ret i32 0
+}
+
+declare void @foo(...) #0
+
 attributes #0 = { nounwind }




More information about the llvm-commits mailing list