Skip to content

Commit aa366ae

Browse files
committed
remove propogation when fir.declare is removed
1 parent a26f871 commit aa366ae

File tree

2 files changed

+0
-19
lines changed

2 files changed

+0
-19
lines changed

flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -281,20 +281,6 @@ class DeclareOpConversion : public mlir::OpRewritePattern<fir::DeclareOp> {
281281
matchAndRewrite(fir::DeclareOp declareOp,
282282
mlir::PatternRewriter &rewriter) const override {
283283
if (!preserveDeclare) {
284-
auto memrefOp = declareOp.getMemref().getDefiningOp();
285-
if (!memrefOp) {
286-
rewriter.replaceOp(declareOp, declareOp.getMemref());
287-
return mlir::success();
288-
}
289-
290-
// attach metadatas from the fir.declare to its memref (if it's an
291-
// operation)
292-
mlir::NamedAttrList elidedAttrs =
293-
mlir::NamedAttrList{memrefOp->getAttrs()};
294-
for (const mlir::NamedAttribute &attr : declareOp->getAttrs())
295-
if (!elidedAttrs.get(attr.getName()))
296-
memrefOp->setAttr(attr.getName(), attr.getValue());
297-
298284
rewriter.replaceOp(declareOp, declareOp.getMemref());
299285
return mlir::success();
300286
}

flang/test/Fir/declare-codegen.fir

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,5 @@ func.func @test_local_memref() {
6161
%1 = fir.declare %0 {uniq_name = "local_array_declare", acc.declare = #acc.declare<dataClause = acc_create>} : (!fir.ref<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
6262
return
6363
}
64-
// NODECL-LABEL: func.func @test_local_memref() {
65-
66-
// Note: the uniq_name is not attached of fir.declare is not preserved because it conflicts with the uniq_name of the memref
67-
// NODECL: fir.alloca{{.*}}{acc.declare = #acc.declare<dataClause = acc_create>, uniq_name = "local_array"}
68-
6964
// DECL-LABEL: func.func @test_local_memref() {
7065
// DECL: fircg.ext_declare{{.*}}{acc.declare = #acc.declare<dataClause = acc_create>, uniq_name = "local_array_declare"}

0 commit comments

Comments
 (0)