[flang-commits] [flang] [flang] Apply nocapture attribute to dummy arguments (PR #116182)
via flang-commits
flang-commits at lists.llvm.org
Mon Nov 18 01:08:30 PST 2024
================
@@ -45,6 +47,25 @@ void FunctionAttrPass::runOnOperation() {
LLVM_DEBUG(llvm::dbgs() << "Func-name:" << func.getSymName() << "\n");
+ llvm::StringRef name = func.getSymName();
+ auto deconstructed = fir::NameUniquer::deconstruct(name);
+ bool isFromModule = !deconstructed.second.modules.empty();
+
+ if ((isFromModule || !func.isDeclaration()) &&
+ !fir::hasBindcAttr(func.getOperation())) {
+ llvm::StringRef nocapture = mlir::LLVM::LLVMDialect::getNoCaptureAttrName();
+ mlir::UnitAttr unitAttr = mlir::UnitAttr::get(func.getContext());
+
+ for (auto [index, argType] : llvm::enumerate(func.getArgumentTypes())) {
+ if (mlir::isa<fir::ReferenceType>(argType) &&
+ !fir::isPointerType(argType) &&
----------------
s-watanabe314 wrote:
Thank you for the review.
I thought that since the dummy argument defined as `integer, pointer :: x` is translated to `fir.ref<fir.box<fir.ptr<i32>>>` (https://godbolt.org/z/qbYn59d6M), it could be determined using `fir::isPointerType`.
As another way to determine whether a dummy argument has the pointer attribute, should I add the `fir.pointer` attribute, similar to target and asynchronous, and check it with `!func.getArgAttr(index, fir::getPointerAttrName())`?
https://github.com/llvm/llvm-project/pull/116182
More information about the flang-commits
mailing list