Skip to content

Commit 69cc16f

Browse files
committed
Revert "[flang] Set LLVM specific attributes to fir.call's of Fortran runtime. (#128093)"
This reverts commit 36fdeb2.
1 parent 4d53616 commit 69cc16f

File tree

19 files changed

+162
-1971
lines changed

19 files changed

+162
-1971
lines changed

flang/include/flang/Optimizer/Builder/FIRBuilder.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -385,15 +385,6 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
385385
mlir::FunctionType ty,
386386
mlir::SymbolTable *);
387387

388-
/// Returns a named function for a Fortran runtime API, creating
389-
/// it, if it does not exist in the module yet.
390-
/// If \p isIO is set to true, then the function corresponds
391-
/// to one of Fortran runtime IO APIs.
392-
mlir::func::FuncOp createRuntimeFunction(mlir::Location loc,
393-
llvm::StringRef name,
394-
mlir::FunctionType ty,
395-
bool isIO = false);
396-
397388
/// Cast the input value to IndexType.
398389
mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val) {
399390
return createConvert(loc, getIndexType(), val);

flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "flang/Optimizer/Builder/FIRBuilder.h"
2222
#include "flang/Optimizer/Dialect/FIRDialect.h"
2323
#include "flang/Optimizer/Dialect/FIRType.h"
24-
#include "flang/Runtime/io-api-consts.h"
2524
#include "flang/Runtime/reduce.h"
2625
#include "flang/Support/Fortran.h"
2726
#include "mlir/IR/BuiltinTypes.h"
@@ -587,33 +586,6 @@ constexpr TypeBuilderFunc getModel<void>() {
587586
};
588587
}
589588

590-
// Define additional runtime type models specific to IO.
591-
template <>
592-
constexpr TypeBuilderFunc getModel<Fortran::runtime::io::IoStatementState *>() {
593-
return getModel<char *>();
594-
}
595-
template <>
596-
constexpr TypeBuilderFunc getModel<Fortran::runtime::io::Iostat>() {
597-
return [](mlir::MLIRContext *context) -> mlir::Type {
598-
return mlir::IntegerType::get(context,
599-
8 * sizeof(Fortran::runtime::io::Iostat));
600-
};
601-
}
602-
template <>
603-
constexpr TypeBuilderFunc
604-
getModel<const Fortran::runtime::io::NamelistGroup &>() {
605-
return [](mlir::MLIRContext *context) -> mlir::Type {
606-
return fir::ReferenceType::get(mlir::TupleType::get(context));
607-
};
608-
}
609-
template <>
610-
constexpr TypeBuilderFunc
611-
getModel<const Fortran::runtime::io::NonTbpDefinedIoTable *>() {
612-
return [](mlir::MLIRContext *context) -> mlir::Type {
613-
return fir::ReferenceType::get(mlir::TupleType::get(context));
614-
};
615-
}
616-
617589
REDUCTION_REF_OPERATION_MODEL(std::int8_t)
618590
REDUCTION_VALUE_OPERATION_MODEL(std::int8_t)
619591
REDUCTION_REF_OPERATION_MODEL(std::int16_t)
@@ -806,22 +778,16 @@ struct RuntimeTableEntry<RuntimeTableKey<KT>, RuntimeIdentifier<Cs...>> {
806778
/// argument is intended to be of the form: <mkRTKey(runtime function name)>.
807779
template <typename RuntimeEntry>
808780
static mlir::func::FuncOp getRuntimeFunc(mlir::Location loc,
809-
fir::FirOpBuilder &builder,
810-
bool isIO = false) {
781+
fir::FirOpBuilder &builder) {
811782
using namespace Fortran::runtime;
812783
auto name = RuntimeEntry::name;
813784
auto func = builder.getNamedFunction(name);
814785
if (func)
815786
return func;
816787
auto funTy = RuntimeEntry::getTypeModel()(builder.getContext());
817-
return builder.createRuntimeFunction(loc, name, funTy, isIO);
818-
}
819-
820-
/// Get (or generate) the MLIR FuncOp for a given IO runtime function.
821-
template <typename E>
822-
static mlir::func::FuncOp getIORuntimeFunc(mlir::Location loc,
823-
fir::FirOpBuilder &builder) {
824-
return getRuntimeFunc<E>(loc, builder, /*isIO=*/true);
788+
func = builder.createFunction(loc, name, funTy);
789+
func->setAttr(FIROpsDialect::getFirRuntimeAttrName(), builder.getUnitAttr());
790+
return func;
825791
}
826792

827793
namespace helper {

flang/include/flang/Optimizer/Dialect/FIRDialect.td

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ def FIROpsDialect : Dialect {
5656
static constexpr llvm::StringRef getFirRuntimeAttrName() {
5757
return "fir.runtime";
5858
}
59-
// Return string name of fir.memory attributes.
60-
// It is attached to fir.call operations to convey
61-
// llvm.memory attributes to LLVM IR.
62-
// Its value is intended to be mlir::LLVM::MemoryEffectsAttr.
63-
// TODO: we should probably make it an inherent attribute
64-
// of fir.call, though, it is supposed to be a short-lived
65-
// attribute that appears right before CodeGen and only
66-
// meaningful for LLVM, so it is unclear if embedding
67-
// it into fir.call makes sense.
68-
static constexpr llvm::StringRef getFirCallMemoryAttrName() {
69-
return "fir.llvm_memory";
70-
}
7159
}];
7260
}
7361

flang/include/flang/Optimizer/Transforms/Passes.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ namespace fir {
6060
#define GEN_PASS_DECL_FUNCTIONATTR
6161
#define GEN_PASS_DECL_CONSTANTARGUMENTGLOBALISATIONOPT
6262
#define GEN_PASS_DECL_COMPILERGENERATEDNAMESCONVERSION
63-
#define GEN_PASS_DECL_SETRUNTIMECALLATTRIBUTES
64-
#define GEN_PASS_DECL_GENRUNTIMECALLSFORTEST
6563

6664
#include "flang/Optimizer/Transforms/Passes.h.inc"
6765

flang/include/flang/Optimizer/Transforms/Passes.td

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -453,37 +453,4 @@ def CUFGPUToLLVMConversion : Pass<"cuf-gpu-convert-to-llvm", "mlir::ModuleOp"> {
453453
];
454454
}
455455

456-
def SetRuntimeCallAttributes
457-
: Pass<"set-runtime-call-attrs", "mlir::func::FuncOp"> {
458-
let summary = "Set Fortran runtime fir.call attributes targeting LLVM IR";
459-
let description = [{
460-
This pass sets different attributes for Fortran runtime calls
461-
that enable more optimizations in LLVM backend.
462-
For the time being, the meaning of these attributes is not
463-
strictly defined for HLFIR/FIR.
464-
}];
465-
let dependentDialects = ["fir::FIROpsDialect", "mlir::LLVM::LLVMDialect"];
466-
}
467-
468-
def GenRuntimeCallsForTest
469-
: Pass<"gen-runtime-calls-for-test", "mlir::ModuleOp"> {
470-
let summary =
471-
"Print FIR containing declarations/calls of Fortran runtime functions";
472-
let description = [{
473-
This pass is only for developers to be able to print FIR
474-
that declares and calls Fortran runtime functions.
475-
It helps producing/updating tests for passes that modify
476-
the func/call operations based on some knowledge of
477-
Fortran runtime.
478-
}];
479-
let options =
480-
[Option<"doGenerateCalls", "do-generate-calls", "bool",
481-
/*default=*/"false",
482-
"Generate thin wrapper functions that call Fortran runtime "
483-
"functions. If it is set to false, then only the declarations "
484-
"are generated.">,
485-
];
486-
let dependentDialects = ["fir::FIROpsDialect", "mlir::func::FuncDialect"];
487-
}
488-
489456
#endif // FLANG_OPTIMIZER_TRANSFORMS_PASSES

flang/include/flang/Optimizer/Transforms/RuntimeFunctions.inc

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)