diff options
author | jeanPerier <jperier@nvidia.com> | 2023-12-20 10:15:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-20 10:15:09 +0100 |
commit | 36a073a5f45e0da3b84bd5284219d64586a97d5d (patch) | |
tree | 2214c029b45c76d9b9af670b5115be42d09925ff /flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | |
parent | 3b1f06e52712a56bf33757d596482c60013d63fd (diff) | |
download | llvm-36a073a5f45e0da3b84bd5284219d64586a97d5d.zip llvm-36a073a5f45e0da3b84bd5284219d64586a97d5d.tar.gz llvm-36a073a5f45e0da3b84bd5284219d64586a97d5d.tar.bz2 |
[flang] Add option to skip struct argument rewrite in target-rewrite (#75939)
Be consistent with complex and character rewrite so that the pass can be
run selectively.
Diffstat (limited to 'flang/lib/Optimizer/CodeGen/TargetRewrite.cpp')
-rw-r--r-- | flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp index 277f3e4..2f5c8cc 100644 --- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp +++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp @@ -79,6 +79,7 @@ public: TargetRewrite(const fir::TargetRewriteOptions &options) { noCharacterConversion = options.noCharacterConversion; noComplexConversion = options.noComplexConversion; + noStructConversion = options.noStructConversion; } void runOnOperation() override final { @@ -252,6 +253,11 @@ public: fir::CodeGenSpecifics::Marshalling &newInTyAndAttrs, llvm::SmallVectorImpl<mlir::Value> &newOpers, mlir::Value &savedStackPtr) { + if (noStructConversion) { + newInTyAndAttrs.push_back(fir::CodeGenSpecifics::getTypeAndAttr(recTy)); + newOpers.push_back(oper); + return; + } auto structArgs = specifics->structArgumentType(loc, recTy, newInTyAndAttrs); if (structArgs.size() != 1) @@ -522,6 +528,10 @@ public: void lowerStructSignatureArg(mlir::Location loc, fir::RecordType recTy, fir::CodeGenSpecifics::Marshalling &newInTyAndAttrs) { + if (noStructConversion) { + newInTyAndAttrs.push_back(fir::CodeGenSpecifics::getTypeAndAttr(recTy)); + return; + } auto structArgs = specifics->structArgumentType(loc, recTy, newInTyAndAttrs); newInTyAndAttrs.insert(newInTyAndAttrs.end(), structArgs.begin(), @@ -645,7 +655,7 @@ public: !noCharacterConversion) || (fir::isa_complex(ty) && !noComplexConversion) || (ty.isa<mlir::IntegerType>() && hasCCallingConv) || - ty.isa<fir::RecordType>()) { + (ty.isa<fir::RecordType>() && !noStructConversion)) { LLVM_DEBUG(llvm::dbgs() << "rewrite " << signature << " for target\n"); return false; } @@ -1128,6 +1138,10 @@ public: void doStructArg(mlir::func::FuncOp func, fir::RecordType recTy, fir::CodeGenSpecifics::Marshalling &newInTyAndAttrs, FIXUPS &fixups) { + if (noStructConversion) { + newInTyAndAttrs.push_back(fir::CodeGenSpecifics::getTypeAndAttr(recTy)); + return; + } auto structArgs = specifics->structArgumentType(func.getLoc(), recTy, newInTyAndAttrs); createFuncOpArgFixups(func, newInTyAndAttrs, structArgs, fixups); |