[all-commits] [llvm/llvm-project] 0cf1e6: [clang] Skip auto-init on scalar vars that have a ...
Jan Voung via All-commits
all-commits at lists.llvm.org
Mon Jun 24 05:46:53 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0cf1e662b13fb20d3897c5b9055c60b0de50beca
https://github.com/llvm/llvm-project/commit/0cf1e662b13fb20d3897c5b9055c60b0de50beca
Author: Jan Voung <jvoung at gmail.com>
Date: 2024-06-24 (Mon, 24 Jun 2024)
Changed paths:
M clang/lib/CodeGen/CGDecl.cpp
M clang/test/CodeGenCXX/auto-var-init-max-size.cpp
M clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
M clang/test/CodeGenCXX/auto-var-init.cpp
A clang/test/CodeGenCXX/trivial-auto-var-init-skip-scalar-with-nonconst-init.cpp
Log Message:
-----------
[clang] Skip auto-init on scalar vars that have a non-constant Init and no self-ref (#94642)
In that scalar case, the Init should initialize the auto var before use. The Init might use uninitialized memory from other sources (e.g., heap) but auto-init did not help us in that case because the auto-init would have been overwritten by the Init before use.
For non-scalars e.g., classes, the Init expr might be a ctor call that leaves uninitialized members, so we leave the auto-init there.
The motivation is to have less IR for the optimizer to later remove, which may not be until a fairly late pass (DSE) or may not get optimized in lower optimization levels like O1 (no DSE) or sometimes due to derefinement.
This is ~10% less left-over auto-init in O1 in a few examples checked.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list