Skip to content

Commit 3f27c53

Browse files
authored
Integrate LLVM at llvm/llvm-project@42a8ff877d47; migrate op-creation API (#2870)
In addition to bumping the LLVM version, this PR updates call sites of an old op-creation API which is marked as deprecated in the latest LLVM version. The old API was of the form `rewriter.create<OpType>(...)`, now replaced with `OpType::create(rewriter, ...)`.
1 parent 0b5b4a2 commit 3f27c53

File tree

50 files changed

+1988
-1688
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1988
-1688
lines changed

WORKSPACE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ workspace(name = "stablehlo")
1717

1818
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1919

20-
LLVM_COMMIT = "32de3b9ef9e7e8debc14416e968456ca13b48bea"
20+
LLVM_COMMIT = "42a8ff877d47131ecb1280a1cc7e5e3c3bca6952"
2121

22-
LLVM_SHA256 = "e048b05e1fb9366e224ea3c06f8473714114039bfad00e81db4ecb6409f23efa"
22+
LLVM_SHA256 = "f768c5c3b987f68318b8ab3dd4530e54988dfe7d6bfb9b7c9c96acf503367d50"
2323

2424
http_archive(
2525
name = "llvm-raw",

build_tools/llvm_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
32de3b9ef9e7e8debc14416e968456ca13b48bea
1+
42a8ff877d47131ecb1280a1cc7e5e3c3bca6952

examples/c++/ExampleAdd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ int main() {
6969

7070
llvm::SmallVector<mlir::NamedAttribute, 10> attributes;
7171
mlir::Operation* op =
72-
block_builder.create<mlir::stablehlo::AddOp>(loc, arguments, attributes)
72+
mlir::stablehlo::AddOp::create(block_builder, loc, arguments, attributes)
7373
.getOperation();
74-
block_builder.create<mlir::func::ReturnOp>(loc, op->getResult(0));
74+
mlir::func::ReturnOp::create(block_builder, loc, op->getResult(0));
7575

7676
/** verify and dump the module **/
7777
assert(mlir::succeeded(mlir::verify(module.get())));

stablehlo/conversions/linalg/tests/miscellaneous.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ func.func @map_compare(%arg0: tensor<?xcomplex<f32>>,
768768
// CHECK-PRIMITIVE: %[[MAP:.+]] = linalg.map
769769
// CHECK-PRIMITIVE-SAME: ins(%[[ARG0]], %[[ARG1]]
770770
// CHECK-PRIMITIVE-SAME: outs(%[[INIT]] : tensor<?xi1>)
771-
// CHECK-PRIMITIVE-NEXT: (%[[A:.+]]: complex<f32>, %[[B:.+]]: complex<f32>) {
771+
// CHECK-PRIMITIVE-NEXT: (%[[A:.+]]: complex<f32>, %[[B:.+]]: complex<f32>, %{{.+}}: i1) {
772772
// CHECK-PRIMITIVE: %[[RE1:.+]] = complex.re %[[A]] : complex<f32>
773773
// CHECK-PRIMITIVE: %[[RE2:.+]] = complex.re %[[B]] : complex<f32>
774774
// CHECK-PRIMITIVE: %[[CMP:.+]] = arith.cmpf oeq, %[[RE1]], %[[RE2]] : f32

stablehlo/conversions/linalg/tests/pointwise.mlir

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ func.func @float_cmp_totalorder(%lhs: tensor<2x2xbf16>,
714714
// CHECK-PRIMITIVE: linalg.map
715715
// CHECK-PRIMITIVE-SAME: ins(
716716
// CHECK-PRIMITIVE-SAME: outs(
717-
// CHECK-PRIMITIVE-NEXT: (%[[LHS_IN:[a-zA-Z0-9]*]]: bf16, %[[RHS_IN:.*]]: bf16) {
717+
// CHECK-PRIMITIVE-NEXT: (%[[LHS_IN:[a-zA-Z0-9]*]]: bf16, %[[RHS_IN:.*]]: bf16, %[[RESULT_OUT:.*]]: i1) {
718718
// CHECK-PRIMITIVE-NEXT: %[[LHS_INT:.*]] = arith.bitcast %[[LHS_IN]] : bf16 to i16
719719
// CHECK-PRIMITIVE-NEXT: %[[LHS_CMP:.*]] = arith.cmpi slt, %[[LHS_INT]], %[[C0]] : i16
720720
// CHECK-PRIMITIVE-NEXT: %[[LHS_SUB:.*]] = arith.subi %[[C32767]], %[[LHS_INT]] : i16
@@ -937,7 +937,7 @@ func.func @select_scalar_pred_dyn(%pred : tensor<i1>, %lhs: tensor<2x?xf32>, %rh
937937
// CHECK-PRIMITIVE-SAME: ins(%[[LHS]], %[[RHS]] : tensor<2x?xf32>, tensor<2x?xf32>)
938938
// CHECK-PRIMITIVE-SAME: outs(%[[DST]] : tensor<2x?xf32>)
939939
// CHECK-PRIMITIVE-SAME: {someattr}
940-
// CHECK-PRIMITIVE: (%[[LHS_:.*]]: f32, %[[RHS_:.*]]: f32) {
940+
// CHECK-PRIMITIVE: (%[[LHS_:.*]]: f32, %[[RHS_:.*]]: f32, %[[RESULT_OUT:.*]]: f32) {
941941
// CHECK-PRIMITIVE: %[[RES:.*]] = arith.select %[[PRED_ELEM]], %[[LHS_]], %[[RHS_]] : f32
942942
// CHECK-PRIMITIVE: linalg.yield %[[RES]]
943943

@@ -978,7 +978,7 @@ func.func @select_scalar_pred_static(%lhs: tensor<2x?xf32>, %rhs: tensor<2x?xf32
978978
// CHECK-PRIMITIVE-SAME: ins(%[[LHS]], %[[RHS]] : tensor<2x?xf32>, tensor<2x?xf32>)
979979
// CHECK-PRIMITIVE-SAME: outs(%[[DST]] : tensor<2x?xf32>)
980980
// CHECK-PRIMITIVE-SAME: {someattr}
981-
// CHECK-PRIMITIVE: (%[[LHS_:.*]]: f32, %[[RHS_:.*]]: f32) {
981+
// CHECK-PRIMITIVE: (%[[LHS_:.*]]: f32, %[[RHS_:.*]]: f32, %[[RESULT_OUT:.*]]: f32) {
982982
// CHECK-PRIMITIVE: linalg.yield %[[LHS_]]
983983

984984
// -----
@@ -1416,7 +1416,7 @@ func.func @clamp_static(%lb : tensor<4xf32>, %x : tensor<4xf32>, %ub : tensor<4x
14161416

14171417
// CHECK-PRIMITIVE: %[[INIT:.*]] = tensor.empty
14181418
// CHECK-PRIMITIVE: %[[RESULT:.*]] = linalg.map ins(%[[LB]], %[[X]], %[[UB]] : tensor<4xf32>, tensor<4xf32>, tensor<4xf32>) outs(%[[INIT]] : tensor<4xf32>)
1419-
// CHECK-PRIMITIVE: (%[[SCALAR_LB:.*]]: f32, %[[SCALAR_X:.*]]: f32, %[[SCALAR_UB:.*]]: f32)
1419+
// CHECK-PRIMITIVE: (%[[SCALAR_LB:.*]]: f32, %[[SCALAR_X:.*]]: f32, %[[SCALAR_UB:.*]]: f32, %[[RESULT_OUT:.*]]: f32)
14201420
// CHECK-PRIMITIVE: %[[MAX:.*]] = arith.maximumf %[[SCALAR_LB]], %[[SCALAR_X]] : f32
14211421
// CHECK-PRIMITIVE: %[[MIN:.*]] = arith.minimumf %[[MAX]], %[[SCALAR_UB]] : f32
14221422
// CHECK-PRIMITIVE: linalg.yield %[[MIN]]
@@ -1478,7 +1478,7 @@ func.func @clamp_scalar(%lb : tensor<f32>, %x : tensor<?xf32>, %ub : tensor<f32>
14781478
// CHECK-PRIMITIVE-DAG: %[[SCALAR_LB:.*]] = tensor.extract %[[LB]]
14791479
// CHECK-PRIMITIVE-DAG: %[[SCALAR_UB:.*]] = tensor.extract %[[UB]]
14801480
// CHECK-PRIMITIVE: %[[RESULT:.*]] = linalg.map ins(%[[X]] : tensor<?xf32>) outs(%[[INIT]] : tensor<?xf32>)
1481-
// CHECK-PRIMITIVE: (%[[SCALAR_X:.*]]: f32)
1481+
// CHECK-PRIMITIVE: (%[[SCALAR_X:.*]]: f32, %[[RESULT_OUT:.*]]: f32)
14821482
// CHECK-PRIMITIVE: %[[MAX:.*]] = arith.maximumf %[[SCALAR_LB]], %[[SCALAR_X]] : f32
14831483
// CHECK-PRIMITIVE: %[[MIN:.*]] = arith.minimumf %[[MAX]], %[[SCALAR_UB]] : f32
14841484
// CHECK-PRIMITIVE: linalg.yield %[[MIN]]
@@ -1554,7 +1554,7 @@ func.func @integer_not(%arg: tensor<2x2xi32>) -> tensor<2x2xi32> {
15541554
// CHECK: linalg.yield %[[V_NOT]] : i32
15551555
// CHECK-PRIMITIVE: %[[CST_N1:.+]] = arith.constant -1 : i32
15561556
// CHECK-PRIMITIVE: linalg.map
1557-
// CHECK-PRIMITIVE: (%[[IN:.+]]: i32)
1557+
// CHECK-PRIMITIVE: (%[[IN:.+]]: i32, %[[RESULT_OUT:.+]]: i32)
15581558
// CHECK-PRIMITIVE: %[[V_NOT:.+]] = arith.xori %[[IN]], %[[CST_N1]] : i32
15591559
// CHECK-PRIMITIVE: linalg.yield %[[V_NOT]] : i32
15601560
%0 = "stablehlo.not"(%arg) : (tensor<2x2xi32>) -> tensor<2x2xi32>

stablehlo/conversions/linalg/transforms/LegalizeToLinalgUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Value getEmptyTensorFor(OpBuilder& b, Location loc, ShapedType resultType,
105105
if (en.value() != ShapedType::kDynamic) continue;
106106
sizes.push_back(tensor::ExtractOp::create(
107107
b, loc, reifiedShapes[0],
108-
ValueRange{b.create<arith::ConstantIndexOp>(loc, en.index())}));
108+
ValueRange{arith::ConstantIndexOp::create(b, loc, en.index())}));
109109
}
110110
}
111111
return isSparse ? getEmptySparseTensor(b, loc, resultType, sizes)
@@ -149,7 +149,7 @@ Value preSparsify(Operation* op, llvm::SmallVector<Value, 2>& values, Type rtp,
149149
!sparse_tensor::getSparseTensorEncoding(op->getOperand(0).getType()))
150150
return Value();
151151
Location loc = op->getLoc();
152-
auto semiring = b->create<sparse_tensor::UnaryOp>(loc, rtp, values[0]);
152+
auto semiring = sparse_tensor::UnaryOp::create(*b, loc, rtp, values[0]);
153153
Type itp = values[0].getType();
154154
Block* present = b->createBlock(&semiring.getPresentRegion(), {}, itp, loc);
155155
b->setInsertionPointToStart(&semiring.getPresentRegion().front());
@@ -161,7 +161,7 @@ Value preSparsify(Operation* op, llvm::SmallVector<Value, 2>& values, Type rtp,
161161

162162
Value postSparsify(Operation* op, Value semiring, Value result, OpBuilder* b) {
163163
if (semiring) {
164-
b->create<sparse_tensor::YieldOp>(op->getLoc(), result);
164+
sparse_tensor::YieldOp::create(*b, op->getLoc(), result);
165165
b->setInsertionPointAfter(semiring.getDefiningOp());
166166
return semiring;
167167
}

0 commit comments

Comments
 (0)