diff --git a/flang/include/flang/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h index ef956a36917fd..8e9de418e1b7e 100644 --- a/flang/include/flang/Lower/AbstractConverter.h +++ b/flang/include/flang/Lower/AbstractConverter.h @@ -108,6 +108,21 @@ class AbstractConverter { /// added or replaced at the inner-most level of the local symbol map. virtual void bindSymbol(SymbolRef sym, const fir::ExtendedValue &exval) = 0; + /// Binds the symbol's physical storage to a storage descriptor, + /// which is the base address of the storage and the offset + /// within the storage, where the symbol begins. + /// The symbol binding will be added or replaced at the innermost level + /// of the local symbol map. + virtual void + bindSymbolStorage(SymbolRef sym, + Fortran::lower::SymMap::StorageDesc storage) = 0; + + /// Returns the storage descriptor previously bound to this symbol. + /// If there is no bound storage, the descriptor will contain + /// nullptr base address. + virtual Fortran::lower::SymMap::StorageDesc + getSymbolStorage(SymbolRef sym) = 0; + /// Override lowering of expression with pre-lowered values. /// Associate mlir::Value to evaluate::Expr. All subsequent call to /// genExprXXX() will replace any occurrence of an overridden diff --git a/flang/include/flang/Lower/ConvertVariable.h b/flang/include/flang/Lower/ConvertVariable.h index b938f6be196af..31f3c72c5c86c 100644 --- a/flang/include/flang/Lower/ConvertVariable.h +++ b/flang/include/flang/Lower/ConvertVariable.h @@ -92,10 +92,14 @@ void defineCommonBlocks( /// The COMMON block is a global structure. \p commonValue is the base address /// of the COMMON block. As the offset from the symbol \p sym, generate the /// COMMON block member value (commonValue + offset) for the symbol. +/// \p commonSize specifies the syze of the COMMON block in bytes. +/// The size is used to represent a COMMON block reference as +/// a !fir.ref>. mlir::Value genCommonBlockMember(AbstractConverter &converter, mlir::Location loc, const Fortran::semantics::Symbol &sym, - mlir::Value commonValue); + mlir::Value commonValue, + std::size_t commonSize); /// Lower a symbol attributes given an optional storage \p and add it to the /// provided symbol map. If \preAlloc is not provided, a temporary storage will diff --git a/flang/include/flang/Lower/SymbolMap.h b/flang/include/flang/Lower/SymbolMap.h index e52d1075e2b9d..813df777d7a39 100644 --- a/flang/include/flang/Lower/SymbolMap.h +++ b/flang/include/flang/Lower/SymbolMap.h @@ -146,14 +146,22 @@ struct SymbolBox : public fir::details::matcher { class SymMap { public: using AcDoVar = llvm::StringRef; + /// Descriptor of a symbol's storage consists of the base address + /// of the storage and the offset within that storage. + using StorageDesc = std::pair; SymMap() { pushScope(); } SymMap(const SymMap &) = delete; - void pushScope() { symbolMapStack.emplace_back(); } + void pushScope() { + symbolMapStack.emplace_back(); + storageMapStack.emplace_back(); + } void popScope() { symbolMapStack.pop_back(); assert(symbolMapStack.size() >= 1); + storageMapStack.pop_back(); + assert(storageMapStack.size() >= 1); } /// Add an extended value to the symbol table. @@ -287,6 +295,8 @@ class SymMap { symbolMapStack.emplace_back(); assert(symbolMapStack.size() == 1); impliedDoStack.clear(); + storageMapStack.clear(); + storageMapStack.emplace_back(); } friend llvm::raw_ostream &operator<<(llvm::raw_ostream &os, @@ -315,6 +325,16 @@ class SymMap { return std::nullopt; } + /// Register the symbol's storage at the innermost level + /// of the symbol table. If the storage is already registered, + /// it will be replaced. + void registerStorage(semantics::SymbolRef sym, StorageDesc storage); + /// Lookup the symbol's storage at the innermost level of the symbol table. + StorageDesc lookupStorage(semantics::SymbolRef sym); + StorageDesc lookupStorage(const semantics::Symbol *sym) { + return lookupStorage(*sym); + } + private: /// Bind `box` to `symRef` in the symbol map. void makeSym(semantics::SymbolRef symRef, const SymbolBox &box, @@ -332,6 +352,10 @@ class SymMap { // Implied DO induction variables are not represented as Se::Symbol in // Ev::Expr. Keep the variable markers in their own stack. llvm::SmallVector> impliedDoStack; + + // A stack of maps between the symbols and their storage descriptors. + llvm::SmallVector> + storageMapStack; }; /// RAII wrapper for SymMap. diff --git a/flang/include/flang/Optimizer/Builder/HLFIRTools.h b/flang/include/flang/Optimizer/Builder/HLFIRTools.h index 49dfc85dc76e6..4d2a5bf385857 100644 --- a/flang/include/flang/Optimizer/Builder/HLFIRTools.h +++ b/flang/include/flang/Optimizer/Builder/HLFIRTools.h @@ -224,7 +224,8 @@ fir::FortranVariableOpInterface genDeclare(mlir::Location loc, fir::FirOpBuilder &builder, const fir::ExtendedValue &exv, llvm::StringRef name, fir::FortranVariableFlagsAttr flags, - mlir::Value dummyScope = nullptr, + mlir::Value dummyScope = nullptr, mlir::Value storage = nullptr, + std::uint64_t storageOffset = 0, cuf::DataAttributeAttr dataAttr = {}); /// Generate an hlfir.associate to build a variable from an expression value. diff --git a/flang/include/flang/Optimizer/HLFIR/HLFIROps.td b/flang/include/flang/Optimizer/HLFIR/HLFIROps.td index 44a8a2e81a497..0811b7bbc13d6 100644 --- a/flang/include/flang/Optimizer/HLFIR/HLFIROps.td +++ b/flang/include/flang/Optimizer/HLFIR/HLFIROps.td @@ -109,10 +109,12 @@ def hlfir_DeclareOp attr-dict `:` functional-type(operands, results) }]; - let builders = [ - OpBuilder<(ins "mlir::Value":$memref, "llvm::StringRef":$uniq_name, - CArg<"mlir::Value", "{}">:$shape, CArg<"mlir::ValueRange", "{}">:$typeparams, + let builders = [OpBuilder<(ins "mlir::Value":$memref, + "llvm::StringRef":$uniq_name, CArg<"mlir::Value", "{}">:$shape, + CArg<"mlir::ValueRange", "{}">:$typeparams, CArg<"mlir::Value", "{}">:$dummy_scope, + CArg<"mlir::Value", "{}">:$storage, + CArg<"std::uint64_t", "0">:$storage_offset, CArg<"fir::FortranVariableFlagsAttr", "{}">:$fortran_attrs, CArg<"cuf::DataAttributeAttr", "{}">:$data_attr)>]; diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp index c003a5b04ecd5..e91fa2db15fa2 100644 --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -631,6 +631,17 @@ class FirConverter : public Fortran::lower::AbstractConverter { addSymbol(sym, exval, /*forced=*/true); } + void bindSymbolStorage( + Fortran::lower::SymbolRef sym, + Fortran::lower::SymMap::StorageDesc storage) override final { + localSymbols.registerStorage(sym, std::move(storage)); + } + + Fortran::lower::SymMap::StorageDesc + getSymbolStorage(Fortran::lower::SymbolRef sym) override final { + return localSymbols.lookupStorage(sym); + } + void overrideExprValues(const Fortran::lower::ExprToValueMap *map) override final { exprValueOverrides = map; diff --git a/flang/lib/Lower/ConvertArrayConstructor.cpp b/flang/lib/Lower/ConvertArrayConstructor.cpp index 87824110b4a0c..006f022b5379a 100644 --- a/flang/lib/Lower/ConvertArrayConstructor.cpp +++ b/flang/lib/Lower/ConvertArrayConstructor.cpp @@ -315,9 +315,8 @@ class RuntimeTempStrategy : public StrategyBase { mlir::Value tempStorage = builder.createHeapTemporary( loc, declaredType, tempName, extents, lengths); mlir::Value shape = builder.genShape(loc, extents); - declare = hlfir::DeclareOp::create( - builder, loc, tempStorage, tempName, shape, lengths, - /*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{}); + declare = hlfir::DeclareOp::create(builder, loc, tempStorage, tempName, + shape, lengths); initialBoxValue = builder.createBox(loc, boxType, declare->getOriginalBase(), shape, /*slice=*/mlir::Value{}, lengths, /*tdesc=*/{}); diff --git a/flang/lib/Lower/ConvertExprToHLFIR.cpp b/flang/lib/Lower/ConvertExprToHLFIR.cpp index 81e09a1ca5bc9..1eda1f1b61355 100644 --- a/flang/lib/Lower/ConvertExprToHLFIR.cpp +++ b/flang/lib/Lower/ConvertExprToHLFIR.cpp @@ -1813,10 +1813,8 @@ class HlfirBuilder { // Allocate scalar temporary that will be initialized // with the values specified by the constructor. mlir::Value storagePtr = builder.createTemporary(loc, recTy); - auto varOp = hlfir::EntityWithAttributes{hlfir::DeclareOp::create( - builder, loc, storagePtr, "ctor.temp", /*shape=*/nullptr, - /*typeparams=*/mlir::ValueRange{}, /*dummy_scope=*/nullptr, - fir::FortranVariableFlagsAttr{})}; + auto varOp = hlfir::EntityWithAttributes{ + hlfir::DeclareOp::create(builder, loc, storagePtr, "ctor.temp")}; // Initialize any components that need initialization. mlir::Value box = builder.createBox(loc, fir::ExtendedValue{varOp}); diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp index 80af7f4c1aaad..88fc3128d21f7 100644 --- a/flang/lib/Lower/ConvertVariable.cpp +++ b/flang/lib/Lower/ConvertVariable.cpp @@ -1413,6 +1413,7 @@ static void instantiateAlias(Fortran::lower::AbstractConverter &converter, mlir::Value bytePtr = fir::CoordinateOp::create( builder, loc, i8Ptr, storeAddr, mlir::ValueRange{offset}); mlir::Value typedPtr = castAliasToPointer(builder, loc, symType, bytePtr); + converter.bindSymbolStorage(sym, {storeAddr, off}); Fortran::lower::StatementContext stmtCtx; mapSymbolAttributes(converter, var, symMap, stmtCtx, typedPtr); // Default initialization is possible for equivalence members: see @@ -1655,13 +1656,15 @@ void Fortran::lower::defineCommonBlocks( mlir::Value Fortran::lower::genCommonBlockMember( Fortran::lower::AbstractConverter &converter, mlir::Location loc, - const Fortran::semantics::Symbol &sym, mlir::Value commonValue) { + const Fortran::semantics::Symbol &sym, mlir::Value commonValue, + std::size_t commonSize) { fir::FirOpBuilder &builder = converter.getFirOpBuilder(); std::size_t byteOffset = sym.GetUltimate().offset(); mlir::IntegerType i8Ty = builder.getIntegerType(8); mlir::Type i8Ptr = builder.getRefType(i8Ty); - mlir::Type seqTy = builder.getRefType(builder.getVarLenSeqTy(i8Ty)); + fir::SequenceType::Shape shape(1, commonSize); + mlir::Type seqTy = builder.getRefType(fir::SequenceType::get(shape, i8Ty)); mlir::Value base = builder.createConvert(loc, seqTy, commonValue); mlir::Value offs = @@ -1670,6 +1673,8 @@ mlir::Value Fortran::lower::genCommonBlockMember( mlir::ValueRange{offs}); mlir::Type symType = converter.genType(sym); + converter.bindSymbolStorage(sym, {base, byteOffset}); + return Fortran::semantics::FindEquivalenceSet(sym) != nullptr ? castAliasToPointer(builder, loc, symType, varAddr) : builder.createConvert(loc, builder.getRefType(symType), varAddr); @@ -1698,7 +1703,8 @@ static void instantiateCommon(Fortran::lower::AbstractConverter &converter, symMap.addSymbol(common, commonAddr); } - mlir::Value local = genCommonBlockMember(converter, loc, varSym, commonAddr); + mlir::Value local = + genCommonBlockMember(converter, loc, varSym, commonAddr, common.size()); Fortran::lower::StatementContext stmtCtx; mapSymbolAttributes(converter, var, symMap, stmtCtx, local); } @@ -1970,7 +1976,8 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter, // Declare a local pointer variable. auto newBase = hlfir::DeclareOp::create( builder, loc, boxAlloc, name, /*shape=*/nullptr, lenParams, - /*dummy_scope=*/nullptr, attributes); + /*dummy_scope=*/nullptr, /*storage=*/nullptr, + /*storage_offset=*/0, attributes); mlir::Value nullAddr = builder.createNullConstant( loc, llvm::cast(ptrBoxType).getEleTy()); @@ -2000,9 +2007,10 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter, mlir::Value dummyScope; if (converter.isRegisteredDummySymbol(sym)) dummyScope = converter.dummyArgsScopeValue(); - auto newBase = - hlfir::DeclareOp::create(builder, loc, base, name, shapeOrShift, - lenParams, dummyScope, attributes, dataAttr); + auto [storage, storageOffset] = converter.getSymbolStorage(sym); + auto newBase = hlfir::DeclareOp::create( + builder, loc, base, name, shapeOrShift, lenParams, dummyScope, storage, + storageOffset, attributes, dataAttr); symMap.addVariableDefinition(sym, newBase, force); return; } @@ -2060,8 +2068,10 @@ void Fortran::lower::genDeclareSymbol( base = genPackArray(converter, sym, exv); dummyScope = converter.dummyArgsScopeValue(); } - hlfir::EntityWithAttributes declare = hlfir::genDeclare( - loc, builder, base, name, attributes, dummyScope, dataAttr); + auto [storage, storageOffset] = converter.getSymbolStorage(sym); + hlfir::EntityWithAttributes declare = + hlfir::genDeclare(loc, builder, base, name, attributes, dummyScope, + storage, storageOffset, dataAttr); symMap.addVariableDefinition(sym, declare.getIfVariableInterface(), force); return; } diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index 7a84b21913bae..bbe749f8c8805 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -1212,12 +1212,10 @@ mlir::acc::FirstprivateRecipeOp Fortran::lower::createOrGetFirstprivateRecipe( auto leftDeclOp = hlfir::DeclareOp::create( builder, loc, recipe.getCopyRegion().getArgument(0), llvm::StringRef{}, - shape, llvm::ArrayRef{}, /*dummy_scope=*/nullptr, - fir::FortranVariableFlagsAttr{}); + shape); auto rightDeclOp = hlfir::DeclareOp::create( builder, loc, recipe.getCopyRegion().getArgument(1), llvm::StringRef{}, - shape, llvm::ArrayRef{}, /*dummy_scope=*/nullptr, - fir::FortranVariableFlagsAttr{}); + shape); hlfir::DesignateOp::Subscripts triplets = getSubscriptsFromArgs(recipe.getCopyRegion().getArguments()); @@ -1523,14 +1521,10 @@ static void genCombiner(fir::FirOpBuilder &builder, mlir::Location loc, auto shape = genShapeFromBoundsOrArgs(loc, builder, seqTy, bounds, recipe.getCombinerRegion().getArguments()); - auto v1DeclareOp = hlfir::DeclareOp::create( - builder, loc, value1, llvm::StringRef{}, shape, - llvm::ArrayRef{}, - /*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{}); - auto v2DeclareOp = hlfir::DeclareOp::create( - builder, loc, value2, llvm::StringRef{}, shape, - llvm::ArrayRef{}, - /*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{}); + auto v1DeclareOp = hlfir::DeclareOp::create(builder, loc, value1, + llvm::StringRef{}, shape); + auto v2DeclareOp = hlfir::DeclareOp::create(builder, loc, value2, + llvm::StringRef{}, shape); hlfir::DesignateOp::Subscripts triplets = getTripletsFromArgs(recipe); llvm::SmallVector lenParamsLeft; diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp index bedcb2a267d92..972f47275cf22 100644 --- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp +++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp @@ -847,10 +847,12 @@ createCopyFunc(mlir::Location loc, lower::AbstractConverter &converter, } auto declDst = hlfir::DeclareOp::create( builder, loc, dst, copyFuncName + "_dst", shape, typeparams, - /*dummy_scope=*/nullptr, attrs); + /*dummy_scope=*/nullptr, /*storage=*/nullptr, + /*storage_offset=*/0, attrs); auto declSrc = hlfir::DeclareOp::create( builder, loc, src, copyFuncName + "_src", shape, typeparams, - /*dummy_scope=*/nullptr, attrs); + /*dummy_scope=*/nullptr, /*storage=*/nullptr, + /*storage_offset=*/0, attrs); converter.copyVar(loc, declDst.getBase(), declSrc.getBase(), varAttrs); mlir::func::ReturnOp::create(builder, loc); return funcOp; diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index 9df2f1d79aa67..0a38f53f8f991 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -688,7 +688,7 @@ static void threadPrivatizeVars(lower::AbstractConverter &converter, } symThreadprivateValue = lower::genCommonBlockMember( converter, currentLocation, sym->GetUltimate(), - commonThreadprivateValue); + commonThreadprivateValue, common->size()); } else { symThreadprivateValue = genThreadprivateOp(*sym); } @@ -1401,7 +1401,7 @@ static void genIntermediateCommonBlockAccessors( for (auto obj : details->objects()) { auto targetCBMemberBind = Fortran::lower::genCommonBlockMember( - converter, currentLocation, *obj, mapArg); + converter, currentLocation, *obj, mapArg, mapSym->size()); fir::ExtendedValue sexv = converter.getSymbolExtendedValue(*obj); fir::ExtendedValue targetCBExv = getExtendedValue(sexv, targetCBMemberBind); @@ -4086,8 +4086,9 @@ void Fortran::lower::genThreadprivateOp(lower::AbstractConverter &converter, firOpBuilder, currentLocation, commonValue.getType(), commonValue); converter.bindSymbol(*common, commonThreadprivateValue); // Generate the threadprivate value for the common block member. - symThreadprivateValue = genCommonBlockMember(converter, currentLocation, - sym, commonThreadprivateValue); + symThreadprivateValue = + genCommonBlockMember(converter, currentLocation, sym, + commonThreadprivateValue, common->size()); } else if (!var.isGlobal()) { // Non-global variable which can be in threadprivate directive must be one // variable in main program, and it has implicit SAVE attribute. Take it as diff --git a/flang/lib/Lower/SymbolMap.cpp b/flang/lib/Lower/SymbolMap.cpp index b929dfbd5aec4..080f21ec67400 100644 --- a/flang/lib/Lower/SymbolMap.cpp +++ b/flang/lib/Lower/SymbolMap.cpp @@ -82,6 +82,23 @@ Fortran::lower::SymMap::lookupImpliedDo(Fortran::lower::SymMap::AcDoVar var) { return {}; } +void Fortran::lower::SymMap::registerStorage( + semantics::SymbolRef symRef, Fortran::lower::SymMap::StorageDesc storage) { + auto *sym = symRef->HasLocalLocality() ? &*symRef : &symRef->GetUltimate(); + assert(storage.first && "registerting storage without an address"); + storageMapStack.back().insert_or_assign(sym, std::move(storage)); +} + +Fortran::lower::SymMap::StorageDesc +Fortran::lower::SymMap::lookupStorage(Fortran::semantics::SymbolRef symRef) { + auto *sym = symRef->HasLocalLocality() ? &*symRef : &symRef->GetUltimate(); + auto &map = storageMapStack.back(); + auto iter = map.find(sym); + if (iter != map.end()) + return iter->second; + return {nullptr, 0}; +} + void Fortran::lower::SymbolBox::dump() const { llvm::errs() << *this << '\n'; } void Fortran::lower::SymMap::dump() const { llvm::errs() << *this << '\n'; } diff --git a/flang/lib/Optimizer/Builder/HLFIRTools.cpp b/flang/lib/Optimizer/Builder/HLFIRTools.cpp index 086dd66711602..f93eaf7ba90b4 100644 --- a/flang/lib/Optimizer/Builder/HLFIRTools.cpp +++ b/flang/lib/Optimizer/Builder/HLFIRTools.cpp @@ -249,6 +249,7 @@ fir::FortranVariableOpInterface hlfir::genDeclare(mlir::Location loc, fir::FirOpBuilder &builder, const fir::ExtendedValue &exv, llvm::StringRef name, fir::FortranVariableFlagsAttr flags, mlir::Value dummyScope, + mlir::Value storage, std::uint64_t storageOffset, cuf::DataAttributeAttr dataAttr) { mlir::Value base = fir::getBase(exv); @@ -278,9 +279,9 @@ hlfir::genDeclare(mlir::Location loc, fir::FirOpBuilder &builder, box.nonDeferredLenParams().end()); }, [](const auto &) {}); - auto declareOp = - hlfir::DeclareOp::create(builder, loc, base, name, shapeOrShift, - lenParams, dummyScope, flags, dataAttr); + auto declareOp = hlfir::DeclareOp::create( + builder, loc, base, name, shapeOrShift, lenParams, dummyScope, storage, + storageOffset, flags, dataAttr); return mlir::cast(declareOp.getOperation()); } @@ -1372,7 +1373,8 @@ hlfir::createTempFromMold(mlir::Location loc, fir::FirOpBuilder &builder, fir::FortranVariableFlagsAttr attrs) -> mlir::Value { auto declareOp = hlfir::DeclareOp::create(builder, loc, memref, name, shape, typeParams, - /*dummy_scope=*/nullptr, attrs); + /*dummy_scope=*/nullptr, /*storage=*/nullptr, + /*storage_offset=*/0, attrs); return declareOp.getBase(); }; @@ -1409,7 +1411,8 @@ hlfir::Entity hlfir::createStackTempFromMold(mlir::Location loc, } auto declareOp = hlfir::DeclareOp::create(builder, loc, alloc, tmpName, shape, lenParams, - /*dummy_scope=*/nullptr, declAttrs); + /*dummy_scope=*/nullptr, /*storage=*/nullptr, + /*storage_offset=*/0, declAttrs); return hlfir::Entity{declareOp.getBase()}; } @@ -1426,8 +1429,7 @@ hlfir::convertCharacterKind(mlir::Location loc, fir::FirOpBuilder &builder, return hlfir::EntityWithAttributes{hlfir::DeclareOp::create( builder, loc, res.getAddr(), ".temp.kindconvert", /*shape=*/nullptr, - /*typeparams=*/mlir::ValueRange{res.getLen()}, - /*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{})}; + /*typeparams=*/mlir::ValueRange{res.getLen()})}; } std::pair> @@ -1499,8 +1501,7 @@ hlfir::genTypeAndKindConvert(mlir::Location loc, fir::FirOpBuilder &builder, fir::ShapeShiftOp::create(builder, loc, shapeShiftType, lbAndExtents); auto declareOp = hlfir::DeclareOp::create( builder, loc, associate.getFirBase(), *associate.getUniqName(), - shapeShift, associate.getTypeparams(), /*dummy_scope=*/nullptr, - /*flags=*/fir::FortranVariableFlagsAttr{}); + shapeShift, associate.getTypeparams()); hlfir::Entity castWithLbounds = mlir::cast(declareOp.getOperation()); fir::FirOpBuilder *bldr = &builder; @@ -1538,9 +1539,8 @@ std::pair hlfir::computeEvaluateOpInNewTemp( extents, typeParams); mlir::Value innerMemory = evalInMem.getMemory(); temp = builder.createConvert(loc, innerMemory.getType(), temp); - auto declareOp = hlfir::DeclareOp::create( - builder, loc, temp, tmpName, shape, typeParams, - /*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{}); + auto declareOp = + hlfir::DeclareOp::create(builder, loc, temp, tmpName, shape, typeParams); computeEvaluateOpIn(loc, builder, evalInMem, declareOp.getOriginalBase()); return {hlfir::Entity{declareOp.getBase()}, /*heapAllocated=*/heapAllocated}; } diff --git a/flang/lib/Optimizer/Builder/TemporaryStorage.cpp b/flang/lib/Optimizer/Builder/TemporaryStorage.cpp index c0d6606b8d298..7e329e357d7b3 100644 --- a/flang/lib/Optimizer/Builder/TemporaryStorage.cpp +++ b/flang/lib/Optimizer/Builder/TemporaryStorage.cpp @@ -82,8 +82,7 @@ fir::factory::HomogeneousScalarStack::HomogeneousScalarStack( mlir::Value shape = builder.genShape(loc, extents); temp = hlfir::DeclareOp::create(builder, loc, tempStorage, tempName, shape, - lengths, /*dummy_scope=*/nullptr, - fir::FortranVariableFlagsAttr{}) + lengths) .getBase(); } diff --git a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp index 629b97a188686..7ed809d8eeec1 100644 --- a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp +++ b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp @@ -265,7 +265,8 @@ void hlfir::DeclareOp::build(mlir::OpBuilder &builder, mlir::OperationState &result, mlir::Value memref, llvm::StringRef uniq_name, mlir::Value shape, mlir::ValueRange typeparams, - mlir::Value dummy_scope, + mlir::Value dummy_scope, mlir::Value storage, + std::uint64_t storage_offset, fir::FortranVariableFlagsAttr fortran_attrs, cuf::DataAttributeAttr data_attr) { auto nameAttr = builder.getStringAttr(uniq_name); @@ -279,8 +280,8 @@ void hlfir::DeclareOp::build(mlir::OpBuilder &builder, auto [hlfirVariableType, firVarType] = getDeclareOutputTypes(inputType, hasExplicitLbs); build(builder, result, {hlfirVariableType, firVarType}, memref, shape, - typeparams, dummy_scope, /*storage=*/nullptr, /*storage_offset=*/0, - nameAttr, fortran_attrs, data_attr); + typeparams, dummy_scope, storage, storage_offset, nameAttr, + fortran_attrs, data_attr); } llvm::LogicalResult hlfir::DeclareOp::verify() { diff --git a/flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp b/flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp index 886a8a59e7441..1c77636d301e9 100644 --- a/flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp +++ b/flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp @@ -118,7 +118,8 @@ createArrayTemp(mlir::Location loc, fir::FirOpBuilder &builder, fir::FortranVariableFlagsAttr attrs) -> mlir::Value { auto declareOp = hlfir::DeclareOp::create(builder, loc, memref, name, shape, typeParams, - /*dummy_scope=*/nullptr, attrs); + /*dummy_scope=*/nullptr, /*storage=*/nullptr, + /*storage_offset=*/0, attrs); return declareOp.getBase(); }; @@ -298,8 +299,7 @@ struct SetLengthOpConversion auto alloca = builder.createTemporary(loc, charType, tmpName, /*shape=*/{}, lenParams); auto declareOp = hlfir::DeclareOp::create( - builder, loc, alloca, tmpName, /*shape=*/mlir::Value{}, lenParams, - /*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{}); + builder, loc, alloca, tmpName, /*shape=*/mlir::Value{}, lenParams); hlfir::Entity temp{declareOp.getBase()}; // Assign string value to the created temp. hlfir::AssignOp::create(builder, loc, string, temp, diff --git a/flang/lib/Optimizer/HLFIR/Transforms/InlineHLFIRCopyIn.cpp b/flang/lib/Optimizer/HLFIR/Transforms/InlineHLFIRCopyIn.cpp index e1df01e0e2eed..b4e89b0966e9c 100644 --- a/flang/lib/Optimizer/HLFIR/Transforms/InlineHLFIRCopyIn.cpp +++ b/flang/lib/Optimizer/HLFIR/Transforms/InlineHLFIRCopyIn.cpp @@ -109,7 +109,9 @@ InlineCopyInConversion::matchAndRewrite(hlfir::CopyInOp copyIn, auto declareOp = hlfir::DeclareOp::create(builder, loc, alloc, tmpName, shape, lenParams, - /*dummy_scope=*/nullptr); + /*dummy_scope=*/nullptr, + /*storage=*/nullptr, + /*storage_offset=*/0); hlfir::Entity temp{declareOp.getBase()}; hlfir::LoopNest loopNest = hlfir::genLoopNest(loc, builder, extents, /*isUnordered=*/true, diff --git a/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp b/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp index 5b6d904fb0d59..e9ca0331d690d 100644 --- a/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp +++ b/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp @@ -552,10 +552,7 @@ mlir::Value OpenACCMappableModel::generatePrivateInit( auto getDeclareOpForType = [&](mlir::Type ty) -> hlfir::DeclareOp { auto alloca = fir::AllocaOp::create(firBuilder, loc, ty); - return hlfir::DeclareOp::create( - firBuilder, loc, alloca, varName, /*shape=*/nullptr, - llvm::ArrayRef{}, - /*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{}); + return hlfir::DeclareOp::create(firBuilder, loc, alloca, varName); }; if (fir::isa_trivial(unwrappedTy)) { @@ -576,10 +573,8 @@ mlir::Value OpenACCMappableModel::generatePrivateInit( } auto alloca = fir::AllocaOp::create( firBuilder, loc, seqTy, /*typeparams=*/mlir::ValueRange{}, extents); - auto declareOp = hlfir::DeclareOp::create( - firBuilder, loc, alloca, varName, shape, - llvm::ArrayRef{}, - /*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{}); + auto declareOp = + hlfir::DeclareOp::create(firBuilder, loc, alloca, varName, shape); if (initVal) { mlir::Type idxTy = firBuilder.getIndexType(); diff --git a/flang/test/Lower/OpenMP/common-block-map.f90 b/flang/test/Lower/OpenMP/common-block-map.f90 index 743438593a3d5..a0a1b1fec3e36 100644 --- a/flang/test/Lower/OpenMP/common-block-map.f90 +++ b/flang/test/Lower/OpenMP/common-block-map.f90 @@ -7,16 +7,14 @@ !CHECK: %[[CB_ADDR:.*]] = fir.address_of(@var_common_) : !fir.ref> !CHECK: %[[MAP:.*]] = omp.map.info var_ptr(%[[CB_ADDR]] : !fir.ref>, !fir.array<8xi8>) map_clauses(tofrom) capture(ByRef) -> !fir.ref> {name = "var_common"} !CHECK: omp.target map_entries(%[[MAP]] -> %[[MAP_ARG:.*]] : !fir.ref>) { -!CHECK: %[[CONV:.*]] = fir.convert %[[MAP_ARG]] : (!fir.ref>) -> !fir.ref> !CHECK: %[[INDEX:.*]] = arith.constant 0 : index -!CHECK: %[[COORD:.*]] = fir.coordinate_of %[[CONV]], %[[INDEX]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[COORD:.*]] = fir.coordinate_of %[[MAP_ARG]], %[[INDEX]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[CONV2:.*]] = fir.convert %[[COORD]] : (!fir.ref) -> !fir.ref -!CHECK: %[[CB_MEMBER_1:.*]]:2 = hlfir.declare %[[CONV2]] {uniq_name = "_QFmap_full_blockEvar1"} : (!fir.ref) -> (!fir.ref, !fir.ref) -!CHECK: %[[CONV3:.*]] = fir.convert %[[MAP_ARG]] : (!fir.ref>) -> !fir.ref> +!CHECK: %[[CB_MEMBER_1:.*]]:2 = hlfir.declare %[[CONV2]] storage(%[[MAP_ARG]][0]) {uniq_name = "_QFmap_full_blockEvar1"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: %[[INDEX2:.*]] = arith.constant 4 : index -!CHECK: %[[COORD2:.*]] = fir.coordinate_of %[[CONV3]], %[[INDEX2]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[COORD2:.*]] = fir.coordinate_of %[[MAP_ARG]], %[[INDEX2]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[CONV4:.*]] = fir.convert %[[COORD2]] : (!fir.ref) -> !fir.ref -!CHECK: %[[CB_MEMBER_2:.*]]:2 = hlfir.declare %[[CONV4]] {uniq_name = "_QFmap_full_blockEvar2"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[CB_MEMBER_2:.*]]:2 = hlfir.declare %[[CONV4]] storage(%[[MAP_ARG]][4]) {uniq_name = "_QFmap_full_blockEvar2"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) subroutine map_full_block implicit none common /var_common/ var1, var2 @@ -29,16 +27,14 @@ subroutine map_full_block !CHECK-LABEL: @_QPmap_mix_of_members !CHECK: %[[COMMON_BLOCK:.*]] = fir.address_of(@var_common_) : !fir.ref> -!CHECK: %[[CB_CONV:.*]] = fir.convert %[[COMMON_BLOCK]] : (!fir.ref>) -> !fir.ref> !CHECK: %[[INDEX:.*]] = arith.constant 0 : index -!CHECK: %[[COORD:.*]] = fir.coordinate_of %[[CB_CONV]], %[[INDEX]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[COORD:.*]] = fir.coordinate_of %[[COMMON_BLOCK]], %[[INDEX]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[CONV:.*]] = fir.convert %[[COORD]] : (!fir.ref) -> !fir.ref -!CHECK: %[[CB_MEMBER_1:.*]]:2 = hlfir.declare %[[CONV]] {uniq_name = "_QFmap_mix_of_membersEvar1"} : (!fir.ref) -> (!fir.ref, !fir.ref) -!CHECK: %[[CB_CONV:.*]] = fir.convert %[[COMMON_BLOCK]] : (!fir.ref>) -> !fir.ref> +!CHECK: %[[CB_MEMBER_1:.*]]:2 = hlfir.declare %[[CONV]] storage(%[[COMMON_BLOCK]][0]) {uniq_name = "_QFmap_mix_of_membersEvar1"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: %[[INDEX:.*]] = arith.constant 4 : index -!CHECK: %[[COORD:.*]] = fir.coordinate_of %[[CB_CONV]], %[[INDEX]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[COORD:.*]] = fir.coordinate_of %[[COMMON_BLOCK]], %[[INDEX]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[CONV:.*]] = fir.convert %[[COORD]] : (!fir.ref) -> !fir.ref -!CHECK: %[[CB_MEMBER_2:.*]]:2 = hlfir.declare %[[CONV]] {uniq_name = "_QFmap_mix_of_membersEvar2"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[CB_MEMBER_2:.*]]:2 = hlfir.declare %[[CONV]] storage(%[[COMMON_BLOCK]][4]) {uniq_name = "_QFmap_mix_of_membersEvar2"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: %[[MAP_EXP:.*]] = omp.map.info var_ptr(%[[CB_MEMBER_2]]#1 : !fir.ref, i32) map_clauses(tofrom) capture(ByRef) -> !fir.ref {name = "var2"} !CHECK: %[[MAP_IMP:.*]] = omp.map.info var_ptr(%[[CB_MEMBER_1]]#1 : !fir.ref, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !fir.ref {name = "var1"} !CHECK: omp.target map_entries(%[[MAP_EXP]] -> %[[ARG_EXP:.*]], %[[MAP_IMP]] -> %[[ARG_IMP:.*]] : !fir.ref, !fir.ref) { @@ -58,16 +54,14 @@ subroutine map_mix_of_members !CHECK: %[[DECL_TAR_CB:.*]] = fir.address_of(@var_common_link_) : !fir.ref> !CHECK: %[[MAP_DECL_TAR_CB:.*]] = omp.map.info var_ptr(%[[DECL_TAR_CB]] : !fir.ref>, !fir.array<8xi8>) map_clauses(tofrom) capture(ByRef) -> !fir.ref> {name = "var_common_link"} !CHECK: omp.target map_entries(%[[MAP_DECL_TAR_CB]] -> %[[MAP_DECL_TAR_ARG:.*]] : !fir.ref>) { -!CHECK: %[[CONV:.*]] = fir.convert %[[MAP_DECL_TAR_ARG]] : (!fir.ref>) -> !fir.ref> !CHECK: %[[INDEX:.*]] = arith.constant 0 : index -!CHECK: %[[COORD:.*]] = fir.coordinate_of %[[CONV]], %[[INDEX]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[COORD:.*]] = fir.coordinate_of %[[MAP_DECL_TAR_ARG]], %[[INDEX]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[CONV:.*]] = fir.convert %[[COORD]] : (!fir.ref) -> !fir.ref -!CHECK: %[[MEMBER_ONE:.*]]:2 = hlfir.declare %[[CONV]] {uniq_name = "_QFElink1"} : (!fir.ref) -> (!fir.ref, !fir.ref) -!CHECK: %[[CONV:.*]] = fir.convert %[[MAP_DECL_TAR_ARG]] : (!fir.ref>) -> !fir.ref> +!CHECK: %[[MEMBER_ONE:.*]]:2 = hlfir.declare %[[CONV]] storage(%[[MAP_DECL_TAR_ARG]][0]) {uniq_name = "_QFElink1"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: %[[INDEX:.*]] = arith.constant 4 : index -!CHECK: %[[COORD:.*]] = fir.coordinate_of %[[CONV]], %[[INDEX]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[COORD:.*]] = fir.coordinate_of %[[MAP_DECL_TAR_ARG]], %[[INDEX]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[CONV:.*]] = fir.convert %[[COORD]] : (!fir.ref) -> !fir.ref -!CHECK: %[[MEMBER_TWO:.*]]:2 = hlfir.declare %[[CONV]] {uniq_name = "_QFElink2"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[MEMBER_TWO:.*]]:2 = hlfir.declare %[[CONV]] storage(%[[MAP_DECL_TAR_ARG]][4]) {uniq_name = "_QFElink2"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) program main implicit none common /var_common_link/ link1, link2 diff --git a/flang/test/Lower/OpenMP/copyin.f90 b/flang/test/Lower/OpenMP/copyin.f90 index 9f27b1b20baf8..129d8bde4dd7b 100644 --- a/flang/test/Lower/OpenMP/copyin.f90 +++ b/flang/test/Lower/OpenMP/copyin.f90 @@ -224,26 +224,23 @@ subroutine combined_parallel_sections() ! CHECK-LABEL: func.func @_QPcommon_1() { ! CHECK: %[[VAL_0:.*]] = fir.address_of(@c_) : !fir.ref> -! CHECK: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[VAL_2:.*]] = arith.constant 0 : index -! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFcommon_1Ex"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] storage(%[[VAL_0]][0]) {uniq_name = "_QFcommon_1Ex"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) ! CHECK: %[[VAL_6:.*]] = omp.threadprivate %[[VAL_0]] : !fir.ref> -> !fir.ref> -! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[VAL_8:.*]] = arith.constant 0 : index -! CHECK: %[[VAL_9:.*]] = fir.coordinate_of %[[VAL_7]], %[[VAL_8]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_9:.*]] = fir.coordinate_of %[[VAL_6]], %[[VAL_8]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFcommon_1Ex"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] storage(%[[VAL_6]][0]) {uniq_name = "_QFcommon_1Ex"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) ! CHECK: %[[VAL_12:.*]] = fir.alloca i32 {bindc_name = "y", uniq_name = "_QFcommon_1Ey"} ! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_12]] {uniq_name = "_QFcommon_1Ey"} : (!fir.ref) -> (!fir.ref, !fir.ref) ! CHECK: omp.parallel { ! CHECK: %[[VAL_14:.*]] = omp.threadprivate %[[VAL_0]] : !fir.ref> -> !fir.ref> -! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index -! CHECK: %[[VAL_17:.*]] = fir.coordinate_of %[[VAL_15]], %[[VAL_16]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_17:.*]] = fir.coordinate_of %[[VAL_14]], %[[VAL_16]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_19:.*]]:2 = hlfir.declare %[[VAL_18]] {uniq_name = "_QFcommon_1Ex"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[VAL_19:.*]]:2 = hlfir.declare %[[VAL_18]] storage(%[[VAL_14]][0]) {uniq_name = "_QFcommon_1Ex"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) ! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_11]]#0 : !fir.ref ! CHECK: hlfir.assign %[[VAL_20]] to %[[VAL_19]]#0 : i32, !fir.ref ! CHECK: omp.barrier @@ -286,35 +283,30 @@ subroutine common_1() ! CHECK: %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFcommon_2Ei"} ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFcommon_2Ei"} : (!fir.ref) -> (!fir.ref, !fir.ref) ! CHECK: %[[VAL_2:.*]] = fir.address_of(@d_) : !fir.ref> -! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index -! CHECK: %[[VAL_5:.*]] = fir.coordinate_of %[[VAL_3]], %[[VAL_4]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_5:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_4]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]] {uniq_name = "_QFcommon_2Ex"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]] storage(%[[VAL_2]][0]) {uniq_name = "_QFcommon_2Ex"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) ! CHECK: %[[VAL_8:.*]] = omp.threadprivate %[[VAL_2]] : !fir.ref> -> !fir.ref> -! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index -! CHECK: %[[VAL_11:.*]] = fir.coordinate_of %[[VAL_9]], %[[VAL_10]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_11:.*]] = fir.coordinate_of %[[VAL_8]], %[[VAL_10]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_12]] {uniq_name = "_QFcommon_2Ex"} : (!fir.ref) -> (!fir.ref, !fir.ref) -! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_8]] : (!fir.ref>) -> !fir.ref> +! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_12]] storage(%[[VAL_8]][0]) {uniq_name = "_QFcommon_2Ex"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) ! CHECK: %[[VAL_15:.*]] = arith.constant 4 : index -! CHECK: %[[VAL_16:.*]] = fir.coordinate_of %[[VAL_14]], %[[VAL_15]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_16:.*]] = fir.coordinate_of %[[VAL_8]], %[[VAL_15]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_18:.*]]:2 = hlfir.declare %[[VAL_17]] {uniq_name = "_QFcommon_2Ey"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[VAL_18:.*]]:2 = hlfir.declare %[[VAL_17]] storage(%[[VAL_8]][4]) {uniq_name = "_QFcommon_2Ey"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) ! CHECK: omp.parallel { ! CHECK: %[[VAL_21:.*]] = omp.threadprivate %[[VAL_2]] : !fir.ref> -> !fir.ref> -! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[VAL_23:.*]] = arith.constant 0 : index -! CHECK: %[[VAL_24:.*]] = fir.coordinate_of %[[VAL_22]], %[[VAL_23]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_24:.*]] = fir.coordinate_of %[[VAL_21]], %[[VAL_23]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_24]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_26:.*]]:2 = hlfir.declare %[[VAL_25]] {uniq_name = "_QFcommon_2Ex"} : (!fir.ref) -> (!fir.ref, !fir.ref) -! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_21]] : (!fir.ref>) -> !fir.ref> +! CHECK: %[[VAL_26:.*]]:2 = hlfir.declare %[[VAL_25]] storage(%[[VAL_21]][0]) {uniq_name = "_QFcommon_2Ex"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) ! CHECK: %[[VAL_28:.*]] = arith.constant 4 : index -! CHECK: %[[VAL_29:.*]] = fir.coordinate_of %[[VAL_27]], %[[VAL_28]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_29:.*]] = fir.coordinate_of %[[VAL_21]], %[[VAL_28]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_29]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_31:.*]]:2 = hlfir.declare %[[VAL_30]] {uniq_name = "_QFcommon_2Ey"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[VAL_31:.*]]:2 = hlfir.declare %[[VAL_30]] storage(%[[VAL_21]][4]) {uniq_name = "_QFcommon_2Ey"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) ! CHECK: %[[VAL_32:.*]] = fir.load %[[VAL_13]]#0 : !fir.ref ! CHECK: hlfir.assign %[[VAL_32]] to %[[VAL_26]]#0 : i32, !fir.ref ! CHECK: %[[VAL_33:.*]] = fir.load %[[VAL_18]]#0 : !fir.ref @@ -484,21 +476,18 @@ subroutine allocatable2() ! [...] ! CHECK: omp.parallel { ! CHECK: %[[VAL_22:.*]] = omp.threadprivate %[[VAL_0:.*]] : !fir.ref> -> !fir.ref> -! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22:.*]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[VAL_24:.*]] = arith.constant 0 : index -! CHECK: %[[VAL_25:.*]] = fir.coordinate_of %[[VAL_23:.*]], %[[VAL_24:.*]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_25:.*]] = fir.coordinate_of %[[VAL_22]], %[[VAL_24:.*]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25:.*]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_27:.*]]:2 = hlfir.declare %[[VAL_26:.*]] {uniq_name = "_QFcommon_3Ex"} : (!fir.ref) -> (!fir.ref, !fir.ref) -! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_22:.*]] : (!fir.ref>) -> !fir.ref> +! CHECK: %[[VAL_27:.*]]:2 = hlfir.declare %[[VAL_26:.*]] storage(%[[VAL_22]][0]) {uniq_name = "_QFcommon_3Ex"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) ! CHECK: %[[VAL_29:.*]] = arith.constant 4 : index -! CHECK: %[[VAL_30:.*]] = fir.coordinate_of %[[VAL_28:.*]], %[[VAL_29:.*]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_30:.*]] = fir.coordinate_of %[[VAL_22]], %[[VAL_29:.*]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_30:.*]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_32:.*]]:2 = hlfir.declare %[[VAL_31:.*]] {uniq_name = "_QFcommon_3Ey"} : (!fir.ref) -> (!fir.ref, !fir.ref) -! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_22:.*]] : (!fir.ref>) -> !fir.ref> +! CHECK: %[[VAL_32:.*]]:2 = hlfir.declare %[[VAL_31:.*]] storage(%[[VAL_22]][4]) {uniq_name = "_QFcommon_3Ey"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) ! CHECK: %[[VAL_34:.*]] = arith.constant 8 : index -! CHECK: %[[VAL_35:.*]] = fir.coordinate_of %[[VAL_33:.*]], %[[VAL_34:.*]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_35:.*]] = fir.coordinate_of %[[VAL_22]], %[[VAL_34:.*]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_35:.*]] : (!fir.ref) -> !fir.ref>> -! CHECK: %[[VAL_37:.*]]:2 = hlfir.declare %[[VAL_36:.*]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFcommon_3Earr"} : (!fir.ref>>) -> (!fir.ref>>, !fir.ref>>) +! CHECK: %[[VAL_37:.*]]:2 = hlfir.declare %[[VAL_36:.*]] storage(%[[VAL_22]][8]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFcommon_3Earr"} : (!fir.ref>>, !fir.ref>) -> (!fir.ref>>, !fir.ref>>) ! CHECK: %[[VAL_38:.*]] = fir.load %[[VAL_16:.*]]#0 : !fir.ref ! CHECK: hlfir.assign %[[VAL_38:.*]] to %[[VAL_27:.*]]#0 : i32, !fir.ref ! CHECK: %[[VAL_39:.*]] = fir.load %[[VAL_21:.*]]#0 : !fir.ref diff --git a/flang/test/Lower/OpenMP/default-clause.f90 b/flang/test/Lower/OpenMP/default-clause.f90 index 505fa4f0f5d63..77725836a0a04 100644 --- a/flang/test/Lower/OpenMP/default-clause.f90 +++ b/flang/test/Lower/OpenMP/default-clause.f90 @@ -420,18 +420,16 @@ subroutine skipped_default_clause_checks() !CHECK: %[[VAR_I_DECLARE:.*]] = hlfir.declare %[[VAR_I]] {uniq_name = "_QFthreadprivate_with_defaultEi"} : (!fir.ref) -> (!fir.ref, !fir.ref) !CHECK: %[[BLK_ADDR:.*]] = fir.address_of(@blk_) : !fir.ref> !CHECK: %[[BLK_THREADPRIVATE_OUTER:.*]] = omp.threadprivate %[[BLK_ADDR]] : !fir.ref> -> !fir.ref> -!CHECK: %[[CONVERT:.*]] = fir.convert %[[BLK_THREADPRIVATE_OUTER]] : (!fir.ref>) -> !fir.ref> !CHECK: %[[VAR_C:.*]] = arith.constant 0 : index -!CHECK: %[[BLK_REF:.*]] = fir.coordinate_of %[[CONVERT]], %[[VAR_C]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[BLK_REF:.*]] = fir.coordinate_of %[[BLK_THREADPRIVATE_OUTER]], %[[VAR_C]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[CONVERT:.*]] = fir.convert %[[BLK_REF]] : (!fir.ref) -> !fir.ref -!CHECK: %[[VAR_X_DECLARE:.*]] = hlfir.declare %[[CONVERT]] {uniq_name = "_QFthreadprivate_with_defaultEx"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[VAR_X_DECLARE:.*]] = hlfir.declare %[[CONVERT]] storage(%[[BLK_THREADPRIVATE_OUTER]][0]) {uniq_name = "_QFthreadprivate_with_defaultEx"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: omp.parallel { !CHECK: %[[BLK_THREADPRIVATE_INNER:.*]] = omp.threadprivate %[[BLK_ADDR]] : !fir.ref> -> !fir.ref> -!CHECK: %[[CONVERT_INNER:.*]] = fir.convert %[[BLK_THREADPRIVATE_INNER]] : (!fir.ref>) -> !fir.ref> !CHECK: %[[VAR_C_INNER:.*]] = arith.constant 0 : index -!CHECK: %[[BLK_REF_INNER:.*]] = fir.coordinate_of %[[CONVERT_INNER]], %[[VAR_C_INNER]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[BLK_REF_INNER:.*]] = fir.coordinate_of %[[BLK_THREADPRIVATE_INNER]], %[[VAR_C_INNER]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[CONVERT_INNER:.*]] = fir.convert %[[BLK_REF_INNER]] : (!fir.ref) -> !fir.ref -!CHECK: %[[VAR_X_DECLARE_INNER:.*]] = hlfir.declare %[[CONVERT_INNER]] {uniq_name = "_QFthreadprivate_with_defaultEx"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[VAR_X_DECLARE_INNER:.*]] = hlfir.declare %[[CONVERT_INNER]] storage(%[[BLK_THREADPRIVATE_INNER]][0]) {uniq_name = "_QFthreadprivate_with_defaultEx"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) subroutine threadprivate_with_default integer :: x common /blk/ x diff --git a/flang/test/Lower/OpenMP/firstprivate-commonblock.f90 b/flang/test/Lower/OpenMP/firstprivate-commonblock.f90 index 1b029c193b7b6..1398e544539e0 100644 --- a/flang/test/Lower/OpenMP/firstprivate-commonblock.f90 +++ b/flang/test/Lower/OpenMP/firstprivate-commonblock.f90 @@ -4,16 +4,14 @@ !CHECK: func.func @_QPfirstprivate_common() { !CHECK: %[[val_0:.*]] = fir.address_of(@c_) : !fir.ref> -!CHECK: %[[val_1:.*]] = fir.convert %[[val_0]] : (!fir.ref>) -> !fir.ref> !CHECK: %[[val_c0:.*]] = arith.constant 0 : index -!CHECK: %[[val_2:.*]] = fir.coordinate_of %[[val_1]], %[[val_c0]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[val_2:.*]] = fir.coordinate_of %[[val_0]], %[[val_c0]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[val_3:.*]] = fir.convert %[[val_2]] : (!fir.ref) -> !fir.ref -!CHECK: %[[VAL_3_DECL:.*]]:2 = hlfir.declare %[[val_3]] {uniq_name = "_QFfirstprivate_commonEx"} : (!fir.ref) -> (!fir.ref, !fir.ref) -!CHECK: %[[val_4:.*]] = fir.convert %[[val_0]] : (!fir.ref>) -> !fir.ref> +!CHECK: %[[VAL_3_DECL:.*]]:2 = hlfir.declare %[[val_3]] storage(%[[val_0]][0]) {uniq_name = "_QFfirstprivate_commonEx"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: %[[val_c4:.*]] = arith.constant 4 : index -!CHECK: %[[val_5:.*]] = fir.coordinate_of %[[val_4]], %[[val_c4]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[val_5:.*]] = fir.coordinate_of %[[val_0]], %[[val_c4]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[val_6:.*]] = fir.convert %[[val_5]] : (!fir.ref) -> !fir.ref -!CHECK: %[[VAL_6_DECL:.*]]:2 = hlfir.declare %[[val_6]] {uniq_name = "_QFfirstprivate_commonEy"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[VAL_6_DECL:.*]]:2 = hlfir.declare %[[val_6]] storage(%[[val_0]][4]) {uniq_name = "_QFfirstprivate_commonEy"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: omp.parallel private(@{{.*}} %{{.*}}#0 -> %[[val_7:.*]], @{{.*}} %{{.*}}#0 -> %[[val_9:.*]] : {{.*}}) { !CHECK: %[[VAL_7_DECL:.*]]:2 = hlfir.declare %[[val_7]] {uniq_name = "_QFfirstprivate_commonEx"} : (!fir.ref) -> (!fir.ref, !fir.ref) !CHECK: %[[VAL_9_DECL:.*]]:2 = hlfir.declare %[[val_9]] {uniq_name = "_QFfirstprivate_commonEy"} : (!fir.ref) -> (!fir.ref, !fir.ref) diff --git a/flang/test/Lower/OpenMP/lastprivate-commonblock.f90 b/flang/test/Lower/OpenMP/lastprivate-commonblock.f90 index beb4e79698702..ddb4c33891727 100644 --- a/flang/test/Lower/OpenMP/lastprivate-commonblock.f90 +++ b/flang/test/Lower/OpenMP/lastprivate-commonblock.f90 @@ -3,14 +3,12 @@ !CHECK: fir.global common @[[CB_C:.*]](dense<0> : vector<8xi8>) {alignment = 4 : i64} : !fir.array<8xi8> !CHECK-LABEL: func.func @_QPlastprivate_common !CHECK: %[[CB_C_REF:.*]] = fir.address_of(@[[CB_C]]) : !fir.ref> -!CHECK: %[[CB_C_REF_CVT:.*]] = fir.convert %[[CB_C_REF]] : (!fir.ref>) -> !fir.ref> -!CHECK: %[[CB_C_X_COOR:.*]] = fir.coordinate_of %[[CB_C_REF_CVT]], %{{.*}} : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[CB_C_X_COOR:.*]] = fir.coordinate_of %[[CB_C_REF]], %{{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK: %[[CB_C_X_ADDR:.*]] = fir.convert %[[CB_C_X_COOR]] : (!fir.ref) -> !fir.ref -!CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[CB_C_X_ADDR]] {uniq_name = "_QFlastprivate_commonEx"} : (!fir.ref) -> (!fir.ref, !fir.ref) -!CHECK: %[[CB_C_REF_CVT:.*]] = fir.convert %[[CB_C_REF]] : (!fir.ref>) -> !fir.ref> -!CHECK: %[[CB_C_Y_COOR:.*]] = fir.coordinate_of %[[CB_C_REF_CVT]], %{{.*}} : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[CB_C_X_ADDR]] storage(%[[CB_C_REF]][0]) {uniq_name = "_QFlastprivate_commonEx"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) +!CHECK: %[[CB_C_Y_COOR:.*]] = fir.coordinate_of %[[CB_C_REF]], %{{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK: %[[CB_C_Y_ADDR:.*]] = fir.convert %[[CB_C_Y_COOR]] : (!fir.ref) -> !fir.ref -!CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %[[CB_C_Y_ADDR]] {uniq_name = "_QFlastprivate_commonEy"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %[[CB_C_Y_ADDR]] storage(%[[CB_C_REF]][4]) {uniq_name = "_QFlastprivate_commonEy"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: omp.wsloop private(@{{.*}} %{{.*}} -> %[[PRIVATE_X_REF:.*]], @{{.*}} %{{.*}} -> %[[PRIVATE_Y_REF:.*]], @{{.*}} %{{.*}} -> %{{.*}} : !{{.*}}, !{{.*}}, !{{.*}}) { !CHECK-NEXT: omp.loop_nest (%[[I:.*]]) : i32 = (%{{.*}}) to (%{{.*}}) inclusive step (%{{.*}}) { !CHECK: %[[PRIVATE_X_DECL:.*]]:2 = hlfir.declare %[[PRIVATE_X_REF]] {uniq_name = "_QFlastprivate_commonEx"} : (!fir.ref) -> (!fir.ref, !fir.ref) diff --git a/flang/test/Lower/OpenMP/private-commonblock.f90 b/flang/test/Lower/OpenMP/private-commonblock.f90 index 8f5f641dea325..241e9fa2e1b5a 100644 --- a/flang/test/Lower/OpenMP/private-commonblock.f90 +++ b/flang/test/Lower/OpenMP/private-commonblock.f90 @@ -20,32 +20,28 @@ subroutine private_common !CHECK: %[[D_BOX_ADDR:.*]] = fir.alloca !fir.box>> !CHECK: %[[B_BOX_ADDR:.*]] = fir.alloca !fir.box> !CHECK: %[[BLK_ADDR:.*]] = fir.address_of(@blk_) : !fir.ref> -!CHECK: %[[I8_ARR:.*]] = fir.convert %[[BLK_ADDR]] : (!fir.ref>) -> !fir.ref> !CHECK: %[[C0:.*]] = arith.constant 0 : index -!CHECK: %[[A_I8_REF:.*]] = fir.coordinate_of %[[I8_ARR]], %[[C0]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[A_I8_REF:.*]] = fir.coordinate_of %[[BLK_ADDR]], %[[C0]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[A_REF:.*]] = fir.convert %[[A_I8_REF]] : (!fir.ref) -> !fir.ref -!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_REF]] {uniq_name = "_QFprivate_clause_commonblockEa"} : (!fir.ref) -> (!fir.ref, !fir.ref) -!CHECK: %[[I8_ARR:.*]] = fir.convert %[[BLK_ADDR]] : (!fir.ref>) -> !fir.ref> +!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_REF]] storage(%[[BLK_ADDR]][0]) {uniq_name = "_QFprivate_clause_commonblockEa"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: %[[C4:.*]] = arith.constant 4 : index -!CHECK: %[[B_I8_REF:.*]] = fir.coordinate_of %[[I8_ARR]], %[[C4]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[B_I8_REF:.*]] = fir.coordinate_of %[[BLK_ADDR]], %[[C4]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[B_REF:.*]] = fir.convert %[[B_I8_REF:.*]] : (!fir.ref) -> !fir.ref> !CHECK: %[[C10:.*]] = arith.constant 10 : index !CHECK: %[[SH10:.*]] = fir.shape %[[C10]] : (index) -> !fir.shape<1> -!CHECK: %[[B_DECL:.*]]:2 = hlfir.declare %[[B_REF]](%[[SH10]]) {uniq_name = "_QFprivate_clause_commonblockEb"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) -!CHECK: %[[I8_ARR:.*]] = fir.convert %[[BLK_ADDR]] : (!fir.ref>) -> !fir.ref> +!CHECK: %[[B_DECL:.*]]:2 = hlfir.declare %[[B_REF]](%[[SH10]]) storage(%[[BLK_ADDR]][4]) {uniq_name = "_QFprivate_clause_commonblockEb"} : (!fir.ref>, !fir.shape<1>, !fir.ref>) -> (!fir.ref>, !fir.ref>) !CHECK: %[[C44:.*]] = arith.constant 44 : index -!CHECK: %[[C_I8_REF:.*]] = fir.coordinate_of %[[I8_ARR]], %[[C44]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[C_I8_REF:.*]] = fir.coordinate_of %[[BLK_ADDR]], %[[C44]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[C_REF:.*]] = fir.convert %[[C_I8_REF]] : (!fir.ref) -> !fir.ref> !CHECK: %[[C5:.*]] = arith.constant 5 : index -!CHECK: %[[C_DECL:.*]]:2 = hlfir.declare %[[C_REF]] typeparams %[[C5]] {uniq_name = "_QFprivate_clause_commonblockEc"} : (!fir.ref>, index) -> (!fir.ref>, !fir.ref>) -!CHECK: %[[I8_ARR:.*]] = fir.convert %[[BLK_ADDR]] : (!fir.ref>) -> !fir.ref> +!CHECK: %[[C_DECL:.*]]:2 = hlfir.declare %[[C_REF]] typeparams %[[C5]] storage(%[[BLK_ADDR]][44]) {uniq_name = "_QFprivate_clause_commonblockEc"} : (!fir.ref>, index, !fir.ref>) -> (!fir.ref>, !fir.ref>) !CHECK: %[[C49:.*]] = arith.constant 49 : index -!CHECK: %[[D_I8_REF:.*]] = fir.coordinate_of %[[I8_ARR]], %[[C49]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[D_I8_REF:.*]] = fir.coordinate_of %[[BLK_ADDR]], %[[C49]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[D_REF:.*]] = fir.convert %[[D_I8_REF]] : (!fir.ref) -> !fir.ref>> !CHECK: %[[TP5:.*]] = arith.constant 5 : index !CHECK: %[[C5:.*]] = arith.constant 5 : index !CHECK: %[[SH5:.*]] = fir.shape %[[C5]] : (index) -> !fir.shape<1> -!CHECK: %[[D_DECL:.*]]:2 = hlfir.declare %[[D_REF]](%[[SH5:.*]]) typeparams %[[TP5]] {uniq_name = "_QFprivate_clause_commonblockEd"} : (!fir.ref>>, !fir.shape<1>, index) -> (!fir.ref>>, !fir.ref>>) +!CHECK: %[[D_DECL:.*]]:2 = hlfir.declare %[[D_REF]](%[[SH5:.*]]) typeparams %[[TP5]] storage(%[[BLK_ADDR]][49]) {uniq_name = "_QFprivate_clause_commonblockEd"} : (!fir.ref>>, !fir.shape<1>, index, !fir.ref>) -> (!fir.ref>>, !fir.ref>>) !CHECK: %[[C_BOX:.*]] = fir.emboxchar %[[C_DECL]]#0, %c5 : (!fir.ref>, index) -> !fir.boxchar<1> !CHECK: %[[D_REF:.*]] = fir.convert %[[D_DECL]]#0 : (!fir.ref>>) -> !fir.ref> !CHECK: %[[D_BOX:.*]] = fir.emboxchar %[[D_REF]], %[[TP5]] : (!fir.ref>, index) -> !fir.boxchar<1> @@ -89,16 +85,16 @@ subroutine private_clause_commonblock() !CHECK: func.func @_QPprivate_clause_commonblock_pointer() { !CHECK: %[[BLK_ADDR:.*]] = fir.address_of(@blk_) : !fir.ref> -!CHECK: %[[BLK_I8_REF:.*]] = fir.convert %[[BLK_ADDR]] : (!fir.ref>) -> !fir.ref> +!CHECK: %[[BLK_I8_REF:.*]] = fir.convert %[[BLK_ADDR]] : (!fir.ref>) -> !fir.ref> !CHECK: %[[C24:.*]] = arith.constant 24 : index -!CHECK: %[[A_I8_REF:.*]] = fir.coordinate_of %[[BLK_I8_REF]], %[[C24]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[A_I8_REF:.*]] = fir.coordinate_of %[[BLK_I8_REF]], %[[C24]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[A_REF:.*]] = fir.convert %[[A_I8_REF]] : (!fir.ref) -> !fir.ref -!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_REF]] {uniq_name = "_QFprivate_clause_commonblock_pointerEa"} : (!fir.ref) -> (!fir.ref, !fir.ref) -!CHECK: %[[BLK_I8_REF:.*]] = fir.convert %[[BLK_ADDR]] : (!fir.ref>) -> !fir.ref> +!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_REF]] storage(%[[BLK_I8_REF]][24]) {uniq_name = "_QFprivate_clause_commonblock_pointerEa"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) +!CHECK: %[[BLK_I8_REF:.*]] = fir.convert %[[BLK_ADDR]] : (!fir.ref>) -> !fir.ref> !CHECK: %[[C0:.*]] = arith.constant 0 : index -!CHECK: %[[C_I8_REF:.*]] = fir.coordinate_of %[[BLK_I8_REF]], %[[C0]] : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[C_I8_REF:.*]] = fir.coordinate_of %[[BLK_I8_REF]], %[[C0]] : (!fir.ref>, index) -> !fir.ref !CHECK: %[[C_REF:.*]] = fir.convert %[[C_I8_REF]] : (!fir.ref) -> !fir.ref>>> -!CHECK: %[[C_DECL:.*]]:2 = hlfir.declare %[[C_REF]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFprivate_clause_commonblock_pointerEc"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) +!CHECK: %[[C_DECL:.*]]:2 = hlfir.declare %[[C_REF]] storage(%[[BLK_I8_REF]][0]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFprivate_clause_commonblock_pointerEc"} : (!fir.ref>>>, !fir.ref>) -> (!fir.ref>>>, !fir.ref>>>) !CHECK: %[[C_BOX:.*]] = fir.load %[[C_DECL]]#0 : !fir.ref>>> !CHECK: %[[C_ADDR:.*]] = fir.box_addr %[[C_BOX]] : (!fir.box>>) -> !fir.ptr> !CHECK: %[[C_REF:.*]] = fir.convert %[[C_ADDR]] : (!fir.ptr>) -> !fir.ref> diff --git a/flang/test/Lower/OpenMP/reduction-equivalence.f90 b/flang/test/Lower/OpenMP/reduction-equivalence.f90 index f46e148ac61cd..6ba4e38352e7d 100644 --- a/flang/test/Lower/OpenMP/reduction-equivalence.f90 +++ b/flang/test/Lower/OpenMP/reduction-equivalence.f90 @@ -30,11 +30,11 @@ end subroutine reduction_equivalence ! CHECK: %[[VAL_1:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_2:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_1]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (!fir.ref) -> !fir.ptr -! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]] {uniq_name = "_QFreduction_equivalenceEva"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) +! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]] storage(%[[VAL_0]][0]) {uniq_name = "_QFreduction_equivalenceEva"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) ! CHECK: %[[VAL_5:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_6:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_5]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (!fir.ref) -> !fir.ptr -! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_7]] {uniq_name = "_QFreduction_equivalenceEvva"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) +! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_7]] storage(%[[VAL_0]][0]) {uniq_name = "_QFreduction_equivalenceEvva"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) ! CHECK: %[[VAL_9:.*]] = arith.constant 1 : i32 ! CHECK: hlfir.assign %[[VAL_9]] to %[[VAL_4]]#0 : i32, !fir.ptr ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ptr) -> !fir.ref diff --git a/flang/test/Lower/OpenMP/sections.f90 b/flang/test/Lower/OpenMP/sections.f90 index 3d5c0326fb6b9..b77c46ed054f2 100644 --- a/flang/test/Lower/OpenMP/sections.f90 +++ b/flang/test/Lower/OpenMP/sections.f90 @@ -264,7 +264,7 @@ subroutine lastprivate2() end subroutine !CHECK-LABEL: func @_QPlastprivate_common -!CHECK: %[[I:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFlastprivate_commonEi"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[I:.*]]:2 = hlfir.declare %{{.*}} storage(%{{.*}}[0]) {uniq_name = "_QFlastprivate_commonEi"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: %[[I_PRIV:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFlastprivate_commonEi"} : (!fir.ref) -> (!fir.ref, !fir.ref) !CHECK: omp.sections !CHECK: omp.section diff --git a/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90 b/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90 index e9cad51534d01..35231f5cd4717 100644 --- a/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90 +++ b/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90 @@ -9,10 +9,9 @@ !CHECK: {{.*}} = omp.threadprivate %[[CBLK_ADDR]] : !fir.ref> -> !fir.ref> !CHECK: omp.parallel { !CHECK: %[[TP_PARALLEL:.*]] = omp.threadprivate %[[CBLK_ADDR]] : !fir.ref> -> !fir.ref> -!CHECK: %[[TP_PARALLEL_ADDR:.*]] = fir.convert %[[TP_PARALLEL]] : (!fir.ref>) -> !fir.ref> -!CHECK: %[[A_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL_ADDR]], %c0_1 : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[A_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL]], %c0_1 : (!fir.ref>, index) -> !fir.ref !CHECK: %[[A_ADDR_CVT:.*]] = fir.convert %[[A_ADDR]] : (!fir.ref) -> !fir.ref -!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_ADDR_CVT]] {uniq_name = "_QFsub_commonblockEa"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_ADDR_CVT]] storage(%[[TP_PARALLEL]][0]) {uniq_name = "_QFsub_commonblockEa"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: %[[A_VAL:.*]] = fir.load %[[A_DECL]]#0 : !fir.ref !CHECK: {{.*}} = fir.call @_FortranAioOutputInteger32({{.*}}, %[[A_VAL]]) fastmath : (!fir.ref, i32) -> i1 !CHECK: omp.terminator diff --git a/flang/test/Lower/OpenMP/threadprivate-common-block-pointer.f90 b/flang/test/Lower/OpenMP/threadprivate-common-block-pointer.f90 index 730d810dc4f2e..c7b77f382b440 100644 --- a/flang/test/Lower/OpenMP/threadprivate-common-block-pointer.f90 +++ b/flang/test/Lower/OpenMP/threadprivate-common-block-pointer.f90 @@ -23,9 +23,8 @@ module mmm ! CHECK: %[[VAL_0:.*]] = fir.address_of(@com1_) : !fir.ref> ! CHECK: omp.parallel { ! CHECK: %[[VAL_17:.*]] = omp.threadprivate %[[VAL_0]] : !fir.ref> -> !fir.ref> -! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[VAL_19:.*]] = arith.constant 0 : index -! CHECK: %[[VAL_20:.*]] = fir.coordinate_of %[[VAL_18]], %[[VAL_19]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_20:.*]] = fir.coordinate_of %[[VAL_17]], %[[VAL_19]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (!fir.ref) -> !fir.ref>> -! CHECK: %[[VAL_22:.*]]:2 = hlfir.declare %[[VAL_21]] {fortran_attrs = #{{.*}}, uniq_name = "_QMmmmEnam1"} : (!fir.ref>>) -> (!fir.ref>>, !fir.ref>>) +! CHECK: %[[VAL_22:.*]]:2 = hlfir.declare %[[VAL_21]] storage(%[[VAL_17]][0]) {fortran_attrs = #{{.*}}, uniq_name = "_QMmmmEnam1"} : (!fir.ref>>, !fir.ref>) -> (!fir.ref>>, !fir.ref>>) diff --git a/flang/test/Lower/OpenMP/threadprivate-commonblock.f90 b/flang/test/Lower/OpenMP/threadprivate-commonblock.f90 index 975c62baa3d71..58949cee07a86 100644 --- a/flang/test/Lower/OpenMP/threadprivate-commonblock.f90 +++ b/flang/test/Lower/OpenMP/threadprivate-commonblock.f90 @@ -17,35 +17,28 @@ module test contains subroutine sub() !CHECK-DAG: %[[CBLK_ADDR:.*]] = fir.address_of(@blk_) : !fir.ref> - !CHECK-DAG: %[[CBLK_ADDR_CVT:.*]] = fir.convert %[[CBLK_ADDR]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[A_ADDR:.*]] = fir.coordinate_of %[[CBLK_ADDR_CVT]], %c0 : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[A_ADDR:.*]] = fir.coordinate_of %[[CBLK_ADDR]], %c0 : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[A_ADDR_CVT:.*]] = fir.convert %[[A_ADDR]] : (!fir.ref) -> !fir.ref - !CHECK-DAG: %[[A_VAL:.*]]:2 = hlfir.declare %[[A_ADDR_CVT]] {uniq_name = "_QMtestEa"} : (!fir.ref) -> (!fir.ref, !fir.ref) + !CHECK-DAG: %[[A_VAL:.*]]:2 = hlfir.declare %[[A_ADDR_CVT]] storage(%[[CBLK_ADDR]][0]) {uniq_name = "_QMtestEa"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK-DAG: %[[OMP_CBLK:.*]] = omp.threadprivate %[[CBLK_ADDR]] : !fir.ref> -> !fir.ref> - !CHECK-DAG: %[[OMP_CBLK_ADDR:.*]] = fir.convert %[[OMP_CBLK]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[A_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK_ADDR]], {{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[A_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK]], {{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[A_ADDR_CVT:.*]] = fir.convert %[[A_ADDR]] : (!fir.ref) -> !fir.ref - !CHECK-DAG: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_ADDR_CVT]] {uniq_name = "_QMtestEa"} : (!fir.ref) -> (!fir.ref, !fir.ref) - !CHECK-DAG: %[[OMP_CBLK_ADDR:.*]] = fir.convert %[[OMP_CBLK]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[B_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK_ADDR]], {{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_ADDR_CVT]] storage(%[[OMP_CBLK]][0]) {uniq_name = "_QMtestEa"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) + !CHECK-DAG: %[[B_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK]], {{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[B_ADDR_CVT:.*]] = fir.convert %[[B_ADDR]] : (!fir.ref) -> !fir.ref> - !CHECK-DAG: %[[B_DECL:.*]]:2 = hlfir.declare %[[B_ADDR_CVT]]({{.*}}) {uniq_name = "_QMtestEb"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) - !CHECK-DAG: %[[OMP_CBLK_ADDR:.*]] = fir.convert %[[OMP_CBLK]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[C_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK_ADDR]], {{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[B_DECL:.*]]:2 = hlfir.declare %[[B_ADDR_CVT]]({{.*}}) storage(%[[OMP_CBLK]][4]) {uniq_name = "_QMtestEb"} : (!fir.ref>, !fir.shape<1>, !fir.ref>) -> (!fir.ref>, !fir.ref>) + !CHECK-DAG: %[[C_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK]], {{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[C_ADDR_CVT:.*]] = fir.convert %[[C_ADDR]] : (!fir.ref) -> !fir.ref>>> - !CHECK-DAG: %[[C_DECL:.*]]:2 = hlfir.declare %[[C_ADDR_CVT]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QMtestEc"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) - !CHECK-DAG: %[[OMP_CBLK_ADDR:.*]] = fir.convert %[[OMP_CBLK]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[D_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK_ADDR]], {{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[C_DECL:.*]]:2 = hlfir.declare %[[C_ADDR_CVT]] storage(%[[OMP_CBLK]][16]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QMtestEc"} : (!fir.ref>>>, !fir.ref>) -> (!fir.ref>>>, !fir.ref>>>) + !CHECK-DAG: %[[D_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK]], {{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[D_ADDR_CVT:.*]] = fir.convert %[[D_ADDR]] : (!fir.ref) -> !fir.ref>>>> - !CHECK-DAG: %[[D_DECL:.*]]:2 = hlfir.declare %[[D_ADDR_CVT]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QMtestEd"} : (!fir.ref>>>>) -> (!fir.ref>>>>, !fir.ref>>>>) - !CHECK-DAG: %[[OMP_CBLK_ADDR:.*]] = fir.convert %[[OMP_CBLK]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[E_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK_ADDR]], {{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[D_DECL:.*]]:2 = hlfir.declare %[[D_ADDR_CVT]] storage(%[[OMP_CBLK]][40]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QMtestEd"} : (!fir.ref>>>>, !fir.ref>) -> (!fir.ref>>>>, !fir.ref>>>>) + !CHECK-DAG: %[[E_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK]], {{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[E_ADDR_CVT:.*]] = fir.convert %[[E_ADDR]] : (!fir.ref) -> !fir.ref> - !CHECK-DAG: %[[E_DECL:.*]]:2 = hlfir.declare %[[E_ADDR_CVT]] typeparams {{.*}} {uniq_name = "_QMtestEe"} : (!fir.ref>, index) -> (!fir.ref>, !fir.ref>) - !CHECK-DAG: %[[OMP_CBLK_ADDR:.*]] = fir.convert %[[OMP_CBLK]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[F_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK_ADDR]], {{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[E_DECL:.*]]:2 = hlfir.declare %[[E_ADDR_CVT]] typeparams {{.*}} storage(%[[OMP_CBLK]][88]) {uniq_name = "_QMtestEe"} : (!fir.ref>, index, !fir.ref>) -> (!fir.ref>, !fir.ref>) + !CHECK-DAG: %[[F_ADDR:.*]] = fir.coordinate_of %[[OMP_CBLK]], {{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[F_ADDR_CVT:.*]] = fir.convert %[[F_ADDR]] : (!fir.ref) -> !fir.ref>> - !CHECK-DAG: %[[F_DECL:.*]]:2 = hlfir.declare %[[F_ADDR_CVT]]({{.*}}) typeparams {{.*}} {uniq_name = "_QMtestEf"} : (!fir.ref>>, !fir.shape<1>, index) -> (!fir.ref>>, !fir.ref>>) + !CHECK-DAG: %[[F_DECL:.*]]:2 = hlfir.declare %[[F_ADDR_CVT]]({{.*}}) typeparams {{.*}} storage(%[[OMP_CBLK]][93]) {uniq_name = "_QMtestEf"} : (!fir.ref>>, !fir.shape<1>, index, !fir.ref>) -> (!fir.ref>>, !fir.ref>>) !CHECK-DAG: {{.*}} = fir.load %[[A_DECL]]#0 : !fir.ref !CHECK-DAG: {{.*}} = fir.embox %[[B_DECL]]#0({{.*}}) : (!fir.ref>, !fir.shape<1>) -> !fir.box> !CHECK-DAG: {{.*}} = fir.load %[[C_DECL]]#0 : !fir.ref>>> @@ -57,30 +50,24 @@ subroutine sub() !$omp parallel !CHECK-DAG: omp.parallel { !CHECK-DAG: %[[TP_PARALLEL:.*]] = omp.threadprivate %[[CBLK_ADDR]] : !fir.ref> -> !fir.ref> - !CHECK-DAG: %[[TP_PARALLEL_ADDR:.*]] = fir.convert %[[TP_PARALLEL]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[TP_A_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL_ADDR]], {{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[TP_A_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL]], {{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[TP_A_ADDR_CVT:.*]] = fir.convert %[[TP_A_ADDR]] : (!fir.ref) -> !fir.ref - !CHECK-DAG: %[[TP_A_DECL:.*]]:2 = hlfir.declare %[[TP_A_ADDR_CVT]] {uniq_name = "_QMtestEa"} : (!fir.ref) -> (!fir.ref, !fir.ref) - !CHECK-DAG: %[[TP_PARALLEL_ADDR:.*]] = fir.convert %[[TP_PARALLEL]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[TP_B_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL_ADDR]], {{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[TP_A_DECL:.*]]:2 = hlfir.declare %[[TP_A_ADDR_CVT]] storage(%[[TP_PARALLEL]][0]) {uniq_name = "_QMtestEa"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) + !CHECK-DAG: %[[TP_B_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL]], {{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[TP_B_ADDR_CVT:.*]] = fir.convert %[[TP_B_ADDR]] : (!fir.ref) -> !fir.ref> - !CHECK-DAG: %[[TP_B_DECL:.*]]:2 = hlfir.declare %[[TP_B_ADDR_CVT]](%{{.*}}) {uniq_name = "_QMtestEb"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) - !CHECK-DAG: %[[TP_PARALLEL_ADDR:.*]] = fir.convert %[[TP_PARALLEL]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[TP_C_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL_ADDR]], {{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[TP_B_DECL:.*]]:2 = hlfir.declare %[[TP_B_ADDR_CVT]](%{{.*}}) storage(%[[TP_PARALLEL]][4]) {uniq_name = "_QMtestEb"} : (!fir.ref>, !fir.shape<1>, !fir.ref>) -> (!fir.ref>, !fir.ref>) + !CHECK-DAG: %[[TP_C_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL]], {{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[TP_C_ADDR_CVT:.*]] = fir.convert %[[TP_C_ADDR]] : (!fir.ref) -> !fir.ref>>> - !CHECK-DAG: %[[TP_C_DECL:.*]]:2 = hlfir.declare %[[TP_C_ADDR_CVT]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QMtestEc"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) - !CHECK-DAG: %[[TP_PARALLEL_ADDR:.*]] = fir.convert %[[TP_PARALLEL]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[TP_D_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL_ADDR]], {{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[TP_C_DECL:.*]]:2 = hlfir.declare %[[TP_C_ADDR_CVT]] storage(%[[TP_PARALLEL]][16]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QMtestEc"} : (!fir.ref>>>, !fir.ref>) -> (!fir.ref>>>, !fir.ref>>>) + !CHECK-DAG: %[[TP_D_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL]], {{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[TP_D_ADDR_CVT:.*]] = fir.convert %[[TP_D_ADDR]] : (!fir.ref) -> !fir.ref>>>> - !CHECK-DAG: %[[TP_D_DECL:.*]]:2 = hlfir.declare %[[TP_D_ADDR_CVT]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QMtestEd"} : (!fir.ref>>>>) -> (!fir.ref>>>>, !fir.ref>>>>) - !CHECK-DAG: %[[TP_PARALLEL_ADDR:.*]] = fir.convert %[[TP_PARALLEL]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[TP_E_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL_ADDR]], {{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[TP_D_DECL:.*]]:2 = hlfir.declare %[[TP_D_ADDR_CVT]] storage(%[[TP_PARALLEL]][40]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QMtestEd"} : (!fir.ref>>>>, !fir.ref>) -> (!fir.ref>>>>, !fir.ref>>>>) + !CHECK-DAG: %[[TP_E_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL]], {{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[TP_E_ADDR_CVT:.*]] = fir.convert %[[TP_E_ADDR]] : (!fir.ref) -> !fir.ref> - !CHECK-DAG: %[[TP_E_DECL:.*]]:2 = hlfir.declare %[[TP_E_ADDR_CVT]] typeparams {{.*}} {uniq_name = "_QMtestEe"} : (!fir.ref>, index) -> (!fir.ref>, !fir.ref>) - !CHECK-DAG: %[[TP_PARALLEL_ADDR:.*]] = fir.convert %[[TP_PARALLEL]] : (!fir.ref>) -> !fir.ref> - !CHECK-DAG: %[[TP_F_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL_ADDR]], %{{.*}} : (!fir.ref>, index) -> !fir.ref + !CHECK-DAG: %[[TP_E_DECL:.*]]:2 = hlfir.declare %[[TP_E_ADDR_CVT]] typeparams {{.*}} storage(%[[TP_PARALLEL]][88]) {uniq_name = "_QMtestEe"} : (!fir.ref>, index, !fir.ref>) -> (!fir.ref>, !fir.ref>) + !CHECK-DAG: %[[TP_F_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL]], %{{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: %[[TP_F_ADDR_CVT:.*]] = fir.convert %[[TP_F_ADDR]] : (!fir.ref) -> !fir.ref>> - !CHECK-DAG: %[[TP_F_DECL:.*]]:2 = hlfir.declare %[[TP_F_ADDR_CVT]]({{.*}}) typeparams {{.*}} {uniq_name = "_QMtestEf"} : (!fir.ref>>, !fir.shape<1>, index) -> (!fir.ref>>, !fir.ref>>) + !CHECK-DAG: %[[TP_F_DECL:.*]]:2 = hlfir.declare %[[TP_F_ADDR_CVT]]({{.*}}) typeparams {{.*}} storage(%[[TP_PARALLEL]][93]) {uniq_name = "_QMtestEf"} : (!fir.ref>>, !fir.shape<1>, index, !fir.ref>) -> (!fir.ref>>, !fir.ref>>) !CHECK-DAG: {{.*}} = fir.load %[[TP_A_DECL]]#0 : !fir.ref !CHECK-DAG: {{.*}} = fir.embox %[[TP_B_DECL]]#0({{.*}}) : (!fir.ref>, !fir.shape<1>) -> !fir.box> !CHECK-DAG: {{.*}} = fir.load %[[TP_C_DECL]]#0 : !fir.ref>>> diff --git a/flang/test/Lower/OpenMP/threadprivate-default-clause.f90 b/flang/test/Lower/OpenMP/threadprivate-default-clause.f90 index e24b7b4195846..0f00e06dfdb1a 100644 --- a/flang/test/Lower/OpenMP/threadprivate-default-clause.f90 +++ b/flang/test/Lower/OpenMP/threadprivate-default-clause.f90 @@ -28,24 +28,21 @@ subroutine sub1() !CHECK-LABEL: func.func @_QPsub2() { !CHECK: %[[BLK:.*]] = fir.address_of(@blk_) : !fir.ref> -!CHECK: %[[BLK_CVT:.*]] = fir.convert %[[BLK]] : (!fir.ref>) -> !fir.ref> !CHECK: %c0 = arith.constant 0 : index -!CHECK: %[[A_ADDR:.*]] = fir.coordinate_of %[[BLK_CVT]], %c0 : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[A_ADDR:.*]] = fir.coordinate_of %[[BLK]], %c0 : (!fir.ref>, index) -> !fir.ref !CHECK: %[[A_CVT:.*]] = fir.convert %[[A_ADDR]] : (!fir.ref) -> !fir.ref -!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_CVT]] {uniq_name = "_QFsub2Ea"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_CVT]] storage(%[[BLK]][0]) {uniq_name = "_QFsub2Ea"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: %[[A_TP0:.*]] = omp.threadprivate %[[BLK]] : !fir.ref> -> !fir.ref> -!CHECK: %[[A_TP0_CVT:.*]] = fir.convert %[[A_TP0]] : (!fir.ref>) -> !fir.ref> !CHECK: %c0_0 = arith.constant 0 : index -!CHECK: %[[A_TP0_ADDR:.*]] = fir.coordinate_of %[[A_TP0_CVT]], %c0_0 : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[A_TP0_ADDR:.*]] = fir.coordinate_of %[[A_TP0]], %c0_0 : (!fir.ref>, index) -> !fir.ref !CHECK: %[[A_TP0_ADDR_CVT:.*]] = fir.convert %[[A_TP0_ADDR]] : (!fir.ref) -> !fir.ref -!CHECK: %[[A_TP0_DECL:.*]]:2 = hlfir.declare %[[A_TP0_ADDR_CVT]] {uniq_name = "_QFsub2Ea"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[A_TP0_DECL:.*]]:2 = hlfir.declare %[[A_TP0_ADDR_CVT]] storage(%[[A_TP0]][0]) {uniq_name = "_QFsub2Ea"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: omp.parallel { !CHECK: %[[BLK_TP:.*]] = omp.threadprivate %[[BLK]] : !fir.ref> -> !fir.ref> -!CHECK: %[[BLK_TP_CVT:.*]] = fir.convert %[[BLK_TP]] : (!fir.ref>) -> !fir.ref> !CHECK: %c0_1 = arith.constant 0 : index -!CHECK: %[[A_TP_ADDR:.*]] = fir.coordinate_of %[[BLK_TP_CVT]], %c0_1 : (!fir.ref>, index) -> !fir.ref +!CHECK: %[[A_TP_ADDR:.*]] = fir.coordinate_of %[[BLK_TP]], %c0_1 : (!fir.ref>, index) -> !fir.ref !CHECK: %[[A_TP_ADDR_CVT:.*]] = fir.convert %[[A_TP_ADDR]] : (!fir.ref) -> !fir.ref -!CHECK: %[[A_TP_DECL:.*]]:2 = hlfir.declare %[[A_TP_ADDR_CVT]] {uniq_name = "_QFsub2Ea"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK: %[[A_TP_DECL:.*]]:2 = hlfir.declare %[[A_TP_ADDR_CVT]] storage(%[[BLK_TP]][0]) {uniq_name = "_QFsub2Ea"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK: %[[TID:.*]] = fir.call @omp_get_thread_num() proc_attrs fastmath : () -> i32 !CHECK: hlfir.assign %[[TID]] to %[[A_TP_DECL]]#0 : i32, !fir.ref !CHECK: omp.terminator diff --git a/flang/test/Lower/OpenMP/threadprivate-use-association.f90 b/flang/test/Lower/OpenMP/threadprivate-use-association.f90 index fb6eaf28de6ae..e60f5158cd3ff 100644 --- a/flang/test/Lower/OpenMP/threadprivate-use-association.f90 +++ b/flang/test/Lower/OpenMP/threadprivate-use-association.f90 @@ -24,16 +24,14 @@ subroutine sub() !$omp parallel !CHECK-DAG: [[ADDR2:%.*]] = omp.threadprivate [[ADDR0]] : !fir.ref> -> !fir.ref> -!CHECK-DAG: [[ADDR3:%.*]] = fir.convert [[ADDR2]] : (!fir.ref>) -> !fir.ref> -!CHECK-DAG: [[ADDR4:%.*]] = fir.coordinate_of [[ADDR3]], %{{.*}} : (!fir.ref>, index) -> !fir.ref +!CHECK-DAG: [[ADDR4:%.*]] = fir.coordinate_of [[ADDR2]], %{{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: [[ADDR5:%.*]] = fir.convert [[ADDR4]] : (!fir.ref) -> !fir.ref -!CHECK-DAG: %[[ADDR6:.*]]:2 = hlfir.declare [[ADDR5]] {uniq_name = "_QMtestEx"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK-DAG: %[[ADDR6:.*]]:2 = hlfir.declare [[ADDR5]] storage([[ADDR2]][0]) {uniq_name = "_QMtestEx"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK-DAG: [[NEWADDR2:%.*]] = omp.threadprivate %[[DECY]]#0 : !fir.ref -> !fir.ref !CHECK-DAG: %[[ADDR7:.*]]:2 = hlfir.declare [[NEWADDR2]] {uniq_name = "_QMtestEy"} : (!fir.ref) -> (!fir.ref, !fir.ref) -!CHECK-DAG: [[ADDR8:%.*]] = fir.convert [[ADDR2]] : (!fir.ref>) -> !fir.ref> -!CHECK-DAG: [[ADDR9:%.*]] = fir.coordinate_of [[ADDR8]], %{{.*}} : (!fir.ref>, index) -> !fir.ref +!CHECK-DAG: [[ADDR9:%.*]] = fir.coordinate_of [[ADDR2]], %{{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: [[ADDR10:%.*]] = fir.convert [[ADDR9]] : (!fir.ref) -> !fir.ref> -!CHECK-DAG: %[[ADDR11:.*]]:2 = hlfir.declare [[ADDR10]](%{{.*}}) {uniq_name = "_QMtestEz"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) +!CHECK-DAG: %[[ADDR11:.*]]:2 = hlfir.declare [[ADDR10]](%{{.*}}) storage([[ADDR2]][4]) {uniq_name = "_QMtestEz"} : (!fir.ref>, !fir.shape<1>, !fir.ref>) -> (!fir.ref>, !fir.ref>) !CHECK-DAG: %{{.*}} = fir.load %[[ADDR6]]#0 : !fir.ref !CHECK-DAG: %{{.*}} = fir.load %[[ADDR7]]#0 : !fir.ref !CHECK-DAG: %{{.*}} = fir.embox %[[ADDR11]]#0(%{{.*}}) : (!fir.ref>, !fir.shape<1>) -> !fir.box> @@ -63,16 +61,14 @@ program main !$omp parallel !CHECK-DAG: [[ADDR4:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref> -> !fir.ref> -!CHECK-DAG: [[ADDR6:%.*]] = fir.convert [[ADDR4]] : (!fir.ref>) -> !fir.ref> -!CHECK-DAG: [[ADDR7:%.*]] = fir.coordinate_of [[ADDR6]], %{{.*}} : (!fir.ref>, index) -> !fir.ref +!CHECK-DAG: [[ADDR7:%.*]] = fir.coordinate_of [[ADDR4]], %{{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: [[ADDR8:%.*]] = fir.convert [[ADDR7]] : (!fir.ref) -> !fir.ref -!CHECK-DAG: %[[DECX1:.*]]:2 = hlfir.declare [[ADDR8]] {uniq_name = "_QFEx1"} : (!fir.ref) -> (!fir.ref, !fir.ref) +!CHECK-DAG: %[[DECX1:.*]]:2 = hlfir.declare [[ADDR8]] storage([[ADDR4]][0]) {uniq_name = "_QFEx1"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) !CHECK-DAG: [[ADDR5:%.*]] = omp.threadprivate %[[ADDR3]]#0 : !fir.ref -> !fir.ref !CHECK-DAG: %[[DECY:.*]]:2 = hlfir.declare [[ADDR5]] {uniq_name = "_QMtestEy"} : (!fir.ref) -> (!fir.ref, !fir.ref) -!CHECK-DAG: [[ADDR9:%.*]] = fir.convert [[ADDR4]] : (!fir.ref>) -> !fir.ref> -!CHECK-DAG: [[ADDR10:%.*]] = fir.coordinate_of [[ADDR9]], %{{.*}} : (!fir.ref>, index) -> !fir.ref +!CHECK-DAG: [[ADDR10:%.*]] = fir.coordinate_of [[ADDR4]], %{{.*}} : (!fir.ref>, index) -> !fir.ref !CHECK-DAG: [[ADDR11:%.*]] = fir.convert [[ADDR10]] : (!fir.ref) -> !fir.ref> -!CHECK-DAG: %[[DECZ1:.*]]:2 = hlfir.declare [[ADDR11]](%{{.*}}) {uniq_name = "_QFEz1"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) +!CHECK-DAG: %[[DECZ1:.*]]:2 = hlfir.declare [[ADDR11]](%{{.*}}) storage([[ADDR4]][4]) {uniq_name = "_QFEz1"} : (!fir.ref>, !fir.shape<1>, !fir.ref>) -> (!fir.ref>, !fir.ref>) !CHECK-DAG: %{{.*}} = fir.load %[[DECX1]]#0 : !fir.ref !CHECK-DAG: %{{.*}} = fir.load %[[DECY]]#0 : !fir.ref !CHECK-DAG: %{{.*}} = fir.embox %[[DECZ1]]#0(%{{.*}}) : (!fir.ref>, !fir.shape<1>) -> !fir.box> diff --git a/flang/test/Lower/declare-with-storage.f90 b/flang/test/Lower/declare-with-storage.f90 new file mode 100644 index 0000000000000..9004d239f3bdb --- /dev/null +++ b/flang/test/Lower/declare-with-storage.f90 @@ -0,0 +1,258 @@ +! Test Lowering into [hl]fir.declare with the storage specification. + +! Create a temporary directory for the module output, so that +! the module files do not compete with other LIT tests. +! RUN: rm -fr %t && mkdir -p %t && cd %t +! RUN: bbc -emit-fir %s --module=%t -o - | FileCheck %s --check-prefixes=ALL,FIR +! RUN: bbc -emit-hlfir %s --module=%t -o - | FileCheck %s --check-prefixes=ALL,HLFIR + +module data1 + real :: m1(5) + character*5 :: m2(3) + common /common1/ m1, m2 +end module data1 +module data2 + integer :: m3 = 1 + real :: m4(7) + common /common1/ m3, m4 +end module data2 +module data3 + real :: x(10) + character*5 :: y(5) + common /common2/ x + equivalence (x(9), y(2)) +end module data3 + +! Test different common1 layouts coming from data1 and data2 modules. +subroutine test1 + use data1 + use data2 +end subroutine test1 +! ALL-LABEL: func.func @_QPtest1() { +! HLFIR: %[[VAL_1:.*]] = fir.address_of(@common1_) : !fir.ref>> +! HLFIR: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref>>) -> !fir.ref> +! HLFIR: %[[VAL_3:.*]] = arith.constant 0 : index +! HLFIR: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_3]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.ref) -> !fir.ref> +! HLFIR: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_5]](%{{.*}}) storage(%[[VAL_2]][0]) {uniq_name = "_QMdata1Em1"} : (!fir.ref>, !fir.shape<1>, !fir.ref>) -> (!fir.ref>, !fir.ref>) +! HLFIR: %[[VAL_9:.*]] = fir.convert %[[VAL_1]] : (!fir.ref>>) -> !fir.ref> +! HLFIR: %[[VAL_10:.*]] = arith.constant 20 : index +! HLFIR: %[[VAL_11:.*]] = fir.coordinate_of %[[VAL_9]], %[[VAL_10]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.ref) -> !fir.ref>> +! HLFIR: %[[VAL_13:.*]] = arith.constant 5 : index +! HLFIR: %[[VAL_16:.*]]:2 = hlfir.declare %[[VAL_12]](%{{.*}}) typeparams %[[VAL_13]] storage(%[[VAL_9]][20]) {uniq_name = "_QMdata1Em2"} : (!fir.ref>>, !fir.shape<1>, index, !fir.ref>) -> (!fir.ref>>, !fir.ref>>) +! HLFIR: %[[VAL_17:.*]] = fir.address_of(@common1_) : !fir.ref>> +! HLFIR: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (!fir.ref>>) -> !fir.ref> +! HLFIR: %[[VAL_19:.*]] = arith.constant 0 : index +! HLFIR: %[[VAL_20:.*]] = fir.coordinate_of %[[VAL_18]], %[[VAL_19]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (!fir.ref) -> !fir.ref +! HLFIR: %[[VAL_22:.*]]:2 = hlfir.declare %[[VAL_21]] storage(%[[VAL_18]][0]) {uniq_name = "_QMdata2Em3"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) +! HLFIR: %[[VAL_23:.*]] = fir.convert %[[VAL_17]] : (!fir.ref>>) -> !fir.ref> +! HLFIR: %[[VAL_24:.*]] = arith.constant 4 : index +! HLFIR: %[[VAL_25:.*]] = fir.coordinate_of %[[VAL_23]], %[[VAL_24]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (!fir.ref) -> !fir.ref> +! HLFIR: %[[VAL_29:.*]]:2 = hlfir.declare %[[VAL_26]](%{{.*}}) storage(%[[VAL_23]][4]) {uniq_name = "_QMdata2Em4"} : (!fir.ref>, !fir.shape<1>, !fir.ref>) -> (!fir.ref>, !fir.ref>) + +! FIR: %[[VAL_1:.*]] = arith.constant 4 : index +! FIR: %[[VAL_3:.*]] = arith.constant 20 : index +! FIR: %[[VAL_4:.*]] = arith.constant 5 : index +! FIR: %[[VAL_5:.*]] = arith.constant 0 : index +! FIR: %[[VAL_7:.*]] = fir.address_of(@common1_) : !fir.ref>> +! FIR: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (!fir.ref>>) -> !fir.ref> +! FIR: %[[VAL_9:.*]] = fir.coordinate_of %[[VAL_8]], %[[VAL_5]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (!fir.ref) -> !fir.ref> +! FIR: %[[VAL_12:.*]] = fir.declare %[[VAL_10]](%{{.*}}) storage(%[[VAL_8]][0]) {uniq_name = "_QMdata1Em1"} : (!fir.ref>, !fir.shape<1>, !fir.ref>) -> !fir.ref> +! FIR: %[[VAL_13:.*]] = fir.coordinate_of %[[VAL_8]], %[[VAL_3]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (!fir.ref) -> !fir.ref>> +! FIR: %[[VAL_16:.*]] = fir.declare %[[VAL_14]](%{{.*}}) typeparams %[[VAL_4]] storage(%[[VAL_8]][20]) {uniq_name = "_QMdata1Em2"} : (!fir.ref>>, !fir.shape<1>, index, !fir.ref>) -> !fir.ref>> +! FIR: %[[VAL_17:.*]] = fir.convert %[[VAL_7]] : (!fir.ref>>) -> !fir.ref> +! FIR: %[[VAL_18:.*]] = fir.coordinate_of %[[VAL_17]], %[[VAL_5]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (!fir.ref) -> !fir.ref +! FIR: %[[VAL_20:.*]] = fir.declare %[[VAL_19]] storage(%[[VAL_17]][0]) {uniq_name = "_QMdata2Em3"} : (!fir.ref, !fir.ref>) -> !fir.ref +! FIR: %[[VAL_21:.*]] = fir.coordinate_of %[[VAL_17]], %[[VAL_1]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (!fir.ref) -> !fir.ref> +! FIR: %[[VAL_24:.*]] = fir.declare %[[VAL_22]](%{{.*}}) storage(%[[VAL_17]][4]) {uniq_name = "_QMdata2Em4"} : (!fir.ref>, !fir.shape<1>, !fir.ref>) -> !fir.ref> + +! Test the local common1 (different from the global definition). +subroutine test2 + real :: x + common /common1/ x +end subroutine test2 +! ALL-LABEL: func.func @_QPtest2() { +! HLFIR: %[[VAL_1:.*]] = fir.address_of(@common1_) : !fir.ref>> +! HLFIR: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref>>) -> !fir.ref> +! HLFIR: %[[VAL_3:.*]] = arith.constant 0 : index +! HLFIR: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_3]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.ref) -> !fir.ref +! HLFIR: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_5]] storage(%[[VAL_2]][0]) {uniq_name = "_QFtest2Ex"} : (!fir.ref, !fir.ref>) -> (!fir.ref, !fir.ref) + +! FIR: %[[VAL_0:.*]] = arith.constant 0 : index +! FIR: %[[VAL_2:.*]] = fir.address_of(@common1_) : !fir.ref>> +! FIR: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (!fir.ref>>) -> !fir.ref> +! FIR: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_3]], %[[VAL_0]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.ref) -> !fir.ref +! FIR: %[[VAL_6:.*]] = fir.declare %[[VAL_5]] storage(%[[VAL_3]][0]) {uniq_name = "_QFtest2Ex"} : (!fir.ref, !fir.ref>) -> !fir.ref + +! Test common2 with equivalence. +subroutine test3 + use data3 +end subroutine test3 +! ALL-LABEL: func.func @_QPtest3() { +! HLFIR: %[[VAL_1:.*]] = fir.address_of(@common2_) : !fir.ref> +! HLFIR: %[[VAL_2:.*]] = arith.constant 0 : index +! HLFIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ptr> +! HLFIR: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_4]](%{{.*}}) storage(%[[VAL_1]][0]) {uniq_name = "_QMdata3Ex"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> (!fir.ptr>, !fir.ptr>) +! HLFIR: %[[VAL_8:.*]] = arith.constant 27 : index +! HLFIR: %[[VAL_9:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_8]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (!fir.ref) -> !fir.ptr>> +! HLFIR: %[[VAL_11:.*]] = arith.constant 5 : index +! HLFIR: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_10]](%{{.*}}) typeparams %[[VAL_11]] storage(%[[VAL_1]][27]) {uniq_name = "_QMdata3Ey"} : (!fir.ptr>>, !fir.shape<1>, index, !fir.ref>) -> (!fir.ptr>>, !fir.ptr>>) + +! FIR: %[[VAL_0:.*]] = arith.constant 5 : index +! FIR: %[[VAL_1:.*]] = arith.constant 27 : index +! FIR: %[[VAL_3:.*]] = arith.constant 0 : index +! FIR: %[[VAL_5:.*]] = fir.address_of(@common2_) : !fir.ref> +! FIR: %[[VAL_6:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_3]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (!fir.ref) -> !fir.ptr> +! FIR: %[[VAL_9:.*]] = fir.declare %[[VAL_7]](%{{.*}}) storage(%[[VAL_5]][0]) {uniq_name = "_QMdata3Ex"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> !fir.ptr> +! FIR: %[[VAL_10:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_1]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (!fir.ref) -> !fir.ptr>> +! FIR: %[[VAL_13:.*]] = fir.declare %[[VAL_11]](%{{.*}}) typeparams %[[VAL_0]] storage(%[[VAL_5]][27]) {uniq_name = "_QMdata3Ey"} : (!fir.ptr>>, !fir.shape<1>, index, !fir.ref>) -> !fir.ptr>> + +! Test host-assocaited common2 usage. +subroutine test4 + use data3 + call inner +contains + subroutine inner + x(9) = 7 + y(5) = '12345' + end subroutine inner +end subroutine test4 +! ALL-LABEL: func.func private @_QFtest4Pinner() attributes {fir.host_symbol = @_QPtest4, llvm.linkage = #llvm.linkage} { +! HLFIR: %[[VAL_1:.*]] = fir.address_of(@common2_) : !fir.ref> +! HLFIR: %[[VAL_2:.*]] = arith.constant 0 : index +! HLFIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ptr> +! HLFIR: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_4]](%{{.*}}) storage(%[[VAL_1]][0]) {uniq_name = "_QMdata3Ex"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> (!fir.ptr>, !fir.ptr>) +! HLFIR: %[[VAL_8:.*]] = arith.constant 27 : index +! HLFIR: %[[VAL_9:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_8]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (!fir.ref) -> !fir.ptr>> +! HLFIR: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_10]](%{{.*}}) typeparams %{{.*}} storage(%[[VAL_1]][27]) {uniq_name = "_QMdata3Ey"} : (!fir.ptr>>, !fir.shape<1>, index, !fir.ref>) -> (!fir.ptr>>, !fir.ptr>>) + +! FIR: %[[VAL_2:.*]] = arith.constant 5 : index +! FIR: %[[VAL_3:.*]] = arith.constant 27 : index +! FIR: %[[VAL_5:.*]] = arith.constant 0 : index +! FIR: %[[VAL_7:.*]] = fir.address_of(@common2_) : !fir.ref> +! FIR: %[[VAL_8:.*]] = fir.coordinate_of %[[VAL_7]], %[[VAL_5]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.ref) -> !fir.ptr> +! FIR: %[[VAL_11:.*]] = fir.declare %[[VAL_9]](%{{.*}}) storage(%[[VAL_7]][0]) {uniq_name = "_QMdata3Ex"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> !fir.ptr> +! FIR: %[[VAL_12:.*]] = fir.coordinate_of %[[VAL_7]], %[[VAL_3]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (!fir.ref) -> !fir.ptr>> +! FIR: %[[VAL_14:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1> +! FIR: %[[VAL_15:.*]] = fir.declare %[[VAL_13]](%{{.*}}) typeparams %[[VAL_2]] storage(%[[VAL_7]][27]) {uniq_name = "_QMdata3Ey"} : (!fir.ptr>>, !fir.shape<1>, index, !fir.ref>) -> !fir.ptr>> + +! Test local equivalence. +subroutine test5 + real :: x(10), y(10) + equivalence (x(5), y(7)) +end subroutine test5 +! ALL-LABEL: func.func @_QPtest5() { +! HLFIR: %[[VAL_1:.*]] = fir.alloca !fir.array<48xi8> {uniq_name = "_QFtest5Ex"} +! HLFIR: %[[VAL_2:.*]] = arith.constant 8 : index +! HLFIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ptr> +! HLFIR: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_4]](%{{.*}}) storage(%[[VAL_1]][8]) {uniq_name = "_QFtest5Ex"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> (!fir.ptr>, !fir.ptr>) +! HLFIR: %[[VAL_8:.*]] = arith.constant 0 : index +! HLFIR: %[[VAL_9:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_8]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (!fir.ref) -> !fir.ptr> +! HLFIR: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_10]](%{{.*}}) storage(%[[VAL_1]][0]) {uniq_name = "_QFtest5Ey"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> (!fir.ptr>, !fir.ptr>) + +! FIR: %[[VAL_0:.*]] = arith.constant 0 : index +! FIR: %[[VAL_2:.*]] = arith.constant 8 : index +! FIR: %[[VAL_4:.*]] = fir.alloca !fir.array<48xi8> {uniq_name = "_QFtest5Ex"} +! FIR: %[[VAL_5:.*]] = fir.coordinate_of %[[VAL_4]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (!fir.ref) -> !fir.ptr> +! FIR: %[[VAL_8:.*]] = fir.declare %[[VAL_6]](%{{.*}}) storage(%[[VAL_4]][8]) {uniq_name = "_QFtest5Ex"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> !fir.ptr> +! FIR: %[[VAL_9:.*]] = fir.coordinate_of %[[VAL_4]], %[[VAL_0]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (!fir.ref) -> !fir.ptr> +! FIR: %[[VAL_11:.*]] = fir.declare %[[VAL_10]](%{{.*}}) storage(%[[VAL_4]][0]) {uniq_name = "_QFtest5Ey"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> !fir.ptr> + +! Test equivalence with saved symbol. +subroutine test6 + real(2), save :: x = 1.0_2 + integer :: y(2) + equivalence (x, y(2)) +end subroutine test6 +! ALL-LABEL: func.func @_QPtest6() { +! HLFIR: %[[VAL_1:.*]] = fir.address_of(@_QFtest6Ex) : !fir.ref> +! HLFIR: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref>) -> !fir.ref> +! HLFIR: %[[VAL_3:.*]] = arith.constant 0 : index +! HLFIR: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_3]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.ref) -> !fir.ptr> +! HLFIR: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_5]](%{{.*}}) storage(%[[VAL_2]][0]) {uniq_name = "_QFtest6E.f18.0"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> (!fir.ptr>, !fir.ptr>) +! HLFIR: %[[VAL_9:.*]] = arith.constant 4 : index +! HLFIR: %[[VAL_10:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_9]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (!fir.ref) -> !fir.ptr +! HLFIR: %[[VAL_12:.*]]:2 = hlfir.declare %[[VAL_11]] storage(%[[VAL_2]][4]) {uniq_name = "_QFtest6Ex"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) +! HLFIR: %[[VAL_13:.*]] = arith.constant 0 : index +! HLFIR: %[[VAL_14:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_13]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (!fir.ref) -> !fir.ptr> +! HLFIR: %[[VAL_18:.*]]:2 = hlfir.declare %[[VAL_15]](%{{.*}}) storage(%[[VAL_2]][0]) {uniq_name = "_QFtest6Ey"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> (!fir.ptr>, !fir.ptr>) + +! FIR: %[[VAL_1:.*]] = arith.constant 4 : index +! FIR: %[[VAL_2:.*]] = arith.constant 0 : index +! FIR: %[[VAL_4:.*]] = fir.address_of(@_QFtest6Ex) : !fir.ref> +! FIR: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.ref>) -> !fir.ref> +! FIR: %[[VAL_6:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (!fir.ref) -> !fir.ptr> +! FIR: %[[VAL_9:.*]] = fir.declare %[[VAL_7]](%{{.*}}) storage(%[[VAL_5]][0]) {uniq_name = "_QFtest6E.f18.0"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> !fir.ptr> +! FIR: %[[VAL_10:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_1]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (!fir.ref) -> !fir.ptr +! FIR: %[[VAL_12:.*]] = fir.declare %[[VAL_11]] storage(%[[VAL_5]][4]) {uniq_name = "_QFtest6Ex"} : (!fir.ptr, !fir.ref>) -> !fir.ptr +! FIR: %[[VAL_13:.*]] = fir.convert %[[VAL_6]] : (!fir.ref) -> !fir.ptr> +! FIR: %[[VAL_15:.*]] = fir.declare %[[VAL_13]](%{{.*}}) storage(%[[VAL_5]][0]) {uniq_name = "_QFtest6Ey"} : (!fir.ptr>, !fir.shape<1>, !fir.ref>) -> !fir.ptr> + +! Test host-associated equivalence. +! TODO: it makes more sense to me to pass only the storage address +! via the host-associated tuple, and then declare x and y inside +! inner via the storage. This gives more information about +! the overlapping of x and y inside inner, which might be useful +! at some point. +subroutine test7 + integer :: x(10), y(7) + equivalence (x(1), y(7)) + call inner +contains + subroutine inner + x(1) = 1 + y(7) = 1 + end subroutine inner +end subroutine test7 +! ALL-LABEL: func.func private @_QFtest7Pinner( +! ALL-SAME: %[[ARG0:.*]]: !fir.ref>, !fir.box>>> {fir.host_assoc}) attributes {fir.host_symbol = @_QPtest7, llvm.linkage = #llvm.linkage} { +! HLFIR: %[[VAL_1:.*]] = arith.constant 0 : i32 +! HLFIR: %[[VAL_2:.*]] = fir.coordinate_of %[[ARG0]], %[[VAL_1]] : (!fir.ref>, !fir.box>>>, i32) -> !fir.ref>> +! HLFIR: %[[VAL_3:.*]] = fir.load %[[VAL_2]] : !fir.ref>> +! HLFIR: %[[VAL_4:.*]] = fir.box_addr %[[VAL_3]] : (!fir.box>) -> !fir.ref> +! HLFIR: %[[VAL_5:.*]] = arith.constant 0 : index +! HLFIR: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_4]](%{{[^)]*}}) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest7Ex"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) +! HLFIR: %[[VAL_9:.*]] = arith.constant 1 : i32 +! HLFIR: %[[VAL_10:.*]] = fir.coordinate_of %[[ARG0]], %[[VAL_9]] : (!fir.ref>, !fir.box>>>, i32) -> !fir.ref>> +! HLFIR: %[[VAL_11:.*]] = fir.load %[[VAL_10]] : !fir.ref>> +! HLFIR: %[[VAL_12:.*]] = fir.box_addr %[[VAL_11]] : (!fir.box>) -> !fir.ref> +! HLFIR: %[[VAL_13:.*]] = arith.constant 0 : index +! HLFIR: %[[VAL_16:.*]]:2 = hlfir.declare %[[VAL_12]](%{{[^)]*}}) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest7Ey"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) + +! FIR: %[[VAL_2:.*]] = arith.constant 1 : i32 +! FIR: %[[VAL_3:.*]] = arith.constant 0 : index +! FIR: %[[VAL_4:.*]] = arith.constant 0 : i32 +! FIR: %[[VAL_6:.*]] = fir.coordinate_of %[[ARG0]], %[[VAL_4]] : (!fir.ref>, !fir.box>>>, i32) -> !fir.ref>> +! FIR: %[[VAL_7:.*]] = fir.load %[[VAL_6]] : !fir.ref>> +! FIR: %[[VAL_8:.*]] = fir.box_addr %[[VAL_7]] : (!fir.box>) -> !fir.ref> +! FIR: %[[VAL_11:.*]] = fir.declare %[[VAL_8]](%{{.*}}) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest7Ex"} : (!fir.ref>, !fir.shape<1>) -> !fir.ref> +! FIR: %[[VAL_12:.*]] = fir.coordinate_of %[[ARG0]], %[[VAL_2]] : (!fir.ref>, !fir.box>>>, i32) -> !fir.ref>> +! FIR: %[[VAL_13:.*]] = fir.load %[[VAL_12]] : !fir.ref>> +! FIR: %[[VAL_14:.*]] = fir.box_addr %[[VAL_13]] : (!fir.box>) -> !fir.ref> +! FIR: %[[VAL_17:.*]] = fir.declare %[[VAL_14]](%{{.*}}) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest7Ey"} : (!fir.ref>, !fir.shape<1>) -> !fir.ref> diff --git a/flang/test/Lower/equivalence-2.f90 b/flang/test/Lower/equivalence-2.f90 index 662be53c59fcb..2cea88ee7440c 100644 --- a/flang/test/Lower/equivalence-2.f90 +++ b/flang/test/Lower/equivalence-2.f90 @@ -112,9 +112,8 @@ subroutine eq_and_comm_same_offset ! CHECK: %[[arr4Store:.*]] = fir.alloca !fir.array<70756xi8> {uniq_name = "_QFeq_and_comm_same_offsetEarr3"} ! CHECK: %[[mcbAddr:.*]] = fir.address_of(@my_common_block_) : !fir.ref> - ! CHECK: %[[mcbCast:.*]] = fir.convert %[[mcbAddr]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[c0:.*]] = arith.constant 0 : index - ! CHECK: %[[mcbCoor:.*]] = fir.coordinate_of %[[mcbCast]], %[[c0]] : (!fir.ref>, index) -> !fir.ref + ! CHECK: %[[mcbCoor:.*]] = fir.coordinate_of %[[mcbAddr]], %[[c0]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[mcbCoorCast:.*]] = fir.convert %[[mcbCoor]] : (!fir.ref) -> !fir.ptr> ! CHECK: %[[c1:.*]] = arith.constant 0 : index ! CHECK: %[[arr4Addr:.*]] = fir.coordinate_of %[[arr4Store]], %[[c1]] : (!fir.ref>, index) -> !fir.ref diff --git a/flang/test/Lower/equivalence-with-host-assoc.f90 b/flang/test/Lower/equivalence-with-host-assoc.f90 index b8ce72f3787c0..733531ab8a2c8 100644 --- a/flang/test/Lower/equivalence-with-host-assoc.f90 +++ b/flang/test/Lower/equivalence-with-host-assoc.f90 @@ -30,11 +30,11 @@ end subroutine test1 ! HLFIR: %[[VAL_2:.*]] = arith.constant 0 : index ! HLFIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref ! HLFIR: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ptr -! HLFIR: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFtest1Ei1"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) +! HLFIR: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] storage(%[[VAL_1]][0]) {uniq_name = "_QFtest1Ei1"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) ! HLFIR: %[[VAL_6:.*]] = arith.constant 0 : index ! HLFIR: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_6]] : (!fir.ref>, index) -> !fir.ref ! HLFIR: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (!fir.ref) -> !fir.ptr -! HLFIR: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_8]] {uniq_name = "_QFtest1Ej1"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) +! HLFIR: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_8]] storage(%[[VAL_1]][0]) {uniq_name = "_QFtest1Ej1"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) ! HLFIR: %[[VAL_10:.*]] = fir.load %[[VAL_9]]#0 : !fir.ptr ! HLFIR: hlfir.assign %[[VAL_10]] to %[[VAL_5]]#0 : i32, !fir.ptr ! HLFIR: return @@ -74,11 +74,11 @@ end module test2 ! HLFIR: %[[VAL_2:.*]] = arith.constant 0 : index ! HLFIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref ! HLFIR: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ptr -! HLFIR: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QMtest2FhostEf1"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) +! HLFIR: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] storage(%[[VAL_1]][0]) {uniq_name = "_QMtest2FhostEf1"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) ! HLFIR: %[[VAL_6:.*]] = arith.constant 0 : index ! HLFIR: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_6]] : (!fir.ref>, index) -> !fir.ref ! HLFIR: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (!fir.ref) -> !fir.ptr -! HLFIR: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_8]] {uniq_name = "_QMtest2FhostEf2"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) +! HLFIR: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_8]] storage(%[[VAL_1]][0]) {uniq_name = "_QMtest2FhostEf2"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) ! HLFIR: %[[VAL_19:.*]] = fir.load %[[VAL_9]]#0 : !fir.ptr ! HLFIR: hlfir.assign %[[VAL_19]] to %[[VAL_5]]#0 : f32, !fir.ptr ! HLFIR: return @@ -96,17 +96,17 @@ end subroutine inner end subroutine test3 ! FIR-LABEL: func.func private @_QFtest3Pinner() attributes {fir.host_symbol = {{.*}}, llvm.linkage = #llvm.linkage} { ! FIR: %[[VAL_0:.*]] = fir.address_of(@blk_) : !fir.ref> -! FIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! FIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! FIR: %[[VAL_2:.*]] = arith.constant 0 : index -! FIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref ! FIR: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ptr -! FIR: %[[VAL_5:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! FIR: %[[VAL_5:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! FIR: %[[VAL_6:.*]] = arith.constant 0 : index -! FIR: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_6]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_6]] : (!fir.ref>, index) -> !fir.ref ! FIR: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (!fir.ref) -> !fir.ptr -! FIR: %[[VAL_9:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! FIR: %[[VAL_9:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! FIR: %[[VAL_10:.*]] = arith.constant 0 : index -! FIR: %[[VAL_11:.*]] = fir.coordinate_of %[[VAL_9]], %[[VAL_10]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_11:.*]] = fir.coordinate_of %[[VAL_9]], %[[VAL_10]] : (!fir.ref>, index) -> !fir.ref ! FIR: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.ref) -> !fir.ptr ! FIR: %[[VAL_13:.*]] = fir.load %[[VAL_8]] : !fir.ptr ! FIR: %[[VAL_14:.*]] = fir.load %[[VAL_12]] : !fir.ptr @@ -117,21 +117,21 @@ end subroutine test3 ! HLFIR-LABEL: func.func private @_QFtest3Pinner() attributes {fir.host_symbol = {{.*}}, llvm.linkage = #llvm.linkage} { ! HLFIR: %[[VAL_0:.*]] = fir.address_of(@blk_) : !fir.ref> -! HLFIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! HLFIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! HLFIR: %[[VAL_2:.*]] = arith.constant 0 : index -! HLFIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref ! HLFIR: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ptr -! HLFIR: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFtest3Ei1"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) -! HLFIR: %[[VAL_6:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! HLFIR: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] storage(%[[VAL_1]][0]) {uniq_name = "_QFtest3Ei1"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) +! HLFIR: %[[VAL_6:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! HLFIR: %[[VAL_7:.*]] = arith.constant 0 : index -! HLFIR: %[[VAL_8:.*]] = fir.coordinate_of %[[VAL_6]], %[[VAL_7]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_8:.*]] = fir.coordinate_of %[[VAL_6]], %[[VAL_7]] : (!fir.ref>, index) -> !fir.ref ! HLFIR: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.ref) -> !fir.ptr -! HLFIR: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_9]] {uniq_name = "_QFtest3Ej1"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) -! HLFIR: %[[VAL_11:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! HLFIR: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_9]] storage(%[[VAL_6]][0]) {uniq_name = "_QFtest3Ej1"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) +! HLFIR: %[[VAL_11:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! HLFIR: %[[VAL_12:.*]] = arith.constant 0 : index -! HLFIR: %[[VAL_13:.*]] = fir.coordinate_of %[[VAL_11]], %[[VAL_12]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_13:.*]] = fir.coordinate_of %[[VAL_11]], %[[VAL_12]] : (!fir.ref>, index) -> !fir.ref ! HLFIR: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (!fir.ref) -> !fir.ptr -! HLFIR: %[[VAL_15:.*]]:2 = hlfir.declare %[[VAL_14]] {uniq_name = "_QFtest3Ek1"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) +! HLFIR: %[[VAL_15:.*]]:2 = hlfir.declare %[[VAL_14]] storage(%[[VAL_11]][0]) {uniq_name = "_QFtest3Ek1"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) ! HLFIR: %[[VAL_16:.*]] = fir.load %[[VAL_10]]#0 : !fir.ptr ! HLFIR: %[[VAL_17:.*]] = fir.load %[[VAL_15]]#0 : !fir.ptr ! HLFIR: %[[VAL_18:.*]] = arith.addi %[[VAL_16]], %[[VAL_17]] : i32 @@ -151,17 +151,17 @@ end subroutine inner end subroutine test4 ! FIR-LABEL: func.func private @_QFtest4Pinner() attributes {fir.host_symbol = {{.*}}, llvm.linkage = #llvm.linkage} { ! FIR: %[[VAL_0:.*]] = fir.address_of(@blk_) : !fir.ref> -! FIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! FIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! FIR: %[[VAL_2:.*]] = arith.constant 0 : index -! FIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref ! FIR: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ptr -! FIR: %[[VAL_5:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! FIR: %[[VAL_5:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! FIR: %[[VAL_6:.*]] = arith.constant 0 : index -! FIR: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_6]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_6]] : (!fir.ref>, index) -> !fir.ref ! FIR: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (!fir.ref) -> !fir.ptr -! FIR: %[[VAL_9:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! FIR: %[[VAL_9:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! FIR: %[[VAL_10:.*]] = arith.constant 0 : index -! FIR: %[[VAL_11:.*]] = fir.coordinate_of %[[VAL_9]], %[[VAL_10]] : (!fir.ref>, index) -> !fir.ref +! FIR: %[[VAL_11:.*]] = fir.coordinate_of %[[VAL_9]], %[[VAL_10]] : (!fir.ref>, index) -> !fir.ref ! FIR: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.ref) -> !fir.ptr ! FIR: %[[VAL_13:.*]] = fir.load %[[VAL_8]] : !fir.ptr ! FIR: %[[VAL_14:.*]] = fir.load %[[VAL_12]] : !fir.ptr @@ -172,21 +172,21 @@ end subroutine test4 ! HLFIR-LABEL: func.func private @_QFtest4Pinner() attributes {fir.host_symbol = {{.*}}, llvm.linkage = #llvm.linkage} { ! HLFIR: %[[VAL_0:.*]] = fir.address_of(@blk_) : !fir.ref> -! HLFIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! HLFIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! HLFIR: %[[VAL_2:.*]] = arith.constant 0 : index -! HLFIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref ! HLFIR: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ptr -! HLFIR: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFtest4Ei1"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) -! HLFIR: %[[VAL_6:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! HLFIR: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] storage(%[[VAL_1]][0]) {uniq_name = "_QFtest4Ei1"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) +! HLFIR: %[[VAL_6:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! HLFIR: %[[VAL_7:.*]] = arith.constant 0 : index -! HLFIR: %[[VAL_8:.*]] = fir.coordinate_of %[[VAL_6]], %[[VAL_7]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_8:.*]] = fir.coordinate_of %[[VAL_6]], %[[VAL_7]] : (!fir.ref>, index) -> !fir.ref ! HLFIR: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.ref) -> !fir.ptr -! HLFIR: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_9]] {uniq_name = "_QFtest4Ej1"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) -! HLFIR: %[[VAL_11:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> +! HLFIR: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_9]] storage(%[[VAL_6]][0]) {uniq_name = "_QFtest4Ej1"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) +! HLFIR: %[[VAL_11:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! HLFIR: %[[VAL_12:.*]] = arith.constant 0 : index -! HLFIR: %[[VAL_13:.*]] = fir.coordinate_of %[[VAL_11]], %[[VAL_12]] : (!fir.ref>, index) -> !fir.ref +! HLFIR: %[[VAL_13:.*]] = fir.coordinate_of %[[VAL_11]], %[[VAL_12]] : (!fir.ref>, index) -> !fir.ref ! HLFIR: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (!fir.ref) -> !fir.ptr -! HLFIR: %[[VAL_15:.*]]:2 = hlfir.declare %[[VAL_14]] {uniq_name = "_QFtest4Ek1"} : (!fir.ptr) -> (!fir.ptr, !fir.ptr) +! HLFIR: %[[VAL_15:.*]]:2 = hlfir.declare %[[VAL_14]] storage(%[[VAL_11]][0]) {uniq_name = "_QFtest4Ek1"} : (!fir.ptr, !fir.ref>) -> (!fir.ptr, !fir.ptr) ! HLFIR: %[[VAL_16:.*]] = fir.load %[[VAL_10]]#0 : !fir.ptr ! HLFIR: %[[VAL_17:.*]] = fir.load %[[VAL_15]]#0 : !fir.ptr ! HLFIR: %[[VAL_18:.*]] = arith.addi %[[VAL_16]], %[[VAL_17]] : i32 diff --git a/flang/test/Lower/explicit-interface-results-2.f90 b/flang/test/Lower/explicit-interface-results-2.f90 index 2336053c32a54..42043579a53d0 100644 --- a/flang/test/Lower/explicit-interface-results-2.f90 +++ b/flang/test/Lower/explicit-interface-results-2.f90 @@ -141,8 +141,7 @@ subroutine host7() call takes_array(return_array()) ! CHECK: %[[VAL_0:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_2:.*]] = fir.address_of(@mycom_) : !fir.ref> -! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (!fir.ref>) -> !fir.ref> -! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_3]], %[[VAL_0]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_0]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.ref) -> !fir.ref ! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_5]] : !fir.ref ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (i32) -> index @@ -163,8 +162,7 @@ subroutine host8() call takes_array(return_array()) ! CHECK: %[[VAL_0:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_1:.*]] = fir.address_of(@mycom_) : !fir.ref> -! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref>) -> !fir.ref> -! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_0]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_0]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ref ! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_4]] : !fir.ref ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i32) -> index @@ -191,8 +189,7 @@ subroutine host9() subroutine internal_proc_a() ! CHECK: %[[VAL_0:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_1:.*]] = fir.address_of(@mycom_) : !fir.ref> -! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref>) -> !fir.ref> -! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_0]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_0]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ref ! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_4]] : !fir.ref ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i32) -> index @@ -218,8 +215,7 @@ subroutine internal_proc_a() call takes_array(return_array()) ! CHECK: %[[VAL_0:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_1:.*]] = fir.address_of(@mycom_) : !fir.ref> -! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref>) -> !fir.ref> -! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_0]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_0]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ref ! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_4]] : !fir.ref ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i32) -> index diff --git a/flang/test/Lower/host-associated-globals.f90 b/flang/test/Lower/host-associated-globals.f90 index c91a5a46af0d5..e02041a8f9eac 100644 --- a/flang/test/Lower/host-associated-globals.f90 +++ b/flang/test/Lower/host-associated-globals.f90 @@ -39,13 +39,11 @@ subroutine bar() end subroutine ! CHECK-LABEL: func.func private @_QFtest_commonPbar() attributes {fir.host_symbol = {{.*}}, llvm.linkage = #llvm.linkage} { ! CHECK: %[[VAL_0:.*]] = fir.address_of(@x_) : !fir.ref> -! CHECK: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[VAL_2:.*]] = arith.constant 4 : index -! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_2]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref) -> !fir.ptr -! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_0]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[VAL_6:.*]] = arith.constant 8 : index -! CHECK: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_6]] : (!fir.ref>, index) -> !fir.ref +! CHECK: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_6]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (!fir.ref) -> !fir.ref subroutine saved_equiv() diff --git a/flang/test/Lower/pointer-assignments.f90 b/flang/test/Lower/pointer-assignments.f90 index 8f83bf7c4946e..ac9c99c97a570 100644 --- a/flang/test/Lower/pointer-assignments.f90 +++ b/flang/test/Lower/pointer-assignments.f90 @@ -365,9 +365,8 @@ subroutine issue1180(x) integer, pointer :: p common /some_common/ p ! CHECK: %[[VAL_1:.*]] = fir.address_of(@some_common_) : !fir.ref> - ! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref>) -> !fir.ref> ! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index - ! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_3]] : (!fir.ref>, index) -> !fir.ref + ! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_3]] : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.ref) -> !fir.ref>> ! CHECK: %[[VAL_6:.*]] = fir.embox %[[VAL_0]] : (!fir.ref) -> !fir.box> ! CHECK: fir.store %[[VAL_6]] to %[[VAL_5]] : !fir.ref>> diff --git a/flang/test/Lower/pointer-initial-target-2.f90 b/flang/test/Lower/pointer-initial-target-2.f90 index 99c7ede50504c..ab478b3e3d704 100644 --- a/flang/test/Lower/pointer-initial-target-2.f90 +++ b/flang/test/Lower/pointer-initial-target-2.f90 @@ -43,8 +43,8 @@ block data bdsnake ! CHECK-LABEL: fir.global @snake_ {alignment = 8 : i64} : tuple>, i32> ! CHECK: %[[tuple0:.*]] = fir.zero_bits tuple>, i32> ! CHECK: %[[snakeAddr:.*]] = fir.address_of(@snake_) : !fir.ref>, i32>> - ! CHECK: %[[byteView:.*]] = fir.convert %[[snakeAddr:.*]] : (!fir.ref>, i32>>) -> !fir.ref> - ! CHECK: %[[coor:.*]] = fir.coordinate_of %[[byteView]], %c24{{.*}} : (!fir.ref>, index) -> !fir.ref + ! CHECK: %[[byteView:.*]] = fir.convert %[[snakeAddr:.*]] : (!fir.ref>, i32>>) -> !fir.ref> + ! CHECK: %[[coor:.*]] = fir.coordinate_of %[[byteView]], %c24{{.*}} : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[bAddr:.*]] = fir.convert %[[coor]] : (!fir.ref) -> !fir.ref ! CHECK: %[[box:.*]] = fir.embox %[[bAddr]] : (!fir.ref) -> !fir.box ! CHECK: %[[rebox:.*]] = fir.rebox %[[box]] : (!fir.box) -> !fir.box> @@ -73,8 +73,7 @@ module some_mod_2 real, pointer :: p(:) => y ! CHECK-LABEL: fir.global @_QMsome_mod_2Ep : !fir.box>> { ! CHECK: %[[c:.*]] = fir.address_of(@com_) : !fir.ref> - ! CHECK: %[[com:.*]] = fir.convert %[[c]] : (!fir.ref>) -> !fir.ref> - ! CHECK: %[[yRaw:.*]] = fir.coordinate_of %[[com]], %c400{{.*}} : (!fir.ref>, index) -> !fir.ref + ! CHECK: %[[yRaw:.*]] = fir.coordinate_of %[[c]], %c400{{.*}} : (!fir.ref>, index) -> !fir.ref ! CHECK: %[[y:.*]] = fir.convert %[[yRaw]] : (!fir.ref) -> !fir.ref> ! CHECK: %[[shape:.*]] = fir.shape_shift %c10{{.*}}, %c200{{.*}} : (index, index) -> !fir.shapeshift<1> ! CHECK: %[[box:.*]] = fir.embox %[[y]](%[[shape]]) : (!fir.ref>, !fir.shapeshift<1>) -> !fir.box> diff --git a/flang/test/Lower/variable-common-viewed-as-module-var.f90 b/flang/test/Lower/variable-common-viewed-as-module-var.f90 index e303df6d91a98..3861e9e2453d6 100644 --- a/flang/test/Lower/variable-common-viewed-as-module-var.f90 +++ b/flang/test/Lower/variable-common-viewed-as-module-var.f90 @@ -31,7 +31,7 @@ subroutine s2() ! CHECK: fir.global common @var_storage_(dense<0> : vector<1xi8>) {alignment = 1 : i64} : !fir.array<1xi8> ! CHECK-LABEL: func.func @_QPs1 -! CHECK: hlfir.declare %{{.*}} typeparams %c1 {uniq_name = "_QMm_common_varEvar"} : (!fir.ref>, index) -> (!fir.ref>, !fir.ref>) +! CHECK: hlfir.declare %{{.*}} typeparams %c1 storage(%{{.*}}[0]) {uniq_name = "_QMm_common_varEvar"} : (!fir.ref>, index, !fir.ref>) -> (!fir.ref>, !fir.ref>) ! CHECK-LABEL: func.func @_QPs2 ! CHECK: hlfir.declare %{{.*}} typeparams %c1 {fortran_attrs = #fir.var_attrs, uniq_name = "var_storage_"} : (!fir.ref>, index) -> (!fir.ref>, !fir.ref>)