Commit Graph

1158 Commits

Author SHA1 Message Date
Devang Patel b5e867acff Add new helper pass that strips all symbol names except debugging information.
This pass makes it easier to test wheter debugging info. influences optimization passes or not.

llvm-svn: 59552
2008-11-18 21:34:39 +00:00
Devang Patel 3b7a2be88e Remove even more llvm.dbg variables.
Remove all dead globals from llvm.metadata.
Ignore linkonce linkage for selected llvm.dbg values.

llvm-svn: 59547
2008-11-18 21:13:41 +00:00
Torok Edwin 026259faeb If SI->size() is 0, we are not allowed to dereference ->begin().
This fixed PR3078.

llvm-svn: 59416
2008-11-16 17:21:25 +00:00
Chris Lattner f8f6270f14 simplify loop
llvm-svn: 59406
2008-11-16 06:35:18 +00:00
Devang Patel 8ada1d5de5 Refactor code.
Strip debug information before stripping symbol names. 

llvm-svn: 59328
2008-11-14 22:49:37 +00:00
Devang Patel 3dd51c5c62 Really remove all debug information.
llvm-svn: 59208
2008-11-13 01:28:40 +00:00
Devang Patel 95b18126ee Use actual function name in comments.
llvm-svn: 59063
2008-11-11 19:16:41 +00:00
Devang Patel f0ef35738c Do now allow InlineAlways pass to remove dead functions.
llvm-svn: 58744
2008-11-05 01:39:16 +00:00
Andrew Lenharth 348f3fa6a7 add a period at the end of the comment, ignoring the fact that the comment would be hard pressed to be considered a sentence, but if it makes Bill happy...
llvm-svn: 58630
2008-11-03 19:29:29 +00:00
Andrew Lenharth 45b86322f2 Ensure that we are checking only calls to the function we are interested in specializing
llvm-svn: 58615
2008-11-03 16:05:35 +00:00
Nick Lewycky 3c6d34a7f0 Changes from Duncan's review:
* merge two weak functions by making them both alias a third non-weak fn
 * don't reimplement CallSite::hasArgument
 * whitelist the safe linkage types

llvm-svn: 58568
2008-11-02 16:46:26 +00:00
Duncan Sands cede1e035c Get this building on 64 bit machines (error:
cast from ‘const llvm::PointerType*’ to ‘unsigned int’
loses precision).

llvm-svn: 58561
2008-11-02 09:00:33 +00:00
Oscar Fuentes 0433be6feb CMake: added a source file.
llvm-svn: 58559
2008-11-02 06:01:39 +00:00
Nick Lewycky d01d42e76c Add a new MergeFunctions pass. It finds identical functions and merges them.
This triggers only 60 times in llvm-test (look at .llvm.bc, not .linked.rbc)
and so it probably wont be turned on by default. Also, may of those are likely
to go away when PR2973 is fixed.

llvm-svn: 58557
2008-11-02 05:52:50 +00:00
Daniel Dunbar 3933e66a89 Add InlineCost class for represent the estimated cost of inlining a
function.
 - This explicitly models the costs for functions which should
   "always" or "never" be inlined. This fixes bugs where such costs
   were not previously respected.

llvm-svn: 58450
2008-10-30 19:26:59 +00:00
Daniel Dunbar e7fbf9f425 Factor shouldInline method out of Inliner.
- No functionality change.

llvm-svn: 58355
2008-10-29 01:02:02 +00:00
Daniel Dunbar cc20455346 Assorted comment/naming fixes, 80-col violations, and reindentation.
- No functionality change.

llvm-svn: 58352
2008-10-28 23:24:26 +00:00
Dan Gohman fa29b67aee Fix a bug that prevented llvm-extract -delete from working.
llvm-svn: 57864
2008-10-21 01:08:07 +00:00
Nuno Lopes 06c67f88d7 dont specialize weak functions and the like
llvm-svn: 57305
2008-10-08 18:45:59 +00:00
Duncan Sands 1d35e9aebe Ignore loads from and stores to local memory (i.e. allocas)
when deciding whether to mark a function readnone/readonly.
Since the pass is currently run before SROA, this may be
quite helpful.  Requested by Chris on IRC.

llvm-svn: 57050
2008-10-04 13:24:24 +00:00
Dan Gohman e21903987f Clean up some multiple-return-value code that is no longer
applicable.

llvm-svn: 57033
2008-10-03 22:21:24 +00:00
Duncan Sands 3a813a5d3f Teach internalize to preserve the callgraph.
Why?  Because it was there!

llvm-svn: 56996
2008-10-03 07:36:09 +00:00
Nuno Lopes 96740aad86 revert the addition of Preverves(CallGraph), per Duncan's comments
llvm-svn: 56917
2008-10-01 09:13:40 +00:00
Nuno Lopes 5093ab4c76 add preserversCFG() + preservers(CallGraph)
llvm-svn: 56887
2008-09-30 22:04:30 +00:00
Nuno Lopes 2bd7b24f1a add AU.setPreservesCFG() since this pass only adds and removes function attributes
llvm-svn: 56868
2008-09-30 18:34:38 +00:00
Duncan Sands 57512a1be4 Speed up these passes when the callgraph has
huge simply connected components.  Suggested
by Chris.

llvm-svn: 56787
2008-09-29 14:59:04 +00:00
Nuno Lopes ffc9da6772 remove redundant test (mayBeOverriden() includes hasLinkOnceLinkage)
llvm-svn: 56786
2008-09-29 14:40:32 +00:00
Duncan Sands e340e18783 Tweak some comments.
llvm-svn: 56784
2008-09-29 13:35:31 +00:00
Duncan Sands 08d91178e9 Rename isWeakForLinker to mayBeOverridden. Use it
instead of hasWeakLinkage in a bunch of optimization
passes.

llvm-svn: 56782
2008-09-29 11:25:42 +00:00
Devang Patel 9eb525d4f9 Implement function notes as function attributes.
llvm-svn: 56716
2008-09-26 23:51:19 +00:00
Devang Patel a05633e105 Now Attributes are divided in three groups
- return attributes - inreg, zext and sext
- parameter attributes
- function attributes - nounwind, readonly, readnone, noreturn

Return attributes use 0 as the index.
Function attributes use ~0U as the index.

This patch requires corresponding changes in llvm-gcc and clang.

llvm-svn: 56704
2008-09-26 22:53:05 +00:00
Devang Patel 4c758ea3e0 Large mechanical patch.
s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g

This sets the stage 
- to implement function notes as function attributes and 
- to distinguish between function attributes and return value attributes.

This requires corresponding changes in llvm-gcc and clang.

llvm-svn: 56622
2008-09-25 21:00:45 +00:00
Devang Patel 6402c7236f s/ParamAttrsWithIndex/FnAttributeWithIndex/g
llvm-svn: 56535
2008-09-24 00:55:02 +00:00
Devang Patel e15607b7bb Put FN_NOTE_AlwaysInline and others in FnAttr namespace.
llvm-svn: 56527
2008-09-24 00:06:15 +00:00
Devang Patel e87abd26ba Move FN_NOTE_AlwaysInline and other out of ParamAttrs namespace.
Do not check isDeclaration() in hasNote(). It is clients' responsibility.

llvm-svn: 56524
2008-09-23 23:52:03 +00:00
Devang Patel ba3fa6c6e1 s/ParameterAttributes/Attributes/g
llvm-svn: 56513
2008-09-23 23:03:40 +00:00
Devang Patel 82fed6702b Use parameter attribute store (soon to be renamed) for
Function Notes also. Function notes are stored at index ~0.

llvm-svn: 56511
2008-09-23 22:35:17 +00:00
Devang Patel 329fe728b5 Add hasNote() to check note associated with a function.
llvm-svn: 56477
2008-09-22 22:32:29 +00:00
Oscar Fuentes a229b3c9a7 Initial support for the CMake build system.
llvm-svn: 56419
2008-09-22 01:08:49 +00:00
Duncan Sands e1dc84be64 Implement review feedback from Devang: make use
of mayReadFromMemory and mayWriteToMemory.

llvm-svn: 56387
2008-09-20 16:45:58 +00:00
Duncan Sands af25ee7ffc Add a new pass AddReadAttrs which works out which functions
can get the readnone/readonly attributes, and gives them it.
The plan is to remove markmodref (which did the same thing
by querying GlobalsModRef) and delete the analogous
functionality from GlobalsModRef.

llvm-svn: 56341
2008-09-19 08:17:05 +00:00
Anton Korobeynikov 1a1140429e Make safer variant of alias resolution routine to be default
llvm-svn: 56005
2008-09-09 20:05:04 +00:00
Anton Korobeynikov a9b60ee0fc Resolve aliases, when possible
llvm-svn: 56001
2008-09-09 19:04:59 +00:00
Duncan Sands b9a6f861b4 Update the callgraph correctly.
llvm-svn: 55896
2008-09-08 11:08:09 +00:00
Duncan Sands 3cf7d86556 Update the callgraph correctly in ArgumentPromotion.
llvm-svn: 55895
2008-09-08 11:07:35 +00:00
Duncan Sands 46911f1271 Reapply 55859. This doesn't change anything as
long as the callgraph is correct.  It checks
for wrong callgraphs more strictly.

llvm-svn: 55894
2008-09-08 11:05:51 +00:00
Duncan Sands 1ea0d2e6db Correct a comment and strip trailing whitespace.
llvm-svn: 55883
2008-09-07 09:54:09 +00:00
Nuno Lopes 421f488cb7 fix crash when the malloc/free function is defined or is a declaration with 0 parameters.
this pass doesnt seem to be used, but still it's now a little more correct

llvm-svn: 55873
2008-09-06 17:44:06 +00:00
Duncan Sands 95c2a7848a When PruneEH turned an invoke into an ordinary
call (thus changing the call site) it didn't
inform the callgraph about this.  But the
call site does matter - as shown by the testcase,
the callgraph become invalid after the inliner
ran (with an edge between two functions simply
missing), resulting in wrong deductions by
GlobalsModRef.

llvm-svn: 55872
2008-09-06 17:19:29 +00:00
Owen Anderson 1dd2e40521 Revert r55859. This is breaking the build in the abscence of its companion commit.
llvm-svn: 55865
2008-09-05 23:36:01 +00:00
Duncan Sands 9e23602849 Delete the removeCallEdgeTo callgraph method,
because it does not maintain a correct list
of callsites.  I discovered (see following
commit) that the inliner will create a wrong
callgraph if it is fed a callgraph with
correct edges but incorrect callsites.  These
were created by Prune-EH, and while it wasn't
done via removeCallEdgeTo, it could have been
done via removeCallEdgeTo, which is an accident
waiting to happen.  Use removeCallEdgeFor
instead.

llvm-svn: 55859
2008-09-05 21:43:04 +00:00
Duncan Sands 3a52056d4d Use removeAllCalledFunctions rather than removing
edges one by one by hand.

llvm-svn: 55836
2008-09-05 14:56:53 +00:00
Duncan Sands 6dd02b5219 Make this pass return that it made a change if
it modifies a functions attributes.

llvm-svn: 55831
2008-09-05 09:08:37 +00:00
Andrew Lenharth 19fb2aba50 try to seperate the mechanism into something others can use
llvm-svn: 55785
2008-09-04 18:51:26 +00:00
Dan Gohman a79db30d28 Tidy up several unbeseeming casts from pointer to intptr_t.
llvm-svn: 55779
2008-09-04 17:05:41 +00:00
Andrew Lenharth 95d573a7f0 cleanup as per Duncan's review
llvm-svn: 55766
2008-09-04 14:34:22 +00:00
Devang Patel a26e2075b8 Update inline threshold for current function if the notes say, optimize for size.
llvm-svn: 55745
2008-09-03 23:06:09 +00:00
Andrew Lenharth 9fed8f5b9c Initial version of a Partial Specialization IPO pass. It triggers a couple hundred times on 176.gcc. I don't know the performance impact yet, the heuristic is quite simple still.
llvm-svn: 55734
2008-09-03 21:00:28 +00:00
Devang Patel a563d24e5d Fix typo in a comment.
llvm-svn: 55720
2008-09-03 20:25:40 +00:00
Devang Patel a4211876e5 Add parentheses to make code more readable.
llvm-svn: 55717
2008-09-03 19:57:15 +00:00
Devang Patel 50c66cdb0d Fix comments.
llvm-svn: 55716
2008-09-03 19:52:17 +00:00
Devang Patel 924d9084d8 Add custom inliner that handles only functions that are marked as always_inline.
llvm-svn: 55713
2008-09-03 18:50:53 +00:00
Devang Patel 0d442ffa2b Handle "always inline" note during inline cost analysis.
llvm-svn: 55712
2008-09-03 18:47:45 +00:00
Devang Patel 79661994b1 Check noinline note and ignore other notes.
llvm-svn: 55711
2008-09-03 18:46:35 +00:00
Devang Patel 62be9ad270 Handle "noinline" note inside the simple inliner.
llvm-svn: 55708
2008-09-03 18:10:21 +00:00
Devang Patel 7e59270272 s/FP_AlwaysInline/FN_NOTE_AlwaysInline/g
llvm-svn: 55676
2008-09-02 22:43:57 +00:00
Devang Patel bfa535af9f respect inline=never and inline=always notes.
llvm-svn: 55673
2008-09-02 22:16:13 +00:00
Dan Gohman 8de6d22392 Use empty() instead of begin() == end().
llvm-svn: 54780
2008-08-14 18:13:49 +00:00
Matthijs Kooijman 4801bd41cf Replace two for loops with while(!X->use_empty()) loops. This prevents
invalidating the iterator by deleting the current use. This fixes a segfault on
64 bit linux reported in PR2675.

Also remove an unneeded if.

llvm-svn: 54778
2008-08-14 15:03:05 +00:00
Bill Wendling f21a38700f Remove tabs.
llvm-svn: 54707
2008-08-12 23:15:44 +00:00
Matthijs Kooijman 75b4fc2c84 Let SRETPromotion properly preserve the function name instead of (implicitly)
postfixing it with a number.

llvm-svn: 54468
2008-08-07 16:01:23 +00:00
Matthijs Kooijman d6c1c8a974 Fix SRETPromotion, it was generating functions without returns statements since
r53941 (but this was not noticed due to the lack of a basic test for
SRETPromotion). 

llvm-svn: 54467
2008-08-07 15:58:09 +00:00
Matthijs Kooijman 41536988dd Add some debug output to SRETPromotion.
llvm-svn: 54464
2008-08-07 15:14:04 +00:00
Matthijs Kooijman fd3070459b Restructure ArgumentPromotion a bit. Instead of just having a single boolean
that says "unconditional loads from this argument are safe", we now keep track
of the safety per set of indices from which loads happen. This prevents
ArgPromotion from promoting loads that aren't really valid. As an added effect,
this will now disregard the the type of the indices passed to a GEP, so
"load GEP %A, i32 1" and "load GEP %A, i64 1" will result in a single argument,
not two.

This fixes PR2598, for which a testcase has been added as well.

llvm-svn: 54159
2008-07-29 10:00:13 +00:00
Dan Gohman fa1211f69b Enable first-class aggregates support.
Remove the GetResultInst instruction. It is still accepted in LLVM assembly
and bitcode, where it is now auto-upgraded to ExtractValueInst. Also, remove
support for return instructions with multiple values. These are auto-upgraded
to use InsertValueInst instructions.

The IRBuilder still accepts multiple-value returns, and auto-upgrades them
to InsertValueInst instructions.

llvm-svn: 53941
2008-07-23 00:34:11 +00:00
Matthijs Kooijman 8b69d77a7a Make GlobalOpt preserve address spaces when scalar replacing aggregate globals.
llvm-svn: 53716
2008-07-17 11:59:53 +00:00
Matthijs Kooijman c893bf472d Allow deadargelim to change return types even though now values were dead. This
again canonicalizes {i32} into i32 and {} into void.

llvm-svn: 53610
2008-07-15 14:42:31 +00:00
Matthijs Kooijman 5e8c022e21 Revert r53606. It turns out that explicitely tracking the liveness of the
return value as a whole in deadargelim is really not needed now that we simply
rebuild the old return value and actually prevents some canonicalization from
taking place.

This revert stops deadargelim from changing {i32} into i32 for now, but I'll
fix that next.

llvm-svn: 53609
2008-07-15 14:39:36 +00:00
Matthijs Kooijman c1da874478 Make deadargelim a bit less smart, so it doesn't choke on nested structs as
return values that are still (partially) live. Instead of updating all uses of
a call instruction after removing some elements, it now just rebuilds the
original struct (With undef gaps where the unused values were) and leaves it to
instcombine to clean this up.

The added testcase still fails currently, but this is due to instcombine which
isn't good enough yet. I will fix that part next.

llvm-svn: 53608
2008-07-15 14:03:10 +00:00
Matthijs Kooijman 04d4c328ac Don't use isa when we can reuse a previous dyn_cast.
llvm-svn: 53607
2008-07-15 13:39:08 +00:00
Matthijs Kooijman 84194b6768 Make DeadArgElim keep liveness of the return value as a whole in addition to
only the liveness of partial return values (for functions returning a struct).
This is more explicit to prevent unwanted changes in the return value. 

In particular, deadargelim now canonicalizes a function returning {i32} to
returning i32 and {} to void, if the struct returned is not used in its
entirety, but only the single element is used.

llvm-svn: 53606
2008-07-15 13:36:06 +00:00
Matthijs Kooijman 79a8eb547c Let DAE keep a list of live functions, instead of simply marking all arguments
and return values live for those functions. This doesn't change anything yet,
but prepares for the coming commits.

llvm-svn: 53601
2008-07-15 09:11:16 +00:00
Matthijs Kooijman e9af814669 Split DAE::MarkLive into MarkLive and PropagateLiveness.
llvm-svn: 53600
2008-07-15 09:00:17 +00:00
Matthijs Kooijman 2ce5709e31 Pass around const RetOrArg references instead of copying values. Also, mark
RetOrArg::getDescription() as const.

llvm-svn: 53599
2008-07-15 08:56:49 +00:00
Matthijs Kooijman f2860b9fb3 Simplify debug code by using RetOrArg::getDescription().
llvm-svn: 53598
2008-07-15 08:53:36 +00:00
Matthijs Kooijman 90d08addb0 Fix indentation (intentionally left out of the previous commit).
llvm-svn: 53592
2008-07-15 08:47:32 +00:00
Matthijs Kooijman 06642d3812 Move the deadargelim code for intrinsically alive functions into its own
method, to slightly simplify control flow.

llvm-svn: 53591
2008-07-15 08:45:12 +00:00
Dan Gohman 3707f1daba Use find instead of lower_bound.
llvm-svn: 53474
2008-07-11 20:58:19 +00:00
Matthijs Kooijman e0f3ab82c4 Restructure dead argument elimination, try #3 :-)
Rewrite the DeadArgumentElimination pass, to use a more explicit tracking of
dependencies between return values and/or arguments. Also make the handling of
arguments and return values the same.

The pass now looks properly inside returned structs, but only at the first
level (ie, not inside nested structs).

This version fixed a few more bugs and was cleaned up a bit. It now passes all
of LLVM's testing, and should still pass SPEC2006. There is still a minor bug
with regard to returning nested structs. Since there is currently nothing that
emits such IR, I will fix that in a seperate commit (partly because it requires
a non-trivial fix).

llvm-svn: 53400
2008-07-10 10:24:08 +00:00
Evan Cheng 88ca48b09d Restore DeadArgElim back to 52570. It's breaking 447.dealII.
llvm-svn: 52736
2008-06-25 18:10:09 +00:00
Duncan Sands 1b03c2ac98 Pacify gcc-4.3.
llvm-svn: 52723
2008-06-25 16:31:18 +00:00
Matthijs Kooijman 2e2001d8b9 Fix a (false) warning on darwin.
llvm-svn: 52705
2008-06-25 08:12:16 +00:00
Matthijs Kooijman 4e1cf1e7d7 Fix some cosmetics in comments.
llvm-svn: 52704
2008-06-25 08:10:21 +00:00
Matthijs Kooijman c702e1d32f Commit the new DeadArgElim pass again, this time with the gcc bootstrap failures fixed.
Also add a testcase to reproduce the gcc bootstrap failure in very much reduced form.

llvm-svn: 52677
2008-06-24 16:30:26 +00:00
Matthijs Kooijman 19a6469e1b Rename a few variables to be more consistent.
llvm-svn: 52672
2008-06-24 09:14:10 +00:00
Dan Gohman 158ff2c4a9 Use Instruction::eraseFromParent().
llvm-svn: 52606
2008-06-21 22:08:46 +00:00
Evan Cheng 33067210d1 Back out Matthijs' DAE patches. It's miscompiling gcc driver.
llvm-svn: 52570
2008-06-21 00:31:44 +00:00
Matthijs Kooijman c456f9dfc6 80 column and trailing whitespace fixes.
llvm-svn: 52539
2008-06-20 15:34:07 +00:00
Matthijs Kooijman 0c50b953c5 Don't let DeadArgumentElimination attempt to update callers when the return
type wasn't changed.

llvm-svn: 52538
2008-06-20 15:25:43 +00:00
Matthijs Kooijman 9dc59b7666 Don't let DeadArgElimination change the return type ({} into void and {T}
into T) when no return values are actually dead.

llvm-svn: 52537
2008-06-20 15:16:45 +00:00
Matthijs Kooijman 013b6a9a42 Explicitely track if any arguments or return values were removed in
DeadArgumentElimination and assert that the function type does not change if
nothing was changed. This should catch subtle changes in function type that are
not intended.

llvm-svn: 52536
2008-06-20 14:28:52 +00:00
Matthijs Kooijman e91aed6ce1 Remove debug output.
llvm-svn: 52535
2008-06-20 14:03:35 +00:00
Matthijs Kooijman 8d32dee428 Recommit r52459, rewriting of the dead argument elimination pass.
This is a fixed version that no longer uses multimap::equal_range, which
resulted in a pointer invalidation problem.

Also, DAE::InspectedFunctions was not really necessary, so it got removed.

Lastly, this version no longer applies the extra arg hack on functions who did
not have any arguments to start with.

llvm-svn: 52532
2008-06-20 09:36:16 +00:00
Dan Gohman d6530872f3 Use the common API for adding instructions to basic blocks instead of
using BasicBlock::getInstList.

llvm-svn: 52500
2008-06-19 17:53:32 +00:00
Matthijs Kooijman 0c71732497 Use a CallSite to find the nth argument of a call/invoke instruction instead of
using getOperand() directly. This makes things work with invoke instructions as
well.

llvm-svn: 52489
2008-06-19 08:53:24 +00:00
Owen Anderson 9094cc957e Revert r52459, which was causing an infinite loop or massive slowdown on MultiSource/Applications/SPASS, and possibly others as well.
Please reapply once this is fixed.

llvm-svn: 52465
2008-06-18 17:32:16 +00:00
Matthijs Kooijman 964557fdf5 Rewrite the DeadArgumentElimination pass, to use a more explicit tracking of
dependencies between return values and/or arguments. Also make the handling of
arguments and return values the same.

The pass now looks properly inside returned structs, but only at the first                                                                                     
level (ie, not inside nested structs).

Also add a testcase for testing various variations of (multiple) dead rerturn
values.

llvm-svn: 52459
2008-06-18 11:12:53 +00:00
Matthijs Kooijman fd17357643 Reapply r52397 (make IPConstProp promote returned arguments), but fixed this
time. Sorry for the trouble!

This time, also add a testcase, which I should have done in the first place...

llvm-svn: 52455
2008-06-18 08:30:37 +00:00
Matthijs Kooijman 97034598b1 Reapply r52396, it was unrelated to the breakage (that was caused by r52397, my
commit after this).

llvm-svn: 52453
2008-06-18 08:09:27 +00:00
Chris Lattner aecc3750d1 revert recent patch which is causing widespread breakage.
llvm-svn: 52415
2008-06-17 17:06:43 +00:00
Matthijs Kooijman 332836d68d Learn IPConstProp to propagate arguments that are directly returned. Strictly
speaking these are not constant values. However, when a function always returns
one of its arguments, then from the point of view of each caller the return
value is constant (or at least a known value) and can be replaced.

llvm-svn: 52397
2008-06-17 12:20:24 +00:00
Matthijs Kooijman f03c1ae407 Learn IPConstProp to look at individual return values and propagate them
individually.

Also learn IPConstProp how returning first class aggregates work, in addition
to old style multiple return instructions.

Modify the return-constants testscase to confirm this behaviour.

llvm-svn: 52396
2008-06-17 12:02:52 +00:00
Chris Lattner dbd595f22d Fix PR2411, where ip constant prop would propagate the
result of a weak function.

llvm-svn: 52137
2008-06-09 07:58:07 +00:00
Matthijs Kooijman e0c5adc158 Let StructRetPromotion check if all if its users are really calls or invokesn,
not other instructions. This fixes a crash with the added testcase.

llvm-svn: 51992
2008-06-05 08:57:20 +00:00
Matthijs Kooijman 463f86639d Let StructRetPromotion check if it's users are really calling it and not
passing its pointer. Fixes test with added testcase.

llvm-svn: 51991
2008-06-05 08:48:32 +00:00
Matthijs Kooijman 230d6fbfeb Use use_iterator::getOperandNo instead of CallSite::hasArgument to check if a
function is passed as an argument instead of called. Also do this check a bit
earlier.

llvm-svn: 51990
2008-06-05 08:34:25 +00:00
Matthijs Kooijman 2353f35989 Replace two manual loops with calls to CallSite::hasArguments (no functional changes).
llvm-svn: 51947
2008-06-04 16:57:50 +00:00
Matthijs Kooijman 57da7d2308 Use eraseFromParent() instead of doing that manually in two places.
llvm-svn: 51770
2008-05-30 12:35:46 +00:00
Gabor Greif 3a9fba5a72 convert more operand loops to iterator formulation
llvm-svn: 51663
2008-05-29 01:59:18 +00:00
Duncan Sands 698348dfac Fix some constructs that gcc-4.4 warns about.
llvm-svn: 51591
2008-05-27 11:50:51 +00:00
Duncan Sands dd7daee850 Factor code to copy global value attributes like
the section or the visibility from one global
value to another: copyAttributesFrom.  This is
particularly useful for duplicating functions:
previously this was done by explicitly copying
each attribute in turn at each place where a
new function was created out of an old one, with
the result that obscure attributes were regularly
forgotten (like the collector or the section).
Hopefully now everything is uniform and nothing
is forgotten.

llvm-svn: 51567
2008-05-26 19:58:59 +00:00
Matthijs Kooijman f399bbf980 Indent fix.
llvm-svn: 51477
2008-05-23 07:57:02 +00:00
Dan Gohman 30ab45d01e Use isSingleValueType instead of isFirstClassType to
exclude struct and array types.

llvm-svn: 51459
2008-05-23 00:17:26 +00:00
Dan Gohman 7a0566b9cd Use isSingleValueType instead of isFirstClassType to
exclude struct and array types.

llvm-svn: 51456
2008-05-23 00:12:03 +00:00
Dale Johannesen 5610dabac9 Less conservative verison of previous patch,
suggested by Duncan.

llvm-svn: 51211
2008-05-16 23:18:52 +00:00
Dale Johannesen e7f5bc2c3b Weak functions not declared non-throwing might be
replaced at linktime with a body that throws, even
if the body in this file does not.  Make PruneEH
be more conservative in this case.
g++.dg/eh/weak1.C

llvm-svn: 51207
2008-05-16 21:31:48 +00:00
Gabor Greif e1f6e4b21d API change for {BinaryOperator|CmpInst|CastInst}::create*() --> Create. Legacy interfaces will be in place for some time. (Merge from use-diet branch.)
llvm-svn: 51200
2008-05-16 19:29:10 +00:00
Gabor Greif 697e94cc22 Fix a bunch of 80col violations that arose from the Create API change. Tweak makefile targets to find these better.
llvm-svn: 51143
2008-05-15 10:04:30 +00:00
Devang Patel f2763e233e Simplify internalize pass. Add test case.
Patch by Matthijs Kooijman!

llvm-svn: 51114
2008-05-14 20:01:01 +00:00
Nate Begeman 53c5c62d6d 80 col / tabs fixes
llvm-svn: 51021
2008-05-13 01:48:26 +00:00
Dan Gohman d78c400b5b Clean up the use of static and anonymous namespaces. This turned up
several things that were neither in an anonymous namespace nor static
but not intended to be global.

llvm-svn: 51017
2008-05-13 00:00:25 +00:00
Duncan Sands 437435dcbc Fix a type and formatting.
llvm-svn: 50900
2008-05-09 12:20:10 +00:00
Gordon Henriksen 829046b0b4 Improve pass documentation and comments.
Patch by Matthijs Kooijman!

llvm-svn: 50861
2008-05-08 17:46:35 +00:00
Devang Patel 4758caa926 Check linkage.
llvm-svn: 50851
2008-05-08 15:08:39 +00:00
Dan Gohman 6a2da37c0e Make several variable declarations static.
llvm-svn: 50696
2008-05-06 01:53:16 +00:00
Chris Lattner b9b5d6ddaa Delete the IPO simplify-libcalls and completely reimplement it as
a FunctionPass.  This makes it simpler, fixes dozens of bugs, adds
a couple of minor features, and shrinks is considerably: from
2214 to 1437 lines.

llvm-svn: 50520
2008-05-01 06:25:24 +00:00
Chris Lattner 438e35c4d1 use string length computation to generalize several xforms.
llvm-svn: 50464
2008-04-30 03:07:53 +00:00
Chris Lattner 92f4702254 Implement more aggressive support for analyzing string length. This
generalizes the previous code to handle the case when the string is not
an immediate to the strlen call (for example, crazy stuff like 
strlen(c ? "foo" : "bart"+1) -> 3).  This implements 
gcc.c-torture/execute/builtins/strlen-2.c.  I will generalize other
cases in simplifylibcalls to use the same routine later.

llvm-svn: 50408
2008-04-29 06:56:02 +00:00
Chris Lattner 67ca6f6347 When SRoA'ing a global variable, make sure the new globals get the
appropriate alignment.  This fixes a miscompilation of 252.eon on
x86-64 (rdar://5891920).

Bill, please pull this into Tak.

llvm-svn: 50308
2008-04-26 07:40:11 +00:00
Nick Lewycky 4d43d3c72c Remove 'unwinds to' support from mainline. This patch undoes r47802 r47989
r48047 r48084 r48085 r48086 r48088 r48096 r48099 r48109 and r48123.

llvm-svn: 50265
2008-04-25 16:53:59 +00:00
Chris Lattner a82d691caa simplify code for propagation of constant arguments into
callees.

llvm-svn: 50142
2008-04-23 06:16:27 +00:00
Chris Lattner 5f1802cfdf Fix a number of bugs in ipconstantprop, simplify the code, fit in 80 cols,
fix read after free bug (PR2238).

llvm-svn: 50141
2008-04-23 05:59:23 +00:00
Chris Lattner ad0d42ba15 don't assume that the argument passed to fprintf("%s" is a string. This
fixes a crash in opt on 433.milc.

llvm-svn: 50023
2008-04-21 03:18:33 +00:00
Chris Lattner eb6bb803a7 Allow argpromote to promote struct arguments with a specified number
of elements.  Patch by Matthijs Kooijman!

llvm-svn: 49962
2008-04-19 19:50:01 +00:00
Chris Lattner a29d2536aa Disable an xform we've had for a long time, pow(x,0.5) -> sqrt.
This is not safe for all inputs.

llvm-svn: 49458
2008-04-10 02:07:51 +00:00
Chris Lattner 802134fc02 Generalize getUnaryFloatFunction to handle any FP unary function, automatically
figuring out the suffix to use.  implement pow(2,x) -> exp2(x).

llvm-svn: 49437
2008-04-09 17:48:11 +00:00
Chris Lattner cca74e5ab9 use the new ConstantFP::get method to make this work with
long double and simplify the code.

llvm-svn: 49435
2008-04-09 17:17:35 +00:00
Chris Lattner b859fb49ed many cleanups to the pow optimizer. Allow it to handle powf,
add support for  pow(x, 2.0) -> x*x.

llvm-svn: 49411
2008-04-09 00:07:45 +00:00
Duncan Sands 813384951e Use Intrinsic::getDeclaration in more places.
llvm-svn: 49338
2008-04-07 13:45:04 +00:00
Gabor Greif e9ecc68d8f API changes for class Use size reduction, wave 1.
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.

llvm-svn: 49277
2008-04-06 20:25:17 +00:00
Evan Cheng ac38d444e2 1. Drop default inline threshold back down to 200.
2. Do not use # of basic blocks as part of the cost computation since it doesn't really figure into function size.
3. More aggressively inline function with vector code.

llvm-svn: 49061
2008-04-01 23:59:29 +00:00
Evan Cheng 3471ae8c5d Increasing the inline limit from (overly conservative) 200 to 300. Given each BB costs 20 and each instruction costs 5, 200 means a 4 BB function + 24 instructions (actually less because caller's size also contributes to it).
Furthermore, double the limit when more than 10% of the callee instructions are vector instructions. Multimedia kernels tend to love inlining.

llvm-svn: 48725
2008-03-24 06:37:48 +00:00
Dan Gohman 9988569af8 Don't include <map> in Pass.h, which doesn't need it. This requires
adding <map> to many files that actually do need it.

llvm-svn: 48667
2008-03-21 23:51:57 +00:00
Andrew Lenharth 74d154ce57 FunctionExtractorPass has been superceded by GVExtractorPass
llvm-svn: 48648
2008-03-21 16:46:53 +00:00
Devang Patel 5ca2ea6479 Incorporate feedback.
- Fix loop nest.
- Use RetVals.size()
- Check for null return value.

llvm-svn: 48605
2008-03-20 18:30:32 +00:00
Zhou Sheng a30cdb9417 Take the old function's name.
llvm-svn: 48588
2008-03-20 08:05:05 +00:00
Chris Lattner 8a923e7c28 Reimplement the parameter attributes support, phase #1. hilights:
1. There is now a "PAListPtr" class, which is a smart pointer around
   the underlying uniqued parameter attribute list object, and manages
   its refcount.  It is now impossible to mess up the refcount.
2. PAListPtr is now the main interface to the underlying object, and
   the underlying object is now completely opaque.
3. Implementation details like SmallVector and FoldingSet are now no
   longer part of the interface.
4. You can create a PAListPtr with an arbitrary sequence of
   ParamAttrsWithIndex's, no need to make a SmallVector of a specific 
   size (you can just use an array or scalar or vector if you wish).
5. All the client code that had to check for a null pointer before
   dereferencing the pointer is simplified to just access the 
   PAListPtr directly.
6. The interfaces for adding attrs to a list and removing them is a
   bit simpler.

Phase #2 will rename some stuff (e.g. PAListPtr) and do other less 
invasive changes.

llvm-svn: 48289
2008-03-12 17:45:29 +00:00
Devang Patel cc189b5606 Check multiple return values.
llvm-svn: 48267
2008-03-12 00:32:32 +00:00
Devang Patel fa8667a2dd Fix attribute handling.
llvm-svn: 48262
2008-03-12 00:07:03 +00:00
Devang Patel 7358165c99 Handle multiple ret values.
llvm-svn: 48254
2008-03-11 22:24:29 +00:00
Devang Patel f6269f0914 Initialize.
llvm-svn: 48253
2008-03-11 22:08:21 +00:00
Nick Lewycky fb2c1a999a Turn unwind_to into "unwinds to".
llvm-svn: 48123
2008-03-10 02:20:00 +00:00
Ted Kremenek d48ed17d18 Fix some compilation errors on msvc:
- "Redefinition of I" (iterator masks previous definition)
- include missing header file

Patch by Argiris Kirtzidis!

llvm-svn: 48115
2008-03-09 18:32:50 +00:00
Nick Lewycky 0ac65c3b99 And again.
llvm-svn: 48112
2008-03-09 17:13:05 +00:00
Nick Lewycky 929703b29e Braces belong here. No functionality change.
llvm-svn: 48111
2008-03-09 17:11:18 +00:00
Nick Lewycky 4d0ed842b1 Prune the unwind_to labels on BBs that don't need them. Another step in the
removal of invoke, PR1269.

llvm-svn: 48084
2008-03-09 04:55:16 +00:00
Andrew Lenharth 3f13b6630a add a pass that can extract all kinds of global values, not just functions. Update llvm-extract to use it and optionally extract a global variable if you want it too
llvm-svn: 48015
2008-03-07 19:51:57 +00:00
Devang Patel 26cabc447c Skip, for now, callsites where use of sret argument is not dominated by callsite.
llvm-svn: 47980
2008-03-05 23:39:23 +00:00
Devang Patel ea4cb89d34 Filter nested structs
llvm-svn: 47906
2008-03-04 21:32:09 +00:00
Devang Patel 297ea0de75 Use appropriate index to get the result value.
llvm-svn: 47897
2008-03-04 19:22:54 +00:00
Devang Patel 748c77f530 Skip sret attribute while preparing attribute list for
new function and new call sites.

llvm-svn: 47896
2008-03-04 19:12:58 +00:00
Devang Patel ed6e4b0b7d Increment counter that keeps track of total number of sret promoted.
llvm-svn: 47892
2008-03-04 17:48:11 +00:00
Devang Patel 6bb36e686d Skip declarations.
llvm-svn: 47890
2008-03-04 17:47:06 +00:00
Devang Patel 5b69f3fa33 Process externally visible functions also. Later on code generator will do the right thing.
llvm-svn: 47889
2008-03-04 17:46:26 +00:00
Devang Patel ecce5af83d Collect statistics.
llvm-svn: 47888
2008-03-04 17:44:37 +00:00
Devang Patel 9d91785987 s/isReturnStruct()/hasStructRetAttr()/g
llvm-svn: 47857
2008-03-03 21:46:28 +00:00
Devang Patel b0faf89133 Preserve paramater attributes.
llvm-svn: 47847
2008-03-03 18:36:03 +00:00
Chris Lattner a683edb2d8 allow specified inline threshold to be negative, as the value is
itself sometimes negative.

llvm-svn: 47786
2008-03-01 08:09:51 +00:00
Devang Patel e8ddaba169 Fix cut-n-pasto.
llvm-svn: 47777
2008-02-29 23:41:13 +00:00
Devang Patel 4eedfd2421 Add pass to promote sret.
This pass transforms 

  %struct._Point = type { i32, i32, i32, i32, i32, i32 }
  define internal void @foo(%struct._Point* sret  %agg.result)

into

  %struct._Point = type { i32, i32, i32, i32, i32, i32 }
  define internal %struct._Point @foo()

This pass updates foo() clients appropriately to use
getresult instruction to extract return values.

This pass is not yet ready for prime time.

llvm-svn: 47776
2008-02-29 23:34:08 +00:00
Dale Johannesen 09f410b6d7 Split ParameterAttributes.h, putting the complicated
stuff into ParamAttrsList.h.  Per feedback from
ParamAttrs changes.

llvm-svn: 47504
2008-02-22 22:17:59 +00:00
Anton Korobeynikov 6f74afea32 Get rid of hash_map. Use StringMap instead
llvm-svn: 47373
2008-02-20 11:27:49 +00:00
Anton Korobeynikov 1bfd121321 Make Transforms to be 4.3 warnings-clean
llvm-svn: 47371
2008-02-20 11:26:25 +00:00
Anton Korobeynikov 579f07135a Unbreak build with gcc 4.3: provide missed includes and silence most annoying warnings.
llvm-svn: 47367
2008-02-20 11:08:44 +00:00
Dale Johannesen 89268bc6e2 Expand ParameterAttributes to 32 bits (in preparation
for adding alignment info, not there yet).  Clean up
interfaces to reference ParameterAttributes consistently.

llvm-svn: 47342
2008-02-19 21:38:47 +00:00
Duncan Sands 85fab3a3ad Simplify caller updating using a CallSite, as
requested by Chris.  While there, do the same
for an existing function committed by someone
called "lattner" :)

llvm-svn: 47273
2008-02-18 17:32:13 +00:00
Duncan Sands 573b3f89e4 Remove any 'nest' parameter attributes if the function
is not passed as an argument to a trampoline intrinsic.

llvm-svn: 47220
2008-02-16 20:56:04 +00:00
Chris Lattner 67b9ef7be8 remove some dead code.
llvm-svn: 47066
2008-02-13 17:18:26 +00:00
Duncan Sands 9aa789fda3 Don't drop function/call return attributes like 'nounwind'.
llvm-svn: 46645
2008-02-01 20:37:16 +00:00
Chris Lattner ade0abb498 Don't let globalopt hack on volatile loads or stores.
llvm-svn: 46523
2008-01-29 19:01:37 +00:00
Dan Gohman 70de4cb1cd Use empty() instead of comparing size() with zero.
llvm-svn: 46514
2008-01-29 13:02:09 +00:00
Chris Lattner a8b4a56061 Transform calls to memcpy into llvm.memcpy calls, patch by Eli Friedman.
llvm-svn: 46433
2008-01-28 04:41:43 +00:00
Evan Cheng 04af661b1f DAE bug fix. Don't lose parameter attributes on vararg arguments.
llvm-svn: 46113
2008-01-17 04:18:54 +00:00
Chris Lattner 5630c4f217 Fix arg promotion to propagate the correct attrs on the calls to
promoted functions.  This is important for varargs calls in 
particular.  Thanks to duncan for providing a great testcase.

llvm-svn: 46108
2008-01-17 01:17:03 +00:00
Chris Lattner 39f156183d Handle attribute(used) global variables that are i8.
llvm-svn: 46090
2008-01-16 21:35:43 +00:00
Devang Patel b3696e4f14 Do not strip llvm.used values.
llvm-svn: 46045
2008-01-16 03:33:05 +00:00
Chris Lattner 26fe7ebc03 Fix the miscompilation of MiBench/consumer-lame that was exposed by Evan's
byval work.  This miscompilation is due to the program indexing an array out
of range and us doing a transformation that broke this.

llvm-svn: 45949
2008-01-14 02:09:12 +00:00
Chris Lattner 9a6db18b04 The isNotSuitableForSRA property is now dead, don't compute it.
llvm-svn: 45948
2008-01-14 01:32:52 +00:00
Chris Lattner ab0537258f Change SRAGlobal to not depend on isNotSuitableForSRA, which makes it very
difficult to understand the invariants.

llvm-svn: 45947
2008-01-14 01:31:05 +00:00
Chris Lattner 20bbac3435 Make the 'shrink global to bool' optimization more self contained, and thus
easier to show that its safe.  No functionality change.

llvm-svn: 45946
2008-01-14 01:17:44 +00:00
Duncan Sands ff70c5de69 Small simplification.
llvm-svn: 45932
2008-01-13 08:12:17 +00:00
Chris Lattner 22ad7abdfe Allow clients to specify the inline threshold when creating
the inliner pass.  Patch by Robert Zeh.

llvm-svn: 45903
2008-01-12 06:49:13 +00:00
Duncan Sands 5b721fc21d When DAE drops the varargs part of a function, ensure any
attributes on the vararg call arguments are also dropped.

llvm-svn: 45892
2008-01-11 23:13:45 +00:00
Chris Lattner b5bd924e83 Teach argpromote to ruthlessly hack small byval structs when it can
get away with it, which exposes opportunities to eliminate the memory
objects entirely.  For example, we now compile byval.ll to:

define internal void @f1(i32 %b.0, i64 %b.1) {
entry:
	%tmp2 = add i32 %b.0, 1		; <i32> [#uses=0]
	ret void
}

define i32 @main() nounwind  {
entry:
	call void @f1( i32 1, i64 2 )
	ret i32 0
}

This seems like it would trigger a lot for code that passes around small
structs (e.g. SDOperand's or _Complex)...

llvm-svn: 45886
2008-01-11 22:31:41 +00:00
Chris Lattner b66fbdde42 Use smallptrset instead of std::set for efficiency.
llvm-svn: 45878
2008-01-11 19:36:30 +00:00
Chris Lattner 4a70261f00 a byval argument is guaranteed to be valid to load.
llvm-svn: 45877
2008-01-11 19:34:32 +00:00
Chris Lattner 4062a625e5 Update this code to use eraseFromParent where possible. Compute
whether an argument is byval and pass into isSafeToPromoteArgument.

llvm-svn: 45876
2008-01-11 19:20:39 +00:00
Chris Lattner e736e55d3c replace a loop with a constant time check.
llvm-svn: 45875
2008-01-11 18:55:10 +00:00
Chris Lattner 669e7054ca another minor datastructure tweak.
llvm-svn: 45874
2008-01-11 18:47:45 +00:00
Chris Lattner a8ba28f6e4 start using smallvector to avoid vector heap thrashing.
llvm-svn: 45873
2008-01-11 18:43:58 +00:00
Duncan Sands b18c30acec Small cleanup for handling of type/parameter attribute
incompatibility.

llvm-svn: 45704
2008-01-07 17:16:06 +00:00
Duncan Sands 404eb05247 The transform that tries to turn calls to bitcast functions into
direct calls bails out unless caller and callee have essentially
equivalent parameter attributes.  This is illogical - the callee's
attributes should be of no relevance here.  Rework the logic, which
incidentally fixes a crash when removed arguments have attributes.

llvm-svn: 45658
2008-01-06 18:27:01 +00:00
Chris Lattner bdd6acfb59 Fix PR1896
llvm-svn: 45568
2008-01-04 05:04:53 +00:00
Chris Lattner d2b0e15535 add missing #include
llvm-svn: 45516
2008-01-02 23:41:05 +00:00
Chris Lattner f3ebc3f3d2 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Chris Lattner a087a8d2ce remove attribution from lib Makefiles.
llvm-svn: 45415
2007-12-29 20:09:26 +00:00
Gordon Henriksen 520e64c0c2 Fixing several transforms which would drop the collector attribute
when copying functions.

llvm-svn: 45356
2007-12-25 22:16:06 +00:00
Duncan Sands 6a7703ed63 Make DAE not wipe out attributes on calls, and not drop
return attributes on the floor.  In the case of a call
to a varargs function where the varargs arguments are
being removed, any call attributes on those arguments
need to be dropped.  I didn't do this because I plan to
make it illegal to have such attributes (see next patch).
With this change, compiling the gcc filter2 eh test at -O0
and then running opt -std-compile-opts on it results in
a correctly working program (compiling at -O1 or higher
results in the test failing due to a problem with how we
output eh info into the IR).

llvm-svn: 45285
2007-12-21 19:16:16 +00:00
Duncan Sands aa31b92508 When inlining through an 'nounwind' call, mark inlined
calls 'nounwind'.  It is important for correct C++
exception handling that nounwind markings do not get
lost, so this transformation is actually needed for
correctness.

llvm-svn: 45218
2007-12-19 21:13:37 +00:00
Duncan Sands 3353ed09ac Rename isNoReturn to doesNotReturn, and isNoUnwind to
doesNotThrow.

llvm-svn: 45160
2007-12-18 09:59:50 +00:00
Christopher Lamb edf0788758 Change the PointerType api for creating pointer types. The old functionality of PointerType::get() has become PointerType::getUnqual(), which returns a pointer in the generic address space. The new prototype of PointerType::get() requires both a type and an address space.
llvm-svn: 45082
2007-12-17 01:12:55 +00:00
Duncan Sands 9f76be61d1 Make PruneEH update the nounwind/noreturn attributes
on functions as it calculates them.

llvm-svn: 44802
2007-12-10 19:09:40 +00:00
Duncan Sands 38ef3a8ec7 Rather than having special rules like "intrinsics cannot
throw exceptions", just mark intrinsics with the nounwind
attribute.  Likewise, mark intrinsics as readnone/readonly
and get rid of special aliasing logic (which didn't use
anything more than this anyway).

llvm-svn: 44544
2007-12-03 20:06:50 +00:00
Duncan Sands ad0ea2d430 Fix PR1146: parameter attributes are longer part of
the function type, instead they belong to functions
and function calls.  This is an updated and slightly
corrected version of Reid Spencer's original patch.
The only known problem is that auto-upgrading of
bitcode files doesn't seem to work properly (see
test/Bitcode/AutoUpgradeIntrinsics.ll).  Hopefully
a bitcode guru (who might that be? :) ) will fix it.

llvm-svn: 44359
2007-11-27 13:23:08 +00:00
Anton Korobeynikov 59c11686cc Don't crash on bogus llvm.noinline. This is first part of PR1817 (preventing reduction)
llvm-svn: 44281
2007-11-22 22:30:10 +00:00
Chris Lattner 0841c3b560 Fix PR1788 by taking the approach suggested by Richard Smith.
Thanks to him for his detailed analysis of the problem.

llvm-svn: 44162
2007-11-15 06:10:55 +00:00
Nick Lewycky c6243020a6 Allow the block extractor take to take a list of basic blocks to not extract
from a file containing Function/BasicBlock pairings. This is not safe against
anonymous or abnormally-named Funcs or BBs.

Make bugpoint use this interface to pass the BBs list to the child bugpoint.

llvm-svn: 44101
2007-11-14 06:47:06 +00:00
Chris Lattner 68f04fa941 Fix the regression on Transforms/GlobalOpt/deadglobal-2.ll from my
patch on friday.

llvm-svn: 44068
2007-11-13 21:46:23 +00:00
Chris Lattner f9c0fd7488 Tighten up a check for folding away loads from (newly constant) globals. This
fixes a crash on Transforms/GlobalOpt/2007-11-09-GEP-GEP-Crash.ll and 
rdar://5585488.

llvm-svn: 43949
2007-11-09 17:33:02 +00:00
Gordon Henriksen 2ed067a0d9 Deleting redundant copy of block extractor pass. See also PR1775.
llvm-svn: 43694
2007-11-05 01:54:05 +00:00
Gordon Henriksen d568767ecb Finishing initial docs for all transformations in Passes.html.
Also cleaned up some comments in source files.

llvm-svn: 43674
2007-11-04 16:15:04 +00:00
Duncan Sands 44b8721de8 Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.
The meaning of getTypeSize was not clear - clarifying it is important
now that we have x86 long double and arbitrary precision integers.
The issue with long double is that it requires 80 bits, and this is
not a multiple of its alignment.  This gives a primitive type for
which getTypeSize differed from getABITypeSize.  For arbitrary precision
integers it is even worse: there is the minimum number of bits needed to
hold the type (eg: 36 for an i36), the maximum number of bits that will
be overwriten when storing the type (40 bits for i36) and the ABI size
(i.e. the storage size rounded up to a multiple of the alignment; 64 bits
for i36).

This patch removes getTypeSize (not really - it is still there but
deprecated to allow for a gradual transition).  Instead there is:

(1) getTypeSizeInBits - a number of bits that suffices to hold all
values of the type.  For a primitive type, this is the minimum number
of bits.  For an i36 this is 36 bits.  For x86 long double it is 80.
This corresponds to gcc's TYPE_PRECISION.

(2) getTypeStoreSizeInBits - the maximum number of bits that is
written when storing the type (or read when reading it).  For an
i36 this is 40 bits, for an x86 long double it is 80 bits.  This
is the size alias analysis is interested in (getTypeStoreSize
returns the number of bytes).  There doesn't seem to be anything
corresponding to this in gcc.

(3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded
up to a multiple of the alignment.  For an i36 this is 64, for an
x86 long double this is 96 or 128 depending on the OS.  This is the
spacing between consecutive elements when you form an array out of
this type (getABITypeSize returns the number of bytes).  This is
TYPE_SIZE in gcc.

Since successive elements in a SequentialType (arrays, pointers
and vectors) need to be aligned, the spacing between them will be
given by getABITypeSize.  This means that the size of an array
is the length times the getABITypeSize.  It also means that GEP
computations need to use getABITypeSize when computing offsets.
Furthermore, if an alloca allocates several elements at once then
these too need to be aligned, so the size of the alloca has to be
the number of elements multiplied by getABITypeSize.  Logically
speaking this doesn't have to be the case when allocating just
one element, but it is simpler to also use getABITypeSize in this
case.  So alloca's and mallocs should use getABITypeSize.  Finally,
since gcc's only notion of size is that given by getABITypeSize, if
you want to output assembler etc the same as gcc then getABITypeSize
is the size you want.

Since a store will overwrite no more than getTypeStoreSize bytes,
and a read will read no more than that many bytes, this is the
notion of size appropriate for alias analysis calculations.

In this patch I have corrected all type size uses except some of
those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard
cases).  I will get around to auditing these too at some point,
but I could do with some help.

Finally, I made one change which I think wise but others might
consider pointless and suboptimal: in an unpacked struct the
amount of space allocated for a field is now given by the ABI
size rather than getTypeStoreSize.  I did this because every
other place that reserves memory for a type (eg: alloca) now
uses getABITypeSize, and I didn't want to make an exception
for unpacked structs, i.e. I did it to make things more uniform.
This only effects structs containing long doubles and arbitrary
precision integers.  If someone wants to pack these types more
tightly they can always use a packed struct.

llvm-svn: 43620
2007-11-01 20:53:16 +00:00
Gordon Henriksen 78c63ac41e More fleshing out of docs/Passes.html, plus some typo fixes and
improved wording in source files.

llvm-svn: 43377
2007-10-26 03:03:51 +00:00
Dale Johannesen 4d06391c47 Fix off by 1 bug in printf->puts lowering.
llvm-svn: 43309
2007-10-24 20:14:50 +00:00
Chris Lattner 9715d9fb59 Fix PR1735 and Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll by
fixing some obviously broken code :(

llvm-svn: 43141
2007-10-18 18:49:29 +00:00
Devang Patel b3dac3f5d9 Do not raise free() call that is called through invoke instruction.
llvm-svn: 43083
2007-10-17 20:12:58 +00:00
Dan Gohman c731c97fac Use empty() member functions when that's what's being tested for instead
of comparing begin() and end().

llvm-svn: 42585
2007-10-03 19:26:29 +00:00
Tanya Lattner 30f65fe4a7 Fix PR1719, by not marking llvm.global.annotations internal.
llvm-svn: 42578
2007-10-03 17:05:40 +00:00
Chris Lattner d66e0cd6c0 Fix PR1719, by not marking llvm.noinline internal.
llvm-svn: 42565
2007-10-03 03:59:15 +00:00
Dale Johannesen 6bf69ed3cc minor long double related changes
llvm-svn: 42439
2007-09-28 18:06:58 +00:00
Chris Lattner 5d13fb538f Fix a logic error in ValueIsOnlyUsedLocallyOrStoredToOneGlobal that caused
miscompilation of 188.ammp.  Reject select and bitcast in 
ValueIsOnlyUsedLocallyOrStoredToOneGlobal because RewriteHeapSROALoadUser can't handle it.

llvm-svn: 41950
2007-09-14 03:41:21 +00:00
Chris Lattner 011f91b5b2 Teach GlobalLoadUsesSimpleEnoughForHeapSRA and the SROA rewriter how to handle
a limited form of PHI nodes.  This finally fixes PR1639, speeding 179.art up
from 7.84s to 3.13s on PPC.

llvm-svn: 41933
2007-09-13 21:31:36 +00:00
Chris Lattner ba98f89388 be tolerant of PHI nodes when rewriting heap SROA code. This is a step
along the way of PR1639

llvm-svn: 41930
2007-09-13 18:00:31 +00:00
Chris Lattner f315d4f1a7 refactor some code, no functionality change. On the path to PR1639
llvm-svn: 41929
2007-09-13 17:29:05 +00:00
Chris Lattner 6eed0e7366 Make ValueIsOnlyUsedLocallyOrStoredToOneGlobal smart enough to see through
bitcasts and phis.  This is a step to fixing PR1639.

llvm-svn: 41928
2007-09-13 16:37:20 +00:00
Chris Lattner 2d2892ee6e Make AllUsesOfLoadedValueWillTrapIfNull strong enough to see through PHI
nodes.  This is the first step of the fix for PR1639.

llvm-svn: 41927
2007-09-13 16:30:19 +00:00
Dale Johannesen bed9dc423c Next round of APFloat changes.
Use APFloat in UpgradeParser and AsmParser.
Change all references to ConstantFP to use the
APFloat interface rather than double.  Remove
the ConstantFP double interfaces.
Use APFloat functions for constant folding arithmetic
and comparisons.
(There are still way too many places APFloat is
just a wrapper around host float/double, but we're
getting there.)

llvm-svn: 41747
2007-09-06 18:13:44 +00:00
David Greene c656cbb8c2 Update GEP constructors to use an iterator interface to fix
GLIBCXX_DEBUG issues.

llvm-svn: 41697
2007-09-04 15:46:09 +00:00
David Greene 703623d571 Update InvokeInst to work like CallInst
llvm-svn: 41506
2007-08-27 19:04:21 +00:00
Dan Gohman 71eaf62e5f Change comments to refer to @malloc and @free instead of %malloc and %free.
llvm-svn: 41488
2007-08-27 16:11:48 +00:00