diff --git a/flang/lib/Optimizer/Transforms/AbstractResult.cpp b/flang/lib/Optimizer/Transforms/AbstractResult.cpp --- a/flang/lib/Optimizer/Transforms/AbstractResult.cpp +++ b/flang/lib/Optimizer/Transforms/AbstractResult.cpp @@ -353,7 +353,12 @@ assert(func.getFunctionType() == getNewFunctionType(funcTy, shouldBoxResult)); } else { + llvm::SmallVector allArgs; + func.getAllArgAttrs(allArgs); + allArgs.insert(allArgs.begin(), + mlir::DictionaryAttr::get(func->getContext())); func.setType(getNewFunctionType(funcTy, shouldBoxResult)); + func.setAllArgAttrs(allArgs); } } } diff --git a/flang/test/Fir/abstract-result-2.fir b/flang/test/Fir/abstract-result-2.fir --- a/flang/test/Fir/abstract-result-2.fir +++ b/flang/test/Fir/abstract-result-2.fir @@ -2,7 +2,8 @@ // Check that the attributes are shifted along with their corresponding arguments -//CHECK: func.func @_QMi8Pintrinsic_pack0(%arg0: !fir.ref>>>, %arg1: !fir.box> {fir.bindc_name = "array"}, %arg2: !fir.ref> {fir.bindc_name = "mask"}, %arg3: !fir.box> {fir.bindc_name = "vector", fir.optional}) +// CHECK-LABEL: func.func @_QMi8Pintrinsic_pack0 +// CHECK-SAME:(%arg0: !fir.ref>>>, %arg1: !fir.box> {fir.bindc_name = "array"}, %arg2: !fir.ref> {fir.bindc_name = "mask"}, %arg3: !fir.box> {fir.bindc_name = "vector", fir.optional}) func.func @_QMi8Pintrinsic_pack0(%arg0: !fir.box> {fir.bindc_name = "array"}, %arg1: !fir.ref> {fir.bindc_name = "mask"}, %arg2: !fir.box> {fir.bindc_name = "vector", fir.optional}) -> !fir.box>> { %0 = fir.alloca !fir.box>> @@ -25,3 +26,7 @@ return %13 : !fir.box>> } func.func private @_FortranAPack(!fir.ref>, !fir.box, !fir.box, !fir.box) -> none attributes {fir.runtime} + +// CHECK-LABEL: func.func private @empty +// CHECK-SAME:(!fir.ref>>>, !fir.box> {fir.bindc_name = "array"}, !fir.ref> {fir.bindc_name = "mask"}, !fir.box> {fir.bindc_name = "vector", fir.optional}) +func.func private @empty(%arg0: !fir.box> {fir.bindc_name = "array"}, %arg1: !fir.ref> {fir.bindc_name = "mask"}, %arg2: !fir.box> {fir.bindc_name = "vector", fir.optional}) -> !fir.box>>