[PATCH] D114268: [InstrProf] Use i32 for GEP index from lowering llvm.instrprof.increment

2021-11-19 Thread Kyungwoo Lee 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 rGde11de308b64: [InstrProf] Use i32 for GEP index from 
lowering llvm.instrprof.increment (authored by ellis, committed by kyulee).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114268

Files:
  clang/test/CodeGen/profile-filter.c
  clang/test/Profile/branch-logical-mixed.cpp
  clang/test/Profile/c-captured.c
  clang/test/Profile/c-general.c
  clang/test/Profile/c-ternary.c
  clang/test/Profile/cxx-class.cpp
  clang/test/Profile/cxx-lambda.cpp
  clang/test/Profile/cxx-rangefor.cpp
  clang/test/Profile/cxx-stmt-initializers.cpp
  clang/test/Profile/cxx-templates.cpp
  clang/test/Profile/cxx-throws.cpp
  clang/test/Profile/objc-general.m
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll
  llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
  llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll

Index: llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
===
--- llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
+++ llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
@@ -18,7 +18,7 @@
 ; GEN: entry:
 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_2, i32 0, i32 0), i64 {{[0-9]+}}, i32 2, i32 0)
 ; GENA: entry:
-; GENA: %{{[0-9+]}} = atomicrmw add i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i64 0, i64 0), i64 1 monotonic
+; GENA: %{{[0-9+]}} = atomicrmw add i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i32 0, i32 0), i64 1 monotonic
 ; USE: br i1 %cmp, label %if.then, label %if.else
 ; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]
 ; USE: ![[BW_ENTRY]] = !{!"branch_weights", i32 0, i32 1}
@@ -35,9 +35,9 @@
 ; GEN: if.else:
 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_2, i32 0, i32 0), i64 {{[0-9]+}}, i32 2, i32 1)
 ; GENA: if.else:
-; GENA:  %pgocount = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i64 0, i64 1), align 8
+; GENA:  %pgocount = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i32 0, i32 1), align 8
 ; GENA:  [[V:%[0-9]*]] = add i64 %pgocount, 1
-; GENA:  store i64 [[V]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i64 0, i64 1), align 8
+; GENA:  store i64 [[V]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i32 0, i32 1), align 8
   %sub = sub nsw i32 %i, 2
   br label %if.end
 
Index: llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
===
--- llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
+++ llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
@@ -38,11 +38,11 @@
 
 for.body: ; preds = %for.cond
 ; CHECK: for.body:
-; NOTENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 0)
-; TENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1)
+; NOTENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 0)
+; TENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 1)
 ; CHECK: %1 = add i64 %pgocount1, 1
-; NOTENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 0)
-; ENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1)
+; NOTENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 0)
+; ENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 1)
   %idxprom = zext i32 %i.0 to i64
   %arrayidx = getelementptr inbounds [200 x i8], [200 x i8]* @"?buffer@@3PADA", i64 0, i64 %idxprom
   %0 = load i8, i8* %arrayidx, align 1
@@ -55,11 +55,11 @@
 
 for.inc:  ; preds = %if.end
 ; CHECK: for.inc:
-; NOTENTRY: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1)
-; ENTRY: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 2)
+; NOTENTRY: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 1)
+; ENTRY: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* 

[PATCH] D114268: [InstrProf] Use i32 for GEP index from lowering llvm.instrprof.increment

2021-11-19 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 388652.
ellis added a comment.

Remove register names


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114268

Files:
  clang/test/CodeGen/profile-filter.c
  clang/test/Profile/branch-logical-mixed.cpp
  clang/test/Profile/c-captured.c
  clang/test/Profile/c-general.c
  clang/test/Profile/c-ternary.c
  clang/test/Profile/cxx-class.cpp
  clang/test/Profile/cxx-lambda.cpp
  clang/test/Profile/cxx-rangefor.cpp
  clang/test/Profile/cxx-stmt-initializers.cpp
  clang/test/Profile/cxx-templates.cpp
  clang/test/Profile/cxx-throws.cpp
  clang/test/Profile/objc-general.m
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll
  llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
  llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll

Index: llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
===
--- llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
+++ llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
@@ -18,7 +18,7 @@
 ; GEN: entry:
 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_2, i32 0, i32 0), i64 {{[0-9]+}}, i32 2, i32 0)
 ; GENA: entry:
-; GENA: %{{[0-9+]}} = atomicrmw add i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i64 0, i64 0), i64 1 monotonic
+; GENA: %{{[0-9+]}} = atomicrmw add i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i32 0, i32 0), i64 1 monotonic
 ; USE: br i1 %cmp, label %if.then, label %if.else
 ; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]
 ; USE: ![[BW_ENTRY]] = !{!"branch_weights", i32 0, i32 1}
@@ -35,9 +35,9 @@
 ; GEN: if.else:
 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_2, i32 0, i32 0), i64 {{[0-9]+}}, i32 2, i32 1)
 ; GENA: if.else:
-; GENA:  %pgocount = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i64 0, i64 1), align 8
+; GENA:  %pgocount = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i32 0, i32 1), align 8
 ; GENA:  [[V:%[0-9]*]] = add i64 %pgocount, 1
-; GENA:  store i64 [[V]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i64 0, i64 1), align 8
+; GENA:  store i64 [[V]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i32 0, i32 1), align 8
   %sub = sub nsw i32 %i, 2
   br label %if.end
 
Index: llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
===
--- llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
+++ llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
@@ -38,11 +38,11 @@
 
 for.body: ; preds = %for.cond
 ; CHECK: for.body:
-; NOTENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 0)
-; TENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1)
+; NOTENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 0)
+; TENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 1)
 ; CHECK: %1 = add i64 %pgocount1, 1
-; NOTENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 0)
-; ENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1)
+; NOTENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 0)
+; ENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 1)
   %idxprom = zext i32 %i.0 to i64
   %arrayidx = getelementptr inbounds [200 x i8], [200 x i8]* @"?buffer@@3PADA", i64 0, i64 %idxprom
   %0 = load i8, i8* %arrayidx, align 1
@@ -55,11 +55,11 @@
 
 for.inc:  ; preds = %if.end
 ; CHECK: for.inc:
-; NOTENTRY: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1)
-; ENTRY: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 2)
+; NOTENTRY: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 1)
+; ENTRY: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 2)
 ; CHECK: %3 = add i64 %pgocount2, 1
-; NOTENTRY: store i64 %3, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 

[PATCH] D114268: [InstrProf] Use i32 for GEP index from lowering llvm.instrprof.increment

2021-11-19 Thread Ellis Hoag via Phabricator via cfe-commits
ellis added a comment.

In D114268#3143976 , @MaskRay wrote:

>> Add names to pgo registers for clarity.
>
> This may increase memory usage, especially for large LTO applications. Unless 
> this is very helpful I might omit it.

I'll omit it. Thanks for the quick review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114268

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


[PATCH] D114268: [InstrProf] Use i32 for GEP index from lowering llvm.instrprof.increment

2021-11-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

> Add names to pgo registers for clarity.

This may increase memory usage. Unless this is very helpful I might omit it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114268

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


[PATCH] D114268: [InstrProf] Use i32 for GEP index from lowering llvm.instrprof.increment

2021-11-19 Thread Ellis Hoag via Phabricator via cfe-commits
ellis created this revision.
Herald added subscribers: wenlei, arphaman, hiraditya.
ellis updated this revision to Diff 388564.
ellis added a comment.
ellis edited the summary of this revision.
ellis added a reviewer: MaskRay.
ellis retitled this revision from "[InstrProf] Use i32 for GEP index" to 
"[InstrProf] Use i32 for GEP index from lowering llvm.instrprof.increment".
ellis published this revision for review.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Run `clang-format`.


The `llvm.instrprof.increment` intrinsic uses `i32` for the index. We should 
use this same type for the index into the GEP instructions.

Add names to pgo registers for clarity.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114268

Files:
  clang/test/CodeGen/profile-filter.c
  clang/test/Profile/branch-logical-mixed.cpp
  clang/test/Profile/c-captured.c
  clang/test/Profile/c-general.c
  clang/test/Profile/c-ternary.c
  clang/test/Profile/cxx-class.cpp
  clang/test/Profile/cxx-lambda.cpp
  clang/test/Profile/cxx-rangefor.cpp
  clang/test/Profile/cxx-stmt-initializers.cpp
  clang/test/Profile/cxx-templates.cpp
  clang/test/Profile/cxx-throws.cpp
  clang/test/Profile/objc-general.m
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll
  llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
  llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll

Index: llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
===
--- llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
+++ llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
@@ -18,7 +18,7 @@
 ; GEN: entry:
 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_2, i32 0, i32 0), i64 {{[0-9]+}}, i32 2, i32 0)
 ; GENA: entry:
-; GENA: %{{[0-9+]}} = atomicrmw add i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i64 0, i64 0), i64 1 monotonic
+; GENA: %{{[0-9+]}} = atomicrmw add i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i32 0, i32 0), i64 1 monotonic
 ; USE: br i1 %cmp, label %if.then, label %if.else
 ; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]
 ; USE: ![[BW_ENTRY]] = !{!"branch_weights", i32 0, i32 1}
@@ -35,9 +35,9 @@
 ; GEN: if.else:
 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_2, i32 0, i32 0), i64 {{[0-9]+}}, i32 2, i32 1)
 ; GENA: if.else:
-; GENA:  %pgocount = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i64 0, i64 1), align 8
+; GENA:  %pgocount = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i32 0, i32 1), align 8
 ; GENA:  [[V:%[0-9]*]] = add i64 %pgocount, 1
-; GENA:  store i64 [[V]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i64 0, i64 1), align 8
+; GENA:  store i64 [[V]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_test_br_2, i32 0, i32 1), align 8
   %sub = sub nsw i32 %i, 2
   br label %if.end
 
Index: llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
===
--- llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
+++ llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll
@@ -38,11 +38,11 @@
 
 for.body: ; preds = %for.cond
 ; CHECK: for.body:
-; NOTENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 0)
-; TENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1)
+; NOTENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 0)
+; TENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 1)
 ; CHECK: %1 = add i64 %pgocount1, 1
-; NOTENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 0)
-; ENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1)
+; NOTENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 0)
+; ENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i32 0, i32 1)
   %idxprom = zext i32 %i.0 to i64
   %arrayidx = getelementptr inbounds [200 x i8], [200 x i8]* @"?buffer@@3PADA", i64 0, i64 %idxprom
   %0 = load i8, i8* %arrayidx, align 1
@@ -55,11 +55,11 @@
 
 for.inc:  ; preds = %if.end
 ; CHECK: for.inc:
-; NOTENTRY: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]*