Re: Resurrecting -Wunreachable-code

2014-05-13 Thread Florian Weimer
On 05/08/2014 11:18 AM, Richard Biener wrote: I plan to follow the Java rules, with necessary adjustments due to language differences: They are based on syntax (except for the infinite loop case), so they are much more pr

Re: Resurrecting -Wunreachable

2014-05-08 Thread Richard Biener
On Thu, May 8, 2014 at 10:21 AM, Florian Weimer wrote: > On 05/07/2014 02:43 PM, Richard Biener wrote: > >>> The more challenging issue with early GIMPLE is that loops have already >>> been >>> lowered to gotos, so adopting the syntax-based Java reachability rules is >>> impossible. Oh dear. >> >

Re: Resurrecting -Wunreachable

2014-05-08 Thread Florian Weimer
On 05/07/2014 02:43 PM, Richard Biener wrote: The more challenging issue with early GIMPLE is that loops have already been lowered to gotos, so adopting the syntax-based Java reachability rules is impossible. Oh dear. Perfect is the enemy of the good (no false positives and no false negatives

Re: Resurrecting -Wunreachable

2014-05-07 Thread Richard Biener
On Wed, May 7, 2014 at 2:28 PM, Florian Weimer wrote: > On 05/07/2014 02:11 PM, Richard Biener wrote: > >>> Precisely. But optimizing this: >>> >>> >>> int main() >>> { >>> if (0) >>> foo (); >>> else >>> throw std::logic_error ("error"); >>> bar (); >>> } >>> >>> to: >>>

Re: Resurrecting -Wunreachable

2014-05-07 Thread Florian Weimer
On 05/07/2014 02:11 PM, Richard Biener wrote: Precisely. But optimizing this: int main() { if (0) foo (); else throw std::logic_error ("error"); bar (); } to: int main() { throw std::logic_error ("error"); bar (); } would cause the code to issue such unwante

Re: Resurrecting -Wunreachable

2014-05-07 Thread Richard Biener
On Wed, May 7, 2014 at 2:07 PM, Florian Weimer wrote: > On 05/07/2014 02:04 PM, Richard Biener wrote: > >> Depends on what "trivially" unreachable is. Yes, >> >> int main() >> { >>if (0) >> foo (); >> } >> >> will already be optimized. But I doubt you want to warn for that >> given C++

Re: Resurrecting -Wunreachable

2014-05-07 Thread Florian Weimer
On 05/07/2014 02:04 PM, Richard Biener wrote: Depends on what "trivially" unreachable is. Yes, int main() { if (0) foo (); } will already be optimized. But I doubt you want to warn for that given C++ and templates which often have this kind of specializations. Precisely. But optim

Re: Resurrecting -Wunreachable

2014-05-07 Thread Richard Biener
On Wed, May 7, 2014 at 1:56 PM, Florian Weimer wrote: > On 05/06/2014 04:30 PM, Richard Biener wrote: > >> Like I have suggested in the past a good point to do this kind of analysis >> on the (mostly, as you say) unoptimized IL is right after going into SSA >> form and implementing said analysis a

Re: Resurrecting -Wunreachable

2014-05-07 Thread Florian Weimer
On 05/06/2014 04:30 PM, Richard Biener wrote: Like I have suggested in the past a good point to do this kind of analysis on the (mostly, as you say) unoptimized IL is right after going into SSA form and implementing said analysis as an IPA pass (yeah, that somewhat conflicts). I don't think th

Re: Resurrecting -Wunreachable

2014-05-06 Thread Richard Biener
On Tue, May 6, 2014 at 4:09 PM, Florian Weimer wrote: > I would like to resurrect -Wunreachable, using an algorithm which is roughly > based on the Java rules for reachable statements and normal completion, > augmented to deal with labels and gotos, no-return functions, statement > expressions, an

Resurrecting -Wunreachable

2014-05-06 Thread Florian Weimer
I would like to resurrect -Wunreachable, using an algorithm which is roughly based on the Java rules for reachable statements and normal completion, augmented to deal with labels and gotos, no-return functions, statement expressions, and whatever else is relevant to C and C++. This analysis wo