Skip to content

Commit 2cf9e6f

Browse files
Copy all attributes when creating new operation.
Instead of just copying the fast-math attribute, copy all of the attributes of the call operation. Also amend the test to check that attributes are still there in the updated code.
1 parent 0cfdecf commit 2cf9e6f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

flang/lib/Optimizer/Transforms/ConstantArgumentGlobalisation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ class CallOpRewriter : public mlir::OpRewritePattern<fir::CallOp> {
134134
loc, newResultTypes,
135135
callOp.getCallee().has_value() ? callOp.getCallee().value()
136136
: mlir::SymbolRefAttr{},
137-
newOperands, callOp.getFastmathAttr());
137+
newOperands);
138+
// Copy all the attributes from the old to new op.
139+
newOp->setAttrs(callOp->getAttrs());
138140
rewriter.replaceOp(callOp, newOp);
139141

140142
for (auto e : toErase)

flang/test/Transforms/constant-argument-globalisation.fir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module {
3030
// CHECK: [[CONST_R1:%.*]] = fir.address_of([[EXTR_1:@.*]]) : !fir.ref<f64>
3131
// CHECK: [[CONST_I:%.*]] = fir.address_of([[EXTR_2:@.*]]) : !fir.ref<i32>
3232
// CHECK: fir.call @sub2([[CONST_R0]], [[CONST_R1]], [[X]], [[Y]], [[CONST_I]])
33+
// CHECK-SAME: fastmath<contract>
3334
// CHECK: return
3435

3536
// CHECK: fir.global internal [[EXTR_0]] constant : f64 {

0 commit comments

Comments
 (0)