[dragonegg PATCH] Turn off libcall simplification in C and C++ when -fno-builtin is specified

Peter Collingbourne peter at pcc.me.uk
Tue Apr 16 14:17:41 PDT 2013


On Tue, Apr 16, 2013 at 11:26:43AM -0700, Peter Collingbourne wrote:
> On Mon, Apr 15, 2013 at 10:28:23AM +0200, Duncan Sands wrote:
> > Hi Peter,
> >
> >> This patch turns off libcall simplification in C and C++ when
> >> -fno-builtin is specified.
> >>
> >> For now I decided to leave the other languages alone, as this is
> >> probably insufficient for those languages [1].
> >>
> >> OK to commit?
> >
> > I think this patch has several problems.  First off, I'm pretty sure that only
> > the C-like front-ends define flag_no_builtin, so your patch means that you would
> > no longer be able to use the plugin for non-C languages as the reference to
> > flag_no_builtin would fail to resolve when loading the plugin.  Secondly, it
> > doesn't do the right thing if someone uses -fno-builtin-FUNCTION.
> >
> > That said, I think something like this is needed, for the following reason.
> > The -fno-builtin-FUNCTION flags can be supported easily enough because it is
> > possible to query GCC to find out if the FUNCTION builtin is available (this
> > doesn't work well for non-C languages because they tend to only set things up
> > for a sprinkling of builtins they are interested in, not all builtins, but that
> > can be worked around).  With this implemented, -fno-builtin will automatically
> > turn off all libcall simplifications for functions that GCC knows about.  But
> > LLVM has standard library optimizations for functions that GCC doesn't know
> > about, and this mechanism won't ever be able to turn those off.  The only
> > solution I see to that is turning off all LLVM libcall simplifications if the
> > user passes -fno-builtin.  Conclusion: your patch is needed, but you are going
> > to have to define flag_no_builtin as a weak symbol so that non-C languages
> > continue to work.
> 
> Hi Duncan,
> 
> I agree with your reasoning.  I looked into this some more and it
> looks like flag_no_builtin is defined as a macro representing a field
> reference starting from gcc 4.6 onwards, while in previous versions
> it is an ordinary variable as you describe.  So I'll modify the patch
> to use the weak reference for gcc <= 4.5.

Attached.  I guess we can add the support for -fno-builtin-FUNCTION separately.

Thanks,
-- 
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Turn-off-libcall-simplification-in-C-and-C-when-fno-.patch
Type: text/x-diff
Size: 1897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130416/fc3e5531/attachment.patch>


More information about the llvm-commits mailing list