diff --git a/third_party/llvm/generated.patch b/third_party/llvm/generated.patch index 7bed258..79626b6 100644 --- a/third_party/llvm/generated.patch +++ b/third_party/llvm/generated.patch @@ -1,43 +1,151 @@ Auto generated patch. Do not edit or delete it, even if empty. -diff -ruN --strip-trailing-cr a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp ---- a/llvm/lib/Target/X86/X86ISelLowering.cpp -+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp -@@ -50049,8 +50049,9 @@ - SDValue X, Y, Z; - if (sd_match(N, m_And(m_Value(X), - m_OneUse(m_Or(m_Value(Y), m_Not(m_Value(Z))))))) { -- // Don't fold if Y is a constant to prevent infinite loops. -- if (!isa(Y)) -+ // Don't fold if Y or Z are constants to prevent infinite loops. -+ if (!DAG.isConstantIntBuildVectorOrConstantInt(Y) && -+ !DAG.isConstantIntBuildVectorOrConstantInt(Z)) - return DAG.getNode( - ISD::AND, DL, VT, X, - DAG.getNOT( -diff -ruN --strip-trailing-cr a/llvm/test/CodeGen/X86/pr108731.ll b/llvm/test/CodeGen/X86/pr108731.ll ---- a/llvm/test/CodeGen/X86/pr108731.ll -+++ b/llvm/test/CodeGen/X86/pr108731.ll -@@ -192,3 +192,23 @@ - ret void - } +diff -ruN --strip-trailing-cr a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp +--- a/llvm/lib/Linker/IRMover.cpp ++++ b/llvm/lib/Linker/IRMover.cpp +@@ -595,11 +595,15 @@ + if (!SGV) + return nullptr; -+define void @PR113240(i64 %a) { -+; CHECK-LABEL: PR113240: -+; CHECK: # %bb.0: # %entry -+; CHECK-NEXT: movq %rdi, %rax -+; CHECK-NEXT: notq %rax -+; CHECK-NEXT: movabsq $8796093022206, %rcx # imm = 0x7FFFFFFFFFE -+; CHECK-NEXT: notq %rcx -+; CHECK-NEXT: orq %rax, %rcx -+; CHECK-NEXT: andq %rdi, %rcx -+; CHECK-NEXT: movq %rcx, 0 -+; CHECK-NEXT: retq -+entry: -+ %and = and i64 %a, 8796093022206 -+ %bf.value = and i64 8796093022206, 0 -+ %not = xor i64 %and, -1 -+ %and4 = and i64 %a, %not -+ store i64 %and4, ptr null, align 8 ++ // If SGV is from dest, it was already materialized when dest was loaded. ++ if (SGV->getParent() == &DstM) ++ return nullptr; ++ + // When linking a global from other modules than source & dest, skip + // materializing it because it would be mapped later when its containing + // module is linked. Linking it now would potentially pull in many types that + // may not be mapped properly. +- if (SGV->getParent() != &DstM && SGV->getParent() != SrcM.get()) ++ if (SGV->getParent() != SrcM.get()) + return nullptr; + + Expected NewProto = linkGlobalValueProto(SGV, ForIndirectSymbol); +diff -ruN --strip-trailing-cr a/llvm/test/ThinLTO/X86/Inputs/ditemplatevalueparameter-remap.ll b/llvm/test/ThinLTO/X86/Inputs/ditemplatevalueparameter-remap.ll +--- a/llvm/test/ThinLTO/X86/Inputs/ditemplatevalueparameter-remap.ll ++++ b/llvm/test/ThinLTO/X86/Inputs/ditemplatevalueparameter-remap.ll +@@ -0,0 +1,29 @@ ++target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" ++target triple = "x86_64-unknown-linux-gnu" ++ ++define void @_Z8thinlto1v() unnamed_addr { ++ %3 = alloca i64, align 4 ++ #dbg_declare(ptr %3, !14, !DIExpression(), !15) ++ ret void ++} ++ ++!llvm.dbg.cu = !{!0} ++!llvm.module.flags = !{!2, !3, !4, !5} ++ ++!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) ++!1 = !DIFile(filename: "B.cpp", directory: ".") ++!2 = !{i32 7, !"Dwarf Version", i32 4} ++!3 = !{i32 2, !"Debug Info Version", i32 3} ++!4 = !{i32 1, !"wchar_size", i32 4} ++!5 = !{i32 8, !"PIC Level", i32 2} ++!10 = distinct !DISubprogram(name: "thinlto1", linkageName: "_Z8thinlto1v", scope: !11, file: !11, line: 8, type: !12, scopeLine: 8, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) ++!11 = !DIFile(filename: "b.cpp", directory: ".") ++!12 = !DISubroutineType(types: !13) ++!13 = !{null} ++!14 = !DILocalVariable(name: "a", arg: 1, scope: !10, file: !11, line: 18, type: !16) ++!15 = !DILocation(line: 18, column: 19, scope: !10) ++!16 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S<&func1>", file: !11, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !17, templateParams: !18, identifier: "_ZTS1SIXadL_Z5func1vEEE") ++!17 = !{} ++!18 = !{!19} ++!19 = !DITemplateValueParameter(name: "Func", type: !20, value: ptr undef) ++!20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) +diff -ruN --strip-trailing-cr a/llvm/test/ThinLTO/X86/ditemplatevalueparameter-remap.ll b/llvm/test/ThinLTO/X86/ditemplatevalueparameter-remap.ll +--- a/llvm/test/ThinLTO/X86/ditemplatevalueparameter-remap.ll ++++ b/llvm/test/ThinLTO/X86/ditemplatevalueparameter-remap.ll +@@ -0,0 +1,93 @@ ++; https://github.com/llvm/llvm-project/pull/110064 ++; This test case checks if thinLTO correctly links metadata values in a specific ++; situation. Assume we are linking module B into module A, where an extern ++; function used in A is defined in B, but the function body has a ++; DITemplateValueParameter referring to another function back in A. The ++; compiler must check this other function is actually coming from A, thus ++; already materialized and does not require remapping. The IR here is modified ++; from the following source code. ++; ++; // A.h ++; template ++; struct S { ++; void Impl() { ++; Func(); ++; } ++; }; ++; ++; void func1(); ++; ++; // A.cpp ++; #include "A.h" ++; __attribute__((weak)) void func1() {} ++; extern void thinlto1(); ++; void bar() { ++; S s; // Force instantiation of S in this compilation unit. ++; s.Impl(); ++; thinlto1(); ++; } ++; ++; // B.cpp ++; #include "A.h" ++; void thinlto1() { ++; S s; ++; } ++; ++; RUN: opt -module-summary -o %t1.bc %s ++; RUN: opt -module-summary -o %t2.bc %S/Inputs/ditemplatevalueparameter-remap.ll ++; RUN: llvm-lto2 run %t1.bc %t2.bc -o %t3 -save-temps \ ++; RUN: -r=%t1.bc,_Z5func1v,p \ ++; RUN: -r=%t1.bc,_Z3bazv,px \ ++; RUN: -r=%t1.bc,_Z8thinlto1v,x \ ++; RUN: -r=%t1.bc,_Z3barv,px \ ++; RUN: -r=%t2.bc,_Z8thinlto1v,px ++; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s ++ ++target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" ++target triple = "x86_64-unknown-linux-gnu" ++ ++$_Z5func1v = comdat any ++ ++define linkonce_odr void @_Z5func1v() unnamed_addr !dbg !10 { + ret void +} + ++; Dummy function to use _Z5func1v so that it is not treated as dead symbol. ++define void @_Z3bazv() { ++ tail call void @_Z5func1v() ++ ret void ++} ++ ++declare void @_Z8thinlto1v() unnamed_addr ++ ++; Check _Z8thinlto1v is inlined after thinLTO. ++; CHECK: void @_Z3barv() ++; CHECK-NOT: @_Z8thinlto1v() ++; CHECK-NEXT: ret void ++define void @_Z3barv() unnamed_addr !dbg !14 { ++ tail call void @_Z8thinlto1v(), !dbg !25 ++ ret void ++} ++ ++!llvm.dbg.cu = !{!0} ++!llvm.module.flags = !{!2, !3, !4, !5} ++ ++!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) ++!1 = !DIFile(filename: "A.cpp", directory: ".") ++!2 = !{i32 7, !"Dwarf Version", i32 4} ++!3 = !{i32 2, !"Debug Info Version", i32 3} ++!4 = !{i32 1, !"wchar_size", i32 4} ++!5 = !{i32 8, !"PIC Level", i32 2} ++!10 = distinct !DISubprogram(name: "func1", linkageName: "_Z5func1v", scope: !11, file: !11, line: 6, type: !12, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) ++!11 = !DIFile(filename: "a.h", directory: ".") ++!12 = !DISubroutineType(types: !13) ++!13 = !{null} ++!14 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !11, file: !11, line: 15, type: !12, scopeLine: 15, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16) ++!16 = !{!17} ++!17 = !DILocalVariable(name: "s", scope: !14, file: !11, line: 10, type: !18) ++!18 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S<&func1>", file: !11, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !19, templateParams: !20, identifier: "_ZTS1SIXadL_Z5func1vEEE") ++!19 = !{} ++!20 = !{!21} ++!21 = !DITemplateValueParameter(name: "Func", type: !22, value: ptr @_Z5func1v) ++!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) ++!25 = !DILocation(line: 16, column: 5, scope: !14) diff --git a/third_party/llvm/workspace.bzl b/third_party/llvm/workspace.bzl index a3d8da0..2d60ea0 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 = "6c4267fb1779bc5550bb413f33250f9365acfbc6" - LLVM_SHA256 = "7010ee8fe86246fabcaedbed21fa9ac2bd2542e0d2ad6172a4481e0294fdf354" + LLVM_COMMIT = "33363521ca24f912cc25530f6cecbca53acce8a3" + LLVM_SHA256 = "3fd9cbd992ed880e348d81715f39138538fd6c8e9164b981551a97181a3b7b24" tf_http_archive( name = name, diff --git a/third_party/stablehlo/temporary.patch b/third_party/stablehlo/temporary.patch index 4a1d725..2eb32ea 100755 --- a/third_party/stablehlo/temporary.patch +++ b/third_party/stablehlo/temporary.patch @@ -1,3 +1,49 @@ +diff --ruN a/stablehlo/stablehlo/conversions/linalg/transforms/TypeConversion.cpp b/stablehlo/stablehlo/conversions/linalg/transforms/TypeConversion.cpp +--- stablehlo/stablehlo/conversions/linalg/transforms/TypeConversion.cpp ++++ stablehlo/stablehlo/conversions/linalg/transforms/TypeConversion.cpp +@@ -47,36 +47,36 @@ + return shapedType; + } + +-std::optional materializeCastFromIllegal(OpBuilder &builder, Type type, ++Value materializeCastFromIllegal(OpBuilder &builder, Type type, + ValueRange inputs, + Location loc) { + Type fromType = getElementTypeOrSelf(inputs[0].getType()); + Type toType = getElementTypeOrSelf(type); + if ((!fromType.isSignedInteger() && !fromType.isUnsignedInteger()) || + !toType.isSignlessInteger()) +- return std::nullopt; ++ return Value(); + // Use unrealized conversion casts to do signful->signless conversions. + return builder.create(loc, type, inputs[0]) + ->getResult(0); + } + +-std::optional materializeCastToIllegal(OpBuilder &builder, Type type, ++Value materializeCastToIllegal(OpBuilder &builder, Type type, + ValueRange inputs, Location loc) { + Type fromType = getElementTypeOrSelf(inputs[0].getType()); + Type toType = getElementTypeOrSelf(type); + if (!fromType.isSignlessInteger() || + (!toType.isSignedInteger() && !toType.isUnsignedInteger())) +- return std::nullopt; ++ return Value(); + // Use unrealized conversion casts to do signless->signful conversions. + return builder.create(loc, type, inputs[0]) + ->getResult(0); + } + +-std::optional scalarToTensor(OpBuilder &builder, Type type, ++Value scalarToTensor(OpBuilder &builder, Type type, + ValueRange inputs, Location loc) { + assert(inputs.size() == 1); + if (mlir::isa(inputs.front().getType())) { +- return std::nullopt; ++ return Value(); + } + Value result = + builder diff --ruN a/stablehlo/stablehlo/tests/vhlo/vhlo_to_version_downgrade_patch.mlir b/stablehlo/stablehlo/tests/vhlo/vhlo_to_version_downgrade_patch.mlir --- stablehlo/stablehlo/tests/vhlo/vhlo_to_version_downgrade_patch.mlir +++ stablehlo/stablehlo/tests/vhlo/vhlo_to_version_downgrade_patch.mlir