[flang][NFC] use llvm.intr.stacksave/restore instead of opaque calls (#108562)

The new LLVM stack save/restore intrinsic operations are more convenient
than function calls because they do not add function declarations to the
module and therefore do not block the parallelisation of passes.
Furthermore they could be much more easily marked with memory effects
than function calls if that ever proved useful.

This builds on top of #107879.

Resolves #108016
This commit is contained in:
Tom Eccles 2024-09-16 12:33:37 +01:00 committed by GitHub
parent 9548dbedbc
commit 5aaf384b16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 124 additions and 155 deletions

View File

@ -29,6 +29,7 @@
#include <utility>
namespace mlir {
class DataLayout;
class SymbolTable;
}
@ -253,6 +254,15 @@ public:
mlir::ValueRange lenParams = {},
llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
/// Create an LLVM stack save intrinsic op. Returns the saved stack pointer.
/// The stack address space is fetched from the data layout of the current
/// module.
mlir::Value genStackSave(mlir::Location loc);
/// Create an LLVM stack restore intrinsic op. stackPointer should be a value
/// previously returned from genStackSave.
void genStackRestore(mlir::Location loc, mlir::Value stackPointer);
/// Create a global value.
fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
llvm::StringRef name,
@ -523,6 +533,9 @@ public:
setCommonAttributes(op);
}
/// Construct a data layout on demand and return it
mlir::DataLayout &getDataLayout();
private:
/// Set attributes (e.g. FastMathAttr) to \p op operation
/// based on the current attributes setting.
@ -537,6 +550,11 @@ private:
/// fir::GlobalOp and func::FuncOp symbol table to speed-up
/// lookups.
mlir::SymbolTable *symbolTable = nullptr;
/// DataLayout constructed on demand. Access via getDataLayout().
/// Stored via a unique_ptr rather than an optional so as not to bloat this
/// class when most instances won't ever need a data layout.
std::unique_ptr<mlir::DataLayout> dataLayout = nullptr;
};
} // namespace fir
@ -729,6 +747,9 @@ elideExtentsAlreadyInType(mlir::Type type, mlir::ValueRange shape);
llvm::SmallVector<mlir::Value>
elideLengthsAlreadyInType(mlir::Type type, mlir::ValueRange lenParams);
/// Get the address space which should be used for allocas
uint64_t getAllocaAddressSpace(mlir::DataLayout *dataLayout);
} // namespace fir::factory
#endif // FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H

View File

@ -42,12 +42,6 @@ mlir::func::FuncOp getLlvmGetRounding(FirOpBuilder &builder);
/// Get the `llvm.set.rounding` intrinsic.
mlir::func::FuncOp getLlvmSetRounding(FirOpBuilder &builder);
/// Get the `llvm.stacksave` intrinsic.
mlir::func::FuncOp getLlvmStackSave(FirOpBuilder &builder);
/// Get the `llvm.stackrestore` intrinsic.
mlir::func::FuncOp getLlvmStackRestore(FirOpBuilder &builder);
/// Get the `llvm.init.trampoline` intrinsic.
mlir::func::FuncOp getLlvmInitTrampoline(FirOpBuilder &builder);

View File

@ -45,7 +45,6 @@ void setMLIRDataLayoutFromAttributes(mlir::ModuleOp mlirModule,
/// std::nullopt.
std::optional<mlir::DataLayout>
getOrSetDataLayout(mlir::ModuleOp mlirModule, bool allowDefaultLayout = false);
} // namespace fir::support
#endif // FORTRAN_OPTIMIZER_SUPPORT_DATALAYOUT_H

View File

@ -3257,15 +3257,10 @@ private:
const Fortran::parser::CharBlock &endPosition =
eval.getLastNestedEvaluation().position;
localSymbols.pushScope();
mlir::func::FuncOp stackSave = fir::factory::getLlvmStackSave(*builder);
mlir::func::FuncOp stackRestore =
fir::factory::getLlvmStackRestore(*builder);
mlir::Value stackPtr =
builder->create<fir::CallOp>(toLocation(), stackSave).getResult(0);
mlir::Value stackPtr = builder->genStackSave(toLocation());
mlir::Location endLoc = genLocation(endPosition);
stmtCtx.attachCleanup([=]() {
builder->create<fir::CallOp>(endLoc, stackRestore, stackPtr);
});
stmtCtx.attachCleanup(
[=]() { builder->genStackRestore(endLoc, stackPtr); });
Fortran::semantics::Scope &scope =
bridge.getSemanticsContext().FindScope(endPosition);
scopeBlockIdMap.try_emplace(&scope, ++blockId);

View File

@ -368,22 +368,9 @@ std::pair<fir::ExtendedValue, bool> Fortran::lower::genCallOpAndResult(
if (!extents.empty() || !lengths.empty()) {
auto *bldr = &converter.getFirOpBuilder();
auto stackSaveFn = fir::factory::getLlvmStackSave(builder);
auto stackSaveSymbol = bldr->getSymbolRefAttr(stackSaveFn.getName());
mlir::Value sp;
fir::CallOp call = bldr->create<fir::CallOp>(
loc, stackSaveSymbol, stackSaveFn.getFunctionType().getResults(),
mlir::ValueRange{});
if (call.getNumResults() != 0)
sp = call.getResult(0);
stmtCtx.attachCleanup([bldr, loc, sp]() {
auto stackRestoreFn = fir::factory::getLlvmStackRestore(*bldr);
auto stackRestoreSymbol =
bldr->getSymbolRefAttr(stackRestoreFn.getName());
bldr->create<fir::CallOp>(loc, stackRestoreSymbol,
stackRestoreFn.getFunctionType().getResults(),
mlir::ValueRange{sp});
});
mlir::Value sp = bldr->genStackSave(loc);
stmtCtx.attachCleanup(
[bldr, loc, sp]() { bldr->genStackRestore(loc, sp); });
}
mlir::Value temp =
builder.createTemporary(loc, type, ".result", extents, resultLengths);

View File

@ -18,6 +18,7 @@
#include "flang/Optimizer/Dialect/FIRAttr.h"
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Support/DataLayout.h"
#include "flang/Optimizer/Support/FatalError.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Optimizer/Support/Utils.h"
@ -328,6 +329,17 @@ mlir::Value fir::FirOpBuilder::createHeapTemporary(
name, dynamicLength, dynamicShape, attrs);
}
mlir::Value fir::FirOpBuilder::genStackSave(mlir::Location loc) {
mlir::Type voidPtr = mlir::LLVM::LLVMPointerType::get(
getContext(), fir::factory::getAllocaAddressSpace(&getDataLayout()));
return create<mlir::LLVM::StackSaveOp>(loc, voidPtr);
}
void fir::FirOpBuilder::genStackRestore(mlir::Location loc,
mlir::Value stackPointer) {
create<mlir::LLVM::StackRestoreOp>(loc, stackPointer);
}
/// Create a global variable in the (read-only) data section. A global variable
/// must have a unique name to identify and reference it.
fir::GlobalOp fir::FirOpBuilder::createGlobal(
@ -791,6 +803,15 @@ void fir::FirOpBuilder::setFastMathFlags(
setFastMathFlags(arithFMF);
}
// Construction of an mlir::DataLayout is expensive so only do it on demand and
// memoise it in the builder instance
mlir::DataLayout &fir::FirOpBuilder::getDataLayout() {
if (dataLayout)
return *dataLayout;
dataLayout = std::make_unique<mlir::DataLayout>(getModule());
return *dataLayout;
}
//===--------------------------------------------------------------------===//
// ExtendedValue inquiry helper implementation
//===--------------------------------------------------------------------===//
@ -1664,3 +1685,10 @@ void fir::factory::setInternalLinkage(mlir::func::FuncOp func) {
mlir::LLVM::LinkageAttr::get(func->getContext(), internalLinkage);
func->setAttr("llvm.linkage", linkage);
}
uint64_t fir::factory::getAllocaAddressSpace(mlir::DataLayout *dataLayout) {
if (dataLayout)
if (mlir::Attribute addrSpace = dataLayout->getAllocaMemorySpace())
return mlir::cast<mlir::IntegerAttr>(addrSpace).getUInt();
return 0;
}

View File

@ -76,25 +76,6 @@ fir::factory::getLlvmSetRounding(fir::FirOpBuilder &builder) {
funcTy);
}
mlir::func::FuncOp fir::factory::getLlvmStackSave(fir::FirOpBuilder &builder) {
// FIXME: This should query the target alloca address space
auto ptrTy = builder.getRefType(builder.getIntegerType(8));
auto funcTy =
mlir::FunctionType::get(builder.getContext(), std::nullopt, {ptrTy});
return builder.createFunction(builder.getUnknownLoc(), "llvm.stacksave.p0",
funcTy);
}
mlir::func::FuncOp
fir::factory::getLlvmStackRestore(fir::FirOpBuilder &builder) {
// FIXME: This should query the target alloca address space
auto ptrTy = builder.getRefType(builder.getIntegerType(8));
auto funcTy =
mlir::FunctionType::get(builder.getContext(), {ptrTy}, std::nullopt);
return builder.createFunction(builder.getUnknownLoc(), "llvm.stackrestore.p0",
funcTy);
}
mlir::func::FuncOp
fir::factory::getLlvmInitTrampoline(fir::FirOpBuilder &builder) {
auto ptrTy = builder.getRefType(builder.getIntegerType(8));

View File

@ -1236,25 +1236,18 @@ private:
inline void clearMembers() { setMembers(nullptr, nullptr, nullptr); }
uint64_t getAllocaAddressSpace() const {
if (dataLayout)
if (mlir::Attribute addrSpace = dataLayout->getAllocaMemorySpace())
return llvm::cast<mlir::IntegerAttr>(addrSpace).getUInt();
return 0;
}
// Inserts a call to llvm.stacksave at the current insertion
// point and the given location. Returns the call's result Value.
inline mlir::Value genStackSave(mlir::Location loc) {
mlir::Type voidPtr = mlir::LLVM::LLVMPointerType::get(
rewriter->getContext(), getAllocaAddressSpace());
return rewriter->create<mlir::LLVM::StackSaveOp>(loc, voidPtr);
fir::FirOpBuilder builder(*rewriter, getModule());
return builder.genStackSave(loc);
}
// Inserts a call to llvm.stackrestore at the current insertion
// point and the given location and argument.
inline void genStackRestore(mlir::Location loc, mlir::Value sp) {
rewriter->create<mlir::LLVM::StackRestoreOp>(loc, sp);
fir::FirOpBuilder builder(*rewriter, getModule());
return builder.genStackRestore(loc, sp);
}
fir::CodeGenSpecifics *specifics = nullptr;

View File

@ -734,28 +734,12 @@ void AllocMemConversion::insertStackSaveRestore(
auto mod = oldAlloc->getParentOfType<mlir::ModuleOp>();
fir::FirOpBuilder builder{rewriter, mod};
mlir::func::FuncOp stackSaveFn = fir::factory::getLlvmStackSave(builder);
mlir::SymbolRefAttr stackSaveSym =
builder.getSymbolRefAttr(stackSaveFn.getName());
builder.setInsertionPoint(oldAlloc);
mlir::Value sp =
builder
.create<fir::CallOp>(oldAlloc.getLoc(), stackSaveSym,
stackSaveFn.getFunctionType().getResults(),
mlir::ValueRange{})
.getResult(0);
mlir::func::FuncOp stackRestoreFn =
fir::factory::getLlvmStackRestore(builder);
mlir::SymbolRefAttr stackRestoreSym =
builder.getSymbolRefAttr(stackRestoreFn.getName());
mlir::Value sp = builder.genStackSave(oldAlloc.getLoc());
auto createStackRestoreCall = [&](mlir::Operation *user) {
builder.setInsertionPoint(user);
builder.create<fir::CallOp>(user->getLoc(), stackRestoreSym,
stackRestoreFn.getFunctionType().getResults(),
mlir::ValueRange{sp});
builder.genStackRestore(user->getLoc(), sp);
};
for (mlir::Operation *user : oldAlloc->getUsers()) {

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Transforms/Passes.h"
@ -31,34 +32,20 @@ public:
};
} // namespace
uint64_t getAllocaAddressSpace(Operation *op) {
mlir::ModuleOp module = mlir::dyn_cast_or_null<mlir::ModuleOp>(op);
if (!module)
module = op->getParentOfType<mlir::ModuleOp>();
if (mlir::Attribute addrSpace =
mlir::DataLayout(module).getAllocaMemorySpace())
return llvm::cast<mlir::IntegerAttr>(addrSpace).getUInt();
return 0;
}
void StackReclaimPass::runOnOperation() {
auto *op = getOperation();
auto *context = &getContext();
mlir::OpBuilder builder(context);
mlir::Type voidPtr =
mlir::LLVM::LLVMPointerType::get(context, getAllocaAddressSpace(op));
fir::FirOpBuilder builder(op, fir::getKindMapping(op));
op->walk([&](fir::DoLoopOp loopOp) {
mlir::Location loc = loopOp.getLoc();
if (!loopOp.getRegion().getOps<fir::AllocaOp>().empty()) {
builder.setInsertionPointToStart(&loopOp.getRegion().front());
auto stackSaveOp = builder.create<LLVM::StackSaveOp>(loc, voidPtr);
mlir::Value sp = builder.genStackSave(loc);
auto *terminator = loopOp.getRegion().back().getTerminator();
builder.setInsertionPoint(terminator);
builder.create<LLVM::StackRestoreOp>(loc, stackSaveOp);
builder.genStackRestore(loc, sp);
}
});
}

View File

@ -134,7 +134,7 @@ end subroutine
!CHECK-NEXT: run 1 save : where/mask
!CHECK-NEXT: run 2 evaluate: where/region_assign1
!CHECK-LABEL: ------------ scheduling where in _QPonly_once ------------
!CHECK-NEXT: unknown effect: %{{[0-9]+}} = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8>
!CHECK-NEXT: unknown effect: %{{[0-9]+}} = llvm.intr.stacksave : !llvm.ptr
!CHECK-NEXT: run 1 save (w): where/mask
!CHECK-NEXT: run 2 evaluate: where/region_assign1
!CHECK-NEXT: run 3 evaluate: where/region_assign2

View File

@ -8,9 +8,9 @@ module m
end subroutine test_proc
end interface
end module m
!CHECK-DAG: %[[S0:.*]] = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8>
!CHECK-DAG: %[[S0:.*]] = llvm.intr.stacksave : !llvm.ptr
!CHECK-DAG: fir.call @test_proc() proc_attrs<bind_c> fastmath<contract> : () -> ()
!CHECK-DAG: fir.call @llvm.stackrestore.p0(%[[S0]]) fastmath<contract> : (!fir.ref<i8>) -> ()
!CHECK-DAG: llvm.intr.stackrestore %[[S0]] : !llvm.ptr
!CHECK-DAG: func.func private @test_proc() attributes {fir.bindc_name = "test_proc"}
subroutine test
BLOCK

View File

@ -182,12 +182,12 @@ end subroutine char_return
! CHECK: %[[VAL_23:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_24:.*]] = arith.cmpi sgt, %[[VAL_22]], %[[VAL_23]] : index
! CHECK: %[[VAL_25:.*]] = arith.select %[[VAL_24]], %[[VAL_22]], %[[VAL_23]] : index
! CHECK: %[[VAL_26:.*]] = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8>
! CHECK: %[[VAL_26:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_27:.*]] = fir.call @_QPcallee(%[[VAL_2]], %[[VAL_25]], %[[VAL_20]]) fastmath<contract> : (!fir.ref<!fir.char<1,3>>, index, !fir.boxchar<1>) -> !fir.boxchar<1>
! CHECK: %[[VAL_28:.*]]:2 = hlfir.declare %[[VAL_2]] typeparams %[[VAL_25]] {uniq_name = ".tmp.func_result"} : (!fir.ref<!fir.char<1,3>>, index) -> (!fir.ref<!fir.char<1,3>>, !fir.ref<!fir.char<1,3>>)
! CHECK: %[[MustFree:.*]] = arith.constant false
! CHECK: %[[ResultTemp:.*]] = hlfir.as_expr %[[VAL_28]]#0 move %[[MustFree]] : (!fir.ref<!fir.char<1,3>>, i1) -> !hlfir.expr<!fir.char<1,3>>
! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_26]]) fastmath<contract> : (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[VAL_26]] : !llvm.ptr
! CHECK: hlfir.yield_element %[[ResultTemp]] : !hlfir.expr<!fir.char<1,3>>
! CHECK: }
! CHECK: %[[VAL_29:.*]] = arith.constant 0 : index

View File

@ -105,6 +105,6 @@ end subroutine
! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_8:.*]] = arith.cmpi sgt, %[[VAL_6]], %[[VAL_7]] : index
! CHECK: %[[VAL_9:.*]] = arith.select %[[VAL_8]], %[[VAL_6]], %[[VAL_7]] : index
! CHECK: %[[VAL_10:.*]] = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8>
! CHECK: %[[VAL_10:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_11:.*]] = fir.box_addr %[[VAL_4]] : (!fir.boxproc<(!fir.ref<!fir.char<1,4>>, index, !fir.ref<!fir.type<_QMmTt3{c:!fir.char<1,4>,p:!fir.boxproc<(!fir.ref<!fir.char<1,4>>, index, !fir.ref<!fir.type<_QMmTt3>>) -> !fir.boxchar<1>>}>>) -> !fir.boxchar<1>>) -> ((!fir.ref<!fir.char<1,4>>, index, !fir.ref<!fir.type<_QMmTt3{c:!fir.char<1,4>,p:!fir.boxproc<(!fir.ref<!fir.char<1,4>>, index, !fir.ref<!fir.type<_QMmTt3>>) -> !fir.boxchar<1>>}>>) -> !fir.boxchar<1>)
! CHECK: %[[VAL_12:.*]] = fir.call %[[VAL_11]](%[[VAL_1]], %[[VAL_9]], %[[VAL_2]]#1) fastmath<contract> : (!fir.ref<!fir.char<1,4>>, index, !fir.ref<!fir.type<_QMmTt3{c:!fir.char<1,4>,p:!fir.boxproc<(!fir.ref<!fir.char<1,4>>, index, !fir.ref<!fir.type<_QMmTt3>>) -> !fir.boxchar<1>>}>>) -> !fir.boxchar<1>

View File

@ -26,10 +26,10 @@ end subroutine
! CHECK-LABEL: func.func @_QPtest_where(
! CHECK: hlfir.where {
! CHECK-NOT: hlfir.exactly_once
! CHECK: %[[VAL_17:.*]] = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8>
! CHECK: %[[VAL_17:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_19:.*]] = fir.call @_QPlogical_func1() fastmath<contract> : () -> !fir.array<100x!fir.logical<4>>
! CHECK: hlfir.yield %{{.*}} : !hlfir.expr<100x!fir.logical<4>> cleanup {
! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_17]]) fastmath<contract> : (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[VAL_17]] : !llvm.ptr
! CHECK: }
! CHECK: } do {
! CHECK: hlfir.region_assign {
@ -70,10 +70,10 @@ end subroutine
! CHECK: }
! CHECK: hlfir.elsewhere mask {
! CHECK: %[[VAL_62:.*]] = hlfir.exactly_once : !hlfir.expr<100x!fir.logical<4>> {
! CHECK: %[[VAL_72:.*]] = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8>
! CHECK: %[[VAL_72:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: fir.call @_QPlogical_func2() fastmath<contract> : () -> !fir.array<100x!fir.logical<4>>
! CHECK: hlfir.yield %{{.*}} : !hlfir.expr<100x!fir.logical<4>> cleanup {
! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_72]]) fastmath<contract> : (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[VAL_72]] : !llvm.ptr
! CHECK: }
! CHECK: }
! CHECK: hlfir.yield %[[VAL_62]] : !hlfir.expr<100x!fir.logical<4>>
@ -123,11 +123,11 @@ end subroutine
! CHECK: } (%[[VAL_10:.*]]: i32) {
! CHECK: %[[VAL_11:.*]] = hlfir.forall_index "i" %[[VAL_10]] : (i32) -> !fir.ref<i32>
! CHECK: hlfir.where {
! CHECK: %[[VAL_21:.*]] = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8>
! CHECK: %[[VAL_21:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK-NOT: hlfir.exactly_once
! CHECK: %[[VAL_23:.*]] = fir.call @_QPpure_logical_func1() fastmath<contract> : () -> !fir.array<100x!fir.logical<4>>
! CHECK: hlfir.yield %{{.*}} : !hlfir.expr<100x!fir.logical<4>> cleanup {
! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_21]]) fastmath<contract> : (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[VAL_21]] : !llvm.ptr
! CHECK: }
! CHECK: } do {
! CHECK: hlfir.region_assign {
@ -172,10 +172,10 @@ end subroutine
! CHECK: }
! CHECK: hlfir.elsewhere mask {
! CHECK: %[[VAL_129:.*]] = hlfir.exactly_once : !hlfir.expr<100x!fir.logical<4>> {
! CHECK: %[[VAL_139:.*]] = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8>
! CHECK: %[[VAL_139:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_141:.*]] = fir.call @_QPpure_logical_func2() fastmath<contract> : () -> !fir.array<100x!fir.logical<4>>
! CHECK: hlfir.yield %{{.*}} : !hlfir.expr<100x!fir.logical<4>> cleanup {
! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_139]]) fastmath<contract> : (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[VAL_139]] : !llvm.ptr
! CHECK: }
! CHECK: }
! CHECK: hlfir.yield %[[VAL_129]] : !hlfir.expr<100x!fir.logical<4>>

View File

@ -227,7 +227,7 @@ subroutine foo6(c)
! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (i32) -> index
! CHECK: %[[CMPI:.*]] = arith.cmpi sgt, %[[VAL_16]], %{{.*}} : index
! CHECK: %[[SELECT:.*]] = arith.select %[[CMPI]], %[[VAL_16]], %{{.*}} : index
! CHECK: %[[VAL_17:.*]] = fir.call @llvm.stacksave.p0() {{.*}}: () -> !fir.ref<i8>
! CHECK: %[[VAL_17:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_18:.*]] = fir.alloca !fir.char<1,?>(%[[SELECT]] : index) {bindc_name = ".result"}
! CHECK: %[[VAL_19:.*]] = fir.call @_QMchar_elemPelem_return_char(%[[VAL_18]], %[[SELECT]], %[[VAL_14]]) {{.*}}: (!fir.ref<!fir.char<1,?>>, index, !fir.boxchar<1>) -> !fir.boxchar<1>
! CHECK: %[[VAL_20:.*]] = arith.cmpi slt, %[[VAL_6]]#1, %[[SELECT]] : index
@ -253,7 +253,7 @@ subroutine foo6(c)
! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_31]], %[[VAL_2]] : index
! CHECK: br ^bb3(%[[VAL_35]], %[[VAL_36]] : index, index)
! CHECK: ^bb5:
! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_17]]) {{.*}}: (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[VAL_17]] : !llvm.ptr
! CHECK: %[[VAL_37:.*]] = arith.subi %[[VAL_10]], %[[VAL_2]] : index
! CHECK: br ^bb1(%[[VAL_12]], %[[VAL_37]] : index, index)
! CHECK: ^bb6:

View File

@ -7,13 +7,13 @@ program bb ! block stack management and exits
integer :: i, j
! CHECK: fir.store %c0{{.*}} to %[[V_1]] : !fir.ref<i32>
i = 0
! CHECK: %[[V_3:[0-9]+]] = fir.call @llvm.stacksave.p0()
! CHECK: %[[V_3:[0-9]+]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: fir.store %{{.*}} to %[[V_1]] : !fir.ref<i32>
! CHECK: br ^bb1
! CHECK: ^bb1: // 2 preds: ^bb0, ^bb16
! CHECK: cond_br %{{.*}}, ^bb2, ^bb17
! CHECK: ^bb2: // pred: ^bb1
! CHECK: %[[V_11:[0-9]+]] = fir.call @llvm.stacksave.p0()
! CHECK: %[[V_11:[0-9]+]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: fir.store %{{.*}} to %[[V_1]] : !fir.ref<i32>
! CHECK: cond_br %{{.*}}, ^bb3, ^bb4
! CHECK: ^bb3: // pred: ^bb2
@ -27,29 +27,29 @@ program bb ! block stack management and exits
! CHECK: fir.store %{{.*}} to %[[V_1]] : !fir.ref<i32>
! CHECK: cond_br %{{.*}}, ^bb7, ^bb8
! CHECK: ^bb7: // pred: ^bb6
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_11]])
! CHECK: llvm.intr.stackrestore %[[V_11]] : !llvm.ptr
! CHECK: br ^bb15
! CHECK: ^bb8: // pred: ^bb6
! CHECK: fir.store %{{.*}} to %[[V_1]] : !fir.ref<i32>
! CHECK: cond_br %{{.*}}, ^bb9, ^bb10
! CHECK: ^bb9: // pred: ^bb8
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_11]])
! CHECK: llvm.intr.stackrestore %[[V_11]] : !llvm.ptr
! CHECK: br ^bb16
! CHECK: ^bb10: // 2 preds: ^bb3, ^bb8
! CHECK: fir.store %{{.*}} to %[[V_1]] : !fir.ref<i32>
! CHECK: cond_br %{{.*}}, ^bb11, ^bb12
! CHECK: ^bb11: // pred: ^bb10
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_11]])
! CHECK: llvm.intr.stackrestore %[[V_11]] : !llvm.ptr
! CHECK: br ^bb18
! CHECK: ^bb12: // pred: ^bb10
! CHECK: fir.store %{{.*}} to %[[V_1]] : !fir.ref<i32>
! CHECK: cond_br %{{.*}}, ^bb13, ^bb14
! CHECK: ^bb13: // pred: ^bb12
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_11]])
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_3]])
! CHECK: llvm.intr.stackrestore %[[V_11]] : !llvm.ptr
! CHECK: llvm.intr.stackrestore %[[V_3]] : !llvm.ptr
! CHECK: br ^bb19
! CHECK: ^bb14: // 2 preds: ^bb5, ^bb12
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_11]])
! CHECK: llvm.intr.stackrestore %[[V_11]] : !llvm.ptr
! CHECK: br ^bb15
! CHECK: ^bb15: // 2 preds: ^bb7, ^bb14
! CHECK: br ^bb16
@ -59,7 +59,7 @@ program bb ! block stack management and exits
! CHECK: fir.store %{{.*}} to %[[V_1]] : !fir.ref<i32>
! CHECK: cf.br ^bb18
! CHECK: ^bb18: // 2 preds: ^bb11, ^bb17
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_3]])
! CHECK: llvm.intr.stackrestore %[[V_3]] : !llvm.ptr
! CHECK: br ^bb19
! CHECK: ^bb19: // 2 preds: ^bb13, ^bb18
block
@ -79,10 +79,10 @@ program bb ! block stack management and exits
12 end block
100 print*, i ! expect 21
! CHECK: %[[V_51:[0-9]+]] = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8>
! CHECK: %[[V_51:[0-9]+]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: fir.store %c5{{.*}} to %[[V_0]] : !fir.ref<i32>
! CHECK: fir.call @ss(%[[V_0]]) proc_attrs<bind_c> fastmath<contract> : (!fir.ref<i32>) -> ()
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_51]]) fastmath<contract> : (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[V_51]] : !llvm.ptr
block
interface
subroutine ss(n) bind(c)

View File

@ -38,15 +38,15 @@ end
! CHECK-LABEL: func @_QPm1
function m1(index)
! CHECK: %[[V_0:[0-9]+]] = fir.alloca i32 {bindc_name = "m1"
! CHECK: %[[V_1:[0-9]+]] = fir.call @llvm.stacksave.p0()
! CHECK: %[[V_1:[0-9]+]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[V_2:[0-9]+]] = fir.load %arg0 : !fir.ref<i32>
! CHECK: %[[V_3:[0-9]+]] = arith.cmpi eq, %[[V_2]], %c1{{.*}} : i32
! CHECK: cf.cond_br %[[V_3]], ^bb1, ^bb2
! CHECK: ^bb1: // pred: ^bb0
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_1]])
! CHECK: llvm.intr.stackrestore %[[V_1]] : !llvm.ptr
! CHECK: cf.br ^bb3
! CHECK: ^bb2: // pred: ^bb0
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_1]])
! CHECK: llvm.intr.stackrestore %[[V_1]] : !llvm.ptr
! CHECK: fir.store %c0{{.*}} to %[[V_0]] : !fir.ref<i32>
! CHECK: cf.br ^bb4
! CHECK: ^bb3: // pred: ^bb1
@ -65,21 +65,21 @@ end
! CHECK-LABEL: func @_QPm2
function m2(index)
! CHECK: %[[V_0:[0-9]+]] = fir.alloca i32 {bindc_name = "m2"
! CHECK: %[[V_1:[0-9]+]] = fir.call @llvm.stacksave.p0()
! CHECK: %[[V_1:[0-9]+]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[V_2:[0-9]+]] = fir.load %arg0 : !fir.ref<i32>
! CHECK: %[[V_3:[0-9]+]] = arith.cmpi eq, %[[V_2]], %c1{{.*}} : i32
! CHECK: cf.cond_br %[[V_3]], ^bb1, ^bb2
! CHECK: ^bb1: // pred: ^bb0
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_1]])
! CHECK: llvm.intr.stackrestore %[[V_1]] : !llvm.ptr
! CHECK: cf.br ^bb5
! CHECK: ^bb2: // pred: ^bb0
! CHECK: %[[V_4:[0-9]+]] = arith.cmpi eq, %[[V_2]], %c2{{.*}} : i32
! CHECK: cf.cond_br %[[V_4]], ^bb3, ^bb4
! CHECK: ^bb3: // pred: ^bb2
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_1]])
! CHECK: llvm.intr.stackrestore %[[V_1]] : !llvm.ptr
! CHECK: cf.br ^bb6
! CHECK: ^bb4: // pred: ^bb2
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_1]])
! CHECK: llvm.intr.stackrestore %[[V_1]] : !llvm.ptr
! CHECK: fir.store %c0{{.*}} to %[[V_0]] : !fir.ref<i32>
! CHECK: cf.br ^bb7
! CHECK: ^bb5: // pred: ^bb1
@ -102,27 +102,27 @@ end
! CHECK-LABEL: func @_QPm3
function m3(index)
! CHECK: %[[V_0:[0-9]+]] = fir.alloca i32 {bindc_name = "m3"
! CHECK: %[[V_1:[0-9]+]] = fir.call @llvm.stacksave.p0()
! CHECK: %[[V_1:[0-9]+]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[V_2:[0-9]+]] = fir.load %arg0 : !fir.ref<i32>
! CHECK: %[[V_3:[0-9]+]] = arith.cmpi eq, %[[V_2]], %c1{{.*}} : i32
! CHECK: cf.cond_br %[[V_3]], ^bb1, ^bb2
! CHECK: ^bb1: // pred: ^bb0
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_1]])
! CHECK: llvm.intr.stackrestore %[[V_1]] : !llvm.ptr
! CHECK: cf.br ^bb7
! CHECK: ^bb2: // pred: ^bb0
! CHECK: %[[V_4:[0-9]+]] = arith.cmpi eq, %[[V_2]], %c2{{.*}} : i32
! CHECK: cf.cond_br %[[V_4]], ^bb3, ^bb4
! CHECK: ^bb3: // pred: ^bb2
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_1]])
! CHECK: llvm.intr.stackrestore %[[V_1]] : !llvm.ptr
! CHECK: cf.br ^bb8
! CHECK: ^bb4: // pred: ^bb2
! CHECK: %[[V_5:[0-9]+]] = arith.cmpi eq, %[[V_2]], %c3{{.*}} : i32
! CHECK: cf.cond_br %[[V_5]], ^bb5, ^bb6
! CHECK: ^bb5: // pred: ^bb4
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_1]])
! CHECK: llvm.intr.stackrestore %[[V_1]] : !llvm.ptr
! CHECK: cf.br ^bb9
! CHECK: ^bb6: // pred: ^bb4
! CHECK: fir.call @llvm.stackrestore.p0(%[[V_1]])
! CHECK: llvm.intr.stackrestore %[[V_1]] : !llvm.ptr
! CHECK: fir.store %c0{{.*}} to %[[V_0]] : !fir.ref<i32>
! CHECK: cf.br ^bb10
! CHECK: ^bb7: // pred: ^bb1

View File

@ -195,7 +195,7 @@ subroutine call_explicit_length_with_iface(bar10)
! CHECK: %[[C0:.*]] = arith.constant 0 : index
! CHECK: %[[COMPI:.*]] = arith.cmpi sgt, %[[VAL_5]], %[[C0]] : index
! CHECK: %[[SELECT:.*]] = arith.select %[[CMPI]], %[[VAL_5]], %[[C0]] : index
! CHECK: %[[VAL_6:.*]] = fir.call @llvm.stacksave.p0() {{.*}}: () -> !fir.ref<i8>
! CHECK: %[[VAL_6:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_7:.*]] = fir.alloca !fir.char<1,?>(%[[SELECT]] : index) {bindc_name = ".result"}
! CHECK: %[[VAL_8:.*]] = fir.convert %[[WAL_1]] : (() -> ()) -> ((!fir.ref<!fir.char<1,?>>, index, !fir.ref<i64>) -> !fir.boxchar<1>)
! CHECK: fir.call %[[VAL_8]](%[[VAL_7]], %[[SELECT]], %[[VAL_1]]) {{.*}}: (!fir.ref<!fir.char<1,?>>, index, !fir.ref<i64>) -> !fir.boxchar<1>

View File

@ -252,12 +252,12 @@ subroutine test_call_to_used_interface(dummy_proc)
call takes_array(dummy_proc())
! CHECK: %[[VAL_1:.*]] = arith.constant 100 : index
! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.array<100xf32> {bindc_name = ".result"}
! CHECK: %[[VAL_3:.*]] = fir.call @llvm.stacksave.p0() {{.*}}: () -> !fir.ref<i8>
! CHECK: %[[VAL_3:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
! CHECK: %[[VAL_5:.*]] = fir.box_addr %[[VAL_0]] : (!fir.boxproc<() -> ()>) -> (() -> !fir.array<100xf32>)
! CHECK: %[[VAL_6:.*]] = fir.call %[[VAL_5]]() {{.*}}: () -> !fir.array<100xf32>
! CHECK: fir.save_result %[[VAL_6]] to %[[VAL_2]](%[[VAL_4]]) : !fir.array<100xf32>, !fir.ref<!fir.array<100xf32>>, !fir.shape<1>
! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<!fir.array<100xf32>>) -> !fir.ref<!fir.array<?xf32>>
! CHECK: fir.call @_QPtakes_array(%[[VAL_7]]) {{.*}}: (!fir.ref<!fir.array<?xf32>>) -> ()
! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_3]]) {{.*}}: (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[VAL_3]] : !llvm.ptr
end subroutine

View File

@ -232,7 +232,7 @@ end subroutine ac2
! CHECK: %[[C0:.*]] = arith.constant 0 : index
! CHECK: %[[CMPI:.*]] = arith.cmpi sgt, %[[VAL_80]], %[[C0]] : index
! CHECK: %[[SELECT:.*]] = arith.select %[[CMPI]], %[[VAL_80]], %[[C0]] : index
! CHECK: %[[VAL_81:.*]] = fir.call @llvm.stacksave.p0() {{.*}}: () -> !fir.ref<i8>
! CHECK: %[[VAL_81:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_82:.*]] = fir.shape %[[SELECT]] : (index) -> !fir.shape<1>
! CHECK: %[[VAL_83:.*]] = fir.convert %[[VAL_74]] : (!fir.box<!fir.array<1xi32>>) -> !fir.box<!fir.array<?xi32>>
! CHECK: %[[VAL_84:.*]] = fir.call @_QFac2Pfunc(%[[VAL_83]]) {{.*}}: (!fir.box<!fir.array<?xi32>>) -> !fir.array<3xi32>
@ -250,7 +250,7 @@ end subroutine ac2
! CHECK: %[[VAL_97:.*]] = fir.array_update %[[VAL_92]], %[[VAL_93]], %[[VAL_96]] : (!fir.array<?xi32>, i32, index) -> !fir.array<?xi32>
! CHECK: fir.result %[[VAL_97]] : !fir.array<?xi32>
! CHECK: }
! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_81]]) {{.*}}: (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[VAL_81]] : !llvm.ptr
! CHECK: fir.freemem %[[VAL_61]] : !fir.heap<!fir.array<1xi32>>
! CHECK: fir.freemem %[[VAL_57]] : !fir.heap<!fir.array<1xi32>>
! CHECK: fir.result %[[VAL_98:.*]] : !fir.array<?xi32>

View File

@ -36,7 +36,7 @@ contains
! CHECK: %[[C0:.*]] = arith.constant 0 : index
! CHECK: %[[CMPI:.*]] = arith.cmpi sgt, %[[VAL_16]], %[[C0]] : index
! CHECK: %[[SELECT:.*]] = arith.select %[[CMPI]], %[[VAL_16]], %[[C0]] : index
! CHECK: %[[VAL_17:.*]] = fir.call @llvm.stacksave.p0() {{.*}}: () -> !fir.ref<i8>
! CHECK: %[[VAL_17:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_18:.*]] = fir.alloca !fir.char<1,?>(%[[SELECT]] : index) {bindc_name = ".result"}
! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_13]] : (() -> ()) -> ((!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>)
! CHECK: %[[VAL_20:.*]] = fir.call %[[VAL_19]](%[[VAL_18]], %[[SELECT]]) {{.*}}: (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
@ -64,7 +64,7 @@ contains
! CHECK: %[[VAL_9:.*]] = fir.extract_value %[[VAL_3]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
! CHECK: %[[VAL_10:.*]] = fir.box_addr %[[VAL_9]] : (!fir.boxproc<() -> ()>) -> (() -> ())
! CHECK: %[[VAL_11:.*]] = fir.extract_value %[[VAL_3]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> i64
! CHECK: %[[VAL_12:.*]] = fir.call @llvm.stacksave.p0() {{.*}}: () -> !fir.ref<i8>
! CHECK: %[[VAL_12:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_13:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_11]] : i64) {bindc_name = ".result"}
! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_10]] : (() -> ()) -> ((!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>)
! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_11]] : (i64) -> index
@ -124,7 +124,7 @@ contains
! CHECK: %[[C0:.*]] = arith.constant 0 : index
! CHECK: %[[CMPI:.*]] = arith.cmpi sgt, %[[VAL_15]], %[[C0]] : index
! CHECK: %[[SELECT:.*]] = arith.select %[[CMPI]], %[[VAL_15]], %[[C0]] : index
! CHECK: %[[VAL_16:.*]] = fir.call @llvm.stacksave.p0() {{.*}}: () -> !fir.ref<i8>
! CHECK: %[[VAL_16:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_17:.*]] = fir.alloca !fir.array<?xi32>, %[[SELECT]] {bindc_name = ".result"}
print *, array_func()
end subroutine

View File

@ -515,12 +515,12 @@ end subroutine test_proc_dummy_other
! CHECK: %[[VAL_35:.*]] = fir.undefined tuple<!fir.boxproc<() -> ()>, i64>
! CHECK: %[[VAL_36:.*]] = fir.insert_value %[[VAL_35]], %[[VAL_34]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, !fir.boxproc<() -> ()>) -> tuple<!fir.boxproc<() -> ()>, i64>
! CHECK: %[[VAL_37:.*]] = fir.insert_value %[[VAL_36]], %[[VAL_8]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, i64) -> tuple<!fir.boxproc<() -> ()>, i64>
! CHECK: %[[VAL_38:.*]] = fir.call @llvm.stacksave.p0() {{.*}}: () -> !fir.ref<i8>
! CHECK: %[[VAL_38:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_39:.*]] = fir.call @_QPget_message(%[[VAL_11]], %[[VAL_9]], %[[VAL_37]]) {{.*}}: (!fir.ref<!fir.char<1,40>>, index, tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxchar<1>
! CHECK: %[[VAL_40:.*]] = fir.convert %[[VAL_11]] : (!fir.ref<!fir.char<1,40>>) -> !fir.ref<i8>
! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_9]] : (index) -> i64
! CHECK: %[[VAL_42:.*]] = fir.call @_FortranAioOutputAscii(%[[VAL_32]], %[[VAL_40]], %[[VAL_41]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64) -> i1
! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_38]]) {{.*}}: (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[VAL_38]] : !llvm.ptr
! CHECK: %[[VAL_43:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_32]]) {{.*}}: (!fir.ref<i8>) -> i32
! CHECK: return
! CHECK: }
@ -577,7 +577,7 @@ end subroutine test_proc_dummy_other
! CHECK: %[[VAL_11:.*]] = fir.extract_value %[[VAL_2]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
! CHECK: %[[VAL_12:.*]] = fir.box_addr %[[VAL_11]] : (!fir.boxproc<() -> ()>) -> (() -> ())
! CHECK: %[[VAL_13:.*]] = fir.extract_value %[[VAL_2]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> i64
! CHECK: %[[VAL_14:.*]] = fir.call @llvm.stacksave.p0() {{.*}}: () -> !fir.ref<i8>
! CHECK: %[[VAL_14:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[VAL_15:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_13]] : i64) {bindc_name = ".result"}
! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_12]] : (() -> ()) -> ((!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>)
! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_13]] : (i64) -> index
@ -624,7 +624,7 @@ end subroutine test_proc_dummy_other
! CHECK: %[[VAL_48:.*]] = arith.subi %[[VAL_43]], %[[VAL_6]] : index
! CHECK: br ^bb4(%[[VAL_47]], %[[VAL_48]] : index, index)
! CHECK: ^bb6:
! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_14]]) {{.*}}: (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[VAL_14]] : !llvm.ptr
! CHECK: %[[VAL_49:.*]] = fir.emboxchar %[[VAL_0]], %[[VAL_3]] : (!fir.ref<!fir.char<1,40>>, index) -> !fir.boxchar<1>
! CHECK: return %[[VAL_49]] : !fir.boxchar<1>
! CHECK: }

View File

@ -18,7 +18,7 @@
! CHECK: %[[Const_0:.*]] = arith.constant 0 : index
! CHECK: %[[Val_7:.*]] = arith.cmpi sgt, %[[Val_6]], %[[Const_0]] : index
! CHECK: %[[Val_8:.*]] = arith.select %[[Val_7]], %[[Val_6]], %[[Const_0]] : index
! CHECK: %[[Val_9:.*]] = fir.call @llvm.stacksave.p0() {{.*}}: () -> !fir.ref<i8>
! CHECK: %[[Val_9:.*]] = llvm.intr.stacksave : !llvm.ptr
! CHECK: %[[Val_10:.*]] = fir.alloca !fir.char<1,?>(%[[Val_8]] : index) {bindc_name = ".result"}
! CHECK: %[[Val_11:.*]] = fir.call @_QFPgetstring(%[[Val_10]], %[[Val_8]], %[[Val_0]]) {{.*}}: (!fir.ref<!fir.char<1,?>>, index, !fir.ref<i32>) -> !fir.boxchar<1>
! CHECK: %[[Val_12:.*]] = fir.convert %[[Val_10]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
@ -32,7 +32,7 @@
! CHECK: %[[Val_18:.*]] = fir.call @_FortranAioBeginInternalFormattedOutput(%[[Val_2]], %[[Val_3]], %[[Val_12]], %[[Val_13]],
! %[[Val_14]], %[[Val_15]], %[[Const_0_i64_0]], %17, %{{.*}}) : (!fir.ref<i8>, i64, !fir.ref<i8>, i64, !fir.box<none>, !fir.ref<!fir.llvm_ptr<i8>>, i64, !fir.ref<i8>, i32) -> !fir.ref<i8>
! CHECK: %[[Val_19:.*]] = fir.call @_FortranAioEndIoStatement(%18) {{.*}}: (!fir.ref<i8>) -> i32
! CHECK: fir.call @llvm.stackrestore.p0(%[[Val_9]]) {{.*}}: (!fir.ref<i8>) -> ()
! CHECK: llvm.intr.stackrestore %[[Val_9]] : !llvm.ptr
if (string/="hi") stop 'FAIL'
contains
function getstring(n) result(r)

View File

@ -174,9 +174,9 @@ func.func @placement3() {
// CHECK-NEXT: %[[C10:.*]] = arith.constant 10 : index
// CHECK-NEXT: fir.do_loop
// CHECK-NEXT: %[[SUM:.*]] = arith.addi %[[C1]], %[[C2]] : index
// CHECK-NEXT: %[[SP:.*]] = fir.call @llvm.stacksave.p0() : () -> !fir.ref<i8>
// CHECK-NEXT: %[[SP:.*]] = llvm.intr.stacksave : !llvm.ptr
// CHECK-NEXT: %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, %[[SUM]]
// CHECK-NEXT: fir.call @llvm.stackrestore.p0(%[[SP]])
// CHECK-NEXT: llvm.intr.stackrestore %[[SP]] : !llvm.ptr
// CHECK-NEXT: fir.result
// CHECK-NEXT: }
// CHECK-NEXT: return
@ -206,9 +206,9 @@ func.func @placement4(%arg0 : i1) {
// CHECK-NEXT: cf.br ^bb1
// CHECK-NEXT: ^bb1:
// CHECK-NEXT: %[[C3:.*]] = arith.constant 3 : index
// CHECK-NEXT: %[[SP:.*]] = fir.call @llvm.stacksave.p0() : () -> !fir.ref<i8>
// CHECK-NEXT: %[[SP:.*]] = llvm.intr.stacksave : !llvm.ptr
// CHECK-NEXT: %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, %[[C3]]
// CHECK-NEXT: fir.call @llvm.stackrestore.p0(%[[SP]]) : (!fir.ref<i8>) -> ()
// CHECK-NEXT: llvm.intr.stackrestore %[[SP]] : !llvm.ptr
// CHECK-NEXT: cf.cond_br %arg0, ^bb1, ^bb2
// CHECK-NEXT: ^bb2:
// CHECK-NEXT: return
@ -393,9 +393,9 @@ func.func @placement_loop_declare() {
// CHECK-NEXT: %[[C10:.*]] = arith.constant 10 : index
// CHECK-NEXT: fir.do_loop
// CHECK-NEXT: %[[SUM:.*]] = arith.addi %[[C1]], %[[C2]] : index
// CHECK-NEXT: %[[SP:.*]] = fir.call @llvm.stacksave.p0() : () -> !fir.ref<i8>
// CHECK-NEXT: %[[SP:.*]] = llvm.intr.stacksave : !llvm.ptr
// CHECK-NEXT: %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, %[[SUM]]
// CHECK: fir.call @llvm.stackrestore.p0(%[[SP]])
// CHECK: llvm.intr.stackrestore %[[SP]] : !llvm.ptr
// CHECK-NEXT: fir.result
// CHECK-NEXT: }
// CHECK-NEXT: return