<div dir="ltr">This looks like a change to clang - could you test it in clang (& review it on cfe-commits instead of llvm-commits)?</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 6, 2016 at 11:57 AM, David Li via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">davidxl created this revision.<br>
davidxl added a reviewer: vsk.<br>
davidxl added subscribers: llvm-commits, cfe-commits.<br>
<br>
For compiler generated assignment operator that is not trivial (calling base class operator=()), Clang FE assign region counters to the function body but does not emit profile counter increment for the function entry. This leads to many problems:<br>
<br>
1) the operator body does not have profile data generated leading to warning in profile-use<br>
2) the size of the function body may be large and lack of profile data may lead to wrong inlining decisions<br>
3) when FE assign region counters to the function, it also emit coverage mapping data for the function -- but it has no coverage data which is confusing (currently the llvm-cov tool will report malformed format (as the name of the operator is not put into the right name section).<br>
<br>
<a href="http://reviews.llvm.org/D16947" rel="noreferrer" target="_blank">http://reviews.llvm.org/D16947</a><br>
<br>
Files:<br>
lib/CodeGen/CGClass.cpp<br>
test/Profile/def-assignop.cpp<br>
<br>
Index: test/Profile/def-assignop.cpp<br>
===================================================================<br>
--- test/Profile/def-assignop.cpp<br>
+++ test/Profile/def-assignop.cpp<br>
@@ -0,0 +1,34 @@<br>
+// RUN: %clang_cc1 -x c++ %s -triple x86_64-unknown-linux-gnu -main-file-name def-assignop.cpp -o - -emit-llvm -fprofile-instrument=clang | FileCheck --check-prefix=PGOGEN %s<br>
+<br>
+<br>
+struct B {<br>
+ int B;<br>
+ void *operator=(const struct B &b2) {<br>
+ if (b2.B == 0) {<br>
+ B = b2.B + 1;<br>
+ } else<br>
+ B = b2.B;<br>
+ return this;<br>
+ }<br>
+};<br>
+<br>
+struct A : public B {<br>
+ A &operator=(const A &) = default;<br>
+// PGOGEN: define {{.*}}@_ZN1AaSERKS_(<br>
+// PGOGEN: %pgocount = load {{.*}} @__profc__ZN1AaSERKS_<br>
+// PGOGEN: {{.*}}add{{.*}}%pgocount, 1<br>
+// PGOGEN: store{{.*}}@__profc__ZN1AaSERKS_<br>
+ int I;<br>
+ int J;<br>
+ int getI() { return I; }<br>
+};<br>
+<br>
+A aa;<br>
+int g;<br>
+int main() {<br>
+ A aa2;<br>
+ aa2 = aa;<br>
+<br>
+ g = aa2.getI();<br>
+ return 0;<br>
+}<br>
Index: lib/CodeGen/CGClass.cpp<br>
===================================================================<br>
--- lib/CodeGen/CGClass.cpp<br>
+++ lib/CodeGen/CGClass.cpp<br>
@@ -1608,6 +1608,7 @@<br>
<br>
LexicalScope Scope(*this, RootCS->getSourceRange());<br>
<br>
+ incrementProfileCounter(RootCS);<br>
AssignmentMemcpyizer AM(*this, AssignOp, Args);<br>
for (auto *I : RootCS->body())<br>
AM.emitAssignment(I);<br>
<br>
<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>