llvm-project/llvm/lib/Transforms/Utils
Rong Xu 1c0e9b97d2 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
2016-10-18 21:36:27 +00:00
..
ASanStackFrameLayout.cpp ASan: remove variable only used in assertions build 2016-08-29 19:12:20 +00:00
AddDiscriminators.cpp Invoke add-discriminator at -g0 -fsample-profile 2016-10-07 15:21:31 +00:00
BasicBlockUtils.cpp Apply clang-tidy's modernize-loop-convert to most of lib/Transforms. 2016-06-26 12:28:59 +00:00
BreakCriticalEdges.cpp [PM] Port BreakCriticalEdges to the new PM. 2016-07-22 18:04:25 +00:00
BuildLibCalls.cpp Recommitting r275284: add support to inline __builtin_mempcpy 2016-07-29 18:23:18 +00:00
BypassSlowDivision.cpp Clarify that the bypassSlowDivision optimization operates on a single BB [v2] 2016-01-04 23:18:58 +00:00
CMakeLists.txt Conditionally eliminate library calls where the result value is not used 2016-10-18 21:36:27 +00:00
CloneFunction.cpp [CloneFunction] Don't remove unrelated nodes from the CGSSC 2016-08-19 16:37:40 +00:00
CloneModule.cpp Apply clang-tidy's modernize-loop-convert to most of lib/Transforms. 2016-06-26 12:28:59 +00:00
CmpInstAnalysis.cpp move decomposeBitTestICmp() to Transforms/Utils; NFC 2016-07-20 17:18:45 +00:00
CodeExtractor.cpp CodeExtractor : Add ability to preserve profile data. 2016-08-02 02:15:45 +00:00
CtorUtils.cpp
DemoteRegToStack.cpp
Evaluator.cpp Use the range variant of find instead of unpacking begin/end 2016-08-11 22:21:41 +00:00
FlattenCFG.cpp [FlattenCFG] Simplify + remove unused variable. NFCI. 2016-08-05 20:53:35 +00:00
FunctionImportUtils.cpp IR: Introduce local_unnamed_addr attribute. 2016-06-14 21:01:22 +00:00
GlobalStatus.cpp GlobalStatus: Don't walk use-lists of ConstantData 2016-09-24 02:30:11 +00:00
ImportedFunctionsInliningStatistics.cpp Imported statistics types changes 2016-08-02 22:18:47 +00:00
InlineFunction.cpp Inliner: Don't mark swifterror allocas with lifetime markers 2016-09-09 22:40:27 +00:00
InstructionNamer.cpp Apply clang-tidy's modernize-loop-convert to most of lib/Transforms. 2016-06-26 12:28:59 +00:00
IntegerDivision.cpp TransformUtils: Avoid getNodePtrUnchecked() in integer division, NFC 2016-02-21 20:14:29 +00:00
LCSSA.cpp [LCSSA] Implement linear algorithm for the isRecursivelyLCSSAForm 2016-10-11 13:37:22 +00:00
LLVMBuild.txt
LibCallsShrinkWrap.cpp Conditionally eliminate library calls where the result value is not used 2016-10-18 21:36:27 +00:00
Local.cpp [DebugInfo] Add comments to phi dbg.value tracking code, NFC 2016-09-27 18:45:31 +00:00
LoopSimplify.cpp [LCSSA] Implement linear algorithm for the isRecursivelyLCSSAForm 2016-10-11 13:37:22 +00:00
LoopUnroll.cpp Reapply "[LoopUnroll] Use the upper bound of the loop trip count to fullly unroll a loop" 2016-10-12 21:29:38 +00:00
LoopUnrollRuntime.cpp Revert "[LoopUnroll] Properly update loop-info when cloning prologues and epilogues." 2016-09-08 03:51:30 +00:00
LoopUtils.cpp [LoopUnroll] Use OptimizationRemarkEmitter directly not via the analysis pass 2016-08-26 15:58:34 +00:00
LoopVersioning.cpp Rename LoopAccessAnalysis to LoopAccessLegacyAnalysis /NFC 2016-07-08 20:55:26 +00:00
LowerInvoke.cpp [PM] Port LowerInvoke to the new pass manager 2016-08-12 17:28:27 +00:00
LowerSwitch.cpp Use the range variant of remove_if instead of unpacking begin/end 2016-08-12 04:32:37 +00:00
Mem2Reg.cpp Consistently use FunctionAnalysisManager 2016-08-09 00:28:15 +00:00
MemorySSA.cpp Memory-SSA: strengthen defClobbersUseOrDef interface 2016-10-13 03:23:33 +00:00
MetaRenamer.cpp
ModuleUtils.cpp [ThinLTO] Prevent importing of "llvm.used" values 2016-04-20 14:39:45 +00:00
NameAnonGlobals.cpp Use StringRef in Pass/PassManager APIs (NFC) 2016-10-01 02:56:57 +00:00
PromoteMemoryToRegister.cpp Reapplying r281895 (and follow-up r281964) after fixing pr30468. 2016-09-22 14:13:25 +00:00
SSAUpdater.cpp Use the range variant of find instead of unpacking begin/end 2016-08-11 22:21:41 +00:00
SanitizerStats.cpp Fix Clang-tidy modernize-use-nullptr and modernize-use-override warnings; other minor fixes. 2016-01-26 18:48:36 +00:00
SimplifyCFG.cpp Ignore debug info when making optimization decisions in SimplifyCFG. 2016-10-17 19:28:44 +00:00
SimplifyIndVar.cpp [IndVars] Remove -liv-reduce 2016-06-05 18:01:12 +00:00
SimplifyInstructions.cpp Explicitly require DominatorTreeAnalysis pass for instsimplify pass. 2016-09-06 22:17:16 +00:00
SimplifyLibCalls.cpp Enable simplify libcalls for ARM PCS 2016-09-13 12:10:14 +00:00
SplitModule.cpp Move instances of std::function. 2016-06-12 16:13:55 +00:00
SymbolRewriter.cpp [PM] Port SymbolRewriter to the new PM 2016-07-25 20:52:00 +00:00
UnifyFunctionExitNodes.cpp Apply clang-tidy's modernize-loop-convert to most of lib/Transforms. 2016-06-26 12:28:59 +00:00
Utils.cpp Conditionally eliminate library calls where the result value is not used 2016-10-18 21:36:27 +00:00
ValueMapper.cpp Use range algorithms instead of unpacking begin/end 2016-08-11 21:15:00 +00:00