Skip to content

Commit

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

PiperOrigin-RevId: 621836786
  • Loading branch information
tensorflower-gardener committed Apr 4, 2024
1 parent 9f995aa commit f181ba8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 242 deletions.
253 changes: 14 additions & 239 deletions third_party/llvm/generated.patch
@@ -1,240 +1,15 @@
Auto generated patch. Do not edit or delete it, even if empty.
diff -ruN --strip-trailing-cr a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1633,7 +1633,8 @@
return;
const RelType relativeRel = target->relativeRel;
numRelativeRelocs =
- llvm::partition(relocs, [=](auto &r) { return r.type == relativeRel; }) -
+ std::stable_partition(relocs.begin(), relocs.end(),
+ [=](auto &r) { return r.type == relativeRel; }) -
relocs.begin();
}

@@ -1666,7 +1667,7 @@
parallelForEach(relocs,
[symTab](DynamicReloc &rel) { rel.computeRaw(symTab); });

- auto irelative = std::partition(
+ auto irelative = std::stable_partition(
relocs.begin() + numRelativeRelocs, relocs.end(),
[t = target->iRelativeRel](auto &r) { return r.type != t; });

diff -ruN --strip-trailing-cr a/lld/test/ELF/gnu-ifunc-nonpreemptible.s b/lld/test/ELF/gnu-ifunc-nonpreemptible.s
--- a/lld/test/ELF/gnu-ifunc-nonpreemptible.s
+++ b/lld/test/ELF/gnu-ifunc-nonpreemptible.s
@@ -1,62 +1,76 @@
# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
-# RUN: ld.lld %t.o -o %t
-# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck %s --check-prefix=DISASM
-# RUN: llvm-readelf -r -s %t | FileCheck %s
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o
+# RUN: ld.lld -shared -soname=b.so b.o -o b.so
+
+# RUN: ld.lld a.o -o a
+# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn a | FileCheck %s --check-prefix=DISASM
+# RUN: llvm-readelf -r -s a | FileCheck %s

-# RUN: ld.lld --export-dynamic %t.o -o %t
-# RUN: llvm-readelf -r -s %t | FileCheck %s
-
-# CHECK: Relocation section '.rela.dyn' at offset {{.*}} contains 2 entries:
+# CHECK: Relocation section '.rela.dyn' at offset {{.*}} contains 3 entries:
# CHECK-NEXT: Type
-# CHECK-NEXT: R_X86_64_IRELATIVE
-# CHECK-NEXT: R_X86_64_IRELATIVE
-
-# CHECK: 0 NOTYPE LOCAL HIDDEN [[#]] __rela_iplt_start
-# CHECK-NEXT: 0 NOTYPE LOCAL HIDDEN [[#]] __rela_iplt_end
-
-# RUN: ld.lld -pie %t.o -o %t1
-# RUN: llvm-readelf -s %t1 | FileCheck %s --check-prefix=PIC
-# RUN: ld.lld -shared %t.o -o %t2
-# RUN: llvm-readelf -s %t2 | FileCheck %s --check-prefix=PIC
+# CHECK-NEXT: {{0*}}[[#%x,O:]] [[#%x,]] R_X86_64_IRELATIVE [[#%x,QUX:]]
+# CHECK-NEXT: {{0*}}[[#O+8]] [[#%x,]] R_X86_64_IRELATIVE
+# CHECK-NEXT: {{0*}}[[#O+16]] [[#%x,]] R_X86_64_IRELATIVE
+
+# CHECK: 0 NOTYPE LOCAL HIDDEN [[#]] __rela_iplt_start
+# CHECK-NEXT: 0 NOTYPE LOCAL HIDDEN [[#]] __rela_iplt_end
+# CHECK-NEXT: {{0*}}[[#QUX]] 0 IFUNC GLOBAL DEFAULT [[#]] qux
+
+# RUN: ld.lld -pie a.o b.so -o a1
+# RUN: llvm-readelf -rs a1 | FileCheck %s --check-prefixes=PIC,PIE
+# RUN: ld.lld -shared a.o b.so -o a2
+# RUN: llvm-readelf -rs a2 | FileCheck %s --check-prefix=PIC
+
+# PIC: {{0*}}[[#%x,O:]] [[#%x,]] R_X86_64_RELATIVE
+# PIC-NEXT: R_X86_64_GLOB_DAT 0000000000000000 ext + 0
+# PIC-NEXT: {{0*}}[[#O-16]] [[#%x,]] R_X86_64_64 0000000000000000 __rela_iplt_start + 0
+# PIC-NEXT: {{0*}}[[#O-8]] [[#%x,]] R_X86_64_64 0000000000000000 __rela_iplt_end + 0
+# PIE-NEXT: {{0*}}[[#O+8]] [[#%x,]] R_X86_64_IRELATIVE
+# PIE-NEXT: {{0*}}[[#O+16]] [[#%x,]] R_X86_64_IRELATIVE
+# PIE-NEXT: {{0*}}[[#O+24]] [[#%x,]] R_X86_64_IRELATIVE

# PIC: 0 NOTYPE WEAK DEFAULT UND __rela_iplt_start
# PIC-NEXT: 0 NOTYPE WEAK DEFAULT UND __rela_iplt_end

# DISASM: Disassembly of section .text:
# DISASM-EMPTY:
-# DISASM-NEXT: <foo>:
+# DISASM-NEXT: <qux>:
+# DISASM: <foo>:
# DISASM: <bar>:
# DISASM: <unused>:
# DISASM: <_start>:
# DISASM-NEXT: callq 0x[[#%x,foo:]]
# DISASM-NEXT: callq 0x[[#%x,bar:]]
+# DISASM-NEXT: callq 0x[[#%x,qux:]]
# DISASM-EMPTY:
# DISASM-NEXT: Disassembly of section .iplt:
# DISASM-EMPTY:
# DISASM-NEXT: <.iplt>:
-# DISASM-NEXT: [[#foo]]: jmpq *{{.*}}(%rip)
+# DISASM-NEXT: [[#qux]]: jmpq *{{.*}}(%rip)
# DISASM-NEXT: pushq $0
# DISASM-NEXT: jmp 0x0
-# DISASM-NEXT: [[#bar]]: jmpq *{{.*}}(%rip)
+# DISASM-NEXT: [[#foo]]: jmpq *{{.*}}(%rip)
# DISASM-NEXT: pushq $1
# DISASM-NEXT: jmp 0x0
+# DISASM-NEXT: [[#bar]]: jmpq *{{.*}}(%rip)
+# DISASM-NEXT: pushq $2
+# DISASM-NEXT: jmp 0x0

-.text
+#--- a.s
+.globl qux, foo, bar
+.type qux, @gnu_indirect_function
.type foo STT_GNU_IFUNC
-.globl foo
-foo:
- ret
-
.type bar STT_GNU_IFUNC
-.globl bar
-bar:
- ret
+qux: ret
+foo: ret
+bar: ret

.type unused, @gnu_indirect_function
.globl unused
-unused:
- ret
+.weak ext
+unused: mov ext@gotpcrel(%rip), %rax

.weak __rela_iplt_start
.weak __rela_iplt_end
@@ -65,7 +79,14 @@
_start:
call foo
call bar
+ call qux

.data
.quad __rela_iplt_start
.quad __rela_iplt_end
+ .quad .data
+
+#--- b.s
+.globl ext
+ext:
+ ret
diff -ruN --strip-trailing-cr a/lld/test/ELF/gnu-ifunc-relative.s b/lld/test/ELF/gnu-ifunc-relative.s
--- a/lld/test/ELF/gnu-ifunc-relative.s
+++ b/lld/test/ELF/gnu-ifunc-relative.s
@@ -1,25 +0,0 @@
-// REQUIRES: x86
-// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-// RUN: ld.lld --strip-all %t.o -o %t
-// RUN: llvm-readobj -r %t | FileCheck %s
-// RUN: ld.lld %t.o -o %t
-// RUN: llvm-readobj -r --symbols %t | FileCheck %s --check-prefixes=CHECK,SYM
-
-.type foo STT_GNU_IFUNC
-.globl foo
-foo:
- ret
-
-.globl _start
-_start:
- call foo
-
-// CHECK: Section ({{.*}}) .rela.dyn {
-// CHECK-NEXT: R_X86_64_IRELATIVE - 0x[[ADDR:.*]]
-// CHECK-NEXT: }
-
-// SYM: Name: foo
-// SYM-NEXT: Value: 0x[[ADDR]]
-// SYM-NEXT: Size: 0
-// SYM-NEXT: Binding: Global
-// SYM-NEXT: Type: GNU_IFunc
diff -ruN --strip-trailing-cr a/llvm/include/llvm/ADT/iterator_range.h b/llvm/include/llvm/ADT/iterator_range.h
--- a/llvm/include/llvm/ADT/iterator_range.h
+++ b/llvm/include/llvm/ADT/iterator_range.h
@@ -48,9 +48,10 @@
// See https://github.com/llvm/llvm-project/issues/63843
template <typename Container>
#else
- template <typename Container,
- std::enable_if_t<explicitly_convertible<
- detail::IterOfRange<Container>, IteratorT>::value> * = nullptr>
+ template <
+ typename Container,
+ std::enable_if_t<explicitly_convertible<
+ llvm::detail::IterOfRange<Container>, IteratorT>::value> * = nullptr>
#endif
iterator_range(Container &&c)
: begin_iterator(adl_begin(c)), end_iterator(adl_end(c)) {
@@ -65,7 +66,8 @@
};

template <typename Container>
-iterator_range(Container &&) -> iterator_range<detail::IterOfRange<Container>>;
+iterator_range(Container &&)
+ -> iterator_range<llvm::detail::IterOfRange<Container>>;

/// Convenience function for iterating over sub-ranges.
///
diff -ruN --strip-trailing-cr a/mlir/include/mlir/IR/OwningOpRef.h b/mlir/include/mlir/IR/OwningOpRef.h
--- a/mlir/include/mlir/IR/OwningOpRef.h
+++ b/mlir/include/mlir/IR/OwningOpRef.h
@@ -13,6 +13,7 @@
#ifndef MLIR_IR_OWNINGOPREF_H
#define MLIR_IR_OWNINGOPREF_H

+#include <type_traits>
#include <utility>

namespace mlir {
diff -ruN --strip-trailing-cr a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
--- a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
@@ -78,6 +78,7 @@
its deps.
**kwargs: Other attributes relevant for a cc_library. For example, deps.
"""
+
# We use the explicit equals pattern here because append and += mutate the
# original list, where this creates a new list and stores it in deps.
copts = copts or []
@@ -89,10 +90,11 @@
"-fno-omit-frame-pointer",
"-fstack-protector-strong",
]
+
# x86 targets have -mno-omit-leaf-frame-pointer.
platform_copts = selects.with_or({
PLATFORM_CPU_X86_64: ["-mno-omit-leaf-frame-pointer"],
- "//conditions:default": []
+ "//conditions:default": [],
})
copts = copts + platform_copts

diff -ruN --strip-trailing-cr a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -580,7 +580,9 @@
BuildingImplicitModuleUsesLock(true), ModulesEmbedAllFiles(false),
IncludeTimestamps(true), UseTemporary(true),
AllowPCMWithCompilerErrors(false), ModulesShareFileManager(true),
- TimeTraceGranularity(500) {}
+ EmitSymbolGraph(false), EmitExtensionSymbolGraphs(false),
+ EmitSymbolGraphSymbolLabelsForTesting(false),
+ EmitPrettySymbolGraphs(false), TimeTraceGranularity(500) {}

/// getInputKindForExtension - Return the appropriate input kind for a file
/// extension. For example, "c" would return Language::C.
4 changes: 2 additions & 2 deletions third_party/llvm/workspace.bzl
Expand Up @@ -4,8 +4,8 @@ load("//third_party:repo.bzl", "tf_http_archive")

def repo(name):
"""Imports LLVM."""
LLVM_COMMIT = "9df19ce40281551bd348b262a131085cf98dadf5"
LLVM_SHA256 = "60a32f6344450da92d170a19d06c742211c208e50274983c13e59147278788d7"
LLVM_COMMIT = "c511c90680eecae2e4adb87f442f41d465feb0f2"
LLVM_SHA256 = "9667d22e7a5ccee5acc209abca172ac7fef99f67281c3099568e9eda541771f0"

tf_http_archive(
name = name,
Expand Down
1 change: 1 addition & 0 deletions third_party/xla/xla/service/cpu/BUILD
Expand Up @@ -500,6 +500,7 @@ cc_library(
"@llvm-project//mlir:ShapeToStandard",
"@llvm-project//mlir:ShapeTransforms",
"@llvm-project//mlir:SparseTensorTransforms",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TensorToLinalg",
"@llvm-project//mlir:TensorTransforms",
"@llvm-project//mlir:Transforms",
Expand Down
8 changes: 7 additions & 1 deletion third_party/xla/xla/service/cpu/hlo_xla_runtime_pipeline.cc
Expand Up @@ -44,6 +44,8 @@ limitations under the License.
#include "mlir/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.h" // from @llvm-project
#include "mlir/Dialect/Vector/Transforms/BufferizableOpInterfaceImpl.h" // from @llvm-project
#include "mlir/Pass/PassManager.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/Support/LogicalResult.h" // from @llvm-project
#include "mlir/Transforms/Passes.h" // from @llvm-project
#include "xla/mlir/backends/cpu/transforms/passes.h"
#include "xla/mlir/runtime/transforms/compiler.h"
Expand Down Expand Up @@ -152,7 +154,11 @@ static Status CreateHloXlaPipeline(
// one-shot-bufferize generates unnecessary allocs for. The detensorize pass
// replaces these linalg.generics with scalar ops.
auto detensorize = mlir::createLinalgDetensorizePass();
if (detensorize->initializeOptions("aggressive-mode=true").failed()) {
if (detensorize
->initializeOptions(
"aggressive-mode=true",
[](const mlir::Twine&) { return mlir::failure(); })
.failed()) {
return tsl::errors::Internal("Failed to set up detensorize pass.");
}
pm.addNestedPass<mlir::func::FuncOp>(std::move(detensorize));
Expand Down

0 comments on commit f181ba8

Please sign in to comment.