diff options
author | Slava Zakharin <szakharin@nvidia.com> | 2023-02-09 14:38:24 -0800 |
---|---|---|
committer | Slava Zakharin <szakharin@nvidia.com> | 2023-02-10 08:57:37 -0800 |
commit | ff8742df9e65c60de2fce0b19c0f52fd663626a1 (patch) | |
tree | aa723551fd33064fb40468bfe5df856caa23fea3 /flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | |
parent | 81767f52f49339be2c78fc9bf831856b9f57e2f0 (diff) | |
download | llvm-ff8742df9e65c60de2fce0b19c0f52fd663626a1.zip llvm-ff8742df9e65c60de2fce0b19c0f52fd663626a1.tar.gz llvm-ff8742df9e65c60de2fce0b19c0f52fd663626a1.tar.bz2 |
[flang] Fixed selective TargetRewrite.
Some conversions were still happening under no-complex/character-conversion
options. This change fixes that and adds a LIT test.
Differential Revision: https://reviews.llvm.org/D143685
Diffstat (limited to 'flang/lib/Optimizer/CodeGen/TargetRewrite.cpp')
-rw-r--r-- | flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp index bddeffb..c51bf5f 100644 --- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp +++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp @@ -119,9 +119,13 @@ public: mlir::ModuleOp getModule() { return getOperation(); } template <typename A, typename B, typename C> - std::function<mlir::Value(mlir::Operation *)> + std::optional<std::function<mlir::Value(mlir::Operation *)>> rewriteCallComplexResultType(mlir::Location loc, A ty, B &newResTys, B &newInTys, C &newOpers) { + if (noComplexConversion) { + newResTys.push_back(ty); + return std::nullopt; + } auto m = specifics->complexReturnType(loc, ty.getElementType()); // Currently targets mandate COMPLEX is a single aggregate or packed // scalar, including the sret case. @@ -153,6 +157,12 @@ public: template <typename A, typename B, typename C> void rewriteCallComplexInputType(A ty, mlir::Value oper, B &newInTys, C &newOpers) { + if (noComplexConversion) { + newInTys.push_back(ty); + newOpers.push_back(oper); + return; + } + auto *ctx = ty.getContext(); mlir::Location loc = mlir::UnknownLoc::get(ctx); if (auto *op = oper.getDefiningOp()) @@ -245,6 +255,11 @@ public: .template Case<fir::BoxCharType>([&](fir::BoxCharType boxTy) { bool sret; if constexpr (std::is_same_v<std::decay_t<A>, fir::CallOp>) { + if (noCharacterConversion) { + newInTys.push_back(boxTy); + newOpers.push_back(oper); + return; + } sret = callOp.getCallee() && functionArgIsSRet( index, getModule().lookupSymbol<mlir::func::FuncOp>( |