[PATCH] D149800: [WIP][PGO] Add ability to mark cold functions as optsize/minsize/optnone

2023-05-11 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

In D149800#4330831 , @davidxl wrote:

> This patch uses a cleaner method than the previous effort. There is some 
> differences:
>
> 1. yamauchi's patch works for both iFDO and autoFDO, while this patch limits 
> to iFDO
> 2. yamauchi's patch also handles size optimization (IIRC) at granularity 
> smaller than function
>
> Longer term, the previous functionality should fold into the new framework.

IIRC 1) and 2) are correct. I don't have a strong preference on which folds 
into which.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149800

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-08-03 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

In D84782#2191243 , @MaskRay wrote:

> @yamauchi Do we need cd890944ad344b1b8cac58332ab11c9eec6b61e9 
>  and 
> 3d6f53018f845e893ad34f64ff2851a2e5c3ba1d 
>  in 
> https://github.com/llvm/llvm-project/tree/release/11.x ?

I think it'd be good to have them, if possible, though it's a latent, 
non-recent bug.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-30 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

Yup, -pgo-instr-old-cfg-hashing=true to revert back to the old hashing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

Latest update diff:

  < +  std::vector Data;
  < +  for (unsigned I = 0; I < 8; ++I)
  < +Data.push_back((uint8_t)(Num >> (I * 8)));
  ---
  > +  uint8_t Data[8];
  > +  support::endian::write64le(Data, Num);




Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:661
+} Data;
+Data.N = (uint64_t)SIVisitor.getNumOfSelectInsts();
+JCH.update(Data.C);

yamauchi wrote:
> MaskRay wrote:
> > MaskRay wrote:
> > > `#include "llvm/Support/Endian.h"`
> > > 
> > > and use `support::endian::write64le(, 
> > > (uint64_t)SIVisitor.getNumOfSelectInsts())`
> > Sorry, just use a plain `uint8_t C[8];` and `support::endian::write64le(C, 
> > (uint64_t)SIVisitor.getNumOfSelectInsts())`
> I went for the same style (using a vector) as the above code (line 642).
Now uses write64le.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281764.
yamauchi added a comment.

Use endian::write64le.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll

Index: llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
===
--- llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
+++ llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
@@ -1,6 +1,8 @@
 ; RUN: llvm-profdata merge %S/Inputs/multiple_hash_profile.proftext -o %t.profdata
 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata  -S | FileCheck %s
+; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-old-cfg-hashing=true -S | FileCheck -check-prefix=CHECKOLDHASH %s
 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s
+; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-old-cfg-hashing=true -S | FileCheck -check-prefix=CHECKOLDHASH %s
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
@@ -29,6 +31,9 @@
 ; CHECK: %mul.i = select i1 %cmp.i, i32 1, i32 %i
 ; CHECK-SAME: !prof ![[BW:[0-9]+]]
 ; CHECK: ![[BW]] = !{!"branch_weights", i32 12, i32 6}
+; CHECKOLDHASH: %mul.i = select i1 %cmp.i, i32 1, i32 %i
+; CHECKOLDHASH-SAME: !prof ![[BW:[0-9]+]]
+; CHECKOLDHASH: ![[BW]] = !{!"branch_weights", i32 6, i32 12}
   %retval.0.i = mul nsw i32 %mul.i, %i
   ret i32 %retval.0.i
 }
Index: llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
===
--- llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
+++ 

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

Here's the diff in the latest update:

  < +union {
  < +  uint64_t N;
  < +  uint8_t C[8];
  < +} Data;
  < +Data.N = (uint64_t)SIVisitor.getNumOfSelectInsts();
  < +JCH.update(Data.C);
  < +Data.N = (uint64_t)ValueSites[IPVK_IndirectCallTarget].size();
  < +JCH.update(Data.C);
  < +Data.N = (uint64_t)ValueSites[IPVK_MemOPSize].size();
  < +JCH.update(Data.C);
  < +Data.N = (uint64_t)MST.AllEdges.size();
  < +JCH.update(Data.C);
  ---
  > +auto updateJCH = [](uint64_t Num) {
  > +  std::vector Data;
  > +  for (unsigned I = 0; I < 8; ++I)
  > +Data.push_back((uint8_t)(Num >> (I * 8)));
  > +  JCH.update(Data);
  > +};
  > +updateJCH((uint64_t)SIVisitor.getNumOfSelectInsts());
  > +updateJCH((uint64_t)ValueSites[IPVK_IndirectCallTarget].size());
  > +updateJCH((uint64_t)ValueSites[IPVK_MemOPSize].size());
  > +updateJCH((uint64_t)MST.AllEdges.size());


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:661
+} Data;
+Data.N = (uint64_t)SIVisitor.getNumOfSelectInsts();
+JCH.update(Data.C);

MaskRay wrote:
> MaskRay wrote:
> > `#include "llvm/Support/Endian.h"`
> > 
> > and use `support::endian::write64le(, 
> > (uint64_t)SIVisitor.getNumOfSelectInsts())`
> Sorry, just use a plain `uint8_t C[8];` and `support::endian::write64le(C, 
> (uint64_t)SIVisitor.getNumOfSelectInsts())`
I went for the same style (using a vector) as the above code (line 642).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281760.
yamauchi added a comment.

Fix the endianness issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll

Index: llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
===
--- llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
+++ llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
@@ -1,6 +1,8 @@
 ; RUN: llvm-profdata merge %S/Inputs/multiple_hash_profile.proftext -o %t.profdata
 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata  -S | FileCheck %s
+; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-old-cfg-hashing=true -S | FileCheck -check-prefix=CHECKOLDHASH %s
 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s
+; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-old-cfg-hashing=true -S | FileCheck -check-prefix=CHECKOLDHASH %s
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
@@ -29,6 +31,9 @@
 ; CHECK: %mul.i = select i1 %cmp.i, i32 1, i32 %i
 ; CHECK-SAME: !prof ![[BW:[0-9]+]]
 ; CHECK: ![[BW]] = !{!"branch_weights", i32 12, i32 6}
+; CHECKOLDHASH: %mul.i = select i1 %cmp.i, i32 1, i32 %i
+; CHECKOLDHASH-SAME: !prof ![[BW:[0-9]+]]
+; CHECKOLDHASH: ![[BW]] = !{!"branch_weights", i32 6, i32 12}
   %retval.0.i = mul nsw i32 %mul.i, %i
   ret i32 %retval.0.i
 }
Index: llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
===
--- llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
+++ 

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

Builtbot failure: 
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/51984

I think it's an endian issue in the hash computation.

Will revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG120e66b3418b: [PGO] Include the mem ops into the function 
hash. (authored by yamauchi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll

Index: llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
===
--- llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
+++ llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
@@ -1,6 +1,8 @@
 ; RUN: llvm-profdata merge %S/Inputs/multiple_hash_profile.proftext -o %t.profdata
 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata  -S | FileCheck %s
+; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-old-cfg-hashing=true -S | FileCheck -check-prefix=CHECKOLDHASH %s
 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s
+; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-old-cfg-hashing=true -S | FileCheck -check-prefix=CHECKOLDHASH %s
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
@@ -29,6 +31,9 @@
 ; CHECK: %mul.i = select i1 %cmp.i, i32 1, i32 %i
 ; CHECK-SAME: !prof ![[BW:[0-9]+]]
 ; CHECK: ![[BW]] = !{!"branch_weights", i32 12, i32 6}
+; CHECKOLDHASH: %mul.i = select i1 %cmp.i, i32 1, i32 %i
+; CHECKOLDHASH-SAME: !prof ![[BW:[0-9]+]]
+; CHECKOLDHASH: ![[BW]] = !{!"branch_weights", i32 6, i32 12}
   %retval.0.i = mul nsw i32 %mul.i, %i
   ret i32 %retval.0.i
 }
Index: llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281716.
yamauchi added a comment.

Address comments. PTAL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll

Index: llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
===
--- llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
+++ llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
@@ -1,6 +1,8 @@
 ; RUN: llvm-profdata merge %S/Inputs/multiple_hash_profile.proftext -o %t.profdata
 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata  -S | FileCheck %s
+; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-old-cfg-hashing=true -S | FileCheck -check-prefix=CHECKOLDHASH %s
 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s
+; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-old-cfg-hashing=true -S | FileCheck -check-prefix=CHECKOLDHASH %s
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
@@ -29,6 +31,9 @@
 ; CHECK: %mul.i = select i1 %cmp.i, i32 1, i32 %i
 ; CHECK-SAME: !prof ![[BW:[0-9]+]]
 ; CHECK: ![[BW]] = !{!"branch_weights", i32 12, i32 6}
+; CHECKOLDHASH: %mul.i = select i1 %cmp.i, i32 1, i32 %i
+; CHECKOLDHASH-SAME: !prof ![[BW:[0-9]+]]
+; CHECKOLDHASH: ![[BW]] = !{!"branch_weights", i32 6, i32 12}
   %retval.0.i = mul nsw i32 %mul.i, %i
   ret i32 %retval.0.i
 }
Index: llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
===
--- llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
+++ 

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: 
llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext:20
 18
 12
 

davidxl wrote:
> nit: change 12 to a different value say 6.(otherwise if the option is an nop, 
> the test will still succeed).
Done.



Comment at: llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll:3
 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata  -S | 
FileCheck %s
+; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata 
-pgo-instr-old-cfg-hashing=true -S | FileCheck %s
 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | 
FileCheck %s

davidxl wrote:
> Use a different prefix like CHECKOLD
Done.



Comment at: llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll:33
 ; CHECK-SAME: !prof ![[BW:[0-9]+]]
 ; CHECK: ![[BW]] = !{!"branch_weights", i32 12, i32 6}
   %retval.0.i = mul nsw i32 %mul.i, %i

davidxl wrote:
> CHECKOLD expects a different weight.
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: 
llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext:1
 # IR level Instrumentation Flag
 :ir

davidxl wrote:
> We can convert this test case to cover the new option introduced:
> 
> basically create another profile entry for _Z3fooi  with the old hash. Change 
> the counter value  a little and expect the profile-use match the old entry 
> when the option is used.
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281708.
yamauchi added a comment.

Address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll

Index: llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
===
--- llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
+++ llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll
@@ -1,6 +1,8 @@
 ; RUN: llvm-profdata merge %S/Inputs/multiple_hash_profile.proftext -o %t.profdata
 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata  -S | FileCheck %s
+; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-old-cfg-hashing=true -S | FileCheck %s
 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s
+; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-old-cfg-hashing=true -S | FileCheck %s
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
Index: llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
===
--- llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
+++ llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
@@ -10,7 +10,7 @@
 
 foo
 # Func Hash:
-29212902728
+1720106746050921044
 # Num Counters:
 2
 # Counter Values:
@@ -19,7 +19,7 @@
 
 bar
 # Func Hash:
-1152921534274394772
+1299757151682747028
 # Num Counters:
 2
 # Counter Values:
@@ -45,7 +45,7 @@
 
 main
 # Func Hash:
-12884901887
+1895182923573755903
 # Num Counters:
 1
 # Counter Values:
@@ -53,7 +53,7 @@
 
 cspgo.c:foo
 # Func Hash:
-1152921563228422740

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281673.
yamauchi added a comment.

Rebase past D84865 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext

Index: llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
===
--- llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
+++ llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
@@ -10,7 +10,7 @@
 
 foo
 # Func Hash:
-29212902728
+1720106746050921044
 # Num Counters:
 2
 # Counter Values:
@@ -19,7 +19,7 @@
 
 bar
 # Func Hash:
-1152921534274394772
+1299757151682747028
 # Num Counters:
 2
 # Counter Values:
@@ -45,7 +45,7 @@
 
 main
 # Func Hash:
-12884901887
+1895182923573755903
 # Num Counters:
 1
 # Counter Values:
@@ -53,7 +53,7 @@
 
 cspgo.c:foo
 # Func Hash:
-1152921563228422740
+1720106746050921044
 # Num Counters:
 4
 # Counter Values:
Index: llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
===
--- llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
+++ llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
@@ -2,7 +2,7 @@
 :ir
 :entry_first
 test_switch
-46200943743
+536873293052540031
 4
 10
 5
Index: llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
===
--- llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
+++ llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
@@ -1,7 +1,7 @@
 # :ir is the flag to indicate this is IR level profile.
 :ir
 test_switch
-46200943743
+536873293052540031
 4
 0
 5
Index: llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
===

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

In D84782#2180626 , @davidxl wrote:

> changes like in llvm/test/Transforms/PGOProfile/PR41279.ll etc can be 
> independently committed.

Uploaded D84865  for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:266
+PGOOldCFGHashing("pgo-instr-old-cfg-hashing", cl::init(false), cl::Hidden,
+ cl::desc("Use the old CFG function hashing."));
+

MaskRay wrote:
> Nit: descriptions usually don't end with a period
> 
> (I know that some descriptions in this file are not consistent)
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281626.
yamauchi added a comment.

Address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/PR41279.ll
  llvm/test/Transforms/PGOProfile/PR41279_2.ll
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/memop_size_from_strlen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll

Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -19,7 +19,7 @@
 entry:
 ; GEN: entry:
 ; NOTENTRY-NOT: call void @llvm.instrprof.increment
-; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
+; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 0)
   switch i32 %i, label %sw.default [
 i32 1, label %sw.bb
 i32 2, label %sw.bb1
@@ -31,23 +31,23 @@
 
 sw.bb:
 ; GEN: sw.bb:
-; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
+; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

In D84782#2180578 , @davidxl wrote:

> Can you split out the test changes and commit it separately?

How exactly? Do you mean commit the non-test part without flipping the flag and 
then flip it with the test changes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281426.
yamauchi added a comment.

Rebase (converting one more test) and fixing a typo and whitespace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/PR41279.ll
  llvm/test/Transforms/PGOProfile/PR41279_2.ll
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/memop_size_from_strlen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll

Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -19,7 +19,7 @@
 entry:
 ; GEN: entry:
 ; NOTENTRY-NOT: call void @llvm.instrprof.increment
-; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
+; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 0)
   switch i32 %i, label %sw.default [
 i32 1, label %sw.bb
 i32 2, label %sw.bb1
@@ -31,23 +31,23 @@
 
 sw.bb:
 ; GEN: sw.bb:
-; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
+; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* 

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

In D84782#2180432 , @davidxl wrote:

> On version bump --- looks like FrontPGO has been bumping version for hashing 
> changes while IR PGO had not, so it is ok to leave the version unchanged 
> (current situation is also confusing as the version of IR and FE PGO are 
> mixed).
>
> On the other hand, just in case, we need to introduce a temporary internal 
> option for people to be able to keep on using old profile (with older scheme 
> of hashing) for a while. Basically, under the option, the hashing scheme 
> falls back to the old way.
>
> other than that, looks fine.

Thanks. Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281417.
yamauchi added a comment.

Add a flag to back out to the old hashing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/PR41279.ll
  llvm/test/Transforms/PGOProfile/PR41279_2.ll
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/memop_size_from_strlen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll

Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -19,7 +19,7 @@
 entry:
 ; GEN: entry:
 ; NOTENTRY-NOT: call void @llvm.instrprof.increment
-; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
+; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 0)
   switch i32 %i, label %sw.default [
 i32 1, label %sw.bb
 i32 2, label %sw.bb1
@@ -31,23 +31,23 @@
 
 sw.bb:
 ; GEN: sw.bb:
-; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
+; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 2)
   br label %sw.epilog
 
 

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

> Many tests can also be enhanced to filter out the hash details if they are 
> not part the main test.

Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281407.
yamauchi added a comment.

Shift the higher 32 bits by 28 bits and add.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/PR41279.ll
  llvm/test/Transforms/PGOProfile/PR41279_2.ll
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/memop_size_from_strlen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll

Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -19,7 +19,7 @@
 entry:
 ; GEN: entry:
 ; NOTENTRY-NOT: call void @llvm.instrprof.increment
-; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
+; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 0)
   switch i32 %i, label %sw.default [
 i32 1, label %sw.bb
 i32 2, label %sw.bb1
@@ -31,23 +31,23 @@
 
 sw.bb:
 ; GEN: sw.bb:
-; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
+; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 2)
   br label %sw.epilog
 
 

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:660
   // information.
-  FunctionHash = (uint64_t)SIVisitor.getNumOfSelectInsts() << 56 |
- (uint64_t)ValueSites[IPVK_IndirectCallTarget].size() << 48 |
- //(uint64_t)ValueSites[IPVK_MemOPSize].size() << 40 |
- (uint64_t)MST.AllEdges.size() << 32 | JC.getCRC();
+  FunctionHash = ((uint64_t)JCH.getCRC()) << 32 | JC.getCRC();
+

Actually I think it'd be better to shift by 28 here rather than throwing out 
the top 4 bits for reservation. Also, adding would be better than or'ing. Will 
update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:623
 // Compute Hash value for the CFG: the lower 32 bits are CRC32 of the index
-// value of each BB in the CFG. The higher 32 bits record the number of edges.
+// value of each BB in the CFG. The higher 32 bits are the CR32 of the numbers
+// of selects, indirect calls, mem ops and edges.

MaskRay wrote:
> To make sure I understand: we use two CRCs instead of one CRC because we want 
> to extract low/high 32 bits for debugging purposes?
> 
> Otherwise, we can just use one CRC.
JamCRC's result is 32-bit, but we have 64-bit (actually 60-bits) of spare room. 
Using more bits should decrease the chance of hash collisions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:642
 
   // Hash format for context sensitive profile. Reserve 4 bits for other
   // information.

davidxl wrote:
> The comment looks stale.
I think the 4 bits are still reserved for CSPGO. See 
https://reviews.llvm.org/rG6cdf3d8086fe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281364.
yamauchi added a comment.
Herald added subscribers: cfe-commits, dexonsmith, steven_wu.
Herald added a project: clang.

Use JamCRC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/PR41279.ll
  llvm/test/Transforms/PGOProfile/PR41279_2.ll
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/memop_size_from_strlen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll

Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -19,7 +19,7 @@
 entry:
 ; GEN: entry:
 ; NOTENTRY-NOT: call void @llvm.instrprof.increment
-; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
+; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 519522107823649919, i32 4, i32 0)
   switch i32 %i, label %sw.default [
 i32 1, label %sw.bb
 i32 2, label %sw.bb1
@@ -31,23 +31,23 @@
 
 sw.bb:
 ; GEN: sw.bb:
-; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
+; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, 

[PATCH] D82586: [HIP] Improve check patterns to avoid test failures in case string "opt", etc. happens to be in the command path.

2020-06-25 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9da93f590414: [HIP] Improve check patterns to avoid test 
failures in case string opt, etc. (authored by yamauchi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82586

Files:
  clang/test/Driver/hip-link-save-temps.hip


Index: clang/test/Driver/hip-link-save-temps.hip
===
--- clang/test/Driver/hip-link-save-temps.hip
+++ clang/test/Driver/hip-link-save-temps.hip
@@ -38,9 +38,9 @@
 
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} 
"-outputs=obj1-host-x86_64-unknown-linux-gnu.o,obj1-hip-amdgcn-amd-amdhsa-gfx900.o,obj1-hip-amdgcn-amd-amdhsa-gfx906.o"
 "-unbundle"
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} 
"-outputs=obj2-host-x86_64-unknown-linux-gnu.o,obj2-hip-amdgcn-amd-amdhsa-gfx900.o,obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
 "-unbundle"
-// CHECK-NOT: llvm-link
-// CHECK-NOT: opt
-// CHECK-NOT: llc
+// CHECK-NOT: {{".*/llvm-link"}}
+// CHECK-NOT: {{".*/opt"}}
+// CHECK-NOT: {{".*/llc"}}
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" 
"obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"


Index: clang/test/Driver/hip-link-save-temps.hip
===
--- clang/test/Driver/hip-link-save-temps.hip
+++ clang/test/Driver/hip-link-save-temps.hip
@@ -38,9 +38,9 @@
 
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=obj1-host-x86_64-unknown-linux-gnu.o,obj1-hip-amdgcn-amd-amdhsa-gfx900.o,obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "-unbundle"
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=obj2-host-x86_64-unknown-linux-gnu.o,obj2-hip-amdgcn-amd-amdhsa-gfx900.o,obj2-hip-amdgcn-amd-amdhsa-gfx906.o" "-unbundle"
-// CHECK-NOT: llvm-link
-// CHECK-NOT: opt
-// CHECK-NOT: llc
+// CHECK-NOT: {{".*/llvm-link"}}
+// CHECK-NOT: {{".*/opt"}}
+// CHECK-NOT: {{".*/llc"}}
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" "obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82586: [HIP] Improve check patterns to avoid test failures in case string "opt", etc. happens to be in the command path.

2020-06-25 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi created this revision.
yamauchi added reviewers: arsenm, yaxunl.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

Similarly to D82046 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82586

Files:
  clang/test/Driver/hip-link-save-temps.hip


Index: clang/test/Driver/hip-link-save-temps.hip
===
--- clang/test/Driver/hip-link-save-temps.hip
+++ clang/test/Driver/hip-link-save-temps.hip
@@ -38,9 +38,9 @@
 
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} 
"-outputs=obj1-host-x86_64-unknown-linux-gnu.o,obj1-hip-amdgcn-amd-amdhsa-gfx900.o,obj1-hip-amdgcn-amd-amdhsa-gfx906.o"
 "-unbundle"
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} 
"-outputs=obj2-host-x86_64-unknown-linux-gnu.o,obj2-hip-amdgcn-amd-amdhsa-gfx900.o,obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
 "-unbundle"
-// CHECK-NOT: llvm-link
-// CHECK-NOT: opt
-// CHECK-NOT: llc
+// CHECK-NOT: {{".*/llvm-link"}}
+// CHECK-NOT: {{".*/opt"}}
+// CHECK-NOT: {{".*/llc"}}
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" 
"obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"


Index: clang/test/Driver/hip-link-save-temps.hip
===
--- clang/test/Driver/hip-link-save-temps.hip
+++ clang/test/Driver/hip-link-save-temps.hip
@@ -38,9 +38,9 @@
 
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=obj1-host-x86_64-unknown-linux-gnu.o,obj1-hip-amdgcn-amd-amdhsa-gfx900.o,obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "-unbundle"
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=obj2-host-x86_64-unknown-linux-gnu.o,obj2-hip-amdgcn-amd-amdhsa-gfx900.o,obj2-hip-amdgcn-amd-amdhsa-gfx906.o" "-unbundle"
-// CHECK-NOT: llvm-link
-// CHECK-NOT: opt
-// CHECK-NOT: llc
+// CHECK-NOT: {{".*/llvm-link"}}
+// CHECK-NOT: {{".*/opt"}}
+// CHECK-NOT: {{".*/llc"}}
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" "obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82046: [HIP] Improve check patterns to avoid test failures in case string "opt",etc. happens to be in the InstallDir path in the -### output.

2020-06-18 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce82b8e8af6d: [HIP] Improve check patterns to avoid test 
failures in case string opt, etc. (authored by yamauchi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82046

Files:
  clang/test/Driver/hip-toolchain-no-rdc.hip


Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -154,14 +154,14 @@
 // Link host objects.
 //
 
-// LINK-NOT: llvm-link
-// LINK-NOT: opt
-// LINK-NOT: llc
+// LINK-NOT: {{".*/llvm-link"}}
+// LINK-NOT: {{".*/opt"}}
+// LINK-NOT: {{".*/llc"}}
 // LINK: [[LD:".*ld.*"]] {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
 // LINK-NOT: "-T" "{{.*}}.lk"
 
-// LKONLY-NOT: llvm-link
-// LKONLY-NOT: opt
-// LKONLY-NOT: llc
+// LKONLY-NOT: {{".*/llvm-link"}}
+// LKONLY-NOT: {{".*/opt"}}
+// LKONLY-NOT: {{".*/llc"}}
 // LKONLY: [[LD:".*ld.*"]] {{.*}} "{{.*/a.o}}" "{{.*/b.o}}"
 // LKONLY-NOT: "-T" "{{.*}}.lk"


Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -154,14 +154,14 @@
 // Link host objects.
 //
 
-// LINK-NOT: llvm-link
-// LINK-NOT: opt
-// LINK-NOT: llc
+// LINK-NOT: {{".*/llvm-link"}}
+// LINK-NOT: {{".*/opt"}}
+// LINK-NOT: {{".*/llc"}}
 // LINK: [[LD:".*ld.*"]] {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
 // LINK-NOT: "-T" "{{.*}}.lk"
 
-// LKONLY-NOT: llvm-link
-// LKONLY-NOT: opt
-// LKONLY-NOT: llc
+// LKONLY-NOT: {{".*/llvm-link"}}
+// LKONLY-NOT: {{".*/opt"}}
+// LKONLY-NOT: {{".*/llc"}}
 // LKONLY: [[LD:".*ld.*"]] {{.*}} "{{.*/a.o}}" "{{.*/b.o}}"
 // LKONLY-NOT: "-T" "{{.*}}.lk"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81861: [HIP] Do not use llvm-link/opt/llc for -fgpu-rdc

2020-06-17 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: clang/test/Driver/hip-toolchain-no-rdc.hip:164
+// LKONLY-NOT: llvm-link
+// LKONLY-NOT: opt
+// LKONLY-NOT: llc

yaxunl wrote:
> arsenm wrote:
> > yamauchi wrote:
> > > Hi, this test seems to fail for me because I happen to have the string 
> > > "opt" in the "InstallDir" file path to the clang binary in my 
> > > workstation, like
> > > 
> > > clang version 11.0.0 (https://github.com/llvm/llvm-project.git 
> > > 6bc2b042f4a9e8d912901679bd4614d46f6fafed)
> > > Target: x86_64-unknown-linux-gnu
> > > Thread model: posix
> > > InstalledDir: /opt/llvm-project/build/bin
> > > 
> > > Is there a way for this check pattern to be refined to avoid this issue?
> > I think the negative checks aren't really necessary
> it can be changed to
> 
> // LINK-NOT: {{".*/opt"}}
Uploaded D82046 for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81861



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


[PATCH] D82046: [HIP] Improve check patterns to avoid test failures in case string "opt",etc. happens to be in the InstallDir path in the -### output.

2020-06-17 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

Context: https://reviews.llvm.org/D81861#inline-753520


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82046



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


[PATCH] D82046: [HIP] Improve check patterns to avoid test failures in case string "opt",etc. happens to be in the InstallDir path in the -### output.

2020-06-17 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi created this revision.
yamauchi added a reviewer: yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
yamauchi added a comment.

Context: https://reviews.llvm.org/D81861#inline-753520


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82046

Files:
  clang/test/Driver/hip-toolchain-no-rdc.hip


Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -154,14 +154,14 @@
 // Link host objects.
 //
 
-// LINK-NOT: llvm-link
-// LINK-NOT: opt
-// LINK-NOT: llc
+// LINK-NOT: {{".*/llvm-link"}}
+// LINK-NOT: {{".*/opt"}}
+// LINK-NOT: {{".*/llc"}}
 // LINK: [[LD:".*ld.*"]] {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
 // LINK-NOT: "-T" "{{.*}}.lk"
 
-// LKONLY-NOT: llvm-link
-// LKONLY-NOT: opt
-// LKONLY-NOT: llc
+// LKONLY-NOT: {{".*/llvm-link"}}
+// LKONLY-NOT: {{".*/opt"}}
+// LKONLY-NOT: {{".*/llc"}}
 // LKONLY: [[LD:".*ld.*"]] {{.*}} "{{.*/a.o}}" "{{.*/b.o}}"
 // LKONLY-NOT: "-T" "{{.*}}.lk"


Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -154,14 +154,14 @@
 // Link host objects.
 //
 
-// LINK-NOT: llvm-link
-// LINK-NOT: opt
-// LINK-NOT: llc
+// LINK-NOT: {{".*/llvm-link"}}
+// LINK-NOT: {{".*/opt"}}
+// LINK-NOT: {{".*/llc"}}
 // LINK: [[LD:".*ld.*"]] {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
 // LINK-NOT: "-T" "{{.*}}.lk"
 
-// LKONLY-NOT: llvm-link
-// LKONLY-NOT: opt
-// LKONLY-NOT: llc
+// LKONLY-NOT: {{".*/llvm-link"}}
+// LKONLY-NOT: {{".*/opt"}}
+// LKONLY-NOT: {{".*/llc"}}
 // LKONLY: [[LD:".*ld.*"]] {{.*}} "{{.*/a.o}}" "{{.*/b.o}}"
 // LKONLY-NOT: "-T" "{{.*}}.lk"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81861: [HIP] Do not use llvm-link/opt/llc for -fgpu-rdc

2020-06-16 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: clang/test/Driver/hip-toolchain-no-rdc.hip:164
+// LKONLY-NOT: llvm-link
+// LKONLY-NOT: opt
+// LKONLY-NOT: llc

Hi, this test seems to fail for me because I happen to have the string "opt" in 
the "InstallDir" file path to the clang binary in my workstation, like

clang version 11.0.0 (https://github.com/llvm/llvm-project.git 
6bc2b042f4a9e8d912901679bd4614d46f6fafed)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/llvm-project/build/bin

Is there a way for this check pattern to be refined to avoid this issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81861



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


[PATCH] D69591: Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.

2020-02-27 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

Here's a fix: https://reviews.llvm.org/D75307


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69591



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


[PATCH] D69591: Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.

2020-02-27 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

This was reverted due to some internal compilation crashes as 
https://github.com/llvm/llvm-project/commit/4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69591



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


[PATCH] D69591: Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.

2020-02-26 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi closed this revision.
yamauchi added a comment.

Committed as https://reviews.llvm.org/rG59fb9cde7a4a


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69591



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


[PATCH] D69591: Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.

2020-02-11 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 243911.
yamauchi added a comment.

Rebase past D71308 . PTAL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69591

Files:
  clang/test/CodeGenCXX/member-function-pointer-calls.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Transforms/Inline/devirtualize-4.ll

Index: llvm/test/Transforms/Inline/devirtualize-4.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/devirtualize-4.ll
@@ -0,0 +1,214 @@
+; RUN: opt < %s -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' -S | FileCheck %s
+; RUN: opt < %s -passes='default' -S | FileCheck %s
+
+; Check that DoNotOptimize is inlined into Test.
+; CHECK: @_Z4Testv()
+; CHECK-NOT: ret void
+; CHECK: call void asm
+; CHECK: ret void
+
+;template 
+;void DoNotOptimize(const T& var) {
+;  asm volatile("" : "+m"(const_cast(var)));
+;}
+;
+;class Interface {
+; public:
+;  virtual void Run() = 0;
+;};
+;
+;class Impl : public Interface {
+; public:
+;  Impl() : f(3) {}
+;  void Run() { DoNotOptimize(this); }
+;
+; private:
+;  int f;
+;};
+;
+;static void IndirectRun(Interface& o) { o.Run(); }
+;
+;void Test() {
+;  Impl o;
+;  IndirectRun(o);
+;}
+
+%class.Impl = type <{ %class.Interface, i32, [4 x i8] }>
+%class.Interface = type { i32 (...)** }
+
+@_ZTV4Impl = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI4Impl to i8*), i8* bitcast (void (%class.Impl*)* @_ZN4Impl3RunEv to i8*)] }, align 8
+@_ZTVN10__cxxabiv120__si_class_type_infoE = external dso_local global i8*
+@_ZTS4Impl = linkonce_odr dso_local constant [6 x i8] c"4Impl\00", align 1
+@_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global i8*
+@_ZTS9Interface = linkonce_odr dso_local constant [11 x i8] c"9Interface\00", align 1
+@_ZTI9Interface = linkonce_odr dso_local constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @_ZTS9Interface, i32 0, i32 0) }, align 8
+@_ZTI4Impl = linkonce_odr dso_local constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @_ZTS4Impl, i32 0, i32 0), i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*) }, align 8
+@_ZTV9Interface = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*)] }, align 8
+
+define dso_local void @_Z4Testv() local_unnamed_addr {
+entry:
+  %o = alloca %class.Impl, align 8
+  %0 = bitcast %class.Impl* %o to i8*
+  call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %0)
+  call void @_ZN4ImplC2Ev(%class.Impl* nonnull %o)
+  %1 = getelementptr inbounds %class.Impl, %class.Impl* %o, i64 0, i32 0
+  call fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* nonnull dereferenceable(8) %1)
+  call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %0)
+  ret void
+}
+
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
+
+define linkonce_odr dso_local void @_ZN4ImplC2Ev(%class.Impl* %this) unnamed_addr align 2 {
+entry:
+  %0 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0
+  call void @_ZN9InterfaceC2Ev(%class.Interface* %0)
+  %1 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0, i32 0
+  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV4Impl, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %1, align 8
+  %f = getelementptr inbounds %class.Impl, %class.Impl* %this, i64 0, i32 1
+  store i32 3, i32* %f, align 8
+  ret void
+}
+
+define internal fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* dereferenceable(8) %o) unnamed_addr {
+entry:
+  %0 = bitcast %class.Interface* %o to void (%class.Interface*)***
+  %vtable = load void (%class.Interface*)**, void (%class.Interface*)*** %0, align 8
+  %1 = load void (%class.Interface*)*, void (%class.Interface*)** %vtable, align 8
+  call void %1(%class.Interface* nonnull %o)
+  ret void
+}
+
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
+
+define linkonce_odr dso_local void @_ZN9InterfaceC2Ev(%class.Interface* %this) unnamed_addr align 2 {
+entry:
+  %0 = getelementptr %class.Interface, %class.Interface* %this, i64 0, i32 0
+  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV9Interface, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8
+  ret void
+}
+
+define linkonce_odr dso_local void @_ZN4Impl3RunEv(%class.Impl* %this) unnamed_addr align 2 {
+entry:
+  %ref.tmp = alloca %class.Impl*, align 8
+  %0 = bitcast %class.Impl** %ref.tmp to i8*

[PATCH] D69591: Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.

2020-02-03 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 242103.
yamauchi added a comment.

Fix typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69591

Files:
  clang/test/CodeGenCXX/member-function-pointer-calls.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Transforms/Inline/devirtualize-4.ll

Index: llvm/test/Transforms/Inline/devirtualize-4.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/devirtualize-4.ll
@@ -0,0 +1,214 @@
+; RUN: opt < %s -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' -S | FileCheck %s
+; RUN: opt < %s -passes='default' -S | FileCheck %s
+
+; Check that DoNotOptimize is inlined into Test.
+; CHECK: @_Z4Testv()
+; CHECK-NOT: ret void
+; CHECK: call void asm
+; CHECK: ret void
+
+;template 
+;void DoNotOptimize(const T& var) {
+;  asm volatile("" : "+m"(const_cast(var)));
+;}
+;
+;class Interface {
+; public:
+;  virtual void Run() = 0;
+;};
+;
+;class Impl : public Interface {
+; public:
+;  Impl() : f(3) {}
+;  void Run() { DoNotOptimize(this); }
+;
+; private:
+;  int f;
+;};
+;
+;static void IndirectRun(Interface& o) { o.Run(); }
+;
+;void Test() {
+;  Impl o;
+;  IndirectRun(o);
+;}
+
+%class.Impl = type <{ %class.Interface, i32, [4 x i8] }>
+%class.Interface = type { i32 (...)** }
+
+@_ZTV4Impl = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI4Impl to i8*), i8* bitcast (void (%class.Impl*)* @_ZN4Impl3RunEv to i8*)] }, align 8
+@_ZTVN10__cxxabiv120__si_class_type_infoE = external dso_local global i8*
+@_ZTS4Impl = linkonce_odr dso_local constant [6 x i8] c"4Impl\00", align 1
+@_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global i8*
+@_ZTS9Interface = linkonce_odr dso_local constant [11 x i8] c"9Interface\00", align 1
+@_ZTI9Interface = linkonce_odr dso_local constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @_ZTS9Interface, i32 0, i32 0) }, align 8
+@_ZTI4Impl = linkonce_odr dso_local constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @_ZTS4Impl, i32 0, i32 0), i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*) }, align 8
+@_ZTV9Interface = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*)] }, align 8
+
+define dso_local void @_Z4Testv() local_unnamed_addr {
+entry:
+  %o = alloca %class.Impl, align 8
+  %0 = bitcast %class.Impl* %o to i8*
+  call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %0)
+  call void @_ZN4ImplC2Ev(%class.Impl* nonnull %o)
+  %1 = getelementptr inbounds %class.Impl, %class.Impl* %o, i64 0, i32 0
+  call fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* nonnull dereferenceable(8) %1)
+  call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %0)
+  ret void
+}
+
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
+
+define linkonce_odr dso_local void @_ZN4ImplC2Ev(%class.Impl* %this) unnamed_addr align 2 {
+entry:
+  %0 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0
+  call void @_ZN9InterfaceC2Ev(%class.Interface* %0)
+  %1 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0, i32 0
+  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV4Impl, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %1, align 8
+  %f = getelementptr inbounds %class.Impl, %class.Impl* %this, i64 0, i32 1
+  store i32 3, i32* %f, align 8
+  ret void
+}
+
+define internal fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* dereferenceable(8) %o) unnamed_addr {
+entry:
+  %0 = bitcast %class.Interface* %o to void (%class.Interface*)***
+  %vtable = load void (%class.Interface*)**, void (%class.Interface*)*** %0, align 8
+  %1 = load void (%class.Interface*)*, void (%class.Interface*)** %vtable, align 8
+  call void %1(%class.Interface* nonnull %o)
+  ret void
+}
+
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
+
+define linkonce_odr dso_local void @_ZN9InterfaceC2Ev(%class.Interface* %this) unnamed_addr align 2 {
+entry:
+  %0 = getelementptr %class.Interface, %class.Interface* %this, i64 0, i32 0
+  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV9Interface, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8
+  ret void
+}
+
+define linkonce_odr dso_local void @_ZN4Impl3RunEv(%class.Impl* %this) unnamed_addr align 2 {
+entry:
+  %ref.tmp = alloca %class.Impl*, align 8
+  %0 = bitcast %class.Impl** %ref.tmp to i8*
+  call void @llvm.lifetime.start.p0i8(i64 8, i8* 

[PATCH] D69591: Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.

2020-01-31 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 241852.
yamauchi added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update clang/test/CodeGenCXX/member-function-pointer-calls.cpp which this change
combined with D71308  enables 
inlining/simplification.

Add a new test that's derived from
clang/test/CodeGenCXX/member-function-pointer-calls.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69591

Files:
  clang/test/CodeGenCXX/member-function-pointer-calls.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Transforms/Inline/devirtualize-4.ll

Index: llvm/test/Transforms/Inline/devirtualize-4.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/devirtualize-4.ll
@@ -0,0 +1,214 @@
+; RUN: opt < %s -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' -S | FileCheck %s
+; UN: opt < %s -passes='default' -S | FileCheck %s
+
+; Check that DoNotOptimize is inlined into Test.
+; CHECK: @_Z4Testv()
+; CHECK-NOT: ret void
+; CHECK: call void asm
+; CHECK: ret void
+
+;template 
+;void DoNotOptimize(const T& var) {
+;  asm volatile("" : "+m"(const_cast(var)));
+;}
+;
+;class Interface {
+; public:
+;  virtual void Run() = 0;
+;};
+;
+;class Impl : public Interface {
+; public:
+;  Impl() : f(3) {}
+;  void Run() { DoNotOptimize(this); }
+;
+; private:
+;  int f;
+;};
+;
+;static void IndirectRun(Interface& o) { o.Run(); }
+;
+;void Test() {
+;  Impl o;
+;  IndirectRun(o);
+;}
+
+%class.Impl = type <{ %class.Interface, i32, [4 x i8] }>
+%class.Interface = type { i32 (...)** }
+
+@_ZTV4Impl = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI4Impl to i8*), i8* bitcast (void (%class.Impl*)* @_ZN4Impl3RunEv to i8*)] }, align 8
+@_ZTVN10__cxxabiv120__si_class_type_infoE = external dso_local global i8*
+@_ZTS4Impl = linkonce_odr dso_local constant [6 x i8] c"4Impl\00", align 1
+@_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global i8*
+@_ZTS9Interface = linkonce_odr dso_local constant [11 x i8] c"9Interface\00", align 1
+@_ZTI9Interface = linkonce_odr dso_local constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @_ZTS9Interface, i32 0, i32 0) }, align 8
+@_ZTI4Impl = linkonce_odr dso_local constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @_ZTS4Impl, i32 0, i32 0), i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*) }, align 8
+@_ZTV9Interface = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*)] }, align 8
+
+define dso_local void @_Z4Testv() local_unnamed_addr {
+entry:
+  %o = alloca %class.Impl, align 8
+  %0 = bitcast %class.Impl* %o to i8*
+  call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %0)
+  call void @_ZN4ImplC2Ev(%class.Impl* nonnull %o)
+  %1 = getelementptr inbounds %class.Impl, %class.Impl* %o, i64 0, i32 0
+  call fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* nonnull dereferenceable(8) %1)
+  call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %0)
+  ret void
+}
+
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
+
+define linkonce_odr dso_local void @_ZN4ImplC2Ev(%class.Impl* %this) unnamed_addr align 2 {
+entry:
+  %0 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0
+  call void @_ZN9InterfaceC2Ev(%class.Interface* %0)
+  %1 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0, i32 0
+  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV4Impl, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %1, align 8
+  %f = getelementptr inbounds %class.Impl, %class.Impl* %this, i64 0, i32 1
+  store i32 3, i32* %f, align 8
+  ret void
+}
+
+define internal fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* dereferenceable(8) %o) unnamed_addr {
+entry:
+  %0 = bitcast %class.Interface* %o to void (%class.Interface*)***
+  %vtable = load void (%class.Interface*)**, void (%class.Interface*)*** %0, align 8
+  %1 = load void (%class.Interface*)*, void (%class.Interface*)** %vtable, align 8
+  call void %1(%class.Interface* nonnull %o)
+  ret void
+}
+
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
+
+define linkonce_odr dso_local void @_ZN9InterfaceC2Ev(%class.Interface* %this) unnamed_addr align 2 {
+entry:
+  %0 = getelementptr %class.Interface, %class.Interface* %this, i64 0, i32 0
+  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV9Interface, i64 0, 

[PATCH] D66711: [clang] Warning for non-final classes with final destructors

2019-08-27 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi accepted this revision.
yamauchi added a comment.

LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66711



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


[PATCH] D66621: [clang] Devirtualization for classes with destructors marked as 'final'

2019-08-23 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

Nice.

In D66621#1642142 , @rsmith wrote:

> This seems subtle, but I believe it is correct.
>
> I wonder whether we should provide a warning for a non-final class has a 
> final destructor, since moving the `final` from the destructor to the class 
> seems like a more obvious way to present the code (and will likely lead to 
> better code generation in compilers that haven't realized they can do this).


Richard, do you think there may be some missed devirtualization optimizations 
that would trigger if the class, rather than the destructor, is declared final 
in Clang? It seems this patch would take care of common call devirtualizations.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66621



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


[PATCH] D65975: [NewPM][PassInstrumentation] IR printing support from clang driver

2019-08-09 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

In D65975#1621892 , @twoh wrote:

> @fedor.sergeev @yamauchi I saw your discussions over llvm-dev mailing list 
> regarding IR printing with the new pass manager, and though this might be the 
> reason why IR printing is not supported under new PM with clang. I would 
> appreciate if you can take a look.


I tested it and it works for me. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65975



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


[PATCH] D63161: Devirtualize destructor of final class.

2019-07-09 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

Recommitted as https://reviews.llvm.org/rL365509


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63161



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


[PATCH] D63161: Devirtualize destructor of final class.

2019-07-08 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

This was reverted due to some internal test failure. But it turned out a false 
alarm. I'll work on recommitting it.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63161



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


[PATCH] D63161: Devirtualize destructor of final class.

2019-06-21 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL364100: Devirtualize destructor of final class. (authored by 
yamauchi, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63161

Files:
  cfe/trunk/lib/CodeGen/CGExprCXX.cpp
  cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp


Index: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,33 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (declaresSameEntity(getCXXRecord(Base), DevirtualizedClass)) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual call. FIXME: handle the case where it is
+// devirtualized to the derived type (the type of the inner
+// expression) as in EmitCXXMemberOrOperatorMemberCallExpr.
+UseVirtualCall = true;
+  }
+}
+if (UseVirtualCall) {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, 
ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }
Index: cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
+++ cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  struct D { virtual ~D() final = 0; };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
+  void evil(D *p) {
+// CHECK-NOT: call void @_ZN5Test11DD1Ev
+delete p;
+  }
+}


Index: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,33 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (declaresSameEntity(getCXXRecord(Base), DevirtualizedClass)) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual call. FIXME: handle the case where it is
+// devirtualized to the derived type (the type of the inner
+// expression) as in EmitCXXMemberOrOperatorMemberCallExpr.
+UseVirtualCall = true;
+  }
+}
+if (UseVirtualCall) {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }
Index: 

[PATCH] D63161: Devirtualize destructor of final class.

2019-06-21 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 206053.
yamauchi marked 2 inline comments as done.
yamauchi added a comment.

Comments addressed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63161

Files:
  lib/CodeGen/CGExprCXX.cpp
  test/CodeGenCXX/devirtualize-dtor-final.cpp


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  struct D { virtual ~D() final = 0; };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
+  void evil(D *p) {
+// CHECK-NOT: call void @_ZN5Test11DD1Ev
+delete p;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,33 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (declaresSameEntity(getCXXRecord(Base), DevirtualizedClass)) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual call. FIXME: handle the case where it is
+// devirtualized to the derived type (the type of the inner
+// expression) as in EmitCXXMemberOrOperatorMemberCallExpr.
+UseVirtualCall = true;
+  }
+}
+if (UseVirtualCall) {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, 
ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - | FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  struct D { virtual ~D() final = 0; };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
+  void evil(D *p) {
+// CHECK-NOT: call void @_ZN5Test11DD1Ev
+delete p;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,33 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (declaresSameEntity(getCXXRecord(Base), DevirtualizedClass)) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// 

[PATCH] D63161: Devirtualize destructor of final class.

2019-06-18 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 205381.
yamauchi added a comment.

Updated.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63161

Files:
  lib/CodeGen/CGExprCXX.cpp
  test/CodeGenCXX/devirtualize-dtor-final.cpp


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  struct D { virtual ~D() final = 0; };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
+  void evil(D *p) {
+// CHECK-NOT: call void@_ZN5Test11DD1Ev
+delete p;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,33 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (getCXXRecord(Base) == DevirtualizedClass) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual call. FIXME: handle the case where it is
+// devirtualized to the derived type (the type of the inner
+// expression) as in EmitCXXMemberOrOperatorMemberCallExpr.
+UseVirtualCall = true;
+  }
+}
+if (UseVirtualCall) {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, 
ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - | FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  struct D { virtual ~D() final = 0; };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
+  void evil(D *p) {
+// CHECK-NOT: call void@_ZN5Test11DD1Ev
+delete p;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,33 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (getCXXRecord(Base) == DevirtualizedClass) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual 

[PATCH] D63161: Devirtualize destructor of final class.

2019-06-17 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi marked 2 inline comments as done.
yamauchi added inline comments.



Comment at: lib/CodeGen/CGExprCXX.cpp:1887
+Dtor = DevirtualizedDtor;
+Ptr = CGF.EmitPointerWithAlignment(Inner);
+  } else {

rsmith wrote:
> In this case we'll emit the inner expression (including its side-effects) 
> twice.
> 
> The simplest thing to do would be to just drop this `else if` case for now 
> and add a FIXME.
I'd go with that. I assume there isn't a simple way to adjust the this pointer 
of a base class given a derived class? Sort of like 
CodeGenFunction::GetAddressOfDerivedClass?



Repository:
  rC Clang

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

https://reviews.llvm.org/D63161



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


[PATCH] D63161: Devirtualize destructor of final class.

2019-06-14 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi marked an inline comment as done.
yamauchi added inline comments.



Comment at: lib/CodeGen/CGExprCXX.cpp:1871
+ CGF.CGM.getLangOpts().AppleKext)))
+  Dtor = DevirtualizedDtor;
+else {

rsmith wrote:
> `Dtor` could be the destructor for a type derived from `ElementPtr`. We'll 
> either need to somehow emit a cast to the correct derived type here, or just 
> abort the devirtualization and emit a virtual call in that case. (The latter 
> is what `EmitCXXMemberOrOperatorMemberCallExpr` does -- see its checks on 
> `getCXXRecord(Base)` and `getCXXRecord(Inner)`.)
> 
> Eg, for:
> 
> ```
> struct SomethingElse { virtual void f(); };
> struct A {
>   virtual ~A();
> };
> struct B : SomethingElse, A {
>   ~B() final;
> };
> void f(B *p) {
>   delete (A*)p;
> }
> ```
> 
> ... `Ptr` will be a pointer to an `A` subobject of a `B` object, but 
> `getDevirtualizedMethod` will still be able to work out that `B::~B` is the 
> right thing to call here (by looking through the cast and finding that the 
> pointer must actually point to a `B` object whose destructor is `final`). We 
> need to either convert `Ptr` back from an `A*` to a `B*` or just not 
> devirtualize this call.
Should be good now.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63161



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


[PATCH] D63161: Devirtualize destructor of final class.

2019-06-14 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 204852.
yamauchi marked an inline comment as done.
yamauchi added a comment.

Addressed comment.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63161

Files:
  lib/CodeGen/CGExprCXX.cpp
  test/CodeGenCXX/devirtualize-dtor-final.cpp


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+}
+
+namespace Test2 {
+  struct SomethingElse { virtual void f(); };
+  struct A { virtual ~A() {} };
+  struct B final : SomethingElse, A {};
+  struct C : SomethingElse, A { virtual ~C() final {} };
+  // CHECK-LABEL: define void @_ZN5Test23fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test21BD1Ev
+delete (A*)b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test24foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test21CD1Ev
+delete (A*)c;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,38 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  const Expr *Inner = Base->ignoreParenBaseCasts();
+  if (getCXXRecord(Base) == DevirtualizedClass) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else if (getCXXRecord(Inner) == DevirtualizedClass) {
+// Devirtualized to the class of the derived type (the type of the
+// expression inside derived-to-base casts). We need to adjust the
+// this pointer to that type.
+Dtor = DevirtualizedDtor;
+Ptr = CGF.EmitPointerWithAlignment(Inner);
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual call.
+UseVirtualCall = true;
+  }
+}
+if (UseVirtualCall) {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, 
ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - | FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+}
+
+namespace Test2 {
+  struct SomethingElse { virtual void f(); };
+  struct A { virtual ~A() {} };
+  struct B final : SomethingElse, A {};
+  struct C : SomethingElse, A { virtual ~C() final {} };
+  // CHECK-LABEL: define void @_ZN5Test23fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test21BD1Ev
+delete (A*)b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test24foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test21CD1Ev
+delete (A*)c;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,38 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-  

[PATCH] D63161: Devirtualize destructor of final class.

2019-06-12 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi marked 2 inline comments as done.
yamauchi added inline comments.



Comment at: lib/CodeGen/CGExprCXX.cpp:1867-1868
 
-  if (Dtor->isVirtual()) {
+  if (Dtor->isVirtual() &&
+  !(Dtor->hasAttr() || RD->hasAttr())) {
 CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,

rsmith wrote:
> Can we use `getDevirtualizedMethod` here instead? That catches a few other 
> cases that just checking for `final` will miss, and disables this for cases 
> where it will currently do the wrong thing (eg, `-fapple-kext`). See 
> `EmitCXXMemberOrOperatorMemberCallExpr` for where we do this for other 
> virtual calls.
> 
> As a particularly terrible example:
> 
> ```
> struct A { virtual ~A() final = 0; };
> void evil(A *p) { delete p; }
> ```
> 
> is (amazingly) valid, and must not be devirtualized because there is no 
> requirement that the destructor of `A` have a definition in this program. (It 
> would, however, be correct to optimize out the entire `delete` expression in 
> this case, on the basis that `p` must always be `nullptr` whenever it's 
> reached. But that doesn't really seem worthwhile.)
Updated. Hopefully this does the right thing.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63161



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


[PATCH] D63161: Devirtualize destructor of final class.

2019-06-12 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 204365.
yamauchi added a comment.

Using getDevirtualizedMethod.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63161

Files:
  lib/CodeGen/CGExprCXX.cpp
  test/CodeGenCXX/devirtualize-dtor-final.cpp


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : public A {};
+  struct C : public A { virtual ~C() final {} };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,15 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+if (auto *DevirtualizedDtor = dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(DE->getArgument(),
+ CGF.CGM.getLangOpts().AppleKext)))
+  Dtor = DevirtualizedDtor;
+else {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, 
ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - | FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : public A {};
+  struct C : public A { virtual ~C() final {} };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,15 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+if (auto *DevirtualizedDtor = dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(DE->getArgument(),
+ CGF.CGM.getLangOpts().AppleKext)))
+  Dtor = DevirtualizedDtor;
+else {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63161: Devirtualize destructor of final class.

2019-06-11 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi created this revision.
yamauchi added a reviewer: davidxl.
Herald added a subscriber: Prazek.
Herald added a project: clang.

Take advantage of the final keyword to devirtualize destructor calls.

Fix https://bugs.llvm.org/show_bug.cgi?id=21368


Repository:
  rC Clang

https://reviews.llvm.org/D63161

Files:
  lib/CodeGen/CGExprCXX.cpp
  test/CodeGenCXX/devirtualize-dtor-final.cpp


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : public A {};
+  struct C : public A { virtual ~C() final {} };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1864,7 +1864,8 @@
 if (RD->hasDefinition() && !RD->hasTrivialDestructor()) {
   Dtor = RD->getDestructor();
 
-  if (Dtor->isVirtual()) {
+  if (Dtor->isVirtual() &&
+  !(Dtor->hasAttr() || RD->hasAttr())) {
 CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
 Dtor);
 return;


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - | FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : public A {};
+  struct C : public A { virtual ~C() final {} };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1864,7 +1864,8 @@
 if (RD->hasDefinition() && !RD->hasTrivialDestructor()) {
   Dtor = RD->getDestructor();
 
-  if (Dtor->isVirtual()) {
+  if (Dtor->isVirtual() &&
+  !(Dtor->hasAttr() || RD->hasAttr())) {
 CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
 Dtor);
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits