Skip to content

Commit 2735369

Browse files
Add loc() tests and relax convert op verification
1 parent 2be1324 commit 2735369

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

flang/include/flang/Optimizer/Dialect/FIROps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2756,7 +2756,7 @@ def fir_AddrOfOp : fir_OneResultOp<"address_of", [NoMemoryEffect]> {
27562756
let assemblyFormat = "`(` $symbol `)` attr-dict `:` type($resTy)";
27572757
}
27582758

2759-
def fir_VolatileCastOp : fir_SimpleOneResultOp<"volatile_cast", [NoMemoryEffect]> {
2759+
def fir_VolatileCastOp : fir_SimpleOneResultOp<"volatile_cast", [Pure]> {
27602760
let summary = "cast between volatile and non-volatile types";
27612761
let description = [{
27622762
Cast between volatile and non-volatile types. The types must be otherwise

flang/lib/Optimizer/Dialect/FIROps.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,12 +1529,14 @@ bool fir::ConvertOp::canBeConverted(mlir::Type inType, mlir::Type outType) {
15291529
llvm::LogicalResult fir::ConvertOp::verify() {
15301530
mlir::Type inType = getValue().getType();
15311531
mlir::Type outType = getType();
1532-
// If we're converting to an LLVM pointer type in code generation, we don't
1532+
// If we're converting to an LLVM pointer type or an integer, we don't
15331533
// need to check for volatility mismatch - volatility will be handled by the
1534-
// memory operations themselves at that point.
1534+
// memory operations themselves in llvm code generation and ptr-to-int can't
1535+
// represent volatility.
15351536
const bool toLLVMPointer = mlir::isa<mlir::LLVM::LLVMPointerType>(outType);
1537+
const bool toInteger = fir::isa_integer(outType);
15361538
if (fir::isa_volatile_type(inType) != fir::isa_volatile_type(outType) &&
1537-
!toLLVMPointer)
1539+
!toLLVMPointer && !toInteger)
15381540
return emitOpError("cannot convert between volatile and non-volatile "
15391541
"types, use fir.volatile_cast instead ")
15401542
<< inType << " / " << outType;

flang/test/Lower/volatile4.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ program p
44
integer,volatile::i,arr(10)
55
integer,volatile,target::tgt(10)
66
integer,volatile,pointer,dimension(:)::ptr
7+
i = loc(i)
78
ptr => tgt
89
i=0
910
arr=1

0 commit comments

Comments
 (0)