[LLVMdev] General questions about PassManager and the removed SimplifyLibraryCalls pass
Dan Liew
dan at su-root.co.uk
Tue Apr 15 10:21:56 PDT 2014
Hmm maybe I'm doing something wrong but I don't observe that using the
FunctionAttrs pass affects an optimization I see that InstCombine
makes.
ret.c:
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello\n");
exit(0);
}
$ clang -emit-llvm -S -O0 ret.c
$ opt -instcombine --debug-pass=Structure -S ret.ll
I see that the call to @printf() gets replaced by @puts(). During this
run the FunctionAttrs is not being run as far as I can tell.
$ opt -instcombine -disable-simplify-libcalls --debug-pass=Structure -S ret.ll
Using -disable-simplify-libcalls causes disableAllFunctions() to be
called on the TargetLibraryInfo pass. Now the call to @printf() is not
replaced with @puts().
So far FunctionAttrs hasn't been involved in InstCombine's optimisations.
Now if we use the functionattrs pass
$ opt -instcombine -functionattrs --debug-pass=Structure -S ret.ll
nothing much changes compared to ``opt -instcombine
--debug-pass=Structure -S ret.ll`` except that @printf() has the
``nounwind`` attribute added and @puts() has the ``readonly``
parameter on its first argument. The optimisation hasn't really
changed.
I was also expecting the call to @exit() to be replaced with a return
statement but that doesn't seem to of happened.
Thoughts?
Thanks,
Dan Liew.
On 15 April 2014 17:22, Dan Liew <dan at su-root.co.uk> wrote:
> Sorry for not replying earlier. I recently just switched my e-mail
> account and I noticed there were several e-mails I haven't replied to
> during migration.
>
> On 10 April 2014 21:48, Meador Inge <meadori at codesourcery.com> wrote:
>> On 04/04/2014 09:13 PM, Daniel Liew wrote:
>>
>>> 2. I recently noticed that the SimplifyLibraryCallsPass was removed
>>> and according to the LLVM3.4 release notes its functionality is now in
>>> "instruction combiner and function attribute marking passes". I was
>>> wondering, which function attributes passes were meant?
>>
>> The "functionattrs" pass. See 'lib/Transforms/IPO/FunctionAttrs.cpp'.
>
> Oh I thought you meant TargetLibraryInfo because it is used by the opt
> tool to disable simplification of library calls, like so...
>
> PassManager Passes;
>
> // Add an appropriate TargetLibraryInfo pass for the module's triple.
> TargetLibraryInfo *TLI = new TargetLibraryInfo(Triple(M->getTargetTriple()));
>
> // The -disable-simplify-libcalls flag actually disables all builtin optzns.
> if (DisableSimplifyLibCalls)
> TLI->disableAllFunctions();
> Passes.add(TLI);
>
> However the TargetLibraryInfo pass seems to be immutable so I guess
> that means it's not allowed to add attributes to functions. I see that
> the FunctionAttrs pass depends on TargetLibraryInfo so I guess that
> makes sense.
>
> I recently just sent a patch to the documentation relating to this to
> llvm-commits. Looks like I'm going to need to re-write it slightly.
>
> Thanks,
> --
> Dan Liew
> PhD Student - Imperial College London
--
Dan Liew
PhD Student - Imperial College London
More information about the llvm-dev
mailing list