[flang-commits] [flang] ba0c082 - [flang] Use the newly introduced AliasAnalysisOpInterface.

Tobias Gysi via flang-commits flang-commits at lists.llvm.org
Wed Mar 1 23:38:46 PST 2023


Author: Tobias Gysi
Date: 2023-03-02T08:32:42+01:00
New Revision: ba0c082b49c05a5e7181a8de3cf5480ccd199d52

URL: https://github.com/llvm/llvm-project/commit/ba0c082b49c05a5e7181a8de3cf5480ccd199d52
DIFF: https://github.com/llvm/llvm-project/commit/ba0c082b49c05a5e7181a8de3cf5480ccd199d52.diff

LOG: [flang] Use the newly introduced AliasAnalysisOpInterface.

This revision uses the AliasAnalysisOpInterface introduced in
https://reviews.llvm.org/D144851 to set the tbaa attributes
of load and store ops. With the attribute it is also possible to
set the attribute on atomics as well as on memcopy and
memove intrinsics as soon as https://reviews.llvm.org/D144965
lands.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D145044

Added: 
    

Modified: 
    flang/lib/Optimizer/CodeGen/CodeGen.cpp
    flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
    flang/lib/Optimizer/CodeGen/TBAABuilder.h
    flang/lib/Optimizer/CodeGen/TypeConverter.h

Removed: 
    


################################################################################
diff  --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 3816d9b7caf51..75f95f213c87a 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -352,8 +352,9 @@ class FIROpConversion : public mlir::ConvertOpToLLVMPattern<FromOp> {
     return *static_cast<fir::LLVMTypeConverter *>(this->getTypeConverter());
   }
 
-  void attachTBAATag(mlir::Operation *op, mlir::Type baseFIRType,
-                     mlir::Type accessFIRType, mlir::LLVM::GEPOp gep) const {
+  void attachTBAATag(mlir::LLVM::AliasAnalysisOpInterface op,
+                     mlir::Type baseFIRType, mlir::Type accessFIRType,
+                     mlir::LLVM::GEPOp gep) const {
     lowerTy().attachTBAATag(op, baseFIRType, accessFIRType, gep);
   }
 

diff  --git a/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp b/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
index c42081869c7ad..74269e710b944 100644
--- a/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
+++ b/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
@@ -141,7 +141,7 @@ SymbolRefAttr TBAABuilder::getDataAccessTag(Type baseFIRType,
   return getAnyDataAccessTag();
 }
 
-void TBAABuilder::attachTBAATag(Operation *op, Type baseFIRType,
+void TBAABuilder::attachTBAATag(AliasAnalysisOpInterface op, Type baseFIRType,
                                 Type accessFIRType, GEPOp gep) {
   if (!enableTBAA)
     return;
@@ -163,10 +163,7 @@ void TBAABuilder::attachTBAATag(Operation *op, Type baseFIRType,
   if (!tbaaTagSym)
     return;
 
-  auto tbaaAttr = ArrayAttr::get(op->getContext(), tbaaTagSym);
-  llvm::TypeSwitch<Operation *>(op)
-      .Case<LoadOp, StoreOp>([&](auto memOp) { memOp.setTbaaAttr(tbaaAttr); })
-      .Default([](auto) { llvm_unreachable("expected LoadOp or StoreOp"); });
+  op.setTBAATags(ArrayAttr::get(op->getContext(), tbaaTagSym));
 }
 
 } // namespace fir

diff  --git a/flang/lib/Optimizer/CodeGen/TBAABuilder.h b/flang/lib/Optimizer/CodeGen/TBAABuilder.h
index f0dfc0ea48b92..48c40a4403dae 100644
--- a/flang/lib/Optimizer/CodeGen/TBAABuilder.h
+++ b/flang/lib/Optimizer/CodeGen/TBAABuilder.h
@@ -170,8 +170,9 @@ class TBAABuilder {
 
   // Attach the llvm.tbaa attribute to the given memory accessing operation
   // based on the provided base/access FIR types and the GEPOp.
-  void attachTBAATag(mlir::Operation *op, mlir::Type baseFIRType,
-                     mlir::Type accessFIRType, mlir::LLVM::GEPOp gep);
+  void attachTBAATag(mlir::LLVM::AliasAnalysisOpInterface op,
+                     mlir::Type baseFIRType, mlir::Type accessFIRType,
+                     mlir::LLVM::GEPOp gep);
 
 private:
   // Return unique string name based on `basename`.

diff  --git a/flang/lib/Optimizer/CodeGen/TypeConverter.h b/flang/lib/Optimizer/CodeGen/TypeConverter.h
index be8843b44f44f..4f472d31c93e6 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -390,8 +390,9 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
   KindMapping &getKindMap() { return kindMapping; }
 
   // Relay TBAA tag attachment to TBAABuilder.
-  void attachTBAATag(mlir::Operation *op, mlir::Type baseFIRType,
-                     mlir::Type accessFIRType, mlir::LLVM::GEPOp gep) {
+  void attachTBAATag(mlir::LLVM::AliasAnalysisOpInterface op,
+                     mlir::Type baseFIRType, mlir::Type accessFIRType,
+                     mlir::LLVM::GEPOp gep) {
     tbaaBuilder.attachTBAATag(op, baseFIRType, accessFIRType, gep);
   }
 


        


More information about the flang-commits mailing list