[flang-commits] [flang] [FIRToMemRef] copy ACC Variable Name attribute (PR #187724)
Scott Manley via flang-commits
flang-commits at lists.llvm.org
Fri Mar 20 08:53:38 PDT 2026
https://github.com/rscottmanley created https://github.com/llvm/llvm-project/pull/187724
When converting from fir.alloca to memref.alloca, also copy the acc variable name attribute if it exists
>From 926263ff4ec9ce359df978e45cb155b073f51227 Mon Sep 17 00:00:00 2001
From: Scott Manley <scmanley at nvidia.com>
Date: Fri, 20 Mar 2026 08:51:19 -0700
Subject: [PATCH] [FIRToMemRef] copy ACC Variable Name attribute
When converting from fir.alloca to memref.alloca, also copy the acc
variable name attribute if it exists
---
flang/lib/Optimizer/Transforms/FIRToMemRef.cpp | 1 +
flang/test/Transforms/FIRToMemRef/alloca.mlir | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/flang/lib/Optimizer/Transforms/FIRToMemRef.cpp b/flang/lib/Optimizer/Transforms/FIRToMemRef.cpp
index 90b4b01e30f62..ee6f644aea911 100644
--- a/flang/lib/Optimizer/Transforms/FIRToMemRef.cpp
+++ b/flang/lib/Optimizer/Transforms/FIRToMemRef.cpp
@@ -330,6 +330,7 @@ void FIRToMemRef::rewriteAlloca(fir::AllocaOp firAlloca,
copyAttribute(firAlloca, alloca, firAlloca.getBindcNameAttrName());
copyAttribute(firAlloca, alloca, firAlloca.getUniqNameAttrName());
copyAttribute(firAlloca, alloca, cuf::getDataAttrName());
+ copyAttribute(firAlloca, alloca, acc::getVarNameAttrName());
auto convert = fir::ConvertOp::create(rewriter, loc, type, alloca);
diff --git a/flang/test/Transforms/FIRToMemRef/alloca.mlir b/flang/test/Transforms/FIRToMemRef/alloca.mlir
index b2859370903f4..2c76c4a9b3849 100644
--- a/flang/test/Transforms/FIRToMemRef/alloca.mlir
+++ b/flang/test/Transforms/FIRToMemRef/alloca.mlir
@@ -86,11 +86,11 @@ func.func @peep_declare() {
// check that attributes are copied when they exist
// CHECK-LABEL: func.func @no_peep_declare
-// CHECK: memref.alloca() {bindc_name = "x", uniq_name = "y"} : memref<i32>
+// CHECK: memref.alloca() {acc.var_name = #acc.var_name<"z">, bindc_name = "x", uniq_name = "y"} : memref<i32>
// CHECK-NOT: memref.store %c1_i32, %alloca[] : memref<i32>
func.func @no_peep_declare() {
%c1_i32 = arith.constant 1 : i32
- %0 = fir.alloca i32 {bindc_name = "x", uniq_name = "y"}
+ %0 = fir.alloca i32 {acc.var_name = #acc.var_name<"z">, bindc_name = "x", uniq_name = "y"}
%1 = fir.declare %0 {uniq_name = "some_name"} : (!fir.ref<i32>) -> !fir.ref<i32>
fir.store %c1_i32 to %1 : !fir.ref<i32>
return
More information about the flang-commits
mailing list