Bug 87153 - Confusing / Incorrect clobber warning with ISRA / -Wclobber
Summary: Confusing / Incorrect clobber warning with ISRA / -Wclobber
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 8.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, ra
Depends on:
Blocks:
 
Reported: 2018-08-30 10:07 UTC by Chris Jefferson
Modified: 2021-12-24 21:30 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-12-24 00:00:00


Attachments
Preprocessed file which produces clobbering warning (37.01 KB, text/plain)
2018-08-30 10:07 UTC, Chris Jefferson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Jefferson 2018-08-30 10:07:10 UTC
Created attachment 44628 [details]
Preprocessed file which produces clobbering warning

I am getting the following warning from code, compiling with -Os -Wclobbered

src/read.c: In function ‘EvalRef.isra.25’:
cc1: warning: argument ‘ISRA.312’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered]

EvalRef is defined as:

static UInt EvalRef(const LHSRef ref, Int needExpr)

Which fdump-tree-all, preprocess.c.225t.switchlower shows as:

EvalRef.isra.25 (const REFTYPE ISRA.310, const UInt ISRA.311, const UInt ISRA.312, Int needExpr)

So, there are (I feel) two issues. Firstly, the warning isn't helpful as it references a gcc-introduced function. Also I still don't see how ISRA.312 could get clobbered, as it is const.

Unfortunately I have tried and failed to produce a small reproducable case of this. I attach a preprocessed source file, made with gcc 8.0.1 on Ubuntu 18.04, from the current master branch of https://www.github.com/gap-system/gap
Comment 1 Richard Biener 2018-08-30 10:40:44 UTC
Confirmed.  I think the warning tells you that the ISRA.312 when not spilled
to the stack by the compiler, might be not properly restored.  That it is
'const' doesn't really matter.

Given the source passes an aggregate by value depending on the ABI
you might get the very same bad effect.

Eventually we can do better with this warning and only warn when we
actually failed to spill the register.

I think the warning for arguments is usually a false positive since
argument registers are call-clobbered.

Given we use setjmp_crosses for the warning I wonder why we do not use
that to guide register allocation ...