LLVM now assume functions may not return, unless they are marked as willreturn


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


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 . 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.



Should this doc be updated accordingly: https://llvm.org/docs/Frontend/PerformanceTips.html ?