Skip to content

Commit

Permalink
[flang] Use the newly introduced AliasAnalysisOpInterface.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gysit committed Mar 2, 2023
1 parent 588da01 commit ba0c082
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
5 changes: 3 additions & 2 deletions flang/lib/Optimizer/CodeGen/CodeGen.cpp
Expand Up @@ -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);
}

Expand Down
7 changes: 2 additions & 5 deletions flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
Expand Up @@ -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;
Expand All @@ -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
5 changes: 3 additions & 2 deletions flang/lib/Optimizer/CodeGen/TBAABuilder.h
Expand Up @@ -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`.
Expand Down
5 changes: 3 additions & 2 deletions flang/lib/Optimizer/CodeGen/TypeConverter.h
Expand Up @@ -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);
}

Expand Down

0 comments on commit ba0c082

Please sign in to comment.