----- Original Message ----- > From: "Chris Lattner" <clatt...@apple.com> > To: "Hal Finkel" <hfin...@anl.gov> > Cc: rjmcc...@gmail.com, cfe-commits@cs.uiuc.edu, > reviews+d3806+public+8377178d9ac8d...@reviews.llvm.org > Sent: Monday, May 19, 2014 6:37:46 PM > Subject: Re: [PATCH] These builtin functions set errno. Mark them accordingly. > > On May 19, 2014, at 10:05 AM, Hal Finkel <hfin...@anl.gov> wrote: > >>> > >>> I'm not going to push this patch further because it's not the > >>> right > >>> solution. In theory, I believe it is correct, but it breaks the > >>> __buitlin escape hatch, which would likely result in serious > >>> performance degradations. > >> > >> I don’t think this is a good solution. The better option here is > >> to > >> tell people to use -fno-math-errno if they don’t care about libm > >> functions setting errno. > > > > But this is the chicken and egg problem: is __builtin_sqrt a libm > > function? The problem that we currently have, IIUC, is that the > > answer is *sometimes*. > > I don’t really care about the builtin,
We need to decide on the semantics of the builtin when -fmath-errno is in effect: might the builtin clobber errno? The current answer is sometimes, the useful answer is no (IMHO) -- at least the useful answer is no when the target really can implement the function without clobbering errno. > it is a transient part of the > AST and having the attributes on it be changed when -fno-math-errno > is set is natural and probably already done. We currently do this for the libm calls themselves, but not for the builtins. This allows us to use the __builtin version to get the 'readnone' version of the function, even when -fmath-errno is in effect. Presumably, this permits the target to directly lower to some instruction (something not normally possible with -fmath-errno and the libm function). > > At the IR level, we already have attributes to model both states: > llvm.sqrt when set to readnone doesn’t modify errno. Yes. -Hal > > -Chris > > -- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits