r264783 - [PGO] Move the instrumentation point closer to the value site.
Betul Buyukkurt via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 29 15:24:55 PDT 2016
Hi Artem,
I’ve uploaded a patch to remove the alignment.
Thanks,
-Betul
From: Artem Belevich [mailto:tra at google.com]
Sent: Tuesday, March 29, 2016 3:15 PM
To: Betul Buyukkurt <betulb at codeaurora.org>
Cc: cfe-commits <cfe-commits at lists.llvm.org>
Subject: Re: r264783 - [PGO] Move the instrumentation point closer to the value site.
Hi,
FYI, cxx-indirect-call.cpp test fails on platforms with different alignment. It may help to either use specific target or change your patterns to accommodate other targets.
--Artem
******************** TEST 'Clang :: Profile/cxx-indirect-call.cpp' FAILED ********************
Script:
--
/usr/local/google/home/tra/work/llvm/build/gpu/release/./bin/clang --driver-mode=g++ /work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp -o - -emit-llvm -S -fprofile-instr-generate -mllvm -enable-value-profiling -fexceptions -target x86_64-unknown-linux-gnu | /usr/local/google/home/tra/work/llvm/build/gpu/release/./bin/FileCheck /work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp
--
Exit Code: 1
Command Output (stderr):
--
/work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp:8:11: error: expected string not found in input
// CHECK: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 4
^
<stdin>:1:1: note: scanning from here
; ModuleID = '/work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp'
^
<stdin>:27:2: note: possible intended match here
%11 = load void ()*, void ()** @foo, align 8
^
--
On Tue, Mar 29, 2016 at 1:44 PM, Betul Buyukkurt via cfe-commits <cfe-commits at lists.llvm.org <mailto:cfe-commits at lists.llvm.org> > wrote:
Author: betulb
Date: Tue Mar 29 15:44:09 2016
New Revision: 264783
URL: http://llvm.org/viewvc/llvm-project?rev=264783 <http://llvm.org/viewvc/llvm-project?rev=264783&view=rev> &view=rev
Log:
[PGO] Move the instrumentation point closer to the value site.
For terminator instructions, the value profiling instrumentation
happens in a basic block other than where the value site resides.
This CR moves the instrumentation point prior to the value site.
Mostly NFC.
Added:
cfe/trunk/test/Profile/cxx-indirect-call.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
cfe/trunk/test/Profile/c-indirect-call.c
Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=264783 <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=264783&r1=264782&r2=264783&view=diff> &r1=264782&r2=264783&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Tue Mar 29 15:44:09 2016
@@ -757,10 +757,10 @@ void CodeGenPGO::valueProfile(CGBuilderT
bool InstrumentValueSites = CGM.getCodeGenOpts().hasProfileClangInstr();
if (InstrumentValueSites && RegionCounterMap) {
- llvm::LLVMContext &Ctx = CGM.getLLVMContext();
- auto *I8PtrTy = llvm::Type::getInt8PtrTy(Ctx);
+ auto BuilderInsertPoint = Builder.saveIP();
+ Builder.SetInsertPoint(ValueSite);
llvm::Value *Args[5] = {
- llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
+ llvm::ConstantExpr::getBitCast(FuncNameVar, Builder.getInt8PtrTy()),
Builder.getInt64(FunctionHash),
Builder.CreatePtrToInt(ValuePtr, Builder.getInt64Ty()),
Builder.getInt32(ValueKind),
@@ -768,6 +768,7 @@ void CodeGenPGO::valueProfile(CGBuilderT
};
Builder.CreateCall(
CGM.getIntrinsic(llvm::Intrinsic::instrprof_value_profile), Args);
+ Builder.restoreIP(BuilderInsertPoint);
return;
}
Modified: cfe/trunk/test/Profile/c-indirect-call.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-indirect-call.c?rev=264783 <http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-indirect-call.c?rev=264783&r1=264782&r2=264783&view=diff> &r1=264782&r2=264783&view=diff
==============================================================================
--- cfe/trunk/test/Profile/c-indirect-call.c (original)
+++ cfe/trunk/test/Profile/c-indirect-call.c Tue Mar 29 15:44:09 2016
@@ -1,13 +1,14 @@
-// Check the data structures emitted by instrumentation.
+// Check the value profiling instrinsics emitted by instrumentation.
+
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-indirect-call.c %s -o - -emit-llvm -fprofile-instrument=clang -mllvm -enable-value-profiling | FileCheck %s
void (*foo)(void);
int main(void) {
// CHECK: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 8
-// CHECK-NEXT: call void [[REG1]]()
// CHECK-NEXT: [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64
// CHECK-NEXT: call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* bitcast ({{.*}}* @__profd_main to i8*), i32 0)
+// CHECK-NEXT: call void [[REG1]]()
foo();
return 0;
}
Added: cfe/trunk/test/Profile/cxx-indirect-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-indirect-call.cpp?rev=264783 <http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-indirect-call.cpp?rev=264783&view=auto> &view=auto
==============================================================================
--- cfe/trunk/test/Profile/cxx-indirect-call.cpp (added)
+++ cfe/trunk/test/Profile/cxx-indirect-call.cpp Tue Mar 29 15:44:09 2016
@@ -0,0 +1,21 @@
+// Check the value profiling instrinsics emitted by instrumentation.
+
+// RUN: %clangxx %s -o - -emit-llvm -S -fprofile-instr-generate -mllvm -enable-value-profiling -fexceptions -target %itanium_abi_triple | FileCheck %s
+
+void (*foo) (void);
+
+int main(int argc, const char *argv[]) {
+// CHECK: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 4
+// CHECK-NEXT: [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64
+// CHECK-NEXT: call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* bitcast ({{.*}}* @__profd_main to i8*), i32 0)
+// CHECK-NEXT: invoke void [[REG1]]()
+ try {
+ foo();
+ } catch (int) {}
+ return 0;
+}
+
+// CHECK: declare void @__llvm_profile_instrument_target(i64, i8*, i32)
+
+
+
_______________________________________________
cfe-commits mailing list
cfe-commits at lists.llvm.org <mailto:cfe-commits at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
--
--Artem Belevich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160329/408c39ce/attachment-0001.html>
More information about the cfe-commits
mailing list