@@ -6808,28 +6808,29 @@ class MappableExprsHandler {
6808
6808
/// they were computed by collectAttachPtrExprInfo(), if they are semantically
6809
6809
/// different.
6810
6810
struct AttachPtrExprComparator {
6811
- const MappableExprsHandler * Handler = nullptr ;
6811
+ const MappableExprsHandler & Handler;
6812
6812
// Cache of previous equality comparison results.
6813
6813
mutable llvm::DenseMap<std::pair<const Expr *, const Expr *>, bool>
6814
6814
CachedEqualityComparisons;
6815
6815
6816
- AttachPtrExprComparator(const MappableExprsHandler *H) : Handler(H) {}
6816
+ AttachPtrExprComparator(const MappableExprsHandler &H) : Handler(H) {}
6817
+ AttachPtrExprComparator() = delete;
6817
6818
6818
6819
// Return true iff LHS is "less than" RHS.
6819
6820
bool operator()(const Expr *LHS, const Expr *RHS) const {
6820
6821
if (LHS == RHS)
6821
6822
return false;
6822
6823
6823
6824
// First, compare by complexity (depth)
6824
- const auto ItLHS = Handler-> AttachPtrComponentDepthMap.find(LHS);
6825
- const auto ItRHS = Handler-> AttachPtrComponentDepthMap.find(RHS);
6825
+ const auto ItLHS = Handler. AttachPtrComponentDepthMap.find(LHS);
6826
+ const auto ItRHS = Handler. AttachPtrComponentDepthMap.find(RHS);
6826
6827
6827
6828
std::optional<size_t> DepthLHS =
6828
- (ItLHS != Handler-> AttachPtrComponentDepthMap.end()) ? ItLHS->second
6829
- : std::nullopt;
6829
+ (ItLHS != Handler. AttachPtrComponentDepthMap.end()) ? ItLHS->second
6830
+ : std::nullopt;
6830
6831
std::optional<size_t> DepthRHS =
6831
- (ItRHS != Handler-> AttachPtrComponentDepthMap.end()) ? ItRHS->second
6832
- : std::nullopt;
6832
+ (ItRHS != Handler. AttachPtrComponentDepthMap.end()) ? ItRHS->second
6833
+ : std::nullopt;
6833
6834
6834
6835
// std::nullopt (no attach pointer) has lowest complexity
6835
6836
if (!DepthLHS.has_value() && !DepthRHS.has_value()) {
@@ -6877,8 +6878,8 @@ class MappableExprsHandler {
6877
6878
/// Returns true iff LHS was computed before RHS by
6878
6879
/// collectAttachPtrExprInfo().
6879
6880
bool wasComputedBefore(const Expr *LHS, const Expr *RHS) const {
6880
- const size_t &OrderLHS = Handler-> AttachPtrComputationOrderMap.at(LHS);
6881
- const size_t &OrderRHS = Handler-> AttachPtrComputationOrderMap.at(RHS);
6881
+ const size_t &OrderLHS = Handler. AttachPtrComputationOrderMap.at(LHS);
6882
+ const size_t &OrderRHS = Handler. AttachPtrComputationOrderMap.at(RHS);
6882
6883
6883
6884
return OrderLHS < OrderRHS;
6884
6885
}
@@ -6897,7 +6898,7 @@ class MappableExprsHandler {
6897
6898
if (!LHS || !RHS)
6898
6899
return false;
6899
6900
6900
- ASTContext &Ctx = Handler-> CGF.getContext();
6901
+ ASTContext &Ctx = Handler. CGF.getContext();
6901
6902
// Strip away parentheses and no-op casts to get to the core expression
6902
6903
LHS = LHS->IgnoreParenNoopCasts(Ctx);
6903
6904
RHS = RHS->IgnoreParenNoopCasts(Ctx);
@@ -7246,6 +7247,10 @@ class MappableExprsHandler {
7246
7247
llvm::DenseMap<const Expr *, size_t> AttachPtrComputationOrderMap = {
7247
7248
{nullptr, 0}};
7248
7249
7250
+ /// An instance of attach-ptr-expr comparator that can be used throughout the
7251
+ /// lifetime of this handler.
7252
+ AttachPtrExprComparator AttachPtrComparator;
7253
+
7249
7254
llvm::Value *getExprTypeSize(const Expr *E) const {
7250
7255
QualType ExprTy = E->getType().getCanonicalType();
7251
7256
@@ -8963,7 +8968,7 @@ class MappableExprsHandler {
8963
8968
8964
8969
public:
8965
8970
MappableExprsHandler(const OMPExecutableDirective &Dir, CodeGenFunction &CGF)
8966
- : CurDir(&Dir), CGF(CGF) {
8971
+ : CurDir(&Dir), CGF(CGF), AttachPtrComparator(*this) {
8967
8972
// Extract firstprivate clause information.
8968
8973
for (const auto *C : Dir.getClausesOfKind<OMPFirstprivateClause>())
8969
8974
for (const auto *D : C->varlist())
@@ -9009,7 +9014,7 @@ class MappableExprsHandler {
9009
9014
9010
9015
/// Constructor for the declare mapper directive.
9011
9016
MappableExprsHandler(const OMPDeclareMapperDecl &Dir, CodeGenFunction &CGF)
9012
- : CurDir(&Dir), CGF(CGF) {}
9017
+ : CurDir(&Dir), CGF(CGF), AttachPtrComparator(*this) {}
9013
9018
9014
9019
/// Generate code for the combined entry if we have a partially mapped struct
9015
9020
/// and take care of the mapping flags of the arguments corresponding to
0 commit comments