Skip to content

Commit

Permalink
Integrate LLVM at llvm/llvm-project@77c780d64b95
Browse files Browse the repository at this point in the history
Updates LLVM usage to match
[77c780d64b95](llvm/llvm-project@77c780d64b95)

PiperOrigin-RevId: 720165473
  • Loading branch information
gribozavr authored and copybara-github committed Jan 27, 2025
1 parent c7f819e commit a829bf3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bazel/import_llvm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load(

def import_llvm(name):
"""Imports LLVM."""
LLVM_COMMIT = "9fecb4f9071740f6c1e665940583e9dceae2beb5"
LLVM_COMMIT = "77c780d64b950d6850d5ec1ee06cd0c21b38b89e"

new_git_repository(
name = name,
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/TensorExt/IR/TensorExtOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def TensorExt_RotateOp : TensorExt_Op<"rotate", [Pure, AllTypesMatch<["tensor",
```
}];

let arguments = (ins AnyTensor:$tensor, SignlessIntegerLike:$shift);
let arguments = (ins AnyTensor:$tensor, SignlessIntegerOrIndexLike:$shift);
let results = (outs AnyTensor:$output);
let assemblyFormat = "operands attr-dict `:` qualified(type($tensor)) `,` type($shift)";
let hasCanonicalizer = 1;
Expand Down
64 changes: 54 additions & 10 deletions patches/llvm.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,56 @@
Auto generated patch. Do not edit or delete it, even if empty.
diff -ruN --strip-trailing-cr a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -3652,6 +3652,7 @@
":__support_macros_optimization",
":llvm_libc_types_size_t",
":string_memory_utils",
+ ":types_size_t",
],
)
diff -ruN --strip-trailing-cr a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -423,12 +423,24 @@
}
}

+ // Now we found a bunch of sets of globals used together. We accumulated
+ // the number of times we encountered the sets (i.e., the number of functions
+ // that use that exact set of globals).
+ //
+ // Multiply that by the size of the set to give us a crude profitability
+ // metric.
+ llvm::stable_sort(UsedGlobalSets,
+ [](const UsedGlobalSet &UGS1, const UsedGlobalSet &UGS2) {
+ return UGS1.Globals.count() * UGS1.UsageCount <
+ UGS2.Globals.count() * UGS2.UsageCount;
+ });
+
// We can choose to merge all globals together, but ignore globals never used
// with another global. This catches the obviously non-profitable cases of
// having a single global, but is aggressive enough for any other case.
if (GlobalMergeIgnoreSingleUse) {
BitVector AllGlobals(Globals.size());
- for (const UsedGlobalSet &UGS : UsedGlobalSets) {
+ for (const UsedGlobalSet &UGS : llvm::reverse(UsedGlobalSets)) {
if (UGS.UsageCount == 0)
continue;
if (UGS.Globals.count() > 1)
@@ -437,16 +449,6 @@
return doMerge(Globals, AllGlobals, M, isConst, AddrSpace);
}

- // Now we found a bunch of sets of globals used together. We accumulated
- // the number of times we encountered the sets (i.e., the number of functions
- // that use that exact set of globals). Multiply that by the size of the set
- // to give us a crude profitability metric.
- llvm::stable_sort(UsedGlobalSets,
- [](const UsedGlobalSet &UGS1, const UsedGlobalSet &UGS2) {
- return UGS1.Globals.count() * UGS1.UsageCount >=
- UGS2.Globals.count() * UGS2.UsageCount;
- });
-
// Starting from the sets with the best (=biggest) profitability, find a
// good combination.
// The ideal (and expensive) solution can only be found by trying all
@@ -456,7 +458,7 @@
BitVector PickedGlobals(Globals.size());
bool Changed = false;

- for (const UsedGlobalSet &UGS : UsedGlobalSets) {
+ for (const UsedGlobalSet &UGS : llvm::reverse(UsedGlobalSets)) {
if (UGS.UsageCount == 0)
continue;
if (PickedGlobals.anyCommon(UGS.Globals))

0 comments on commit a829bf3

Please sign in to comment.