Commit Graph

7117 Commits

Author SHA1 Message Date
Eli Friedman da90dd6d72 Add a new step to legalization to legalize vector math operations. This
will allow simplifying LegalizeDAG to eliminate type legalization.  (I 
have a patch to do that, but it's not quite finished; I'll commit it 
once it's finished and I've fixed any review comments for this patch.)  
See the comment at the beginning of 
lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp for more details on the
motivation for this patch.

llvm-svn: 72325
2009-05-23 12:35:30 +00:00
Duncan Sands d6fb6501e3 Add a new codegen pass that normalizes dwarf exception handling
code in preparation for code generation.  The main thing it does
is handle the case when eh.exception calls (and, in a future
patch, eh.selector calls) are far away from landing pads.  Right
now in practice you only find eh.exception calls close to landing
pads: either in a landing pad (the common case) or in a landing
pad successor, due to loop passes shifting them about.  However
future exception handling improvements will result in calls far
from landing pads:
(1) Inlining of rewinds.  Consider the following case:
In function @f:
...
  invoke @g to label %normal unwind label %unwinds
...
unwinds:
  %ex = call i8* @llvm.eh.exception()
...

In function @g:
...
  invoke @something to label %continue unwind label %handler
...
handler:
  %ex = call i8* @llvm.eh.exception()
... perform cleanups ...
  "rethrow exception"

Now inline @g into @f.  Currently this is turned into:
In function @f:
...
  invoke @something to label %continue unwind label %handler
...
handler:
  %ex = call i8* @llvm.eh.exception()
... perform cleanups ...
  invoke "rethrow exception" to label %normal unwind label %unwinds
unwinds:
  %ex = call i8* @llvm.eh.exception()
...

However we would like to simplify invoke of "rethrow exception" into
a branch to the %unwinds label.  Then %unwinds is no longer a landing
pad, and the eh.exception call there is then far away from any landing
pads.

(2) Using the unwind instruction for cleanups.
It would be nice to have codegen handle the following case:
  invoke @something to label %continue unwind label %run_cleanups
...
handler:
... perform cleanups ...
  unwind

This requires turning "unwind" into a library call, which
necessarily takes a pointer to the exception as an argument
(this patch also does this unwind lowering).  But that means
you are using eh.exception again far from a landing pad.

(3) Bugpoint simplifications.  When bugpoint is simplifying
exception handling code it often generates eh.exception calls
far from a landing pad, which then causes codegen to assert.
Bugpoint then latches on to this assertion and loses sight
of the original problem.

Note that it is currently rare for this pass to actually do
anything.  And in fact it normally shouldn't do anything at
all given the code coming out of llvm-gcc!  But it does fire
a few times in the testsuite.  As far as I can see this is
almost always due to the LoopStrengthReduce codegen pass
introducing pointless loop preheader blocks which are landing
pads and only contain a branch to another block.  This other
block contains an eh.exception call.  So probably by tweaking
LoopStrengthReduce a bit this can be avoided.

llvm-svn: 72276
2009-05-22 20:36:31 +00:00
Jay Foad 7d0479f2c2 Use v.data() instead of &v[0] when SmallVector v might be empty.
llvm-svn: 72210
2009-05-21 09:52:38 +00:00
Bill Wendling f99bd3a82b Temporarily revert r72191. It was causing an assert during llvm-gcc
bootstrapping.

llvm-svn: 72200
2009-05-21 00:04:55 +00:00
Bill Wendling 8658bb565d Minor code cleanup. No functionality change.
llvm-svn: 72198
2009-05-20 23:31:45 +00:00
Bill Wendling 744668d5af Merge 'ConstructFunctionDbgScope' and 'ConstructAbstractDbgScope'.
llvm-svn: 72197
2009-05-20 23:28:48 +00:00
Bill Wendling bcad77a8d5 Rename 'New*' methods to 'Create*' to be consistent. 'NewString' isn't used.
llvm-svn: 72196
2009-05-20 23:24:48 +00:00
Bill Wendling 806535f908 Add comment for emit section.
llvm-svn: 72195
2009-05-20 23:22:40 +00:00
Bill Wendling 480ff32120 Move 'Emit' methods down to their own place.
llvm-svn: 72194
2009-05-20 23:21:38 +00:00
Bill Wendling 2b128d70c5 Revert r72192. It was causing a build failure.
llvm-svn: 72193
2009-05-20 23:19:06 +00:00
Bill Wendling 8d7533d3e5 Do some mechanical changes. Combine the 'construct abastract dbg thingy' in with
the 'constract function dbg thingy'. Rename some methods to make them consistent
with the rest of the methods. Move the 'Emit' methods to the end of the file.

llvm-svn: 72192
2009-05-20 23:04:56 +00:00
Argyrios Kyrtzidis 2b59a5fc6c Introduce DebugScope which gets embedded into the machine instructions' DebugLoc.
DebugScope refers to a debug region, function or block.

llvm-svn: 72191
2009-05-20 22:57:17 +00:00
Eli Friedman 9030c35eb4 Fix for PR4235: to build a floating-point value from integer parts,
build an integer and cast that to a float.  This fixes a crash 
caused by trying to split an f32 into two f16's.

This changes the behavior in test/CodeGen/XCore/fneg.ll because that 
testcase now triggers a DAGCombine which converts the fneg into an integer
operation.  If someone is interested, it's probably possible to tweak 
the test to generate an actual fneg.

llvm-svn: 72162
2009-05-20 06:02:09 +00:00
Bill Wendling 670da9a22a Forward decls.
llvm-svn: 72114
2009-05-19 17:52:31 +00:00
Bill Wendling a3b8e84a57 Remove 'class' specifier.
llvm-svn: 72113
2009-05-19 17:51:26 +00:00
Bill Wendling a8705a95a6 Fix to compile on VS2008.
llvm-svn: 72112
2009-05-19 17:50:18 +00:00
Dan Gohman d697a2dd8e Remove the #ifndef NDEBUG from the FastISel debugging options. This
fixes dejagnu tests that use these options.

llvm-svn: 72094
2009-05-19 02:19:57 +00:00
Mike Stump ebf04f2843 Fix cmake builds.
llvm-svn: 72078
2009-05-19 00:18:14 +00:00
Bill Wendling ec78f1516d Don't set the "location" information for inlined functions' variables.
llvm-svn: 72064
2009-05-18 23:08:55 +00:00
Bill Wendling 1992f86733 Small code cleanup.
llvm-svn: 72057
2009-05-18 22:33:01 +00:00
Bill Wendling bc308569a3 RecordVariable is called each time a DECLARE node is encountered. For an inlined
function, this could be many, many times. We don't want to re-add variables to
that DIE for each time. We just want to add them once. Check to make sure that
we haven't added them already.

llvm-svn: 72047
2009-05-18 22:02:36 +00:00
Bob Wilson d9145fca7f Fix CodePlacementOpt::OptimizeIntraLoopEdges so that its return value
correctly indicates whether it changed the code.

llvm-svn: 72038
2009-05-18 21:02:18 +00:00
Lang Hames cf47d0134f New Spiller interface and trivial implementation.
llvm-svn: 72030
2009-05-18 19:03:16 +00:00
Bill Wendling d2dc9063d7 Revert last commit. It was wrong.
llvm-svn: 72026
2009-05-18 18:21:03 +00:00
Bill Wendling af7e400fda Don't call RegionInlinedFnEnd if our optimization level isn't -O0.
llvm-svn: 72024
2009-05-18 18:17:22 +00:00
Daniel Dunbar a8c1658619 Silence Release-Asserts warnings.
llvm-svn: 72011
2009-05-18 16:43:04 +00:00
Lang Hames 4030d8122d Prevented reg0 from being added to MBB live-in set, which was causing issues
for PostRAScheduler. 

llvm-svn: 71991
2009-05-17 23:50:36 +00:00
Jakob Stoklund Olesen 1c3da3a94b Rename MachineVerifier pass to avoid command line collision.
llvm-svn: 71987
2009-05-17 19:37:14 +00:00
Jakob Stoklund Olesen e61c7a3958 Verify that explicit definitions in the TargetInstrDesc are matched by
explicit register define operands.

llvm-svn: 71933
2009-05-16 07:25:20 +00:00
Jakob Stoklund Olesen c482d14565 Allow redefinition of reserved registers.
llvm-svn: 71932
2009-05-16 07:24:54 +00:00
Duncan Sands 83d008614f Put back a bit of expensive checking logic that
was overenthusiastically deleted in r70234.

llvm-svn: 71926
2009-05-16 04:14:29 +00:00
Duncan Sands bdbc98f3ef Pacify gcc-4.3, which suggests explicit braces here
to avoid an ambiguous else.

llvm-svn: 71924
2009-05-16 03:28:54 +00:00
Jakob Stoklund Olesen 36c027ab18 Pass to verify generated machine code.
The following is checked:

* Operand counts: All explicit operands must be present.

* Register classes: All physical and virtual register operands must be
  compatible with the register class required by the instruction descriptor.

* Register live intervals: Registers must be defined only once, and must be
  defined before use.

The machine code verifier is enabled with the command-line option
'-verify-machineinstrs', or by defining the environment variable
LLVM_VERIFY_MACHINEINSTRS to the name of a file that will receive all the
verifier errors.

llvm-svn: 71918
2009-05-16 00:33:53 +00:00
Bill Wendling 2f921f82e4 Split out the DwarfDebug module from the DwarfWriter module.
Again, no intendtional functionality change.

llvm-svn: 71854
2009-05-15 09:23:25 +00:00
Bill Wendling 1c5fd604b3 Mark class as hidden.
llvm-svn: 71850
2009-05-15 06:55:26 +00:00
Evan Cheng e23c109a67 Fix PR4210. Rewritter should track and update kills of sub-registers as well.
llvm-svn: 71848
2009-05-15 06:48:19 +00:00
Bill Wendling dd20b98c35 Move c'tor/d'tor to top of file.
llvm-svn: 71828
2009-05-15 01:18:50 +00:00
Bill Wendling d64cd2bb6e Split out the DwarfException class into its own file. No functionality change,
though the classes have been marked with "VISIBILITY_HIDDEN".

llvm-svn: 71827
2009-05-15 01:12:28 +00:00
Bill Wendling 47054f3d57 Split out the Dwarf writer stuff into separate files. This is a much more
logical/sane approach to organizing all of the stuff that goes into writing out
DWARF information. Honestly? even this is too complex for what it's supposed to
be doing.

Trivia: It *looks* like there would be functionality changes, however there aren't!
llvm-svn: 71821
2009-05-15 00:11:17 +00:00
Owen Anderson 672855eba8 Down with static variables!
Part one of many.

llvm-svn: 71785
2009-05-14 19:17:24 +00:00
Mike Stump 207fbf4320 Tag blocks with DW_AT_APPLE_block.
llvm-svn: 71784
2009-05-14 18:45:49 +00:00
Bob Wilson 857fe4e425 Revert r71744. I must not have understood this correctly, because the
assertion is failing for some tests.

llvm-svn: 71779
2009-05-14 18:08:41 +00:00
Lang Hames 2646b72424 Fix for PR4124. Make TwoAddressFormPass::FindLastUseInMBB return the real last use.
llvm-svn: 71769
2009-05-14 04:26:30 +00:00
Dan Gohman d4f63052c4 Add an assert to turn a segfault on an unsupported inline
asm construct into an assertion failure.

llvm-svn: 71757
2009-05-14 00:30:16 +00:00
Bill Wendling cdec744869 There's yet more ugliness (surprise!) in DebugInfo. This needs major reworking.
Basically, there was a situation where it was getting an empty vector and doing
a .back() on that. Which isn't cool.

llvm-svn: 71746
2009-05-13 23:55:49 +00:00
Bob Wilson b4c93b1ff7 The IfConverter::MergeBlocks method appears to be used only to merge a basic
block with its unique predecessor.  Change the code to assert if that is not
the case, instead of trying to handle situations where the block has
multiple predecessors.

llvm-svn: 71744
2009-05-13 23:54:13 +00:00
Jim Grosbach 4f915313ed Removing the HasBuiltinSetjmp flag and associated bits. Flagging the presence
of exception handling builtin sjlj targets in functions turns out not to 
be necessary. Marking the intrinsic implementation in the .td file as 
defining all registers is sufficient to get the context saved properly by 
the containing function.

llvm-svn: 71743
2009-05-13 23:50:53 +00:00
Bob Wilson 43f21dde1e Revert a portion of Dan's change r71018 that I'm convinced is wrong.
Dan was trying to catch the case where a basic block ends with a conditional
branch to the fall-through block.  In this case, all the instructions have
been moved out of FromBBI, leaving it empty.  It cannot end with a
conditional branch.  As the existing comment indicates, it will always fall
through to the next block.  If the block already had the next block (NBB)
listed as a successor, the preceding loop has a check for that and does not
remove it.  Thus, we need to check and add the successor only when it is
not already listed.

With Dan's change, the empty block often ends up with the fall-through
successor listed twice.  This exposed the problem in pr4195, where
CodePlacementOpt did not handle the same predecessor listed more than once.
It is also at least partially responsible for pr4202 and probably a similar
issue with Thumb branches being out of range.

llvm-svn: 71742
2009-05-13 23:48:58 +00:00
Bob Wilson 969bf71ca6 Merge adjacent conditional.
llvm-svn: 71741
2009-05-13 23:35:38 +00:00
Bob Wilson 43467d7daf Remove an unused variable.
llvm-svn: 71740
2009-05-13 23:31:30 +00:00
Bob Wilson 2371f4f70a Fix some typos and spelling and grammar, mostly in comments, but also one
field name.  No functional changes.

llvm-svn: 71739
2009-05-13 23:25:24 +00:00
Evan Cheng ab0d23396a Run code placement optimization for targets that want it (arm and x86 for now).
llvm-svn: 71726
2009-05-13 21:42:09 +00:00
Bill Wendling f7b83c7ae7 Change MachineInstrBuilder::addReg() to take a flag instead of a list of
booleans. This gives a better indication of what the "addReg()" is
doing. Remembering what all of those booleans mean isn't easy, especially if you
aren't spending all of your time in that code.

I took Jakob's suggestion and made it illegal to pass in "true" for the
flag. This should hopefully prevent any unintended misuse of this (by reverting
to the old way of using addReg()).

llvm-svn: 71722
2009-05-13 21:33:08 +00:00
Bill Wendling 1d601cdaf4 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 ce06bb8a53 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 1bc26286ef add ShrinkWrapping.cpp
llvm-svn: 71645
2009-05-13 06:27:38 +00:00
Lang Hames 8d4636d516 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 aeca45dd6f 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 85cca64dd7 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 df1aeeeb90 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 faec4fd030 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 9a968a8b17 Switch to using IRBuilder throughout.
llvm-svn: 71587
2009-05-12 20:27:44 +00:00
Evan Cheng c94de92c54 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 9e3d48f10d 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 6c60dbb3cb - 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 f094cbbcb9 Fixed PR4090.
llvm-svn: 71495
2009-05-11 23:14:13 +00:00
Dale Johannesen b571463363 Fix PR4188. TailMerging can't tolerate inexact
sucessor info.

llvm-svn: 71478
2009-05-11 21:54:13 +00:00
Evan Cheng 1988352fbd Apply patch review feedback.
llvm-svn: 71472
2009-05-11 20:53:52 +00:00
Evan Cheng 2b1b92189d Unbreak non-debug build.
llvm-svn: 71457
2009-05-11 18:40:52 +00:00
Evan Cheng c84bf99f58 Eliminate a compiler warning.
llvm-svn: 71456
2009-05-11 18:40:35 +00:00
Dan Gohman 9521cadff7 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 dd437d3a26 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 aa9c019461 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 59b1ca2a8f 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 d6280534e4 --- 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 d53af35629 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 9085126bee Oops. Don't forget to align single bb loops.
llvm-svn: 71363
2009-05-09 19:18:01 +00:00
Duncan Sands af9eaa830a 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 51fa9c7138 Enable loop bb placement optimization.
llvm-svn: 71291
2009-05-08 23:35:49 +00:00
Mike Stump 90b7cd6a40 Avoid warning in release-asserts build.
llvm-svn: 71275
2009-05-08 22:53:06 +00:00
Bill Wendling 8881780832 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 fa03b0084a 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 2dc580c954 Minor clean ups. No functionality change.
llvm-svn: 71256
2009-05-08 20:38:02 +00:00
Evan Cheng 6e9959e327 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 65a58168cc Factor out cycle-finder code and make it generic.
llvm-svn: 71241
2009-05-08 18:51:58 +00:00
Anton Korobeynikov c94dbf5ba0 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 e7a9661f31 Properly expand libcalls for urem / srem. Also make code more straightforward.
llvm-svn: 71238
2009-05-08 18:51:08 +00:00
Anton Korobeynikov e2b78115d4 Typo
llvm-svn: 71237
2009-05-08 18:50:54 +00:00
Evan Cheng 5b9b33bcac Reverse branch condition only when there is a conditional branch.
llvm-svn: 71214
2009-05-08 09:35:53 +00:00
Nick Lewycky b873ed672d Add explicit braces to disambiguate nested if/else. Removes a warning.
llvm-svn: 71211
2009-05-08 06:57:41 +00:00
Evan Cheng 2fa281106a 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 e20be4183c 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 5352454e6b Fix a comment (again).
llvm-svn: 71180
2009-05-07 21:20:42 +00:00
Bob Wilson 94c0a9fe8e Fix a comment.
llvm-svn: 71179
2009-05-07 21:19:45 +00:00
Dan Gohman 4bb6fa23cb 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 17f0f65499 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 58f3811300 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 143bae5dcd Code refactoring.
llvm-svn: 71151
2009-05-07 05:49:39 +00:00
Evan Cheng f356a89e92 Rename "loop aligner" pass to "code placement optimization" pass.
llvm-svn: 71150
2009-05-07 05:42:24 +00:00
Bill Wendling 5a2fff718d Just turn aggressive stack coloring off at -O3.
llvm-svn: 71140
2009-05-07 01:33:38 +00:00
Bill Wendling 6144f63bd5 Temporarily revert r71010. It was causing massive failures during self-hosting.
llvm-svn: 71138
2009-05-07 01:27:25 +00:00
Argyrios Kyrtzidis baf3fee885 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 4d11693f33 - 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 cfc0513080 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 49518d8f54 CMake: Updated lib/CodeGen/CMakeLists.txt.
llvm-svn: 71085
2009-05-06 14:56:40 +00:00
Duncan Sands 2338f6c57e 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 ab68cf24bb Renamed Spiller classes (plus uses and related files) to VirtRegRewriter.
llvm-svn: 71057
2009-05-06 02:36:21 +00:00
Dan Gohman bb2f10759e 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 9bf9002161 Enable stack coloring with regs at -O3.
llvm-svn: 71010
2009-05-05 20:30:36 +00:00
Chris Lattner 929b644b0f 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 6fc03634db 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 1ff2727c95 Move getInstrOperandRegClass from the scheduler to TargetInstrInfo.
llvm-svn: 70950
2009-05-05 00:30:09 +00:00
Evan Cheng dbfb102523 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 354b12259f 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 71fb950b73 Restore a comment.
llvm-svn: 70900
2009-05-04 19:23:45 +00:00
Argyrios Kyrtzidis 9ae29b2d8f -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 3f77805642 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 4b6072bcb8 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 79be34012f Revert r70803 for now, it causes a regression.
llvm-svn: 70811
2009-05-03 23:27:19 +00:00
Argyrios Kyrtzidis ce7196b903 -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 1de5cf548e Typo.
llvm-svn: 70792
2009-05-03 19:10:11 +00:00
Evan Cheng 210fc62a91 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 2745bc92fa Fix typo
llvm-svn: 70770
2009-05-03 13:19:57 +00:00
Anton Korobeynikov 05b7a7c8f8 Properly handle sdiv / udiv / srem / urem libcalls
llvm-svn: 70764
2009-05-03 13:18:16 +00:00
Anton Korobeynikov 399ad444fd Proper name 16 bit libcalls
llvm-svn: 70750
2009-05-03 13:14:08 +00:00
Anton Korobeynikov f3fc92d6fc Add libcall expansion for 16 and 128 bit muls
llvm-svn: 70749
2009-05-03 13:13:51 +00:00
Argyrios Kyrtzidis 97324cec99 -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 62a3124fb8 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 80b9abf8f4 Simplify more code and add timer stuff.
llvm-svn: 70539
2009-05-01 08:40:06 +00:00
Bill Wendling 03968bd796 Simplify more code.
llvm-svn: 70537
2009-05-01 08:35:12 +00:00
Bill Wendling 87cbaf4bc9 Simplify some code.
llvm-svn: 70534
2009-05-01 08:32:14 +00:00
Bill Wendling 1c24c74495 Fix whitespace. It was confusing me.
llvm-svn: 70533
2009-05-01 08:25:13 +00:00
Evan Cheng f8949a61bf Code clean up. Bye bye PhysRegTracker.
llvm-svn: 70524
2009-05-01 01:03:49 +00:00
Argyrios Kyrtzidis a5037484a4 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 050631c0a6 Join cross class copies using getCommonSubClass()
llvm-svn: 70513
2009-04-30 21:24:03 +00:00
Evan Cheng 007cbe91c5 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 fe0c648fee 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 5ab42e93c4 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 026e5d7667 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 7e6e352735 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 1971dc7007 MachineInstr::isRegTiedTo{Use,Def}Operand can safely be made const.
llvm-svn: 70408
2009-04-29 20:57:16 +00:00
Nate Begeman 39b59db245 Update comment, replace theoretically impossible check with an assert.
llvm-svn: 70391
2009-04-29 18:13:31 +00:00
Evan Cheng 9cce299cc8 spillPhysRegAroundRegDefsUses() may have invalidated iterators stored in fixed_ IntervalPtrs. Reset them.
llvm-svn: 70378
2009-04-29 07:16:34 +00:00
Nate Begeman 5f829d896d Implement review feedback for vector shuffle work.
llvm-svn: 70372
2009-04-29 05:20:52 +00:00
Sanjiv Gupta ccd30945f9 Add a public method called getAddressSpace() to the GlobalAddressSDNode.
llvm-svn: 70366
2009-04-29 04:43:24 +00:00
Chris Lattner 7d10386113 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 cfb4cae201 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 084669a1c9 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 e0eb5483d1 Move getMatchingSuperReg() out of coalescer and into TargetRegisterInfo.
llvm-svn: 70309
2009-04-28 18:29:27 +00:00
Jakob Stoklund Olesen fb9e23b217 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