Florian Hahn via llvm-dev
2021-Jan-25 10:23 UTC
[llvm-dev] LLVM now assume functions may not return, unless they are marked as willreturn
Hi, Just a quick heads up. Recently a few changes landed that updated code in LLVM that implicitly assumed some functions will return. Now, the code explicitly checks for the `willreturn` attribute. Please see the patches below https://reviews.llvm.org/rG292077072ec1 <https://reviews.llvm.org/rG292077072ec1> https://reviews.llvm.org/rG5d12b976b004 <https://reviews.llvm.org/rG5d12b976b004> Among other things, this means LLVM now won’t remove function calls to readonly functions, unless they are willreturn. This fixes some longstanding issues for languages without C++-like forward-progress guarantees (see https://bugs.llvm.org/show_bug.cgi?id=965 ) For the simple example below, LLVM now won’t remove the call to loop(), if it is compiled as a C program. void loop() { while(1); } int main() { loop(); return 1; } If your frontend provides C++-like forward progress guarantees, please make sure functions/loops are marked as `mustprogress` accordingly. Mustprogress helps with inferring `willlreturn`. If your frontend can guarantee a function will always return, consider adding the `willreturn` attribute to the generated functions. Please audit the intrinsics definitions for your target. They also need to be marked as willreturn, if possible.As an example, see the patch that updated AArch64 https://reviews.llvm.org/rG50ae6a3ac9bd <https://reviews.llvm.org/rG50ae6a3ac9bd> . At the moment, the code still (wrongly) assumes that all intrinsics will return. Once people had time to update their backends, the plan is to remove this assumption. Cheers, Florian -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210125/98053047/attachment.html>
Mehdi AMINI via llvm-dev
2021-Jan-26 00:21 UTC
[llvm-dev] LLVM now assume functions may not return, unless they are marked as willreturn
Hi, Should this doc be updated accordingly: https://llvm.org/docs/Frontend/PerformanceTips.html ? Thanks! -- Mehdi On Mon, Jan 25, 2021 at 2:23 AM Florian Hahn via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi, > > Just a quick heads up. Recently a few changes landed that updated code in > LLVM that implicitly assumed some functions will return. Now, the code > explicitly checks for the `willreturn` attribute. Please see the patches > below > https://reviews.llvm.org/rG292077072ec1 > https://reviews.llvm.org/rG5d12b976b004 > > Among other things, this means LLVM now won’t remove function calls to > readonly functions, unless they are willreturn. This fixes some > longstanding issues for languages without C++-like forward-progress > guarantees (see https://bugs.llvm.org/show_bug.cgi?id=965 ) > > For the simple example below, LLVM now won’t remove the call to loop(), > if it is compiled as a C program. > > void loop() { > while(1); > } > int main() { > loop(); > return 1; > } > > > If your frontend provides C++-like forward progress guarantees, please > make sure functions/loops are marked as `mustprogress` accordingly. > Mustprogress helps with inferring `willlreturn`. > > If your frontend can guarantee a function will always return, consider > adding the `willreturn` attribute to the generated functions. > > Please audit the intrinsics definitions for your target. They also need to > be marked as willreturn, if possible.As an example, see the patch that > updated AArch64 https://reviews.llvm.org/rG50ae6a3ac9bd . At the moment, > the code still (wrongly) assumes that all intrinsics will return. Once > people had time to update their backends, the plan is to remove this > assumption. > > Cheers, > Florian > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210125/11944336/attachment.html>