aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
AgeCommit message (Collapse)AuthorFilesLines
2015-07-29Reverting r243386 because it has serious post-commit concerns that have not ↵Aaron Ballman1-0/+5
been addressed. Also reverts r243389, which relied on this commit. llvm-svn: 243527
2015-07-28Changes for MachineBasicBlock to use SortedVector for LiveIns.Puyan Lotfi1-5/+0
llvm-svn: 243389
2015-06-26CodeGen: Push the ModuleSlotTracker through MachineOperandsDuncan P. N. Exon Smith1-1/+1
Push `ModuleSlotTracker` through `MachineOperand`s, dropping the time for `llc -print-machineinstrs` on the testcase in PR23865 from ~13 seconds to ~9 seconds. Now `SlotTracker::processFunctionMetadata()` accounts for only 8% of the runtime, which seems reasonable. llvm-svn: 240845
2015-06-26CodeGen: Use a single SlotTracker in MachineFunction::print()Duncan P. N. Exon Smith1-1/+16
Expose enough of the IR-level `SlotTracker` so that `MachineFunction::print()` can use a single one for printing `BasicBlock`s. Next step would be to lift this through a few more APIs so that we can make other print methods faster. Fixes PR23865, changing the runtime of `llc -print-machineinstrs` from many minutes (killed after 3 minutes, but it wasn't very close) to 13 seconds for a 502185 line dump. llvm-svn: 240842
2015-06-23[MachineBasicBlock] Add getFirstNonDebugInstr to complement getLastNonDebugInstrBenjamin Kramer1-0/+8
Use it in CodeGen where applicable. No functionality change intended. llvm-svn: 240414
2015-06-23[MachineBasicBlock] Use the const_cast(this) trick to reduce duplicationBenjamin Kramer1-25/+0
NFC. llvm-svn: 240413
2015-05-27MachineBasicBlock: Cleanup computeRegisterLiveness()Matthias Braun1-16/+14
- Clean documentation comment - Change the API to accept an iterator so you can actually pass MachineBasicBlock::end() now. - Add more "const". llvm-svn: 238288
2015-05-18MC: Clean up method names in MCContext.Jim Grosbach1-1/+1
The naming was a mish-mash of old and new style. Update to be consistent with the new. NFC. llvm-svn: 237594
2015-03-27Remove superfluous .str() and replace std::string concatenation with Twine.Yaron Keren1-1/+1
llvm-svn: 233392
2015-02-27Rewrite MachineOperand::print and MachineInstr::print to avoidEric Christopher1-1/+1
uses of TM->getSubtargetImpl and propagate to all calls. This could be a debugging regression in places where we had a TargetMachine and/or MachineFunction but don't have it as part of the MachineInstr. Fixing this would require passing a MachineFunction/Function down through the print operator, but none of the existing uses in tree seem to do this. llvm-svn: 230710
2014-12-22The leak detector is dead, long live asan and valgrind.Rafael Espindola1-5/+0
In resent times asan and valgrind have found way more memory management bugs in llvm than the special purpose leak detector. llvm-svn: 224703
2014-12-11CodeGen: Stop using LeakDetector for MachineInstrDuncan P. N. Exon Smith1-4/+0
Since `MachineInstr` is required to have a trivial destructor, it cannot remove itself from `LeakDetection`. Remove the calls. As it happens, this requirement is because `MachineFunction` allocates all `MachineInstr`s in a custom allocator; when the `MachineFunction` is destroyed they're dropped of the edge. There's no benefit to detecting leaks. llvm-svn: 224061
2014-12-04Allow target to specify prefix for labelsMatt Arsenault1-3/+1
Use the MCAsmInfo instead of the DataLayout, and allow specifying a custom prefix for labels specifically. HSAIL requires that labels begin with @, but global symbols with &. llvm-svn: 223323
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
2014-08-13[MachineDominatorTree] Provide a method to inform a MachineDominatorTree that aQuentin Colombet1-25/+2
critical edge has been split. The MachineDominatorTree will when lazy update the underlying dominance properties when require. ** Context ** This is a follow-up of r215410. Each time a critical edge is split this invalidates the dominator tree information. Thus, subsequent queries of that interface will be slow until the underlying information is actually recomputed (costly). ** Problem ** Prior to this patch, splitting a critical edge needed to query the dominator tree to update the dominator information. Therefore, splitting a bunch of critical edges will likely produce poor performance as each query to the dominator tree will use the slow query path. This happens a lot in passes like MachineSink and PHIElimination. ** Proposed Solution ** Splitting a critical edge is a local modification of the CFG. Moreover, as soon as a critical edge is split, it is not critical anymore and thus cannot be a candidate for critical edge splitting anymore. In other words, the predecessor and successor of a basic block inserted on a critical edge cannot be inserted by critical edge splitting. Using these observations, we can pile up the splitting of critical edge and apply then at once before updating the DT information. The core of this patch moves the update of the MachineDominatorTree information from MachineBasicBlock::SplitCriticalEdge to a lazy MachineDominatorTree. ** Performance ** Thanks to this patch, the motivating example compiles in 4- minutes instead of 6+ minutes. No test case added as the motivating example as nothing special but being huge! The binaries are strictly identical for all the llvm test-suite + SPECs with and without this patch for both Os and O3. Regarding compile time, I observed only noise, although on average I saw a small improvement. <rdar://problem/17894619> llvm-svn: 215576
2014-08-05Have MachineFunction cache a pointer to the subtarget to make lookupsEric Christopher1-14/+8
shorter/easier and have the DAG use that to do the same lookup. This can be used in the future for TargetMachine based caching lookups from the MachineFunction easily. Update the MIPS subtarget switching machinery to update this pointer at the same time it runs. llvm-svn: 214838
2014-08-04Remove the TargetMachine forwards for TargetSubtargetInfo basedEric Christopher1-8/+17
information and update all callers. No functional change. llvm-svn: 214781
2014-07-02Fix missing constMatt Arsenault1-1/+1
llvm-svn: 212168
2014-04-21[Modules] Make Support/Debug.h modular. This requires it to not changeChandler Carruth1-0/+2
behavior based on other files defining DEBUG_TYPE, which means it cannot define DEBUG_TYPE at all. This is actually better IMO as it forces folks to define relevant DEBUG_TYPEs for their files. However, it requires all files that currently use DEBUG(...) to define a DEBUG_TYPE if they don't already. I've updated all such files in LLVM and will do the same for other upstream projects. This still leaves one important change in how LLVM uses the DEBUG_TYPE macro going forward: we need to only define the macro *after* header files have been #include-ed. Previously, this wasn't possible because Debug.h required the macro to be pre-defined. This commit removes that. By defining DEBUG_TYPE after the includes two things are fixed: - Header files that need to provide a DEBUG_TYPE for some inline code can do so by defining the macro before their inline code and undef-ing it afterward so the macro does not escape. - We no longer have rampant ODR violations due to including headers with different DEBUG_TYPE definitions. This may be mostly an academic violation today, but with modules these types of violations are easy to check for and potentially very relevant. Where necessary to suppor headers with DEBUG_TYPE, I have moved the definitions below the includes in this commit. I plan to move the rest of the DEBUG_TYPE macros in LLVM in subsequent commits; this one is big enough. The comments in Debug.h, which were hilariously out of date already, have been updated to reflect the recommended practice going forward. llvm-svn: 206822
2014-04-14[C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper1-25/+25
instead of comparing to nullptr. llvm-svn: 206142
2014-03-07Replace PROLOG_LABEL with a new CFI_INSTRUCTION.Rafael Espindola1-1/+1
The old system was fairly convoluted: * A temporary label was created. * A single PROLOG_LABEL was created with it. * A few MCCFIInstructions were created with the same label. The semantics were that the cfi instructions were mapped to the PROLOG_LABEL via the temporary label. The output position was that of the PROLOG_LABEL. The temporary label itself was used only for doing the mapping. The new CFI_INSTRUCTION has a 1:1 mapping to MCCFIInstructions and points to one by holding an index into the CFI instructions of this function. I did consider removing MMI.getFrameInstructions completelly and having CFI_INSTRUCTION own a MCCFIInstruction, but MCCFIInstructions have non trivial constructors and destructors and are somewhat big, so the this setup is probably better. The net result is that we don't create temporary labels that are never used. llvm-svn: 203204
2014-03-04[Modules] Move the LeakDetector header into the IR library where theChandler Carruth1-1/+1
source file had already been moved. Also move the unittest into the IR unittest library. This may seem an odd thing to put in the IR library but we only really use this with instructions and it needs the LLVM context to work, so it is intrinsically tied to the IR library. llvm-svn: 202842
2014-03-02[C++11] Replace llvm::next and llvm::prior with std::next and std::prev.Benjamin Kramer1-4/+4
Remove the old functions. llvm-svn: 202636
2014-01-29PGO branch weight: update edge weights in IfConverter.Manman Ren1-0/+7
This commit only handles IfConvertTriangle. To update edge weights of a successor, one interface is added to MachineBasicBlock: /// Set successor weight of a given iterator. setSuccWeight(succ_iterator I, uint32_t weight) An existing testing case test/CodeGen/Thumb2/v8_IT_5.ll is updated, since we now correctly update the edge weights, the cold block is placed at the end of the function and we jump to the cold block. llvm-svn: 200428
2014-01-09Put the functionality for printing a value to a raw_ostream as anChandler Carruth1-8/+5
operand into the Value interface just like the core print method is. That gives a more conistent organization to the IR printing interfaces -- they are all attached to the IR objects themselves. Also, update all the users. This removes the 'Writer.h' header which contained only a single function declaration. llvm-svn: 198836
2014-01-07Move the LLVM IR asm writer header files into the IR directory, as theyChandler Carruth1-1/+1
are part of the core IR library in order to support dumping and other basic functionality. Rename the 'Assembly' include directory to 'AsmParser' to match the library name and the only functionality left their -- printing has been in the core IR library for quite some time. Update all of the #includes to match. All of this started because I wanted to have the layering in good shape before I started adding support for printing LLVM IR using the new pass infrastructure, and commandline support for the new pass infrastructure. llvm-svn: 198688
2014-01-03Make the llvm mangler depend only on DataLayout.Rafael Espindola1-1/+2
Before this patch any program that wanted to know the final symbol name of a GlobalValue had to link with Target. This patch implements a compromise solution where the mangler uses DataLayout. This way, any tool that already links with Target (llc, clang) gets the exact behavior as before and new IR files can be mangled without linking with Target. With this patch the mangler is constructed with just a DataLayout and DataLayout is extended to include the information the Mangler needs. llvm-svn: 198438
2013-12-07Add a RequireStructuredCFG Field to TargetMachine.Vincent Lejeune1-0/+5
llvm-svn: 196634
2013-10-10Rename LiveRange to LiveInterval::SegmentMatthias Braun1-3/+3
The Segment struct contains a single interval; multiple instances of this struct are used to construct a live range, but the struct is not a live range by itself. llvm-svn: 192392
2013-07-04Live-in copies go *after* EH_LABELs.Jakob Stoklund Olesen1-1/+1
This will soon be tested by exception handling working at all. llvm-svn: 185615
2013-07-03Add MachineBasicBlock::addLiveIn().Jakob Stoklund Olesen1-0/+33
This function adds a live-in physical register to an MBB and ensures that it is copied to a virtual register immediately. llvm-svn: 185594
2013-06-18Use pointers to the MCAsmInfo and MCRegInfo.Bill Wendling1-1/+1
Someone may want to do something crazy, like replace these objects if they change or something. No functionality change intended. llvm-svn: 184175
2013-04-22Optimize MachineBasicBlock::getSymbol by caching the symbol. Since the symbolEli Bendersky1-7/+11
name computation is expensive, this helps save about 25% of the time spent in this function. llvm-svn: 180049
2013-02-17Remove use of reverse iterators in repairIntervalsInRange(). While they wereCameron Zwarich1-9/+1
arguably better than forward iterators for this use case, they are confusing and there are some implementation problems with reverse iterators and MI bundles. llvm-svn: 175393
2013-02-17Fix a conversion from a forward iterator to a reverse iterator inCameron Zwarich1-6/+7
MachineBasicBlock::SplitCriticalEdge. Since this is an iterator rather than an instr_iterator, the isBundled() check only passes if getFirstTerminator() returned end() and the garbage memory happens to lean that way. Multiple successors can be present without any terminator instructions in the case of exception handling with a fallthrough. llvm-svn: 175383
2013-02-17Add support for updating the LiveIntervals of registers used by 'exotic'Cameron Zwarich1-0/+29
terminators that actually have register uses when splitting critical edges. This commit also introduces a method repairIntervalsInRange() on LiveIntervals, which allows for repairing LiveIntervals in a small range after an arbitrary target hook modifies, inserts, and removes instructions. It's pretty limited right now, but I hope to extend it to support all of the things that are done by the convertToThreeAddress() target hooks. llvm-svn: 175382
2013-02-12Add blocks to the LiveIntervalAnalysis RegMaskBlocks array when splittingCameron Zwarich1-2/+6
a critical edge. llvm-svn: 174936
2013-02-12Fix the updating of LiveIntervals after splitting a critical edge. PHI operandCameron Zwarich1-12/+3
live ranges should always be extended, and the only successor that should be considered for extension of other ranges is the target of the split edge. llvm-svn: 174935
2013-02-11Add support for updating LiveIntervals to ↵Cameron Zwarich1-0/+68
MachineBasicBlock::SplitCriticalEdge(). This is currently a bit hairier than it needs to be, since depending on where the split block resides the end ListEntry of the split block may be the end ListEntry of the original block or a new entry. Some changes to the SlotIndexes updating should make it possible to eliminate the two cases here. This also isn't as optimized as it could be. In the future Liveinterval should probably get a flag that indicates whether the LiveInterval is within a single basic block. We could ignore all such intervals when splitting an edge. llvm-svn: 174870
2013-02-11Update SlotIndexes after updateTerminator() possibly removes instructions. I amCameron Zwarich1-0/+24
really trying to avoid piping SlotIndexes through to RemoveBranch() and friends. llvm-svn: 174869
2013-02-10Fix the unused but nearly correct method SlotIndexes::insertMBBInMaps() and addCameron Zwarich1-0/+14
support for updating SlotIndexes to MachineBasicBlock::SplitCriticalEdge(). This calls renumberIndexes() every time; it should be improved to only renumber locally. llvm-svn: 174851
2013-01-02Move all of the header files which are involved in modelling the LLVM IRChandler Carruth1-2/+2
into their new header subdirectory: include/llvm/IR. This matches the directory structure of lib, and begins to correct a long standing point of file layout clutter in LLVM. There are still more header files to move here, but I wanted to handle them in separate commits to make tracking what files make sense at each layer easier. The only really questionable files here are the target intrinsic tablegen files. But that's a battle I'd rather not fight today. I've updated both CMake and Makefile build systems (I think, and my tests think, but I may have missed something). I've also re-sorted the includes throughout the project. I'll be committing updates to Clang, DragonEgg, and Polly momentarily. llvm-svn: 171366
2012-12-18Tighten up the splice() API for bundled instructions.Jakob Stoklund Olesen1-13/+0
Remove the instr_iterator versions of the splice() functions. It doesn't seem useful to be able to splice sequences of instructions that don't consist of full bundles. The normal splice functions that take MBB::iterator arguments are not changed, and they can move whole bundles around without any problems. llvm-svn: 170456
2012-12-18Tighten the insert() API for bundled instructions.Jakob Stoklund Olesen1-0/+12
The normal insert() function takes an MBB::iterator position, and inserts a stand-alone MachineInstr as before. The insert() function that takes an MBB::instr_iterator position can insert instructions inside a bundle, and will now update the bundle flags correctly when that happens. When the insert position is between two bundles, it is unclear whether the instruction should be appended to the previous bundle, prepended to the next bundle, or stand on its own. The MBB::insert() function doesn't bundle the instruction in that case, use the MIBundleBuilder class for that. llvm-svn: 170437
2012-12-17Tighten up the erase/remove API for bundled instructions.Jakob Stoklund Olesen1-18/+21
Most code is oblivious to bundles and uses the MBB::iterator which only visits whole bundles. MBB::erase() operates on whole bundles at a time as before. MBB::remove() now refuses to remove bundled instructions. It is not safe to remove all instructions in a bundle without deleting them since there is no way of returning pointers to all the removed instructions. MBB::remove_instr() and MBB::erase_instr() will now update bundle flags correctly, lifting individual instructions out of bundles while leaving the remaining bundle intact. The MachineInstr convenience functions are updated so eraseFromParent() erases a whole bundle as before eraseFromBundle() erases a single instruction, leaving the rest of its bundle. removeFromParent() refuses to operate on bundled instructions, and removeFromBundle() lifts a single instruction out of its bundle. These functions will no longer accidentally split or coalesce bundles - bundle flags are updated to preserve the existing bundling, and explicit bundleWith* / unbundleFrom* functions should be used to change the instruction bundling. This API update is still a work in progress. I am going to update APIs first so they maintain bundle flags automatically when possible. Then I'll add stricter verification of the bundle flags. llvm-svn: 170384
2012-12-03Use the new script to sort the includes of every file under lib.Chandler Carruth1-7/+7
Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
2012-11-20Fix physical register liveness calculations:Tim Northover1-6/+9
+ Take account of clobbers + Give outputs priority over inputs since they happen later. llvm-svn: 168360
2012-10-26Make sure I is not the end iterator when isInsideBundle is called. Akira Hatanaka1-2/+3
llvm-svn: 166784
2012-10-08Move TargetData to DataLayout.Micah Villmow1-1/+1
llvm-svn: 165402
2012-09-12Add a function computeRegisterLiveness() to MachineBasicBlock. This uses ↵James Molloy1-0/+74
analyzePhysReg() from r163694 to heuristically try and determine the liveness state of a physical register upon arrival at a particular instruction in a block. The search for liveness is clipped to a specific number of instructions around the target MachineInstr, in order to avoid degenerating into an O(N^2) algorithm. It tries to use various clues about how instructions around (both before and after) a given MachineInstr use that register, to determine its state at the MachineInstr. llvm-svn: 163695