From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9EFE5385AC33; Tue, 12 Jul 2022 19:51:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9EFE5385AC33 From: "lhyatt at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/106274] New: Loss of macro tracking information with -flto Date: Tue, 12 Jul 2022 19:51:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lhyatt at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jul 2022 19:51:32 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106274 Bug ID: 106274 Summary: Loss of macro tracking information with -flto Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: lhyatt at gcc dot gnu.org CC: marxin at gcc dot gnu.org Target Milestone: --- This is related to PR101551 but easier to demonstrate a testcase for: =3D=3D=3D=3D=3D=3D=3D #define X(p) p =3D=3D 0 int f(void *) __attribute__((nonnull)); int f(void *p) { return X(p); } =3D=3D=3D=3D=3D=3D=3D=3D When compiled without -flto, there is information on the macro expansion in= the diagnostics: $ gcc -c t5.c -Wnonnull-compare /home/lewis/t5.c: In function =E2=80=98f=E2=80=99: /home/lewis/t5.c:1:16: warning: nonnull argument =E2=80=98p=E2=80=99 compar= ed to NULL [-Wnonnull-compare] 1 | #define X(p) p =3D=3D 0 | ^ /home/lewis/t5.c:4:12: note: in expansion of macro =E2=80=98X=E2=80=99 4 | return X(p); | ^ However, if you add -flto, you don't get the extra information: $ gcc -c t5.c -Wnonnull-compare -flto /home/lewis/t5.c: In function =E2=80=98f=E2=80=99: /home/lewis/t5.c:1:16: warning: nonnull argument =E2=80=98p=E2=80=99 compar= ed to NULL [-Wnonnull-compare] 1 | #define X(p) p =3D=3D 0 | ^ The reason is that this warning is generated after the ipa_free_lang_data p= ass, and that does this: =3D=3D=3D=3D=3D=3D=3D=3D /* If we are the LTO frontend we have freed lang-specific data already. */ if (in_lto_p || (!flag_generate_lto && !flag_generate_offload)) { /* Rebuild type inheritance graph even when not doing LTO to get consistent profile data. */ rebuild_type_inheritance_graph (); return 0; } ... /* Reset diagnostic machinery. */ tree_diagnostics_defaults (global_dc); =3D=3D=3D=3D=3D=3D=3D=3D With -flto, flag_generate_lto is true, so it doesn't return early, and proc= eeds to the last line, which resets the diagnostic finalizer to default_diagnostic_finalizer, which is not aware of virtual locations. PR101551 is about more or less the same thing except it's the other case th= at prevents this function from returning early (flag_generate_offload =3D=3D t= rue). I am not sure to what extent they are otherwise related. Is it possible to avoid resetting the diagnostics machinery in either of th= ese cases? Thanks...=