Commit Graph

563 Commits

Author SHA1 Message Date
Reid Spencer
1ea099c5fd In debug builds, make a statistic for each kind of call optimization. This
helps track down what gets triggered in the pass so its easier to identify
good test cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21582 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-27 00:05:45 +00:00
Chris Lattner
bc9fa589ef This analysis doesn't take 'throwing' into consideration, it looks at
'unwinding'


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21581 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 23:53:25 +00:00
Reid Spencer
0ddf0d6bec Fix up the debug statement to actually use a newline .. radical concept.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21580 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 23:07:08 +00:00
Reid Spencer
ef99ea318e Uh, this isn't argpromotion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21579 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 23:05:17 +00:00
Reid Spencer
8f13261863 Add some debugging output so we can tell which calls are getting triggered
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21578 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 23:02:16 +00:00
Reid Spencer
47a3785062 No, seriously folks, memcpy really does return void.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21575 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 22:49:48 +00:00
Reid Spencer
a525f6d8f5 memcpy returns void!!!!!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21574 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 22:46:23 +00:00
Reid Spencer
43fd4d077f Fix some bugs found by running on llvm-test:
* MemCpyOptimization can only be optimized if the 3rd and 4th arguments are
  constants and we weren't checking for that.
* The result of llvm.memcpy (and llvm.memmove) is void* not sbyte*, put in
  a cast.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21570 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 19:55:57 +00:00
Reid Spencer
fcbdb9c85b Changes From Review Feedback:
* Have the SimplifyLibCalls pass acquire the TargetData and pass it down to
  the optimization classes so they can use it to make better choices for
  the signatures of functions, etc.
* Rearrange the code a little so the utility functions are closer to their
  usage and keep the core of the pass near the top of the files.
* Adjust the StrLen pass to get/use the correct prototype depending on the
  TargetData::getIntPtrType() result. The result of strlen is size_t which
  could be either uint or ulong depending on the platform.
* Clean up some coding nits (cast vs. dyn_cast, remove redundant items from
  a switch, etc.)
* Implement the MemMoveOptimization as a twin of MemCpyOptimization (they
  only differ in name).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21569 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 19:13:17 +00:00
Reid Spencer
20754ac069 * Merge get_GVInitializer and getCharArrayLength into a single function
named getConstantStringLength. This is the common part of StrCpy and
  StrLen optimizations and probably several others, yet to be written. It
  performs all the validity checks for looking at constant arrays that are
  supposed to be null-terminated strings and then computes the actual
  length of the string.
* Implement the MemCpyOptimization class. This just turns memcpy of 1, 2, 4
  and 8 byte data blocks that are properly aligned on those boundaries into
  a load and a store. Much more could be done here but alignment
  restrictions and lack of knowledge of the target instruction set prevent
  use from doing significantly more. That will have to be delegated to the
  code generators as they lower llvm.memcpy calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21562 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 07:45:18 +00:00
Reid Spencer
912401c3f6 * Implement StrLenOptimization
* Factor out commonalities between StrLenOptimization and StrCatOptimization
* Make sure that signatures return sbyte* not void*


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21559 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 05:24:00 +00:00
Reid Spencer
43e0baece3 Incorporate feedback from Chris:
* Change signatures of OptimizeCall and ValidateCalledFunction so they are
  non-const, allowing the optimization object to be modified. This is in
  support of caching things used across multiple calls.
* Provide two functions for constructing and caching function types
* Modify the StrCatOptimization to cache Function objects for strlen and
  llvm.memcpy so it doesn't regenerate them on each call site. Make sure
  these are invalidated each time we start the pass.
* Handle both a GEP Instruction and a GEP ConstantExpr
* Add additional checks to make sure we really are dealing with an arary of
  sbyte and that all the element initializers are ConstantInt or
  ConstantExpr that reduce to ConstantInt.
* Make sure the GlobalVariable is constant!
* Don't use ConstantArray::getString as it can fail and it doesn't give us
  the right thing. We must check for null bytes in the middle of the array.
* Use llvm.memcpy instead of memcpy so we can factor alignment into it.
* Don't use void* types in signatures, replace with sbyte* instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21555 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 03:26:15 +00:00
Reid Spencer
855adb1ac4 Changes due to code review and new implementation:
* Don't use std::string for the function names, const char* will suffice
* Allow each CallOptimizer to validate the function signature before
  doing anything
* Repeatedly loop over the functions until an iteration produces
  no more optimizations. This allows one optimization to insert a
  call that is optimized by another optimization.
* Implement the ConstantArray portion of the StrCatOptimization
* Provide a template for the MemCpyOptimization
* Make ExitInMainOptimization split the block, not delete everything
  after the return instruction.
(This covers revision 1.3 and 1.4, as the 1.3 comments were botched)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21548 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-25 21:20:38 +00:00
Reid Spencer
6cc0311c6d Lots of changes based on review and new functionality:
* Use a 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21546 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-25 21:11:48 +00:00
Reid Spencer
b7c11e3966 Post-Review Cleanup:
* Fix comments at top of file
* Change algorithm for running the call optimizations from n*n to something
  closer to n.
* Use a hash_map to store and lookup the optimizations since there will
  eventually (or potentially) be a large number of them. This gets lookup
  based on the name of the function to O(1). Each CallOptimizer now has a
  std::string member named func_name that tracks the name of the function
  that it applies to. It is this string that is entered into the hash_map
  for fast comparison against the function names encountered in the module.
* Cleanup some style issues pertaining to iterator invalidation
* Don't pass the Function pointer to the OptimizeCall function because if
  the optimization needs it, it can get it from the CallInst passed in.
* Add the skeleton for a new CallOptimizer, StrCatOptimizer which will
  eventually replace strcat's of constant strings with direct copies.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21526 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-25 03:59:26 +00:00
Reid Spencer
a7c049bf6a A new pass to provide specific optimizations for certain well-known library
calls. The pass visits all external functions in the module and determines
if such function calls can be optimized. The optimizations are specific to
the library calls involved. This initial version only optimizes calls to
exit(3) when they occur in main(): it changes them to ret instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21522 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-25 02:53:12 +00:00
Misha Brukman
fd93908ae8 Remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21427 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 23:48:37 +00:00
Chris Lattner
cb2d1a2dc2 Fix a bug where we would not promote calls to invokes if they occured in
the same block as the setjmp.  Thanks to Greg Pettyjohn for noticing this!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21403 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 16:46:46 +00:00
Chris Lattner
feb1550824 stop using method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20603 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-15 05:19:49 +00:00
Chris Lattner
e4d5c441e0 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!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20597 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-15 04:54:21 +00:00
Chris Lattner
82aa566795 Make this MUCH faster by avoiding a linear search in the symbol table code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20479 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-06 05:42:36 +00:00
Chris Lattner
35c81b0b12 Teach globalopt how memset/cpy/move affect memory, to allow better optimization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20352 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-27 18:58:52 +00:00
Chris Lattner
da895d6337 Fix spelling, patch contributed by Gabor Greif!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20343 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-27 06:18:25 +00:00
Chris Lattner
1f21ef1511 make this more efficient. Scan up to 16 nodes, not the whole list.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20289 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-23 16:53:04 +00:00
Alkis Evlogimenos
f64ea9d122 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20109 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-10 18:36:30 +00:00
Chris Lattner
d514d8294d Adjust to changes in APIs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19958 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-01 01:23:31 +00:00
Chris Lattner
667fdaef9f Switchinst takes a hint for the number of cases it will have.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19899 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-29 00:38:45 +00:00
Jeff Cohen
ecc1cef8bf Apply feedback from Chris.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19432 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-10 04:23:32 +00:00
Chris Lattner
4d0801b243 Fix VS warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19382 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-08 19:45:31 +00:00
Jeff Cohen
bf65268def Add more missing createXxxPass functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19370 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-08 17:21:40 +00:00
Chris Lattner
38c2556d0c Properly implement copying of a global, fixing the 255.vortex & povray
failures from last night.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18832 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-12 19:34:41 +00:00
Chris Lattner
077f1a8292 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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18819 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-12 06:03:06 +00:00
Chris Lattner
96a86b2993 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18817 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-12 05:53:50 +00:00
Chris Lattner
2ffa47b6bf Only cound if we actually made a change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18800 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-11 17:00:14 +00:00
Chris Lattner
dd0ecf6731 Implement stripping of debug symbols, making the --strip-debug options in
gccas/gccld more than just a noop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18456 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-03 16:22:08 +00:00
Chris Lattner
e3ad43c828 Initial reimplementation of the -strip pass, with a stub for implementing
-S


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18440 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-02 21:25:03 +00:00
Chris Lattner
fa07e4fc30 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!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18418 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-02 07:11:07 +00:00
Chris Lattner
bc965b97ad 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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18417 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-02 06:25:58 +00:00
Chris Lattner
8db93f18cc Ignore debugger intrinsics when doing inlining size computations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18109 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-22 17:21:44 +00:00
Chris Lattner
bd38edfe23 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!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17746 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-14 20:50:30 +00:00
Chris Lattner
6739eae7ea Remove note to self
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17734 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-14 06:57:47 +00:00
Chris Lattner
a990d94330 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17730 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-14 06:10:11 +00:00
Chris Lattner
4c989b6bd7 Remove debugging code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17719 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-13 23:32:53 +00:00
Chris Lattner
11a3d7b7dd 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17718 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-13 23:31:34 +00:00
Chris Lattner
d79c7b43f4 Actually, leave the check in. This prevents us from counting dead arguments
as IPCP opportunities.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17680 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-11 07:47:54 +00:00
Chris Lattner
3e062eacab Fix bug: IPConstantProp/deadarg.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17679 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-11 07:46:29 +00:00
Chris Lattner
ff1529b6cf Make IP Constant prop more aggressive about handling self recursive calls.
This implements IPConstantProp/recursion.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17666 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-10 19:43:59 +00:00
Chris Lattner
c890bfe1da 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!)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17657 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-09 20:47:30 +00:00
Chris Lattner
a8e475093a Change this back so that I get stable numbers to reflect the change from the
nightly testers


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17646 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-09 08:05:23 +00:00
Chris Lattner
52f20f8308 Fix bug: 2004-11-08-FreeUseCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17642 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-09 05:10:56 +00:00
Chris Lattner
ae18963a70 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17588 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-07 21:46:47 +00:00
Reid Spencer
6cb21d443e Change Library Names Not To Conflict With Others When Installed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17286 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-27 23:18:45 +00:00
Chris Lattner
e9ece2a746 *** empty log message ***
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17161 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-22 06:43:28 +00:00
Reid Spencer
cac731ecbe We won't use automake
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17155 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-22 03:35:04 +00:00
Reid Spencer
86d341b204 Initial automake generated Makefile template
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17136 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-18 23:55:41 +00:00
Chris Lattner
f26801b0e6 Get this file compiling with VC++, patch contributed by Morten Ofstad. Thanks Morten!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17125 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-18 15:43:46 +00:00
Chris Lattner
7a7ed0274d 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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17042 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-16 18:09:00 +00:00
Chris Lattner
b23cd2f688 Fix a bug John tracked down in libstdc++ where we were incorrectly deleting
weak functions.  Thanks for finding this John!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16997 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-14 19:53:50 +00:00
Reid Spencer
d96cb6eaa0 Update to reflect changes in Makefile rules.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16950 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-13 11:46:52 +00:00
Chris Lattner
30ba5690cf 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16916 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-11 05:54:41 +00:00
Chris Lattner
708148e41f 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++.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16901 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-10 23:14:11 +00:00
Reid Spencer
81f76b324e Initial version of automake Makefile.am file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16893 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-10 22:20:40 +00:00
Chris Lattner
8be8012ba4 Fix 2004-10-10-CastStoreOnce.llx, by adjusting types back if we strip off a cast
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16878 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-10 17:07:12 +00:00
Chris Lattner
c4d81b0388 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16876 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-10 16:47:33 +00:00
Chris Lattner
031955d462 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16874 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-10 16:43:46 +00:00
Chris Lattner
9b34a61019 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16871 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-09 21:48:45 +00:00
Chris Lattner
930f475604 Fix infinite loop due to iteration
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16864 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-09 03:32:52 +00:00
Chris Lattner
8f57e9c083 If we found a dead global, we should at least delete it...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16858 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-08 22:05:31 +00:00
Chris Lattner
a4be1dc0a1 * Pull out the meat of runOnModule into another function for clarity.
* Do not lead dangling dead constants prevent optimization
* Iterate global optimization while we're making progress.

These changes allow us to be more aggressive, handling cases like
GlobalOpt/iterate.llx without a problem (turning it into 'ret int 0').


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16857 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-08 20:59:28 +00:00
Chris Lattner
e40e2d1a71 We might as well delete the known-dead global sooner rather than later since
we know it is dead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16855 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-08 20:25:55 +00:00
Chris Lattner
670c889ac9 Implement SRA for global variables. This allows the other global variable
optimizations to trigger much more often.  This allows the elimination of
several dozen more global variables in Programs/External.  Note that we only
do this for non-constant globals: constant globals will already be optimized
out if the accesses to them permit it.

This implements Transforms/GlobalOpt/globalsra.llx


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16842 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-08 17:32:09 +00:00
Chris Lattner
cf4d2a5699 Improve comments, no functionality changes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16814 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-07 21:30:30 +00:00
Chris Lattner
3602549c3d Fix a bug in the safety analysis routine
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16804 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-07 06:01:25 +00:00
Chris Lattner
bc53e5e628 Comment cleanups
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16803 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-07 06:00:24 +00:00
Chris Lattner
7a90b68e5c * Rename pass to globalopt, since we do more than just constify
* Instead of handling dead functions specially, just nuke them.
* Be more aggressive about cleaning up after constification, in
  particular, handle getelementptr instructions and constantexprs.
* Be a little bit more structured about how we process globals.

*** Delete globals that are only stored to, and never read.  These are
    clearly not useful, so they should go.  This implements deadglobal.llx

This last one triggers quite a few times.  In particular, 2208 in the
external tests, 1865 of which are in 252.eon.  This shrinks eon from
1995094 to 1732341 bytes of bytecode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16802 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-07 04:16:33 +00:00
Chris Lattner
e47ba74b07 Implement GlobalConstifier/trivialstore.llx, and also do some
simplifications of the resultant program to avoid making later passes
do it all.

This allows us to constify globals that just have the same constant that
they are initialized stored into them.

Suprisingly this comes up ALL of the freaking time, dozens of times in
SPEC, 30 times in vortex alone.

For example, on 256.bzip2, it allows us to constify these two globals:

%smallMode = internal global ubyte 0             ; <ubyte*> [#uses=8]
%verbosity = internal global int 0               ; <int*> [#uses=49]

Which (with later optimizations) results in the bytecode file shrinking
from 82286 to 69686 bytes!  Lets hear it for IPO :)

For the record, it's nuking lots of "if (verbosity > 2) { do lots of stuff }"
code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16793 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-06 20:57:02 +00:00
Chris Lattner
23367a779c Disable the 'WARNING: Found global types that are not compatible' warning
that always prints when linking programs to libstdc++ :(


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16603 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-30 00:12:29 +00:00
Chris Lattner
b12914bfc0 'Pass' should now not be derived from by clients. Instead, they should derive
from ModulePass.  Instead of implementing Pass::run, then should implement
ModulePass::runOnModule.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16436 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-20 04:48:05 +00:00
Chris Lattner
f5afcabff8 Add comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16400 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-19 01:05:16 +00:00
Chris Lattner
0c0aa711b8 Fix the inliner to always delete any edges from the external call node to
a function being deleted.  Due to optimizations done while inlining, there
can be edges from the external call node to a function node that were not
apparent any longer.

This fixes the compiler crash while compiling 175.vpr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16399 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-18 21:37:03 +00:00
Chris Lattner
5eb6f6c829 Convert this pass to be a CallGraphSCCPass instead of a Pass, which eliminates
the worklist and makes it more efficient.  This does not change functionality
at all.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16390 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-18 00:34:13 +00:00
Chris Lattner
ebeb0cba94 Fix typo in comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16384 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-17 03:58:39 +00:00
Reid Spencer
551ccae044 Changes For Bug 352
Move include/Config and include/Support into include/llvm/Config,
include/llvm/ADT and include/llvm/Support. From here on out, all LLVM
public header files must be under include/llvm/.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16137 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-01 22:55:40 +00:00
Chris Lattner
4e4c444d5c If we are linking two global variables and they have the same size, do not
spew warnings, even if the types don't match.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15933 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-20 00:30:39 +00:00
Chris Lattner
77a2a9d9da Implement test/Regression/Transforms/GlobalConstifier/phi-select.llx
This allows more globals to be marked constant, particularly global arrays.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15735 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-14 20:57:17 +00:00
Chris Lattner
8528672e7e "extract" the block extractor pass from bugpoint (haha)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15714 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-13 03:05:17 +00:00
Chris Lattner
ee45f4cbe4 This patch makes the inliner refuse to inline functions that have alloca
instructions in the body of the function (not the entry block).  This fixes
test/Programs/SingleSource/Regression/C/2004-08-12-InlinerAndAllocas.c
and test/Programs/External/SPEC/CINT2000/176.gcc on zion.

This should obviously be pulled into 1.3.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15684 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-12 05:45:09 +00:00
Chris Lattner
54970c0328 Fix another really nasty regression that Anshu pointed out. In cases where
dangling constant users were removed from a function, causing it to be dead,
we never removed the call graph edge from the external node to the function.

In most cases, this didn't cause a problem (by luck).  This should definitely
go into 1.3


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15570 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-08 03:29:50 +00:00
Misha Brukman
47b14a4a6a Fix #includes of i*.h => Instructions.h as per PR403.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15334 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-29 17:30:56 +00:00
Chris Lattner
9ce300013d Ignore instructions that are in trivially dead functions. This allows us
to constify 14 globals instead of 4 in a trivial C++ testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15027 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-20 03:58:07 +00:00
Chris Lattner
8919cccc3d Fix a performance regression from the CPR patch, simplify code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14974 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 21:34:16 +00:00
Chris Lattner
96940cb522 Strip out and simplify some code. This also fixes the regression last
night compiling cfrac.  It did not realize that code like this:

int G; int *H = &G;

takes the address of G.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14973 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 19:56:20 +00:00
Reid Spencer
3188cab989 Avoid an unnecessary isa<Constant>.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14963 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 08:31:18 +00:00
Chris Lattner
25c6d68029 Remove useless statistic, fix some slightly broken logic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14958 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 07:22:58 +00:00
Chris Lattner
5827aebe64 Fix a rather serious bug in previous checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14957 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 06:56:58 +00:00
Reid Spencer
518310cb0d bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14953 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 00:44:37 +00:00
Reid Spencer
460f16c625 bug 122:
- Minimize redundant isa<GlobalValue> usage


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14948 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 00:32:14 +00:00
Reid Spencer
0c4a0418d3 bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage
- Rename methods to get ride of ConstantPointerRef usage


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14945 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 00:25:04 +00:00
Reid Spencer
3178158918 bug 122:
- Excise dead CPR procesing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14944 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 00:23:51 +00:00
Chris Lattner
fdd9f1facc Remove unused file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14460 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-28 00:46:58 +00:00
Chris Lattner
65f437ce7b These passes are long dead/obsolete. They never worked in the first place
and are a maintenence burden.  Nuke nuke nuke


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14457 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-28 00:44:18 +00:00
Misha Brukman
e5d6dab09e File depends on DSA, moved to lib/Analysis/DataStructure
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14325 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-22 18:11:38 +00:00
Chris Lattner
beabf45a69 Make order of argument addition deterministic. In particular, the layout
of ConstantInt objects in memory used to determine which order arguments
were added in in some cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14276 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-21 00:07:58 +00:00
Chris Lattner
cf5933a716 Fix the inliner to be deterministic, not letting its output depend on the
relative location of Function objects in memory.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14260 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-20 04:11:48 +00:00
Chris Lattner
e5ad50b2e8 Do not function resolve intrinsics. This prevents warnings and possible bad
things from happening due to

declare bool %llvm.isunordered(double, double)
declare bool %llvm.isunordered(float, float)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14219 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-18 05:50:48 +00:00
Chris Lattner
f70c22b019 Rename Type::PrimitiveID to TypeId and ::getPrimitiveID() to ::getTypeID()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14201 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-17 18:19:28 +00:00
John Criswell
e7b9a1a5f2 Fix a bug in the -deadtypeelim pass. The SymbolTable re-write changed it
to eliminate the wrong type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13855 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 21:16:46 +00:00
Reid Spencer
9231ac8b6f Convert to SymbolTable's new iteration interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13754 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:53:40 +00:00
Chris Lattner
b11a99bd39 Fix a bug in my previous checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13717 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-24 06:24:46 +00:00
Chris Lattner
befa499d45 Fix cases where we missed inlining some more obvious candidates because the
caller was in an SCC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13693 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:22:17 +00:00
Chris Lattner
74c68ffd5f Simplify the interface and remove an unneeded #include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13692 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:21:35 +00:00
Chris Lattner
9e7cc2f0d4 Fairly substantial changes to update the alias analysis we are querying as
we make the transformation.  This allows us to use interprocedural alias
analyses successfully.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13691 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:21:17 +00:00
Misha Brukman
7d248397a7 Clarify the logic: the flag is renamed to `deleteFn' to signify it will delete
the function instead of isolating it. This also means the condition is reversed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13112 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-22 23:00:51 +00:00
Misha Brukman
79906c9825 Add a flag to choose between isolating a function or deleting the function from
the Module. The default behavior keeps functionality as before: the chosen
function is the one that remains.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13111 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-22 22:52:22 +00:00
Chris Lattner
3e1358a9fa Fix an incredibly nasty iterator invalidation problem. I am too spoiled by ilists :)
Eventually it would be nice if CallGraph maintained an ilist of CallGraphNode's instead
of a vector of pointers to them, but today is not that day.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13100 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 20:44:33 +00:00
Chris Lattner
107fb18d89 Fix typeo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13089 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 14:23:18 +00:00
Chris Lattner
68d57e7ae8 REALLY fix PR324: don't delete linkonce functions until after the SCC traversal
is done, which avoids invalidating iterators in the SCC traversal routines


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13088 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-20 22:06:53 +00:00
Chris Lattner
5ad2b1d544 Fix PR324 and testcase: Inline/2004-04-20-InlineLinkOnce.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13080 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-20 20:20:59 +00:00
Chris Lattner
f1ab4b4eac Change the ExitBlocks list from being explicitly contained in the Loop
structure to being dynamically computed on demand.  This makes updating
loop information MUCH easier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13045 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:14:10 +00:00
Chris Lattner
ce1a3a292d Actually update the call graph as the inliner changes it. This allows us to
execute other CallGraphSCCPasses after the inliner without crashing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12861 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 05:37:29 +00:00
Chris Lattner
85eb157d96 Stop printing Function*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12857 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 04:06:56 +00:00
Chris Lattner
d08ddd3300 Simplify code a bit, and be sure to mark the external node as potentially throwing
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12856 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 04:06:38 +00:00
Chris Lattner
775cbdd51a Remove the "really gross hacks" that are there to deal with recursive functions.
Now we collect all of the call sites we are interested in inlining, then inline
them.  This entirely avoids issues with trying to inline a call site we got by
inlining another call site.  This also eliminates iterator invalidation issues.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12770 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-08 06:34:31 +00:00
Chris Lattner
f6e43bc796 Add statistics to the loop extractor. The loop extractor has successfully
extracted all 63 loops for Olden/bh without crashing and without
miscompiling the program!!!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12491 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 05:46:10 +00:00
Chris Lattner
fdded9f95a Fix problem with PHI nodes having multiple predecessors from different
exit nodes


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12490 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 05:43:18 +00:00
Chris Lattner
369287bab5 The code extractor needs dominator info. Provide it
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12483 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 03:48:06 +00:00
Chris Lattner
6dd196f762 Restore old inlining heuristic. As the comment indicates, this is a nasty
horrible hack.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12423 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 06:38:14 +00:00
Chris Lattner
5156c39d64 Fix several bugs in the loop extractor. In particular, subloops were never
extracted, and a function that contained a single top-level loop never had
the loop extracted, regardless of how much non-loop code there was.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12403 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 00:02:02 +00:00
Chris Lattner
41bc0b069c Split into two passes. Now there is the general loop extractor, usable on
the command line, and the single loop extractor, usable by bugpoint


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12390 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 20:01:36 +00:00
Chris Lattner
97836fad2c Passes don't print stuff!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12385 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 04:17:53 +00:00
Chris Lattner
16d0eb0468 FunctionPass's should not define their own 'run' method.
Require 'simplified' loops, not just raw natural loops.  This fixes
CodeExtractor/2004-03-13-LoopExtractorCrash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12381 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 04:01:06 +00:00
Chris Lattner
1e3cb34753 Move prototype to IPO.h instead of Scalar.h
Make sure that the file interface header (IPO.h) is included first
remove dead #incldue


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12375 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 02:37:16 +00:00
Chris Lattner
efddcfa0df Indent anon namespace properly, add copyright block
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12373 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 02:34:07 +00:00
Chris Lattner
c3c8703c3b Move to the IPO library. Utils shouldn't contain passes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12372 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 02:32:27 +00:00
Chris Lattner
a2dc727ac4 DemoteRegToStack got moved from DemoteRegToStack.h to Local.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12368 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 02:13:38 +00:00
Chris Lattner
619d3544b1 This change makes two big adjustments.
* Be a lot more accurate about what the effects will be when inlining a call
   to a function when an argument is an alloca.
 * Dramatically reduce the penalty for inlining a call in a large function.
   This heuristic made it almost impossible to inline a function into a large
   function, no matter how small the callee is.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12363 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-13 23:15:45 +00:00
Chris Lattner
9440db8866 Implement ArgumentPromotion/aggregate-promote.ll
This allows pointers to aggregate objects, whose elements are only read, to
be promoted and passed in by element instead of by reference.  This can
enable a LOT of subsequent optimizations in the caller function.

It's worth pointing out that this stuff happens a LOT of C++ programs, because
objects in templates are generally passed around by reference.  When these
templates are instantiated on small aggregate or scalar types, however, it is
more efficient to pass them in by value than by reference.

This transformation triggers most on C++ codes (e.g. 334 times on eon), but
does happen on C codes as well.  For example, on mesa it triggers 72 times,
and on gcc it triggers 35 times.  this is amazingly good considering that
we are using 'basicaa' so far.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12202 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-08 01:04:36 +00:00
Chris Lattner
86a734bd40 Implement: ArgumentPromotion/chained.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12200 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-07 22:52:53 +00:00
Chris Lattner
7db5a6df78 Fix another minor bug, exposed by perlbmk
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12198 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-07 22:43:27 +00:00
Chris Lattner
7e6f5090af Fix a minor bug and turn debug output into, well, debug output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12195 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-07 21:54:50 +00:00
Chris Lattner
ed570a7dca New LLVM pass: argument promotion. This version only handles simple scalar
variables.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12193 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-07 21:29:54 +00:00
Misha Brukman
99cc88bb64 * Remove function to find "main" in a Module, there's a method for that
* Removing extraneous empty space and empty comment lines


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12014 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-29 23:09:10 +00:00
Chris Lattner
7d90a2738e setcond instructions don't have aliasing implications.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11919 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-27 18:09:25 +00:00
Chris Lattner
4f77caaa3d Since LLVM uses structure type equivalence, it isn't useful to keep around
multiple type names for the same structural type.  Make DTE eliminate all
but one of the type names


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11879 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-26 20:02:23 +00:00
Chris Lattner
079236d1c9 My faith in programmers has been found to be totally misplaced. One would
assume that if they don't intend to write to a global variable, that they
would mark it as constant.  However, there are people that don't understand
that the compiler can do nice things for them if they give it the information
it needs.

This pass looks for blatently obvious globals that are only ever read from.
Though it uses a trivially simple "alias analysis" of sorts, it is still able
to do amazing things to important benchmarks.  253.perlbmk, for example,
contains several ***GIANT*** function pointer tables that are not marked
constant and should be.  Marking them constant allows the optimizer to turn
a whole bunch of indirect calls into direct calls.  Note that only a link-time
optimizer can do this transformation, but perlbmk does have several strings
and other minor globals that can be marked constant by this pass when run
from GCCAS.

176.gcc has a ton of strings and large tables that are marked constant, both
at compile time (38 of them) and at link time (48 more).  Other benchmarks
give similar results, though it seems like big ones have disproportionally
more than small ones.

This pass is extremely quick and does good things.  I'm going to enable it
in gccas & gccld.  Not bad for 50 SLOC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11836 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-25 21:34:36 +00:00
Chris Lattner
0db085baec Intrinsic functions cannot throw
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11383 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-13 16:46:46 +00:00
Chris Lattner
68b86f4f41 Don't depend on auto data conversion
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11229 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-09 05:16:30 +00:00
Chris Lattner
d21cd809b6 Adjust to the changed StructType interface. In particular, getElementTypes() is gone.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11228 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-09 04:37:31 +00:00
Chris Lattner
d5d8996720 Start using the new and improve interface to FunctionType arguments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11224 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-09 04:14:01 +00:00
Chris Lattner
aeb2a1d708 rename the "exceptional" destination of an invoke instruction to the 'unwind' dest
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11202 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-08 21:44:31 +00:00