aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/BranchFolding.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-04-22Re-commit optimization bisect support (r267022) without new pass manager ↵Andrew Kaylor1-1/+1
support. The original commit was reverted because of a buildbot problem with LazyCallGraph::SCC handling (not related to the OptBisect handling). Differential Revision: http://reviews.llvm.org/D19172 llvm-svn: 267231
2016-04-22Revert "Initial implementation of optimization bisect support."Vedant Kumar1-1/+1
This reverts commit r267022, due to an ASan failure: http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/1549 llvm-svn: 267115
2016-04-21Initial implementation of optimization bisect support.Andrew Kaylor1-1/+1
This patch implements a optimization bisect feature, which will allow optimizations to be selectively disabled at compile time in order to track down test failures that are caused by incorrect optimizations. The bisection is enabled using a new command line option (-opt-bisect-limit). Individual passes that may be skipped call the OptBisect object (via an LLVMContext) to see if they should be skipped based on the bisect limit. A finer level of control (disabling individual transformations) can be managed through an addition OptBisect method, but this is not yet used. The skip checking in this implementation is based on (and replaces) the skipOptnoneFunction check. Where that check was being called, a new call has been inserted in its place which checks the bisect limit and the optnone attribute. A new function call has been added for module and SCC passes that behaves in a similar way. Differential Revision: http://reviews.llvm.org/D19172 llvm-svn: 267022
2016-04-06RegisterScavenger: Take a reference as enterBasicBlock() argument.Matthias Braun1-1/+1
Make it obvious that the argument cannot be nullptr. Remove an unnecessary nullptr check in initRegState. llvm-svn: 265511
2016-03-31Don't use potentially invalidated iteratorStephan Bergmann1-2/+4
If the lhs is evaluated before the rhs, FuncletI's operator-> can trigger the assert(isHandleInSync() && "invalid iterator access!"); at include/llvm/ADT/DenseMap.h:1061. (Happens e.g. when compiled with GCC 6.) Differential Revision: http://reviews.llvm.org/D18440 llvm-svn: 265024
2016-03-10Test commit accessMarianne Mailhot-Sarrasin1-1/+1
llvm-svn: 263165
2016-03-03[BranchFolding] Change function name related with merging MMOs. NFCJunmo Park1-7/+5
Summary: Removing MMOs is not our prefer behavior any more. Reviewers: mcrosier, reames Differential Revision: http://reviews.llvm.org/D17668 llvm-svn: 262580
2016-02-27CodeGen: Remove an iterator => pointer conversion, NFCDuncan P. N. Exon Smith1-2/+2
Part of PR26753. llvm-svn: 262154
2016-02-27CodeGen: Change MachineInstr to use MachineInstr&, NFCDuncan P. N. Exon Smith1-4/+4
Change MachineInstr API to prefer MachineInstr& over MachineInstr* whenever the parameter is expected to be non-null. Slowly inching toward being able to fix PR26753. llvm-svn: 262149
2016-02-27CodeGen: Use MachineInstr& in HashMachineInstr, NFCDuncan P. N. Exon Smith1-10/+10
Also update HashEndOfMBB to take MachineBasicBlock&. llvm-svn: 262146
2016-02-23CodeGen: TII: Take MachineInstr& in predicate API, NFCDuncan P. N. Exon Smith1-4/+4
Change TargetInstrInfo API to take `MachineInstr&` instead of `MachineInstr*` in the functions related to predicated instructions (I'll try to come back later and get some of the rest). All of these functions require non-null parameters already, so references are more clear. As a bonus, this happens to factor away a host of implicit iterator => pointer conversions. No functionality change intended. llvm-svn: 261605
2016-01-11[BranchFolding] Set correct mem refs (2nd try)Junmo Park1-1/+1
This is a recommit of r257253 which was reverted in r257270. Previous testcase can make failure on some targets due to using opt with O3 option. Original Summary: Merge MBBICommon and MBBI's MMOs. Differential Revision: http://reviews.llvm.org/D15990 llvm-svn: 257317
2016-01-09Revert "[BranchFolding] Set correct mem refs"Michael Zolotukhin1-1/+1
This reverts commit 1ff11017d2669b933b29fcbb6451cfcda34ad693. llvm-svn: 257270
2016-01-09[BranchFolding] Set correct mem refsJunmo Park1-1/+1
Merge MBBICommon and MBBI's MMOs. Differential Revision: http://reviews.llvm.org/D15990 llvm-svn: 257253
2016-01-06Consolidate MemRefs handling from BranchFolding and correct latent bugPhilip Reames1-14/+1
Move the logic from BranchFolding to use the shared infrastructure for merging MMOs introduced in 256909. This has the effect of making BranchFolding more capable. In the process, fix a latent bug. The existing handling for merging didn't handle the case where one of the instructions being merged had overflowed and dropped MemRefs. This was a latent bug in the places the code was commoned from, but potentially reachable in BranchFolding. Once this is in, we're left with a single place to consider implementing MMO unique-ing as proposed in http://reviews.llvm.org/D15230. Differential Revision: http://reviews.llvm.org/D15913 llvm-svn: 256966
2015-12-23[MemOperands] Clarify code around dropping memory operands [NFC]Philip Reames1-1/+1
Clarify a comment about what it means to drop memory operands from an instruction. While I'm adding change the name of the method slightly to make it a bit more clear what's going on when reading calling code. llvm-svn: 256346
2015-12-04Revert "[BranchFolding] Merge MMOs during tail merge"Rafael Espindola1-26/+16
This reverts commit r254694. It broke bootstrap. llvm-svn: 254700
2015-12-04[BranchFolding] Merge MMOs during tail mergeJunmo Park1-16/+26
Summary: If we remove the MMOs from Load/Store instructions, they are treated as volatile. This makes other optimization passes unhappy. eg. Load/Store Optimization So, it looks better to merge, not remove. Reviewers: gberry, mcrosier Subscribers: gberry, llvm-commits Differential Revision: http://reviews.llvm.org/D14797 llvm-svn: 254694
2015-12-04(no commit message)Junmo Park1-1/+1
llvm-svn: 254686
2015-12-03[WinEH] Avoid infinite loop in BranchFolding for multiple single block funcletsAndrew Kaylor1-0/+8
Differential Revision: http://reviews.llvm.org/D14996 llvm-svn: 254629
2015-12-01Replace all weight-based interfaces in MBB with probability-based ↵Cong Hou1-5/+11
interfaces, and update all uses of old interfaces. (This is the second attempt to submit this patch. The first caused two assertion failures and was reverted. See https://llvm.org/bugs/show_bug.cgi?id=25687) The patch in http://reviews.llvm.org/D13745 is broken into four parts: 1. New interfaces without functional changes (http://reviews.llvm.org/D13908). 2. Use new interfaces in SelectionDAG, while in other passes treat probabilities as weights (http://reviews.llvm.org/D14361). 3. Use new interfaces in all other passes. 4. Remove old interfaces. This patch is 3+4 above. In this patch, MBB won't provide weight-based interfaces any more, which are totally replaced by probability-based ones. The interface addSuccessor() is redesigned so that the default probability is unknown. We allow unknown probabilities but don't allow using it together with known probabilities in successor list. That is to say, we either have a list of successors with all known probabilities, or all unknown probabilities. In the latter case, we assume each successor has 1/N probability where N is the number of successors. An assertion checks if the user is attempting to add a successor with the disallowed mixed use as stated above. This can help us catch many misuses. All uses of weight-based interfaces are now updated to use probability-based ones. Differential revision: http://reviews.llvm.org/D14973 llvm-svn: 254377
2015-12-01Revert r254348: "Replace all weight-based interfaces in MBB with ↵Hans Wennborg1-6/+3
probability-based interfaces, and update all uses of old interfaces." and the follow-up r254356: "Fix a bug in MachineBlockPlacement that may cause assertion failure during BranchProbability construction." Asserts were firing in Chromium builds. See PR25687. llvm-svn: 254366
2015-12-01Replace all weight-based interfaces in MBB with probability-based ↵Cong Hou1-3/+6
interfaces, and update all uses of old interfaces. The patch in http://reviews.llvm.org/D13745 is broken into four parts: 1. New interfaces without functional changes (http://reviews.llvm.org/D13908). 2. Use new interfaces in SelectionDAG, while in other passes treat probabilities as weights (http://reviews.llvm.org/D14361). 3. Use new interfaces in all other passes. 4. Remove old interfaces. This patch is 3+4 above. In this patch, MBB won't provide weight-based interfaces any more, which are totally replaced by probability-based ones. The interface addSuccessor() is redesigned so that the default probability is unknown. We allow unknown probabilities but don't allow using it together with known probabilities in successor list. That is to say, we either have a list of successors with all known probabilities, or all unknown probabilities. In the latter case, we assume each successor has 1/N probability where N is the number of successors. An assertion checks if the user is attempting to add a successor with the disallowed mixed use as stated above. This can help us catch many misuses. All uses of weight-based interfaces are now updated to use probability-based ones. Differential revision: http://reviews.llvm.org/D14973 llvm-svn: 254348
2015-11-11[WinEH] Don't forward branches across empty EH pad BBsReid Kleckner1-1/+1
For really simple SEH catchpads, we tried to forward the invoke unwind edge across the empty block. llvm-svn: 252822
2015-10-24Refactor: Simplify boolean conditional return statements in lib/CodeGen.Rafael Espindola1-5/+2
Patch by Richard. llvm-svn: 251213
2015-10-09CodeGen: Remove implicit conversions from Analysis and BranchFoldingDuncan P. N. Exon Smith1-24/+25
Remove a few more implicit ilist iterator conversions, this time from Analysis.cpp and BranchFolding.cpp. I added a few overloads for `remove()` and `erase()`, which quite naturally take pointers as well as iterators as parameters. This will reduce the churn at least in the short term, but I don't really have a problem with these existing for longer. llvm-svn: 249867
2015-10-04[WinEH] Permit branch folding in the face of funcletsDavid Majnemer1-13/+45
Track which basic blocks belong to which funclets. Permit branch folding to fire but only if it can prove that doing so will not cause code in one funclet to be reused in another. llvm-svn: 249257
2015-10-01[WinEH] Stop BranchFolding from merging across funcletsDavid Majnemer1-2/+4
BranchFolding would merge two funclets together, this is not OK. Disable this and strengthen the assertion in FuncletLayout. llvm-svn: 249069
2015-09-17[WinEH] Add and use hasEHPadSuccessor instead of getLandingPadSuccessorReid Kleckner1-1/+1
getLandingPadSuccessor assumes that each invoke can have at most one EH pad successor, but WinEH invokes can have more than one. Two out of three callers of getLandingPadSuccessor don't use the returned landingpad, so we can make them use this simple predicate instead. Eventually we'll have to circle back and fix SplitKit.cpp so that register allocation works. Baby steps. llvm-svn: 247904
2015-09-16Use range-based for loops. NFCCraig Topper1-47/+31
llvm-svn: 247772
2015-08-27[WinEH] Add some support for code generating catchpadReid Kleckner1-6/+6
We can now run 32-bit programs with empty catch bodies. The next step is to change PEI so that we get funclet prologues and epilogues. llvm-svn: 246235
2015-08-10fix minsize detection: minsize attribute implies optimizing for sizeSanjay Patel1-3/+1
llvm-svn: 244528
2015-08-04wrap OptSize and MinSize attributes for easier and consistent access (NFCI)Sanjay Patel1-0/+1
Create wrapper methods in the Function class for the OptimizeForSize and MinSize attributes. We want to hide the logic of "or'ing" them together when optimizing just for size (-Os). Currently, we are not consistent about this and rely on a front-end to always set OptimizeForSize (-Os) if MinSize (-Oz) is on. Thus, there are 18 FIXME changes here that should be added as follow-on patches with regression tests. This patch is NFC-intended: it just replaces existing direct accesses of the attributes by the equivalent wrapper call. Differential Revision: http://reviews.llvm.org/D11734 llvm-svn: 243994
2015-07-29Roll forward r242871Jingyue Wu1-18/+35
r242871 missed one place that should be guarded with isPhysicalReg. This patch fixes that. llvm-svn: 243555
2015-07-29Temporarily revert r242871Jingyue Wu1-28/+15
PR24299 llvm-svn: 243522
2015-07-22[BranchFolding] do not iterate the aliases of virtual registersJingyue Wu1-15/+28
Summary: MCRegAliasIterator only works for physical registers. So, do not run it on virtual registers. With this issue fixed, we can resurrect the BranchFolding pass in NVPTX backend. Reviewers: jholewinski, bkramer Subscribers: henryhu, meheff, llvm-commits, jholewinski Differential Revision: http://reviews.llvm.org/D11174 llvm-svn: 242871
2015-06-23[BranchFolding] Document why replacing HashMachineInstr with hash_code ↵Benjamin Kramer1-1/+3
doesn't work llvm-svn: 240415
2015-06-23[MachineBasicBlock] Add getFirstNonDebugInstr to complement getLastNonDebugInstrBenjamin Kramer1-57/+18
Use it in CodeGen where applicable. No functionality change intended. llvm-svn: 240414
2015-06-23Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko1-1/+1
Apparently, the style needs to be agreed upon first. llvm-svn: 240390
2015-06-20Reformat.NAKAMURA Takumi1-7/+12
llvm-svn: 240213
2015-06-20Revert r240040, "[BranchFolding] Replace custom MachineInstr with ↵NAKAMURA Takumi1-6/+46
MachineInstrExpressionTrait" It caused different emission between stage2 and stage3. Investigating. llvm-svn: 240212
2015-06-19Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-1/+1
The patch is generated using this command: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ llvm/lib/ Thanks to Eugene Kosov for the original patch! llvm-svn: 240137
2015-06-18[BranchFolding] Replace custom MachineInstr with MachineInstrExpressionTraitBenjamin Kramer1-46/+6
While the hash functions are subtly different it shouldn't have an impact. Instructions are checked with isIdenticalTo later. llvm-svn: 240040
2015-05-19MachineInstr: Remove unused parameter.Matthias Braun1-3/+2
llvm-svn: 237726
2015-04-30Don't rewrite jumps to empty BBs to landing pads.Pete Cooper1-0/+5
In the test case here, the 'unreachable' BB was removed by BranchFolding because its empty. It then rewrote the jump from 'entry' to jump to its fallthrough, which was a landing pad. This results in 'entry' jumping to 2 different landing pads, which fails the machine verifier. rdar://problem/20750162 llvm-svn: 236248
2015-03-13BranchFolding: MergePotentialsElt has a total order, just call array_pod_sort.Benjamin Kramer1-1/+1
No functionality change intended. llvm-svn: 232217
2015-03-10Don't evaluate rend() on every iteration of the loop.Chad Rosier1-1/+3
llvm-svn: 231837
2015-03-10[BranchFolding] Remove MMOs during tail merge to preserve dependencies.Chad Rosier1-0/+57
When tail merging it may be necessary to remove MMOs from memory operations to ensures later passes (e.g., MI sched) conservatively compute dependencies. Currently, we only remove the MMO from the common tail if the MMO doesn't match with the relative instruction in the non-common tail(s). A more robust solution would be to add multiple MMOs from the duplicate MIs to the new MI. Currently ScheduleDAGInstrs.cpp ignores all MMOs on instructions with multiple MMOs, so this solution is equivalent for the time being. No test case included as this is incredibly difficult to reproduce. Patch was a collaborative effort between Ana Pazos and myself. Phabricator: http://reviews.llvm.org/D7769 llvm-svn: 231799
2015-02-14CodeGen: Canonicalize access to function attributes, NFCDuncan P. N. Exon Smith1-2/+1
Canonicalize access to function attributes to use the simpler API. getAttributes().getAttribute(AttributeSet::FunctionIndex, Kind) => getFnAttribute(Kind) getAttributes().hasAttribute(AttributeSet::FunctionIndex, Kind) => hasFnAttribute(Kind) Also, add `Function::getFnStackAlignment()`, and canonicalize: getAttributes().getStackAlignment(AttributeSet::FunctionIndex) => getFnStackAlignment() llvm-svn: 229208
2014-11-19Update SetVector to rely on the underlying set's insert to return a ↵David Blaikie1-1/+1
pair<iterator, bool> This is to be consistent with StringSet and ultimately with the standard library's associative container insert function. This lead to updating SmallSet::insert to return pair<iterator, bool>, and then to update SmallPtrSet::insert to return pair<iterator, bool>, and then to update all the existing users of those functions... llvm-svn: 222334