summaryrefslogtreecommitdiff
path: root/test/Other
AgeCommit message (Collapse)Author
2017-12-29[PM] pass -debug-pass-manager flag into FunctionToLoopPassAdaptor's ↵Fedor Sergeev
canonicalization PM Summary: New pass manager driver passes DebugPM (-debug-pass-manager) flag into individual PassManager constructors in order to enable debug logging. FunctionToLoopPassAdaptor has its own internal LoopCanonicalizationPM which never gets its debug logging enabled and that means canonicalization passes like LoopSimplify are never present in -debug-pass-manager output. Extending FunctionToLoopPassAdaptor's constructor and createFunctionToLoopPassAdaptor wrapper with an optional boolean DebugLogging argument. Passing debug-logging flags there as appropriate. Reviewers: chandlerc, davide Reviewed By: davide Subscribers: mehdi_amini, eraman, llvm-commits, JDevlieghere Differential Revision: https://reviews.llvm.org/D41586 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321548 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-18Fix more inconsistent line endings. NFC.Dimitry Andric
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321016 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-14[SimplifyCFG] don't sink common insts too soon (PR34603)Sanjay Patel
This should solve: https://bugs.llvm.org/show_bug.cgi?id=34603 ...by preventing SimplifyCFG from altering redundant instructions before early-cse has a chance to run. It changes the default (canonical-forming) behavior of SimplifyCFG, so we're only doing the sinking transform later in the optimization pipeline. Differential Revision: https://reviews.llvm.org/D38566 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320749 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-14[PM][InstCombine] fixing omission of AliasAnalysis in new-pass-manager's ↵Fedor Sergeev
version of InstCombine Summary: Passing AliasAnalysis results instead of nullptr appears to work just fine. A couple new-pass-manager tests updated to align with new order of analyses. Reviewers: chandlerc, spatel, craig.topper Reviewed By: chandlerc Subscribers: mehdi_amini, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D41203 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320687 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-01IR printing improvement for loop passes - handle -print-module-scopeFedor Sergeev
Summary: Adding support for -print-module-scope similar to how it is being done for function passes. This option causes loop-pass printer to emit a whole-module IR instead of just a loop itself. Reviewers: sanjoy, silvas, weimingz Reviewed By: sanjoy Subscribers: apilipenko, skatkov, llvm-commits Differential Revision: https://reviews.llvm.org/D40247 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319566 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-01IR printing improvement for function passes - introducing -print-module-scopeFedor Sergeev
Summary: When debugging function passes it happens to be rather useful to dump the whole module before the transformation and then use this dump to analyze this single transformation by running it separately on that particular module state. Introducing -print-module-scope debugging option that forces all the function-level IR dumps to become whole-module dumps. This option builds on top of normal dumping controls like -print-before/after -filter-print-funcs The plan is to eventually extend this option to cover other local passes (at least loop passes) but that should go as a separate change. Reviewers: sanjoy, weimingz, silvas, fedor.sergeev Reviewed By: weimingz Subscribers: apilipenko, skatkov, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D40245 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319561 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-28Add a new pass to speculate around PHI nodes with constant (integer) ↵Chandler Carruth
operands when profitable. The core idea is to (re-)introduce some redundancies where their cost is hidden by the cost of materializing immediates for constant operands of PHI nodes. When the cost of the redundancies is covered by this, avoiding materializing the immediate has numerous benefits: 1) Less register pressure 2) Potential for further folding / combining 3) Potential for more efficient instructions due to immediate operand As a motivating example, consider the remarkably different cost on x86 of a SHL instruction with an immediate operand versus a register operand. This pattern turns up surprisingly frequently, but is somewhat rarely obvious as a significant performance problem. The pass is entirely target independent, but it does rely on the target cost model in TTI to decide when to speculate things around the PHI node. I've included x86-focused tests, but any target that sets up its immediate cost model should benefit from this pass. There is probably more that can be done in this space, but the pass as-is is enough to get some important performance on our internal benchmarks, and should be generally performance neutral, but help with more extensive benchmarking is always welcome. One awkward part is that this pass has to be scheduled after *everything* that can eliminate these kinds of redundancies. This includes SimplifyCFG, GVN, etc. I'm open to suggestions about better places to put this. We could in theory make it part of the codegen pass pipeline, but there doesn't really seem to be a good reason for that -- it isn't "lowering" in any sense and only relies on pretty standard cost model based TTI queries, so it seems to fit well with the "optimization" pipeline model. Still, further thoughts on the pipeline position are welcome. I've also only implemented this in the new pass manager. If folks are very interested, I can try to add it to the old PM as well, but I didn't really see much point (my use case is already switched over to the new PM). I've tested this pretty heavily without issue. A wide range of benchmarks internally show no change outside the noise, and I don't see any significant changes in SPEC either. However, the size class computation in tcmalloc is substantially improved by this, which turns into a 2% to 4% win on the hottest path through tcmalloc for us, so there are definitely important cases where this is going to make a substantial difference. Differential revision: https://reviews.llvm.org/D37467 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319164 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-22IR printing improvement for loop passesFedor Sergeev
Summary: Loop-pass printing is somewhat deficient since it does not provide the context around the loop (e.g. preheader). This context information becomes pretty essential when analyzing transformations that move stuff out of the loop. Extending printLoop to cover preheader and exit blocks (if any). Reviewers: sanjoy, silvas, weimingz Reviewed By: sanjoy Subscribers: apilipenko, skatkov, llvm-commits Differential Revision: https://reviews.llvm.org/D40246 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318878 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-16Let llvm.invariant.group.barrier accepts pointer to any address spaceYaxun Liu
llvm.invariant.group.barrier may accept pointers to arbitrary address space. This patch let it accept pointers to i8 in any address space and returns pointer to i8 in the same address space. Differential Revision: https://reviews.llvm.org/D39973 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318413 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03Recommit r317351 : Add CallSiteSplitting passJun Bum Lim
This recommit r317351 after fixing a buildbot failure. Original commit message: Summary: This change add a pass which tries to split a call-site to pass more constrained arguments if its argument is predicated in the control flow so that we can expose better context to the later passes (e.g, inliner, jump threading, or IPA-CP based function cloning, etc.). As of now we support two cases : 1) If a call site is dominated by an OR condition and if any of its arguments are predicated on this OR condition, try to split the condition with more constrained arguments. For example, in the code below, we try to split the call site since we can predicate the argument (ptr) based on the OR condition. Split from : if (!ptr || c) callee(ptr); to : if (!ptr) callee(null ptr) // set the known constant value else if (c) callee(nonnull ptr) // set non-null attribute in the argument 2) We can also split a call-site based on constant incoming values of a PHI For example, from : BB0: %c = icmp eq i32 %i1, %i2 br i1 %c, label %BB2, label %BB1 BB1: br label %BB2 BB2: %p = phi i32 [ 0, %BB0 ], [ 1, %BB1 ] call void @bar(i32 %p) to BB0: %c = icmp eq i32 %i1, %i2 br i1 %c, label %BB2-split0, label %BB1 BB1: br label %BB2-split1 BB2-split0: call void @bar(i32 0) br label %BB2 BB2-split1: call void @bar(i32 1) br label %BB2 BB2: %p = phi i32 [ 0, %BB2-split0 ], [ 1, %BB2-split1 ] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317362 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03Revert "Add CallSiteSplitting pass"Jun Bum Lim
Revert due to Buildbot failure. This reverts commit r317351. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317353 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03Add CallSiteSplitting passJun Bum Lim
Summary: This change add a pass which tries to split a call-site to pass more constrained arguments if its argument is predicated in the control flow so that we can expose better context to the later passes (e.g, inliner, jump threading, or IPA-CP based function cloning, etc.). As of now we support two cases : 1) If a call site is dominated by an OR condition and if any of its arguments are predicated on this OR condition, try to split the condition with more constrained arguments. For example, in the code below, we try to split the call site since we can predicate the argument (ptr) based on the OR condition. Split from : if (!ptr || c) callee(ptr); to : if (!ptr) callee(null ptr) // set the known constant value else if (c) callee(nonnull ptr) // set non-null attribute in the argument 2) We can also split a call-site based on constant incoming values of a PHI For example, from : BB0: %c = icmp eq i32 %i1, %i2 br i1 %c, label %BB2, label %BB1 BB1: br label %BB2 BB2: %p = phi i32 [ 0, %BB0 ], [ 1, %BB1 ] call void @bar(i32 %p) to BB0: %c = icmp eq i32 %i1, %i2 br i1 %c, label %BB2-split0, label %BB1 BB1: br label %BB2-split1 BB2-split0: call void @bar(i32 0) br label %BB2 BB2-split1: call void @bar(i32 1) br label %BB2 BB2: %p = phi i32 [ 0, %BB2-split0 ], [ 1, %BB2-split1 ] Reviewers: davidxl, huntergr, chandlerc, mcrosier, eraman, davide Reviewed By: davidxl Subscribers: sdesmalen, ashutosh.nema, fhahn, mssimpso, aemerson, mgorny, mehdi_amini, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D39137 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317351 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-25Add CalledValuePropagation passMatthew Simpson
This patch adds a new pass for attaching !callees metadata to indirect call sites. The pass propagates values to call sites by performing an IPSCCP-like analysis using the generic sparse propagation solver. For indirect call sites having a small set of possible callees, the attached metadata indicates what those callees are. The metadata can be used to facilitate optimizations like intersecting the function attributes of the possible callees, refining the call graph, performing indirect call promotion, etc. Differential Revision: https://reviews.llvm.org/D37355 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316576 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-23[PM] Add pgo-memop-opt pass to the new pass managerRong Xu
This pass adds pgo-memop-opt pass to the new pass manager. It is in the old pass manager but somehow left out in the new pass manager. Differential Revision: http://reviews.llvm.org/D39145 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316384 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-05[NewPassManager] Run global dead code elimination after the inliner.Davide Italiano
This is the same exact change we did for the current pass manager in rL314997, but the new pass manager pipeline already happened to run GlobalOpt after the inliner, so we just insert a run of GDCE here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315003 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-05[PassManager] Improve the interaction between -O2 and ThinLTO.Davide Italiano
Run GDCE slightly later so that we don't have to repeat it twice when preparing for Thin. Thanks to Mehdi for the suggestion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314999 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-05[PassManager] Run global optimizations after the inliner.Davide Italiano
The inliner performs some kind of dead code elimination as it goes, but there are cases that are not really caught by it. We might at some point consider teaching the inliner about them, but it is OK for now to run GlobalOpt + GlobalDCE in tandem as their benefits generally outweight the cost, making the whole pipeline faster. This fixes PR34652. Differential Revision: https://reviews.llvm.org/D38154 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314997 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-04Do not call Loop::getName on possibly dead loopsSanjoy Das
This fixes PR34832. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314938 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-14[PM/CGSCC] Teach the CGSCC pass manager components to gracefully handleChandler Carruth
invalidated SCCs even when we do not have an updated SCC to redirect towards. This comes up in a fairly subtle and surprising circumstance: we need to have a connected but internal node in the call graph which later becomes a disconnected island, and then gets deleted. All of this needs to happen mid-CGSCC walk. Because it is disconnected, we have no way of computing a new "current" SCC when it gets deleted. Instead, we need to explicitly check for a deleted "current" SCC and bail out of the current CGSCC step. This will bubble all the way up to the post-order walk and then resume correctly. I've included minimal tests for this bug. The specific behavior matches something we've seen in the wild with the new PM combined with ThinLTO and sample PGO, but I've not yet confirmed whether this is the only issue there. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313242 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-09Merge isKnownNonNull into isKnownNonZeroNuno Lopes
It now knows the tricks of both functions. Also, fix a bug that considered allocas of non-zero address space to be always non null Differential Revision: https://reviews.llvm.org/D37628 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312869 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-09[DivRempairs] add a pass to optimize div/rem pairs (PR31028)Sanjay Patel
This is intended to be a superset of the functionality from D31037 (EarlyCSE) but implemented as an independent pass, so there's no stretching of scope and feature creep for an existing pass. I also proposed a weaker version of this for SimplifyCFG in D30910. And I initially had almost this same functionality as an addition to CGP in the motivating example of PR31028: https://bugs.llvm.org/show_bug.cgi?id=31028 The advantage of positioning this ahead of SimplifyCFG in the pass pipeline is that it can allow more flattening. But it needs to be after passes (InstCombine) that could sink a div/rem and undo the hoisting that is done here. Decomposing remainder may allow removing some code from the backend (PPC and possibly others). Differential Revision: https://reviews.llvm.org/D37121 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312862 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-19revert failing testVictor Leschuk
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311238 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-19Add temporary test to verify that win10 builder hangs on errorVictor Leschuk
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311236 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-15[llvm] Get rid of "%T" expansionsKuba Mracek
The %T lit expansion expands to a common directory shared between all the tests in the same directory, which is unexpected and unintuitive, and more importantly, it's been a source of subtle race conditions and flaky tests. In https://reviews.llvm.org/D35396, it was agreed that it would be best to simply ban %T and only keep %t, which is unique to each test. When a test needs a temporary directory, it can just create one using mkdir %t. This patch removes %T in llvm. Differential Revision: https://reviews.llvm.org/D36495 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310953 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-11[PM] Switch the CGSCC debug messages to use the standard LLVM debugChandler Carruth
printing techniques with a DEBUG_TYPE controlling them. It was a mistake to start re-purposing the pass manager `DebugLogging` variable for generic debug printing -- those logs are intended to be very minimal and primarily used for testing. More detailed and comprehensive logging doesn't make sense there (it would only make for brittle tests). Moreover, we kept forgetting to propagate the `DebugLogging` variable to various places making it also ineffective and/or unavailable. Switching to `DEBUG_TYPE` makes this a non-issue. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310695 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-10Revert part of r310296 to make it really NFC for instrumentation PGO.Dehao Chen
Summary: Part of r310296 will disable PGOIndirectCallPromotion in ThinLTO backend if PGOOpt is None. However, as PGOOpt is not passed down to ThinLTO backend for instrumentation based PGO, that change would actually disable ICP entirely in ThinLTO backend, making it behave differently in instrumentation PGO mode. This change reverts that change, and only disable ICP there when it is SamplePGO. Reviewers: davidxl Reviewed By: davidxl Subscribers: sanjoy, mehdi_amini, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D36566 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310550 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-08Make ICP uses PSI to check for hotness.Dehao Chen
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310416 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-08[PM] Fix a likely more critical infloop bug in the CGSCC pass manager.Chandler Carruth
This was just a bad oversight on my part. The code in question should never have worked without this fix. But it turns out, there are relatively few places that involve libfunctions that participate in a single SCC, and unless they do, this happens to not matter. The effect of not having this correct is that each time through this routine, the edge from write_wrapper to write was toggled between a call edge and a ref edge. First time through, it becomes a demoted call edge and is turned into a ref edge. Next time it is a promoted call edge from a ref edge. On, and on it goes forever. I've added the asserts which should have always been here to catch silly mistakes like this in the future as well as a test case that will actually infloop without the fix. The other (much scarier) infinite-inlining issue I think didn't actually occur in practice, and I simply misdiagnosed this minor issue as that much more scary issue. The other issue *is* still a real issue, but I'm somewhat relieved that so far it hasn't happened in real-world code yet... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310342 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-07Move the SampleProfileLoader right after EarlyFPM.Dehao Chen
Summary: SampleProfileLoader pass do need to happen after some early cleanup passes so that inlining can happen correctly inside the SampleProfileLoader pass. Reviewers: chandlerc, davidxl, tejohnson Reviewed By: chandlerc, tejohnson Subscribers: sanjoy, mehdi_amini, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D36333 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310296 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-03Use profile summary to disable peeling for huge working setsTeresa Johnson
Summary: Detect when the working set size of a profiled application is huge, by comparing the number of counts required to reach the hot percentile in the profile summary to a large threshold*. When the working set size is determined to be huge, disable peeling to avoid bloating the working set further. *Note that the selected threshold (15K) is significantly larger than the largest working set value in SPEC cpu2006 (which is gcc at around 11K). Reviewers: davidxl Subscribers: mehdi_amini, mzolotukhin, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D36288 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310005 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-02[PM] Split LoopUnrollPass and make partial unroller a function passTeresa Johnson
Summary: This is largely NFC*, in preparation for utilizing ProfileSummaryInfo and BranchFrequencyInfo analyses. In this patch I am only doing the splitting for the New PM, but I can do the same for the legacy PM as a follow-on if this looks good. *Not NFC since for partial unrolling we lose the updates done to the loop traversal (adding new sibling and child loops) - according to Chandler this is not very useful for partial unrolling, but it also means that the debugging flag -unroll-revisit-child-loops no longer works for partial unrolling. Reviewers: chandlerc Subscribers: mehdi_amini, mzolotukhin, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D36157 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309886 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29Update the test to make windows bot pass.Dehao Chen
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309482 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29update the test file that was omitted in r309478.Dehao Chen
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309479 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29Refine the PGOOpt and SamplePGOSupport handling.Dehao Chen
Summary: Now that SamplePGOSupport is part of PGOOpt, there are several places that need tweaking: 1. AddDiscriminator pass should *not* be invoked at ThinLTOBackend (as it's already invoked in the PreLink phase) 2. addPGOInstrPasses should only be invoked when either ProfileGenFile or ProfileUseFile is non-empty. 3. SampleProfileLoaderPass should only be invoked when SampleProfileFile is non-empty. 4. PGOIndirectCallPromotion should only be invoked in ProfileUse phase, or in ThinLTOBackend of SamplePGO. Reviewers: chandlerc, tejohnson, davidxl Reviewed By: chandlerc Subscribers: sanjoy, mehdi_amini, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D36040 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309478 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-27Relax the matching in these testsAdam Nemet
Looks like the template arguments are displayed differently depending on the host compiler(?). E.g.: InnerAnalysisManagerProxy<CGSCCAnalysisManager InnerAnalysisManagerProxy<llvm::AnalysisManager<llvm::LazyCallGraph::SCC, ... Fix fallout after r309294 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309297 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-27[ICP] Migrate to OptimizationRemarkEmitterAdam Nemet
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309294 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-26Migrate SimplifyLibCalls to new OptimizationRemarkEmitterAdam Nemet
Summary: This changes SimplifyLibCalls to use the new OptimizationRemarkEmitter API. In fact, as SimplifyLibCalls is only ever called via InstCombine, (as far as I can tell) the OptimizationRemarkEmitter is added there, and then passed through to SimplifyLibCalls later. I have avoided changing any remark text. This closes PR33787 Patch by Sam Elliott! Reviewers: anemet, davide Reviewed By: anemet Subscribers: davide, mehdi_amini, eraman, fhahn, llvm-commits Differential Revision: https://reviews.llvm.org/D35608 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309158 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-26Make new PM honor -fdebug-info-for-profilingDehao Chen
Summary: The new PM needs to invoke add-discriminator pass when building with -fdebug-info-for-profiling. Reviewers: chandlerc, davidxl Reviewed By: chandlerc Subscribers: sanjoy, llvm-commits Differential Revision: https://reviews.llvm.org/D35744 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309121 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-26Add test coverage for new PM PGOOpt handling.Dehao Chen
Summary: This patch adds flags and tests to cover the PGOOpt handling logic in new PM. Reviewers: chandlerc, davide Reviewed By: chandlerc Subscribers: sanjoy, llvm-commits Differential Revision: https://reviews.llvm.org/D35807 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309076 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-19[TRE] Move to the new OptRemark API.Davide Italiano
Fixes PR33788. Differential Revision: https://reviews.llvm.org/D35570 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308524 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-19[PM/LCG] Follow-up fix to r308088 to handle deletion of libraryChandler Carruth
functions. In the prior commit, we provide ordering to the LCG between functions and library function definitions that they might begin to call through transformations. But we still would delete these library functions from the call graph if they became dead during inlining. While this immediately crashed, it also exposed a loss of information. We shouldn't remove definitions of library functions that can still usefully participate in the LCG-powered CGSCC optimization process. If new call edges are formed, we want to have definitions to be called. We can still remove these functions if truly dead using global-dce, etc, but removing them during the CGSCC walk is premature. This fixes a crash in the new PM when optimizing some unusual libraries that end up with "internal" lib functions such as the code in the "R" language's libraries. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308417 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-15[PM/LCG] Teach the LazyCallGraph to maintain reference edges from everyChandler Carruth
function to every defined function known to LLVM as a library function. LLVM can introduce calls to these functions either by replacing other library calls or by recognizing patterns (such as memset_pattern or vector math patterns) and replacing those with calls. When these library functions are actually defined in the module, we need to have reference edges to them initially so that we visit them during the CGSCC walk in the right order and can effectively rebuild the call graph afterward. This was discovered when building code with Fortify enabled as that is a common case of both inline definitions of library calls and simplifications of code into calling them. This can in extreme cases of LTO-ing with libc introduce *many* more reference edges. I discussed a bunch of different options with folks but all of them are unsatisfying. They either make the graph operations substantially more complex even when there are *no* defined libfuncs, or they introduce some other complexity into the callgraph. So this patch goes with the simplest possible solution of actual synthetic reference edges. If this proves to be a memory problem, I'm happy to implement one of the clever techniques to save memory here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308088 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-12Make shell redirection construct portableKamil Rytarowski
Summary: NetBSD shell sh(1) does not support ">& /dev/null" construct. This is bashism. The portable and POSIX solution is to use: "> /dev/null 2>&1". This change fixes 22 Unexpected Failures on NetBSD/amd64 for the "check-llvm" target. Sponsored by <The NetBSD Foundation> Reviewers: joerg, dim, rnk Reviewed By: joerg, rnk Subscribers: rnk, davide, llvm-commits Differential Revision: https://reviews.llvm.org/D35277 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307789 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-11fix typos in comments; NFCHiroshi Inoue
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307626 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-10[PM] Enable registration of out-of-tree passes with PassBuilderPhilip Pfaffe
Summary: This patch adds a callback registration API to the PassBuilder, enabling registering out-of-tree passes with it. Through the Callback API, callers may register callbacks with the various stages at which passes are added into pass managers, including parsing of a pass pipeline as well as at extension points within the default -O pipelines. Registering utilities like `require<>` and `invalidate<>` needs to be handled manually by the caller, but a helper is provided. Additionally, adding passes at pipeline extension points is exposed through the opt tool. This patch adds a `-passes-ep-X` commandline option for every extension point X, which opt parses into pipelines inserted into that extension point. Reviewers: chandlerc Reviewed By: chandlerc Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D33464 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307532 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-30Revert "[lit] Clean output directories before running tests."Zachary Turner
This reverts commit da6318a92fba793e4f2447ec478b001392d57d43. This is causing failures on some build bots due to what appears to be some kind of lit ordering dependency. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306833 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-30[lit] Clean output directories before running tests.Zachary Turner
Presently lit leaks files in the tests' output directories. Specifically, if a test creates output files, lit makes no effort to remove them prior to the next test run. This is problematic because it leads to false positives whenever a test passes because stale files were present. In general it is a source of flakiness that should be removed. This patch addresses this by building the list of all test directories that are part of the current run set, and then deleting those directories and recreating them anew. This gives each test a clean baseline to start from. Differential Revision: https://reviews.llvm.org/D34732 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306832 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-29[ThinkLTO] Invoke build(Thin)?LTOPreLinkDefaultPipeline.Tim Shen
Previously it doesn't actually invoke the designated new PM builder functions. This patch moves NameAnonGlobalPass out from PassBuilder, as Chandler points out that PassBuilder is used for non-O0 builds, and for optimizations only. Differential Revision: https://reviews.llvm.org/D34728 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306756 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-27[EarlyCSE][MemorySSA] Enable MemorySSA in function-simplification pass of ↵Geoff Berry
EarlyCSE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306477 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-01[PM/ThinLTO] Port the ThinLTO pipeline (both components) to the new PM.Chandler Carruth
Based on the original patch by Davide, but I've adjusted the API exposed to just be different entry points rather than exposing more state parameters. I've factored all the common logic out so that we don't have any duplicate pipelines, we just stitch them together in different ways. I think this makes the build easier to reason about and understand. This adds a direct method for getting the module simplification pipeline as well as a method to get the optimization pipeline. While not my express goal, this seems nice and gives a good place comment about the restrictions that are imposed on them. I did make some minor changes to the way the pipelines are structured here, but hopefully not ones that are significant or controversial: 1) I sunk the PGO indirect call promotion to only be run when we have PGO enabled (or as part of the special ThinLTO pipeline). 2) I made the extra GlobalOpt run in ThinLTO just happen all the time and at a slightly more powerful place (before we remove available externaly functions). This seems like general goodness and not a big compile time sink, so it didn't make sense to *only* use it in ThinLTO. Fewer differences in the pipeline makes everything simpler IMO. 3) I hoisted the ThinLTO stop point pre-link above the the RPO function attr inference. The RPO inference won't infer anything terribly meaningful pre-link (recursiveness?) so it didn't make a lot of sense. But if the placement of RPO inference starts to matter, we should move it to the canonicalization phase anyways which seems like a better place for it (and there is a FIXME to this effect!). But that seemed a bridge too far for this patch. If we ever need to parameterize these pipelines more heavily, we can always sink the logic to helper functions with parameters to keep those parameters out of the public API. But the changes above seemed minor that we could possible get away without the parameters entirely. I added support for parsing 'thinlto' and 'thinlto-pre-link' names in pass pipelines to make it easy to test these routines and play with them in larger pipelines. I also added a really basic manifest of passes test that will show exactly how the pipelines behave and work as well as making updates to them clear. Lastly, this factoring does introduce a nesting layer of module pass managers in the default pipeline. I don't think this is a big deal and the flexibility of decoupling the pipelines seems easily worth it. Differential Revision: https://reviews.llvm.org/D33540 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304407 91177308-0d34-0410-b5e6-96231b3b80d8