[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-24 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.

In D82213#2110941 , @fhahn wrote:

> That's interesting. We are also using something similar for the matrix 
> lowering remarks [1]: we traverse the inlining chain bottom up and emit a 
> remark at each step which contains the expression available at that level. I 
> think those approaches could be useful in general to surface remarks at the 
> right level and it might be worth moving them somewhere so they can be 
> shared. What do you think?
>
> [1] 
> https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp#L1783


That's indeed similar, though it seems like what you're doing is more than just 
showing the full inline stack as location. Agreed that if we start to do these 
in more places for optimization remarks, it'd make sense to build it into 
remarks infra. But we may not always want full inline stack names as location 
(considering deep inlining with long template instantiation names that can 
"pollute" the remark messages), so I'm guessing what we could do is move that 
into remarks infra, but still use a separate switch to control whether we show 
inline locations (just like how `-fdiagnostics-show-hotness` controls whether 
we show hotness for remarks)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82213/new/

https://reviews.llvm.org/D82213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-24 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

That's interesting. We are also using something similar for the matrix lowering 
remarks [1]: we traverse the inlining chain bottom up and emit a remark at each 
step which contains the expression available at that level. I think those 
approaches could be useful in general to surface remarks at the right level and 
it might be worth moving them somewhere so they can be shared. What do you 
think?

[1] 
https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp#L1783


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82213/new/

https://reviews.llvm.org/D82213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-21 Thread Wenlei He via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c8a6936bf6b: [Remarks] Add callsite locations to inline 
remarks (authored by wenlei).

Changed prior to commit:
  https://reviews.llvm.org/D82213?vs=272263=272289#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82213/new/

https://reviews.llvm.org/D82213

Files:
  clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
  clang/test/Frontend/optimization-remark-with-hotness.c
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/lib/Analysis/InlineAdvisor.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
  llvm/test/Transforms/SampleProfile/Inputs/remarks.prof
  llvm/test/Transforms/SampleProfile/remarks.ll

Index: llvm/test/Transforms/SampleProfile/remarks.ll
===
--- llvm/test/Transforms/SampleProfile/remarks.ll
+++ llvm/test/Transforms/SampleProfile/remarks.ll
@@ -21,7 +21,8 @@
 
 ; We are expecting foo() to be inlined in main() (almost all the cycles are
 ; spent inside foo).
-; CHECK: remark: remarks.cc:13:21: inlined callee '_Z3foov' into 'main'
+; CHECK: remark: remarks.cc:13:21: _Z3foov inlined into main to match profiling context with (cost=130, threshold=225) at callsite main:0
+; CHECK: remark: remarks.cc:9:19: rand inlined into main to match profiling context with (cost=always): always inline attribute at callsite _Z3foov:6 @ main:0
 
 ; The back edge for the loop is the hottest edge in the loop subgraph.
 ; CHECK: remark: remarks.cc:6:9: most popular destination for conditional branches at remarks.cc:5:3
@@ -32,18 +33,51 @@
 ; Checking to see if YAML file is generated and contains remarks
 ;YAML:   --- !Passed
 ;YAML-NEXT:  Pass:sample-profile-inline
-;YAML-NEXT:  Name:InlineSuccess
+;YAML-NEXT:  Name:Inlined
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 13, Column: 21 }
 ;YAML-NEXT:  Function:main
 ;YAML-NEXT:  Args:
-;YAML-NEXT:- String:  'inlined callee '''
 ;YAML-NEXT:- Callee:  _Z3foov
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 3, Column: 0 }
-;YAML-NEXT:- String:  ''' into '''
+;YAML-NEXT:- String:  ' inlined into '
 ;YAML-NEXT:- Caller:  main
 ;YAML-NEXT:DebugLoc:{ File: remarks.cc, Line: 13, Column: 0 }
-;YAML-NEXT:- String:  
+;YAML-NEXT:- String:  ' to match profiling context'
+;YAML-NEXT:- String:  ' with '
+;YAML-NEXT:- String:  '(cost='
+;YAML-NEXT:- Cost:'130'
+;YAML-NEXT:- String:  ', threshold='
+;YAML-NEXT:- Threshold:   '225'
+;YAML-NEXT:- String:  ')'
+;YAML-NEXT:- String:  ' at callsite '
+;YAML-NEXT:- String:  main
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'0'
 ;YAML-NEXT:  ...
+;YAML:   --- !Passed
+;YAML-NEXT:  Pass:sample-profile-inline
+;YAML-NEXT:  Name:AlwaysInline
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 9, Column: 19 }
+;YAML-NEXT:  Function:main
+;YAML-NEXT:  Args:
+;YAML-NEXT:- Callee:  rand
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 90, Column: 0 }
+;YAML-NEXT:- String:  ' inlined into '
+;YAML-NEXT:- Caller:  main
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 13, Column: 0 }
+;YAML-NEXT:- String:  ' to match profiling context'
+;YAML-NEXT:- String:  ' with '
+;YAML-NEXT:- String:  '(cost=always)'
+;YAML-NEXT:- String:  ': '
+;YAML-NEXT:- Reason:  always inline attribute
+;YAML-NEXT:- String:  ' at callsite '
+;YAML-NEXT:- String:  _Z3foov
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'6'
+;YAML-NEXT:- String:  ' @ '
+;YAML-NEXT:- String:  main
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'0'
 ;YAML:  --- !Analysis
 ;YAML-NEXT:  Pass:sample-profile
 ;YAML-NEXT:  Name:AppliedSamples
@@ -139,7 +173,9 @@
 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
 
 ; Function Attrs: nounwind
-declare i32 @rand() #3
+define i32 @rand() #3 !dbg !59 {
+  ret i32 1
+}
 
 ; Function Attrs: nounwind argmemonly
 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
@@ -158,7 +194,7 @@
 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" "use-sample-profile" }
 attributes #1 = { nounwind argmemonly }
 attributes #2 = { 

[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-20 Thread David Li via Phabricator via cfe-commits
davidxl accepted this revision.
davidxl added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: llvm/lib/Analysis/InlineAdvisor.cpp:383
+   const Function , const InlineCost ,
+   bool ProfileGuidedInline, const char *PassName) {
   ORE.emit([&]() {

ProfileGuidedInline --> ForProfileContext 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82213/new/

https://reviews.llvm.org/D82213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-20 Thread Wenlei He via Phabricator via cfe-commits
wenlei marked an inline comment as done.
wenlei added inline comments.



Comment at: llvm/lib/Analysis/InlineAdvisor.cpp:392
+if (ProfileGuidedInline)
+  Remark << " by profile guided inliner";
+Remark << " with " << IC;

davidxl wrote:
> Perhaps reword it to " to match profiling context" ..
Sounds good, updated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82213/new/

https://reviews.llvm.org/D82213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-20 Thread Wenlei He via Phabricator via cfe-commits
wenlei updated this revision to Diff 272263.
wenlei added a comment.

Update remark message.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82213/new/

https://reviews.llvm.org/D82213

Files:
  clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
  clang/test/Frontend/optimization-remark-with-hotness.c
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/lib/Analysis/InlineAdvisor.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
  llvm/test/Transforms/SampleProfile/Inputs/remarks.prof
  llvm/test/Transforms/SampleProfile/remarks.ll

Index: llvm/test/Transforms/SampleProfile/remarks.ll
===
--- llvm/test/Transforms/SampleProfile/remarks.ll
+++ llvm/test/Transforms/SampleProfile/remarks.ll
@@ -21,7 +21,8 @@
 
 ; We are expecting foo() to be inlined in main() (almost all the cycles are
 ; spent inside foo).
-; CHECK: remark: remarks.cc:13:21: inlined callee '_Z3foov' into 'main'
+; CHECK: remark: remarks.cc:13:21: _Z3foov inlined into main to match profiling context with (cost=130, threshold=225) at callsite main:0
+; CHECK: remark: remarks.cc:9:19: rand inlined into main to match profiling context with (cost=always): always inline attribute at callsite _Z3foov:6 @ main:0
 
 ; The back edge for the loop is the hottest edge in the loop subgraph.
 ; CHECK: remark: remarks.cc:6:9: most popular destination for conditional branches at remarks.cc:5:3
@@ -32,18 +33,51 @@
 ; Checking to see if YAML file is generated and contains remarks
 ;YAML:   --- !Passed
 ;YAML-NEXT:  Pass:sample-profile-inline
-;YAML-NEXT:  Name:InlineSuccess
+;YAML-NEXT:  Name:Inlined
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 13, Column: 21 }
 ;YAML-NEXT:  Function:main
 ;YAML-NEXT:  Args:
-;YAML-NEXT:- String:  'inlined callee '''
 ;YAML-NEXT:- Callee:  _Z3foov
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 3, Column: 0 }
-;YAML-NEXT:- String:  ''' into '''
+;YAML-NEXT:- String:  ' inlined into '
 ;YAML-NEXT:- Caller:  main
 ;YAML-NEXT:DebugLoc:{ File: remarks.cc, Line: 13, Column: 0 }
-;YAML-NEXT:- String:  
+;YAML-NEXT:- String:  ' to match profiling context'
+;YAML-NEXT:- String:  ' with '
+;YAML-NEXT:- String:  '(cost='
+;YAML-NEXT:- Cost:'130'
+;YAML-NEXT:- String:  ', threshold='
+;YAML-NEXT:- Threshold:   '225'
+;YAML-NEXT:- String:  ')'
+;YAML-NEXT:- String:  ' at callsite '
+;YAML-NEXT:- String:  main
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'0'
 ;YAML-NEXT:  ...
+;YAML:   --- !Passed
+;YAML-NEXT:  Pass:sample-profile-inline
+;YAML-NEXT:  Name:AlwaysInline
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 9, Column: 19 }
+;YAML-NEXT:  Function:main
+;YAML-NEXT:  Args:
+;YAML-NEXT:- Callee:  rand
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 90, Column: 0 }
+;YAML-NEXT:- String:  ' inlined into '
+;YAML-NEXT:- Caller:  main
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 13, Column: 0 }
+;YAML-NEXT:- String:  ' to match profiling context'
+;YAML-NEXT:- String:  ' with '
+;YAML-NEXT:- String:  '(cost=always)'
+;YAML-NEXT:- String:  ': '
+;YAML-NEXT:- Reason:  always inline attribute
+;YAML-NEXT:- String:  ' at callsite '
+;YAML-NEXT:- String:  _Z3foov
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'6'
+;YAML-NEXT:- String:  ' @ '
+;YAML-NEXT:- String:  main
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'0'
 ;YAML:  --- !Analysis
 ;YAML-NEXT:  Pass:sample-profile
 ;YAML-NEXT:  Name:AppliedSamples
@@ -139,7 +173,9 @@
 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
 
 ; Function Attrs: nounwind
-declare i32 @rand() #3
+define i32 @rand() #3 !dbg !59 {
+  ret i32 1
+}
 
 ; Function Attrs: nounwind argmemonly
 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
@@ -158,7 +194,7 @@
 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" "use-sample-profile" }
 attributes #1 = { nounwind argmemonly }
 attributes #2 = { nounwind readnone }
-attributes #3 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" 

[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-20 Thread David Li via Phabricator via cfe-commits
davidxl added inline comments.



Comment at: llvm/lib/Analysis/InlineAdvisor.cpp:392
+if (ProfileGuidedInline)
+  Remark << " by profile guided inliner";
+Remark << " with " << IC;

Perhaps reword it to " to match profiling context" ..


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82213/new/

https://reviews.llvm.org/D82213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-20 Thread Wenlei He via Phabricator via cfe-commits
wenlei updated this revision to Diff 272240.
wenlei added a comment.

Address David's comments, add test for nested inlinining.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82213/new/

https://reviews.llvm.org/D82213

Files:
  clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
  clang/test/Frontend/optimization-remark-with-hotness.c
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/lib/Analysis/InlineAdvisor.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
  llvm/test/Transforms/SampleProfile/Inputs/remarks.prof
  llvm/test/Transforms/SampleProfile/remarks.ll

Index: llvm/test/Transforms/SampleProfile/remarks.ll
===
--- llvm/test/Transforms/SampleProfile/remarks.ll
+++ llvm/test/Transforms/SampleProfile/remarks.ll
@@ -21,7 +21,8 @@
 
 ; We are expecting foo() to be inlined in main() (almost all the cycles are
 ; spent inside foo).
-; CHECK: remark: remarks.cc:13:21: inlined callee '_Z3foov' into 'main'
+; CHECK: remark: remarks.cc:13:21: _Z3foov inlined into main by profile guided inliner with (cost=130, threshold=225) at callsite main:0
+; CHECK: remark: remarks.cc:9:19: rand inlined into main by profile guided inliner with (cost=always): always inline attribute at callsite _Z3foov:6 @ main:0
 
 ; The back edge for the loop is the hottest edge in the loop subgraph.
 ; CHECK: remark: remarks.cc:6:9: most popular destination for conditional branches at remarks.cc:5:3
@@ -32,18 +33,51 @@
 ; Checking to see if YAML file is generated and contains remarks
 ;YAML:   --- !Passed
 ;YAML-NEXT:  Pass:sample-profile-inline
-;YAML-NEXT:  Name:InlineSuccess
+;YAML-NEXT:  Name:Inlined
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 13, Column: 21 }
 ;YAML-NEXT:  Function:main
 ;YAML-NEXT:  Args:
-;YAML-NEXT:- String:  'inlined callee '''
 ;YAML-NEXT:- Callee:  _Z3foov
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 3, Column: 0 }
-;YAML-NEXT:- String:  ''' into '''
+;YAML-NEXT:- String:  ' inlined into '
 ;YAML-NEXT:- Caller:  main
 ;YAML-NEXT:DebugLoc:{ File: remarks.cc, Line: 13, Column: 0 }
-;YAML-NEXT:- String:  
+;YAML-NEXT:- String:  ' by profile guided inliner'
+;YAML-NEXT:- String:  ' with '
+;YAML-NEXT:- String:  '(cost='
+;YAML-NEXT:- Cost:'130'
+;YAML-NEXT:- String:  ', threshold='
+;YAML-NEXT:- Threshold:   '225'
+;YAML-NEXT:- String:  ')'
+;YAML-NEXT:- String:  ' at callsite '
+;YAML-NEXT:- String:  main
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'0'
 ;YAML-NEXT:  ...
+;YAML:   --- !Passed
+;YAML-NEXT:  Pass:sample-profile-inline
+;YAML-NEXT:  Name:AlwaysInline
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 9, Column: 19 }
+;YAML-NEXT:  Function:main
+;YAML-NEXT:  Args:
+;YAML-NEXT:- Callee:  rand
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 90, Column: 0 }
+;YAML-NEXT:- String:  ' inlined into '
+;YAML-NEXT:- Caller:  main
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 13, Column: 0 }
+;YAML-NEXT:- String:  ' by profile guided inliner'
+;YAML-NEXT:- String:  ' with '
+;YAML-NEXT:- String:  '(cost=always)'
+;YAML-NEXT:- String:  ': '
+;YAML-NEXT:- Reason:  always inline attribute
+;YAML-NEXT:- String:  ' at callsite '
+;YAML-NEXT:- String:  _Z3foov
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'6'
+;YAML-NEXT:- String:  ' @ '
+;YAML-NEXT:- String:  main
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'0'
 ;YAML:  --- !Analysis
 ;YAML-NEXT:  Pass:sample-profile
 ;YAML-NEXT:  Name:AppliedSamples
@@ -139,7 +173,9 @@
 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
 
 ; Function Attrs: nounwind
-declare i32 @rand() #3
+define i32 @rand() #3 !dbg !59 {
+  ret i32 1
+}
 
 ; Function Attrs: nounwind argmemonly
 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
@@ -158,7 +194,7 @@
 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" "use-sample-profile" }
 attributes #1 = { nounwind argmemonly }
 attributes #2 = { nounwind readnone }
-attributes #3 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" 

[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-19 Thread Wenlei He via Phabricator via cfe-commits
wenlei marked an inline comment as done.
wenlei added inline comments.



Comment at: llvm/lib/Analysis/InlineAdvisor.cpp:391
+Remark << ore::NV("Caller", );
+if (ProfileGuidedInline)
+  Remark << " by profile guided inliner";

davidxl wrote:
> is this necessary? User should know if their build has profile or not.
> 
> What is more useful is when PGO is on, but some callsite does not have 
> profile data, then it is worth reporting.
> is this necessary? User should know if their build has profile or not.

This was used to differentiate between SampleProfileLoader inline vs CGSCC 
inline. Maybe the message `by profile guided inliner` isn't great, but can't 
think of a better and concise way..

With the differentiation in the message, the inlinee tree recovered through 
some parsing is what I'm looking for (`[P]` for SampleProfileLoader inline, 
`[C]` for CGSCC inline):

```
Inlinees for main
[P]  _ZN15largesolidarrayIP6regobjEixEi @ 369
[P]  _Z7random1i @ 363
[C]_Z8myrandomv @ 2
[P]  _Z7random1i @ 364
[C]_Z8myrandomv @ 2
[P]  _ZN15largesolidarrayIP6regobjEixEi @ 366
[P]  _ZN6wayobj9createwayERP8point16tRi @ 327
[P]_ZN6wayobj11createwayarEiiRP8point16tRi @ 37.1
[P]  _ZN6wayobj5indexEii @ 143
[P]  _ZN6wayobj5indexEii @ 130
[P]  _ZN6wayobj6indexxEi @ 31
[P]  _ZN6wayobj6indexyEi @ 32
[C]  _ZN8point16tC2Ess @ 2
[C]  _ZN8point16tC2Ess @ 2.1
```

> What is more useful is when PGO is on, but some callsite does not have 
> profile data, then it is worth reporting.

That can be useful. I was also looking for a way to get call site count printed 
(if we have a count), but looks like it's not available from `InlineCost`. I'm 
going to defer that for now if that's ok. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82213/new/

https://reviews.llvm.org/D82213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-19 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

Can you add a test case where there is more than one level of inline contexts 
for the callsite?




Comment at: llvm/lib/Analysis/InlineAdvisor.cpp:391
+Remark << ore::NV("Caller", );
+if (ProfileGuidedInline)
+  Remark << " by profile guided inliner";

is this necessary? User should know if their build has profile or not.

What is more useful is when PGO is on, but some callsite does not have profile 
data, then it is worth reporting.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82213/new/

https://reviews.llvm.org/D82213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-19 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg added subscribers: fhahn, anemet, thegameg.
thegameg added a comment.

This sounds useful indeed. @fhahn, @anemet might want to take a look.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82213/new/

https://reviews.llvm.org/D82213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-19 Thread Wenlei He via Phabricator via cfe-commits
wenlei created this revision.
wenlei added reviewers: wmi, davidxl, hoy.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

Add call site location info into inline remarks so we can differentiate inline 
sites.
This can be useful for inliner tuning. We can also reconstruct full 
hierarchical inline 
tree from parsing such remarks. The messege of inline remark is also tweaked so 
we can 
differentiate SampleProfileLoader inline from CGSCC inline.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82213

Files:
  clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
  clang/test/Frontend/optimization-remark-with-hotness.c
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/lib/Analysis/InlineAdvisor.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
  llvm/test/Transforms/SampleProfile/remarks.ll

Index: llvm/test/Transforms/SampleProfile/remarks.ll
===
--- llvm/test/Transforms/SampleProfile/remarks.ll
+++ llvm/test/Transforms/SampleProfile/remarks.ll
@@ -21,7 +21,7 @@
 
 ; We are expecting foo() to be inlined in main() (almost all the cycles are
 ; spent inside foo).
-; CHECK: remark: remarks.cc:13:21: inlined callee '_Z3foov' into 'main'
+; CHECK: remark: remarks.cc:13:21: _Z3foov inlined into main by profile guided inliner with (cost=130, threshold=225) at callsite main:0
 
 ; The back edge for the loop is the hottest edge in the loop subgraph.
 ; CHECK: remark: remarks.cc:6:9: most popular destination for conditional branches at remarks.cc:5:3
@@ -32,17 +32,26 @@
 ; Checking to see if YAML file is generated and contains remarks
 ;YAML:   --- !Passed
 ;YAML-NEXT:  Pass:sample-profile-inline
-;YAML-NEXT:  Name:InlineSuccess
+;YAML-NEXT:  Name:Inlined
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 13, Column: 21 }
 ;YAML-NEXT:  Function:main
 ;YAML-NEXT:  Args:
-;YAML-NEXT:- String:  'inlined callee '''
 ;YAML-NEXT:- Callee:  _Z3foov
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 3, Column: 0 }
-;YAML-NEXT:- String:  ''' into '''
+;YAML-NEXT:- String:  ' inlined into '
 ;YAML-NEXT:- Caller:  main
 ;YAML-NEXT:DebugLoc:{ File: remarks.cc, Line: 13, Column: 0 }
-;YAML-NEXT:- String:  
+;YAML-NEXT:- String:  ' by profile guided inliner'
+;YAML-NEXT:- String:  ' with '
+;YAML-NEXT:- String:  '(cost='
+;YAML-NEXT:- Cost:'130'
+;YAML-NEXT:- String:  ', threshold='
+;YAML-NEXT:- Threshold:   '225'
+;YAML-NEXT:- String:  ')'
+;YAML-NEXT:- String:  ' at callsite '
+;YAML-NEXT:- String:  main
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'0'
 ;YAML-NEXT:  ...
 ;YAML:  --- !Analysis
 ;YAML-NEXT:  Pass:sample-profile
Index: llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
===
--- llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
+++ llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
@@ -22,7 +22,7 @@
 ;  4   return foo();
 ;  5 }
 
-; CHECK: remark: /tmp/s.c:4:10: foo inlined into bar with (cost={{[0-9\-]+}}, threshold={{[0-9]+}}) (hotness: 30)
+; CHECK: remark: /tmp/s.c:4:10: foo inlined into bar with (cost={{[0-9\-]+}}, threshold={{[0-9]+}}) at callsite bar:1 (hotness: 30)
 
 ; YAML:  --- !Passed
 ; YAML-NEXT: Pass:inline
@@ -42,6 +42,10 @@
 ; YAML-NEXT:   - String: ', threshold='
 ; YAML-NEXT:   - Threshold: '{{[0-9]+}}'
 ; YAML-NEXT:   - String: ')'
+; YAML-NEXT:   - String:  ' at callsite '
+; YAML-NEXT:   - String:  bar
+; YAML-NEXT:   - String:  ':'
+; YAML-NEXT:   - Line:'1'
 ; YAML-NEXT: ...
 
 ; ModuleID = '/tmp/s.c'
Index: llvm/lib/Transforms/IPO/SampleProfile.cpp
===
--- llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/CallGraph.h"
 #include "llvm/Analysis/CallGraphSCCPass.h"
+#include "llvm/Analysis/InlineAdvisor.h"
 #include "llvm/Analysis/InlineCost.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
@@ -916,9 +917,8 @@
   InlineFunctionInfo IFI(nullptr, GetAC);
   if (InlineFunction(CB, IFI).isSuccess()) {
 // The call to InlineFunction erases I, so we can't pass it here.
-ORE->emit(OptimizationRemark(CSINLINE_DEBUG, "InlineSuccess", DLoc, BB)
-  << "inlined callee '" << ore::NV("Callee", CalledFunction)
-  << "' into '" << ore::NV("Caller", BB->getParent()) << "'");
+