[PATCH] D153701: [Clang] Implement P2718R0 "Lifetime extension in range-based for loops"
Yurong via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 14 07:28:05 PDT 2023
yronglin added a comment.
In D153701#4563919 <https://reviews.llvm.org/D153701#4563919>, @yronglin wrote:
> 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:
>
> | Item | Count |
> | Addational Materialized Temporarys Total | 50655585 |
> | Clang Trunk Total | 18346347 |
> | Diff | 32309238 |
> |
>
> The more detail result in https://yronglin.github.io
>
> 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?
I have updated the table, and it was sorted by `Count Inc` col.
**Num files: 7445**
| Item | Count | Mem |
| Addational Materialized Temporarys Total | 50655585 | 1187240.2734 (KB) |
| Clang Trunk Total | 18346347 | 429992.5078 (KB) |
| Diff | 32309238 | 757247.7656 (KB) |
| Avg | 4339.7230 | 4.2380 (KB/file) |
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