From 8555db77763fadbd6be83df0a5532828bc419cba Mon Sep 17 00:00:00 2001 From: Gunhyun Park Date: Thu, 25 Jul 2024 11:34:28 -0700 Subject: [PATCH] Integrate LLVM at llvm/llvm-project@84658fb82b67 (#2463) --- WORKSPACE.bazel | 4 ++-- build_tools/llvm_version.txt | 2 +- .../linalg/transforms/TypeConversion.cpp | 22 ++++++++++++------ .../stablehlo_legalize_to_vhlo.0_18_0.mlir.bc | Bin 17376 -> 17379 bytes .../stablehlo_legalize_to_vhlo.0_19_0.mlir.bc | Bin 17636 -> 17639 bytes .../stablehlo_legalize_to_vhlo.0_20_0.mlir.bc | Bin 17653 -> 17656 bytes .../stablehlo_legalize_to_vhlo.1_0_0.mlir.bc | Bin 17652 -> 17655 bytes .../stablehlo_legalize_to_vhlo.1_1_0.mlir.bc | Bin 17999 -> 18002 bytes .../stablehlo_legalize_to_vhlo.1_2_0.mlir.bc | Bin 18270 -> 18276 bytes .../stablehlo_legalize_to_vhlo.1_3_0.mlir.bc | Bin 18491 -> 18497 bytes .../stablehlo_legalize_to_vhlo.1_4_0.mlir.bc | Bin 18547 -> 18553 bytes .../StablehloLegalizeQuantToInt.cpp | 9 +++---- 12 files changed, 23 insertions(+), 14 deletions(-) diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 69ec464bad6..7e1dd60ea7c 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -17,9 +17,9 @@ workspace(name = "stablehlo") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -LLVM_COMMIT = "dd7d81ea49bf39e1d69bbb84bd3f31bd95519369" +LLVM_COMMIT = "84658fb82b67fc22ecba1560d0cddd09f9104178" -LLVM_SHA256 = "fbd43ef20f4209b0619e209e48c431f76008917714a8c5336063e1ff51d8d084" +LLVM_SHA256 = "b4a50d36a8ab0284f7022f61bbf07a2fb3ea25c6bb2cc422d2418c23b61366da" http_archive( name = "llvm-raw", diff --git a/build_tools/llvm_version.txt b/build_tools/llvm_version.txt index a742a8cd21b..8a1b137263f 100644 --- a/build_tools/llvm_version.txt +++ b/build_tools/llvm_version.txt @@ -1 +1 @@ -dd7d81ea49bf39e1d69bbb84bd3f31bd95519369 +84658fb82b67fc22ecba1560d0cddd09f9104178 diff --git a/stablehlo/conversions/linalg/transforms/TypeConversion.cpp b/stablehlo/conversions/linalg/transforms/TypeConversion.cpp index a77097c7557..12f32fa172d 100644 --- a/stablehlo/conversions/linalg/transforms/TypeConversion.cpp +++ b/stablehlo/conversions/linalg/transforms/TypeConversion.cpp @@ -66,17 +66,25 @@ std::optional materializeCastToIllegal(OpBuilder &builder, Type type, ->getResult(0); } -std::optional scalarToTensor(OpBuilder &builder, Type /*type*/, +std::optional scalarToTensor(OpBuilder &builder, Type type, ValueRange inputs, Location loc) { assert(inputs.size() == 1); - if (llvm::isa(inputs.front().getType())) { + if (mlir::isa(inputs.front().getType())) { return std::nullopt; } - return builder - .create( - loc, RankedTensorType::get({}, inputs.front().getType()), - inputs.front()) - .getResult(); + Value result = + builder + .create( + loc, RankedTensorType::get({}, inputs.front().getType()), + inputs.front()) + .getResult(); + // Convert to a signed integer if necessary. + Type elementType = mlir::getElementTypeOrSelf(type); + if (elementType.isInteger() && !elementType.isSignlessInteger()) { + result = builder.create(loc, type, result) + ->getResult(0); + } + return result; } } // namespace diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_18_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_18_0.mlir.bc index 689795f46661638401375c117de592356e9635d4..8ad245638fa9da933d49124b81ad3706dea58b64 100644 GIT binary patch delta 41 xcmaFR&iJ^Uaf2Tp*RDiX#sEe}c9v-lUYxOACWxtTvIa56J)KCGrF2LKbO3uOQR delta 38 ucmaFf$@rv`aYHE|*R3R0#sEe}c9w0M>-lUY*wvX?xtTvQY(A!@C-p>?xOACWxtTvIa56J)KB8tQ2LKuI3!wl2 delta 38 ucmey-$@sOCaYHE|*S#cG#sEe}c9vb6>-p>?*wvX?xtTvQY(B1LC-g*>xOACWxtTvIa56J)KCEUa2LKsp3!DG| delta 38 ucmey~$@ry{aYG3o*S#cG#sEe}c9vb6>-g*>*wvX?xtTvQY(A!DC{#u45^zi~)>{>@15mALQFC!L85C%FWEhq`=9{xVc9CvK#;&fD4BJ delta 39 vcmccA!+5@jal>{#u3agti~)>{>@3qZALQFC!J)~_%FWEh#IU(u{jwYY{{{;@ diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_2_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_2_0.mlir.bc index 14d46adb9299f56002238461ee73d0a3ebb5ff82..65050e9dd21feef05fa25422c4bbdce6301f206f 100644 GIT binary patch delta 59 zcmccD$M~d=al=18Zlg3-#sEe}b{4+0&7Azxxws6OS-F`_6*!q0H!qjW;p5f^@uir+ J0@51J@&LWD3={wW delta 53 zcmaFT$9S)gal=18ZmBd@#sEe}c9w6cn>qQXbFphPvvM<=GHhNYnZw7S3F1gGF>F@U HaFz!Enhy+s diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_3_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_3_0.mlir.bc index dce39194d4ab9e6c603f0c87290621e4367c6295..5044c515901b508f203717d39ddd0408dc907dfe 100644 GIT binary patch delta 71 zcmdlzf$`u3#tjnu!cyt1i~)>{>@45Xm>GAmu?8?QPtF&X-t5M|j*H8XnU$N_RDqM3 War1A<96oM+5MPQ3ERe5pMjilR(hryb delta 65 zcmX>&fpPZ)#tjnu!c6I`i~)>{>@4@vm>GAmu?8?QPtF&X-t5M|j*DHJnU$N_lwtEf T$s9foO%O+liD7f8#u<443nLE& diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_4_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_4_0.mlir.bc index ac1894894e974130bc91af74b98ee9bf06d753fe..fa842c041e3062c121ed59ec0da0de1ffb6f9e28 100644 GIT binary patch delta 58 zcmex7f$`@A#triPTute$i~)>{>@0DcHTf@baTzkRax{>@04ZHTf@bv1>E4axgetLoc(), op->getName().getStringRef(), operands, newResultTypes, op->getAttrs(), op->getSuccessors()); for (Region ®ion : op->getRegions()) { - Region &newRegion = *state.addRegion(); - rewriter.inlineRegionBefore(region, newRegion, newRegion.begin()); - if (failed( - rewriter.convertRegionTypes(&newRegion, *getTypeConverter()))) { + auto newRegion = std::make_unique(op); + rewriter.inlineRegionBefore(region, *newRegion, newRegion->begin()); + if (failed(rewriter.convertRegionTypes(newRegion.get(), + *getTypeConverter()))) { return failure(); } + state.addRegion(std::move(newRegion)); } Operation *newOp = rewriter.create(state); rewriter.replaceOp(op, newOp);