diff options
| author | jeanPerier <jperier@nvidia.com> | 2024-08-23 14:32:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-23 14:32:43 +0200 |
| commit | 2051a7bcd3f375c063f803df3cfde9e6e6d724ad (patch) | |
| tree | b82c1916c454f42d8c0cc1bfb11c1d5865788539 /flang/lib/Lower/ConvertCall.cpp | |
| parent | 2f144ac5a13dc39389e1850417f4ac766b1f1ada (diff) | |
[flang][NFC] turn fir.call is_bind_c into enum for procedure flags (#105691)
First patch to fix a BIND(C) ABI issue
(https://github.com/llvm/llvm-project/issues/102113). I need to keep
track of BIND(C) in more locations (fir.dispatch and func.func
operations), and I need to fix a few passes that are dropping the
attribute on the floor. Since I expect more procedure attributes that
cannot be reflected in mlir::FunctionType will be needed for ABI,
optimizations, or debug info, this NFC patch adds a new enum attribute
to keep track of procedure attributes in the IR.
This patch is not updating lowering to lower more attributes, this will
be done in a separate patch to keep the test changes low here.
Adding the attribute on fir.dispatch and func.func will also be done in
separate patches.
Diffstat (limited to 'flang/lib/Lower/ConvertCall.cpp')
| -rw-r--r-- | flang/lib/Lower/ConvertCall.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp index fd873f55dd84..f445a21e560b 100644 --- a/flang/lib/Lower/ConvertCall.cpp +++ b/flang/lib/Lower/ConvertCall.cpp @@ -372,7 +372,7 @@ std::pair<fir::ExtendedValue, bool> Fortran::lower::genCallOpAndResult( auto stackSaveSymbol = bldr->getSymbolRefAttr(stackSaveFn.getName()); mlir::Value sp; fir::CallOp call = bldr->create<fir::CallOp>( - loc, stackSaveFn.getFunctionType().getResults(), stackSaveSymbol, + loc, stackSaveSymbol, stackSaveFn.getFunctionType().getResults(), mlir::ValueRange{}); if (call.getNumResults() != 0) sp = call.getResult(0); @@ -380,9 +380,9 @@ std::pair<fir::ExtendedValue, bool> Fortran::lower::genCallOpAndResult( auto stackRestoreFn = fir::factory::getLlvmStackRestore(*bldr); auto stackRestoreSymbol = bldr->getSymbolRefAttr(stackRestoreFn.getName()); - bldr->create<fir::CallOp>(loc, + bldr->create<fir::CallOp>(loc, stackRestoreSymbol, stackRestoreFn.getFunctionType().getResults(), - stackRestoreSymbol, mlir::ValueRange{sp}); + mlir::ValueRange{sp}); }); } mlir::Value temp = @@ -640,11 +640,15 @@ std::pair<fir::ExtendedValue, bool> Fortran::lower::genCallOpAndResult( if (callNumResults != 0) callResult = dispatch.getResult(0); } else { - // Standard procedure call with fir.call. - auto call = builder.create<fir::CallOp>(loc, funcType.getResults(), - funcSymbolAttr, operands); + // TODO: gather other procedure attributes. + fir::FortranProcedureFlagsEnumAttr procAttrs; if (caller.characterize().IsBindC()) - call.setIsBindC(true); + procAttrs = fir::FortranProcedureFlagsEnumAttr::get( + builder.getContext(), fir::FortranProcedureFlagsEnum::bind_c); + + // Standard procedure call with fir.call. + auto call = builder.create<fir::CallOp>( + loc, funcType.getResults(), funcSymbolAttr, operands, procAttrs); callNumResults = call.getNumResults(); if (callNumResults != 0) |
