[llvm] r364580 - Use "willreturn" in isGuaranteedToTransferExecutionToSuccessor
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 12:29:49 PDT 2019
Author: jdoerfert
Date: Thu Jun 27 12:29:48 2019
New Revision: 364580
URL: http://llvm.org/viewvc/llvm-project?rev=364580&view=rev
Log:
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
Modified:
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=364580&r1=364579&r2=364580&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Thu Jun 27 12:29:48 2019
@@ -4285,6 +4285,11 @@ bool llvm::isGuaranteedToTransferExecuti
if (!CS.doesNotThrow())
return false;
+ // A function which doens't throw and has "willreturn" attribute will
+ // always return.
+ if (CS.hasFnAttr(Attribute::WillReturn))
+ return true;
+
// Non-throwing call sites can loop infinitely, call exit/pthread_exit
// etc. and thus not return. However, LLVM already assumes that
//
Modified: llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp?rev=364580&r1=364579&r2=364580&view=diff
==============================================================================
--- llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp (original)
+++ llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp Thu Jun 27 12:29:48 2019
@@ -464,6 +464,7 @@ TEST(ValueTracking, GuaranteedToTransfer
"declare void @nounwind_argmemonly(i32*) nounwind argmemonly "
"declare void @throws_but_readonly(i32*) readonly "
"declare void @throws_but_argmemonly(i32*) argmemonly "
+ "declare void @nounwind_willreturn(i32*) nounwind willreturn"
" "
"declare void @unknown(i32*) "
" "
@@ -476,6 +477,7 @@ TEST(ValueTracking, GuaranteedToTransfer
" call void @unknown(i32* %p) nounwind argmemonly "
" call void @unknown(i32* %p) readonly "
" call void @unknown(i32* %p) argmemonly "
+ " call void @nounwind_willreturn(i32* %p)"
" ret void "
"} ";
@@ -497,6 +499,7 @@ TEST(ValueTracking, GuaranteedToTransfer
true, // call void @unknown(i32* %p) nounwind argmemonly
false, // call void @unknown(i32* %p) readonly
false, // call void @unknown(i32* %p) argmemonly
+ true, // call void @nounwind_willreturn(i32* %p)
false, // ret void
};
More information about the llvm-commits
mailing list