[PATCH] D153701: [WIP][Clang] Implement P2718R0 "Lifetime extension in range-based for loops"

Yurong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 6 06:47:19 PDT 2023


yronglin added a comment.

Sorry for the late reply.  I tried to investigate the memory impact of creating these additional materializations by build the whole llvm-project and compare the number of `MaterializedTemporaryExpr` created during parsing.

Steps:

1. Add a public member `uint64_t NumMetarilizedTemporaryExpr = 0;` in `ASTContext` .
2. Increment the value of `NumMetarilizedTemporaryExpr ` in `Sema::CreateMaterializeTemporaryExpr`.
3. Write the `NumMetarilizedTemporaryExpr ` into a text file when `ASTContext` destruction, each translation unit will append a line to the file to record the value of `NumMetarilizedTemporaryExpr `.
4. Build the entire llvm-project separately using the compiler that creates addational materializations and the compiler that doesn't.
5. Sum the numbers produced by each translation unit.

The result is:

The version that create addational materializations:                 50740658
The version that does not create addational materializations:  18360888

The gap between these two numbers is very large. So I'think we can create additional materializations only within for-range initializers. I'm not sure if I can find a way to only create materializes for temporaries that need to have an extended lifetime, WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153701/new/

https://reviews.llvm.org/D153701



More information about the cfe-commits mailing list