aeft wrote: > When I compile LLVM with clang built from this PR, it reports 821 new unique > warnings. I looked into several and found they are FPs. I will follow up with > details, fixes, and reproducer test cases.
My latest commit fixes 817 FPs out of 821 warnings. Three related fixes: 1. `handleAssignment` now `markAsWritten` the narrowed `UseFact` for `MemberExpr LHS` (previously only `DeclRefExpr LHS`). Tests: `struct_field_in_loop_safe`. 2. `VisitMemberExpr`'s narrow now peels the per-Expr lvalue wrap from UseFact's UsedOrigins, mirroring handleUse's peel-for-non-reference-DRE rule. Tests: `struct_field_read_in_loop_safe`. 3. `VisitMemberExpr`'s narrow now also fires for reference fields (previously gated on `doesDeclHaveStorage`), so `handleAssignment`'s reference-assignment path can find the narrowed UseFact for ME LHS. Tests: `ref_field_dangle_then_rescue`. The remaining warnings are TPs but are safe in practice (testing commit: 461e473a8f1d1af85f8392b3b529adfca31eadb1): ``` /workspace/llvm-project/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp:166:17: warning: address of stack memory escapes to a field [-Wlifetime-safety-dangling-field] /workspace/llvm-project/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp:198:27: warning: address of stack memory escapes to a field [-Wlifetime-safety-dangling-field] /workspace/llvm-project/llvm/lib/ProfileData/InstrProfWriter.cpp:524:30: warning: address of stack memory escapes to a field [-Wlifetime-safety-dangling-field] /workspace/llvm-project/llvm/lib/ProfileData/InstrProfWriter.cpp:526:32: warning: address of stack memory escapes to a field [-Wlifetime-safety-dangling-field] ``` - `InstrProfWriter.cpp:524`, `:526`: the field is reset to `nullptr` before the local goes out of scope. - `InstructionSelect.cpp:166`, `:198`: fragile but currently safe, the field is left dangling without an explicit reset, working only because no one reads it after the local dies. cc @usx95 https://github.com/llvm/llvm-project/pull/195603 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
