[PATCH] D90539: Make CallInst::updateProfWeight emit i32 weights instead of i64

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 31 12:43:43 PDT 2020


aeubanks created this revision.
aeubanks added reviewers: asbirlea, ychen.
Herald added subscribers: llvm-commits, dexonsmith, wenlei, hiraditya.
Herald added a project: LLVM.
aeubanks requested review of this revision.

Typically branch_weights are i32, not i64.
This fixes entry_counts_cold.ll under NPM.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90539

Files:
  llvm/lib/IR/Instructions.cpp
  llvm/test/Transforms/Inline/prof-update-sample-alwaysinline.ll
  llvm/test/Transforms/Inline/prof-update-sample.ll
  llvm/test/Transforms/SampleProfile/entry_counts_cold.ll
  llvm/test/Transforms/SampleProfile/inline-mergeprof.ll


Index: llvm/test/Transforms/SampleProfile/inline-mergeprof.ll
===================================================================
--- llvm/test/Transforms/SampleProfile/inline-mergeprof.ll
+++ llvm/test/Transforms/SampleProfile/inline-mergeprof.ll
@@ -91,7 +91,7 @@
 ; SCALE: name: "sum"
 ; SCALE-NEXT: {!"function_entry_count", i64 46}
 ; SCALE: !{!"branch_weights", i32 11, i32 2}
-; SCALE: !{!"branch_weights", i64 20}
+; SCALE: !{!"branch_weights", i32 20}
 ; SCALE: name: "sub"
 ; SCALE-NEXT: {!"function_entry_count", i64 -1}
 
Index: llvm/test/Transforms/SampleProfile/entry_counts_cold.ll
===================================================================
--- llvm/test/Transforms/SampleProfile/entry_counts_cold.ll
+++ llvm/test/Transforms/SampleProfile/entry_counts_cold.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/entry_counts_cold.prof -S | FileCheck %s
+; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/entry_counts_cold.prof -S | FileCheck %s
 ; ModuleID = 'temp.bc'
 source_filename = "temp.c"
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
@@ -108,7 +109,7 @@
 ; CHECK: [[TOP]] = !{!"function_entry_count", i64 101}
 ; CHECK: [[FOO]] = !{!"function_entry_count", i64 151}
 ; CHECK: [[BAR]] = !{!"function_entry_count", i64 303}
-; CHECK: [[BAZ]] = !{!"branch_weights", i64 303}
+; CHECK: [[BAZ]] = !{!"branch_weights", i32 303}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: GNU)
 !1 = !DIFile(filename: "temp.c", directory: "llvm/test/Transforms/SampleProfile")
Index: llvm/test/Transforms/Inline/prof-update-sample.ll
===================================================================
--- llvm/test/Transforms/Inline/prof-update-sample.ll
+++ llvm/test/Transforms/Inline/prof-update-sample.ll
@@ -49,12 +49,12 @@
 !13 = !{i32 999000, i64 100, i32 1}
 !14 = !{i32 999999, i64 1, i32 2}
 !15 = !{!"function_entry_count", i64 1000}
-!16 = !{!"branch_weights", i64 2000}
-!17 = !{!"branch_weights", i64 400}
+!16 = !{!"branch_weights", i32 2000}
+!17 = !{!"branch_weights", i32 400}
 !18 = !{!"VP", i32 0, i64 140, i64 111, i64 80, i64 222, i64 40, i64 333, i64 20}
 ; CHECK: ![[ENTRY_COUNT]] = !{!"function_entry_count", i64 600}
-; CHECK: ![[COUNT_CALLEE1]] = !{!"branch_weights", i64 2000}
-; CHECK: ![[COUNT_CALLEE]] = !{!"branch_weights", i64 1200}
+; CHECK: ![[COUNT_CALLEE1]] = !{!"branch_weights", i32 2000}
+; CHECK: ![[COUNT_CALLEE]] = !{!"branch_weights", i32 1200}
 ; CHECK: ![[COUNT_IND_CALLEE]] = !{!"VP", i32 0, i64 84, i64 111, i64 48, i64 222, i64 24, i64 333, i64 12}
-; CHECK: ![[COUNT_CALLER]] = !{!"branch_weights", i64 800}
+; CHECK: ![[COUNT_CALLER]] = !{!"branch_weights", i32 800}
 ; CHECK: ![[COUNT_IND_CALLER]] = !{!"VP", i32 0, i64 56, i64 111, i64 32, i64 222, i64 16, i64 333, i64 8}
Index: llvm/test/Transforms/Inline/prof-update-sample-alwaysinline.ll
===================================================================
--- llvm/test/Transforms/Inline/prof-update-sample-alwaysinline.ll
+++ llvm/test/Transforms/Inline/prof-update-sample-alwaysinline.ll
@@ -48,13 +48,13 @@
 !13 = !{i32 999000, i64 100, i32 1}
 !14 = !{i32 999999, i64 1, i32 2}
 !15 = !{!"function_entry_count", i64 1000}
-!16 = !{!"branch_weights", i64 2000}
-!17 = !{!"branch_weights", i64 400}
+!16 = !{!"branch_weights", i32 2000}
+!17 = !{!"branch_weights", i32 400}
 !18 = !{!"VP", i32 0, i64 140, i64 111, i64 80, i64 222, i64 40, i64 333, i64 20}
 attributes #0 = { alwaysinline }
 ; CHECK: ![[ENTRY_COUNT]] = !{!"function_entry_count", i64 600}
-; CHECK: ![[COUNT_CALLEE1]] = !{!"branch_weights", i64 2000}
-; CHECK: ![[COUNT_CALLEE]] = !{!"branch_weights", i64 1200}
+; CHECK: ![[COUNT_CALLEE1]] = !{!"branch_weights", i32 2000}
+; CHECK: ![[COUNT_CALLEE]] = !{!"branch_weights", i32 1200}
 ; CHECK: ![[COUNT_IND_CALLEE]] = !{!"VP", i32 0, i64 84, i64 111, i64 48, i64 222, i64 24, i64 333, i64 12}
-; CHECK: ![[COUNT_CALLER]] = !{!"branch_weights", i64 800}
+; CHECK: ![[COUNT_CALLER]] = !{!"branch_weights", i32 800}
 ; CHECK: ![[COUNT_IND_CALLER]] = !{!"VP", i32 0, i64 56, i64 111, i64 32, i64 222, i64 16, i64 333, i64 8}
Index: llvm/lib/IR/Instructions.cpp
===================================================================
--- llvm/lib/IR/Instructions.cpp
+++ llvm/lib/IR/Instructions.cpp
@@ -561,7 +561,7 @@
                        .getZExtValue());
     Val *= APS;
     Vals.push_back(MDB.createConstant(ConstantInt::get(
-        Type::getInt64Ty(getContext()), Val.udiv(APT).getLimitedValue())));
+        Type::getInt32Ty(getContext()), Val.udiv(APT).getLimitedValue())));
   } else if (ProfDataName->getString().equals("VP"))
     for (unsigned i = 1; i < ProfileData->getNumOperands(); i += 2) {
       // The first value is the key of the value profile, which will not change.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90539.302109.patch
Type: text/x-patch
Size: 4934 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201031/6e12b70b/attachment.bin>


More information about the llvm-commits mailing list