summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add null check for promoted direct callDehao Chen2017-08-291-2/+2
| | | | | | | | | | | | | | Summary: We originally assume that in pgo-icp, the promoted direct call will never be null after strip point casts. However, stripPointerCasts is so smart that it could possibly return the value of the function call if it knows that the return value is always an argument. In this case, the returned value cannot cast to Instruction. In this patch, null check is added to ensure null pointer will not be accessed. Reviewers: tejohnson, xur, davidxl, djasper Reviewed By: tejohnson Subscribers: llvm-commits, sanjoy Differential Revision: https://reviews.llvm.org/D37252 llvm-svn: 312005
* Create PHI node for the return value only when the return value has uses.Taewook Oh2017-08-281-0/+3
| | | | | | | | | | | | | | | | | | | Summary: Currently, a phi node is created in the normal destination to unify the return values from promoted calls and the original indirect call. This patch makes this phi node to be created only when the return value has uses. This patch is necessary to generate valid code, as compiler crashes with the attached test case without this patch. Without this patch, an illegal phi node that has no incoming value from `entry`/`catch` is created in `cleanup` block. I think existing implementation is good as far as there is at least one use of the original indirect call. `insertCallRetPHI` creates a new phi node in the normal destination block only when the original indirect call dominates its use and the normal destination block. Otherwise, `fixupPHINodeForNormalDest` will handle the unification of return values naturally without creating a new phi node. However, if there's no use, `insertCallRetPHI` still creates a new phi node even when the original indirect call does not dominate the normal destination block, because `getCallRetPHINode` returns false. Reviewers: xur, davidxl, danielcdh Reviewed By: xur Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37176 llvm-svn: 311906
* Add missing dependency in ICP. (NFC)Dehao Chen2017-08-141-4/+9
| | | | llvm-svn: 310896
* Make ICP uses PSI to check for hotness.Dehao Chen2017-08-081-8/+20
| | | | | | | | | | | | | | Summary: Currently, ICP checks the count against a fixed value to see if it is hot enough to be promoted. This does not work for SamplePGO because sampled count may be much smaller. This patch uses PSI to check if the count is hot enough to be promoted. Reviewers: davidxl, tejohnson, eraman Reviewed By: davidxl Subscribers: sanjoy, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D36341 llvm-svn: 310416
* [ICP] Migrate to OptimizationRemarkEmitterAdam Nemet2017-07-271-35/+53
| | | | | | | | | | | | | | | | | | | | | This is a module pass so for the old PM, we can't use ORE, the function analysis pass. Instead ORE is created on the fly. A few notes: - isPromotionLegal is folded in the caller since we want to emit the Function in the remark but we can only do that if the symbol table look-up succeeded. - There was good test coverage for remarks in this pass. - promoteIndirectCall uses ORE conditionally since it's also used from SampleProfile which does not use ORE yet. Fixes PR33792. Differential Revision: https://reviews.llvm.org/D35929 llvm-svn: 309294
* [ProfileData] PR33517: Check for failure of symtab creationVedant Kumar2017-06-201-1/+6
| | | | | | | | | | | | With PR33517, it became apparent that symbol table creation can fail when presented with malformed inputs. This patch makes that sort of error detectable, so llvm-cov etc. can fail more gracefully. Specifically, we now check that function names within the symbol table aren't empty. Testing: check-{llvm,clang,profile}, some unit test updates. llvm-svn: 305765
* Split PGO memory intrinsic optimization into its own source fileTeresa Johnson2017-06-151-361/+0
| | | | | | | | | | | | | | Summary: Split the PGOMemOPSizeOpt pass out from IndirectCallPromotion.cpp into its own file. Reviewers: davidxl Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D34248 llvm-svn: 305501
* [PGO] Update VP metadata after memory intrinsic optimizationTeresa Johnson2017-06-131-0/+8
| | | | | | | | | | | | | | | Summary: Leave an updated VP metadata on the fallback memcpy intrinsic after specialization. This can be used for later possible expansion based on the average of the remaining values. Reviewers: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34164 llvm-svn: 305321
* Fix spelling error in command line option description. NFCCraig Topper2017-05-051-2/+2
| | | | llvm-svn: 302311
* Memory intrinsic value profile optimization: Avoid divide by 0Teresa Johnson2017-04-281-0/+4
| | | | | | | | | | | | | | Summary: Skip memops if the total value profiled count is 0, we can't correctly scale up the counts and there is no point anyway. Reviewers: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32624 llvm-svn: 301645
* Memory intrinsic value profile optimization: Improve debug output (NFC)Teresa Johnson2017-04-271-9/+11
| | | | | | | | | | | | | | Summary: Misc improvements to debug output. Fix a couple typos and also dump the value profile before we make any profitability checks. Reviewers: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32607 llvm-svn: 301574
* Update profile during memory instrinsic optimizationTeresa Johnson2017-04-241-1/+3
| | | | | | | | | | | | | | | | Summary: Ensure that the new merge BB (which contains the rest of the original BB after the mem op being optimized) gets a profile frequency, in case there are additional mem ops later in the BB. Otherwise they get skipped as the merge BB looks cold. Reviewers: davidxl, xur Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32447 llvm-svn: 301244
* [PGO] Preserve GlobalsAA in pgo-memop-opt pass.Rong Xu2017-04-061-1/+5
| | | | | | | Preserve GlobalsAA analysis in memory intrinsic calls optimization based on profiled size. llvm-svn: 299707
* [PGO] Memory intrinsic calls optimization based on profiled sizeRong Xu2017-04-041-1/+345
| | | | | | | | | | | | | | | | | | | | | | | | This patch optimizes two memory intrinsic operations: memset and memcpy based on the profiled size of the operation. The high level transformation is like: mem_op(..., size) ==> switch (size) { case s1: mem_op(..., s1); goto merge_bb; case s2: mem_op(..., s2); goto merge_bb; ... default: mem_op(..., size); goto merge_bb; } merge_bb: Differential Revision: http://reviews.llvm.org/D28966 llvm-svn: 299446
* Add call branch annotation for ICP promoted direct call in SamplePGO mode.Dehao Chen2017-02-231-14/+42
| | | | | | | | | | | | | | Summary: SamplePGO uses branch_weight annotation to represent callsite hotness. When ICP promotes an indirect call to direct call, we need to make sure the direct call is annotated with branch_weight in SamplePGO mode, so that downstream function inliner can use hot callsite heuristic. Reviewers: davidxl, eraman, xur Reviewed By: davidxl, xur Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D30282 llvm-svn: 296028
* [ICP] Fix bool conversion warning and actually write out the reason instead ↵Benjamin Kramer2017-01-301-1/+1
| | | | | | of dropping it. llvm-svn: 293564
* Expose isLegalToPromot as a global helper function so that SamplePGO pass ↵Dehao Chen2017-01-301-46/+36
| | | | | | | | | | | | | | | | can call it for legality check. Summary: SamplePGO needs to check if it is legal to promote a target before it actually promotes it. Reviewers: davidxl Reviewed By: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29306 llvm-svn: 293559
* Makes promoteIndirectCall an external function.Dehao Chen2017-01-231-17/+7
| | | | | | | | | | | | | | Summary: promoteIndirectCall should be a utility function that could be invoked by other optimization passes. Reviewers: davidxl Reviewed By: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29051 llvm-svn: 292850
* Use StringRef in Pass/PassManager APIs (NFC)Mehdi Amini2016-10-011-3/+1
| | | | llvm-svn: 283004
* Fix some Clang-tidy modernize and Include What You Use warnings.Eugene Zelenko2016-08-111-12/+22
| | | | | | Differential revision: https://reviews.llvm.org/D23291 llvm-svn: 278364
* Consistently use ModuleAnalysisManagerSean Silva2016-08-091-1/+1
| | | | | | | | | | | Besides a general consistently benefit, the extra layer of indirection allows the mechanical part of https://reviews.llvm.org/D23256 that requires touching every transformation and analysis to be factored out cleanly. Thanks to David for the suggestion. llvm-svn: 278078
* Address review comments.Teresa Johnson2016-07-171-0/+8
| | | | llvm-svn: 275706
* Refactor indirect call promotion profitability analysis (NFC)Teresa Johnson2016-07-171-8/+0
| | | | | | | | | | | | | | | Summary: Refactored the profitability analysis out of the IC promotion pass and into lib/Analysis so that it can be accessed by the summary index builder in a follow-on patch to enable IC promotion in ThinLTO (D21932). Reviewers: davidxl, xur Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D22182 llvm-svn: 275705
* Remove unused variable to fix bot failure from r275216Teresa Johnson2016-07-121-2/+1
| | | | | | | Remove unused variable added in r275216. Should fix bot failure: http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/24665 llvm-svn: 275219
* Refactor indirect call promotion profitability analysis (NFC)Teresa Johnson2016-07-121-61/+21
| | | | | | | | | | | | | | | Summary: Refactored the profitability analysis out of the IC promotion pass and into lib/Analysis so that it can be accessed by the summary index builder in a follow-on patch to enable IC promotion in ThinLTO (D21932). Reviewers: davidxl, xur Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D22182 llvm-svn: 275216
* make icall pass name consistent /NFCXinliang David Li2016-06-021-3/+3
| | | | llvm-svn: 271467
* minor cleanup /NFCXinliang David Li2016-05-171-4/+2
| | | | llvm-svn: 269839
* [PM] Port indirect call promotion pass to new pass managerXinliang David Li2016-05-161-0/+9
| | | | llvm-svn: 269660
* Move helper classes into anonymous namespaces. NFC.Benjamin Kramer2016-05-151-0/+2
| | | | llvm-svn: 269591
* Rename pass name to prepare to new PM porting /NFCXinliang David Li2016-05-151-8/+10
| | | | llvm-svn: 269586
* [IndirectCallPromotion] Remove duplicate comment. NFCAdam Nemet2016-05-091-1/+0
| | | | llvm-svn: 268986
* [PGO] Fix incorrect Twine usage in emitting optimization remarks.Rong Xu2016-04-281-9/+8
| | | | | | | Should not store Twine objects to local variables. This is fixed the test failures with r267815 in VS2015 X64 build. llvm-svn: 267908
* [PGO] Promote indirect calls to conditional direct calls with value-profileRong Xu2016-04-271-0/+693
This patch implements the transformation that promotes indirect calls to conditional direct calls when the indirect-call value profile meta-data is available. Differential Revision: http://reviews.llvm.org/D17864 llvm-svn: 267815
OpenPOWER on IntegriCloud