Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ static bool isDummyArgument(mlir::Value v) {
if (!blockArg)
return false;

return blockArg.getOwner()->isEntryBlock();
mlir::Block *owner = blockArg.getOwner();
if (!owner->isEntryBlock() ||
!mlir::isa<mlir::FunctionOpInterface>(owner->getParentOp()))
return false;
return true;
}

/// Temporary function to skip through all the no op operations
Expand Down
1 change: 1 addition & 0 deletions flang/lib/Optimizer/Transforms/AddAliasTags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static std::string getFuncArgName(mlir::Value arg) {
"arg is a function argument");
mlir::FunctionOpInterface func = mlir::dyn_cast<mlir::FunctionOpInterface>(
blockArg.getOwner()->getParentOp());
assert(func && "This is not a function argument");
mlir::StringAttr attr = func.getArgAttrOfType<mlir::StringAttr>(
blockArg.getArgNumber(), "fir.bindc_name");
if (!attr)
Expand Down
37 changes: 37 additions & 0 deletions flang/test/Transforms/tbaa.fir
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,40 @@
// CHECK: fir.store %[[VAL_8]] to %[[VAL_12]] : !fir.ref<i32>
// CHECK: return
// CHECK: }

// -----

// Make sure we don't mistake other block arguments as dummy arguments:

omp.declare_reduction @add_reduction_i32 : i32 init {
^bb0(%arg0: i32):
%c0_i32 = arith.constant 0 : i32
omp.yield(%c0_i32 : i32)
} combiner {
^bb0(%arg0: i32, %arg1: i32):
%0 = arith.addi %arg0, %arg1 : i32
omp.yield(%0 : i32)
}

func.func @_QQmain() attributes {fir.bindc_name = "reduce"} {
%c10_i32 = arith.constant 10 : i32
%c6_i32 = arith.constant 6 : i32
%c-1_i32 = arith.constant -1 : i32
%0 = fir.address_of(@_QFEi) : !fir.ref<i32>
%1 = fir.declare %0 {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> !fir.ref<i32>
omp.parallel reduction(@add_reduction_i32 %1 -> %arg0 : !fir.ref<i32>) {
// CHECK: omp.parallel reduction({{.*}}) {
%8 = fir.declare %arg0 {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> !fir.ref<i32>
// CHECK-NEXT: %[[DECL:.*]] = fir.declare
fir.store %c-1_i32 to %8 : !fir.ref<i32>
// CHECK-NOT: fir.store %{{.*}} to %[[DECL]] {tbaa = %{{.*}}} : !fir.ref<i32>
// CHECK: fir.store %{{.*}} to %[[DECL]] : !fir.ref<i32>
omp.terminator
}
return
}

fir.global internal @_QFEi : i32 {
%c0_i32 = arith.constant 0 : i32
fir.has_value %c0_i32 : i32
}