COMP: Use pzero() init for Packet locals in SelfadjointMatrixVector loop#6173
Conversation
Follow-up to InsightSoftwareConsortium#6166. On ubuntu-24.04 + GCC 13/14 + C++20 (the toolchain that InsightSoftwareConsortium#6164 introduces), GCC -O3 IPA-CP emits additional false-positive -Wmaybe-uninitialized at the outer selfadjoint_product_impl::run() call site, attributing the read to "argument 3 of type const float *" of the cloned selfadjoint_matrix_vector_product::run.constprop.isra. Add pzero(Packet{}) declare-then-assign init for the four Packet locals (A0i, A1i, Bi, Xi) loaded from the lhs/rhs/res pointers inside the inner loop. Mirrors the InsightSoftwareConsortium#6166 ptmp2/ptmp3 pattern: pzero() is visible to GCC's IPA-CP as a definite zero starting state, while a bare declaration plus subsequent ploadu/pload is opaque and lets the optimizer trace an uninit path through cloned variants.
|
| Filename | Overview |
|---|---|
| Modules/ThirdParty/Eigen3/src/itkeigen/Eigen/src/Core/products/SelfadjointMatrixVector.h | Adds pzero(Packet{}) before four ploadu/pload calls in the vectorized inner loop to suppress IPA-CP false-positive -Wmaybe-uninitialized warnings with GCC 13/14 + C++20; semantically neutral since each zero-initialized value is immediately overwritten. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["GCC 13/14 + -O3 + C++20\nIPA-CP cloning of run()"] --> B["Creates run.constprop.isra\nspecialized clone"]
B --> C{"SSA analysis of\nPacket locals"}
C -->|"Before fix: opaque load\nPacket A0i = ploadu(a0It)"| D["IPA-CP cannot prove\nSSA value initialized\nalong cloned path"]
D --> E["-Wmaybe-uninitialized\nwarning at line 231\nbypasses #pragma guard"]
C -->|"After fix:\nPacket A0i = pzero(Packet{})\nA0i = ploadu(a0It)"| F["IPA-CP sees definite\nzero starting state\nfor SSA value"]
F --> G["No false-positive warning\ngenerated in clone"]
E --> H["report_build_diagnostics.py\ntreats warning as fatal → exit 255"]
G --> I["Clean CI build ✓"]
Reviews (2): Last reviewed commit: "COMP: Use pzero() init for Packet locals..." | Re-trigger Greptile
|
@dzenanz Please delay merging this for the moment. This whack-a-mole problem, being solved by backporting eigen 5.0.1 fixes to the ITK-vendored 3.4.90 codebase, is creeping from "small acceptable bandage" to "large maintenance nightmare surgery". I'm looking into updating the internal vendored eigen to 5.0.1 (with USE_SYSTEM_EIGEN back support to eigen 3.3.0 or 3.4.0) as an alternative. |
1f7150e
into
InsightSoftwareConsortium:main
Follow-up to #6166 covering the additional GCC -O3 IPA-CP false-positive
-Wmaybe-uninitializedwarnings exposed when #6164 lands itsubuntu-24.04+ GCC 13/14 + C++20 toolchain. Mirrors #6166'spzero(Packet{})pattern at the inner-loop Packet load sites.Symptom on PR #6164
ITK.Linux.Pythonbuild at SHAbf6e691b8(CDash buildid 1124-2153): 0 compile errors, 0 test failures, 4 warnings — all 4 inModules/ThirdParty/Eigen3/src/itkeigen/Eigen/src/Core/products/SelfadjointMatrixVector.h:231of the formwith GCC's note
by argument 3 of type 'const float *' to 'run.constprop' declared here.report_build_diagnostics.pytreats warnings as fatal → exit 255.The Continuous build of
mainat the same toolchain-pre-#6164 baseline (Linux-Build14631-main-Python) showswarn=0. The toolchain bump in #6164 (ubuntu-22.04→ubuntu-24.04, C++17 → C++20) is what exposes the additional IPA-CP cloning paths.Why this works
pzero(Packet{})is visible to GCC's IPA-CP as a definite zero starting state for the Packet SSA value. A barePacket Bi = ploadu<Packet>(rhsIt);is opaque — GCC's IPA-CP-clonedrun.constprop.isracan trace the SSA value back through the cloned signature'sargument 3(therhspointer in the clone after constant args are stripped) and decide along some specialized path the read is from uninitialized memory. The addedPacket X = pzero(Packet{}); X = pload...;pattern gives IPA-CP a known starting state forA0i,A1i,Bi, andXi— same trick #6166 used for theptmp2/ptmp3accumulators.How to verify
This file's warning surface is only triggered on the toolchain combination embedded in #6164 (ubuntu-24.04 + C++20). Local verification on macOS does not reproduce. CI verification:
main.ITK.Linux.Pythonlands clean on rebased COMP: Minimize redundant Azure CI matrix (issue #6163) #6164.