Skip to content

Commit a829bf3

Browse files
gribozavrcopybara-github
authored andcommitted
Updates LLVM usage to match [77c780d64b95](llvm/llvm-project@77c780d64b95) PiperOrigin-RevId: 720165473
1 parent c7f819e commit a829bf3

File tree

3 files changed

+56
-12
lines changed

3 files changed

+56
-12
lines changed

bazel/import_llvm.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ load(
77

88
def import_llvm(name):
99
"""Imports LLVM."""
10-
LLVM_COMMIT = "9fecb4f9071740f6c1e665940583e9dceae2beb5"
10+
LLVM_COMMIT = "77c780d64b950d6850d5ec1ee06cd0c21b38b89e"
1111

1212
new_git_repository(
1313
name = name,

lib/Dialect/TensorExt/IR/TensorExtOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def TensorExt_RotateOp : TensorExt_Op<"rotate", [Pure, AllTypesMatch<["tensor",
4242
```
4343
}];
4444

45-
let arguments = (ins AnyTensor:$tensor, SignlessIntegerLike:$shift);
45+
let arguments = (ins AnyTensor:$tensor, SignlessIntegerOrIndexLike:$shift);
4646
let results = (outs AnyTensor:$output);
4747
let assemblyFormat = "operands attr-dict `:` qualified(type($tensor)) `,` type($shift)";
4848
let hasCanonicalizer = 1;

patches/llvm.patch

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,56 @@
11
Auto generated patch. Do not edit or delete it, even if empty.
2-
diff -ruN --strip-trailing-cr a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
3-
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
4-
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
5-
@@ -3652,6 +3652,7 @@
6-
":__support_macros_optimization",
7-
":llvm_libc_types_size_t",
8-
":string_memory_utils",
9-
+ ":types_size_t",
10-
],
11-
)
2+
diff -ruN --strip-trailing-cr a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
3+
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
4+
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
5+
@@ -423,12 +423,24 @@
6+
}
7+
}
128

9+
+ // Now we found a bunch of sets of globals used together. We accumulated
10+
+ // the number of times we encountered the sets (i.e., the number of functions
11+
+ // that use that exact set of globals).
12+
+ //
13+
+ // Multiply that by the size of the set to give us a crude profitability
14+
+ // metric.
15+
+ llvm::stable_sort(UsedGlobalSets,
16+
+ [](const UsedGlobalSet &UGS1, const UsedGlobalSet &UGS2) {
17+
+ return UGS1.Globals.count() * UGS1.UsageCount <
18+
+ UGS2.Globals.count() * UGS2.UsageCount;
19+
+ });
20+
+
21+
// We can choose to merge all globals together, but ignore globals never used
22+
// with another global. This catches the obviously non-profitable cases of
23+
// having a single global, but is aggressive enough for any other case.
24+
if (GlobalMergeIgnoreSingleUse) {
25+
BitVector AllGlobals(Globals.size());
26+
- for (const UsedGlobalSet &UGS : UsedGlobalSets) {
27+
+ for (const UsedGlobalSet &UGS : llvm::reverse(UsedGlobalSets)) {
28+
if (UGS.UsageCount == 0)
29+
continue;
30+
if (UGS.Globals.count() > 1)
31+
@@ -437,16 +449,6 @@
32+
return doMerge(Globals, AllGlobals, M, isConst, AddrSpace);
33+
}
34+
35+
- // Now we found a bunch of sets of globals used together. We accumulated
36+
- // the number of times we encountered the sets (i.e., the number of functions
37+
- // that use that exact set of globals). Multiply that by the size of the set
38+
- // to give us a crude profitability metric.
39+
- llvm::stable_sort(UsedGlobalSets,
40+
- [](const UsedGlobalSet &UGS1, const UsedGlobalSet &UGS2) {
41+
- return UGS1.Globals.count() * UGS1.UsageCount >=
42+
- UGS2.Globals.count() * UGS2.UsageCount;
43+
- });
44+
-
45+
// Starting from the sets with the best (=biggest) profitability, find a
46+
// good combination.
47+
// The ideal (and expensive) solution can only be found by trying all
48+
@@ -456,7 +458,7 @@
49+
BitVector PickedGlobals(Globals.size());
50+
bool Changed = false;
51+
52+
- for (const UsedGlobalSet &UGS : UsedGlobalSets) {
53+
+ for (const UsedGlobalSet &UGS : llvm::reverse(UsedGlobalSets)) {
54+
if (UGS.UsageCount == 0)
55+
continue;
56+
if (PickedGlobals.anyCommon(UGS.Globals))

0 commit comments

Comments
 (0)