[llvm-commits] [llvm] r147142 - in /llvm/trunk: lib/Analysis/BranchProbabilityInfo.cpp test/Analysis/BranchProbabilityInfo/noreturn.ll
baldrick at free.fr
Tue Dec 27 03:44:17 PST 2011
On 27/12/11 12:02, Chandler Carruth wrote:
> On Dec 27, 2011 5:32 AM, "Duncan Sands" <baldrick at free.fr
> <mailto:baldrick at free.fr>> wrote:
> > Hi Chandler,
> > > Make the unreachable probability much much heavier. The previous
> > > probability wouldn't be considered "hot" in some weird loop structures
> > > or other compounding probability patterns. This makes it much harder to
> > > confuse, but isn't really a principled fix. I'd actually like it if we
> > > could model a zero probability, as it would make this much easier to
> > > reason about. Suggestions for how to do this better are welcome.
> > a call to a function that only throws an exception will usually be followed
> > by unreachable. Would giving unreachable zero probability mean that throwing
> > the exception is considered to occur with probability zero? While throwing
> > exceptions is fairly rare, it does happen.
> I think to handle this well the probability analysis would need to learn about
> exceptions and throwing so it can differentiate between abort and throw.
"abort" should have the nounwind attribute, which tells you that it is not going
to throw an exception.
> I suspect there are other places where we compute poor probabilities in the face
> of exceptions.
> Still, treating probably exceptional code paths as having a probability that
> *approaches* zero (as BPI is never used to prove reachability) seems not
> entirely unreasonable-it means we will optimize the non-throwing path over the
> throwing path at any expense. That's the same trade off as zero-cost exceptions?
Codegen also supports sj/lj style exception handling in which throwing an
exception is much less expensive than with zero-cost exception handling.
> Anyways, I'm not saying it's the right long term model, suggestions here are
> very welcome.
I don't have any useful ideas for the moment :(
More information about the llvm-commits