Skip to content

Commit ff1749d

Browse files
authored
merge main into amd-staging (llvm#736)
2 parents 7264c98 + cd815d9 commit ff1749d

File tree

31 files changed

+485
-239
lines changed

31 files changed

+485
-239
lines changed

clang/include/clang/AST/DeclBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ class alignas(8) Decl {
492492
/// perform non-Decl specific checks based on the object's type and strict
493493
/// flex array level.
494494
static bool isFlexibleArrayMemberLike(
495-
ASTContext &Context, const Decl *D, QualType Ty,
495+
const ASTContext &Context, const Decl *D, QualType Ty,
496496
LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
497497
bool IgnoreTemplateOrMacroSubstitution);
498498

clang/include/clang/AST/Expr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ class Expr : public ValueStmt {
542542
/// When IgnoreTemplateOrMacroSubstitution is set, it doesn't consider sizes
543543
/// resulting from the substitution of a macro or a template as special sizes.
544544
bool isFlexibleArrayMemberLike(
545-
ASTContext &Context,
545+
const ASTContext &Context,
546546
LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
547547
bool IgnoreTemplateOrMacroSubstitution = false) const;
548548

clang/lib/AST/DeclBase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ bool Decl::isFileContextDecl() const {
438438
}
439439

440440
bool Decl::isFlexibleArrayMemberLike(
441-
ASTContext &Ctx, const Decl *D, QualType Ty,
441+
const ASTContext &Ctx, const Decl *D, QualType Ty,
442442
LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
443443
bool IgnoreTemplateOrMacroSubstitution) {
444444
// For compatibility with existing code, we treat arrays of length 0 or

clang/lib/AST/Expr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ bool Expr::isKnownToHaveBooleanValue(bool Semantic) const {
203203
}
204204

205205
bool Expr::isFlexibleArrayMemberLike(
206-
ASTContext &Ctx,
206+
const ASTContext &Ctx,
207207
LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
208208
bool IgnoreTemplateOrMacroSubstitution) const {
209209
const Expr *E = IgnoreParens();

flang/include/flang/Lower/AbstractConverter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ class AbstractConverter {
314314
mangleName(const Fortran::semantics::DerivedTypeSpec &) = 0;
315315
/// Unique a compiler generated name (add a containing scope specific prefix)
316316
virtual std::string mangleName(std::string &) = 0;
317+
/// Unique a compiler generated name (add a provided scope specific prefix)
318+
virtual std::string mangleName(std::string &, const semantics::Scope &) = 0;
317319
/// Return the field name for a derived type component inside a fir.record
318320
/// type.
319321
virtual std::string

flang/lib/Lower/Bridge.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,11 @@ class FirConverter : public Fortran::lower::AbstractConverter {
10491049
return Fortran::lower::mangle::mangleName(name, getCurrentScope(),
10501050
scopeBlockIdMap);
10511051
}
1052+
std::string
1053+
mangleName(std::string &name,
1054+
const Fortran::semantics::Scope &myScope) override final {
1055+
return Fortran::lower::mangle::mangleName(name, myScope, scopeBlockIdMap);
1056+
}
10521057
std::string getRecordTypeFieldName(
10531058
const Fortran::semantics::Symbol &component) override final {
10541059
return Fortran::lower::mangle::getRecordTypeFieldName(component,

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3148,7 +3148,51 @@ static void
31483148
genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
31493149
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
31503150
const parser::OpenMPDeclareMapperConstruct &declareMapperConstruct) {
3151-
TODO(converter.getCurrentLocation(), "OpenMPDeclareMapperConstruct");
3151+
mlir::Location loc = converter.genLocation(declareMapperConstruct.source);
3152+
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
3153+
lower::StatementContext stmtCtx;
3154+
const auto &spec =
3155+
std::get<parser::OmpMapperSpecifier>(declareMapperConstruct.t);
3156+
const auto &mapperName{std::get<std::optional<parser::Name>>(spec.t)};
3157+
const auto &varType{std::get<parser::TypeSpec>(spec.t)};
3158+
const auto &varName{std::get<parser::Name>(spec.t)};
3159+
assert(varType.declTypeSpec->category() ==
3160+
semantics::DeclTypeSpec::Category::TypeDerived &&
3161+
"Expected derived type");
3162+
3163+
std::string mapperNameStr;
3164+
if (mapperName.has_value()) {
3165+
mapperNameStr = mapperName->ToString();
3166+
mapperNameStr =
3167+
converter.mangleName(mapperNameStr, mapperName->symbol->owner());
3168+
} else {
3169+
mapperNameStr =
3170+
varType.declTypeSpec->derivedTypeSpec().name().ToString() + ".default";
3171+
mapperNameStr = converter.mangleName(
3172+
mapperNameStr, *varType.declTypeSpec->derivedTypeSpec().GetScope());
3173+
}
3174+
3175+
// Save current insertion point before moving to the module scope to create
3176+
// the DeclareMapperOp
3177+
mlir::OpBuilder::InsertionGuard guard(firOpBuilder);
3178+
3179+
firOpBuilder.setInsertionPointToStart(converter.getModuleOp().getBody());
3180+
auto mlirType = converter.genType(varType.declTypeSpec->derivedTypeSpec());
3181+
auto declMapperOp = firOpBuilder.create<mlir::omp::DeclareMapperOp>(
3182+
loc, mapperNameStr, mlirType);
3183+
auto &region = declMapperOp.getRegion();
3184+
firOpBuilder.createBlock(&region);
3185+
auto varVal = region.addArgument(firOpBuilder.getRefType(mlirType), loc);
3186+
converter.bindSymbol(*varName.symbol, varVal);
3187+
3188+
// Populate the declareMapper region with the map information.
3189+
mlir::omp::DeclareMapperInfoOperands clauseOps;
3190+
const auto *clauseList{
3191+
parser::Unwrap<parser::OmpClauseList>(declareMapperConstruct.t)};
3192+
List<Clause> clauses = makeClauses(*clauseList, semaCtx);
3193+
ClauseProcessor cp(converter, semaCtx, clauses);
3194+
cp.processMap(loc, stmtCtx, clauseOps);
3195+
firOpBuilder.create<mlir::omp::DeclareMapperInfoOp>(loc, clauseOps.mapVars);
31523196
}
31533197

31543198
static void

flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ class MapInfoFinalizationPass
464464
for (auto *user : mapOp->getUsers()) {
465465
if (llvm::isa<mlir::omp::TargetOp, mlir::omp::TargetDataOp,
466466
mlir::omp::TargetUpdateOp, mlir::omp::TargetExitDataOp,
467-
mlir::omp::TargetEnterDataOp>(user))
467+
mlir::omp::TargetEnterDataOp,
468+
mlir::omp::DeclareMapperInfoOp>(user))
468469
return user;
469470

470471
if (auto mapUser = llvm::dyn_cast<mlir::omp::MapInfoOp>(user))
@@ -495,7 +496,9 @@ class MapInfoFinalizationPass
495496
// ourselves to the possibility of race conditions while this pass
496497
// undergoes frequent re-iteration for the near future. So we loop
497498
// over function in the module and then map.info inside of those.
498-
module->walk([&](mlir::func::FuncOp func) {
499+
getOperation()->walk([&](mlir::Operation *func) {
500+
if (!mlir::isa<mlir::func::FuncOp, mlir::omp::DeclareMapperOp>(func))
501+
return;
499502
// clear all local allocations we made for any boxes in any prior
500503
// iterations from previous function scopes.
501504
localBoxAllocas.clear();
@@ -598,7 +601,6 @@ class MapInfoFinalizationPass
598601
// if (alreadyMapped)
599602
// continue;
600603

601-
#if 1//<<<<<<< HEAD
602604
// builder.setInsertionPoint(op);
603605
// mlir::Value fieldIdxVal = builder.createIntegerConstant(
604606
// op.getLoc(), mlir::IndexType::get(builder.getContext()),
@@ -617,27 +619,6 @@ class MapInfoFinalizationPass
617619
// hlfir::Entity{fieldCoord})
618620
// .first,
619621
// /*dataExvIsAssumedSize=*/false, op.getLoc());
620-
#else//=======
621-
builder.setInsertionPoint(op);
622-
mlir::Value fieldIdxVal = builder.createIntegerConstant(
623-
op.getLoc(), mlir::IndexType::get(builder.getContext()),
624-
fieldIdx);
625-
auto fieldCoord = builder.create<fir::CoordinateOp>(
626-
op.getLoc(), builder.getRefType(memTy), op.getVarPtr(),
627-
fieldIdxVal);
628-
fir::factory::AddrAndBoundsInfo info =
629-
fir::factory::getDataOperandBaseAddr(
630-
builder, fieldCoord, /*isOptional=*/false, op.getLoc());
631-
llvm::SmallVector<mlir::Value> bounds =
632-
fir::factory::genImplicitBoundsOps<mlir::omp::MapBoundsOp,
633-
mlir::omp::MapBoundsType>(
634-
builder, info,
635-
hlfir::translateToExtendedValue(op.getLoc(), builder,
636-
hlfir::Entity{fieldCoord})
637-
.first,
638-
/*dataExvIsAssumedSize=*/false, op.getLoc());
639-
#endif//>>>>>>> ffde2687be1fcb92c0c686aee441b83e71531457
640-
641622
// mlir::omp::MapInfoOp fieldMapOp =
642623
// builder.create<mlir::omp::MapInfoOp>(
643624
// op.getLoc(), fieldCoord.getResult().getType(),

flang/test/Lower/OpenMP/Todo/map-mapper.f90

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

flang/test/Lower/OpenMP/Todo/omp-declare-mapper.f90

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

0 commit comments

Comments
 (0)