[PATCH] D63372: Use "willreturn" function attribute in isGuaranteedToTransferExecutionToSuccessor

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 12:30:36 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL364580: Use "willreturn" in isGuaranteedToTransferExecutionToSuccessor (authored by jdoerfert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D63372?vs=206440&id=206907#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63372/new/

https://reviews.llvm.org/D63372

Files:
  llvm/trunk/lib/Analysis/ValueTracking.cpp
  llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp


Index: llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
===================================================================
--- llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
+++ llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
@@ -464,6 +464,7 @@
       "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 @@
       "  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 @@
       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
   };
 
Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -4285,6 +4285,11 @@
     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
     //


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63372.206907.patch
Type: text/x-patch
Size: 1737 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190627/c79e0f85/attachment.bin>


More information about the llvm-commits mailing list