Commit Graph

62 Commits

Author SHA1 Message Date
Nick Lewycky f740db31e2 SCCCaptured is trivially false on entry to this loop and not modified inside it.
Eliminate the dead test for it on each loop iteration. No functionality change.

llvm-svn: 147616
2012-01-05 22:21:45 +00:00
Nick Lewycky 4c378a4453 Change CaptureTracking to pass a Use* instead of a Value* when a value is
captured. This allows the tracker to look at the specific use, which may be
especially interesting for function calls.

Use this to fix 'nocapture' deduction in FunctionAttrs. The existing one does
not iterate until a fixpoint and does not guarantee that it produces the same
result regardless of iteration order. The new implementation builds up a graph
of how arguments are passed from function to function, and uses a bottom-up walk
on the argument-SCCs to assign nocapture. This gets us nocapture more often, and
does so rather efficiently and independent of iteration order.

llvm-svn: 147327
2011-12-28 23:24:21 +00:00
Eli Friedman a917d4f9b4 Revert a bit of r137667; the logic in question can safely handle atomic load/store.
llvm-svn: 137702
2011-08-16 01:28:22 +00:00
Eli Friedman 211e348eaa Update inter-procedural optimizations for atomic load/store.
llvm-svn: 137667
2011-08-15 22:16:46 +00:00
Dan Gohman 65316d6749 Add helper functions for computing the Location of load, store,
and vaarg instructions.

llvm-svn: 118845
2010-11-11 21:50:19 +00:00
Dan Gohman 066c1bb1e9 Add a doesAccessArgPointees helper function, and update code to use
it, and to be consistent.

llvm-svn: 118692
2010-11-10 18:17:28 +00:00
Dan Gohman 2577580967 Factor out the code for testing whether a function accesses
arbitrary memory into a helper function, and adjust some comments.

llvm-svn: 118687
2010-11-10 17:34:04 +00:00
Dan Gohman 2694e14087 Make ModRefBehavior a lattice. Use this to clean up AliasAnalysis
chaining and simplify FunctionAttrs' GetModRefBehavior logic.

llvm-svn: 118660
2010-11-10 01:02:18 +00:00
Dan Gohman e3467a7687 Teach FunctionAttrs about the VAArg instruction.
llvm-svn: 118627
2010-11-09 20:17:38 +00:00
Dan Gohman 35814e6128 Use the AliasAnalysis interface to determine how a Function accesses
memory. This isn't a real improvement with present day AliasAnalysis
implementations; it's mainly for consistency.

llvm-svn: 118624
2010-11-09 20:13:27 +00:00
Dan Gohman de52155685 Teach FunctionAttrs about AccessesArgumentsReadonly.
llvm-svn: 118617
2010-11-09 19:56:27 +00:00
Dan Gohman 470ade12e0 Fix a thinko that Duncan spotted.
llvm-svn: 118430
2010-11-08 19:24:47 +00:00
Dan Gohman 2cd1fd4a82 Make FunctionAttrs TBAA-aware.
llvm-svn: 118417
2010-11-08 17:12:04 +00:00
Dan Gohman 9130bad71f Extend the AliasAnalysis::pointsToConstantMemory interface to allow it
to optionally look for constant or local (alloca) memory.

Teach BasicAliasAnalysis::pointsToConstantMemory to look through Select
and Phi nodes, and to support looking for local memory.

Remove FunctionAttrs' PointsToLocalOrConstantMemory function, now that
AliasAnalysis knows all the tricks that it knew.

llvm-svn: 118412
2010-11-08 16:45:26 +00:00
Dan Gohman 86449d705a Make FunctionAttrs use AliasAnalysis::getModRefBehavior, now that it
knows about intrinsic functions.

llvm-svn: 118410
2010-11-08 16:10:15 +00:00
Duncan Sands 9d1fe4c40d Rename PointsToLocalMemory to PointsToLocalOrConstantMemory to make
the code more self-documenting.

llvm-svn: 118171
2010-11-03 14:45:05 +00:00
Duncan Sands e659aba516 Now that the MallocInst no longer exists, this workaround for
it claiming not to have side-effects is no longer needed.

llvm-svn: 117789
2010-10-30 16:12:16 +00:00
Duncan Sands b8f3b14dfb If a function does a volatile load from a global constant, do not
consider it to be readonly.  In fact, don't even consider it to be
readonly if it does a volatile load from an AllocaInst either (it
is debatable as to whether readonly would be correct or not in this
case; play safe for the moment).  This fixes PR8279.

llvm-svn: 117783
2010-10-30 12:59:44 +00:00
Owen Anderson 6c18d1aac0 Get rid of static constructors for pass registration. Instead, every pass exposes an initializeMyPassFunction(), which
must be called in the pass's constructor.  This function uses static dependency declarations to recursively initialize
the pass's dependencies.

Clients that only create passes through the createFooPass() APIs will require no changes.  Clients that want to use the
CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h
before parsing commandline arguments.

I have tested this with all standard configurations of clang and llvm-gcc on Darwin.  It is possible that there are problems
with the static dependencies that will only be visible with non-standard options.  If you encounter any crash in pass
registration/creation, please send the testcase to me directly.

llvm-svn: 116820
2010-10-19 17:21:58 +00:00
Owen Anderson 071cee0c81 CallGraphSCC passes implicity require CallGraph analysis.
llvm-svn: 116443
2010-10-13 22:00:45 +00:00
Owen Anderson df7a4f2515 Now with fewer extraneous semicolons!
llvm-svn: 115996
2010-10-07 22:25:06 +00:00
Owen Anderson a7aed18624 Reapply r110396, with fixes to appease the Linux buildbot gods.
llvm-svn: 110460
2010-08-06 18:33:48 +00:00
Owen Anderson bda59bd247 Revert r110396 to fix buildbots.
llvm-svn: 110410
2010-08-06 00:23:35 +00:00
Owen Anderson 755aceb5d0 Don't use PassInfo* as a type identifier for passes. Instead, use the address of the static
ID member as the sole unique type identifier.  Clean up APIs related to this change.

llvm-svn: 110396
2010-08-05 23:42:04 +00:00
Dan Gohman 5442c71f2e Thread const correctness through a bunch of AliasAnalysis interfaces and
eliminate several const_casts.

Make CallSite implicitly convertible to ImmutableCallSite.

Rename the getModRefBehavior for intrinsic IDs to
getIntrinsicModRefBehavior to avoid overload ambiguity with CallSite,
which happens to be implicitly convertible to bool.

llvm-svn: 110155
2010-08-03 21:48:53 +00:00
Gabor Greif 62f0aac99d simplify by using CallSite constructors; virtually eliminates CallSite::get from the tree
llvm-svn: 109687
2010-07-28 22:50:26 +00:00
Owen Anderson a57b97e7e7 Fix batch of converting RegisterPass<> to INTIALIZE_PASS().
llvm-svn: 109045
2010-07-21 22:09:45 +00:00
Chris Lattner 4422d31b84 introduce a new CallGraphSCC class, and pass it around
to CallGraphSCCPass's instead of passing around a
std::vector<CallGraphNode*>.  No functionality change,
but now we have a much tidier interface.

llvm-svn: 101558
2010-04-16 22:42:17 +00:00
Duncan Sands 19d0b47b1f There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy().  Convert most instances of the first form to the second form.
Requested by Chris.

llvm-svn: 96344
2010-02-16 11:11:14 +00:00
Duncan Sands f117880ab0 Be less stingy as to how many selects and phi nodes we
are prepared to look through.

llvm-svn: 92898
2010-01-07 05:48:42 +00:00
Duncan Sands c8493da5b1 Fix a README item: have functionattrs look through selects and
phi nodes when deciding which pointers point to local memory.
I actually checked long ago how useful this is, and it isn't
very: it hardly ever fires in the testsuite, but since Chris
wants it here it is!

llvm-svn: 92836
2010-01-06 15:37:47 +00:00
Duncan Sands 78376ad7e1 Partially address a README by having functionattrs consider calls to
memcpy, memset and other intrinsics that only access their arguments
to be readnone if the intrinsic's arguments all point to local memory.
This improves the testcase in the README to readonly, but it could in
theory be made readnone, however this would involve more sophisticated
analysis that looks through the memcpy.

llvm-svn: 92829
2010-01-06 08:45:52 +00:00
Dan Gohman 94e617627d Extend CaptureTracking to indicate when a value is never stored, even
if it is not ultimately captured. Teach BasicAliasAnalysis that a 
local object address which does not escape and is never stored does
not alias with a value resulting from a load.

llvm-svn: 89398
2009-11-19 21:57:48 +00:00
Victor Hernandez f390e04a47 Rename MallocFreeHelper as MemoryBuiltins
llvm-svn: 85286
2009-10-27 20:05:49 +00:00
Victor Hernandez 762195bd01 Rename MallocHelper as MallocFreeHelper, since it now also identifies calls to free()
llvm-svn: 85181
2009-10-26 23:58:56 +00:00
Nick Lewycky 974e12b2d3 Remove includes of Support/Compiler.h that are no longer needed after the
VISIBILITY_HIDDEN removal.

llvm-svn: 85043
2009-10-25 06:57:41 +00:00
Nick Lewycky 02d5f77d26 Remove VISIBILITY_HIDDEN from class/struct found inside anonymous namespaces.
Chris claims we should never have visibility_hidden inside any .cpp file but
that's still not true even after this commit.

llvm-svn: 85042
2009-10-25 06:33:48 +00:00
Victor Hernandez 5c704d505c Malloc calls are marked NoAlias, so the code below the isMalloc() check makes it redundant. Removing the isMalloc() check.
llvm-svn: 84541
2009-10-19 21:47:22 +00:00
Victor Hernandez a3aaf85e23 Remove MallocInst from LLVM Instructions.
llvm-svn: 84299
2009-10-17 01:18:07 +00:00
Chris Lattner 43d0db70ac remove special handling of bitcast(malloc), it will be handled
when the loop inspects the bitcast operand.

llvm-svn: 82928
2009-09-27 21:29:28 +00:00
Chris Lattner a8627272c1 unlike the malloc instruction, "malloc" calls do not claim to be readonly, just nounwind.
llvm-svn: 82927
2009-09-27 21:23:38 +00:00
Victor Hernandez 5d034499ad Enhance transform passes so that they apply the same tranforms to malloc calls as to MallocInst.
Reviewed by Dan Gohman.

llvm-svn: 82300
2009-09-18 22:35:49 +00:00
Chris Lattner 2f2110affa simplify some code by making the SCCNodes set contain Function*'s
instead of CallGraphNode*'s.  This also papers over a callgraph
problem where a pass (in this case, MemCpyOpt) introduces a new
function into the module (llvm.memset.i64) but doesn't add it to
the call graph (nor should it, since it is a function pass).

While it might be a good idea for MemCpyOpt to not synthesize 
functions in a runOnFunction(), there is no need for FunctionAttrs
to be boneheaded, so fix it there.  This fixes an assertion building
176.gcc.

llvm-svn: 80535
2009-08-31 04:09:04 +00:00
Chris Lattner 305b115a87 Fix some nasty callgraph dangling pointer problems in
argpromotion and structretpromote.  Basically, when replacing
a function, they used the 'changeFunction' api which changes
the entry in the function map (and steals/reuses the callgraph
node).

This has some interesting effects: first, the problem is that it doesn't
update the "callee" edges in any callees of the function in the call graph.
Second, this covers for a major problem in all the CGSCC pass stuff, which 
is that it is completely broken when functions are deleted if they *don't*
reuse a CGN.  (there is a cute little fixme about this though :).

This patch changes the protocol that CGSCC passes must obey: now the CGSCC 
pass manager copies the SCC and preincrements its iterator to avoid passes
invalidating it.  This allows CGSCC passes to mutate the current SCC.  However
multiple passes may be run on that SCC, so if passes do this, they are now
required to *update* the SCC to be current when they return.

Other less interesting parts of this patch are that it makes passes update
the CG more directly, eliminates changeFunction, and requires clients of
replaceCallSite to specify the new callee CGN if they are changing it.

llvm-svn: 80527
2009-08-31 00:19:58 +00:00
Duncan Sands 9759f2e063 Fix PR3754: don't mark functions that wrap MallocInst with
the readnone.  Since MallocInst is scheduled for deletion
it doesn't seem worth doing anything more subtle, such as
having mayWriteToMemory return true for MallocInst.

llvm-svn: 71077
2009-05-06 08:42:00 +00:00
Duncan Sands 5cbd3d9c52 This debug info special case should no longer
be needed now that these intrinsics are marked
as not accessing memory.

llvm-svn: 66420
2009-03-09 11:57:08 +00:00
Nick Lewycky 9ec96d19e3 Fix comments, pointed out by Duncan Sands.
llvm-svn: 66381
2009-03-08 17:08:09 +00:00
Nick Lewycky fbed86a865 Mark function returns as noalias.
llvm-svn: 66369
2009-03-08 06:20:47 +00:00
Devang Patel cc40a61af7 Ignore debug info intrinsics.
llvm-svn: 65908
2009-03-03 00:28:44 +00:00
Duncan Sands e0aa0d677d BasicAliasAnalysis and FunctionAttrs were both
doing very similar pointer capture analysis.
Factor out the common logic.  The new version
is from FunctionAttrs since it does a better
job than the version in BasicAliasAnalysis

llvm-svn: 62461
2009-01-18 12:19:30 +00:00