From fe37fc28d79807aee9a4dfe647bd871b23cbccbb Mon Sep 17 00:00:00 2001 From: xla authors Date: Fri, 13 Dec 2024 01:03:54 -0800 Subject: [PATCH] Integrate LLVM at llvm/llvm-project@5e53a8dadb00 Updates LLVM usage to match [5e53a8dadb00](https://github.com/llvm/llvm-project/commit/5e53a8dadb00) PiperOrigin-RevId: 705788183 --- third_party/llvm/generated.patch | 34 +++++++++++++ third_party/llvm/workspace.bzl | 4 +- third_party/shardy/temporary.patch | 50 +++++++++++++++++-- third_party/shardy/workspace.bzl | 4 +- .../tsl/third_party/llvm/generated.patch | 34 +++++++++++++ .../tsl/third_party/llvm/workspace.bzl | 4 +- 6 files changed, 119 insertions(+), 11 deletions(-) diff --git a/third_party/llvm/generated.patch b/third_party/llvm/generated.patch index 509398da979e8..42c41389c7d53 100644 --- a/third_party/llvm/generated.patch +++ b/third_party/llvm/generated.patch @@ -1 +1,35 @@ Auto generated patch. Do not edit or delete it, even if empty. +diff -ruN --strip-trailing-cr a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp +--- a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp ++++ b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp +@@ -63,6 +63,12 @@ + "outgoing name should be " + ".out")); + ++static cl::opt ++ MaxCascade("mlregalloc-max-cascade", cl::Hidden, ++ cl::desc("The maximum number of times a live range can be " ++ "evicted before preventing it from being evicted"), ++ cl::init(20)); ++ + // Options that only make sense in development mode + #ifdef LLVM_HAVE_TFLITE + #include "RegAllocScore.h" +@@ -643,8 +649,16 @@ + RegClassInfo.getNumAllocatableRegs(MRI->getRegClass(VirtReg.reg())) < + RegClassInfo.getNumAllocatableRegs( + MRI->getRegClass(Intf->reg()))); +- // Only evict older cascades or live ranges without a cascade. ++ + unsigned IntfCascade = RA.getExtraInfo().getCascade(Intf->reg()); ++ // There is a potential that the model could be adversarial and ++ // continually evict live ranges over and over again, leading to a ++ // large amount of compile time being spent in regalloc. If we hit the ++ // threshold, prevent the range from being evicted. ++ if (IntfCascade >= MaxCascade) ++ return false; ++ ++ // Only evict older cascades or live ranges without a cascade. + if (Cascade <= IntfCascade) { + if (!Urgent) + return false; diff --git a/third_party/llvm/workspace.bzl b/third_party/llvm/workspace.bzl index bf592d9749f16..094e5680c446d 100644 --- a/third_party/llvm/workspace.bzl +++ b/third_party/llvm/workspace.bzl @@ -4,8 +4,8 @@ load("//third_party:repo.bzl", "tf_http_archive") def repo(name): """Imports LLVM.""" - LLVM_COMMIT = "0876c11ceeb093904decc4d89bef213d483a5656" - LLVM_SHA256 = "8379577a71645bbba89dea08beba32b3e56b833da7340ba5be7efa3986c8f8ed" + LLVM_COMMIT = "5e53a8dadb0019ee87936c1278fa222781257005" + LLVM_SHA256 = "eb8e26186a8f7e15e59d37729353525d2367272c9f053d2ef1a2c1e292b8b688" tf_http_archive( name = name, diff --git a/third_party/shardy/temporary.patch b/third_party/shardy/temporary.patch index 0b6347196507c..c73ae739bb474 100644 --- a/third_party/shardy/temporary.patch +++ b/third_party/shardy/temporary.patch @@ -1,15 +1,55 @@ +diff --git a/third_party/llvm/generated.patch b/third_party/llvm/generated.patch +index 509398d..42c4138 100644 +--- a/third_party/llvm/generated.patch ++++ b/third_party/llvm/generated.patch +@@ -1 +1,35 @@ + Auto generated patch. Do not edit or delete it, even if empty. ++diff -ruN --strip-trailing-cr a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp ++--- a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp +++++ b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp ++@@ -63,6 +63,12 @@ ++ "outgoing name should be " ++ ".out")); ++ +++static cl::opt +++ MaxCascade("mlregalloc-max-cascade", cl::Hidden, +++ cl::desc("The maximum number of times a live range can be " +++ "evicted before preventing it from being evicted"), +++ cl::init(20)); +++ ++ // Options that only make sense in development mode ++ #ifdef LLVM_HAVE_TFLITE ++ #include "RegAllocScore.h" ++@@ -643,8 +649,16 @@ ++ RegClassInfo.getNumAllocatableRegs(MRI->getRegClass(VirtReg.reg())) < ++ RegClassInfo.getNumAllocatableRegs( ++ MRI->getRegClass(Intf->reg()))); ++- // Only evict older cascades or live ranges without a cascade. +++ ++ unsigned IntfCascade = RA.getExtraInfo().getCascade(Intf->reg()); +++ // There is a potential that the model could be adversarial and +++ // continually evict live ranges over and over again, leading to a +++ // large amount of compile time being spent in regalloc. If we hit the +++ // threshold, prevent the range from being evicted. +++ if (IntfCascade >= MaxCascade) +++ return false; +++ +++ // Only evict older cascades or live ranges without a cascade. ++ if (Cascade <= IntfCascade) { ++ if (!Urgent) ++ return false; diff --git a/third_party/llvm/workspace.bzl b/third_party/llvm/workspace.bzl -index c469253..bf592d9 100644 +index bf592d9..094e568 100644 --- a/third_party/llvm/workspace.bzl +++ b/third_party/llvm/workspace.bzl @@ -4,8 +4,8 @@ load("//third_party:repo.bzl", "tf_http_archive") def repo(name): """Imports LLVM.""" -- LLVM_COMMIT = "19bc282320ba4d2e961e287f110b9110297ae3ee" -- LLVM_SHA256 = "bb765866b09b92743feb5cb42354def323a972f540b606106bee401250781b23" -+ LLVM_COMMIT = "0876c11ceeb093904decc4d89bef213d483a5656" -+ LLVM_SHA256 = "8379577a71645bbba89dea08beba32b3e56b833da7340ba5be7efa3986c8f8ed" +- LLVM_COMMIT = "0876c11ceeb093904decc4d89bef213d483a5656" +- LLVM_SHA256 = "8379577a71645bbba89dea08beba32b3e56b833da7340ba5be7efa3986c8f8ed" ++ LLVM_COMMIT = "5e53a8dadb0019ee87936c1278fa222781257005" ++ LLVM_SHA256 = "eb8e26186a8f7e15e59d37729353525d2367272c9f053d2ef1a2c1e292b8b688" tf_http_archive( name = name, diff --git a/third_party/shardy/workspace.bzl b/third_party/shardy/workspace.bzl index afdaf6f8d40c7..caf1ebdcf4c25 100644 --- a/third_party/shardy/workspace.bzl +++ b/third_party/shardy/workspace.bzl @@ -3,8 +3,8 @@ load("//third_party:repo.bzl", "tf_http_archive", "tf_mirror_urls") def repo(): - SHARDY_COMMIT = "92ca5a918d76f63becaf6ffddbb3d91b509b4d33" - SHARDY_SHA256 = "c8bd25e7a89fa576f1948827378abbfbadb01857c168826b66db0265dfd4f8e6" + SHARDY_COMMIT = "5650f653b7afbe5176bccfbf743dbee5e2d20955" + SHARDY_SHA256 = "08340f5670fc6ef0060fb53eb9a6f2561a519b14403a85fc0f62f3562de934ed" tf_http_archive( name = "shardy", diff --git a/third_party/tsl/third_party/llvm/generated.patch b/third_party/tsl/third_party/llvm/generated.patch index 509398da979e8..42c41389c7d53 100644 --- a/third_party/tsl/third_party/llvm/generated.patch +++ b/third_party/tsl/third_party/llvm/generated.patch @@ -1 +1,35 @@ Auto generated patch. Do not edit or delete it, even if empty. +diff -ruN --strip-trailing-cr a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp +--- a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp ++++ b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp +@@ -63,6 +63,12 @@ + "outgoing name should be " + ".out")); + ++static cl::opt ++ MaxCascade("mlregalloc-max-cascade", cl::Hidden, ++ cl::desc("The maximum number of times a live range can be " ++ "evicted before preventing it from being evicted"), ++ cl::init(20)); ++ + // Options that only make sense in development mode + #ifdef LLVM_HAVE_TFLITE + #include "RegAllocScore.h" +@@ -643,8 +649,16 @@ + RegClassInfo.getNumAllocatableRegs(MRI->getRegClass(VirtReg.reg())) < + RegClassInfo.getNumAllocatableRegs( + MRI->getRegClass(Intf->reg()))); +- // Only evict older cascades or live ranges without a cascade. ++ + unsigned IntfCascade = RA.getExtraInfo().getCascade(Intf->reg()); ++ // There is a potential that the model could be adversarial and ++ // continually evict live ranges over and over again, leading to a ++ // large amount of compile time being spent in regalloc. If we hit the ++ // threshold, prevent the range from being evicted. ++ if (IntfCascade >= MaxCascade) ++ return false; ++ ++ // Only evict older cascades or live ranges without a cascade. + if (Cascade <= IntfCascade) { + if (!Urgent) + return false; diff --git a/third_party/tsl/third_party/llvm/workspace.bzl b/third_party/tsl/third_party/llvm/workspace.bzl index bf592d9749f16..094e5680c446d 100644 --- a/third_party/tsl/third_party/llvm/workspace.bzl +++ b/third_party/tsl/third_party/llvm/workspace.bzl @@ -4,8 +4,8 @@ load("//third_party:repo.bzl", "tf_http_archive") def repo(name): """Imports LLVM.""" - LLVM_COMMIT = "0876c11ceeb093904decc4d89bef213d483a5656" - LLVM_SHA256 = "8379577a71645bbba89dea08beba32b3e56b833da7340ba5be7efa3986c8f8ed" + LLVM_COMMIT = "5e53a8dadb0019ee87936c1278fa222781257005" + LLVM_SHA256 = "eb8e26186a8f7e15e59d37729353525d2367272c9f053d2ef1a2c1e292b8b688" tf_http_archive( name = name,