llvm.org GIT mirror llvm / 775fc95
Use "willreturn" in isGuaranteedToTransferExecutionToSuccessor The `willreturn` function attribute guarantees that a function call will come back to the call site if the call is also known not to throw. Therefore, this attribute can be used in `isGuaranteedToTransferExecutionToSuccessor`. Patch by Hideto Ueno (@uenoku) Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63372 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364580 91177308-0d34-0410-b5e6-96231b3b80d8 Johannes Doerfert a month ago
2 changed file(s) with 8 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
42844284 if (!CS.doesNotThrow())
42854285 return false;
42864286
4287 // A function which doens't throw and has "willreturn" attribute will
4288 // always return.
4289 if (CS.hasFnAttr(Attribute::WillReturn))
4290 return true;
4291
42874292 // Non-throwing call sites can loop infinitely, call exit/pthread_exit
42884293 // etc. and thus not return. However, LLVM already assumes that
42894294 //
463463 "declare void @nounwind_argmemonly(i32*) nounwind argmemonly "
464464 "declare void @throws_but_readonly(i32*) readonly "
465465 "declare void @throws_but_argmemonly(i32*) argmemonly "
466 "declare void @nounwind_willreturn(i32*) nounwind willreturn"
466467 " "
467468 "declare void @unknown(i32*) "
468469 " "
475476 " call void @unknown(i32* %p) nounwind argmemonly "
476477 " call void @unknown(i32* %p) readonly "
477478 " call void @unknown(i32* %p) argmemonly "
479 " call void @nounwind_willreturn(i32* %p)"
478480 " ret void "
479481 "} ";
480482
496498 true, // call void @unknown(i32* %p) nounwind argmemonly
497499 false, // call void @unknown(i32* %p) readonly
498500 false, // call void @unknown(i32* %p) argmemonly
501 true, // call void @nounwind_willreturn(i32* %p)
499502 false, // ret void
500503 };
501504