[flang-commits] [flang] [fir][AddAliasTags] allow usage of AddAliasTag pass after FirToMemref (PR #219493)
Caroline Newcombe via flang-commits
flang-commits at lists.llvm.org
Mon Aug 31 08:13:16 PDT 2026
================
@@ -817,15 +817,28 @@ void AddAliasTagsPass::runOnAliasInterface(fir::FirAliasTagOpInterface op,
} else if (enableLocalAllocs &&
source.kind == fir::AliasAnalysis::SourceKind::Allocate) {
std::optional<llvm::StringRef> name;
- mlir::Operation *sourceOp =
- llvm::cast<mlir::Value>(source.origin.u).getDefiningOp();
+ mlir::Value sourceVal = llvm::cast<mlir::Value>(source.origin.u);
+ mlir::Operation *sourceOp = sourceVal.getDefiningOp();
bool unknownAllocOp = false;
if (auto alloc = mlir::dyn_cast_or_null<fir::AllocaOp>(sourceOp))
name = alloc.getUniqName();
else if (auto alloc = mlir::dyn_cast_or_null<fir::AllocMemOp>(sourceOp))
name = alloc.getUniqName();
- else
+ else if (mlir::StringAttr nameAttr =
+ sourceOp ? sourceOp->getAttrOfType<mlir::StringAttr>(
+ fir::AllocaOp::getUniqNameAttrName())
----------------
cenewcombe wrote:
Your explanation about deriving the name from the allocation operation, along with the change to `tbaa-codegen2.fir`, made me reconsider the `!empty` check. Since accesses sharing an allocation are guaranteed to use the same name, an empty name is still a sound shared bucket ("allocated data/"). The reset moves compiler temps with an empty name onto the parent "allocated data" tag, which makes them `MayAlias` named local allocations and loses existing TBAA precision.
Could we therefore drop the check and `name.reset`? Sorry for the mix-up here.
https://github.com/llvm/llvm-project/pull/219493
More information about the flang-commits
mailing list