Commit Graph

445 Commits

Author SHA1 Message Date
Chris Lattner 6cb4559369 stop using method.
llvm-svn: 20603
2005-03-15 05:19:49 +00:00
Chris Lattner 531f9e92d4 This mega patch converts us from using Function::a{iterator|begin|end} to
using Function::arg_{iterator|begin|end}.  Likewise Module::g* -> Module::global_*.

This patch is contributed by Gabor Greif, thanks!

llvm-svn: 20597
2005-03-15 04:54:21 +00:00
Chris Lattner 1b032f59e7 Make this MUCH faster by avoiding a linear search in the symbol table code.
llvm-svn: 20479
2005-03-06 05:42:36 +00:00
Chris Lattner 7561ca1d15 Teach globalopt how memset/cpy/move affect memory, to allow better optimization.
llvm-svn: 20352
2005-02-27 18:58:52 +00:00
Chris Lattner 0ce80cd542 Fix spelling, patch contributed by Gabor Greif!
llvm-svn: 20343
2005-02-27 06:18:25 +00:00
Chris Lattner 25169caa80 make this more efficient. Scan up to 16 nodes, not the whole list.
llvm-svn: 20289
2005-02-23 16:53:04 +00:00
Alkis Evlogimenos c4a44c6b3d Localize globals if they are only used in main(). This replaces the
global with an alloca, which eventually gets promoted into a
register. This enables a lot of other optimizations later on.

llvm-svn: 20109
2005-02-10 18:36:30 +00:00
Chris Lattner d6a4492f81 Adjust to changes in APIs
llvm-svn: 19958
2005-02-01 01:23:31 +00:00
Chris Lattner a3f06fa2dd Switchinst takes a hint for the number of cases it will have.
llvm-svn: 19899
2005-01-29 00:38:45 +00:00
Jeff Cohen 3e62e7c68b Apply feedback from Chris.
llvm-svn: 19432
2005-01-10 04:23:32 +00:00
Chris Lattner 46fa04b531 Fix VS warnings.
llvm-svn: 19382
2005-01-08 19:45:31 +00:00
Jeff Cohen 677babc4d4 Add more missing createXxxPass functions.
llvm-svn: 19370
2005-01-08 17:21:40 +00:00
Chris Lattner 745196a5fc Properly implement copying of a global, fixing the 255.vortex & povray
failures from last night.

llvm-svn: 18832
2004-12-12 19:34:41 +00:00
Chris Lattner 1cbd5be7a1 Though the previous xform applies to literally dozens (hundreds?) of variables
in SPEC, the subsequent optimziations that we are after don't play with
with FP values, so disable this xform for them.  Really we just don't want
stuff like:

double G;   (always 0 or 412312.312)
  = G;

turning into:

bool G_b;
  = G_b ? 412312.312 : 0;

We'd rather just do the load.

-Chris

llvm-svn: 18819
2004-12-12 06:03:06 +00:00
Chris Lattner 40e4cec9ee If a variable can only hold two values, and is not already a bool, shrink it
down to actually BE a bool.  This allows simple value range propagation
stuff work harder, deleting comparisons in bzip2 in some hot loops.

This implements GlobalOpt/integer-bool.ll, which is the essence of the
loop condition distilled into a testcase.

llvm-svn: 18817
2004-12-12 05:53:50 +00:00
Chris Lattner 263b0a1669 Only cound if we actually made a change.
llvm-svn: 18800
2004-12-11 17:00:14 +00:00
Chris Lattner 9019e5cfa0 Implement stripping of debug symbols, making the --strip-debug options in
gccas/gccld more than just a noop.

llvm-svn: 18456
2004-12-03 16:22:08 +00:00
Chris Lattner e8ebcb3300 Initial reimplementation of the -strip pass, with a stub for implementing
-S

llvm-svn: 18440
2004-12-02 21:25:03 +00:00
Chris Lattner c0677c081d Implement a FIXME by checking to make sure that a malloc is not being used
in scary and unknown ways before we promote it.  This fixes the miscompilation
of 188.ammp that has been plauging us since a globalopt patch went in.

Thanks a ton to Tanya for helping me diagnose the problem!

llvm-svn: 18418
2004-12-02 07:11:07 +00:00
Chris Lattner 3b18139b3c Fix a minor bug where we set a var to initialized on malloc, not on store.
This doesn't fix anything that I'm aware of, just noticed it by inspection

llvm-svn: 18417
2004-12-02 06:25:58 +00:00
Chris Lattner 79e87e39eb Ignore debugger intrinsics when doing inlining size computations.
llvm-svn: 18109
2004-11-22 17:21:44 +00:00
Chris Lattner 28eeb73f2f If a global is just loaded and restored, realize that it is not changing
value.  This allows us to turn more globals into constants and eliminate them.
This patch implements GlobalOpt/load-store-global.llx.

Note that this patch speeds up 255.vortex from:

Output/255.vortex.out-cbe.time:program 7.640000
Output/255.vortex.out-llc.time:program 9.810000

to:

Output/255.vortex.out-cbe.time:program 7.250000
Output/255.vortex.out-llc.time:program 9.490000

Which isn't bad at all!

llvm-svn: 17746
2004-11-14 20:50:30 +00:00
Chris Lattner 5a8b003a09 Remove note to self
llvm-svn: 17734
2004-11-14 06:57:47 +00:00
Chris Lattner af555adc15 If a function always returns a constant, replace all calls sites with that
constant value.  This makes the return value dead and allows for
simplification in the caller.

This implements IPConstantProp/return-constant.ll

This triggers several dozen times throughout SPEC.

llvm-svn: 17730
2004-11-14 06:10:11 +00:00
Chris Lattner 9fa7f0ae0a Remove debugging code
llvm-svn: 17719
2004-11-13 23:32:53 +00:00
Chris Lattner 244031d306 Argument promotion transforms functions to unconditionally load their
argument pointers.  This is only valid to do if the function already
unconditionally loaded an argument or if the pointer passed in is known
to be valid.  Make sure to do the required checks.

This fixed ArgumentPromotion/control-flow.ll and the Burg program.

llvm-svn: 17718
2004-11-13 23:31:34 +00:00
Chris Lattner 9621dfab3f Actually, leave the check in. This prevents us from counting dead arguments
as IPCP opportunities.

llvm-svn: 17680
2004-11-11 07:47:54 +00:00
Chris Lattner 5fa696f8e4 Fix bug: IPConstantProp/deadarg.ll
llvm-svn: 17679
2004-11-11 07:46:29 +00:00
Chris Lattner c1d24cd859 Make IP Constant prop more aggressive about handling self recursive calls.
This implements IPConstantProp/recursion.ll

llvm-svn: 17666
2004-11-10 19:43:59 +00:00
Chris Lattner 0d3773d8b1 Do not let dead constant expressions hanging off of functions prevent IPCP.
This allows to elimination of a bunch of global pool descriptor args from
programs being pool allocated (and is also generally useful!)

llvm-svn: 17657
2004-11-09 20:47:30 +00:00
Chris Lattner 436285e75d Change this back so that I get stable numbers to reflect the change from the
nightly testers

llvm-svn: 17646
2004-11-09 08:05:23 +00:00
Chris Lattner 1f0a97c6cb Fix bug: 2004-11-08-FreeUseCrash.ll
llvm-svn: 17642
2004-11-09 05:10:56 +00:00
Chris Lattner 49fa1ecd04 VERY large functions that are only called from one place are not really
exciting to inline.  Only inline medium or small sized functions with a
single call site.

llvm-svn: 17588
2004-11-07 21:46:47 +00:00
Reid Spencer 57cbe39d1e Change Library Names Not To Conflict With Others When Installed
llvm-svn: 17286
2004-10-27 23:18:45 +00:00
Chris Lattner fe9abf92de *** empty log message ***
llvm-svn: 17161
2004-10-22 06:43:28 +00:00
Reid Spencer c1c320c335 We won't use automake
llvm-svn: 17155
2004-10-22 03:35:04 +00:00
Reid Spencer 6a11a75f31 Initial automake generated Makefile template
llvm-svn: 17136
2004-10-18 23:55:41 +00:00
Chris Lattner 88a8a329c3 Get this file compiling with VC++, patch contributed by Morten Ofstad. Thanks Morten!
llvm-svn: 17125
2004-10-18 15:43:46 +00:00
Chris Lattner 8e71c6a33d Add support for the undef value. Implement a new optimization based on globals
that are initialized with undef.  When promoting malloc to a global, start out
initialized to undef

llvm-svn: 17042
2004-10-16 18:09:00 +00:00
Chris Lattner 5d33e8e73a Fix a bug John tracked down in libstdc++ where we were incorrectly deleting
weak functions.  Thanks for finding this John!

llvm-svn: 16997
2004-10-14 19:53:50 +00:00
Reid Spencer ace94df71f Update to reflect changes in Makefile rules.
llvm-svn: 16950
2004-10-13 11:46:52 +00:00
Chris Lattner 004e250cd2 This patch implements two things (sorry).
First, it allows SRA of globals that have embedded arrays, implementing
GlobalOpt/globalsra-partial.llx.  This comes up infrequently, but does allow,
for example, deleting several stores to dead parts of globals in dhrystone.

Second, this implements GlobalOpt/malloc-promote-*.llx, which is the
following nifty transformation:

Basically if a global pointer is initialized with malloc, and we can tell
that the program won't notice, we transform this:

struct foo *FooPtr;
...
  FooPtr = malloc(sizeof(struct foo));
...
  FooPtr->A   FooPtr->B

Into:

struct foo FooPtrBody;
...
   FooPtrBody.A  FooPtrBody.B

This comes up occasionally, for example, the 'disp' global in 183.equake (where
the xform speeds the CBE version of the program up from 56.16s to 52.40s (7%)
on apoc), and the 'desired_accept', 'fixLRBT', 'macroArray', & 'key_queue'
globals in 300.twolf (speeding it up from 22.29s to 21.55s (3.4%)).

The nice thing about this xform is that it exposes the resulting global to
global variable optimization and makes alias analysis easier in addition to
eliminating a few loads.

llvm-svn: 16916
2004-10-11 05:54:41 +00:00
Chris Lattner e42eb31f7d Just because we cannot completely eliminate all uses of a global, we can
still optimize away all of the indirect calls and loads, etc from it.
This turns code like this:

  if (G != 0)
    G();

into
   if (G != 0)
     ActualCallee();

This triggers a couple of times in gcc and libstdc++.

llvm-svn: 16901
2004-10-10 23:14:11 +00:00
Reid Spencer 97327f05fc Initial version of automake Makefile.am file.
llvm-svn: 16893
2004-10-10 22:20:40 +00:00
Chris Lattner 604ed7aae8 Fix 2004-10-10-CastStoreOnce.llx, by adjusting types back if we strip off a cast
llvm-svn: 16878
2004-10-10 17:07:12 +00:00
Chris Lattner a0e769cc81 Implement GlobalOpt/deadglobal-2.llx, deletion of globals that are only
stored to, but are stored at variable indexes.  This occurs at least in
176.gcc, but probably others, and we should handle it for completeness.

llvm-svn: 16876
2004-10-10 16:47:33 +00:00
Chris Lattner cb9f152d8c Avoid calling use_size() which could (in theory) be expensive if the global
has a large number of users.  Instead, just keep track of whether we're
making changes as we do so.

This patch has no functionlity changes.

llvm-svn: 16874
2004-10-10 16:43:46 +00:00
Chris Lattner 09a527290d Eliminate global pointers that are only stored a single value and null if
we know that all uses of the global will trap if the pointer contained is
null.  In this case, we forward substitute the stored value to any uses.

This has the effect of devirtualizing trivial globals in trivial cases.  For
example, 164.gzip contains this:

gzip.h:extern   int (*read_buf) OF((char *buf, unsigned size));
bits.c: read_buf  = file_read;
deflate.c:    lookahead = read_buf((char*)window,
deflate.c:        n = read_buf((char*)window+strstart+lookahead, more);

Since read_buf has to point to file_read at every use, we just replace
the calls through read_buf with a direct call to file_read.

This occurs in several benchmarks, including 176.gcc and 164.gzip.  Direct
calls are good and stuff.

llvm-svn: 16871
2004-10-09 21:48:45 +00:00
Chris Lattner f369b38d55 Fix infinite loop due to iteration
llvm-svn: 16864
2004-10-09 03:32:52 +00:00
Chris Lattner 1b8d2957d3 If we found a dead global, we should at least delete it...
llvm-svn: 16858
2004-10-08 22:05:31 +00:00