public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Debugging optimizer problems
@ 2018-02-02 19:29 jacob navia
  2018-02-02 21:11 ` Florian Weimer
  2018-02-05 22:35 ` Martin Sebor
  0 siblings, 2 replies; 5+ messages in thread
From: jacob navia @ 2018-02-02 19:29 UTC (permalink / raw)
  To: gcc

Hi

I am confronted with a classical problem: a program gives correct 
results when compiled with optimizations off, and gives the wrong ones 
with optimization (-O2) on.

I have isolated the probem in a single file but now there is no way that 
I can further track down the problem to one of the many functions in 
that file.

I have in my small C compiler introduced the following construct:

#pragma optimize(on/off,push/pop)

to deal with optimizer bugs.

#pragma optimize(off)

turns OFF all optimizations until a #pragma optimize(on) is seen or 
until the end of the compiulation unit. If

#pragma optimize(off,push)

is given, the optimization state can be retrieved with a

#pragma optimize(pop), or

#pragma optimize(on)

This has three advantages:

1) Allows the user to reduce the code area where the problem is hiding.

2) Provides a work around to the user for any optimizer bug.

3) Allows gcc developers to find bugs in a more direct fashion.

These pragmas can only be given at a global scope, not within a function.

I do not know gcc internals, and this improvement could be difficult to 
implement, and I do not know either your priorities in gcc development 
but it surely would help users. Obviously I think that the problem is in 
the code I am compiling, not in gcc, but it *could* be in gcc. That 
construct would help enormously.

Thanks in advance for your time.

jacob


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-02-05 22:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-02 19:29 Debugging optimizer problems jacob navia
2018-02-02 21:11 ` Florian Weimer
2018-02-02 22:03   ` jacob navia
2018-02-05 13:46     ` David Brown
2018-02-05 22:35 ` Martin Sebor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).