1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 04:22:57 +02:00
Commit Graph

7064 Commits

Author SHA1 Message Date
Bill Wendling
35584a26be Move the bookkeeping of the debug scopes back to the place where it
belonged. The variable declaration stuff wasn't happy with it where it
was. Sorry that the testcase is so big. Bugpoint wasn't able to reduce it
successfully.

llvm-svn: 71714
2009-05-13 20:33:33 +00:00
John Mosby
6b2d45fe66 PEI: rename PEI.h to PrologEpilogInserter.h to adhere to file naming standard
llvm-svn: 71678
2009-05-13 17:52:11 +00:00
Chris Lattner
53ddc0fba1 add ShrinkWrapping.cpp
llvm-svn: 71645
2009-05-13 06:27:38 +00:00
Lang Hames
f6a337d7fb Fix for PR4121. If TwoAddressInstructionPass removes a dead def, and the regB
operand was killed, the kill needs to be removed from regB's VarInfo.

llvm-svn: 71635
2009-05-13 04:18:47 +00:00
Jim Grosbach
4bb5e9d1df Add support for GCC compatible builtin setjmp and longjmp intrinsics. This is
a supporting preliminary patch for GCC-compatible SjLJ exception handling. Note that these intrinsics are not designed to be invoked directly by the user, but
rather used by the front-end as target hooks for exception handling.

llvm-svn: 71610
2009-05-12 23:59:14 +00:00
Evan Cheng
e43bfc153e If header of inner loop is aligned, do not align the outer loop header. We don't want to add nops in the outer loop for the sake of aligning the inner loop.
llvm-svn: 71609
2009-05-12 23:58:14 +00:00
Evan Cheng
c7f7276825 Teach TransferDeadness to delete truly dead instructions if they do not produce side effects.
llvm-svn: 71606
2009-05-12 23:07:00 +00:00
John Mosby
618e3e6578 Restructure PEI code:
- moved shrink wrapping code from PrologEpilogInserter.cpp to
  new file ShrinkWrapping.cpp.

- moved PEI pass definition into new shared header PEI.h.

llvm-svn: 71588
2009-05-12 20:33:29 +00:00
Jay Foad
a4531bdfe8 Switch to using IRBuilder throughout.
llvm-svn: 71587
2009-05-12 20:27:44 +00:00
Evan Cheng
d6e3e4d746 Fixed a stack slot coloring with reg bug: do not update implicit use / def when doing forward / backward propagation.
llvm-svn: 71574
2009-05-12 18:31:57 +00:00
Bob Wilson
16f684a429 Fix pr4195: When iterating through predecessor blocks, break out of the loop
after finding the (unique) layout predecessor.  Sometimes a block may be listed
more than once, and processing it more than once in this loop can lead to
inconsistent values for FtTBB/FtFBB, since the AnalyzeBranch method does not
clear these values.  There's no point in continuing the loop regardless.
The testcase for this is reduced from the 2003-05-02-DependentPHI SingleSource
test.

llvm-svn: 71536
2009-05-12 03:48:10 +00:00
Bill Wendling
dd997304e8 - Record that the debug info is actually used so that the label folder doesn't
blast it away.
- Move InlineInfo bookkeeping to bookkeep the correct debug info object.

llvm-svn: 71519
2009-05-12 00:06:59 +00:00
Lang Hames
c577f429c0 Fixed PR4090.
llvm-svn: 71495
2009-05-11 23:14:13 +00:00
Dale Johannesen
dd32623987 Fix PR4188. TailMerging can't tolerate inexact
sucessor info.

llvm-svn: 71478
2009-05-11 21:54:13 +00:00
Evan Cheng
645351d3a8 Apply patch review feedback.
llvm-svn: 71472
2009-05-11 20:53:52 +00:00
Evan Cheng
dad97e1bfc Unbreak non-debug build.
llvm-svn: 71457
2009-05-11 18:40:52 +00:00
Evan Cheng
7c7809eebd Eliminate a compiler warning.
llvm-svn: 71456
2009-05-11 18:40:35 +00:00
Dan Gohman
dfa39efe6d When scalarizing a vector BITCAST, check whether the operand has vector
type, rather than assume that it does. If the operand is not vector, it
shouldn't be run through ScalarizeVectorOp. This fixes one of the
testcases in PR3886.

llvm-svn: 71453
2009-05-11 18:30:42 +00:00
John Mosby
366006cfd3 Shrink wrapping in PEI:
- reduces _static_ callee saved register spills
  and restores similar to Chow's original algorithm.
- iterative implementation with simple heuristic
  limits to mitigate compile time impact.
- handles placing spills/restores for multi-entry,
  multi-exit regions in the Machine CFG without
  splitting edges.
- passes test-suite in LLCBETA mode.

Added contains() method to ADT/SparseBitVector.

llvm-svn: 71438
2009-05-11 17:04:19 +00:00
Jay Foad
5827394cd0 Don't generate redundant casts of constant values when lowering calls to
memcpy, memmove and memset.

llvm-svn: 71427
2009-05-11 11:32:25 +00:00
Bill Wendling
e0a4e2af03 This is a large rewrite of how Dwarf info for inlined functions is handled.
The DwarfWriter expects DbgScopes and DIEs to behave themselves according to
DwarfWriter's rules. However, inlined functions violate these rules. There are
two different types of DIEs associated with an inlined function: an abstract
instance, which has information about the original source code for the function
being inlined; and concrete instances, which are created for each place the
function was inlined and point back to the abstract instance.

This patch tries to stay true to this schema. It bypasses how regular DbgScopes
and DIEs are created and used when necessary. It provides special handling for
DIEs of abstract and concrete instances.

This doesn't take care of all of the problems with debug info for inlined
functions, but it's a step in the right direction. For one thing, llvm-gcc
generates wrong IR (it's missing some llvm.dbg intrinsics at the point where the
function's inlined) for this example:

#include <stdio.h>
static __inline__ __attribute__((always_inline))  int bar(int x) { return 4; }
void foo() {
  long long b = 1;
  int Y = bar(4);
  printf("%d\n", Y);
}

while clang generates correct IR.

llvm-svn: 71410
2009-05-10 23:14:38 +00:00
Bill Wendling
c4ffa72fc4 --- Reverse-merging r71370 into '.':
U    lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp

Revert r71370.

llvm-svn: 71373
2009-05-10 00:10:50 +00:00
Bill Wendling
bea75516f2 A debug function start was not being recorded when the optimization level wasn't
None. However, we were always recording the region end. There's no longer a good
reason for this code to be separated out between the different opt levels, as it
was doing pretty much the same thing anyway.

llvm-svn: 71370
2009-05-09 23:51:35 +00:00
Evan Cheng
581641b664 Oops. Don't forget to align single bb loops.
llvm-svn: 71363
2009-05-09 19:18:01 +00:00
Duncan Sands
f7af13b2d4 Rename PaddedSize to AllocSize, in the hope that this
will make it more obvious what it represents, and stop
it being confused with the StoreSize.

llvm-svn: 71349
2009-05-09 07:06:46 +00:00
Evan Cheng
06b0d3879e Enable loop bb placement optimization.
llvm-svn: 71291
2009-05-08 23:35:49 +00:00
Mike Stump
9779d47f7a Avoid warning in release-asserts build.
llvm-svn: 71275
2009-05-08 22:53:06 +00:00
Bill Wendling
1dccca6452 Mirror how Fast ISel determines if a region.end intrinsic is the end of an
inlined function or the end of a function. Before, this was never executing the
"inlined" version of the Record method.

This will become important once the inlined Dwarf writer patch lands.

llvm-svn: 71268
2009-05-08 21:14:49 +00:00
Bill Wendling
6ad9e22d42 Compute the offsets of the compile units. We need this so that when we emit a
concrete instance of an inlined function, we can get the actual address of the
abstract instance inside of the compile unit.

This isn't currently used, but will be by a future check-in.

llvm-svn: 71263
2009-05-08 21:03:15 +00:00
Bill Wendling
d7428b0d9c Minor clean ups. No functionality change.
llvm-svn: 71256
2009-05-08 20:38:02 +00:00
Evan Cheng
aadb8051c0 Don't align loop header unless the loop back edge is below the header.
llvm-svn: 71242
2009-05-08 19:01:44 +00:00
Anton Korobeynikov
b3dc881070 Factor out cycle-finder code and make it generic.
llvm-svn: 71241
2009-05-08 18:51:58 +00:00
Anton Korobeynikov
026d2328a6 Do not emit bit tests if target does not support natively left shift
llvm-svn: 71240
2009-05-08 18:51:34 +00:00
Anton Korobeynikov
353d4609cf Properly expand libcalls for urem / srem. Also make code more straightforward.
llvm-svn: 71238
2009-05-08 18:51:08 +00:00
Anton Korobeynikov
aa7f982935 Typo
llvm-svn: 71237
2009-05-08 18:50:54 +00:00
Evan Cheng
10038ab095 Reverse branch condition only when there is a conditional branch.
llvm-svn: 71214
2009-05-08 09:35:53 +00:00
Nick Lewycky
a8f179d44b Add explicit braces to disambiguate nested if/else. Removes a warning.
llvm-svn: 71211
2009-05-08 06:57:41 +00:00
Evan Cheng
2a1d20b0fb Optimize code placement in loop to eliminate unconditional branches or move unconditional branch to the outside of the loop. e.g.
///       A:                                                                                                                                                                 
///       ...                                                                                                                                                                
///       <fallthrough to B>                                                                                                                                                 
///                                                                                                                                                                          
///       B:  --> loop header                                                                                                                                                
///       ...                                                                                                                                                                
///       jcc <cond> C, [exit]                                                                                                                                               
///                                                                                                                                                                          
///       C:                                                                                                                                                                 
///       ...                                                                                                                                                                
///       jmp B                                                                                                                                                              
///                                                                                                                                                                          
/// ==>                                                                                                                                                                      
///                                                                                                                                                                          
///       A:                                                                                                                                                                 
///       ...                                                                                                                                                                
///       jmp B                                                                                                                                                              
///                                                                                                                                                                          
///       C:  --> new loop header                                                                                                                                            
///       ...                                                                                                                                                                
///       <fallthough to B>                                                                                                                                                  
///                                                                                                                                                                          
///       B:                                                                                                                                                                 
///       ...                                                                                                                                                                
///       jcc <cond> C, [exit] 

llvm-svn: 71209
2009-05-08 06:34:09 +00:00
Bob Wilson
d61f4e70d8 Fix pr4100. Do not remove no-op copies when they are dead. The register
scavenger gets confused about register liveness if it doesn't see them.
I'm not thrilled with this solution, but it only comes up when there are dead
copies in the code, which is something that hopefully doesn't happen much.

Here is what happens in pr4100: As shown in the following excerpt from the
debug output of llc, the source of a move gets reloaded from the stack,
inserting a new load instruction before the move.  Since that source operand
is a kill, the physical register is free to be reused for the destination
of the move.  The move ends up being a no-op, copying R3 to R3, so it is
deleted.  But, it leaves behind the load to reload %reg1028 into R3, and
that load is not updated to show that it's destination operand (R3) is dead.
The scavenger gets confused by that load because it thinks that R3 is live.

Starting RegAlloc of: %reg1025<def,dead> = MOVr %reg1028<kill>, 14, %reg0, %reg0
  Regs have values: 
  Reloading %reg1028 into R3
  Last use of R3[%reg1028], removing it from live set
  Assigning R3 to %reg1025
  Register R3 [%reg1025] is never used, removing it from live set

Alternative solutions might be either marking the load as dead, or zapping
the load along with the no-op copy.  I couldn't see an easy way to do
either of those, though.

llvm-svn: 71196
2009-05-07 23:47:03 +00:00
Bob Wilson
a46384485b Fix a comment (again).
llvm-svn: 71180
2009-05-07 21:20:42 +00:00
Bob Wilson
8028930294 Fix a comment.
llvm-svn: 71179
2009-05-07 21:19:45 +00:00
Dan Gohman
ebacd61d7d Revert 71165. It did more than just revert 71158 and it introduced
several regressions. The problem due to 71158 is now fixed.

llvm-svn: 71176
2009-05-07 19:46:24 +00:00
Bill Wendling
9f97e4a3dc Temporarily revert r71158. It was causing a failure during a full bootstrap:
checking for bcopy... no
checking for getc_unlocked... Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511.
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decUtility.c:360: internal compiler error: Abort trap
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
make[4]: *** [decUtility.o] Error 1
make[4]: *** Waiting for unfinished jobs....
Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511.
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decNumber.c:5591: internal compiler error: Abort trap
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
make[4]: *** [decNumber.o] Error 1
make[3]: *** [all-stage2-libdecnumber] Error 2
make[3]: *** Waiting for unfinished jobs....

llvm-svn: 71165
2009-05-07 17:26:14 +00:00
Argyrios Kyrtzidis
bd72fc132d Move the tablegen-produced DebugLoc handling into a AsmWriter::processDebugLoc function.
No functionality change.

llvm-svn: 71156
2009-05-07 13:55:51 +00:00
Evan Cheng
ef5794cb99 Code refactoring.
llvm-svn: 71151
2009-05-07 05:49:39 +00:00
Evan Cheng
1b99da6e30 Rename "loop aligner" pass to "code placement optimization" pass.
llvm-svn: 71150
2009-05-07 05:42:24 +00:00
Bill Wendling
6edd6ef74f Just turn aggressive stack coloring off at -O3.
llvm-svn: 71140
2009-05-07 01:33:38 +00:00
Bill Wendling
7c50dcd02e Temporarily revert r71010. It was causing massive failures during self-hosting.
llvm-svn: 71138
2009-05-07 01:27:25 +00:00
Argyrios Kyrtzidis
0f60e636c0 Make DwarfWriter::RecordInlinedFnStart more like the other DwarfWriter's methods:
-Have it return a label ID
-Remove the unused Instruction parameter

No functionality change.

llvm-svn: 71132
2009-05-07 00:16:31 +00:00
Bill Wendling
6e1b018958 - Move some debug fields to coincide with how GCC emits them. No functionality
change.
- Reformatting.

llvm-svn: 71118
2009-05-06 21:21:34 +00:00
Evan Cheng
0ee6696fd8 Do not use register as base ptr of pre- and post- inc/dec load / store nodes.
llvm-svn: 71098
2009-05-06 18:25:01 +00:00
Oscar Fuentes
24167db5ad CMake: Updated lib/CodeGen/CMakeLists.txt.
llvm-svn: 71085
2009-05-06 14:56:40 +00:00
Duncan Sands
938fde7e43 Add generic expansion of SUB when ADD and XOR
are legal.  Based on a patch by Micah Villmow.

llvm-svn: 71078
2009-05-06 11:29:50 +00:00
Lang Hames
fcc5ebb1d4 Renamed Spiller classes (plus uses and related files) to VirtRegRewriter.
llvm-svn: 71057
2009-05-06 02:36:21 +00:00
Dan Gohman
5e839321f2 If a MachineBasicBlock has multiple ways of reaching another block,
allow it to have multiple CFG edges to that block. This is needed
to allow MachineBasicBlock::isOnlyReachableByFallthrough to work
correctly. This fixes PR4126.

llvm-svn: 71018
2009-05-05 21:10:19 +00:00
Evan Cheng
984da04cd0 Enable stack coloring with regs at -O3.
llvm-svn: 71010
2009-05-05 20:30:36 +00:00
Chris Lattner
a96ef42a06 Do not require variable debug info nodes to have a compile unit.
For implicit decls like "self" and "_cmd" in ObjC, these decls
should not have a location.

llvm-svn: 70964
2009-05-05 04:55:56 +00:00
Evan Cheng
77e14276e0 Do not substitute if the new register isn't in the register class of the operand being updated.
llvm-svn: 70953
2009-05-05 00:46:16 +00:00
Evan Cheng
95ce4ffb36 Move getInstrOperandRegClass from the scheduler to TargetInstrInfo.
llvm-svn: 70950
2009-05-05 00:30:09 +00:00
Evan Cheng
ecfc8e8464 Do forward and backward substitution to eliminate loads and stores when possible.
llvm-svn: 70937
2009-05-04 23:13:13 +00:00
Chris Lattner
7e3c94b55e Make DBG_STOPPOINT nodes, and therefore DBG_LABEL labels, get a DebugLoc, so that it
shows up in -print-machineinstrs.  This doesn't appear to affect anything, but it was
weird for some DBG_LABELs to have DebugLocs but not all of them.

llvm-svn: 70921
2009-05-04 22:10:05 +00:00
Argyrios Kyrtzidis
f82d02a6ca Restore a comment.
llvm-svn: 70900
2009-05-04 19:23:45 +00:00
Argyrios Kyrtzidis
fb958c2b09 -Remove the DwarfWriter::RecordSourceLine calls from the instruction selectors.
-Depend on DebugLocs for source line info.

(Comes with Regression-Be-Gone(tm))

llvm-svn: 70871
2009-05-04 16:23:49 +00:00
Evan Cheng
9df9768ee5 Make sure to color with only allocatable registers for the specific register class.
llvm-svn: 70821
2009-05-04 03:30:11 +00:00
Evan Cheng
bb12bac53b The stack slots which share the same stack slot after coloring can, but do not have to, use the same register. In fact, they each may have different register class requirements.
llvm-svn: 70815
2009-05-04 00:24:50 +00:00
Argyrios Kyrtzidis
e68261749e Revert r70803 for now, it causes a regression.
llvm-svn: 70811
2009-05-03 23:27:19 +00:00
Argyrios Kyrtzidis
bb6e4d027c -Remove the DwarfWriter::RecordSourceLine calls from the instruction selectors.
-Depend on DebugLocs for source line info.

llvm-svn: 70803
2009-05-03 22:03:35 +00:00
Evan Cheng
a64d6b8822 Typo.
llvm-svn: 70792
2009-05-03 19:10:11 +00:00
Evan Cheng
28aa6c41d1 In some rare cases, the register allocator can spill registers but end up not utilizing registers at all. The fundamental problem is linearscan's backtracking can end up freeing more than one allocated registers. However, reloads and restores might be folded into uses / defs and freed registers might not be used at all.
VirtRegMap keeps track of allocations so it knows what's not used. As a horrible hack, the stack coloring can color spill slots with *free* registers. That is, it replace reload and spills with copies from and to the free register. It unfold instructions that load and store the spill slot and replace them with register using variants.

Not yet enabled. This is part 1. More coming.

llvm-svn: 70787
2009-05-03 18:32:42 +00:00
Anton Korobeynikov
15587901c3 Fix typo
llvm-svn: 70770
2009-05-03 13:19:57 +00:00
Anton Korobeynikov
34d22f34a8 Properly handle sdiv / udiv / srem / urem libcalls
llvm-svn: 70764
2009-05-03 13:18:16 +00:00
Anton Korobeynikov
7f560f113d Proper name 16 bit libcalls
llvm-svn: 70750
2009-05-03 13:14:08 +00:00
Anton Korobeynikov
b4da45ecd8 Add libcall expansion for 16 and 128 bit muls
llvm-svn: 70749
2009-05-03 13:13:51 +00:00
Argyrios Kyrtzidis
a034549d67 -Move the DwarfWriter::ValidDebugInfo check to a static DIDescriptor::ValidDebugInfo
-Create DebugLocs without the need to have a DwarfWriter around

llvm-svn: 70682
2009-05-03 08:50:41 +00:00
Bob Wilson
da90bf9e40 Allow CONCAT_VECTORS nodes to be legal or have custom lowering for some targets.
Changes to take advantage of this will come later.

llvm-svn: 70560
2009-05-01 17:55:32 +00:00
Bill Wendling
2da6a65b62 Simplify more code and add timer stuff.
llvm-svn: 70539
2009-05-01 08:40:06 +00:00
Bill Wendling
0bab670012 Simplify more code.
llvm-svn: 70537
2009-05-01 08:35:12 +00:00
Bill Wendling
662dfea32e Simplify some code.
llvm-svn: 70534
2009-05-01 08:32:14 +00:00
Bill Wendling
2f01fd9bf1 Fix whitespace. It was confusing me.
llvm-svn: 70533
2009-05-01 08:25:13 +00:00
Evan Cheng
d6a780a181 Code clean up. Bye bye PhysRegTracker.
llvm-svn: 70524
2009-05-01 01:03:49 +00:00
Argyrios Kyrtzidis
9956976b76 Make DebugLoc independent of DwarfWriter.
-Replace DebugLocTuple's Source ID with CompileUnit's GlobalVariable*
-Remove DwarfWriter::getOrCreateSourceID
-Make necessary changes for the above (fix callsites, etc.)

llvm-svn: 70520
2009-04-30 23:22:31 +00:00
Jakob Stoklund Olesen
17d292db73 Join cross class copies using getCommonSubClass()
llvm-svn: 70513
2009-04-30 21:24:03 +00:00
Evan Cheng
a4c868f1d4 Add a smarter heuristic to determine when to coalesce a virtual register with a physical one. More specifically, it avoid tying a virtual register in the loop with a physical register defined / used outside the loop. When it determines it's not profitable, it will use the physical register as the allocation preference instead.
This is *not* turned on by default. Testing indicates this is just as likely to pessimize code. The main issue seems to be allocation preference doesn't work effectively. That will change once I've taught register allocator "swapping".

llvm-svn: 70503
2009-04-30 18:39:57 +00:00
Jay Foad
9768cabf4a Move helper functions for optimizing division by constant into the APInt
class.

llvm-svn: 70488
2009-04-30 10:15:35 +00:00
Chris Lattner
794fb5b4b3 fix a regression handling indirect results: these need to be considered
memory operands otherwise the writebacks get lost when the inline asm 
doesn't otherwise have side effects.  This fixes rdar://6839427, though
clang really shouldn't generate these anymore.

llvm-svn: 70455
2009-04-30 00:48:50 +00:00
Bill Wendling
40a162f75f Instead of passing in an unsigned value for the optimization level, use an enum,
which better identifies what the optimization is doing. And is more flexible for
future uses.

llvm-svn: 70440
2009-04-29 23:29:43 +00:00
Nate Begeman
b407809122 Fix infinite recursion in the C++ code which handles movddup by making it unnecessary.
llvm-svn: 70425
2009-04-29 22:47:44 +00:00
Jakob Stoklund Olesen
0bfaaea2a4 MachineInstr::isRegTiedTo{Use,Def}Operand can safely be made const.
llvm-svn: 70408
2009-04-29 20:57:16 +00:00
Nate Begeman
e4dd5a96ba Update comment, replace theoretically impossible check with an assert.
llvm-svn: 70391
2009-04-29 18:13:31 +00:00
Evan Cheng
62fdc300dd spillPhysRegAroundRegDefsUses() may have invalidated iterators stored in fixed_ IntervalPtrs. Reset them.
llvm-svn: 70378
2009-04-29 07:16:34 +00:00
Nate Begeman
414534b3eb Implement review feedback for vector shuffle work.
llvm-svn: 70372
2009-04-29 05:20:52 +00:00
Sanjiv Gupta
b1c777e865 Add a public method called getAddressSpace() to the GlobalAddressSDNode.
llvm-svn: 70366
2009-04-29 04:43:24 +00:00
Chris Lattner
e1eefefdc3 Disable the load-shrinking optimization from looking at
anything larger than 64-bits, avoiding a crash.  This should
really be fixed to use APInts, though type legalization happens
to help us out and we get good code on the attached testcase at
least.

This fixes rdar://6836460

llvm-svn: 70360
2009-04-29 03:45:07 +00:00
Evan Cheng
51727d25b2 Determine allocation 'preference' with right register class. I haven't seen this changing codegen so no test case.
llvm-svn: 70351
2009-04-29 00:42:27 +00:00
Bill Wendling
7546bed590 Second attempt:
Massive check in. This changes the "-fast" flag to "-O#" in llc. If you want to
use the old behavior, the flag is -O0. This change allows for finer-grained
control over which optimizations are run at different -O levels.

Most of this work was pretty mechanical. The majority of the fixes came from
verifying that a "fast" variable wasn't used anymore. The JIT still uses a
"Fast" flag. I'll change the JIT with a follow-up patch.

llvm-svn: 70343
2009-04-29 00:15:41 +00:00
Evan Cheng
46e0ff09e5 Move getMatchingSuperReg() out of coalescer and into TargetRegisterInfo.
llvm-svn: 70309
2009-04-28 18:29:27 +00:00
Jakob Stoklund Olesen
6a489c6d7e Don't coalesce a physical register with an incompatible virtual register.
If the physical register does not belong to the virtual register's regclass,
don't coalesce. The physical register could be an invalid operand for an
instruction using the vreg.

The regclass matching is done after determining the actual subregisters being copied.

llvm-svn: 70298
2009-04-28 16:34:35 +00:00
Sanjiv Gupta
51c8ca2ca6 Initialized arrays can be in any address space.
llvm-svn: 70297
2009-04-28 16:34:20 +00:00
Jakob Stoklund Olesen
26d9b11da5 Move getSubRegisterRegClass from ScheduleDagSDNodesEmit.cpp to a TargetRegisterClass method.
Also make the method non-asserting. It will return NULL when given an invalid subreg index.

The method is needed by an upcoming patch.

llvm-svn: 70296
2009-04-28 16:34:09 +00:00
Evan Cheng
754a0d2f9e Fix PR4034. Bug in LiveInterval::join when it's compacting new valno's.
llvm-svn: 70291
2009-04-28 06:24:09 +00:00
Evan Cheng
8a9736a26c Fix for PR4051. When 2address pass delete an instruction, update kill info when necessary.
llvm-svn: 70279
2009-04-28 02:12:36 +00:00
Bill Wendling
ef47ace92f r70270 isn't ready yet. Back this out. Sorry for the noise.
llvm-svn: 70275
2009-04-28 01:04:53 +00:00
Bill Wendling
2799e916c3 Massive check in. This changes the "-fast" flag to "-O#" in llc. If you want to
use the old behavior, the flag is -O0. This change allows for finer-grained
control over which optimizations are run at different -O levels.

Most of this work was pretty mechanical. The majority of the fixes came from
verifying that a "fast" variable wasn't used anymore. The JIT still uses a
"Fast" flag. I'm not 100% sure if it's necessary to change it there...

llvm-svn: 70270
2009-04-28 00:21:31 +00:00
Evan Cheng
c315cf24e3 Fix PR4076. Correctly create live interval of physical register with two-address update.
llvm-svn: 70245
2009-04-27 20:42:46 +00:00
Owen Anderson
b313524b03 Don't skip the CopyMI when removing kill markers.
This should have no effect on generated code, but makes the intermediate state
of the coalescer more sane.

llvm-svn: 70238
2009-04-27 19:55:47 +00:00
Duncan Sands
ae8fb3fbcb Now that PR2957 is resolved, remove a bunch of
no-longer needed workarounds.

llvm-svn: 70234
2009-04-27 19:33:03 +00:00
Nate Begeman
9d121924fd 2nd attempt, fixing SSE4.1 issues and implementing feedback from duncan.
PR2957

ISD::VECTOR_SHUFFLE now stores an array of integers representing the shuffle
mask internal to the node, rather than taking a BUILD_VECTOR of ConstantSDNodes
as the shuffle mask.  A value of -1 represents UNDEF.

In addition to eliminating the creation of illegal BUILD_VECTORS just to 
represent shuffle masks, we are better about canonicalizing the shuffle mask,
resulting in substantially better code for some classes of shuffles.

llvm-svn: 70225
2009-04-27 18:41:29 +00:00
Evan Cheng
43fc90ae59 Fix PR4056. It's possible a physical register def is dead if its implicit use is deleted by two-address pass.
llvm-svn: 70213
2009-04-27 17:36:47 +00:00
Evan Cheng
c346651d6f Also delete last unused val#.
llvm-svn: 70212
2009-04-27 17:35:19 +00:00
Dan Gohman
744f455d55 When transforming sext(trunc(load(x))) into sext(smaller load(x)),
the trunc is directly replaced with the smaller load, so don't
try to create a new sext node. This fixes PR4050.

llvm-svn: 70179
2009-04-27 02:00:55 +00:00
Evan Cheng
cd5a58a3e4 Reuse unused val#'s to avoid running out of memory in extreme cases.
llvm-svn: 70069
2009-04-25 20:20:15 +00:00
Dan Gohman
1031d09a38 Refactor the code to grab the low and high parts of a value
using EXTRACT_ELEMENT into a utility function.

llvm-svn: 70056
2009-04-25 17:55:53 +00:00
Dan Gohman
60349bb21e Add a top-level comment about DAGCombiner's role in the compiler.
llvm-svn: 70052
2009-04-25 17:09:45 +00:00
Evan Cheng
696a04eba2 Do not share a single unknown val# for all the live ranges merged into a physical sub-register live interval. When coalescer is merging in clobbered virtaul register live interval into a physical register live interval, give each virtual register val# a separate val# in the physical register live interval. Otherwise, the coalescer would have lost track of the definitions information it needs to make correct coalescing decisions.
llvm-svn: 70026
2009-04-25 09:25:19 +00:00
Dale Johannesen
493c3bcdc0 Fix PR 4057, a crash doing float->char const folding.
This particular one is undefined behavior (although this
isn't related to the crash), so it will no longer do it
at compile time, which seems better.

llvm-svn: 69990
2009-04-24 21:34:13 +00:00
Rafael Espindola
0b1037ad26 Revert 69952. Causes testsuite failures on linux x86-64.
llvm-svn: 69967
2009-04-24 12:40:33 +00:00
Nate Begeman
c1a09c7dfa PR2957
ISD::VECTOR_SHUFFLE now stores an array of integers representing the shuffle
mask internal to the node, rather than taking a BUILD_VECTOR of ConstantSDNodes
as the shuffle mask.  A value of -1 represents UNDEF.

In addition to eliminating the creation of illegal BUILD_VECTORS just to 
represent shuffle masks, we are better about canonicalizing the shuffle mask,
resulting in substantially better code for some classes of shuffles.

A clean up of x86 shuffle code, and some canonicalizing in DAGCombiner is next.

llvm-svn: 69952
2009-04-24 03:42:54 +00:00
Dan Gohman
63dab69b36 Instead of requiring TLI.LowerCallTo to return an ISD::BUILD_PAIR,
use ISD::EXTRACT_ELEMENT. SelectionDAG has a special fast-path for
the cast of an EXTRACT_ELEMENT with a BUILD_PAIR operand, for the
common case.

llvm-svn: 69948
2009-04-24 02:40:23 +00:00
Dan Gohman
9d13b714f5 Factor out a bit of code that appears in several places into a
utility function.

llvm-svn: 69937
2009-04-23 23:13:24 +00:00
Dan Gohman
313018c1d3 Handle Void types in ComputeValueVTs. This doesn't currently occur,
but this change makes the code more general and easier to adapt for
new purposes.

llvm-svn: 69935
2009-04-23 22:50:03 +00:00
Evan Cheng
ff776c8193 Update comments.
llvm-svn: 69919
2009-04-23 20:39:31 +00:00
Evan Cheng
f20fb20367 Fix an obvious type.
llvm-svn: 69918
2009-04-23 20:18:13 +00:00
Evan Cheng
a36c6c6819 It has finally happened. Spiller is now using live interval info.
This fixes a very subtle bug. vr defined by an implicit_def is allowed overlap with any register since it doesn't actually modify anything. However, if it's used as a two-address use, its live range can be extended and it can be spilled. The spiller must take care not to emit a reload for the vn number that's defined by the implicit_def. This is both a correctness and performance issue.

llvm-svn: 69743
2009-04-21 22:46:52 +00:00
Devang Patel
d679dbbacc Fix Visual Studio 2008 build failure.
Patch by Marius Wachtler

llvm-svn: 69637
2009-04-21 00:08:56 +00:00
Dan Gohman
de72d5129b Make X86's copyRegToReg able to handle copies to and from subclasses.
This makes the extra copyRegToReg calls in ScheduleDAGSDNodesEmit.cpp
unnecessary. Derived from a patch by Jakob Stoklund Olesen.

llvm-svn: 69635
2009-04-20 22:54:34 +00:00
Dan Gohman
69fa329052 Simplify this code. getConstant knows how to make
broadcasted vector constants.

llvm-svn: 69634
2009-04-20 22:51:43 +00:00
Bob Wilson
f7e9ff1d28 Move duplicated AddLiveIn function from X86 and ARM backends to be a method
in the MachineFunction class, renaming it to addLiveIn for consistency with
the same method in MachineBasicBlock.  Thanks for Anton for suggesting this.

llvm-svn: 69615
2009-04-20 18:36:57 +00:00
Bob Wilson
840cf4fa18 Revise my previous change 68996 as suggested by Duncan.
llvm-svn: 69607
2009-04-20 17:27:09 +00:00
Evan Cheng
e6a6c3a70c - Remove an arbitrary spill weight tweak that should not have been there.
- Find more reloads from SS.

llvm-svn: 69606
2009-04-20 17:23:48 +00:00
Evan Cheng
c248188b46 Added a linearscan register allocation optimization. When the register allocator spill an interval with multiple uses in the same basic block, it creates a different virtual register for each of the reloads. e.g.
%reg1498<def> = MOV32rm %reg1024, 1, %reg0, 12, %reg0, Mem:LD(4,4) [sunkaddr39 + 0]
        %reg1506<def> = MOV32rm %reg1024, 1, %reg0, 8, %reg0, Mem:LD(4,4) [sunkaddr42 + 0]
        %reg1486<def> = MOV32rr %reg1506
        %reg1486<def> = XOR32rr %reg1486, %reg1498, %EFLAGS<imp-def,dead>
        %reg1510<def> = MOV32rm %reg1024, 1, %reg0, 4, %reg0, Mem:LD(4,4) [sunkaddr45 + 0]

=>

        %reg1498<def> = MOV32rm %reg2036, 1, %reg0, 12, %reg0, Mem:LD(4,4) [sunkaddr39 + 0]
        %reg1506<def> = MOV32rm %reg2037, 1, %reg0, 8, %reg0, Mem:LD(4,4) [sunkaddr42 + 0]
        %reg1486<def> = MOV32rr %reg1506
        %reg1486<def> = XOR32rr %reg1486, %reg1498, %EFLAGS<imp-def,dead>
        %reg1510<def> = MOV32rm %reg2038, 1, %reg0, 4, %reg0, Mem:LD(4,4) [sunkaddr45 + 0]

From linearscan's point of view, each of reg2036, 2037, and 2038 are separate registers, each is "killed" after a single use. The reloaded register is available and it's often clobbered right away. e.g. In thise case reg1498 is allocated EAX while reg2036 is allocated RAX. This means we end up with multiple reloads from the same stack slot in the same basic block.

Now linearscan recognize there are other reloads from same SS in the same BB. So it'll "downgrade" RAX (and its aliases) after reg2036 is allocated until the next reload (reg2037) is done. This greatly increase the likihood reloads from SS are reused.

This speeds up sha1 from OpenSSL by 5.8%. It is also an across the board win for SPEC2000 and 2006.

llvm-svn: 69585
2009-04-20 08:01:12 +00:00
Duncan Sands
870c1f4240 Now that BUILD_VECTOR operands are allowed to be
bigger than the vector element type, turn checking
of the operand type back on again, appropriately
adjusted.

llvm-svn: 69516
2009-04-19 06:40:30 +00:00
Chris Lattner
9b80af1a86 Fix PR3898, which manifests as failures on are an Xcore,
patch by Jakob Stoklund Olesen!

llvm-svn: 69472
2009-04-18 20:48:07 +00:00
Duncan Sands
d2ba02aa87 Don't try to make BUILD_VECTOR operands have the same
type as the vector element type: allow them to be of
a wider integer type than the element type all the way
through the system, and not just as far as LegalizeDAG.
This should be safe because it used to be this way
(the old type legalizer would produce such nodes), so
backends should be able to handle it.  In fact only
targets which have legal vector types with an illegal
promoted element type will ever see this (eg: <4 x i16>
on ppc).  This fixes a regression with the new type
legalizer (vec_splat.ll).  Also, treat SCALAR_TO_VECTOR
the same as BUILD_VECTOR.  After all, it is just a
special case of BUILD_VECTOR.

llvm-svn: 69467
2009-04-18 20:16:54 +00:00
Evan Cheng
1b6d7dc766 Add a new LiveInterval::overlaps(). It checks if the live interval overlaps a range specified by [Start, End).
llvm-svn: 69434
2009-04-18 08:52:15 +00:00
Dale Johannesen
f957aa4768 Inline asm's were still introducing bogus dependencies;
my earlier patch to this code only fixed half of it.

llvm-svn: 69408
2009-04-18 00:09:40 +00:00
Evan Cheng
2d5be54315 Teach spiller to unfold instructions which modref spill slot when a scratch
register is available and when it's profitable.

e.g.
     xorq  %r12<kill>, %r13
     addq  %rax, -184(%rbp)
     addq  %r13, -184(%rbp)
==>
     xorq  %r12<kill>, %r13
     movq  -184(%rbp), %r12
     addq  %rax, %r12
     addq  %r13, %r12
     movq  %r12, -184(%rbp)

Two more instructions, but fewer memory accesses. It can also open up
opportunities for more optimizations.

llvm-svn: 69341
2009-04-17 01:29:40 +00:00
Dan Gohman
397a4671f0 In the list-burr's pseudo two-addr dependency heuristics, don't
add dependencies on nodes with exactly one successor which is a
COPY_TO_REGCLASS node. In the case that the copy is coalesced
away, the dependence should be on the user of the copy, rather
than the copy itself.

llvm-svn: 69309
2009-04-16 20:59:02 +00:00
Dan Gohman
2165510df6 Handle SUBREG_TO_REG instructions with the same heuristics
as INSERT_SUBREG instructions in the list-burr scheduler.

llvm-svn: 69308
2009-04-16 20:57:10 +00:00
Devang Patel
d324ddbd7b Do not treat beginning of inlined scope as beginning of normal function scope if the location info is missing.
Insetad of doing ...
if (inlined_subroutine && known_location)
  DW_TAG_inline_subroutine
else
  DW_TAG_subprogram

do

if (inlined_subroutine) {
 if (known_location)
   DW_TAG_inline_subroutine
} else {
 DW_TAG_subprogram
}

llvm-svn: 69300
2009-04-16 17:55:30 +00:00
Devang Patel
6052d698f5 Record line number at the beginning of a func.start.
This line was accidently lost yesterday.

llvm-svn: 69286
2009-04-16 15:07:09 +00:00
Devang Patel
87488c2a88 In -fast mode do what FastISel does.
This code could use some refactoring help!

llvm-svn: 69254
2009-04-16 02:33:41 +00:00
Devang Patel
d9a9d5bdbb If FastISel is run and it has known DebugLoc then use it.
llvm-svn: 69253
2009-04-16 01:33:10 +00:00
Devang Patel
c6c6759194 If location where the function was inlined is not know then do not emit debug info describing inlinied region.
llvm-svn: 69252
2009-04-16 01:31:54 +00:00
Devang Patel
4a18de4193 s/RootDbgScope/FunctionDbgScope/g
llvm-svn: 69216
2009-04-15 20:41:31 +00:00
Devang Patel
21463f4a25 Add DISubprogram is not null check.
This fixes test/CodeGen//2009-01-21-invalid-debug-info.m test case.

llvm-svn: 69210
2009-04-15 20:11:08 +00:00
Dan Gohman
5555c4538b Generalize one of the SelectionDAG::ReplaceAllUsesWith overloads
to support replacing a node with another that has a superset of
the result types. Use this instead of calling
ReplaceAllUsesOfValueWith for each value.

llvm-svn: 69209
2009-04-15 20:06:30 +00:00
Devang Patel
d9d88a827d Check isInlinedSubroutine() before creating DW_TAG_inlined_subroutine.
llvm-svn: 69202
2009-04-15 19:42:57 +00:00
Dan Gohman
420019a18a Fix MachineInstr::getNumExplicitOperands to count
variadic operands correctly. Patch by Jakob Stoklund Olesen!

llvm-svn: 69190
2009-04-15 17:59:11 +00:00
Dan Gohman
e1e53b379b Move MachineRegisterInfo::setRegClass out of line.
llvm-svn: 69126
2009-04-15 01:19:35 +00:00
Dan Gohman
a885b48029 Move MachineJumpTableInfo::ReplaceMBBInJumpTables out of line.
llvm-svn: 69125
2009-04-15 01:18:49 +00:00