|
33 | 33 | #include "llvm/ADT/STLExtras.h" |
34 | 34 | #include "llvm/ADT/SmallVector.h" |
35 | 35 | #include "llvm/ADT/TypeSwitch.h" |
| 36 | +#include "llvm/Support/CommandLine.h" |
36 | 37 |
|
37 | 38 | namespace { |
38 | 39 | #include "flang/Optimizer/Dialect/CanonicalizationPatterns.inc" |
39 | 40 | } // namespace |
40 | 41 |
|
| 42 | +static llvm::cl::opt<bool> clUseStrictVolatileVerification( |
| 43 | + "strict-fir-volatile-verifier", llvm::cl::init(false), |
| 44 | + llvm::cl::desc( |
| 45 | + "use stricter verifier for FIR operations with volatile types")); |
| 46 | + |
| 47 | +bool fir::useStrictVolatileVerification() { |
| 48 | + return clUseStrictVolatileVerification; |
| 49 | +} |
| 50 | + |
41 | 51 | static void propagateAttributes(mlir::Operation *fromOp, |
42 | 52 | mlir::Operation *toOp) { |
43 | 53 | if (!fromOp || !toOp) |
@@ -1535,11 +1545,14 @@ llvm::LogicalResult fir::ConvertOp::verify() { |
1535 | 1545 | // represent volatility. |
1536 | 1546 | const bool toLLVMPointer = mlir::isa<mlir::LLVM::LLVMPointerType>(outType); |
1537 | 1547 | const bool toInteger = fir::isa_integer(outType); |
1538 | | - if (fir::isa_volatile_type(inType) != fir::isa_volatile_type(outType) && |
1539 | | - !toLLVMPointer && !toInteger) |
1540 | | - return emitOpError("cannot convert between volatile and non-volatile " |
1541 | | - "types, use fir.volatile_cast instead ") |
1542 | | - << inType << " / " << outType; |
| 1548 | + if (fir::useStrictVolatileVerification()) { |
| 1549 | + if (fir::isa_volatile_type(inType) != fir::isa_volatile_type(outType) && |
| 1550 | + !toLLVMPointer && !toInteger) { |
| 1551 | + return emitOpError("cannot convert between volatile and non-volatile " |
| 1552 | + "types, use fir.volatile_cast instead ") |
| 1553 | + << inType << " / " << outType; |
| 1554 | + } |
| 1555 | + } |
1543 | 1556 | if (canBeConverted(inType, outType)) |
1544 | 1557 | return mlir::success(); |
1545 | 1558 | return emitOpError("invalid type conversion") |
@@ -1841,6 +1854,10 @@ llvm::LogicalResult fir::TypeInfoOp::verify() { |
1841 | 1854 | static llvm::LogicalResult |
1842 | 1855 | verifyEmboxOpVolatilityInvariants(mlir::Type memrefType, |
1843 | 1856 | mlir::Type resultType) { |
| 1857 | + |
| 1858 | + if (!fir::useStrictVolatileVerification()) |
| 1859 | + return mlir::success(); |
| 1860 | + |
1844 | 1861 | mlir::Type boxElementType = |
1845 | 1862 | llvm::TypeSwitch<mlir::Type, mlir::Type>(resultType) |
1846 | 1863 | .Case<fir::BoxType, fir::ClassType>( |
|
0 commit comments