Commit Graph

2678 Commits

Author SHA1 Message Date
Victor Hernandez a3aaf85e23 Remove MallocInst from LLVM Instructions.
llvm-svn: 84299
2009-10-17 01:18:07 +00:00
Victor Hernandez 6f834660c9 Invert isSafeToGetMallocArraySize check because we return NULL when we don't know the size.
Thanks to Duncan Sands for noticing this bug.

llvm-svn: 84261
2009-10-16 18:08:17 +00:00
Evan Cheng 8ec25937f1 When checking aliases between phi sources and V2, we know the sources are not themselves phi nodes. However, V2 may be. Call aliasCheck with V2 first to potentially eliminate a std::swap call.
llvm-svn: 84226
2009-10-16 00:33:09 +00:00
Victor Hernandez 13020b1faf Fix bug where array malloc with unexpected computation of the size argument resulted in MallocHelper
identifying the malloc as a non-array malloc.  This broke GlobalOpt's optimization of stores of mallocs 
to global variables.

The fix is to classify malloc's into 3 categories:
1. non-array mallocs
2. array mallocs whose array size can be determined
3. mallocs that cannot be determined to be of type 1 or 2 and cannot be optimized

getMallocArraySize() returns NULL for category 3, and all users of this function must avoid their 
malloc optimization if this function returns NULL.

Eventually, currently unexpected codegen for computing the malloc's size argument will be supported in
isArrayMalloc() and getMallocArraySize(), extending malloc optimizations to those examples.

llvm-svn: 84199
2009-10-15 20:14:52 +00:00
Nick Lewycky d708a4908c Add missing break statements! Thanks to Duncan Sands for pointing this out!
llvm-svn: 84191
2009-10-15 18:48:58 +00:00
Nick Lewycky 9cec2380f2 Teach basicaa about memcpy/memmove/memset. The length argument can be used to
improve alias results if constant, and the source pointer can't be modified.

llvm-svn: 84175
2009-10-15 07:11:24 +00:00
Nick Lewycky d7216cf74c Teach BasicAA to use the size parameter of the memory use marker intrinsics.
llvm-svn: 84174
2009-10-15 06:12:11 +00:00
Nick Lewycky fcb27ad54c Take advantage of TargetData when available; we know that the atomic intrinsics
only dereference the element they point to directly with no pointer arithmetic.

llvm-svn: 84159
2009-10-15 00:36:35 +00:00
Evan Cheng b3ccb6498c Clear VisitedPHIs after use.
llvm-svn: 84080
2009-10-14 06:46:26 +00:00
Evan Cheng c1eed9d120 Another BasicAA fix. If a value does not alias a GEP's base pointer, then it
cannot alias the GEP. GEP pointer alias rule states this clearly:
A pointer value formed from a getelementptr instruction is associated with the
addresses associated with the first operand of the getelementptr.

llvm-svn: 84079
2009-10-14 06:41:49 +00:00
Evan Cheng f92f5557ee More code clean up based on patch feedback.
llvm-svn: 84074
2009-10-14 05:22:03 +00:00
Evan Cheng 31565b3e9f Change VisitedPHIs into an instance variable that's freed by each alias() call.
llvm-svn: 84072
2009-10-14 05:05:02 +00:00
Evan Cheng c10e88db22 Teach basic AA about PHI nodes. If all operands of a phi NoAlias another value than it's safe to declare the PHI NoAlias the value. Ditto for MustAlias.
llvm-svn: 84038
2009-10-13 22:02:20 +00:00
Dan Gohman abb728d3f4 Compute a full cost value even when a setjmp call is found.
llvm-svn: 84015
2009-10-13 20:10:10 +00:00
Dan Gohman 2ccea5d13f Split code not specific to Function inlining out into a separate class,
named CodeMetrics. Move it to be a non-nested class. Rename RegionInfo
back to FunctionInfo.

llvm-svn: 84013
2009-10-13 19:58:07 +00:00
Benjamin Kramer a8d176d62f Update the other CMake file.
llvm-svn: 84003
2009-10-13 18:50:54 +00:00
Evan Cheng f1f3dd3c3c Refactor some code. No functionality changes.
llvm-svn: 84000
2009-10-13 18:42:04 +00:00
Dan Gohman 4552e3cd73 Move the InlineCost code from Transforms/Utils to Analysis.
llvm-svn: 83998
2009-10-13 18:30:07 +00:00
Devang Patel c5cc659cfa "there is not any instruction with attached debug info in this module" does not mean "there is no debug info in this module". :)
llvm-svn: 83984
2009-10-13 17:35:35 +00:00
Nick Lewycky e2782c7614 Teach BasicAA a little something about the atomic intrinsics: they can only
modify through the pointer they're given.

llvm-svn: 83959
2009-10-13 07:48:38 +00:00
Victor Hernandez 70e8505eb1 Memory dependence analysis was incorrectly stopping to scan for stores to a pointer at bitcast uses of a malloc call.
It should continue scanning until the malloc call, and this patch fixes that.

llvm-svn: 83931
2009-10-13 01:42:53 +00:00
Dan Gohman dc4893abfe Revert r83606 and add comments explaining why it isn't safe.
llvm-svn: 83649
2009-10-09 16:35:06 +00:00
Dan Gohman d65387a49f Preserve HasNSW and HasNUW when constructing SCEVs for Add and Mul
instructions.

llvm-svn: 83606
2009-10-09 00:41:22 +00:00
Dan Gohman 816fe0a4aa Add the ability to track HasNSW and HasNUW on more kinds of SCEV expressions.
llvm-svn: 83601
2009-10-09 00:10:36 +00:00
Douglas Gregor da3c79698c Update CMake build yet again after a source file was removed
llvm-svn: 83575
2009-10-08 21:24:34 +00:00
Bill Wendling 3dc625cdce It's possible for a global variable to be optimized out of a metadata object. So
we should allow a "null" with this dyn_cast.

llvm-svn: 83573
2009-10-08 20:52:51 +00:00
Chris Lattner 78765deded remove LoopVR pass. According to Nick:
"LoopVR's logic was copied into ScalarEvolution::getUnsignedRange and 
::getSignedRange. Please delete LoopVR."

llvm-svn: 83531
2009-10-08 06:42:44 +00:00
Devang Patel 55571bd7bd Extract subprogram and compile unit information from the debug info attached to an instruction.
llvm-svn: 83491
2009-10-07 22:04:08 +00:00
Torok Edwin a4560bad97 Add PR to this FIXME, looks like I didn't commit this change after all.
llvm-svn: 83457
2009-10-07 09:22:55 +00:00
Duncan Sands 9ed7b16bf3 Introduce and use convenience methods for getting pointer types
where the element is of a basic builtin type.  For example, to get
an i8* use getInt8PtrTy.

llvm-svn: 83379
2009-10-06 15:40:36 +00:00
Evan Phoenix 44e5dbcaf0 Extend ConstantFolding to understand signed overflow variants
llvm-svn: 83338
2009-10-05 22:53:52 +00:00
Torok Edwin c5b8846891 Don't treat malloc calls with non-matching prototype as malloc.
Fixes second part of PR5130, miscompilation in FreeBSD kernel, where malloc takes 3 params,
and *does* initialize memory.

llvm-svn: 83324
2009-10-05 21:15:43 +00:00
Dan Gohman e525d9ddc0 Remove an unnnecessary LLVMContext argument in
ConstantFoldLoadThroughGEPConstantExpr.

llvm-svn: 83311
2009-10-05 16:36:26 +00:00
Chris Lattner 59d939894b teach the optimizer how to constant fold uadd/usub intrinsics.
llvm-svn: 83295
2009-10-05 05:26:04 +00:00
Chris Lattner 351534f9b1 simplify this code a bunch.
llvm-svn: 83294
2009-10-05 05:06:24 +00:00
Chris Lattner 9ca7c0913a code simplifications.
llvm-svn: 83292
2009-10-05 05:00:35 +00:00
Mike Stump 70cb67fcf4 Expand api out in the usual inserter way, though, I do have a
question, can we get rid of the BasicBlock versions of all inserters
and use Head == 0 to indicate the old case when GetInsertBlock == 0?

llvm-svn: 83216
2009-10-01 22:08:58 +00:00
Devang Patel 34986f12e6 Add another MDNode into DebugLocTuple. This will be used to keep track of inlined functions.
llvm-svn: 83190
2009-10-01 01:15:28 +00:00
Devang Patel a49be76f43 Add isFOO() helpers. Fix getDirectory() and getFilename() for DIScope.
llvm-svn: 83180
2009-09-30 22:34:41 +00:00
Mike Stump 14cf8ecf0b Add a way for a frontend to generate more complex dwarf location
information.  This allows arbitrary code involving DW_OP_plus_uconst
and DW_OP_deref.  The scheme allows for easy extention to include,
any, or all of the DW_OP_ opcodes.  I thought about just exposing all
of them, but, wasn't sure if people wanted the dwarf opcodes exposed
in the api.  Is that a layering violation?

With this scheme, the entire existing block scheme used by llvm-gcc
can be switched over to the new scheme.  I think that would be
cleaner, as then the compiler specific bits are not present in llvm
proper.  Before the old code can be yanked however, similar code in
clang would have to be removed.

Next up, more testing.

llvm-svn: 83120
2009-09-30 00:08:22 +00:00
Devang Patel b296942f6d Remove std::string uses from DebugInfo interface.
llvm-svn: 83083
2009-09-29 18:40:58 +00:00
Dan Gohman f230656a02 When extending the operands of an addrec, iterate through all
the operands, rather than trying to partition them into a start
and a step. This handles non-affine add recurrences correctly.

llvm-svn: 83011
2009-09-28 21:01:47 +00:00
Dan Gohman d1415a8e56 Create a README.txt for lib/Analysis, and add an entry.
llvm-svn: 83001
2009-09-28 18:38:53 +00:00
Dan Gohman 86dc886584 Fix this debug output to handle the case where the loop has been deleted.
llvm-svn: 82994
2009-09-28 15:40:01 +00:00
Dan Gohman 0bd312afd8 Include the name of the loop header in debug messages.
llvm-svn: 82993
2009-09-28 15:07:18 +00:00
Dan Gohman 4dbb301f17 Move the dominator verification code out of special code embedded within
the PassManager code into a regular verifyAnalysis method.

Also, reorganize loop verification. Make the LoopPass infrastructure
call verifyLoop as needed instead of having LoopInfo::verifyAnalysis
check every loop in the function after each looop pass. Add a new
command-line argument, -verify-loop-info, to enable the expensive
full checking.

llvm-svn: 82952
2009-09-28 00:27:48 +00:00
Dan Gohman 2963777d0c Move this assert to check the condition as soon as it is known.
llvm-svn: 82951
2009-09-28 00:10:28 +00:00
Dan Gohman 277e767578 Extend the StartPassTimer and StopPassTimer functions so that the
code that stops the timer doesn't have to search to find the timer
object before it stops the timer. This avoids a lock acquisition
and a few other things done with the timer running.

llvm-svn: 82949
2009-09-28 00:07:05 +00:00
Dan Gohman b0934cdd1c Fix an old copy+pasto.
llvm-svn: 82947
2009-09-27 23:52:07 +00:00
Dan Gohman adde5dfde2 Extract the code for inserting a loop into the loop queue into
a separate function.

llvm-svn: 82946
2009-09-27 23:49:43 +00:00
Dan Gohman 37a99664ff When a loop is deleted, immediately release all of the active
LoopPasses for that loop. This avoids trouble with the PassManager
trying to call verifyAnalysis on them, and frees up some memory
sooner rather than later.

llvm-svn: 82945
2009-09-27 23:43:07 +00:00
Dan Gohman cb663d749d Delete a bogus comment.
llvm-svn: 82908
2009-09-27 17:50:44 +00:00
Dan Gohman 2aab867048 Fix SCEVExpander's canonical addrec expansion code to work on loops that
aren't in canonical loop-simplify form, since it doesn't itself depend
on LoopSimplify. This means handling loops without preheaders and loops
with multiple backedges.

llvm-svn: 82905
2009-09-27 17:46:40 +00:00
Dan Gohman 6daa565cf9 Instead of testing whether an instruction dominates the loop preheader,
test whether it properly dominates the loop header. This is equivalent
when the loop has a preheader, and has the advantage of working when
the loop doesn't have a preheader. Since IVUsers doesn't Require
LoopSimplify, the loop isn't guaranteed to have a preheader.

llvm-svn: 82899
2009-09-27 15:30:00 +00:00
Dan Gohman f39a3a9288 Add a properlyDominates member function to ScalarEvolution.
llvm-svn: 82898
2009-09-27 15:26:03 +00:00
Dan Gohman 0523507a2f Remove a redundant #include.
llvm-svn: 82897
2009-09-27 15:21:52 +00:00
Dan Gohman 5bafe38916 Fix a case where ScalarEvolution was expanding pointer arithmetic
to inttoptr/ptrtoint unnecessarily.

llvm-svn: 82864
2009-09-26 16:11:57 +00:00
Dale Johannesen f6a987b784 Handle sqrt in CannotBeNegativeZero. absf and absl
appear to be misspellings, removed in favor of fabs*.

llvm-svn: 82796
2009-09-25 20:54:50 +00:00
Victor Hernandez ddc2ce4fe2 No need to verify that malloc's return type is i8*.
llvm-svn: 82561
2009-09-22 18:50:03 +00:00
Daniel Dunbar 0356483539 Switch DIDescriptor to use a TrackingVH. - This makes it much safer to work with debug info, since it was extraordinarily easy to have dangling pointers thanks to MDNode uniquing.
llvm-svn: 82507
2009-09-22 02:03:18 +00:00
Chris Lattner 7e6d56ebc5 Revert r82404, it is causing a bootstrap miscompile. This is very very
scary, as it indicates a lurking bug. yay.

llvm-svn: 82411
2009-09-20 22:44:26 +00:00
Chris Lattner eea16a168a improve memdep to eliminate bitcasts (and aliases, and noop geps)
early for the stated reasons: this allows it to find more 
equivalences and depend less on code layout.

llvm-svn: 82404
2009-09-20 21:00:18 +00:00
Daniel Dunbar 7d6781b0fe Tabs -> spaces, and remove trailing whitespace.
llvm-svn: 82355
2009-09-20 02:20:51 +00:00
Daniel Dunbar c418d6b106 Strip trailing whitespace.
llvm-svn: 82332
2009-09-19 20:40:05 +00:00
Nick Lewycky 3b8bd05081 Add a comment explaining why you would ever want to do this.
llvm-svn: 82319
2009-09-19 19:00:06 +00:00
Nick Lewycky 7e6deb1cb4 Lett users of sparse propagation do their own thing with phi nodes if they want
to. This can be combined with LCSSA or SSI form to store more information on a
PHINode than can be computed by looking at its incoming values.

llvm-svn: 82317
2009-09-19 18:33:36 +00:00
Duncan Sands 1636b7ef47 The flag "--dot-cfg-only" is at the moment equivalent to the flag "--dot-cfg".
It prints the content of all bbs, instead of printing empty bbs to make the
CFG more readable.  Fix this.  Patch by Tobias Grosser.

llvm-svn: 82315
2009-09-19 11:25:44 +00:00
Victor Hernandez 537d8d99be Enhance analysis passes so that they apply the same analysis to malloc calls as to MallocInst.
Reviewed by Eli Friedman.

llvm-svn: 82281
2009-09-18 21:34:51 +00:00
Victor Hernandez 788eaabd18 Update malloc call creation code (AllocType is now the element type of the malloc, not the resulting type).
In getMallocArraySize(), fix bug in the case that array size is the product of 2 constants.

Extend isArrayMalloc() and getMallocArraySize() to handle case where malloc is used as char array.

Ensure that ArraySize in LowerAllocations::runOnBasicBlock() is correct type.

Extend Instruction::isSafeToSpeculativelyExecute() to handle malloc calls.

Add verification for malloc calls.

Reviewed by Dan Gohman.

llvm-svn: 82257
2009-09-18 19:20:02 +00:00
Nick Lewycky 6a3260e004 Add newlines.
llvm-svn: 82206
2009-09-18 07:36:47 +00:00
Dan Gohman 36bad00bef Teach ScalarEvolution how to reason about no-wrap flags on loops
where the induction variable has a non-unit stride, such as {0,+,2}, and
there are expressions such as {1,+,2} inside the loop formed with
or or add nsw operators.

llvm-svn: 82151
2009-09-17 18:05:20 +00:00
Devang Patel 820640d39f Provide a way to extract location info from DILocation.
llvm-svn: 82064
2009-09-16 18:20:05 +00:00
Andreas Neustifter 41c1103273 Reapplied r81355 with the problems fixed.
(See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090907/086737.html and
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090907/086746.html)

llvm-svn: 82039
2009-09-16 11:35:50 +00:00
Chris Lattner 3045f9e57b simplify some code
llvm-svn: 81961
2009-09-16 00:08:07 +00:00
Dan Gohman 94262db4d4 Teach ValueTracking how to look through GlobalAliases. GlobalAliases are
not folded in the constant folder because the constant folder doesn't
simplify ConstantExpr operands.

llvm-svn: 81864
2009-09-15 16:14:44 +00:00
Chris Lattner e0987215f0 add a new CallGraphNode::replaceCallEdge method and use it from
argpromote to avoid invalidating an iterator.  This fixes PR4977.
All clang tests now pass with expensive checking (on my system 
at least).

llvm-svn: 81843
2009-09-15 05:40:35 +00:00
Chris Lattner d4d966f500 make -debug-pass=Executions show information about what call graph nodes
are in the SCC for each execution of a CGSCC pass.

llvm-svn: 81838
2009-09-15 05:03:04 +00:00
Andreas Neustifter bcdb0423c5 Bugfix. Sorry.
llvm-svn: 81517
2009-09-11 08:43:15 +00:00
Andreas Neustifter f5a1ca2133 Make ProfileEstimator even more robust on general CFGs.
llvm-svn: 81516
2009-09-11 08:39:33 +00:00
Dan Gohman 21c6216c87 Teach lib/VMCore/ConstantFold.cpp how to set the inbounds keyword and
how to fold notionally-out-of-bounds array getelementptr indices instead
of just doing these in lib/Analysis/ConstantFolding.cpp, because it can
be done in a fairly general way without TargetData, and because not all
constants are visited by lib/Analysis/ConstantFolding.cpp. This enables
more constant folding.

Also, set the "inbounds" flag when the getelementptr indices are
one-past-the-end.

llvm-svn: 81483
2009-09-11 00:04:14 +00:00
Dan Gohman 91d598de5c Give these files top-level comments that describe the current code.
llvm-svn: 81473
2009-09-10 23:07:18 +00:00
Dale Johannesen 50f0376f49 Fix uppercaseo.
llvm-svn: 81463
2009-09-10 22:01:32 +00:00
Victor Hernandez 7b98b9291c Fit code within 80 columns
llvm-svn: 81459
2009-09-10 20:18:57 +00:00
Andreas Neustifter 753441e318 Make ProfileEstimator more robust on general CFGs.
llvm-svn: 81450
2009-09-10 16:30:38 +00:00
Benjamin Kramer 4bf4e8686c Add some braces to make newer GCCs happy and update CMakeLists.
llvm-svn: 81443
2009-09-10 11:31:39 +00:00
Andreas Neustifter f4858d59e5 Cleaned up code by factoring out common portions of edge loading into function.
llvm-svn: 81438
2009-09-10 07:12:35 +00:00
Evan Cheng 1d9d4bdc99 Add malloc call utility functions. Patch by Victor Hernandez.
llvm-svn: 81426
2009-09-10 04:36:43 +00:00
Andreas Neustifter 1bad7f222a Reverted r81358.
llvm-svn: 81364
2009-09-09 18:19:35 +00:00
Benjamin Kramer 3cb19a156d Fix build, add missing simicolon.
llvm-svn: 81362
2009-09-09 18:03:46 +00:00
Andreas Neustifter 93bc18f80a Add the first functions for updating ProfileInfo.
llvm-svn: 81359
2009-09-09 17:52:57 +00:00
Andreas Neustifter 505fd86bd2 Cleaned up code by factoring out common portions of edge loading into funcion.
llvm-svn: 81358
2009-09-09 17:51:39 +00:00
Chris Lattner 9ded9ac8af revert r81335, which breaks the build.
llvm-svn: 81347
2009-09-09 16:00:57 +00:00
Andreas Neustifter ba545ec6f5 Fixed wrong storage option for ProfileVerifierDisableAssertions.
Fixed non working -profile-verifier-noassert option.
Fixed missing newline in debugEntry().
Cleaned up assert messages. (assert(0 && Message) is still shown, but the message is printed before.)
When verifiying loaded profiles the ProfileVerifier got confused when block was a setjmp target, this is checked now.
When verifiying loaded profiles the ProfileVerifier got confused when block eventually reaching an exit(), this is checked now.

llvm-svn: 81338
2009-09-09 13:01:03 +00:00
Andreas Neustifter 0bd472dc33 Updated ProfileInfo to have clean seperation between different sentinels.
llvm-svn: 81335
2009-09-09 12:48:26 +00:00
Dan Gohman 3ddbc242fb Re-apply r80926, with fixes: keep the domtree informed of new blocks
that get created during loop unswitching, and fix SplitBlockPredecessors'
LCSSA updating code to create new PHIs instead of trying to just move
existing ones.

Also, optimize Loop::verifyLoop, since it gets called a lot. Use
searches on a sorted list of blocks instead of calling the "contains"
function, as is done in other places in the Loop class, since "contains"
does a linear search. Also, don't call verifyLoop from LoopSimplify or
LCSSA, as the PassManager is already calling verifyLoop as part of
LoopInfo's verifyAnalysis.

llvm-svn: 81221
2009-09-08 15:45:00 +00:00
Chris Lattner 0cdbc7a2ca fix ComputeMaskedBits handling of zext/sext/trunc to work with vectors.
This fixes PR4905

llvm-svn: 81174
2009-09-08 00:13:52 +00:00
Chris Lattner 4bc2825d0b add some comments to describe the invariants.
llvm-svn: 81173
2009-09-08 00:06:16 +00:00
Duncan Sands 4827538f82 Do not try to override non-virtual methods, especially
when the new method gives the same result as the original
(as far as I can see).  This will hopefully pacify icc.

llvm-svn: 81131
2009-09-06 20:02:00 +00:00
Duncan Sands d216b05e75 Mark more constants unsigned, as warned about by icc (#68).
Patch by Erick Tryzelaar.

llvm-svn: 81116
2009-09-06 12:56:52 +00:00
Evan Cheng 904199547b Revert r80926. It causes loop unswitch assertion and slow down some JIT tests significantly.
llvm-svn: 81101
2009-09-06 02:26:10 +00:00
Andreas Neustifter b7d704dac3 Prevent warnings on compilers for which its not clear that assert won't return.
llvm-svn: 81044
2009-09-04 21:22:04 +00:00
Andreas Neustifter 8f166f6a36 Cleaned up ProfileVerifierPass.
(See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090831/086219.html)

llvm-svn: 81007
2009-09-04 17:15:10 +00:00
Daniel Dunbar a48a2f6055 Revert "--- Reverse-merging r80908 into '.':", I already "fixed" this.
llvm-svn: 80970
2009-09-03 23:40:10 +00:00
Dan Gohman e4ca02da1b Revert 80959. It isn't sufficient to solve the full problem. And it
introduced regressions in the Ocaml bindings tests.

llvm-svn: 80969
2009-09-03 23:34:49 +00:00
Bill Wendling 92291f6ad0 --- Reverse-merging r80908 into '.':
D    test/Analysis/Profiling

--- Reverse-merging r80907 into '.':
U    lib/Analysis/ProfileInfoLoaderPass.cpp

Attempt to remove failure in the self-hosting build bot.

llvm-svn: 80966
2009-09-03 23:13:46 +00:00
Dan Gohman 2a53b30f6d Remove the API for creating ConstantExprs with the nsw, nuw, inbounds,
and exact flags. Because ConstantExprs are uniqued, creating an
expression with this flag causes all expressions with the same operands
to have the same flag, which may not be safe. Add, sub, mul, and sdiv
ConstantExprs are usually folded anyway, so the main interesting flag
here is inbounds, and the constant folder already knows how to set the
inbounds flag automatically in most cases, so there isn't an urgent need
for the API support.

This can be reconsidered in the future, but for now just removing these
API bits eliminates a source of potential trouble with little downside.

llvm-svn: 80959
2009-09-03 22:17:40 +00:00
Dan Gohman ed8f32022e Smallvectorize switchExitBlocks.
llvm-svn: 80942
2009-09-03 20:36:13 +00:00
Dan Gohman 4c1bdcf5d7 Add a verifyAnalysis to LoopInfo, LoopSimplify, and LCSSA form that verify
that these passes are properly preserved.

Fix several transformation passes that claimed to preserve LoopSimplify
form but weren't.

llvm-svn: 80926
2009-09-03 16:31:42 +00:00
Dan Gohman 3a0ce3e639 Move getUniqueExitBlocks from LoopBase to Loop, since they depend on
LoopSimplify form, which is currently only available on Loops (and
not MachineLoops). Also, move the code out of the header file.

llvm-svn: 80923
2009-09-03 16:10:48 +00:00
Dan Gohman 96a26bd35a Don't try to verify a LoopPass analysis if the loop has been deleted.
llvm-svn: 80919
2009-09-03 15:09:24 +00:00
Dan Gohman 237d9e5213 Remove references to expression "handles", which are no longer used.
llvm-svn: 80918
2009-09-03 15:00:26 +00:00
Andreas Neustifter d194e13b8d Fix build warning.
llvm-svn: 80912
2009-09-03 09:11:10 +00:00
Andreas Neustifter b68e921c25 Code Cleanup.
(See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090831/086139.html)

llvm-svn: 80909
2009-09-03 08:41:05 +00:00
Daniel Dunbar 0dc21e4713 Remove undefined behavior when loading optimal edge profile info.
llvm-svn: 80907
2009-09-03 07:37:42 +00:00
Gabor Greif 2d60e1ec0c back out my recent commit (r80858), it seems to break self-hosting buildbot's stage 2 configure
llvm-svn: 80871
2009-09-03 02:02:59 +00:00
Gabor Greif 14dfba6d66 re-commit r66920 (which has been backed out in r66953) I may have more luck this time. I'll back out if needed...
llvm-svn: 80858
2009-09-03 00:18:58 +00:00
Torok Edwin 18e03dd70c Fix DbgStopPointInst->getFileName/getDirectory, broken by the MDNodification in
r80406, and readd a -print-dbginfo test.

llvm-svn: 80778
2009-09-02 11:13:56 +00:00
Chris Lattner 950e60ea97 fix PR4848 an infinite loop when indexing down through a recursive gep
and we get the original pointer type.  This doesn't mean that we're
at the first pointer being indexed.  Correct the predicate.

llvm-svn: 80762
2009-09-02 05:35:45 +00:00
Chris Lattner 65fb597793 revert my patch, duncan points out what is wrong with my logic. Add
a comment so that I don't change this in the future :)

llvm-svn: 80760
2009-09-02 04:39:04 +00:00
Chris Lattner 8f23276431 one more try at making this simpler, hopefully it won't break everything :)
llvm-svn: 80759
2009-09-02 04:34:06 +00:00
Duncan Sands 5632d96176 Complicate Chris's simplification, avoiding complaints
about singular iterators when building with expensive
checks turned on.

llvm-svn: 80757
2009-09-02 03:48:41 +00:00
Daniel Dunbar 2a275102d3 Fix build warning.
llvm-svn: 80730
2009-09-01 22:07:12 +00:00
Chris Lattner 6190bb01be debug intrinsics do not go in the callgraph, this fixes a couple
clang regtest failures.

llvm-svn: 80724
2009-09-01 21:37:50 +00:00
Chris Lattner 339c82df85 Fix a regression I introduced in r80708, found by llvm-test.
llvm-svn: 80718
2009-09-01 20:33:43 +00:00
Andreas Neustifter e3cdafc70b OptimalEdgeProfiling: Reading in Profiles.
This enables LLVM to read the OptimalEdgeProfiles.

llvm-svn: 80715
2009-09-01 19:08:51 +00:00
Andreas Neustifter 4fde5c756d Small fix in ProfileEstimator that eliminates duplicated code.
llvm-svn: 80711
2009-09-01 19:01:59 +00:00
Chris Lattner 9b463729d7 remove CallGraphNode::replaceCallSite, it is redundant with other APIs.
llvm-svn: 80708
2009-09-01 18:52:39 +00:00
Chris Lattner e33167ac35 doxygenate RefreshCallGraph, add a new 'verification mode', and run it after
CGSCC passes make change to ensure they are updating the callgraph correctly
(when assertions are enabled).

llvm-svn: 80698
2009-09-01 18:32:03 +00:00
Chris Lattner 3f7b3d149f simpler solution to iterator invalidation "problem" found
by expensive checking.

llvm-svn: 80695
2009-09-01 18:13:40 +00:00
Duncan Sands 1f8303bfce Do not manipulate invalid iterators. This fixes the
llvm-gcc build when expensive checking is turned on.

llvm-svn: 80671
2009-09-01 15:13:02 +00:00
Benjamin Kramer a43ad3ddbd Update CMakeLists.
llvm-svn: 80669
2009-09-01 10:24:10 +00:00
Andreas Neustifter 8bcd5dcf5d Preparation for Optimal Edge Profiling:
Optimal edge profiling is only possible when blocks with no predecessors get an
virtual edge (BB,0) that counts the execution frequencies of this
function-exiting blocks.
This patch makes the necessary changes before actually enabling optimal edge profiling.

llvm-svn: 80667
2009-09-01 10:06:05 +00:00
Andreas Neustifter b683b6e2ce Preparation for Optimal Edge Profiling:
This adds a pass to verify the current profile against the flow conditions.
This is very helpful when later on trying to perserve the profiling information
during all passes.

llvm-svn: 80666
2009-09-01 08:48:42 +00:00
Chris Lattner 063d06527e Change CallGraphNode to maintain it's Function as an AssertingVH
for sanity.  This didn't turn up any bugs.

Change CallGraphNode to maintain its "callsite" information in the 
call edges list as a WeakVH instead of as an instruction*.  This fixes
a broad class of dangling pointer bugs, and makes CallGraph have a number
of useful invariants again.  This fixes the class of problem indicated
by PR4029 and PR3601.

llvm-svn: 80663
2009-09-01 06:31:31 +00:00
Devang Patel b1bff47718 Introduce DILocation.
llvm-svn: 80648
2009-09-01 01:14:15 +00:00
Devang Patel b2de5fa689 Subprogram is a scope. Derive DISubprogram from DIScope.
llvm-svn: 80637
2009-08-31 22:47:13 +00:00
Devang Patel 869529c58c Rename DIBlock as DILexicalBlock.
llvm-svn: 80633
2009-08-31 22:00:15 +00:00
Dan Gohman dba696afc0 Don't use an iterator which is potentially invalidated.
llvm-svn: 80632
2009-08-31 21:58:28 +00:00
Devang Patel e4cfcc3081 Derive DICompileUnit from DIScope.
llvm-svn: 80627
2009-08-31 21:34:44 +00:00
Dan Gohman cc2f1eb7fe Extend the ValuesAtScope cache to cover all expressions, not just
SCEVUnknowns, as the non-SCEVUnknown cases in the getSCEVAtScope code
can also end up repeatedly climing through the same expression trees,
which can be unusably slow when the trees are very tall.

Also, add a quick check for SCEV pointer equality to the main
SCEV comparison routine, as the full comparison code can be expensive
in the case of large expression trees.

These fix compile-time problems in some pathlogical cases.

llvm-svn: 80623
2009-08-31 21:15:23 +00:00
Devang Patel d9b6115f27 Introduce DIScope.
llvm-svn: 80620
2009-08-31 20:44:45 +00:00
Devang Patel 88a26fb0f1 Oops. Fix inverted logic in assertion check.
llvm-svn: 80618
2009-08-31 20:27:49 +00:00
Devang Patel 9fda4bd998 Simplify isDerivedType() and other predicate interface.
llvm-svn: 80602
2009-08-31 18:49:10 +00:00
Chris Lattner a9262bb19c cleanups pointed out by duncan
llvm-svn: 80595
2009-08-31 17:08:30 +00:00
Chris Lattner eedcd84803 Step #1 to giving Callgraph some sane invariants. The problems with callgraph
stem from the fact that we have two types of passes that need to update it:

1. callgraphscc and module passes that are explicitly aware of it
2. Functionpasses (and loop passes etc) that are interlaced with CGSCC passes
   by the CGSCC Passmgr.

In the case of #1, we can reasonably expect the passes to update the call
graph just like any analysis.  However, functionpasses are not and generally
should not be CG aware.  This has caused us no end of problems, so this takes
a new approach.  Logically, the CGSCC Pass manager can rescan every function 
after it runs a function pass over it to see if the functionpass made any 
updates to the IR that affect the callgraph.  This allows it to catch new calls
introduced by the functionpass.

In practice, doing this would be slow.  This implementation keeps track of
whether or not the current scc is dirtied by a function pass, and, if so, 
delays updating the callgraph until it is actually needed again.  This was
we avoid extraneous rescans, but we still have good invariants when the
callgraph is needed.

Step #2 of the "give Callgraph some sane invariants" is to change CallGraphNode
to use a CallBackVH for the callsite entry of the CallGraphNode.  This way
we can immediately remove entries from the callgraph when a FunctionPass is
active instead of having dangling pointers.  The current pass tries to tolerate
these dangling pointers, but it is just an evil hack.

This is related to PR3601/4835/4029.  This also reverts r80541, a hack working
around the sad lack of invariants.

llvm-svn: 80566
2009-08-31 07:23:46 +00:00
Chris Lattner 7e4fbddf39 cleanups, factor some code out to a helper function
llvm-svn: 80542
2009-08-31 06:01:21 +00:00
Chris Lattner b822abd37d fix a crash building SPASS by tolerating a callsite that doesn't exist
in the callgraph, see the big comment at the top of the testcase.

llvm-svn: 80541
2009-08-31 05:46:59 +00:00
Chris Lattner 081375bb08 Fix PR4834, a tricky case where the inliner would resolve an
indirect function pointer, inline it, then go to delete the body.
The problem is that the callgraph had other references to the function,
though the inliner had no way to know it, so we got a dangling pointer
and an invalid iterator out of the deal.

The fix to this is pretty simple: stop the inliner from deleting the
function by knowing that there are references to it.  Do this by making
CallGraphNodes contain a refcount.  This requires moving deletion of 
available_externally functions to the module-level cleanup sweep where
it belongs.

llvm-svn: 80533
2009-08-31 03:15:49 +00:00
Chris Lattner 4275cf2efa use an accessor instead of poking internals of a node.
llvm-svn: 80532
2009-08-31 02:24:20 +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