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 Google-ML-Automation committed Jan 27, 2025
1 parent c8f96a0 commit 8591928
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 1,402 deletions.
64 changes: 54 additions & 10 deletions third_party/llvm/generated.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))
4 changes: 2 additions & 2 deletions third_party/llvm/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ load("//third_party:repo.bzl", "tf_http_archive")

def repo(name):
"""Imports LLVM."""
LLVM_COMMIT = "9fecb4f9071740f6c1e665940583e9dceae2beb5"
LLVM_SHA256 = "4fdbe474546073cb311a30d9d6f55766ce4217d6e30b45af74abbf6f93207c91"
LLVM_COMMIT = "77c780d64b950d6850d5ec1ee06cd0c21b38b89e"
LLVM_SHA256 = "109bdf7b5e62992fa8ccf9445eb462b046ffc6409de859f5f7482ea3cde8f967"

tf_http_archive(
name = name,
Expand Down
Loading

0 comments on commit 8591928

Please sign in to comment.