================ @@ -8811,8 +8829,19 @@ class MappableExprsHandler { ++EI; } } - llvm::stable_sort(DeclComponentLists, [](const MapData &LHS, - const MapData &RHS) { + llvm::stable_sort(DeclComponentLists, [VD](const MapData &LHS, + const MapData &RHS) { + // For cases like map(p, p[0], p[0][0]), the shortest map, like map(p) ---------------- abhinavgaba wrote:
And I'm also not sure yet the lambda captures function would interact with this if we split g`enerateInfoForCapture. > 2. What if we have 3-level dependency, will we need the third loop in this > case? For a three-level pointer case like this: `map(to: sp->x, sp->y) map(to: sp->sq->a, sp->sq->b) map(to: sp->sq->sr->c, sp->sq->sr->d) map(sp)` We should eventually have something like: ``` &sp, &sp, sizeof(sp), TO | PARAM // map-chain for the containing-struct sp[0] with base-pointer sp &sp[0], &sp[0], sizeof(sp[0]), ALLOC &sp[0], &sp->x, sizeof(sp->x), TO | MEMBER_OF(2) &sp[0], &sp->y, sizeof(sp->y), TO | MEMBER_OF(2) &sp, &sp[0], ATTACH // map-chain for the containing-struct sp->sq[0] with base-pointer sp->sq &(sp->sq[0]), &(sp->sq[0]), sizeof(sp->sq[0]), ALLOC &sp->sq[0], &sp->sq->a, sizeof(sp->sq->a), TO | MEMBER_OF(6) &sp->sq[0], &sp->sq->a, sizeof(sp->sq->a), TO | MEMBER_OF(6) &sp->sq, &sp->sq[0], ATTACH // map-chain for the containing-struct sp->sq->sr[0] with base-pointer sp->sq->sr &(sp->sq->sr[0]), &(sp->sq->sr[0]), sizeof(sp->sq->sr[0]), ALLOC &sp->sq->sr[0], &sp->sq->sr->c, sizeof(sp->sq->sr->c), TO | MEMBER_OF(10) &sp->sq->sr[0], &sp->sq->sr->d, sizeof(sp->sq->sr->d), TO | MEMBER_OF(10) &sp->sq->sr, &sp->sq->sr[0], ATTACH ``` The `for (Expr* AttachBasePtr: AttachBasePtrs)` loop would need to run three times, once each for the for the attachable-base-pointer `sp`, `sp->sq`, and `sp->sq->sr`. And we can think of the first invocation to be for the component-lists that have no base-pointer, and pull that into the loop as well. https://github.com/llvm/llvm-project/pull/145454 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits