Following #197442, FortranEvaluate was implicitly included in OpenMP-utils.h which should be avoided to ensure front-end data structures in the Optimizers can stop and restart pure MLIR source without any side-data structures. To ensure this is done, EntryBlockArgs has been stripped back to only track vars, objects are now tracked within ObjectEntryBlockArgs in Lowering as this is a more appropriate place for this information, and the existing symbol tracking in EntryBlockArgsEntry was only used here. This ensures FortranEvaluate is not needed within the Optimizers, and objects can still be maintained when lowering. This enables better referencing in Reduction Clauses, where previously context was being lost for expressions such as ArrayElements. See more: #197442 Assisted-by: Codex
49 lines
1.9 KiB
C++
49 lines
1.9 KiB
C++
//===-- lib/Support/OpenMP-utils.cpp ----------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "flang/Support/OpenMP-utils.h"
|
|
|
|
#include "mlir/IR/OpDefinition.h"
|
|
|
|
namespace Fortran::common::openmp {
|
|
mlir::Block *genEntryBlock(mlir::OpBuilder &builder, const EntryBlockArgs &args,
|
|
mlir::Region ®ion) {
|
|
assert(region.empty() && "non-empty region");
|
|
|
|
llvm::SmallVector<mlir::Type> types;
|
|
llvm::SmallVector<mlir::Location> locs;
|
|
unsigned numVars = args.hasDeviceAddrVars.size() + args.hostEvalVars.size() +
|
|
args.inReductionVars.size() + args.mapVars.size() + args.privVars.size() +
|
|
args.reductionVars.size() + args.taskReductionVars.size() +
|
|
args.useDeviceAddrVars.size() + args.useDevicePtrVars.size();
|
|
types.reserve(numVars);
|
|
locs.reserve(numVars);
|
|
|
|
auto extractTypeLoc = [&types, &locs](llvm::ArrayRef<mlir::Value> vals) {
|
|
llvm::transform(vals, std::back_inserter(types),
|
|
[](mlir::Value v) { return v.getType(); });
|
|
llvm::transform(vals, std::back_inserter(locs),
|
|
[](mlir::Value v) { return v.getLoc(); });
|
|
};
|
|
|
|
// Populate block arguments in clause name alphabetical order to match
|
|
// expected order by the BlockArgOpenMPOpInterface.
|
|
extractTypeLoc(args.hasDeviceAddrVars);
|
|
extractTypeLoc(args.hostEvalVars);
|
|
extractTypeLoc(args.inReductionVars);
|
|
extractTypeLoc(args.mapVars);
|
|
extractTypeLoc(args.privVars);
|
|
extractTypeLoc(args.reductionVars);
|
|
extractTypeLoc(args.taskReductionVars);
|
|
extractTypeLoc(args.useDeviceAddrVars);
|
|
extractTypeLoc(args.useDevicePtrVars);
|
|
|
|
return builder.createBlock(®ion, {}, types, locs);
|
|
}
|
|
} // namespace Fortran::common::openmp
|