Skip to content

Commit 434b8a3

Browse files
committed
Revert "[mlir][ODS] Omit printing default-valued attributes in oilists (#68694)"
This reverts commit e98a4bb. This caused test failures: - https://lab.llvm.org/buildbot/#/builders/61/builds/50374 - https://lab.llvm.org/buildbot/#/builders/220/builds/29092
1 parent e98a4bb commit 434b8a3

File tree

6 files changed

+18
-28
lines changed

6 files changed

+18
-28
lines changed

flang/test/Lower/OpenMP/FIR/atomic-read.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
!CHECK: %[[VAR_X:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFEx"}
1515
!CHECK: %[[VAR_Y:.*]] = fir.alloca i32 {bindc_name = "y", uniq_name = "_QFEy"}
1616
!CHECK: omp.atomic.read %[[VAR_X]] = %[[VAR_Y]] memory_order(acquire) hint(uncontended) : !fir.ref<i32>, i32
17-
!CHECK: omp.atomic.read %[[VAR_A]] = %[[VAR_B]] memory_order(relaxed) : !fir.ref<!fir.char<1>>, !fir.char<1>
17+
!CHECK: omp.atomic.read %[[VAR_A]] = %[[VAR_B]] memory_order(relaxed) hint(none) : !fir.ref<!fir.char<1>>, !fir.char<1>
1818
!CHECK: omp.atomic.read %[[VAR_C]] = %[[VAR_D]] memory_order(seq_cst) hint(contended) : !fir.ref<!fir.logical<4>>, !fir.logical<4>
1919
!CHECK: omp.atomic.read %[[VAR_E]] = %[[VAR_F]] hint(speculative) : !fir.ref<!fir.char<1,8>>, !fir.char<1,8>
2020
!CHECK: omp.atomic.read %[[VAR_G]] = %[[VAR_H]] hint(nonspeculative) : !fir.ref<f32>, f32

flang/test/Lower/OpenMP/FIR/critical.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | FileCheck %s --check-prefix="OMPDialect"
33
!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | tco | FileCheck %s --check-prefix="LLVMIR"
44

5-
!OMPDialect: omp.critical.declare @help2
5+
!OMPDialect: omp.critical.declare @help2 hint(none)
66
!OMPDialect: omp.critical.declare @help1 hint(contended)
77

88
subroutine omp_critical()

flang/test/Lower/OpenMP/critical.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
22

3-
!CHECK: omp.critical.declare @help2
3+
!CHECK: omp.critical.declare @help2 hint(none)
44
!CHECK: omp.critical.declare @help1 hint(contended)
55

66
subroutine omp_critical()

mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func.func @wsloop(%arg0: index, %arg1: index, %arg2: index, %arg3: index, %arg4:
9090
// CHECK-LABEL: @atomic_write
9191
// CHECK: (%[[ARG0:.*]]: !llvm.ptr<i32>)
9292
// CHECK: %[[VAL0:.*]] = llvm.mlir.constant(1 : i32) : i32
93-
// CHECK: omp.atomic.write %[[ARG0]] = %[[VAL0]] memory_order(relaxed) : !llvm.ptr<i32>, i32
93+
// CHECK: omp.atomic.write %[[ARG0]] = %[[VAL0]] hint(none) memory_order(relaxed) : !llvm.ptr<i32>, i32
9494
func.func @atomic_write(%a: !llvm.ptr<i32>) -> () {
9595
%1 = arith.constant 1 : i32
9696
omp.atomic.write %a = %1 hint(none) memory_order(relaxed) : !llvm.ptr<i32>, i32
@@ -474,4 +474,4 @@ llvm.func @_QPtarget_map_with_bounds(%arg0: !llvm.ptr<i32>, %arg1: !llvm.ptr<arr
474474
omp.terminator
475475
}
476476
llvm.return
477-
}
477+
}

mlir/test/Dialect/OpenMP/ops.mlir

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ omp.critical.declare @mutex6 hint(contended, nonspeculative)
831831
omp.critical.declare @mutex7 hint(uncontended, speculative)
832832
// CHECK: omp.critical.declare @mutex8 hint(contended, speculative)
833833
omp.critical.declare @mutex8 hint(contended, speculative)
834-
// CHECK: omp.critical.declare @mutex9
834+
// CHECK: omp.critical.declare @mutex9 hint(none)
835835
omp.critical.declare @mutex9 hint(none)
836836
// CHECK: omp.critical.declare @mutex10
837837
omp.critical.declare @mutex10
@@ -909,7 +909,7 @@ func.func @omp_atomic_read(%v: memref<i32>, %x: memref<i32>) {
909909
omp.atomic.read %v = %x hint(nonspeculative, contended) : memref<i32>, i32
910910
// CHECK: omp.atomic.read %[[v]] = %[[x]] memory_order(seq_cst) hint(contended, speculative) : memref<i32>, i32
911911
omp.atomic.read %v = %x hint(speculative, contended) memory_order(seq_cst) : memref<i32>, i32
912-
// CHECK: omp.atomic.read %[[v]] = %[[x]] memory_order(seq_cst) : memref<i32>, i32
912+
// CHECK: omp.atomic.read %[[v]] = %[[x]] memory_order(seq_cst) hint(none) : memref<i32>, i32
913913
omp.atomic.read %v = %x hint(none) memory_order(seq_cst) : memref<i32>, i32
914914
return
915915
}
@@ -927,7 +927,7 @@ func.func @omp_atomic_write(%addr : memref<i32>, %val : i32) {
927927
omp.atomic.write %addr = %val memory_order(relaxed) : memref<i32>, i32
928928
// CHECK: omp.atomic.write %[[ADDR]] = %[[VAL]] hint(uncontended, speculative) : memref<i32>, i32
929929
omp.atomic.write %addr = %val hint(speculative, uncontended) : memref<i32>, i32
930-
// CHECK: omp.atomic.write %[[ADDR]] = %[[VAL]] : memref<i32>, i32
930+
// CHECK: omp.atomic.write %[[ADDR]] = %[[VAL]] hint(none) : memref<i32>, i32
931931
omp.atomic.write %addr = %val hint(none) : memref<i32>, i32
932932
return
933933
}
@@ -1004,7 +1004,7 @@ func.func @omp_atomic_update(%x : memref<i32>, %expr : i32, %xBool : memref<i1>,
10041004
omp.yield(%const:i32)
10051005
}
10061006

1007-
// CHECK: omp.atomic.update %[[X]] : memref<i32>
1007+
// CHECK: omp.atomic.update hint(none) %[[X]] : memref<i32>
10081008
// CHECK-NEXT: (%[[XVAL:.*]]: i32):
10091009
// CHECK-NEXT: %[[NEWVAL:.*]] = llvm.add %[[XVAL]], %[[EXPR]] : i32
10101010
// CHECK-NEXT: omp.yield(%[[NEWVAL]] : i32)
@@ -1181,7 +1181,7 @@ func.func @omp_atomic_capture(%v: memref<i32>, %x: memref<i32>, %expr: i32) {
11811181
omp.atomic.write %x = %expr : memref<i32>, i32
11821182
}
11831183

1184-
// CHECK: omp.atomic.capture {
1184+
// CHECK: omp.atomic.capture hint(none) {
11851185
// CHECK-NEXT: omp.atomic.update %[[x]] : memref<i32>
11861186
// CHECK-NEXT: (%[[xval:.*]]: i32):
11871187
// CHECK-NEXT: %[[newval:.*]] = llvm.add %[[xval]], %[[expr]] : i32

mlir/tools/mlir-tblgen/OpFormatGen.cpp

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,16 +2009,6 @@ static void genEnumAttrPrinter(const NamedAttribute *var, const Operator &op,
20092009
" }\n";
20102010
}
20112011

2012-
/// Generate a check that a DefaultValuedAttr has a value that is non-default.
2013-
static void genNonDefaultValueCheck(MethodBody &body, const Operator &op,
2014-
AttributeVariable &attrElement) {
2015-
FmtContext fctx;
2016-
Attribute attr = attrElement.getVar()->attr;
2017-
fctx.withBuilder("::mlir::OpBuilder((*this)->getContext())");
2018-
body << " && " << op.getGetterName(attrElement.getVar()->name) << "Attr() != "
2019-
<< tgfmt(attr.getConstBuilderTemplate(), &fctx, attr.getDefaultValue());
2020-
}
2021-
20222012
/// Generate the check for the anchor of an optional group.
20232013
static void genOptionalGroupPrinterAnchor(FormatElement *anchor,
20242014
const Operator &op,
@@ -2052,7 +2042,12 @@ static void genOptionalGroupPrinterAnchor(FormatElement *anchor,
20522042
if (attr.hasDefaultValue()) {
20532043
// Consider a default-valued attribute as present if it's not the
20542044
// default value.
2055-
genNonDefaultValueCheck(body, op, *element);
2045+
FmtContext fctx;
2046+
fctx.withBuilder("::mlir::OpBuilder((*this)->getContext())");
2047+
body << " && " << op.getGetterName(element->getVar()->name)
2048+
<< "Attr() != "
2049+
<< tgfmt(attr.getConstBuilderTemplate(), &fctx,
2050+
attr.getDefaultValue());
20562051
return;
20572052
}
20582053
llvm_unreachable("attribute must be optional or default-valued");
@@ -2163,6 +2158,7 @@ void OperationFormat::genElementPrinter(FormatElement *element,
21632158

21642159
// Emit the OIList
21652160
if (auto *oilist = dyn_cast<OIListElement>(element)) {
2161+
genLiteralPrinter(" ", body, shouldEmitSpace, lastWasPunctuation);
21662162
for (auto clause : oilist->getClauses()) {
21672163
LiteralElement *lelement = std::get<0>(clause);
21682164
ArrayRef<FormatElement *> pelement = std::get<1>(clause);
@@ -2174,14 +2170,8 @@ void OperationFormat::genElementPrinter(FormatElement *element,
21742170
for (VariableElement *var : vars) {
21752171
TypeSwitch<FormatElement *>(var)
21762172
.Case([&](AttributeVariable *attrEle) {
2177-
body << " || (" << op.getGetterName(attrEle->getVar()->name)
2173+
body << " || " << op.getGetterName(attrEle->getVar()->name)
21782174
<< "Attr()";
2179-
Attribute attr = attrEle->getVar()->attr;
2180-
if (attr.hasDefaultValue()) {
2181-
// Don't print default-valued attributes.
2182-
genNonDefaultValueCheck(body, op, *attrEle);
2183-
}
2184-
body << ")";
21852175
})
21862176
.Case([&](OperandVariable *ele) {
21872177
if (ele->getVar()->isVariadic()) {

0 commit comments

Comments
 (0)