[llvm-dev] LLVM now assume functions may not return, unless they are marked as willreturn

Florian Hahn via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 25 02:23:04 PST 2021


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() {
int main() {
	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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210125/98053047/attachment.html>

More information about the llvm-dev mailing list