aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Utils.cpp
diff options
context:
space:
mode:
authorRong Xu <xur@google.com>2016-10-18 21:36:27 +0000
committerRong Xu <xur@google.com>2016-10-18 21:36:27 +0000
commit1c0e9b97d2215e2855f2f97cd3db456e8e8dc1b7 (patch)
treeda2b7412812181a5a61e6a569e787e0e4042aaa3 /llvm/lib/Transforms/Utils/Utils.cpp
parentea62ae984414e737f62397fc025d908c7c740969 (diff)
downloadllvm-1c0e9b97d2215e2855f2f97cd3db456e8e8dc1b7.zip
llvm-1c0e9b97d2215e2855f2f97cd3db456e8e8dc1b7.tar.gz
llvm-1c0e9b97d2215e2855f2f97cd3db456e8e8dc1b7.tar.bz2
Conditionally eliminate library calls where the result value is not used
Summary: This pass shrink-wraps a condition to some library calls where the call result is not used. For example: sqrt(val); is transformed to if (val < 0) sqrt(val); Even if the result of library call is not being used, the compiler cannot safely delete the call because the function can set errno on error conditions. Note in many functions, the error condition solely depends on the incoming parameter. In this optimization, we can generate the condition can lead to the errno to shrink-wrap the call. Since the chances of hitting the error condition is low, the runtime call is effectively eliminated. These partially dead calls are usually results of C++ abstraction penalty exposed by inlining. This optimization hits 108 times in 19 C/C++ programs in SPEC2006. Reviewers: hfinkel, mehdi_amini, davidxl Subscribers: modocache, mgorny, mehdi_amini, xur, llvm-commits, beanz Differential Revision: https://reviews.llvm.org/D24414 llvm-svn: 284542
Diffstat (limited to 'llvm/lib/Transforms/Utils/Utils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Utils.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Utils.cpp b/llvm/lib/Transforms/Utils/Utils.cpp
index aa23e80..8dc9c35 100644
--- a/llvm/lib/Transforms/Utils/Utils.cpp
+++ b/llvm/lib/Transforms/Utils/Utils.cpp
@@ -25,6 +25,7 @@ void llvm::initializeTransformUtils(PassRegistry &Registry) {
initializeBreakCriticalEdgesPass(Registry);
initializeInstNamerPass(Registry);
initializeLCSSAWrapperPassPass(Registry);
+ initializeLibCallsShrinkWrapLegacyPassPass(Registry);
initializeLoopSimplifyPass(Registry);
initializeLowerInvokeLegacyPassPass(Registry);
initializeLowerSwitchPass(Registry);