[flang-commits] [flang] 5f9e049 - In the case the function body is empty, shifting attributes as inserting argument is not supported
via flang-commits
flang-commits at lists.llvm.org
Thu Nov 10 08:54:55 PST 2022
Author: Renaud-K
Date: 2022-11-10T08:53:34-08:00
New Revision: 5f9e0491116e18b238f16091bc9a892cc6f7e64d
URL: https://github.com/llvm/llvm-project/commit/5f9e0491116e18b238f16091bc9a892cc6f7e64d
DIFF: https://github.com/llvm/llvm-project/commit/5f9e0491116e18b238f16091bc9a892cc6f7e64d.diff
LOG: In the case the function body is empty, shifting attributes as inserting argument is not supported
Differential revision: https://reviews.llvm.org/D137757
Added:
Modified:
flang/lib/Optimizer/Transforms/AbstractResult.cpp
flang/test/Fir/abstract-result-2.fir
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/Transforms/AbstractResult.cpp b/flang/lib/Optimizer/Transforms/AbstractResult.cpp
index b295885384131..dcc6e902fd84c 100644
--- a/flang/lib/Optimizer/Transforms/AbstractResult.cpp
+++ b/flang/lib/Optimizer/Transforms/AbstractResult.cpp
@@ -353,7 +353,12 @@ class AbstractResultOnFuncOpt
assert(func.getFunctionType() ==
getNewFunctionType(funcTy, shouldBoxResult));
} else {
+ llvm::SmallVector<mlir::DictionaryAttr> 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
index 3c13943dca166..08b723b830593 100644
--- 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<!fir.box<!fir.heap<!fir.array<?xi32>>>>, %arg1: !fir.box<!fir.array<?x?x?xi32>> {fir.bindc_name = "array"}, %arg2: !fir.ref<!fir.logical<4>> {fir.bindc_name = "mask"}, %arg3: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "vector", fir.optional})
+// CHECK-LABEL: func.func @_QMi8Pintrinsic_pack0
+// CHECK-SAME:(%arg0: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, %arg1: !fir.box<!fir.array<?x?x?xi32>> {fir.bindc_name = "array"}, %arg2: !fir.ref<!fir.logical<4>> {fir.bindc_name = "mask"}, %arg3: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "vector", fir.optional})
func.func @_QMi8Pintrinsic_pack0(%arg0: !fir.box<!fir.array<?x?x?xi32>> {fir.bindc_name = "array"}, %arg1: !fir.ref<!fir.logical<4>> {fir.bindc_name = "mask"}, %arg2: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "vector", fir.optional}) -> !fir.box<!fir.heap<!fir.array<?xi32>>> {
%0 = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
@@ -25,3 +26,7 @@ func.func @_QMi8Pintrinsic_pack0(%arg0: !fir.box<!fir.array<?x?x?xi32>> {fir.bin
return %13 : !fir.box<!fir.heap<!fir.array<?xi32>>>
}
func.func private @_FortranAPack(!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, !fir.box<none>) -> none attributes {fir.runtime}
+
+// CHECK-LABEL: func.func private @empty
+// CHECK-SAME:(!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.box<!fir.array<?x?x?xi32>> {fir.bindc_name = "array"}, !fir.ref<!fir.logical<4>> {fir.bindc_name = "mask"}, !fir.box<!fir.array<?xi32>> {fir.bindc_name = "vector", fir.optional})
+func.func private @empty(%arg0: !fir.box<!fir.array<?x?x?xi32>> {fir.bindc_name = "array"}, %arg1: !fir.ref<!fir.logical<4>> {fir.bindc_name = "mask"}, %arg2: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "vector", fir.optional}) -> !fir.box<!fir.heap<!fir.array<?xi32>>>
More information about the flang-commits
mailing list