1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-26 14:33:02 +02:00
Commit Graph

505 Commits

Author SHA1 Message Date
John Criswell
a6620d4a6e Doh! Forgot to LLVMify the style.
llvm-svn: 22312
2005-06-29 15:57:50 +00:00
John Criswell
1bafe064da Basic fix for PR#591; don't convert an fprintf() to an fwrite() if there
is a mismatch in their character type pointers (i.e. fprintf() prints an
array of ubytes while fwrite() takes an array of sbytes).
We can probably do better than this (such as casting the ubyte to an
sbyte).

llvm-svn: 22310
2005-06-29 15:03:18 +00:00
Chris Lattner
eb08628106 add a debug type
llvm-svn: 22277
2005-06-24 16:00:46 +00:00
Reid Spencer
a6012f9023 Fix a problem with the strcmp optimization checking the wrong string and
not casting to the correct type.

llvm-svn: 22250
2005-06-18 17:46:28 +00:00
Chris Lattner
4cff3f786f Fix PR575, patch provided by John Mellor-Crummey. Thanks!
llvm-svn: 22223
2005-06-15 22:49:30 +00:00
Chris Lattner
369ba5da69 Do not promote globals only used by main to locals if there are constantexprs
or other uses hanging off of them.

llvm-svn: 22219
2005-06-15 21:11:48 +00:00
Chris Lattner
092a738e18 Fix a problem on 64-bit targets where we passed (int)0 through ... instead of
(void*)0.

llvm-svn: 22205
2005-06-09 02:59:00 +00:00
Reid Spencer
59580db70f Make the registration hash_map static. No other module needs it. Also,
document what its for a little better.

llvm-svn: 22164
2005-05-21 01:27:04 +00:00
Reid Spencer
6c0f6b6458 Adjust the file comment to read a little easier.
llvm-svn: 22163
2005-05-21 00:57:44 +00:00
Reid Spencer
5161c39bfe Make sure ... arguments are casted to sbyte* where needed.
llvm-svn: 22162
2005-05-21 00:39:30 +00:00
Reid Spencer
0a43070283 Add a "brief" comment for CastToCStr
llvm-svn: 22161
2005-05-21 00:23:23 +00:00
Chris Lattner
d7d4a57a4f Fix mismatched type problem that crashed on cases like this:
sprintf(P, "%s", X);

Where X is not an sbyte*.  This fixes the bug JohnMC reported on llvm-bugs.

llvm-svn: 22159
2005-05-20 22:22:25 +00:00
Chris Lattner
df9c75fb12 teach the inliner about coldcc and noreturn functions
llvm-svn: 22113
2005-05-18 04:30:33 +00:00
Reid Spencer
720fbd937a Don't look for __builtin_ffs, we'll never see it from llvm-gcc and there's
not reason to include it for other front ends.

llvm-svn: 22070
2005-05-15 21:27:34 +00:00
Reid Spencer
58ad53e9d3 Provide this optimization as well:
ffs(x) -> (x == 0 ? 0 : 1+llvm.cttz(x))

llvm-svn: 22068
2005-05-15 21:19:45 +00:00
Reid Spencer
24104523b5 Duh .. you actually have to #include Config/config.h before you can test
for one of the values that it defines!

llvm-svn: 22058
2005-05-15 17:20:47 +00:00
Reid Spencer
9cd1000c52 Changes for ffs lib call simplification:
* Check for availability of ffsll call in configure script
* Support ffs, ffsl, and ffsll conversion to constant value if the argument
  is constant.

llvm-svn: 22027
2005-05-14 16:42:52 +00:00
Chris Lattner
2d9c054f4e Preserve calling conventions when doing IPO
llvm-svn: 21798
2005-05-09 01:05:50 +00:00
Chris Lattner
b57ab2e975 Convert non-address taken functions with C calling conventions to fastcc.
llvm-svn: 21791
2005-05-08 22:18:06 +00:00
Reid Spencer
b4fdf14d34 * Add two strlen optimizations:
strlen(x) != 0 -> *x != 0
    strlen(x) == 0 -> *x == 0
* Change nested statistics to use style of other LLVM statistics so that
  only the name of the optimization (simplify-libcalls) is used as the
  statistic name, and the description indicates which specific all is
  optimized. Cuts down on some redundancy and saves a few bytes of space.
* Make note of stpcpy optimization that could be done.

llvm-svn: 21766
2005-05-07 20:15:59 +00:00
Reid Spencer
65d553cd03 Don't increment the counter unless the debug flag is set.
llvm-svn: 21762
2005-05-07 04:59:45 +00:00
Chris Lattner
3d4098b1e0 preserve the tail marker
llvm-svn: 21734
2005-05-06 06:46:58 +00:00
Chris Lattner
99db0ab3df Wrap long lines
llvm-svn: 21720
2005-05-06 05:34:40 +00:00
Chris Lattner
adcc532d05 Fix a bug compimling Ruby, fixing this testcase:
LowerSetJmp/2005-05-05-OldUses.ll

llvm-svn: 21696
2005-05-05 15:47:43 +00:00
Reid Spencer
c564fd819c Implement the IsDigitOptimization for simplifying calls to the isdigit
library function:
  isdigit(chr) -> 0 or 1 if chr is constant
  isdigit(chr) -> chr - '0' <= 9 otherwise

Although there are many calls to isdigit in llvm-test, most of them are
compiled away by macros leaving only this:

2 MultiSource/Applications/hexxagon

llvm-svn: 21688
2005-05-04 18:58:28 +00:00
Reid Spencer
8d2736401b * Correct the function prototypes for some of the functions to match the
actual spec (int -> uint)
* Add the ability to get/cache the strlen function prototype.
* Make sure generated values are appropriately named for debugging purposes
* Add the SPrintFOptimiation for 4 casts of sprintf optimization:
    sprintf(str,cstr) -> llvm.memcpy(str,cstr) (if cstr has no %)
    sprintf(str,"")   -> store sbyte 0, str
    sprintf(str,"%s",src) -> llvm.memcpy(str,src) (if src is constant)
    sprintf(str,"%c",chr) -> store chr, str   ; store sbyte 0, str+1

The sprintf optimization didn't fire as much as I had hoped:

  2 MultiSource/Applications/SPASS
  5 MultiSource/Benchmarks/McCat/18-imp
 22 MultiSource/Benchmarks/Prolangs-C/TimberWolfMC
  1 MultiSource/Benchmarks/Prolangs-C/assembler
  6 MultiSource/Benchmarks/Prolangs-C/unix-smail
  2 MultiSource/Benchmarks/mediabench/mpeg2/mpeg2dec

llvm-svn: 21679
2005-05-04 03:20:21 +00:00
Reid Spencer
f52c228416 Implement optimizations for the strchr and llvm.memset library calls.
Neither of these activated as many times as was hoped:

strchr:
9 MultiSource/Applications/siod
1 MultiSource/Applications/d
2 MultiSource/Prolangs-C/archie-client
1 External/SPEC/CINT2000/176.gcc/176.gcc

llvm.memset:
no hits

llvm-svn: 21669
2005-05-03 07:23:44 +00:00
Reid Spencer
0c484ea7de Avoid garbage output in the statistics display by ensuring that the
strings passed to Statistic's constructor are not destructable. The stats
are printed during static destruction and the SimplifyLibCalls module was
getting destructed before the statistics.

llvm-svn: 21661
2005-05-03 02:54:54 +00:00
Reid Spencer
123f4e393f Add the StrNCmpOptimization which is similar to strcmp.
Unfortunately, this optimization didn't trigger on any llvm-test tests.

llvm-svn: 21660
2005-05-03 01:43:45 +00:00
Reid Spencer
a5fcd1660f Implement the fprintf optimization which converts calls like this:
fprintf(F,"hello") -> fwrite("hello",strlen("hello"),1,F)
  fprintf(F,"%s","hello") -> fwrite("hello",strlen("hello"),1,F)
  fprintf(F,"%c",'x') -> fputc('c',F)

This optimization fires severals times in llvm-test:

313 MultiSource/Applications/Burg
302 MultiSource/Benchmarks/Prolangs-C/TimberWolfMC
189 MultiSource/Benchmarks/Prolangs-C/mybison
175 MultiSource/Benchmarks/Prolangs-C/football
130 MultiSource/Benchmarks/Prolangs-C/unix-tbl

llvm-svn: 21657
2005-05-02 23:59:26 +00:00
Reid Spencer
f7511e4fe2 Fix a comment that stated the wrong thing.
llvm-svn: 21638
2005-04-30 06:45:47 +00:00
Reid Spencer
cc551c4345 * Don't depend on "guessing" what a FILE* is, just require that the actual
type be obtained from a CallInst we're optimizing.
* Make it possible for getConstantStringLength to return the ConstantArray
  that it extracts in case the content is needed by an Optimization.
* Implement the strcmp optimization
* Implement the toascii optimization

This pass is now firing several to many times in the following MultiSource
tests:

Applications/Burg      -   7 (strcat,strcpy)
Applications/siod      -  13 (strcat,strcpy,strlen)
Applications/spiff     - 120 (exit,fputs,strcat,strcpy,strlen)
Applications/treecc    -  66 (exit,fputs,strcat,strcpy)
Applications/kimwitu++ -  34 (strcmp,strcpy,strlen)
Applications/SPASS     - 588 (exit,fputs,strcat,strcpy,strlen)

llvm-svn: 21626
2005-04-30 03:17:54 +00:00
Reid Spencer
a32eb179ed Implement the optimizations for "pow" and "fputs" library calls.
llvm-svn: 21618
2005-04-29 09:39:47 +00:00
Jeff Cohen
6dccb593c9 Consistently use 'class' to silence VC++
llvm-svn: 21612
2005-04-29 03:05:44 +00:00
Reid Spencer
e7eb17c64b Remove from the TODO list those optimizations that are already handled by
constant folding implemented in lib/Transforms/Utils/Local.cpp.

llvm-svn: 21604
2005-04-28 18:05:16 +00:00
Reid Spencer
b5d4b854ea Document additional libcall transformations that need to be written.
Help Wanted!

There's a lot of them to write.

llvm-svn: 21603
2005-04-28 04:40:06 +00:00
Reid Spencer
49cfe25457 Doxygenate.
llvm-svn: 21602
2005-04-27 21:29:20 +00:00
Chris Lattner
96704dee49 remove 'statement with no effect' warning
llvm-svn: 21600
2005-04-27 20:12:17 +00:00
Reid Spencer
b7cff5d9d1 More Cleanup:
* Name the instructions by appending to name of original
* Factor common part out of a switch statement.

llvm-svn: 21597
2005-04-27 17:46:54 +00:00
Reid Spencer
1eb67fef62 This is a cleanup commit:
* Correct stale documentation in a few places
* Re-order the file to better associate things and reduce line count
* Make the pass thread safe by caching the Function* objects needed by the
  optimizers in the pass object instead of globally.
* Provide the SimplifyLibCalls pass object to the optimizer classes so they
  can access cached Function* objects and TargetData info
* Make sure the pass resets its cache if the Module passed to runOnModule
  changes
* Rename CallOptimizer LibCallOptimization. All the classes are named
  *Optimization while the objects are *Optimizer.
* Don't cache Function* in the optimizer objects because they could be used
  by multiple PassManager's running in multiple threads
* Add an optimization for strcpy which is similar to strcat
* Add a "TODO" list at the end of the file for ideas on additional libcall
  optimizations that could be added (get ideas from other compilers).

Sorry for the huge diff. Its mostly reorganization of code. That won't
happen again as I believe the design and infrastructure for this pass is
now done or close to it.

llvm-svn: 21589
2005-04-27 07:54:40 +00:00
Chris Lattner
792ae155ad detect functions that never return, and turn the instruction following a
call to them into an 'unreachable' instruction.

This triggers a bunch of times, particularly on gcc:

gzip: 36
gcc: 601
eon: 12
bzip: 38
llvm-svn: 21587
2005-04-27 04:52:23 +00:00
Reid Spencer
e3b60245eb Prefix the debug statistics so they group together.
llvm-svn: 21583
2005-04-27 00:20:23 +00:00
Reid Spencer
27f80b8c96 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.

llvm-svn: 21582
2005-04-27 00:05:45 +00:00
Chris Lattner
bd077a1945 This analysis doesn't take 'throwing' into consideration, it looks at
'unwinding'

llvm-svn: 21581
2005-04-26 23:53:25 +00:00
Reid Spencer
ddef064121 Fix up the debug statement to actually use a newline .. radical concept.
llvm-svn: 21580
2005-04-26 23:07:08 +00:00
Reid Spencer
7f06064798 Uh, this isn't argpromotion.
llvm-svn: 21579
2005-04-26 23:05:17 +00:00
Reid Spencer
42906defb1 Add some debugging output so we can tell which calls are getting triggered
llvm-svn: 21578
2005-04-26 23:02:16 +00:00
Reid Spencer
47a20efcb0 No, seriously folks, memcpy really does return void.
llvm-svn: 21575
2005-04-26 22:49:48 +00:00
Reid Spencer
270f03e49e memcpy returns void!!!!!
llvm-svn: 21574
2005-04-26 22:46:23 +00:00
Reid Spencer
303c65cea6 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.

llvm-svn: 21570
2005-04-26 19:55:57 +00:00