diff options
author | Johannes Doerfert <jdoerfert@anl.gov> | 2019-06-27 19:29:48 +0000 |
---|---|---|
committer | Johannes Doerfert <jdoerfert@anl.gov> | 2019-06-27 19:29:48 +0000 |
commit | 6ed459fd41c8ff3ccf1b0a4ac5416fba39f1856a (patch) | |
tree | 228a3552d37ff1d32bda47b5125c87a5bff45566 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 1cf9e72cbc019bd33771900f349d1fc651d682be (diff) | |
download | bcm5719-llvm-6ed459fd41c8ff3ccf1b0a4ac5416fba39f1856a.tar.gz bcm5719-llvm-6ed459fd41c8ff3ccf1b0a4ac5416fba39f1856a.zip |
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
llvm-svn: 364580
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index e49f28513b8..ebd214586d6 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -4285,6 +4285,11 @@ bool llvm::isGuaranteedToTransferExecutionToSuccessor(const Instruction *I) { 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 // |