summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/CodeGenPGO.cpp3
-rw-r--r--clang/test/Profile/c-avoid-direct-call.c11
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index e5993f51e4d..7e89492f1c6 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -755,6 +755,9 @@ void CodeGenPGO::valueProfile(CGBuilderTy &Builder, uint32_t ValueKind,
if (!ValuePtr || !ValueSite || !Builder.GetInsertBlock())
return;
+ if (isa<llvm::Constant>(ValuePtr))
+ return;
+
bool InstrumentValueSites = CGM.getCodeGenOpts().hasProfileClangInstr();
if (InstrumentValueSites && RegionCounterMap) {
auto BuilderInsertPoint = Builder.saveIP();
diff --git a/clang/test/Profile/c-avoid-direct-call.c b/clang/test/Profile/c-avoid-direct-call.c
new file mode 100644
index 00000000000..cd02e714dbe
--- /dev/null
+++ b/clang/test/Profile/c-avoid-direct-call.c
@@ -0,0 +1,11 @@
+// Check the value profiling instrinsics emitted by instrumentation.
+
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-avoid-direct-call.c %s -o - -emit-llvm -fprofile-instrument=clang -mllvm -enable-value-profiling | FileCheck %s
+
+void foo();
+
+int main(void) {
+// CHECK-NOT: call void @__llvm_profile_instrument_target
+ foo(21);
+ return 0;
+}
OpenPOWER on IntegriCloud