[PATCH] D14227: Add a new attribute: norecurse

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 08:48:37 PST 2015


Hi David,

There was some discussion here that caused me to go down this route:
http://reviews.llvm.org/D14148 . There are a couple of reasons why I think
this is better as an attribute than an analysis, although I'm not strongly
opposed to it being an analysis instead.

* Analyses are easy to clobber, hard to preserve. The chances of having to
recompute this information when needed is high. This is a weak argument in
and of itself, though.
* Norecurse does actually model language features. OpenCL mandates no
recursion, so all of its BIFLs could be annotated with this so that
optimizatons on non-recursive functions can take place even when BIFLs
aren't available (function prototypes only).
* In C++, "main" is non-recursive. This is not the case in C, and there is
a longstanding gratuitous hack in GlobalOpt that completely breaks C in
favour of C++ by string-matching "main". This attribute allows us to have
Clang tell the backend this information in a language-safe manner.

Cheers,

James

On Mon, 2 Nov 2015 at 16:41 David Blaikie via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> On Mon, Nov 2, 2015 at 5:03 AM, James Molloy via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> jmolloy created this revision.
>> jmolloy added reviewers: manmanren, dexonsmith, joker.eph.
>> jmolloy added a subscriber: llvm-commits.
>> jmolloy set the repository for this revision to rL LLVM.
>>
>> This attribute allows the compiler to assume that the function never
>> recurses into itself, either directly or indirectly (transitively). This
>> can be used among other things to demote global variables to locals.
>>
>
> Where would this attribute generally come from? Is it expected that this
> would be exposed as a source language attribute? (any prior art there?)
> Otherwise wouldn't this be an LLVM analysis, rather than a first-class IR
> feature?
>
>
>>
>> The norecurse attribute indicates that the function does not call itself
>> either directly or indirectly down any possible call path.
>>
>> Repository:
>>   rL LLVM
>>
>> http://reviews.llvm.org/D14227
>>
>> Files:
>>   docs/LangRef.rst
>>   include/llvm/Bitcode/LLVMBitCodes.h
>>   include/llvm/IR/Attributes.h
>>   include/llvm/IR/Function.h
>>   lib/AsmParser/LLLexer.cpp
>>   lib/AsmParser/LLParser.cpp
>>   lib/AsmParser/LLToken.h
>>   lib/Bitcode/Reader/BitcodeReader.cpp
>>   lib/Bitcode/Writer/BitcodeWriter.cpp
>>   lib/IR/Attributes.cpp
>>   lib/IR/Verifier.cpp
>>   test/Bindings/llvm-c/invalid-bitcode.test
>>   test/Bitcode/attributes.ll
>>   test/Bitcode/compatibility.ll
>>   test/Bitcode/invalid.ll
>>   test/LTO/X86/invalid.ll
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151102/cc488318/attachment.html>


More information about the llvm-commits mailing list