• Home
  • History
  • Annotate
  • only in /external/llvm/include/llvm/Analysis/
History log of /external/llvm/include/llvm/Analysis/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
cd81d94322a39503e4a3e87b6ee03d4fcb3465fb 21-Jul-2014 Stephen Hines <srhines@google.com> Update LLVM for rebase to r212749.

Includes a cherry-pick of:
r212948 - fixes a small issue with atomic calls

Change-Id: Ib97bd980b59f18142a69506400911a6009d9df18
dce4a407a24b04eebc6a376f8e62b41aaa7b071f 29-May-2014 Stephen Hines <srhines@google.com> Update LLVM for 3.5 rebase (r209712).

Change-Id: I149556c940fb7dc92d075273c87ff584f400941f
36b56886974eae4f9c5ebc96befd3e7bfe5de338 24-Apr-2014 Stephen Hines <srhines@google.com> Update to LLVM 3.5a.

Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
2905440bdd9627f202398137aab5ded38f681fc9 16-Nov-2013 Benjamin Kramer <benny.kra@googlemail.com> ScalarEvolution: Warn if the result of setFlags/clearFlags is unused.

This was a source of bugs in the past.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194929 91177308-0d34-0410-b5e6-96231b3b80d8
e2058ff5bd4fa0397b57f6bdd84e5a5aa2343433 14-Nov-2013 Michael Gottesman <mgottesman@apple.com> Added BlockFrequencyInfo::view for displaying the block frequency propagation graph via graphviz.

This is useful for debugging issues in the BlockFrequency implementation since
one can easily visualize where probability mass and other errors occur in the

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194654 91177308-0d34-0410-b5e6-96231b3b80d8
5230ad61fd35d3006e7764c3152d28e2e68c288f 12-Nov-2013 Sebastian Pop <spop@codeaurora.org> delinearization of arrays

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194527 91177308-0d34-0410-b5e6-96231b3b80d8
b8fc659c8eb36796531d55fa78cbb1957895aa9b 12-Nov-2013 Sebastian Pop <spop@codeaurora.org> remove virtual methods in SCEVApplyRewriter and SCEVParameterRewriter

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194526 91177308-0d34-0410-b5e6-96231b3b80d8
2f08e75a45b9fa698a49277f6cc11e041bf5fa51 12-Nov-2013 Andrew Trick <atrick@apple.com> GraphViz CFGPrinter: wrap long lines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194496 91177308-0d34-0410-b5e6-96231b3b80d8
4be0c592c42739b1927aaf2a20b3fabbf6adf335 12-Nov-2013 Andrew Trick <atrick@apple.com> whitespace

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194495 91177308-0d34-0410-b5e6-96231b3b80d8
3cda2d38851d73eec38d38a46462aaa65de4ef8e 12-Nov-2013 Wan Xiaofei <xiaofei.wan@intel.com> Change data structure to memorize computed result in ScalarEvolution

Replace std::map with SmallVector to memorize the cached result since SCEV usually belongs to little Loop/BB
Linear scan on SmallVector is faster than std::map.

Code reviewer : Andrew Trick.
Test result : Pass Unit Test & LLVM Test Suite

401.bzip2 0.425721 0.419981 101.37%
403.gcc 24.53855 24.2667 101.12%
429.mcf 0.060847 0.059944 101.51%
433.milc 0.646009 0.636119 101.55%
444.namd 1.383928 1.370614 100.97%
445.gobmk 5.836575 5.800225 100.63%
450.soplex 1.911257 1.895963 100.81%
456.hmmer 1.039565 1.032534 100.68%
458.sjeng 0.897401 0.885567 101.34%
464.h264ref 3.645908 3.577991 101.90%
470.lbm 0.049456 0.048398 102.19%
471.omnetpp 5.638575 5.60435 100.61%
bitmnp01 0.045738 0.045291 100.99%
cjpegv2data 0.304359 0.302833 100.50%
idctrn01 0.046433 0.045763 101.46%
quake2 4.534416 4.4952 100.87%
quake 2.688566 2.659208 101.10%
xcsoar 12.42545 12.30385 100.99%
linpack 0.038739 0.03803 101.86%
matrix01 0.053564 0.0528 101.45%
nbench 0.402867 0.395803 101.78%
tblook01 0.021265 0.021015 101.19%
ttsprk01 0.066384 0.065566 101.25%

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194459 91177308-0d34-0410-b5e6-96231b3b80d8
49837ef8111fbeace7ae6379ca733c8f8fa94cfe 09-Nov-2013 Chandler Carruth <chandlerc@gmail.com> Move the old pass manager infrastructure into a legacy namespace and
give the files a legacy prefix in the right directory. Use forwarding
headers in the old locations to paper over the name change for most
clients during the transitional period.

No functionality changed here! This is just clearing some space to
reduce renaming churn later on with a new system.

Even when the new stuff starts to go in, it is going to be hidden behind
a flag and off-by-default as it is still WIP and under development.

This patch is specifically designed so that very little out-of-tree code
has to change. I'm going to work as hard as I can to keep that the case.
Only direct forward declarations of the PassManager class are impacted
by this change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194324 91177308-0d34-0410-b5e6-96231b3b80d8
10bb82e54fc0608e6220581bda0405af8f12d32f 06-Nov-2013 Andrew Trick <atrick@apple.com> Rewrite SCEV's backedge taken count computation.

Patch by Michele Scandale!

Rewrite of the functions used to compute the backedge taken count of a
loop on LT and GT comparisons.

I decided to split the handling of LT and GT cases becasue the trick
"a > b == -a < -b" in some cases prevents the trip count computation
due to the multiplication by -1 on the two operands of the
comparison. This issue comes from the conservative computation of
value range of SCEVs: taking the negative SCEV of an expression that
have a small positive range (e.g. [0,31]), we would have a SCEV with a
fullset as value range.

Indeed, in the new rewritten function I tried to better handle the
maximum backedge taken count computation when MAX/MIN expression are
used to handle the cases where no entry guard is found.

Some test have been modified in order to check the new value correctly
(I manually check them and reasoning on possible overflow the new
values seem correct).

I finally added a new test case related to the multiplication by -1
issue on GT comparisons.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194116 91177308-0d34-0410-b5e6-96231b3b80d8
c143c7573bfd0d55cf283cc2676dbd852f939c87 31-Oct-2013 Rafael Espindola <rafael.espindola@gmail.com> Merge CallGraph and BasicCallGraph.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193734 91177308-0d34-0410-b5e6-96231b3b80d8
887f9c5ec15582aec34aa6c28955d01e4e9961e2 26-Oct-2013 Wan Xiaofei <xiaofei.wan@intel.com> Quick look-up for block in loop.

This patch implements quick look-up for block in loop by maintaining a hash set for blocks.
It improves the efficiency of loop analysis a lot, the biggest improvement could be 5-6%(458.sjeng).
Below are the compilation time for our benchmark in llc before & after the patch.

Benchmark llc - trunk llc - patched
401.bzip2 0.339081 100.00% 0.329657 102.86%
403.gcc 19.853966 100.00% 19.605466 101.27%
429.mcf 0.049823 100.00% 0.048451 102.83%
433.milc 0.514898 100.00% 0.510217 100.92%
444.namd 1.109328 100.00% 1.103481 100.53%
445.gobmk 4.988028 100.00% 4.929114 101.20%
456.hmmer 0.843871 100.00% 0.825865 102.18%
458.sjeng 0.754238 100.00% 0.714095 105.62%
464.h264ref 2.9668 100.00% 2.90612 102.09%
471.omnetpp 4.556533 100.00% 4.511886 100.99%
bitmnp01 0.038168 100.00% 0.0357 106.91%
idctrn01 0.037745 100.00% 0.037332 101.11%
libquake2 3.78689 100.00% 3.76209 100.66%
libquake_ 2.251525 100.00% 2.234104 100.78%
linpack 0.033159 100.00% 0.032788 101.13%
matrix01 0.045319 100.00% 0.043497 104.19%
nbench 0.333161 100.00% 0.329799 101.02%
tblook01 0.017863 100.00% 0.017666 101.12%
ttsprk01 0.054337 100.00% 0.053057 102.41%

Reviewer : Andrew Trick <atrick@apple.com>, Hal Finkel <hfinkel@anl.gov>
Approver : Andrew Trick <atrick@apple.com>
Test : Pass make check-all & llvm test-suite

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193460 91177308-0d34-0410-b5e6-96231b3b80d8
4d4bbaf997c16f9e79503bd640306d784efd090e 25-Oct-2013 Andrew Trick <atrick@apple.com> Fix SCEVExpander: don't try to expand quadratic recurrences outside a loop.

Partial fix for PR17459: wrong code at -O3 on x86_64-linux-gnu
(affecting trunk and 3.3)

When SCEV expands a recurrence outside of a loop it attempts to scale
by the stride of the recurrence. Chained recurrences don't work that
way. We could compute binomial coefficients, but would hve to
guarantee that the chained AddRec's are in a perfectly reduced form.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193438 91177308-0d34-0410-b5e6-96231b3b80d8
6e1c511aba87ab5f9962ae9328014897459f777a 25-Oct-2013 Rafael Espindola <rafael.espindola@gmail.com> Call destroy from ~BasicCallGraph.

This fix a memory leak found by valgrind.

Calling it from the base class destructor would not destroy the BasicCallGraph

FIXME: BasicCallGraph is the only thing that inherits from CallGraph. Can
we merge the two?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193412 91177308-0d34-0410-b5e6-96231b3b80d8
5e1d0d39db5fefe013f58c124a94694f96bce2f1 24-Oct-2013 Nuno Lopes <nunoplopes@sapo.pt> fix PR17635: false positive with packed structures
LLVM optimizers may widen accesses to packed structures that overflow the structure itself, but should be in bounds up to the alignment of the object

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193317 91177308-0d34-0410-b5e6-96231b3b80d8
135fe6ac5f5b80ef68c19b3ec7bb0063e28f2bab 22-Oct-2013 Benjamin Kramer <benny.kra@googlemail.com> Speling fixes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193165 91177308-0d34-0410-b5e6-96231b3b80d8
325ee6e115e97a2e0c2a37d69d25269dabbe77df 21-Oct-2013 Matt Arsenault <Matthew.Arsenault@amd.com> Remove unused SCEV functions

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193097 91177308-0d34-0410-b5e6-96231b3b80d8
cee51c48030f37133ad4004d3e5c14d8ebfc91c4 03-Oct-2013 Matt Arsenault <Matthew.Arsenault@amd.com> Rename DataLayout variables TD -> DL

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191927 91177308-0d34-0410-b5e6-96231b3b80d8
dd5d86d992eb129ecd0bb013d2db2d6a0e8d2605 02-Oct-2013 Chandler Carruth <chandlerc@gmail.com> Remove the very substantial, largely unmaintained legacy PGO

This was essentially work toward PGO based on a design that had several
flaws, partially dating from a time when LLVM had a different
architecture, and with an effort to modernize it abandoned without being
completed. Since then, it has bitrotted for several years further. The
result is nearly unusable, and isn't helping any of the modern PGO
efforts. Instead, it is getting in the way, adding confusion about PGO
in LLVM and distracting everyone with maintenance on essentially dead
code. Removing it paves the way for modern efforts around PGO.

Among other effects, this removes the last of the runtime libraries from
LLVM. Those are being developed in the separate 'compiler-rt' project
now, with somewhat different licensing specifically more approriate for

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191835 91177308-0d34-0410-b5e6-96231b3b80d8
d4278821665aa97f5fc0d19a32ff1fb39a22d395 30-Sep-2013 Benjamin Kramer <benny.kra@googlemail.com> Convert manual insert point restores to the new RAII object.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191675 91177308-0d34-0410-b5e6-96231b3b80d8
6629210aaf9d2e4fcbecc80b35f72108304da4b4 24-Sep-2013 Benjamin Kramer <benny.kra@googlemail.com> Teach MemoryBuiltins and InstructionSimplify that operator new never returns NULL.

This is safe per C++11 [operator new returns] a non-null pointer to
suitably aligned storage (3.7.4), or else throw a bad_alloc exception. This
requirement is binding on a replacement version of this function.

Brings us a tiny bit closer to eliminating more vector push_backs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191310 91177308-0d34-0410-b5e6-96231b3b80d8
4f77a21d6ca2d560a7508fd54581b12dfc01630b 19-Sep-2013 Shuxin Yang <shuxin.llvm@gmail.com> Add function DominatorTree::getDescendants().

As its name suggests, this function will return all basic blocks
dominated by a given block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191014 91177308-0d34-0410-b5e6-96231b3b80d8
65457b679ae240c1a37da82c5484dac478c47b6d 17-Sep-2013 Arnold Schwaighofer <aschwaighofer@apple.com> Costmodel: Add support for horizontal vector reductions

Upcoming SLP vectorization improvements will want to be able to estimate costs
of horizontal reductions. Add infrastructure to support this.

We model reductions as a series of (shufflevector,add) tuples ultimately
followed by an extractelement. For example, for an add-reduction of <4 x float>
we could generate the following sequence:

(v0, v1, v2, v3)
\ \ / /
\ \ /
+ +

(v0+v2, v1+v3, undef, undef)
\ /
((v0+v2) + (v1+v3), undef, undef)

%rdx.shuf = shufflevector <4 x float> %rdx, <4 x float> undef,
<4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
%bin.rdx = fadd <4 x float> %rdx, %rdx.shuf
%rdx.shuf7 = shufflevector <4 x float> %bin.rdx, <4 x float> undef,
<4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
%bin.rdx8 = fadd <4 x float> %bin.rdx, %rdx.shuf7
%r = extractelement <4 x float> %bin.rdx8, i32 0

This commit adds a cost model interface "getReductionCost(Opcode, Ty, Pairwise)"
that will allow clients to ask for the cost of such a reduction (as backends
might generate more efficient code than the cost of the individual instructions
summed up). This interface is excercised by the CostModel analysis pass which
looks for reduction patterns like the one above - starting at extractelements -
and if it sees a matching sequence will call the cost model interface.

We will also support a second form of pairwise reduction that is well supported
on common architectures (haddps, vpadd, faddp).

(v0, v1, v2, v3)
\ / \ /
(v0+v1, v2+v3, undef, undef)
\ /
((v0+v1)+(v2+v3), undef, undef, undef)

%rdx.shuf.0.0 = shufflevector <4 x float> %rdx, <4 x float> undef,
<4 x i32> <i32 0, i32 2 , i32 undef, i32 undef>
%rdx.shuf.0.1 = shufflevector <4 x float> %rdx, <4 x float> undef,
<4 x i32> <i32 1, i32 3, i32 undef, i32 undef>
%bin.rdx.0 = fadd <4 x float> %rdx.shuf.0.0, %rdx.shuf.0.1
%rdx.shuf.1.0 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef,
<4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>
%rdx.shuf.1.1 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef,
<4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
%bin.rdx.1 = fadd <4 x float> %rdx.shuf.1.0, %rdx.shuf.1.1
%r = extractelement <4 x float> %bin.rdx.1, i32 0

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190876 91177308-0d34-0410-b5e6-96231b3b80d8
4f7e2c38e864d7eaeb407ac501478e9579624d1b 11-Sep-2013 Hal Finkel <hfinkel@anl.gov> Add getUnrollingPreferences to TTI

Allow targets to customize the default behavior of the generic loop unrolling
transformation. This will be used by the PowerPC backend when targeting the A2
core (which is in-order with a deep pipeline), and using more aggressive
defaults is important.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190542 91177308-0d34-0410-b5e6-96231b3b80d8
14807bd8c801f976c999e5a6699f31ee9642021a 10-Sep-2013 Matt Arsenault <Matthew.Arsenault@amd.com> Teach ScalarEvolution about pointer address spaces

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190425 91177308-0d34-0410-b5e6-96231b3b80d8
f208398528efde82bc49f48d0fef0587c1f192bb 29-Aug-2013 Hal Finkel <hfinkel@anl.gov> Revert: r189565 - Add getUnrollingPreferences to TTI

Revert unintentional commit (of an unreviewed change).

Original commit message:

Add getUnrollingPreferences to TTI

Allow targets to customize the default behavior of the generic loop unrolling
transformation. This will be used by the PowerPC backend when targeting the A2
core (which is in-order with a deep pipeline), and using more aggressive
defaults is important.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189566 91177308-0d34-0410-b5e6-96231b3b80d8
32f258b96a723b771eb44a2c0689b8bf4dd871ee 29-Aug-2013 Hal Finkel <hfinkel@anl.gov> Add getUnrollingPreferences to TTI

Allow targets to customize the default behavior of the generic loop unrolling
transformation. This will be used by the PowerPC backend when targeting the A2
core (which is in-order with a deep pipeline), and using more aggressive
defaults is important.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189565 91177308-0d34-0410-b5e6-96231b3b80d8
a8a7099c1849fcbb4a68642a292fd0250aa46505 23-Aug-2013 Richard Sandiford <rsandifo@linux.vnet.ibm.com> Turn MipsOptimizeMathLibCalls into a target-independent scalar transform

...so that it can be used for z too. Most of the code is the same.
The only real change is to use TargetTransformInfo to test when a sqrt
instruction is available.

The pass is opt-in because at the moment it only handles sqrt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189097 91177308-0d34-0410-b5e6-96231b3b80d8
328a4fbfbb778de44d9a738c3efdfd42a58925d9 21-Aug-2013 Jakub Staszak <kubastaszak@gmail.com> Add some constantness.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188844 91177308-0d34-0410-b5e6-96231b3b80d8
72dba254ae65b06062106910a70d46f21e19d55a 13-Aug-2013 Nick Lewycky <nicholas@mxc.ca> Fix an oversight in isPotentiallyReachable where we wouldn't do any CFG-walking
to find loops if the From and To instructions were in the same block.

Refactor the code a little now that we need to fill to start the CFG-walking
algorithm with more than one starting basic block sometimes.

Special thanks to Andrew Trick for catching an error in my understanding of
natural loops in code review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188236 91177308-0d34-0410-b5e6-96231b3b80d8
00d7baad90040cd117d717ff93c41a22f767759b 06-Aug-2013 Matt Arsenault <Matthew.Arsenault@amd.com> Fix missing -*- C++ -*-s

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187758 91177308-0d34-0410-b5e6-96231b3b80d8
81e480463d8bb57776d03cebfd083762909023f1 27-Jul-2013 Nick Lewycky <nicholas@mxc.ca> Reimplement isPotentiallyReachable to make nocapture deduction much stronger.
Adds unit tests for it too.

Split BasicBlockUtils into an analysis-half and a transforms-half, and put the
analysis bits into a new Analysis/CFG.{h,cpp}. Promote isPotentiallyReachable
into llvm::isPotentiallyReachable and move it into Analysis/CFG.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187283 91177308-0d34-0410-b5e6-96231b3b80d8
57e6b2d1f3de0bf459e96f7038e692d624f7e580 27-Jul-2013 Tom Stellard <thomas.stellard@amd.com> SimplifyCFG: Use parallel-and and parallel-or mode to consolidate branch conditions

Merge consecutive if-regions if they contain identical statements.
Both transformations reduce number of branches. The transformation
is guarded by a target-hook, and is currently enabled only for +R600,
but the correctness has been tested on X86 target using a variety of
CPU benchmarks.

Patch by: Mei Ye

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187278 91177308-0d34-0410-b5e6-96231b3b80d8
a1ac7ede0c39fff1612311afab0039b74eed59e1 23-Jul-2013 Matt Arsenault <Matthew.Arsenault@amd.com> Fix typo (ponted -> pointed)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186896 91177308-0d34-0410-b5e6-96231b3b80d8
a0ec3f9b7b826b9b40b80199923b664bad808cce 14-Jul-2013 Craig Topper <craig.topper@gmail.com> Use SmallVectorImpl& instead of SmallVector to avoid repeating small vector size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186274 91177308-0d34-0410-b5e6-96231b3b80d8
bee07bddeaf30aba392c1abd2815cd07545ef2c0 13-Jul-2013 Michael Gottesman <mgottesman@apple.com> Fixed 80+ violation and added C++ to header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186225 91177308-0d34-0410-b5e6-96231b3b80d8
c0a11edba6ea46c782672ab3fb4e4ab3dc267a22 12-Jul-2013 Arnold Schwaighofer <aschwaighofer@apple.com> TargetTransformInfo: address calculation parameter for gather/scather

Address calculation for gather/scather in vectorized code can incur a
significant cost making vectorization unbeneficial. Add infrastructure to add
Tests and cost model for targets will be in follow-up commits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186187 91177308-0d34-0410-b5e6-96231b3b80d8
4ff87aaf84f0fbc9dffa2757fd7a33c7ee9044ea 12-Jul-2013 Michael Gottesman <mgottesman@apple.com> Fixed comment in header of Block Frequency Impl and added text for C++ mode.

This is a generic block implementation that works on more than machine blocks.
The C++ mode addition is a bonus due to the extra space provided.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186175 91177308-0d34-0410-b5e6-96231b3b80d8
a10369920fa86d8961495b71dbc00f5596d122d9 12-Jul-2013 Shuxin Yang <shuxin.llvm@gmail.com> Stylistic change.

Thank Nick for figuring out these problems.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186146 91177308-0d34-0410-b5e6-96231b3b80d8
5e915e6e364532ed00b4c5508e59b42f608b5244 08-Jul-2013 Shuxin Yang <shuxin.llvm@gmail.com> Fix a SCEV update problem.

The symptom is seg-fault, and the root cause is that a SCEV contains a SCEVUnknown
which has null-pointer to a llvm::Value.

This is how the problem take place:
1). In the pristine input IR, there are two relevant instrutions Op1 and Op2,
Op1's corresponding SCEV (denoted as SCEV(op1)) is a SCEVUnknown, and
SCEV(Op2) contains SCEV(Op1). None of these instructions are dead.

Op1 : V1 = ...
Op2 : V2 = ... // directly or indirectly (data-flow) depends on Op1

2) Optimizer (LSR in my case) generates an instruction holding the equivalent
value of Op1, making Op1 dead.
Op1': V1' = ...
Op1: V1 = ... ; now dead)
Op2 : V2 = ... //Now deps on Op1', but the SCEV(Op2) still contains SCEV(Op1)

3) Op1 is deleted, and call-back function is called to reset
SCEV(Op1) to indicate it is invalid. However, SCEV(Op2) is not
invalidated as well.

4) Following pass get the cached, invalid SCEV(Op2), and try to manipulate it,
and cause segfault.

The fix:
It seems there is no clean yet inexpensive fix. I write to dev-list
soliciting good solution, unforunately no ack. So, I decide to fix this
problem in a brute-force way:

When ScalarEvolution::getSCEV is called, check if the cached SCEV
contains a invalid SCEVUnknow, if yes, remove the cached SCEV, and
re-evaluate the SCEV from scratch.

I compile buch of big *.c and *.cpp, fortunately, I don't see any increase
in compile time.

The reduced test-case has 2357 lines of code+other-stuff, too big to commit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185843 91177308-0d34-0410-b5e6-96231b3b80d8
99666cb8f98ba9d84a7516a9f0bbfce5fb9a7df2 29-Jun-2013 Preston Briggs <preston.briggs@gmail.com> extending the interface of Dependence slightly to support future work

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185241 91177308-0d34-0410-b5e6-96231b3b80d8
37cb687fcb256cd891d1a69c8db77ae1c39f759f 29-Jun-2013 Jakob Stoklund Olesen <stoklund@2pi.dk> Try to unbreak Linux buildbots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185237 91177308-0d34-0410-b5e6-96231b3b80d8
97be1d608e0fd8f0578342932b3b8116e5028a02 29-Jun-2013 Jakob Stoklund Olesen <stoklund@2pi.dk> Minimize precision loss when computing cyclic probabilities.

Allow block frequencies to exceed 32 bits by using the new
BlockFrequency division function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185236 91177308-0d34-0410-b5e6-96231b3b80d8
b0f8341b3449623db80f1ac375e2dcfe4b1796e4 26-Jun-2013 Jakob Stoklund Olesen <stoklund@2pi.dk> Merge isReachable into isBackedge.

Prefer using RPO.lookup() instead of RPO[] which can mutate the map.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184891 91177308-0d34-0410-b5e6-96231b3b80d8
75b51621540c23ddfc1e9ef6b4dc803453d9d122 25-Jun-2013 Benjamin Kramer <benny.kra@googlemail.com> BlockFrequency: Bump up the entry frequency a bit.

This is a band-aid to fix the most severe regressions we're seeing from basing
spill decisions on block frequencies, until we have a better solution.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184835 91177308-0d34-0410-b5e6-96231b3b80d8
3ade978551927cfb0e6dd4e26f0768908b1898bb 09-Jun-2013 Benjamin Kramer <benny.kra@googlemail.com> Add a const version of findNearestCommonDominator to PostDom for convenience.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183629 91177308-0d34-0410-b5e6-96231b3b80d8
326ae27c4f744cc7fb43f5a413d042d54fc1ddc0 07-Jun-2013 Jakub Staszak <kubastaszak@gmail.com> Remove unneeded #include.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183460 91177308-0d34-0410-b5e6-96231b3b80d8
06f5ebc5a1604b01689cf2d482dd05f956538af6 31-May-2013 Quentin Colombet <qcolombet@apple.com> Loop Strength Reduce: Scaling factor cost.

Account for the cost of scaling factor in Loop Strength Reduce when rating the
formulae. This uses a target hook.

The default implementation of the hook is: if the addressing mode is legal, the
scaling factor is free.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183045 91177308-0d34-0410-b5e6-96231b3b80d8
616011418e7460f765469f6347417fa25b5b740b 31-May-2013 Andrew Trick <atrick@apple.com> Fix ScalarEvolution::ComputeExitLimitFromCond for 'or' conditions.

Fixes PR16130 - clang produces incorrect code with loop/expression at -O2.

This is a 2+ year old bug that's now holding up the release. It's a
case where we knowingly made aggressive assumptions about undefined
behavior. These assumptions are wrong when SCEV is computing a
subexpression that does not directly control the branch. With this
fix, we avoid making assumptions in those cases but still optimize the
common case. SCEV's trip count computation for exits controlled by
'or' expressions is now analagous to the trip count computation for
loops with multiple exits. I had already fixed the multiple exit case
to be conservative.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182989 91177308-0d34-0410-b5e6-96231b3b80d8
ee21b6f7b41e3fc19031f6d410b2ebe6a1a2f361 28-May-2013 Paul Redmond <paul.redmond@intel.com> Add support for llvm.vectorizer metadata

- llvm.loop.parallel metadata has been renamed to llvm.loop to be more generic
by making the root of additional loop metadata.
- Loop::isAnnotatedParallel now looks for llvm.loop and associated
- document llvm.loop and update llvm.mem.parallel_loop_access
- add support for llvm.vectorizer.width and llvm.vectorizer.unroll
- document llvm.vectorizer.* metadata
- add utility class LoopVectorizerHints for getting/setting loop metadata
- use llvm.vectorizer.width=1 to indicate already vectorized instead of
- update existing tests that used llvm.loop.parallel and

Reviewed by: Nadav Rotem

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182802 91177308-0d34-0410-b5e6-96231b3b80d8
9f5de6dadcdb9922ad8c8135a29e4abccec11671 28-May-2013 Michael Kuperstein <michael.m.kuperstein@intel.com> Make BasicAliasAnalysis recognize the fact a noalias argument cannot alias another argument, even if the other argument is not itself marked noalias.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182755 91177308-0d34-0410-b5e6-96231b3b80d8
77226a03dca98e6237c1068f2652fe41bea7b687 24-May-2013 Diego Novillo <dnovillo@google.com> Add a new function attribute 'cold' to functions.

Other than recognizing the attribute, the patch does little else.
It changes the branch probability analyzer so that edges into
blocks postdominated by a cold function are given low weight.

Added analysis and code generation tests. Added documentation for the
new attribute.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182638 91177308-0d34-0410-b5e6-96231b3b80d8
63f3ca5da75a614c603c04757edeaac123879d39 17-May-2013 Matt Arsenault <Matthew.Arsenault@amd.com> Add missing -*- C++ -*- to headers

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182164 91177308-0d34-0410-b5e6-96231b3b80d8
d14743ed791f49cb9b5e3b018c3fa3391ab2193d 17-May-2013 Sylvestre Ledru <sylvestre@debian.org> Fix a typo (ouput => output)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182090 91177308-0d34-0410-b5e6-96231b3b80d8
453f4f01302f00651aae2fc7658f6e23a2beadb0 15-May-2013 David Blaikie <dblaikie@gmail.com> Use only explicit bool conversion operators

BitVector/SmallBitVector::reference::operator bool remain implicit since
they model more exactly a bool, rather than something else that can be
boolean tested.

The most common (non-buggy) case are where such objects are used as
return expressions in bool-returning functions or as boolean function
arguments. In those cases I've used (& added if necessary) a named
function to provide the equivalent (or sometimes negative, depending on
convenient wording) test.

One behavior change (YAMLParser) was made, though no test case is
included as I'm not sure how to reach that code path. Essentially any
comparison of llvm::yaml::document_iterators would be invalid if neither
iterator was at the end.

This helped uncover a couple of bugs in Clang - test cases provided for
those in a separate commit along with similar changes to `operator bool`
instances in Clang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181868 91177308-0d34-0410-b5e6-96231b3b80d8
d03fdfb97c1a693101bfef5800c262237f5d382f 10-Apr-2013 Tobias Grosser <grosser@fim.uni-passau.de> RegionInfo: Add helpers to replace entry/exit recursively

Contributed by: Star Tan <tanmx_star@yeah.net>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179157 91177308-0d34-0410-b5e6-96231b3b80d8
8e4df489d0e02e0fbdd00ed829e70e5f21998162 09-Apr-2013 Nadav Rotem <nrotem@apple.com> Revert r176408 and r176407 to address PR15540.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179111 91177308-0d34-0410-b5e6-96231b3b80d8
6bf4f676413b8f7d97aaff289997aab344180957 05-Apr-2013 Arnold Schwaighofer <aschwaighofer@apple.com> CostModel: Add parameter to instruction cost to further classify operand values

On certain architectures we can support efficient vectorized version of
instructions if the operand value is uniform (splat) or a constant scalar.
An example of this is a vector shift on x86.

We can efficiently support

for (i = 0 ; i < ; i += 4)
w[0:3] = v[0:3] << <2, 2, 2, 2>

but not

for (i = 0; i < ; i += 4)
w[0:3] = v[0:3] << x[0:3]

This patch adds a parameter to getArithmeticInstrCost to further qualify operand
values as uniform or uniform constant.

Targets can then choose to return a different cost for instructions with such
operand values.

A follow-up commit will test this feature on x86.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178807 91177308-0d34-0410-b5e6-96231b3b80d8
e74c2e86cb405963ba9c4043a1d0ca00b8f85fbe 26-Mar-2013 Andrew Trick <atrick@apple.com> Fix SCEV forgetMemoizedResults should search and destroy backedge exprs.

Fixes PR15570: SEGV: SCEV back-edge info invalid after dead code removal.

Indvars creates a SCEV expression for the loop's back edge taken
count, then determines that the comparison is always true and
removes it.

When loop-unroll asks for the expression, it contains a NULL
SCEVUnknkown (as a CallbackVH).

forgetMemoizedResults should invalidate the loop back edges expression.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177986 91177308-0d34-0410-b5e6-96231b3b80d8
80c6a66bbfb748c230d52345ededd3fd35ebddd7 20-Mar-2013 Rafael Espindola <rafael.espindola@gmail.com> Add std prefixes to fix the build with xlc.
Patch by Kai <kai@redstar.de>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177574 91177308-0d34-0410-b5e6-96231b3b80d8
02a2d4fb9e29f7a2b270bb23596dba02a1f79a03 19-Mar-2013 Jakub Staszak <kubastaszak@gmail.com> Remove unneeded #includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177351 91177308-0d34-0410-b5e6-96231b3b80d8
ec3bb4b660fc2f8353c510ebfc15277bcf28df8b 10-Mar-2013 Jakub Staszak <kubastaszak@gmail.com> Remove unneeded #includes. Use forward declarations instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176783 91177308-0d34-0410-b5e6-96231b3b80d8
e939a066c85a21e86d32e0a57fd16f4188576633 10-Mar-2013 Jakub Staszak <kubastaszak@gmail.com> Remove unneeded #includes. Use forward declarations instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176782 91177308-0d34-0410-b5e6-96231b3b80d8
64bf55af6f3cc6c6db985d3840547b5869e57222 09-Mar-2013 Jakub Staszak <kubastaszak@gmail.com> Remove unneeded const_cast.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176771 91177308-0d34-0410-b5e6-96231b3b80d8
209cb5b56bb90f1ceee570efabe9c04121cb0beb 09-Mar-2013 Jakub Staszak <kubastaszak@gmail.com> Use forward declaration instead of #include.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176770 91177308-0d34-0410-b5e6-96231b3b80d8
423de3f0478fd8e4f8aa650d8cf9f64d08963118 08-Mar-2013 David Blaikie <dblaikie@gmail.com> Remove -print-dbginfo as it is unused & bitrotten.

This pass hasn't been touched in two years & would fail with assertions against
the current debug info metadata format (the only test case for it still uses a
many-versions old debug info metadata format)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176707 91177308-0d34-0410-b5e6-96231b3b80d8
985dac65791b9f6f631bdd51c18fe66592a67469 06-Mar-2013 Shuxin Yang <shuxin.llvm@gmail.com> Memory Dependence Analysis (not mem-dep test) take advantage of "invariant.load" metadata.

The "invariant.load" metadata indicates the memory unit being accessed is immutable.
A load annotated with this metadata can be moved across any store.

As I am not sure if it is legal to move such loads across barrier/fence, this
change dose not allow such transformation.


Thank Arnold for code review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176562 91177308-0d34-0410-b5e6-96231b3b80d8
62c102360ad39e005c3c8c42fe85bfc9f2f23474 06-Mar-2013 Jakub Staszak <kubastaszak@gmail.com> Remove duplicated forward declaration.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176536 91177308-0d34-0410-b5e6-96231b3b80d8
f84606732c76899af54c295ec987c96c88452747 05-Mar-2013 Jakub Staszak <kubastaszak@gmail.com> Fix a few typos in comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176519 91177308-0d34-0410-b5e6-96231b3b80d8
fe0c244633aff93111063224317ec9c20d3dbcf4 05-Mar-2013 Jakub Staszak <kubastaszak@gmail.com> Add some constantness.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176518 91177308-0d34-0410-b5e6-96231b3b80d8
aa4e2aea9e8ce01f31a917639bcc7d810b9fe6d1 05-Mar-2013 Jakub Staszak <kubastaszak@gmail.com> std::distance() == 0 means that iterators are equal. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176516 91177308-0d34-0410-b5e6-96231b3b80d8
6936ebd700d8195cfed39baa21230ee736fe1316 05-Mar-2013 Arnold Schwaighofer <aschwaighofer@apple.com> Use the right number of slashes in comment string

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176504 91177308-0d34-0410-b5e6-96231b3b80d8
1c9bdf1e5e4b128206e1699c1bb82457118601e4 05-Mar-2013 Arnold Schwaighofer <aschwaighofer@apple.com> Clarify comment for function getObjectSize

Clarify that we mean the object starting at the pointer to the end of the
underlying object and not the size of the whole allocated object.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176491 91177308-0d34-0410-b5e6-96231b3b80d8
b443a0aeac38e6fdce063224dfc746c269b0779d 02-Mar-2013 Nuno Lopes <nunoplopes@sapo.pt> recommit r172363 & r171325 (reverted in r172756)
This adds minimalistic support for PHI nodes to llvm.objectsize() evaluation

fingers crossed so that it does break clang boostrap again..

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176408 91177308-0d34-0410-b5e6-96231b3b80d8
2bc689c8461dfbaa4ca9a9cc4ae5bc59cb007329 02-Mar-2013 Nuno Lopes <nunoplopes@sapo.pt> add getUnderlyingObjectSize()
this is similar to getObjectSize(), but doesnt subtract the offset
tweak the BasicAA code accordingly (per PR14988)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176407 91177308-0d34-0410-b5e6-96231b3b80d8
a39058aaed4540fc37681cad728b99546595b2e8 19-Feb-2013 David Blaikie <dblaikie@gmail.com> Use LLVM_DELETED_FUNCTION rather than '// do not implement' comments.

Also removes some redundant DNI comments on function declarations already
using the macro.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175466 91177308-0d34-0410-b5e6-96231b3b80d8
b075ed3b90fa2a520aeb15802fddf3460d865f91 16-Feb-2013 Matt Beaumont-Gay <matthewbg@google.com> Pacify -Wnon-virtual-dtor

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175324 91177308-0d34-0410-b5e6-96231b3b80d8
0deff9fbeb3a6a68f224282f8c6bd277d4c0c78c 15-Feb-2013 Sebastian Pop <spop@codeaurora.org> capitalize SCEV to match the current naming convention

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175302 91177308-0d34-0410-b5e6-96231b3b80d8
5661fcdde295645e5c6f982a25225e682727b5b1 15-Feb-2013 Sebastian Pop <spop@codeaurora.org> add ScevApplyRewriter

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175294 91177308-0d34-0410-b5e6-96231b3b80d8
a9e4d3f37590bb326e6c5a3ea02ee1aa3db681ea 15-Feb-2013 Sebastian Pop <spop@codeaurora.org> add SCEVParameterRewriter

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175293 91177308-0d34-0410-b5e6-96231b3b80d8
5d0ce79e26f40141f35cc0002dc5cc6060382359 13-Feb-2013 Pekka Jaaskelainen <pekka.jaaskelainen@tut.fi> Metadata for annotating loops as parallel. The first consumer for this
metadata is the loop vectorizer.

See the documentation update for more info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175060 91177308-0d34-0410-b5e6-96231b3b80d8
96a82d186e123dbcc414b513007675c6af7fff84 09-Feb-2013 Jakub Staszak <kubastaszak@gmail.com> Remove unneeded #includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174806 91177308-0d34-0410-b5e6-96231b3b80d8
882b9276cb3a19ecc4fd307d8c0acd17574570a0 09-Feb-2013 Jakub Staszak <kubastaszak@gmail.com> Remove trailing spaces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174791 91177308-0d34-0410-b5e6-96231b3b80d8
29521a0fb9ba7ed6a2fc50d2c958151f86963ead 09-Feb-2013 Jakub Staszak <kubastaszak@gmail.com> Remove unneeded #includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174790 91177308-0d34-0410-b5e6-96231b3b80d8
4fa57932c7b13ec42c563e33a2e40fd04194b64e 09-Feb-2013 Jakub Staszak <kubastaszak@gmail.com> Remove #includes from the commonly used LoopInfo.h.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174786 91177308-0d34-0410-b5e6-96231b3b80d8
fb55a8fd7c38aa09d9c243d48a8a72d890f36a3d 08-Feb-2013 Arnold Schwaighofer <aschwaighofer@apple.com> ARM cost model: Address computation in vector mem ops not free

Adds a function to target transform info to query for the cost of address
computation. The cost model analysis pass now also queries this interface.
The code in LoopVectorize adds the cost of address computation as part of the
memory instruction cost calculation. Only there, we know whether the instruction
will be scalarized or not.
Increase the penality for inserting in to D registers on swift. This becomes
necessary because we now always assume that address computation has a cost and
three is a closer value to the architecture.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174713 91177308-0d34-0410-b5e6-96231b3b80d8
43d836343e56b78d9a660272c84a8feb1683d861 31-Jan-2013 Dan Gohman <dan433584@gmail.com> Document another instsimplify assumption.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174100 91177308-0d34-0410-b5e6-96231b3b80d8
de0eb19248f3053c07a5b1dad9c47b8435458337 31-Jan-2013 Dan Gohman <dan433584@gmail.com> Move isKnownNonNull out of AliasAnalysis.h and into ValueTracking.cpp since
it isn't really an AliasAnalysis concept, and ValueTracking has similar things
that it could plausibly share code with some day.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174027 91177308-0d34-0410-b5e6-96231b3b80d8
a070d2a0355c4993240b5206ebc1d517c151331d 31-Jan-2013 Dan Gohman <dan433584@gmail.com> Change GetPointerBaseWithConstantOffset's DataLayout argument from a
reference to a pointer, so that it can handle the case where DataLayout
is not available and behave conservatively.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174024 91177308-0d34-0410-b5e6-96231b3b80d8
c4e441804ebe5a2d0eadbd9b0840d4f1b12d5a6f 28-Jan-2013 Dan Gohman <dan433584@gmail.com> Add a comment mentioning that InstructionSimplify routines do,
in fact, resolve undef uses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173721 91177308-0d34-0410-b5e6-96231b3b80d8
13086a658ae06046ded902229f9918b8bad505bd 22-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Begin fleshing out an interface in TTI for modelling the costs of
generic function calls and intrinsics. This is somewhat overlapping with
an existing intrinsic cost method, but that one seems targetted at
vector intrinsics. I'll merge them or separate their names and use cases
in a separate commit.

This sinks the test of 'callIsSmall' down into TTI where targets can
control it. The whole thing feels very hack-ish to me though. I've left
a FIXME comment about the fundamental design problem this presents. It
isn't yet clear to me what the users of this function *really* care
about. I'll have to do more analysis to figure that out. Putting this
here at least provides it access to proper analysis pass tools and other
such. It also allows us to more cleanly implement the baseline cost
interfaces in TTI.

With this commit, it is now theoretically possible to simplify much of
the inline cost analysis's handling of calls by calling through to this
interface. That conversion will have to happen in subsequent commits as
it requires more extensive restructuring of the inline cost analysis.

The CodeMetrics class is now really only in the business of running over
a block of code and aggregating the metrics on that block of code, with
the actual cost evaluation done entirely in terms of TTI.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173148 91177308-0d34-0410-b5e6-96231b3b80d8
a5157e68d183e1bdf010e94a15dc0c44b65f889b 21-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Switch CodeMetrics itself over to use TTI to determine if an instruction
is free. The whole CodeMetrics API should probably be reworked more, but
this is enough to allow deleting the duplicate code there for computing
whether an instruction is free.

All of the passes using this have been updated to pull in TTI and hand
it to the CodeMetrics stuff. Further, a dead CodeMetrics API
(analyzeFunction) is nuked for lack of users.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173036 91177308-0d34-0410-b5e6-96231b3b80d8
6097e774fc9896583ae916daabedbd87b26b4466 21-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Fix indentation and formatting.

This change brought to by clang-format. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173034 91177308-0d34-0410-b5e6-96231b3b80d8
8d6c0f4deeb0f2ff671df7ae92b75ee1e39acd37 21-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Now that the inline cost analysis is a pass, we can easily have it
depend on and use other analyses (as long as they're either immutable
passes or CGSCC passes of course -- nothing in the pass manager has been
fixed here). Leverage this to thread TargetTransformInfo down through
the inline cost analysis.

No functionality changed here, this just threads things through.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173031 91177308-0d34-0410-b5e6-96231b3b80d8
86953b5795007eaa98838297360a6987e33e92e7 21-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Make the inline cost a proper analysis pass. This remains essentially
a dynamic analysis done on each call to the routine. However, now it can
use the standard pass infrastructure to reference other analyses,
instead of a silly setter method. This will become more interesting as
I teach it about more analysis passes.

This updates the two inliner passes to use the inline cost analysis.
Doing so highlights how utterly redundant these two passes are. Either
we should find a cheaper way to do always inlining, or we should merge
the two and just fiddle with the thresholds to get the desired behavior.
I'm leaning increasingly toward the latter as it would also remove the
Inliner sub-class split.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173030 91177308-0d34-0410-b5e6-96231b3b80d8
78e1cdaba3cad6e85ff631542052bbb718c7e588 21-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Fix an old-style doxygen comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173027 91177308-0d34-0410-b5e6-96231b3b80d8
4ef13242ab7473de62c2c4d77de3c69d362bd9ef 21-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Cleanup the formatting of this header. This removes the namespace indent
and reformats a few constructors using clang-format. Only whitespace
changes here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173018 91177308-0d34-0410-b5e6-96231b3b80d8
c61aa59bcc62019b8e31fcbb3582255be3a63052 21-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Remove the comma from the last enumerator to fix -pedantic warnings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172999 91177308-0d34-0410-b5e6-96231b3b80d8
1e05bd9e714934a71ff933ad15f0b884808b405f 21-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Introduce a generic interface for querying an operation's expected
lowered cost.

Currently, this is a direct port of the logic implementing
isInstructionFree in CodeMetrics. The hope is that the interface can be
improved (f.ex. supporting un-formed instruction queries) and the
implementation abstracted so that as we have test cases and target
knowledge we can expose increasingly accurate heuristics to clients.

I'll start switching existing consumers over and kill off the routine in
CodeMetrics in subsequent commits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172998 91177308-0d34-0410-b5e6-96231b3b80d8
053a2119835ac6ca3484f1b496cabd43c37e4279 20-Jan-2013 Renato Golin <renato.golin@linaro.org> Revert CostTable algorithm, will re-write

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172992 91177308-0d34-0410-b5e6-96231b3b80d8
90230c84668269fbd53d163e398cd16486d5d414 19-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Sort all of the includes. Several files got checked in with mis-sorted

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172891 91177308-0d34-0410-b5e6-96231b3b80d8
167ede898a6105e05fcd9d2ae5679fbf1744018f 17-Jan-2013 Bill Wendling <isanbard@gmail.com> Reverting r171325 & r172363. This was causing a mis-compile on the self-hosted LTO build bots.

Okay, here's how to reproduce the problem:

1) Build a Release (or Release+Asserts) version of clang in the normal way.

2) Using the clang & clang++ binaries from (1), build a Release (or
Release+Asserts) version of the same sources, but this time enable LTO ---
specify the `-flto' flag on the command line.

3) Run the ARC migrator tests:

$ arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ ./src/tools/clang/test/ARCMT/cxx-rewrite.mm

You'll see that the output isn't correct (the whitespace is off).

The mis-compile is in the function `RewriteBuffer::RemoveText' in the
clang/lib/Rewrite/Core/Rewriter.cpp file. When that function and RewriteRope.cpp
are compiled with LTO and the `arcmt-test' executable is regenerated, you'll see
the error. When those files are not LTO'ed, then the output of the `arcmt-test'
is fine.

It is *really* hard to get a testcase out of this. I'll file a PR with what I
have currently.

--- Reverse-merging r172363 into '.':
U include/llvm/Analysis/MemoryBuiltins.h
U lib/Analysis/MemoryBuiltins.cpp

--- Reverse-merging r171325 into '.':
U test/Transforms/InstCombine/objsize.ll
G include/llvm/Analysis/MemoryBuiltins.h
G lib/Analysis/MemoryBuiltins.cpp

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172756 91177308-0d34-0410-b5e6-96231b3b80d8
d3c965d6251e6d939f7797f8704d4e3a82f7e274 16-Jan-2013 Renato Golin <renato.golin@linaro.org> Change CostTable model to be global to all targets

Moving the X86CostTable to a common place, so that other back-ends
can share the code. Also simplifying it a bit and commoning up
tables with one and two types on operations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172658 91177308-0d34-0410-b5e6-96231b3b80d8
1ba5769676bb14078ddbdb9760523619726800c0 14-Jan-2013 Andrew Trick <atrick@apple.com> SCEVExpander fix. RAUW needs to update the InsertedExpressions cache.

Note that this bug is only exposed because LTO fails to use TTI.

Fixes self-LTO of clang. rdar://13007381.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172462 91177308-0d34-0410-b5e6-96231b3b80d8
29eb2cc00ca0bc4d218c6d034f90becfed999bcb 13-Jan-2013 Nuno Lopes <nunoplopes@sapo.pt> fix compile-time regression report by Joerg Sonnenberger:
cache result of Size/OffsetVisitor to speedup analysis of PHI nodes

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172363 91177308-0d34-0410-b5e6-96231b3b80d8
96f498bd9f140a98321c478f517877c4767b94fa 13-Jan-2013 Dmitri Gribenko <gribozavr@gmail.com> Remove redundant 'llvm::' qualifications

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172358 91177308-0d34-0410-b5e6-96231b3b80d8
a125cacf7d154d0e5cad47f011e619e45517c839 11-Jan-2013 Andrew Trick <atrick@apple.com> Added -view-callgraph module pass.

-dot-callgraph similarly follows a standard module pass pattern.

Patch by Speziale Ettore!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172220 91177308-0d34-0410-b5e6-96231b3b80d8
cbdb7e4b560f77f49f042ea47eac6d4980d8bece 11-Jan-2013 Jakub Staszak <kubastaszak@gmail.com> LoopPass.h doesn't require Function.h. Remove unneeded #include.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172155 91177308-0d34-0410-b5e6-96231b3b80d8
48fdf9b37926a9c3debd3f0b5814a2a4b6bb5097 10-Jan-2013 Jakub Staszak <kubastaszak@gmail.com> Remove unneeded #includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172118 91177308-0d34-0410-b5e6-96231b3b80d8
674be02d525d4e24bc6943ed9274958c580bcfbc 10-Jan-2013 Jakub Staszak <kubastaszak@gmail.com> Fix include guards so they exactly match file names.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172025 91177308-0d34-0410-b5e6-96231b3b80d8
14925e6b885f8bd8cf448627386d412831f4bf1b 09-Jan-2013 Nadav Rotem <nrotem@apple.com> ARM Cost model: Use the size of vector registers and widest vectorizable instruction to determine the max vectorization factor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172010 91177308-0d34-0410-b5e6-96231b3b80d8
83be7b0dd3ae9a3cb22d36ae4c1775972553b94b 09-Jan-2013 Nadav Rotem <nrotem@apple.com> Cost Model: Move the 'max unroll factor' variable to the TTI and add initial Cost Model support on ARM.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171928 91177308-0d34-0410-b5e6-96231b3b80d8
3251e81d793a293b78f4914be6093b405c24fc2a 07-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Move CallGraphSCCPass.h into the Analysis tree; that's where the
implementation lives already.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171746 91177308-0d34-0410-b5e6-96231b3b80d8
e4ba75f43e2ab1480d119d2d4eb878256274e0fb 07-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Switch the SCEV expander and LoopStrengthReduce to use
TargetTransformInfo rather than TargetLowering, removing one of the
primary instances of the layering violation of Transforms depending
directly on Target.

This is a really big deal because LSR used to be a "special" pass that
could only be tested fully using llc and by looking at the full output
of it. It also couldn't run with any other loop passes because it had to
be created by the backend. No longer is this true. LSR is now just
a normal pass and we should probably lift the creation of LSR out of
lib/CodeGen/Passes.cpp and into the PassManagerBuilder. =] I've not done
this, or updated all of the tests to use opt and a triple, because
I suspect someone more familiar with LSR would do a better job. This
change should be essentially without functional impact for normal
compilations, and only change behvaior of targetless compilations.

The conversion required changing all of the LSR code to refer to the TTI
interfaces, which fortunately are very similar to TargetLowering's
interfaces. However, it also allowed us to *always* expect to have some
implementation around. I've pushed that simplification through the pass,
and leveraged it to simplify code somewhat. It required some test
updates for one of two things: either we used to skip some checks
altogether but now we get the default "no" answer for them, or we used
to have no information about the target and now we do have some.

I've also started the process of removing AddrMode, as the TTI interface
doesn't use it any longer. In some cases this simplifies code, and in
others it adds some complexity, but I think it's not a bad tradeoff even
there. Subsequent patches will try to clean this up even further and use
other (more appropriate) abstractions.

Yet again, almost all of the formatting changes brought to you by
clang-format. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171735 91177308-0d34-0410-b5e6-96231b3b80d8
bb00800ff46e7a2a628d0a6741a7f0422c74c198 07-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Fix the enumerator names for ShuffleKind to match tho coding standards,
and make its comments doxygen comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171688 91177308-0d34-0410-b5e6-96231b3b80d8
d1b8ef97c47d347f2a2261a0d6de4872f248321f 07-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Make the popcnt support enums and methods have more clear names and
follow the conding conventions regarding enumerating a set of "kinds" of

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171687 91177308-0d34-0410-b5e6-96231b3b80d8
be04929f7fd76a921540e9901f24563e51dc1219 07-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Move TargetTransformInfo to live under the Analysis library. This no
longer would violate any dependency layering and it is in fact an
analysis. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171686 91177308-0d34-0410-b5e6-96231b3b80d8
0b8c9a80f20772c3793201ab5b251d3520b9cea3 02-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Move all of the header files which are involved in modelling the LLVM IR
into their new header subdirectory: include/llvm/IR. This matches the
directory structure of lib, and begins to correct a long standing point
of file layout clutter in LLVM.

There are still more header files to move here, but I wanted to handle
them in separate commits to make tracking what files make sense at each
layer easier.

The only really questionable files here are the target intrinsic
tablegen files. But that's a battle I'd rather not fight today.

I've updated both CMake and Makefile build systems (I think, and my
tests think, but I may have missed something).

I've also re-sorted the includes throughout the project. I'll be
committing updates to Clang, DragonEgg, and Polly momentarily.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171366 91177308-0d34-0410-b5e6-96231b3b80d8
0a9ff4cab3a3fc1179c37855717a54ae44a5312e 31-Dec-2012 Nuno Lopes <nunoplopes@sapo.pt> recommit r171298 (add support for PHI nodes to ObjectSizeOffsetVisitor). Hopefully with bugs corrected now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171325 91177308-0d34-0410-b5e6-96231b3b80d8
41be2fb1f9e9b8f796effb81c2bee6cf397136cf 31-Dec-2012 Nuno Lopes <nunoplopes@sapo.pt> add support for GlobalAlias to ObjectSizeOffsetVisitor

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171303 91177308-0d34-0410-b5e6-96231b3b80d8
e949aa1c91132094a9073c82a8aef729fa8c9eca 28-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Teach instsimplify to use the constant folder where appropriate for
constant folding calls. Add the initial tests for this which show that
now instsimplify can simplify blindingly obvious code patterns expressed
with both intrinsics and library calls.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171194 91177308-0d34-0410-b5e6-96231b3b80d8
c98bd9f1a79adffe73acd337b6f7f9afa6bae078 28-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Add entry points to instsimplify for simplifying calls. The entry points
are nice and decomposed so that we can simplify synthesized calls as
easily as actually call instructions. The internal utility still has the
same behavior, it just now operates on a more generic interface so that
I can extend the set of call simplifications that instsimplify knows

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171189 91177308-0d34-0410-b5e6-96231b3b80d8
44185d49084f76427be15b1d4db18fc3027681c9 27-Dec-2012 Alexey Samsonov <samsonov@google.com> Fix new[]/delete mismatch in FullDependence spotted by AddressSanitizer

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171150 91177308-0d34-0410-b5e6-96231b3b80d8
67ae13575900e8efd056672987249fd0adbf5e73 20-Dec-2012 James Molloy <james.molloy@arm.com> Add a new attribute, 'noduplicate'. If a function contains a noduplicate call, the call cannot be duplicated - Jump threading, loop unrolling, loop unswitching, and loop rotation are inhibited if they would duplicate the call.

Similarly inlining of the function is inhibited, if that would duplicate the call (in particular inlining is still allowed when there is only one callsite and the function has internal linkage).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170704 91177308-0d34-0410-b5e6-96231b3b80d8
dbaa2376f7b3c027e895ff4bee3ae08351f3ea88 13-Dec-2012 Rafael Espindola <rafael.espindola@gmail.com> Rename isPowerOfTwo to isKnownToBeAPowerOfTwo.

In a previous thread it was pointed out that isPowerOfTwo is not a very precise
name since it can return false for powers of two if it is unable to show that
they are powers of two.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170093 91177308-0d34-0410-b5e6-96231b3b80d8
b09c146b116359616f6cbd4c8b3328607e00ff42 12-Dec-2012 Rafael Espindola <rafael.espindola@gmail.com> The TargetData is not used for the isPowerOfTwo determination. It has never
been used in the first place. It simply was passed to the function and to the
recursive invocations. Simply drop the parameter and update the callers for the
new signature.

Patch by Saleem Abdulrasool!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169988 91177308-0d34-0410-b5e6-96231b3b80d8
09ee250e728ccdb7afc6354d777f8319c5a0465c 12-Dec-2012 Michael Ilseman <milseman@apple.com> Added a slew of SimplifyInstruction floating-point optimizations, many of which take advantage of fast-math flags. Test cases included.

fsub X, +0 ==> X
fsub X, -0 ==> X, when we know X is not -0
fsub +/-0.0, (fsub -0.0, X) ==> X
fsub nsz +/-0.0, (fsub +/-0.0, X) ==> X
fsub nnan ninf X, X ==> 0.0
fadd nsz X, 0 ==> X
fadd [nnan ninf] X, (fsub [nnan ninf] 0, X) ==> 0
where nnan and ninf have to occur at least once somewhere in this expression
fmul X, 1.0 ==> X

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169940 91177308-0d34-0410-b5e6-96231b3b80d8
4ced4ee94b59a2b239a59a2ae5fd373579868f20 11-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Hoist the GEP constant address offset computation to a common home on
the GEP instruction class.

This is part of the continued refactoring and cleaning of the
infrastructure used by SROA. This particular operation is also done in
a few other places which I'll try to refactor to share this

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169852 91177308-0d34-0410-b5e6-96231b3b80d8
2bf786af90b8c3826974b2a9deea5e8081ebf113 10-Dec-2012 Sean Silva <silvas@purdue.edu> Fix funky copy-pasted grammatical error.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169742 91177308-0d34-0410-b5e6-96231b3b80d8
ed90ed077a58d6eff6aede206273ae0aeefa3a94 10-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Add a new visitor for walking the uses of a pointer value.

This visitor provides infrastructure for recursively traversing the
use-graph of a pointer-producing instruction like an alloca or a malloc.
It maintains a worklist of uses to visit, so it can handle very deep
recursions. It automatically looks through instructions which simply
translate one pointer to another (bitcasts and GEPs). It tracks the
offset relative to the original pointer as long as that offset remains
constant and exposes it during the visit as an APInt offset. Finally, it
performs conservative escape analysis.

However, currently it has some limitations that should be addressed
going forward:
1) It doesn't handle vectors of pointers.
2) It doesn't provide a cheaper visitor when the constant offset
tracking isn't needed.
3) It doesn't support non-instruction pointer values.

The current functionality is exactly what is required to implement the
SROA pointer-use visitors in terms of this one, rather than in terms of
their own ad-hoc base visitor, which was always very poorly specified.
SROA has been converted to use this, and the code there deleted which
this utility now provides.

Technically speaking, using this new visitor allows SROA to handle a few
more cases than it previously did. It is now more aggressive in ignoring
chains of instructions which look like they would defeat SROA, but in
fact do not because they never result in a read or write of memory.
While this is "neat", it shouldn't be interesting for real programs as
any such chains should have been removed by others passes long before we
get to SROA. As a consequence, I've not added any tests for these
features -- it shouldn't be part of SROA's contract to perform such

The goal is to extend the functionality of this visitor going forward,
and re-use it from passes like ASan that can benefit from doing
a detailed walk of the uses of a pointer.

Thanks to Ben Kramer for the code review rounds and lots of help
reviewing and debugging this patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169728 91177308-0d34-0410-b5e6-96231b3b80d8
1638b839090a35adcd5a4b4cc0a649352276e703 09-Dec-2012 Michael Ilseman <milseman@apple.com> Reorganize FastMathFlags to be a wrapper around unsigned, and streamline some interfaces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169712 91177308-0d34-0410-b5e6-96231b3b80d8
49eb628c21b358380b76df82aa3dfe0baab4c6ec 03-Dec-2012 Pedro Artigas <partigas@apple.com> moves doInitialization and doFinalization to the Pass class and removes some unreachable code in MachineModuleInfo

reviewed by Evan Cheng <evan.cheng@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169164 91177308-0d34-0410-b5e6-96231b3b80d8
255f89faee13dc491cb64fbeae3c763e7e2ea4e6 03-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Sort the #include lines for the include/... tree with the script.

AKA: Recompile *ALL* the source code!

This one went much better. No manual edits here. I spot-checked for
silliness and grep-checked for really broken edits and everything seemed
good. It all still compiles. Yell if you see something that looks goofy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169133 91177308-0d34-0410-b5e6-96231b3b80d8
d04a8d4b33ff316ca4cf961e06c9e312eff8e64f 03-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Use the new script to sort the includes of every file under lib.

Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.

Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
84bcf93e0fd225de2217d1b712c01586a633a6d8 30-Nov-2012 Chandler Carruth <chandlerc@gmail.com> Move the InstVisitor utility into VMCore where it belongs. It heavily
depends on the IR infrastructure, there is no sense in it being off in
Support land.

This is in preparation to start working to expand InstVisitor into more
special-purpose visitors that are still generic and can be re-used
across different passes. The expansion will go into the Analylis tree
though as nothing in VMCore needs it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168972 91177308-0d34-0410-b5e6-96231b3b80d8
c63ee60ef030177fed0fea9212bc2f516fdf0796 29-Nov-2012 Dan Gohman <dan433584@gmail.com> Update comment for malloc being a library call now, rather than an instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168946 91177308-0d34-0410-b5e6-96231b3b80d8
eb61c920f12cacee38815bf10821d2f294b66f3a 27-Nov-2012 Michael Ilseman <milseman@apple.com> Fast-math optimization: fold multiply by zero

Added in first optimization using fast-math flags to serve as an example for following optimizations. SimplifyInstruction will now try to optimize an fmul observing its FastMathFlags to see if it can fold multiply by zero when 'nnan' and 'nsz' flags are set.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168648 91177308-0d34-0410-b5e6-96231b3b80d8
d6f048959a8a747f7b8a2fe830e8589a106f090e 21-Nov-2012 Preston Briggs <preston.briggs@gmail.com> test commit: added a few comments

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168445 91177308-0d34-0410-b5e6-96231b3b80d8
7372a7d5f87bf1ff65d07f25bae037ddc4df994d 20-Nov-2012 Sebastian Pop <spop@codeaurora.org> removes a few "const" qualifiers

so that I can (someday) call SE->getSCEV without complaint.
No semantic change intended.

Patch from Preston Briggs <preston.briggs@gmail.com>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168391 91177308-0d34-0410-b5e6-96231b3b80d8
28f872f8a1945635f30763805c1418a90c6b345e 19-Nov-2012 Bob Wilson <bob.wilson@apple.com> Clean up handling of always-inline functions in the inliner.

This patch moves the isInlineViable function from the InlineAlways pass into
the InlineCostAnalyzer and then changes the InlineCost computation to use that
simple check for always-inline functions. All the special-case checks for
AlwaysInline in the CallAnalyzer can then go away.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168300 91177308-0d34-0410-b5e6-96231b3b80d8
593423f7461fbbbf752ff013bf20c19ef95d3435 19-Nov-2012 Bob Wilson <bob.wilson@apple.com> Some comment fixes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168299 91177308-0d34-0410-b5e6-96231b3b80d8
407a6169b729c72c3a7ddb01b8454ab0b4f6897c 15-Nov-2012 Michael Ilseman <milseman@apple.com> Remove trailing whitespace

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168103 91177308-0d34-0410-b5e6-96231b3b80d8
6bed58ef240b1e1a1fb41fb867a8ba6e7566e0e9 02-Nov-2012 Nadav Rotem <nrotem@apple.com> Add a cost model analysis that allows us to estimate the cost of IR-level instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167324 91177308-0d34-0410-b5e6-96231b3b80d8
ece6c6bb6329748b92403c06ac87f45c43485911 01-Nov-2012 Chandler Carruth <chandlerc@gmail.com> Revert the series of commits starting with r166578 which introduced the
getIntPtrType support for multiple address spaces via a pointer type,
and also introduced a crasher bug in the constant folder reported in

These commits also contained several problems that should really be
addressed before they are re-committed. I have avoided reverting various
cleanups to the DataLayout APIs that are reasonable to have moving
forward in order to reduce the amount of churn, and minimize the number
of commits that were reverted. I've also manually updated merge
conflicts and manually arranged for the getIntPtrType function to stay
in DataLayout and to be defined in a plausible way after this revert.

Thanks to Duncan for working through this exact strategy with me, and
Nick Lewycky for tracking down the really annoying crasher this
triggered. (Test case to follow in its own commit.)

After discussing with Duncan extensively, and based on a note from
Micah, I'm going to continue to back out some more of the more
problematic patches in this series in order to ensure we go into the
LLVM 3.2 branch with a reasonable story here. I'll send a note to
llvmdev explaining what's going on and why.

Summary of reverted revisions:

r166634: Fix a compiler warning with an unused variable.
r166607: Add some cleanup to the DataLayout changes requested by
r166596: Revert "Back out r166591, not sure why this made it through
since I cancelled the command. Bleh, sorry about this!
r166591: Delete a directory that wasn't supposed to be checked in yet.
r166578: Add in support for getIntPtrType to get the pointer type based
on the address space.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167221 91177308-0d34-0410-b5e6-96231b3b80d8
e803d05bd87d1181c971fb719fef5638dd44ce99 31-Oct-2012 Benjamin Kramer <benny.kra@googlemail.com> Fix a couple of comment typos.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167113 91177308-0d34-0410-b5e6-96231b3b80d8
6a09098cca6938dbfdc28e26fc45d626342816ac 29-Oct-2012 Bob Wilson <bob.wilson@apple.com> Remove code to saturate profile counts.

We may need to change the way profile counter values are stored, but
saturation is the wrong thing to do. Just remove it for now.

Patch by Alastair Murray!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166938 91177308-0d34-0410-b5e6-96231b3b80d8
b8b3f6081f8dc409e7281e1597d8d94e50e4b028 26-Oct-2012 Benjamin Kramer <benny.kra@googlemail.com> Remove LoopDependenceAnalysis.

It was unmaintained and not much more than a stub. The new DependenceAnalysis
pass is both more general and complete.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166810 91177308-0d34-0410-b5e6-96231b3b80d8
ff18310274e872429cd06d679b1c8c8a14166328 26-Oct-2012 Benjamin Kramer <benny.kra@googlemail.com> Add a basic verifier for SCEV's backedge taken counts.

Enabled with -verify-scev. This could be extended significantly but hopefully
catches the common cases now. Note that it's not enabled by default in any
configuration because the way it tries to distinguish SCEVs is still fragile and
may produce false positives. Also the test-suite isn't clean yet, one example
is that it fails if a pass drops an NSW bit but it's still present in SCEV's
cached. Cleaning up all those cases will take some time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166786 91177308-0d34-0410-b5e6-96231b3b80d8
8e4e0074092f5e6e429f4ac5415a82a8423ec4f9 25-Oct-2012 Benjamin Kramer <benny.kra@googlemail.com> DependenceAnalysis: Push #includes down into the implementation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166688 91177308-0d34-0410-b5e6-96231b3b80d8
aa76e9e2cf50af190de90bc778b7f7e42ef9ceff 24-Oct-2012 Micah Villmow <villmow@gmail.com> Add in support for getIntPtrType to get the pointer type based on the address space.
This checkin also adds in some tests that utilize these paths and updates some of the

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166578 91177308-0d34-0410-b5e6-96231b3b80d8
a04a4a79ea365d1ba96ed4b5861e879b267162e2 19-Oct-2012 Nadav Rotem <nrotem@apple.com> revert r166264 because the LTO build is still failing

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166340 91177308-0d34-0410-b5e6-96231b3b80d8
725f1d12801109a3b1d081a6e1c9e44426b2cf34 19-Oct-2012 Nadav Rotem <nrotem@apple.com> recommit the patch that makes LSR and LowerInvoke use the TargetTransform interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166264 91177308-0d34-0410-b5e6-96231b3b80d8
3b9a911efcf280950f878a050728450423875639 18-Oct-2012 Bob Wilson <bob.wilson@apple.com> Temporarily revert the TargetTransform changes.

The TargetTransform changes are breaking LTO bootstraps of clang. I am
working with Nadav to figure out the problem, but I am reverting it for now
to get our buildbots working.

This reverts svn commits: 165665 165669 165670 165786 165787 165997
and I have also reverted clang svn 165741

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166168 91177308-0d34-0410-b5e6-96231b3b80d8
ed84062812c7b8a82d0e8128a22aa1aa07a14d79 12-Oct-2012 Sean Silva <silvas@purdue.edu> Remove unnecessary classof()'s

isa<> et al. automatically infer when the cast is an upcast (including a
self-cast), so these are no longer necessary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165767 91177308-0d34-0410-b5e6-96231b3b80d8
aa79721fceb3310db5c6aa98f212b690652a8ab4 12-Oct-2012 Chad Rosier <mcrosier@apple.com> Remove extra semicolon.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165758 91177308-0d34-0410-b5e6-96231b3b80d8
54d2d2bbe9be3f23b680e6c6ba28e7ef1fade992 11-Oct-2012 NAKAMURA Takumi <geek4civic@gmail.com> llvm/Analysis/Passes.h: Fix copypasto in createDependenceAnalysisPass().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165709 91177308-0d34-0410-b5e6-96231b3b80d8
ad43499fc4c2879e25e8c83ddd556a3079e41516 11-Oct-2012 Sebastian Pop <spop@codeaurora.org> dependence analysis

Patch from Preston Briggs <preston.briggs@gmail.com>.

This is an updated version of the dependence-analysis patch, including an MIV
test based on Banerjee's inequalities.

It's a fairly complete implementation of the paper

Practical Dependence Testing
Gina Goff, Ken Kennedy, and Chau-Wen Tseng
PLDI 1991

It cannot yet propagate constraints between coupled RDIV subscripts (discussed
in Section 5.3.2 of the paper).

It's organized as a FunctionPass with a single entry point that supports testing
for dependence between two instructions in a function. If there's no dependence,
it returns null. If there's a dependence, it returns a pointer to a Dependence
which can be queried about details (what kind of dependence, is it loop
independent, direction and distance vector entries, etc). I haven't included
every imaginable feature, but there's a good selection that should be adequate
for supporting many loop transformations. Of course, it can be extended as

Included in the patch file are many test cases, commented with C code showing
the loops and array references.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165708 91177308-0d34-0410-b5e6-96231b3b80d8
e3d0e86919730784faaddcb5d9b0257c39b0804b 11-Oct-2012 Nadav Rotem <nrotem@apple.com> Add a new interface to allow IR-level passes to access codegen-specific information.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165665 91177308-0d34-0410-b5e6-96231b3b80d8
c92b8aa79f4a2cd16f7b674189e425c2c367e886 09-Oct-2012 Nick Lewycky <nicholas@mxc.ca> Give CaptureTracker::shouldExplore a base implementation. Most users want to do
the same thing. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165435 91177308-0d34-0410-b5e6-96231b3b80d8
3574eca1b02600bac4e625297f4ecf745f4c4f32 08-Oct-2012 Micah Villmow <villmow@gmail.com> Move TargetData to DataLayout.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165402 91177308-0d34-0410-b5e6-96231b3b80d8
4fde2f6a280d0697c31d82e4148a4ba36fc8c0f0 04-Oct-2012 Jakub Staszak <kubastaszak@gmail.com> Fix doxygen comment to match parameters' names.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165239 91177308-0d34-0410-b5e6-96231b3b80d8
94c22716d60ff5edf6a98a3c67e0faa001be1142 27-Sep-2012 Sylvestre Ledru <sylvestre@debian.org> Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164767

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164768 91177308-0d34-0410-b5e6-96231b3b80d8
7e2c793a2b5c746344652b6579e958ee42fafdcc 27-Sep-2012 Sylvestre Ledru <sylvestre@debian.org> Fix a typo 'iff' => 'if'

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164767 91177308-0d34-0410-b5e6-96231b3b80d8
adb4a40cb6ef2dba298e9dac5a905fcd2bee6e35 19-Sep-2012 Will Dietz <wdietz2@illinois.edu> Fix minor typo in IntervalPartition.h

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164222 91177308-0d34-0410-b5e6-96231b3b80d8
9455a61009d6745558b217a44838f5c6318b0d5c 19-Sep-2012 Benjamin Kramer <benny.kra@googlemail.com> InlineCost: Make TotalAllocaSizeRecursiveCaller unsigned to avoid sign-compare warnings.

It's a size, not a cost.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164219 91177308-0d34-0410-b5e6-96231b3b80d8
92df026f0da91dc65ef6186e97ff87b1f53e8cd0 19-Sep-2012 Nadav Rotem <nrotem@apple.com> Prevent inlining of callees which allocate lots of memory into a recursive caller.


void foo() {
... foo(); // I'm recursive!


bar() { int a[1000]; // large stack size }


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164207 91177308-0d34-0410-b5e6-96231b3b80d8
de8091708f2d5ade958507aa6d37907a6277e9f2 17-Sep-2012 Craig Topper <craig.topper@gmail.com> Mark unimplemented copy constructors and copy assignment operators as LLVM_DELETED_FUNCTION.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164015 91177308-0d34-0410-b5e6-96231b3b80d8
7ffafe4102ec4b8491a82e700076c85bd692ec84 17-Sep-2012 Craig Topper <craig.topper@gmail.com> Remove a couple unused fields. Not detected by Wunused-private-field because of unimplemented copy constructor and copy assignment operator that make the class look incomplete. Upcoming patch will mark them deleted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164013 91177308-0d34-0410-b5e6-96231b3b80d8
15d0c81b2496a025af30a78e3a36fd7f05b165ef 05-Sep-2012 Roman Divacky <rdivacky@freebsd.org> Remove unused typedefs gcc4.8 warns about.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163225 91177308-0d34-0410-b5e6-96231b3b80d8
230768bd1316a012e88ac62689589fe5e2f10456 05-Sep-2012 Dan Gohman <gohman@apple.com> Make provenance checking conservative in cases when
pointers-to-strong-pointers may be in play. These can lead to retains and
releases happening in unstructured ways, foiling the optimizer. This fixes

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163180 91177308-0d34-0410-b5e6-96231b3b80d8
cb5f63d7fa717b67a666712a3a0d7eebd4d8fb8b 31-Aug-2012 Benjamin Kramer <benny.kra@googlemail.com> Clean up ProfileDataLoader a bit.

- Overloading operator<< for raw_ostream and pointers is dangerous, it alters
the behavior of code that includes the header.
- Remove unused ID.
- Use LLVM's byte swapping helpers instead of a hand-coded.
- Make ReadProfilingData work directly on a pointer.

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162992 91177308-0d34-0410-b5e6-96231b3b80d8
f91e400b2125067e75e0f2159bca7ffd0cf109a0 31-Aug-2012 Bill Wendling <isanbard@gmail.com> Cleanups due to feedback. No functionality change. Patch by Alistair.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162979 91177308-0d34-0410-b5e6-96231b3b80d8
688c1cd6c932ce2811905dbca64e631c7ecbbd0f 29-Aug-2012 Michael Liao <michael.liao@intel.com> fix C++ comment in C header

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162856 91177308-0d34-0410-b5e6-96231b3b80d8
8e0d1c03ca7fd86e6879b4e37d0d7f0e982feef6 29-Aug-2012 Benjamin Kramer <benny.kra@googlemail.com> Make MemoryBuiltins aware of TargetLibraryInfo.

This disables malloc-specific optimization when -fno-builtin (or -ffreestanding)
is specified. This has been a problem for a long time but became more severe
with the recent memory builtin improvements.

Since the memory builtin functions are used everywhere, this required passing
TLI in many places. This means that functions that now have an optional TLI
argument, like RecursivelyDeleteTriviallyDeadFunctions, won't remove dead
mallocs anymore if the TLI argument is missing. I've updated most passes to do
the right thing.

Fixes PR13694 and probably others.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162841 91177308-0d34-0410-b5e6-96231b3b80d8
d26200423ee818e54d4088bd0c499caf840d866d 29-Aug-2012 Manman Ren <mren@apple.com> Profile: set branch weight metadata with data generated from profiling.

This patch implements ProfileDataLoader which loads profile data generated by
-insert-edge-profiling and updates branch weight metadata accordingly.

Patch by Alastair Murray.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162799 91177308-0d34-0410-b5e6-96231b3b80d8
23a22a29441b8b7d948e6ff7c2afb39e6528cfbd 27-Aug-2012 Hongbin Zheng <etherzhhb@gmail.com> Remove the the block_node_iterator of Region, replace it by the block_iterator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162672 91177308-0d34-0410-b5e6-96231b3b80d8
6adeb67b33d718767ff25e935fbfafff8e5584e0 24-Aug-2012 Manman Ren <mren@apple.com> Forgot to check in ProfileDataTypes.h in r162576

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162578 91177308-0d34-0410-b5e6-96231b3b80d8
cd62c287230a495134ae8c896a9e1f49fc981ba4 24-Aug-2012 Manman Ren <mren@apple.com> Profile: move a single enum out of ProfileInfoTypes.h into a new
ProfileDataTypes.h header.

With this patch the old and new profiling code can exist side-by-side. The new
profiling code will be submitted soon and it only supports insert-edge-profiling
for now and will not depend on ProfileInfo.

Patch by Alastair Murray.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162576 91177308-0d34-0410-b5e6-96231b3b80d8
1a710fdde197b00107ef55df51054925b9a5d2a2 24-Aug-2012 Manman Ren <mren@apple.com> BranchProb: modify the definition of an edge in BranchProbabilityInfo to handle
the case of multiple edges from one block to another.

A simple example is a switch statement with multiple values to the same
destination. The definition of an edge is modified from a pair of blocks to
a pair of PredBlock and an index into the successors.

Also set the weight correctly when building SelectionDAG from LLVM IR,
especially when converting a Switch.
IntegersSubsetMapping is updated to calculate the weight for each cluster.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162572 91177308-0d34-0410-b5e6-96231b3b80d8
168843c0137ad67c24a3930244a9c5f60add320d 17-Aug-2012 Benjamin Kramer <benny.kra@googlemail.com> MemoryBuiltins: Properly guard ObjectSizeOffsetVisitor against cycles in the IR.

The previous fix only checked for simple cycles, use a set to catch longer
cycles too.

Drop the broken check from the ObjectSizeOffsetEvaluator. The BoundsChecking
pass doesn't have to deal with invalid IR like InstCombine does.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162120 91177308-0d34-0410-b5e6-96231b3b80d8
05130597262f3ed00dc4881d64795d117c76e3fc 16-Aug-2012 Rafael Espindola <rafael.espindola@gmail.com> Teach GVN to reason about edges dominating uses. This allows it to handle cases
where some fact lake a=b dominates a use in a phi, but doesn't dominate the
basic block itself.

This feature could also be implemented by splitting critical edges, but at least
with the current algorithm reasoning about the dominance directly is faster.

The time for running "opt -O2" in the testcase in pr10584 is 1.003 times slower
and on gcc as a single file it is 1.0007 times faster.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162023 91177308-0d34-0410-b5e6-96231b3b80d8
0c34ae88bfe6ab40fc30784f131510992438ea43 15-Aug-2012 Bill Wendling <isanbard@gmail.com> Set the branch probability of branching to the 'normal' destination of an invoke
instruction to something absurdly high, while setting the probability of
branching to the 'unwind' destination to the bare minimum. This should set cause
the normal destination's invoke blocks to be moved closer to the invoke.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161944 91177308-0d34-0410-b5e6-96231b3b80d8
a3a3219b3a972db6449548abf7e0c9112e8ce7b9 13-Aug-2012 Nadav Rotem <nrotem@apple.com> Fix a documentation typo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161758 91177308-0d34-0410-b5e6-96231b3b80d8
25ac7518ffda5f4256e8333dde4801270bb26418 10-Aug-2012 Rafael Espindola <rafael.espindola@gmail.com> Move BasicBlockEdge to the cpp file. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161663 91177308-0d34-0410-b5e6-96231b3b80d8
702bcce747cd3fd89049b16d37c9c88952b5af81 07-Aug-2012 Rafael Espindola <rafael.espindola@gmail.com> The dominance computation already has logic for computing if an edge dominates
a use or a BB, but it is inline in the handling of the invoke instruction.

This patch refactors it so that it can be used in other cases. For example, in

define i32 @f(i32 %x) {
%cmp = icmp eq i32 %x, 0
br i1 %cmp, label %bb2, label %bb1
br label %bb2
%cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
%foo = add i32 %cond, %x
ret i32 %foo

GVN should be able to replace %x with 0 in any use that is dominated by the
true edge out of bb0. In the above example the only such use is the one in
the phi.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161429 91177308-0d34-0410-b5e6-96231b3b80d8
5258d9f96767d898af4756930ce0c66a31ddf7d9 02-Aug-2012 NAKAMURA Takumi <geek4civic@gmail.com> include/llvm/Analysis/RegionInfo.h: Appease msvc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161179 91177308-0d34-0410-b5e6-96231b3b80d8
f63f8834250e5bd50b1cc5b2649acdf42988abad 02-Aug-2012 Hongbin Zheng <etherzhhb@gmail.com> Implement the block_iterator of Region based on df_iterator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161177 91177308-0d34-0410-b5e6-96231b3b80d8
6e699bf38dd862331532bd6f74ec491bdfad5db9 25-Jul-2012 Nuno Lopes <nunoplopes@sapo.pt> revert r160742: it's breaking CMake build

original commit msg:
MemoryBuiltins: add support to determine the size of strdup'ed non-constant strings

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160751 91177308-0d34-0410-b5e6-96231b3b80d8
e3094283e38d9e6f6a4a7a14a3a5d0f2af67d5d5 25-Jul-2012 Nuno Lopes <nunoplopes@sapo.pt> MemoryBuiltins: add support to determine the size of strdup'ed non-constant strings

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160742 91177308-0d34-0410-b5e6-96231b3b80d8
e288cd100f86631ec0ade2a85930397a4ea7b21e 21-Jul-2012 Benjamin Kramer <benny.kra@googlemail.com> Remove unused private member variables uncovered by the recent changes to clang's -Wunused-private-field.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160583 91177308-0d34-0410-b5e6-96231b3b80d8
18a1b616ea123548b61a037c4f4fea4133aac1b5 18-Jul-2012 Andrew Trick <atrick@apple.com> SCEVTraversal: Add a visited set.

Expression trees may be DAGs. Make sure traversal has linear complexity.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160426 91177308-0d34-0410-b5e6-96231b3b80d8
31f18eeb2bff53ce48c9c980f0b0676401d593c8 17-Jul-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Allow for customized graph edge pruning in PostOrderIterator.h

Make it possible to prune individual graph edges from a post-order
traversal by specializing the po_iterator_storage template. Previously,
it was only possible to prune full graph nodes. Edge pruning makes it
possible to remove loop back-edges, for example.

Also replace the existing DFSetTraits customization hook with a
po_iterator_storage method for observing the post-order. DFSetTraits was
only used by LoopIterator.h which now provides a po_iterator_storage

Thanks to Sean and Chandler for reviewing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160366 91177308-0d34-0410-b5e6-96231b3b80d8
e08c32249fca32cd7b122024a4ca252fcb235694 14-Jul-2012 Andrew Trick <atrick@apple.com> LSR Fix: check SCEV expression safety before expansion.

All SCEV expressions used by LSR formulae must be safe to
expand. i.e. they may not contain UDiv unless we can prove nonzero

Fixes PR11356: LSR hoists UDiv.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160205 91177308-0d34-0410-b5e6-96231b3b80d8
8b7036b0f4ae3f76ad24a6b9bc2d874620406306 14-Jul-2012 Andrew Trick <atrick@apple.com> Factor SCEV traversal code so I can use it elsewhere. No functionality.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160203 91177308-0d34-0410-b5e6-96231b3b80d8
0dff532fce434c3e9fdf9695aed8efeb5f752ed5 03-Jul-2012 Nuno Lopes <nunoplopes@sapo.pt> fold PHI nodes in SizeOffsetEvaluator whenever possible.
Unfortunately this change requires the cache map to hold WeakVHs instead

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159667 91177308-0d34-0410-b5e6-96231b3b80d8
06cb8ed00696eb14d1b831921452e50ec0568ea2 29-Jun-2012 Chandler Carruth <chandlerc@gmail.com> Move llvm/Support/IRBuilder.h -> llvm/IRBuilder.h

This was always part of the VMCore library out of necessity -- it deals
entirely in the IR. The .cpp file in fact was already part of the VMCore
library. This is just a mechanical move.

I've tried to go through and re-apply the coding standard's preferred
header sort, but at 40-ish files, I may have gotten some wrong. Please
let me know if so.

I'll be committing the corresponding updates to Clang and Polly, and
Duncan has DragonEgg.

Thanks to Bill and Eric for giving the green light for this bit of cleanup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159421 91177308-0d34-0410-b5e6-96231b3b80d8
16eeb6f5ebc978b03745177b9ac82684ab1c6932 29-Jun-2012 Bill Wendling <isanbard@gmail.com> The DIBuilder class is just a wrapper around debug info creation
(a.k.a. MDNodes). The module doesn't belong in Analysis. Move it to the VMCore

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159414 91177308-0d34-0410-b5e6-96231b3b80d8
41a3f251346681e21171879dce409b2e6a3ba750 28-Jun-2012 Nuno Lopes <nunoplopes@sapo.pt> MemoryBuiltins:
- recognize C++ new(std::nothrow) friends
- ignore ExtractElement and ExtractValue instructions in size/offset analysis (all easy cases are probably folded away before we get here)
- also recognize realloc as noalias

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159356 91177308-0d34-0410-b5e6-96231b3b80d8
0bcbd1df7a204e1e512f1a27066d725309de1b13 28-Jun-2012 Bill Wendling <isanbard@gmail.com> Move lib/Analysis/DebugInfo.cpp to lib/VMCore/DebugInfo.cpp and
include/llvm/Analysis/DebugInfo.h to include/llvm/DebugInfo.h.

The reasoning is because the DebugInfo module is simply an interface to the
debug info MDNodes and has nothing to do with analysis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159312 91177308-0d34-0410-b5e6-96231b3b80d8
494f8c6cfaa7443bc708f6006c70f37ca30ac765 27-Jun-2012 Bill Wendling <isanbard@gmail.com> Revamp how debugging information is emitted for debug info objects.

It's not necessary for each DI class to have its own copy of `print' and
`dump'. Instead, just give DIDescriptor those methods and have it call the
appropriate debugging printing routine based on the type of the debug

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159237 91177308-0d34-0410-b5e6-96231b3b80d8
c9b1e25493b393013b28e5d457f2fb2845a4dd9f 26-Jun-2012 Andrew Trick <atrick@apple.com> Enable the new LoopInfo algorithm by default.

The primary advantage is that loop optimizations will be applied in a
stable order. This helps debugging and unit test creation. It is also
a better overall implementation without pathologically bad performance
on deep functions.

On large functions (llvm-stress --size=200000 | opt -loops)
Before: 0.1263s
After: 0.0225s

On deep functions (after tweaking llvm-stress, thanks Nadav):
Before: 0.2281s
After: 0.0227s

See r158790 for more comments.

The loop tree is now consistently generated in forward order, but loop
passes are applied in reverse order over the program. If we have a
loop optimization that prefers forward order, that can easily be
achieved by adding a different type of LoopPassManager.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159183 91177308-0d34-0410-b5e6-96231b3b80d8
eb7c6865cd8d44a882aa7c3e10e1d976f333344f 22-Jun-2012 Nuno Lopes <nunoplopes@sapo.pt> remove extractMallocCallFromBitCast, since it was tailor maded for its sole user. Update GlobalOpt accordingly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158952 91177308-0d34-0410-b5e6-96231b3b80d8
2b3e9580536dfb5666b9d91e99baebf6d45bfa5f 21-Jun-2012 Nuno Lopes <nunoplopes@sapo.pt> Add support for invoke to the MemoryBuiltin analysid.
Update comments accordingly.

Make instcombine remove useless invokes to C++'s 'new' allocation function (test attached).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158937 91177308-0d34-0410-b5e6-96231b3b80d8
10cefaab3fa4270396fa57b3286ab9860fafb60d 21-Jun-2012 Nuno Lopes <nunoplopes@sapo.pt> move some typedefs so that we don't polute the llvm namespace. this should appease the GCC buildbots

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158924 91177308-0d34-0410-b5e6-96231b3b80d8
9e72a79ef4a9fcda482ce0b0e1f0bd6a4f16cffd 21-Jun-2012 Nuno Lopes <nunoplopes@sapo.pt> refactor the MemoryBuiltin analysis:
- provide more extensive set of functions to detect library allocation functions (e.g., malloc, calloc, strdup, etc)
- provide an API to compute the size and offset of an object pointed by

Move a few clients (GVN, AA, instcombine, ...) to the new API.
This implementation is a lot more aggressive than each of the custom implementations being replaced.

Patch reviewed by Nick Lewycky and Chandler Carruth, thanks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158919 91177308-0d34-0410-b5e6-96231b3b80d8
b9598e41bc5187cfe8fb6345a90be27e6967958f 21-Jun-2012 Andrew Trick <atrick@apple.com> Restructure PopulateLoopsDFS::insertIntoLoop.

As Nadav pointed out the first implementation was obscure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158862 91177308-0d34-0410-b5e6-96231b3b80d8
60c7d5bc2cbeff9eff16716295ffd6a5374dc6bc 20-Jun-2012 Andrew Trick <atrick@apple.com> Add "extern template" declarations now that we use explicit instantiation.

This is supported by gcc and clang, but guarded by a macro for MSVC 2008.

The extern template declaration is not necessary but generally good
form. It can avoid extra instantiations of the template methods
defined inline.

The EXTERN_TEMPLATE_INSTANTIATION macro could probably be generalized to
handle multiple template parameters if someone thinks it's worthwhile.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158840 91177308-0d34-0410-b5e6-96231b3b80d8
305b515c2787f47adecbe120e4b4bef55c5e5525 20-Jun-2012 Chandler Carruth <chandlerc@gmail.com> Remove 'static' from inline functions defined in header files.

There is a pretty staggering amount of this in LLVM's header files, this
is not all of the instances I'm afraid. These include all of the
functions that (in my build) are used by a non-static inline (or
external) function. Specifically, these issues were caught by the new
'-Winternal-linkage-in-inline' warning.

I'll try to just clean up the remainder of the clearly redundant "static
inline" cases on functions (not methods!) defined within headers if
I can do so in a reliable way.

There were even several cases of a missing 'inline' altogether, or my
personal favorite "static bool inline". Go figure. ;]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158800 91177308-0d34-0410-b5e6-96231b3b80d8
37aa33bc11c01a7142bfa2428a5a4d219b07b6c3 20-Jun-2012 Andrew Trick <atrick@apple.com> A new algorithm for computing LoopInfo. Temporarily disabled.

-stable-loops enables a new algorithm for generating the Loop
forest. It differs from the original algorithm in a few respects:

- Not determined by use-list order.
- Initially guarantees RPO order of block and subloops.
- Linear in the number of CFG edges.
- Nonrecursive.

I didn't want to change the LoopInfo API yet, so the block lists are
still inclusive. This seems strange to me, and it means that building
LoopInfo is not strictly linear, but it may not be a problem in
practice. At least the block lists start out in RPO order now. In the
future we may add an attribute or wrapper analysis that allows other
passes to assume RPO order.

The primary motivation of this work was not to optimize LoopInfo, but
to allow reproducing performance issues by decomposing the compilation
stages. I'm often unable to do this with the current LoopInfo, because
the loop tree order determines Loop pass order. Serializing the IR
tends to invert the order, which reverses the optimization order. This
makes it nearly impossible to debug interdependent loop optimizations
such as LSR.

I also believe this will provide more stable performance results across time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158790 91177308-0d34-0410-b5e6-96231b3b80d8
cbf24b4e58c2f621f480883c5bb1f2f2b2b8d497 20-Jun-2012 Andrew Trick <atrick@apple.com> Move the implementation of LoopInfo into LoopInfoImpl.h.

The implementation only needs inclusion from LoopInfo.cpp and
MachineLoopInfo.cpp. Clients of the interface should only include the
interface. This makes the interface readable and speeds up rebuilds
after modifying the implementation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158787 91177308-0d34-0410-b5e6-96231b3b80d8
95a9d937728ca9cf2bf44f86ff1184df318b3bd7 06-Jun-2012 Benjamin Kramer <benny.kra@googlemail.com> Round 2 of dead private variable removal.

LLVM is now -Wunused-private-field clean except for
- lib/MC/MCDisassembler/Disassembler.h. Not sure why it keeps all those unaccessible fields.
- gtest.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158096 91177308-0d34-0410-b5e6-96231b3b80d8
d9b0b025612992a0b724eeca8bdf10b1d7a5c355 02-Jun-2012 Benjamin Kramer <benny.kra@googlemail.com> Fix typos found by http://github.com/lyda/misspell-check

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157885 91177308-0d34-0410-b5e6-96231b3b80d8
fc4199bf4add3422ce6470ca47bbe6bff2d70ea5 01-Jun-2012 Eric Christopher <echristo@apple.com> Add support for enum forward declarations.

Part of rdar://11570854

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157786 91177308-0d34-0410-b5e6-96231b3b80d8
6cf07a80ff5ee8ef7dc336f954aae17c7e8d83d4 30-May-2012 Benjamin Kramer <benny.kra@googlemail.com> Teach SCEV's icmp simplification logic that a-b == 0 is equivalent to a == b.

This also required making recursive simplifications until
nothing changes or a hard limit (currently 3) is hit.

With the simplification in place indvars can canonicalize
loops of the form
for (unsigned i = 0; i < a-b; ++i)
for (unsigned i = 0; i != a-b; ++i)
which used to fail because SCEV created a weird umax expr
for the backedge taken count.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157701 91177308-0d34-0410-b5e6-96231b3b80d8
bb0f6eac1f2d04e485607f0726c31a84ce9b8ced 23-May-2012 Eric Christopher <echristo@apple.com> Add support for C++11 enum classes in llvm.

Part of rdar://11496790

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157303 91177308-0d34-0410-b5e6-96231b3b80d8
791e629deef7e4a410e67527da26405916415d3a 19-May-2012 Eric Christopher <echristo@apple.com> Actually support DW_TAG_rvalue_reference_type that we were trying
to generate out of the front end.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157094 91177308-0d34-0410-b5e6-96231b3b80d8
8aa22019ca5ef29a15058be905d782e7225aa206 19-May-2012 Andrew Trick <atrick@apple.com> SCEV: Add MarkPendingLoopPredicates to avoid recursive isImpliedCond.

getUDivExpr attempts to simplify by checking for overflow.
isLoopEntryGuardedByCond then evaluates the loop predicate which
may lead to the same getUDivExpr causing endless recursion.

Fixes PR12868: clang 3.2 segmentation fault.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157092 91177308-0d34-0410-b5e6-96231b3b80d8
3a884f5c17ac32e34e7e62b4602a0d73eeda1ce8 14-May-2012 Chad Rosier <mcrosier@apple.com> Move the capture analysis from MemoryDependencyAnalysis to a more general place
so that it can be reused in MemCpyOptimizer. This analysis is needed to remove
an unnecessary memcpy when returning a struct into a local variable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156776 91177308-0d34-0410-b5e6-96231b3b80d8
b401e3bd16c3d648464606d5e5b496dd61d12afc 10-May-2012 Dan Gohman <gohman@apple.com> Teach DeadStoreElimination to eliminate exit-block stores with phi addresses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156558 91177308-0d34-0410-b5e6-96231b3b80d8
599da5ec016a6e52371c8e76e5aa091c04cbacd1 08-May-2012 Eric Christopher <echristo@apple.com> Update comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156404 91177308-0d34-0410-b5e6-96231b3b80d8
7c52c97a2232756bbcc2fb4e664892bdb8b2d90c 04-May-2012 Chandler Carruth <chandlerc@gmail.com> Rename the Region::block_iterator to Region::block_node_iterator, and
add a new Region::block_iterator which actually iterates over the basic
blocks of the region.

The old iterator, now call 'block_node_iterator' iterates over
RegionNodes which contain a single basic block. This works well with the
GraphTraits-based iterator design, however most users actually want an
iterator over the BasicBlocks inside these RegionNodes. Now the
'block_iterator' is a wrapper which exposes exactly this interface.
Internally it uses the block_node_iterator to walk all nodes which are
single basic blocks, but transparently unwraps the basic block to make
user code simpler.

While this patch is a bit of a wash, most of the updates are to internal
users, not external users of the RegionInfo. I have an accompanying
patch to Polly that is a strict simplification of every user of this
interface, and I'm working on a pass that also wants the same simplified

This patch alone should have no functional impact.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156202 91177308-0d34-0410-b5e6-96231b3b80d8
d5003cafd6fc86acaf8e09ef0ca1dc899da8850e 04-May-2012 Chandler Carruth <chandlerc@gmail.com> A pile of long over-due refactorings here. There are some very, *very*
minor behavior changes with this, but nothing I have seen evidence of in
the wild or expect to be meaningful. The real goal is unifying our logic
and simplifying the interfaces. A summary of the changes follows:

- Make 'callIsSmall' actually accept a callsite so it can handle
intrinsics, and simplify callers appropriately.
- Nuke a completely bogus declaration of 'callIsSmall' that was still
lurking in InlineCost.h... No idea how this got missed.
- Teach the 'isInstructionFree' about the various more intelligent
'free' heuristics that got added to the inline cost analysis during
review and testing. This mostly surrounds int->ptr and ptr->int casts.
- Switch most of the interesting parts of the inline cost analysis that
were essentially computing 'is this instruction free?' to use the code
metrics routine instead. This way we won't keep duplicating logic.

All of this is motivated by the desire to allow other passes to compute
a roughly equivalent 'cost' metric for a particular basic block as the
inline cost analysis. Sadly, re-using the same analysis for both is
really messy because only the actual inline cost analysis is ever going
to go to the contortions required for simplification, SROA analysis,

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156140 91177308-0d34-0410-b5e6-96231b3b80d8
252ef566e8734b6bcf46434d0a7954c9eda0bd96 03-May-2012 Nuno Lopes <nunoplopes@sapo.pt> add support for calloc to objectsize lowering

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156102 91177308-0d34-0410-b5e6-96231b3b80d8
216432df5ac897327a0cb6323f08811910481038 23-Apr-2012 Eric Christopher <echristo@apple.com> Allow forward declarations to take a context. This helps the debugger
find forward declarations in the context that the actual definition
will occur.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155380 91177308-0d34-0410-b5e6-96231b3b80d8
558ece284cef9d42a96577f3943cb3efee8904e0 13-Apr-2012 Dan Gohman <gohman@apple.com> Add forms of dominates and isReachableFromEntry that accept a Use
directly instead of a user Instruction. This allows them to test
whether a def dominates a particular operand if the user instruction
is a PHI.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154631 91177308-0d34-0410-b5e6-96231b3b80d8
f7c3e5f05199e1202c86198e0827cac19c0f48b5 11-Apr-2012 Benjamin Kramer <benny.kra@googlemail.com> FoldingSet: Push the hash through FoldingSetTraits::Equals, so clients can use it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154496 91177308-0d34-0410-b5e6-96231b3b80d8
d9fc1ce8096f7138c60edc3a6655583bf209780e 10-Apr-2012 Andrew Trick <atrick@apple.com> Fix 12513: Loop unrolling breaks with indirect branches.

Take this opportunity to generalize the indirectbr bailout logic for
loop transformations. CFG transformations will never get indirectbr
right, and there's no point trying.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154386 91177308-0d34-0410-b5e6-96231b3b80d8
b381578fcb5fea988f661dbbee9747b8fd55c5fb 06-Apr-2012 David Chisnall <csdavec@swan.ac.uk> Reintroduce InlineCostAnalyzer::getInlineCost() variant with explicit callee
parameter until we have a more sensible API for doing the same thing.

Reviewed by Chandler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154180 91177308-0d34-0410-b5e6-96231b3b80d8
26c8dcc692fb2addd475446cfff24d6a4e958bca 04-Apr-2012 Rafael Espindola <rafael.espindola@gmail.com> Always compute all the bits in ComputeMaskedBits.
This allows us to keep passing reduced masks to SimplifyDemandedBits, but
know about all the bits if SimplifyDemandedBits fails. This allows instcombine
to simplify cases like the one in the included testcase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154011 91177308-0d34-0410-b5e6-96231b3b80d8
6126a1e1894f346fae02a514a20aa56b879aeb99 03-Apr-2012 Eric Christopher <echristo@apple.com> Add a line number for the scope of the function (starting at the first
brace) so that we get more accurate line number information about the
declaration of a given function and the line where the function
first starts.

Part of rdar://11026482

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153916 91177308-0d34-0410-b5e6-96231b3b80d8
1c8cf21d0c96cee0d55b619be58b1b400675e6ac 03-Apr-2012 Rafael Espindola <rafael.espindola@gmail.com> Make dominatedBySlowTreeWalk private and assert cases handled by the caller.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153905 91177308-0d34-0410-b5e6-96231b3b80d8
5004e9849aff165bcbd953f891b402ad23bdd1ac 02-Apr-2012 Rafael Espindola <rafael.espindola@gmail.com> Add missing 'd'.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153872 91177308-0d34-0410-b5e6-96231b3b80d8
caa2c40a57040dc3e1a5e40401cd1e4ede845451 02-Apr-2012 Chandler Carruth <chandlerc@gmail.com> Start cleaning up the InlineCost class. This switches to sentinel values
rather than a bitfield, a great suggestion by Chris during code review.

There is still quite a bit of cruft in the interface, but that requires
sorting out some awkward uses of the cost inside the actual inliner.

No functionality changed intended here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153853 91177308-0d34-0410-b5e6-96231b3b80d8
6226c49bdec886a7162e24e152af579df203e163 31-Mar-2012 Rafael Espindola <rafael.espindola@gmail.com> Add a workaround for building with old versions of clang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153820 91177308-0d34-0410-b5e6-96231b3b80d8
95d594cac3737ae1594a391276942a443cac426b 31-Mar-2012 Rafael Espindola <rafael.espindola@gmail.com> Teach CodeGen's version of computeMaskedBits to understand the range metadata.
This is the CodeGen equivalent of r153747. I tested that there is not noticeable
performance difference with any combination of -O0/-O2 /-g when compiling
gcc as a single compilation unit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153817 91177308-0d34-0410-b5e6-96231b3b80d8
45de584b4f82fbfb9cb9c50bc1fc08931b534308 31-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Remove a bunch of empty, dead, and no-op methods from all of these
interfaces. These methods were used in the old inline cost system where
there was a persistent cache that had to be updated, invalidated, and
cleared. We're now doing more direct computations that don't require
this intricate dance. Even if we resume some level of caching, it would
almost certainly have a simpler and more narrow interface than this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153813 91177308-0d34-0410-b5e6-96231b3b80d8
f2286b0152f0b942e82d8e809186e5cc0d247131 31-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Initial commit for the rewrite of the inline cost analysis to operate
on a per-callsite walk of the called function's instructions, in
breadth-first order over the potentially reachable set of basic blocks.

This is a major shift in how inline cost analysis works to improve the
accuracy and rationality of inlining decisions. A brief outline of the
algorithm this moves to:

- Build a simplification mapping based on the callsite arguments to the
function arguments.
- Push the entry block onto a worklist of potentially-live basic blocks.
- Pop the first block off of the *front* of the worklist (for
breadth-first ordering) and walk its instructions using a custom
- For each instruction's operands, re-map them based on the
simplification mappings available for the given callsite.
- Compute any simplification possible of the instruction after
re-mapping, and store that back int othe simplification mapping.
- Compute any bonuses, costs, or other impacts of the instruction on the
cost metric.
- When the terminator is reached, replace any conditional value in the
terminator with any simplifications from the mapping we have, and add
any successors which are not proven to be dead from these
simplifications to the worklist.
- Pop the next block off of the front of the worklist, and repeat.
- As soon as the cost of inlining exceeds the threshold for the
callsite, stop analyzing the function in order to bound cost.

The primary goal of this algorithm is to perfectly handle dead code
paths. We do not want any code in trivially dead code paths to impact
inlining decisions. The previous metric was *extremely* flawed here, and
would always subtract the average cost of two successors of
a conditional branch when it was proven to become an unconditional
branch at the callsite. There was no handling of wildly different costs
between the two successors, which would cause inlining when the path
actually taken was too large, and no inlining when the path actually
taken was trivially simple. There was also no handling of the code
*path*, only the immediate successors. These problems vanish completely
now. See the added regression tests for the shiny new features -- we
skip recursive function calls, SROA-killing instructions, and high cost
complex CFG structures when dead at the callsite being analyzed.

Switching to this algorithm required refactoring the inline cost
interface to accept the actual threshold rather than simply returning
a single cost. The resulting interface is pretty bad, and I'm planning
to do lots of interface cleanup after this patch.

Several other refactorings fell out of this, but I've tried to minimize
them for this patch. =/ There is still more cleanup that can be done
here. Please point out anything that you see in review.

I've worked really hard to try to mirror at least the spirit of all of
the previous heuristics in the new model. It's not clear that they are
all correct any more, but I wanted to minimize the change in this single
patch, it's already a bit ridiculous. One heuristic that is *not* yet
mirrored is to allow inlining of functions with a dynamic alloca *if*
the caller has a dynamic alloca. I will add this back, but I think the
most reasonable way requires changes to the inliner itself rather than
just the cost metric, and so I've deferred this for a subsequent patch.
The test case is XFAIL-ed until then.

As mentioned in the review mail, this seems to make Clang run about 1%
to 2% faster in -O0, but makes its binary size grow by just under 4%.
I've looked into the 4% growth, and it can be fixed, but requires
changes to other parts of the inliner.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153812 91177308-0d34-0410-b5e6-96231b3b80d8
092c5ccf5bdcaa53151645e5628cec77fcf4062b 30-Mar-2012 Rafael Espindola <rafael.espindola@gmail.com> Handle unreachable code in the dominates functions. This changes users when
needed for correctness, but still doesn't clean up code that now unnecessary
checks for reachability.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153755 91177308-0d34-0410-b5e6-96231b3b80d8
b8ca98874316bfe8e46b27e7a034a8a764c92e08 29-Mar-2012 Eric Christopher <echristo@apple.com> Add support for objc property decls according to the page at:


including type and DECL. Expand the metadata needed accordingly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153639 91177308-0d34-0410-b5e6-96231b3b80d8
eede6c9075a3a872e0ea00bbd71ab6fa88b677cd 25-Mar-2012 Rafael Espindola <rafael.espindola@gmail.com> Use the isReachableFromEntry method.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153400 91177308-0d34-0410-b5e6-96231b3b80d8
42c487d2e529489648176ebb8e9ef022c07ef785 24-Mar-2012 Rafael Espindola <rafael.espindola@gmail.com> Avoid using dominatedBySlowTreeWalk.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153398 91177308-0d34-0410-b5e6-96231b3b80d8
6b980541df5846ad335c377c8803b517968daee2 24-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Refactor the interface to recursively simplifying instructions to be tad
bit simpler by handling a common case explicitly.

Also, refactor the implementation to use a worklist based walk of the
recursive users, rather than trying to use value handles to detect and
recover from RAUWs during the recursive descent. This fixes a very
subtle bug in the previous implementation where degenerate control flow
structures could cause mutually recursive instructions (PHI nodes) to
collapse in just such a way that From became equal to To after some
amount of recursion. At that point, we hit the inf-loop that the assert
at the top attempted to guard against. This problem is defined away when
not using value handles in this manner. There are lots of comments
claiming that the WeakVH will protect against just this sort of error,
but they're not accurate about the actual implementation of WeakVHs,
which do still track RAUWs.

I don't have any test case for the bug this fixes because it requires
running the recursive simplification on unreachable phi nodes. I've no
way to either run this or easily write an input that triggers it. It was
found when using instruction simplification inside the inliner when
running over the nightly test-suite.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153393 91177308-0d34-0410-b5e6-96231b3b80d8
1508e5e0495a3b3d034cb8e0b9be16b01749d8b3 22-Mar-2012 Andrew Trick <atrick@apple.com> Cleanup IVUsers::addUsersIfInteresting.

Keep the public interface clean, even though LLVM proper does not
currently use it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153263 91177308-0d34-0410-b5e6-96231b3b80d8
f91f5af802bd4487c49ee17cd0d3e46c6456263e 16-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Start removing the use of an ad-hoc 'never inline' set and instead
directly query the function information which this set was representing.
This simplifies the interface of the inline cost analysis, and makes the
always-inline pass significantly more efficient.

Previously, always-inline would first make a single set of every
function in the module *except* those marked with the always-inline
attribute. It would then query this set at every call site to see if the
function was a member of the set, and if so, refuse to inline it. This
is quite wasteful. Instead, simply check the function attribute directly
when looking at the callsite.

The normal inliner also had similar redundancy. It added every function
in the module with the noinline attribute to its set to ignore, even
though inside the cost analysis function we *already tested* the
noinline attribute and produced the same result.

The only tricky part of removing this is that we have to be able to
correctly remove only the functions inlined by the always-inline pass
when finalizing, which requires a bit of a hack. Still, much less of
a hack than the set of all non-always-inline functions was. While I was
touching this function, I switched a heavy-weight set to a vector with
sort+unique. The algorithm already had a two-phase insert and removal
pattern, we were just needlessly paying the uniquing cost on every

This probably speeds up some compiles by a small amount (-O0 compiles
with lots of always-inline, so potentially heavy libc++ users), but I've
not tried to measure it.

I believe there is no functional change here, but yell if you spot one.
None are intended.

Finally, the direction this is going in is to greatly simplify the
inline cost query interface so that we can replace its implementation
with a much more clever one. Along the way, all the APIs get simplified,
so it seems incrementally good.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152903 91177308-0d34-0410-b5e6-96231b3b80d8
9b081d9691f4509af58919db5760235ca319c9da 16-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Pull the implementation of the code metrics out of the inline cost
analysis implementation. The header was already separated. Also cleanup
all the comments in the header to follow a nice modern doxygen form.

There is still plenty of cruft here, but some of that will fall out in
subsequent refactorings and this was an easy step in the right
direction. No functionality changed here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152898 91177308-0d34-0410-b5e6-96231b3b80d8
75ae20366fd1b480f4cc38400bb075c43c9f4f7f 16-Mar-2012 Andrew Trick <atrick@apple.com> LSR fix: Add isSimplifiedLoopNest to IVUsers analysis.

Only record IVUsers that are dominated by simplified loop
headers. Otherwise SCEVExpander will crash while looking for a

I previously tried to work around this in LSR itself, but that was
insufficient. This way, LSR can continue to run if some uses are not
in simple loops, as long as we don't attempt to analyze those users.

Fixes <rdar://problem/11049788> Segmentation fault: 11 in LoopStrengthReduce

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152892 91177308-0d34-0410-b5e6-96231b3b80d8
220d2d7b50ddbbab1fe5e57fe9f39e72ef430a89 15-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Remove all remnants of partial specialization in the cost computation
side of things. This is all dead code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152759 91177308-0d34-0410-b5e6-96231b3b80d8
274d377ea68195989c3238fe96ce2ca812a12faf 15-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Extend the inline cost calculation to account for bonuses due to
correlated pairs of pointer arguments at the callsite. This is designed
to recognize the common C++ idiom of begin/end pointer pairs when the
end pointer is a constant offset from the begin pointer. With the
C-based idiom of a pointer and size, the inline cost saw the constant
size calculation, and this provides the same level of information for
begin/end pairs.

In order to propagate this information we have to search for candidate
operations on a pair of pointer function arguments (or derived from
them) which would be simplified if the pointers had a known constant
offset. Then the callsite analysis looks for such pointer pairs in the
argument list, and applies the appropriate bonus.

This helps LLVM detect that half of bounds-checked STL algorithms
(such as hash_combine_range, and some hybrid sort implementations)
disappear when inlined with a constant size input. However, it's not
a complete fix due the inaccuracy of our cost metric for constants in
general. I'm looking into that next.

Benchmarks showed no significant code size change, and very minor
performance changes. However, specific code such as hashing is showing
significantly cleaner inlining decisions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152752 91177308-0d34-0410-b5e6-96231b3b80d8
5161de6ebbd36b0532bd980483d757f5a3014611 13-Mar-2012 Chris Lattner <sabre@nondot.org> enhance jump threading to preserve TBAA information when PRE'ing loads,
fixing rdar://11039258, an issue that came up when inspecting clang's
bootstrapped codegen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152635 91177308-0d34-0410-b5e6-96231b3b80d8
bd0fe5642544d4ec3aee1ede7af60c006bae5cbf 13-Mar-2012 Duncan Sands <baldrick@free.fr> Generalize the "trunc(ptrtoint(x)) - trunc(ptrtoint(y)) ->
trunc(ptrtoint(x-y))" optimization introduced by Chandler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152626 91177308-0d34-0410-b5e6-96231b3b80d8
0aa85eb231dc76bcabcd35f6dc9a50536f607df3 13-Mar-2012 Duncan Sands <baldrick@free.fr> Uniformize the InstructionSimplify interface by ensuring that all routines
take a TargetLibraryInfo parameter. Internally, rather than passing TD, TLI
and DT parameters around all over the place, introduce a struct for holding

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152623 91177308-0d34-0410-b5e6-96231b3b80d8
c10fa6c801e48771b5eade50afc2fe6abaf08227 08-Mar-2012 Stepan Dyatkovskiy <stpworld@narod.ru> Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:

Implemented CaseIterator and it solves almost all described issues: we don't need to mix operand/case/successor indexing anymore. Base iterator class is implemented as a template since it may be initialized either from "const SwitchInst*" or from "SwitchInst*".

ConstCaseIt is just a read-only iterator.
CaseIt is read-write iterator; it allows to change case successor and case value.

Usage of iterator allows totally remove resolveXXXX methods. All indexing convertions done automatically inside the iterator's getters.

Main way of iterator usage looks like this:
SwitchInst *SI = ... // intialize it somehow

for (SwitchInst::CaseIt i = SI->caseBegin(), e = SI->caseEnd(); i != e; ++i) {
BasicBlock *BB = i.getCaseSuccessor();
ConstantInt *V = i.getCaseValue();
// Do something.

If you want to convert case number to TerminatorInst successor index, just use getSuccessorIndex iterator's method.
If you want initialize iterator from TerminatorInst successor index, use CaseIt::fromSuccessorIndex(...) method.

There are also related changes in llvm-clients: klee and clang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152297 91177308-0d34-0410-b5e6-96231b3b80d8
6f130bf368ab082ab87bafaee9bf4e1a78acc669 08-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Rotate two of the functions used to count bonuses for the inline cost
analysis to be methods on the cost analysis's function info object
instead of the code metrics object. These really are just users of the
code metrics, they're building the information for the function's

This is the first step of growing the amount of information we collect
about a function in order to cope with pair-wise simplifications due to

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152283 91177308-0d34-0410-b5e6-96231b3b80d8
c9ae8cc24c70dda33b68cacf01d2feeeb836f6f2 26-Feb-2012 Rafael Espindola <rafael.espindola@gmail.com> Change the implementation of dominates(inst, inst) to one based on what the
verifier does. This correctly handles invoke.
Thanks to Duncan, Andrew and Chris for the comments.
Thanks to Joerg for the early testing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151469 91177308-0d34-0410-b5e6-96231b3b80d8
8c727f9200cd54adc4a1b742950e80035bc53a20 26-Feb-2012 Rafael Espindola <rafael.espindola@gmail.com> Don't call dominates on unreachable instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151466 91177308-0d34-0410-b5e6-96231b3b80d8
55f4ab84e567ac101d70f052771d1bc67a7560e3 25-Feb-2012 Nick Lewycky <nicholas@mxc.ca> Move isKnownNonNull from private implementation detail of BasicAA to a public
function that others can use, next to llvm::isIdentifiedObject.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151446 91177308-0d34-0410-b5e6-96231b3b80d8
9f90e8760fda131db8311f976c6bbeb66abbaa05 20-Feb-2012 Eric Christopher <echristo@apple.com> Add support for runtime languages on our forward declarations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150973 91177308-0d34-0410-b5e6-96231b3b80d8
b0934ab7d811e23bf530371976b8b35f3242169c 19-Feb-2012 Ahmed Charles <ace2001ac@gmail.com> Remove dead code. Improve llvm_unreachable text. Simplify some control flow.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150918 91177308-0d34-0410-b5e6-96231b3b80d8
1a4ccc3aa24d0ed3617d617b80785ae33e9282b1 10-Feb-2012 Hal Finkel <hfinkel@anl.gov> Make aliasesPointer and aliasesUnknownInst public members of AliasSet.

These query functions are safe for external use and, furthermore,
are the only way to make queries against the "unknown instructions" array.
BBVectorize will use these functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150248 91177308-0d34-0410-b5e6-96231b3b80d8
4fe345729285ae634c657ab854057464d03220f7 08-Feb-2012 Eric Christopher <echristo@apple.com> Add support for a temporary forward decl type. We want this so we
can rauw forward declarations if we decide to emit the full type.

Part of rdar://10809898

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150024 91177308-0d34-0410-b5e6-96231b3b80d8
9f99721a1882cdef9f7cca25de7ea43627d23958 08-Feb-2012 Devang Patel <dpatel@apple.com> Remove tabs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150022 91177308-0d34-0410-b5e6-96231b3b80d8
6588abf377b7381274236e651462ec83052f6013 06-Feb-2012 Devang Patel <dpatel@apple.com> DebugInfo: Provide a new hook to encode relationship between a property and an ivar.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149874 91177308-0d34-0410-b5e6-96231b3b80d8
50bee42b54cd9aec5f49566307df2b0cf23afcf6 05-Feb-2012 Craig Topper <craig.topper@gmail.com> Convert assert(0) to llvm_unreachable

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149849 91177308-0d34-0410-b5e6-96231b3b80d8
18c7f80b3e83ab584bd8572695a3cde8bafd9d3c 05-Feb-2012 Chris Lattner <sabre@nondot.org> reapply the patches reverted in r149470 that reenable ConstantDataArray,
but with a critical fix to the SelectionDAG code that optimizes copies
from strings into immediate stores: the previous code was stopping reading
string data at the first nul. Address this by adding a new argument to
llvm::getConstantStringInfo, preserving the behavior before the patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149800 91177308-0d34-0410-b5e6-96231b3b80d8
0df823461dd3de0146c656cba4697d96998f3d24 04-Feb-2012 Devang Patel <dpatel@apple.com> Update llvm debug version to support new structure and tag for Objective-C property's debug info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149736 91177308-0d34-0410-b5e6-96231b3b80d8
1ea02d467a311b4846b942377d0b00fde987be65 04-Feb-2012 Devang Patel <dpatel@apple.com> Introduce DIObjCProperty. This will be used to encode objective-c property.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149732 91177308-0d34-0410-b5e6-96231b3b80d8
24473120a253a05f3601cd3373403b47e6d03d41 01-Feb-2012 Stepan Dyatkovskiy <stpworld@narod.ru> SwitchInst refactoring.
The purpose of refactoring is to hide operand roles from SwitchInst user (programmer). If you want to play with operands directly, probably you will need lower level methods than SwitchInst ones (TerminatorInst or may be User). After this patch we can reorganize SwitchInst operands and successors as we want.

What was done:

1. Changed semantics of index inside the getCaseValue method:
getCaseValue(0) means "get first case", not a condition. Use getCondition() if you want to resolve the condition. I propose don't mix SwitchInst case indexing with low level indexing (TI successors indexing, User's operands indexing), since it may be dangerous.
2. By the same reason findCaseValue(ConstantInt*) returns actual number of case value. 0 means first case, not default. If there is no case with given value, ErrorIndex will returned.
3. Added getCaseSuccessor method. I propose to avoid usage of TerminatorInst::getSuccessor if you want to resolve case successor BB. Use getCaseSuccessor instead, since internal SwitchInst organization of operands/successors is hidden and may be changed in any moment.
4. Added resolveSuccessorIndex and resolveCaseIndex. The main purpose of these methods is to see how case successors are really mapped in TerminatorInst.
4.1 "resolveSuccessorIndex" was created if you need to level down from SwitchInst to TerminatorInst. It returns TerminatorInst's successor index for given case successor.
4.2 "resolveCaseIndex" converts low level successors index to case index that curresponds to the given successor.

Note: There are also related compatability fix patches for dragonegg, klee, llvm-gcc-4.0, llvm-gcc-4.2, safecode, clang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149481 91177308-0d34-0410-b5e6-96231b3b80d8
91766fe066efe6e0969ba805a2e3726a70ed34a3 01-Feb-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Revert Chris' commits up to r149348 that started causing VMCoreTests unit test to fail.

These are:


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149470 91177308-0d34-0410-b5e6-96231b3b80d8
f98743a49d931e4f4d7ee17e5869972fc96ff115 31-Jan-2012 Chris Lattner <sabre@nondot.org> remove commented-out code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149364 91177308-0d34-0410-b5e6-96231b3b80d8
f0e1053a63f5522ecfe1df8fe3ea07b24cb6b193 31-Jan-2012 Chris Lattner <sabre@nondot.org> remove the last vestiges of llvm::GetConstantStringInfo, in CodeGen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149356 91177308-0d34-0410-b5e6-96231b3b80d8
3ef9cfef13d7c7208b98b2d9995c3df6dcfe0d99 31-Jan-2012 Chris Lattner <sabre@nondot.org> Change ConstantArray::get to form a ConstantDataArray when possible,
kicking in the big win of ConstantDataArray. As part of this, change
the implementation of GetConstantStringInfo in ValueTracking to work
with ConstantDataArray (and not ConstantArray) making it dramatically,
amazingly, more efficient in the process and renaming it to

This keeps around a GetConstantStringInfo entrypoint that (grossly)
forwards to getConstantStringInfo and constructs the std::string
required, but existing clients should move over to
getConstantStringInfo instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149351 91177308-0d34-0410-b5e6-96231b3b80d8
a97ddd0cffb9a9eb1313343fd49097c9057a5850 24-Jan-2012 Chris Lattner <sabre@nondot.org> Split the interesting bits of ConstantFoldLoadThroughGEPConstantExpr
out into a new ConstantFoldLoadThroughGEPIndices (more useful) function
and rewrite it to be simpler, more efficient, and to handle the new
ConstantDataSequential type.

Enhance ConstantFoldLoadFromConstPtr to handle ConstantDataSequential.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148786 91177308-0d34-0410-b5e6-96231b3b80d8
b5c26ef9da16052597d59a412eaae32098aa1be0 20-Jan-2012 Andrew Trick <atrick@apple.com> SCEVExpander fixes. Affects LSR and indvars.

LSR has gradually been improved to more aggressively reuse existing code, particularly existing phi cycles. This exposed problems with the SCEVExpander's sloppy treatment of its insertion point. I applied some rigor to the insertion point problem that will hopefully avoid an endless bug cycle in this area. Changes:

- Always used properlyDominates to check safe code hoisting.

- The insertion point provided to SCEV is now considered a lower bound. This is usually a block terminator or the use itself. Under no cirumstance may SCEVExpander insert below this point.

- LSR is reponsible for finding a "canonical" insertion point across expansion of different expressions.

- Robust logic to determine whether IV increments are in "expanded" form and/or can be safely hoisted above some insertion point.

Fixes PR11783: SCEVExpander assert.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148535 91177308-0d34-0410-b5e6-96231b3b80d8
bda43e95a03c19868106e8111d7a5bf1c924ec63 17-Jan-2012 Jakub Staszak <kubastaszak@gmail.com> Move includes to the .cpp file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148342 91177308-0d34-0410-b5e6-96231b3b80d8
3eada319fc21bca31a2bc7819e4c05f46e6f82e1 11-Jan-2012 Andrew Trick <atrick@apple.com> Clarified the SCEV getSmallConstantTripCount interface with in-your-face comments.

This interface is misleading and dangerous, but it is actually what we need for unrolling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147926 91177308-0d34-0410-b5e6-96231b3b80d8
64925c55c65f9345a69fb67db07aa62cfb723577 10-Jan-2012 Andrew Trick <atrick@apple.com> Enable LSR IV Chains with sufficient heuristics.

These heuristics are sufficient for enabling IV chains by
default. Performance analysis has been done for i386, x86_64, and
thumbv7. The optimization is rarely important, but can significantly
speed up certain cases by eliminating spill code within the
loop. Unrolled loops are prime candidates for IV chains. In many
cases, the final code could still be improved with more target
specific optimization following LSR. The goal of this feature is for
LSR to make the best choice of induction variables.

Instruction selection may not completely take advantage of this
feature yet. As a result, there could be cases of slight code size

Code size can be worse on x86 because it doesn't support postincrement
addressing. In fact, when chains are formed, you may see redundant
address plus stride addition in the addressing mode. GenerateIVChains
tries to compensate for the common cases.

On ARM, code size increase can be mitigated by using postincrement
addressing, but downstream codegen currently misses some opportunities.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147826 91177308-0d34-0410-b5e6-96231b3b80d8
ee98aa87434d9d49a8e4dab41d873888ac9c4805 07-Jan-2012 Andrew Trick <atrick@apple.com> Extended replaceCongruentPhis to handle mixed phi types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147707 91177308-0d34-0410-b5e6-96231b3b80d8
f8fd841a4bb7a59f81cf4642169e8251e039acfe 07-Jan-2012 Andrew Trick <atrick@apple.com> Expose isNonConstantNegative to users of ScalarEvolution.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147700 91177308-0d34-0410-b5e6-96231b3b80d8
260bf5364e151754c16f723d62c4080009bf98cb 06-Jan-2012 Andrew Trick <atrick@apple.com> Put all IVUsers in the processed set. Allow querying IVUsers with isIVUserOrOperand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147686 91177308-0d34-0410-b5e6-96231b3b80d8
febaf8401779fedf8db7b02e499c5e39848fb9f5 05-Jan-2012 Dan Gohman <gohman@apple.com> Generalize isSafeToSpeculativelyExecute to work on arbitrary
Values, rather than just Instructions, since it's interesting
for ConstantExprs too.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147560 91177308-0d34-0410-b5e6-96231b3b80d8
da69f3b357097e75fbf9a5a2bbe1e7273d4b4271 04-Jan-2012 Benjamin Kramer <benny.kra@googlemail.com> Simplify more DenseMap.find users.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147550 91177308-0d34-0410-b5e6-96231b3b80d8
34b5f0437b9bf67bcbeb166a1c092dbbe3786157 04-Jan-2012 Benjamin Kramer <benny.kra@googlemail.com> Simplify code. No functionality change.

Using DenseMap iterators isn't free as they have to check for empty
buckets. Dominator queries are common so this gives a minor speedup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147544 91177308-0d34-0410-b5e6-96231b3b80d8
3a023d318075639434fdb5e2424d0c2c5edd89e7 29-Dec-2011 Rafael Espindola <rafael.espindola@gmail.com> Fix grammar error noticed by Duncan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147333 91177308-0d34-0410-b5e6-96231b3b80d8
b48a18903a5769f0ecb295db069252576b1388b0 29-Dec-2011 Nick Lewycky <nicholas@mxc.ca> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147327 91177308-0d34-0410-b5e6-96231b3b80d8
25101bb2a799a36be9f077ee2fc2dcf0df2b6efb 20-Dec-2011 Jakub Staszak <kubastaszak@gmail.com> Add some constantness to BranchProbabilityInfo and BlockFrequnencyInfo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146986 91177308-0d34-0410-b5e6-96231b3b80d8
2d24e2a396a1d211baaeedf32148a3b657240170 20-Dec-2011 David Blaikie <dblaikie@gmail.com> Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146960 91177308-0d34-0410-b5e6-96231b3b80d8
34706936412b9e9ff73511fed58e97bf6e100e69 18-Dec-2011 Joerg Sonnenberger <joerg@bec.de> Allow inlining of functions with returns_twice calls, if they have the
attribute themselve.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146851 91177308-0d34-0410-b5e6-96231b3b80d8
f0426601977c3e386d2d26c72a2cca691dc42072 15-Dec-2011 Dan Gohman <gohman@apple.com> Move Instruction::isSafeToSpeculativelyExecute out of VMCore and
into Analysis as a standalone function, since there's no need for
it to be in VMCore. Also, update it to use isKnownNonZero and
other goodies available in Analysis, making it more precise,
enabling more aggressive optimization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146610 91177308-0d34-0410-b5e6-96231b3b80d8
e15402f92b6949d2474cc82648239fe22e5a2209 05-Dec-2011 Anna Zaks <ganna@apple.com> Change the Dominators recalculate() function to only rely on GraphTraits

This is a patch by Guoping Long!

As part of utilizing LLVM Dominator computation in Clang, made two changes to LLVM dominators tree implementation:

- (1) Change the recalculate() template function to only rely on GraphTraits.
- (2) Add a size() method to GraphTraits template class to query the number of nodes in the graph.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145837 91177308-0d34-0410-b5e6-96231b3b80d8
aab8e28d5e470711d80276bbf717408c3ab966fd 02-Dec-2011 Chad Rosier <mcrosier@apple.com> Fix a few more places where TargetData/TargetLibraryInfo is not being passed.
Add FIXMEs to places that are non-trivial to fix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145661 91177308-0d34-0410-b5e6-96231b3b80d8
618c1dbd293d15ee19f61b1156ab8086ad28311a 01-Dec-2011 Chad Rosier <mcrosier@apple.com> Propagate TargetLibraryInfo throughout ConstantFolding.cpp and
InstructionSimplify.cpp. Other fixups as needed.
Part of rdar://10500969

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145559 91177308-0d34-0410-b5e6-96231b3b80d8
553fe05f236f46fe27b7fcfa822b06367d50183e 30-Nov-2011 Andrew Trick <atrick@apple.com> LSR: handle the expansion of phi operands that use postinc forms of the IV.

Fixes PR11431: SCEVExpander::expandAddRecExprLiterally(const llvm::SCEVAddRecExpr*): Assertion `(!isa<Instruction>(Result) || SE.DT->dominates(cast<Instruction>(Result), Builder.GetInsertPoint())) && "postinc expansion does not dominate use"' failed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145482 91177308-0d34-0410-b5e6-96231b3b80d8
ed38f1ca2ede643b058211ec09b205ed30d2a256 28-Nov-2011 Andrew Trick <atrick@apple.com> Remove the temporary flag -disable-unroll-scev and dead code.

SCEV should now be used for trip count analysis, not LoopInfo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145262 91177308-0d34-0410-b5e6-96231b3b80d8
6935b78e6f3b7dca7786041c56c9a795d2247659 21-Nov-2011 Nick Lewycky <nicholas@mxc.ca> Add virtual destructor. Whoops!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145044 91177308-0d34-0410-b5e6-96231b3b80d8
7912ef97ffde3ab3334143ddfb4cafdf04e2ebfc 20-Nov-2011 Nick Lewycky <nicholas@mxc.ca> Less template, more virtual! Refactoring suggested by Chris in code review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145014 91177308-0d34-0410-b5e6-96231b3b80d8
173862e5468fbcf4b022b9088d2c81b25c2d60c5 20-Nov-2011 Nick Lewycky <nicholas@mxc.ca> Refactor code to use new attribute getters on CallSite for NoCapture and ByVal.
Suggested in code review by Eli.

That code in InstCombine looks kinda suspicious.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145013 91177308-0d34-0410-b5e6-96231b3b80d8
ce35d8b5a1071bb8ccf70bf8be3952dd0c4f2f15 18-Nov-2011 Devang Patel <dpatel@apple.com> DISubrange supports unsigned lower/upper array bounds, so let's not fake it in the end while emitting DWARF. If a FE needs to encode signed lower/upper array bounds then we need to extend DISubrange or ad DISignedSubrange.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144937 91177308-0d34-0410-b5e6-96231b3b80d8
2774dc085d36c2097e080e2e0ea46a7e49be37af 15-Nov-2011 Benjamin Kramer <benny.kra@googlemail.com> Missed some users of Value::getNameStr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144656 91177308-0d34-0410-b5e6-96231b3b80d8
a7b0cb759433c715065440ee2a963a04db7f2b0b 15-Nov-2011 Benjamin Kramer <benny.kra@googlemail.com> Remove all remaining uses of Value::getNameStr().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144648 91177308-0d34-0410-b5e6-96231b3b80d8
88990248d3bfb2f265fcf27f8a032ac0eb14d09f 14-Nov-2011 Nick Lewycky <nicholas@mxc.ca> Refactor capture tracking (which already had a couple flags for whether returns
and stores capture) to permit the caller to see each capture point and decide
whether to continue looking.

Use this inside memdep to do an analysis that basicaa won't do. This lets us
solve another devirtualization case, fixing PR8908!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144580 91177308-0d34-0410-b5e6-96231b3b80d8
066b5d8403483bf3a8bb033b690da318fbc68e79 14-Nov-2011 Benjamin Kramer <benny.kra@googlemail.com> Make headers standalone.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144537 91177308-0d34-0410-b5e6-96231b3b80d8
ecfd04b272940374323c2e6e57aff06ff5c4f133 09-Nov-2011 Eric Christopher <echristo@apple.com> Fix typo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144198 91177308-0d34-0410-b5e6-96231b3b80d8
5786b4cdc118a7fbcdae238e264a884691ab43b7 09-Nov-2011 Eli Friedman <eli.friedman@gmail.com> Enhance verifyLoop so that it can reliably verify that every block in a loop is reachable from the loop header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144166 91177308-0d34-0410-b5e6-96231b3b80d8
5cdf0700c72bee5fae5180a3a5fc3747b519758f 04-Nov-2011 Eli Friedman <eli.friedman@gmail.com> Add missing forward declarations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143717 91177308-0d34-0410-b5e6-96231b3b80d8
b39e25ef2c8d8c840ec4155e57c737ac7bd4f167 04-Nov-2011 Eli Friedman <eli.friedman@gmail.com> Delete names for unused parameters in inline function definitions in headers, so LLVM users can compile with -Wunused-parameter. PR11257; based on patch by Kevin Harris.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143715 91177308-0d34-0410-b5e6-96231b3b80d8
dd3149d57977d0632cfaf24290dd93416fb2a0ef 26-Oct-2011 Duncan Sands <baldrick@free.fr> The maximum power of 2 dividing a power of 2 is itself. This occurs
in 403.gcc and was spotted by my super-optimizer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143054 91177308-0d34-0410-b5e6-96231b3b80d8
de1c9bb45017e25b5fc2b77e15d3c377f6572075 24-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Remove return heuristics from the static branch probabilities, and
introduce no-return or unreachable heuristics.

The return heuristics from the Ball and Larus paper don't work well in
practice as they pessimize early return paths. The only good hitrate
return heuristics are those for:
- NULL return
- Constant return
- negative integer return

Only the last of these three can possibly require significant code for
the returning block, and even the last is fairly rare and usually also
a constant. As a consequence, even for the cold return paths, there is
little code on that return path, and so little code density to be gained
by sinking it. The places where sinking these blocks is valuable (inner
loops) will already be weighted appropriately as the edge is a loop-exit

All of this aside, early returns are nearly as common as all three of
these return categories, and should actually be predicted as taken!
Rather than muddy the waters of the static predictions, just remain
silent on returns and let the CFG itself dictate any layout or other

However, the return heuristic was flagging one very important case:
unreachable. Unfortunately it still gave a 1/4 chance of the
branch-to-unreachable occuring. It also didn't do a rigorous job of
finding those blocks which post-dominate an unreachable block.

This patch builds a more powerful analysis that should flag all branches
to blocks known to then reach unreachable. It also has better worst-case
runtime complexity by not looping through successors for each block. The
previous code would perform an N^2 walk in the event of a single entry
block branching to N successors with a switch where each successor falls
through to the next and they finally fall through to a return.

Test case added for noreturn heuristics. Also doxygen comments improved
along the way.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142793 91177308-0d34-0410-b5e6-96231b3b80d8
f46c674a16669518dbb24d4cdd4bfc904dd3b505 24-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Doxygen-ify the comments on the public interface for BPI. Also, move the
two more subtle routines to the bottom and expand on their cautionary
comments a bit. No functionality or actual interface change here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142789 91177308-0d34-0410-b5e6-96231b3b80d8
b068bbbaecf338f481124551a5e6f37484fad800 24-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Simplify the design of BranchProbabilityInfo by collapsing it into
a single class. Previously it was split between two classes, one
internal and one external. The concern seemed to center around exposing
the weights used, but those can remain confined to the implementation

Having a single class to maintain the state and analyses in use will
also simplify several of the enhancements I want to make to our static

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142783 91177308-0d34-0410-b5e6-96231b3b80d8
14edd314af99ccaad194d071f23e437a1371f176 23-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Teach the BranchProbabilityInfo pass to print its results, and use that
to bring it under direct test instead of merely indirectly testing it in
the BlockFrequencyInfo pass.

The next step is to start adding tests for the various heuristics
employed, and to start fixing those heuristics once they're under test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142778 91177308-0d34-0410-b5e6-96231b3b80d8
6aa5c26c81071e22a23a6f0ae7dcac6080ad6597 19-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Add pass printing support to BlockFrequencyInfo pass. The implementation
layer already had support for printing the results of this analysis, but
the wiring was missing.

Now that printing the analysis works, actually bring some of this
analysis, and the BranchProbabilityInfo analysis that it wraps, under
test! I'm planning on fixing some bugs and doing other work here, so
having a nice place to add regression tests and a way to observe the
results is really useful.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142491 91177308-0d34-0410-b5e6-96231b3b80d8
2115cd2a48feaf956b0906f7fcfdee8baf4795dd 19-Oct-2011 Eric Christopher <echristo@apple.com> Whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142438 91177308-0d34-0410-b5e6-96231b3b80d8
56169787dbfb6d0b422ef114889b481e977b8996 15-Oct-2011 Nick Lewycky <nicholas@mxc.ca> Fix extra whitespace in comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142079 91177308-0d34-0410-b5e6-96231b3b80d8
365c9f1ff55bef134c6b9707f7df44d680ddabea 15-Oct-2011 Andrew Trick <atrick@apple.com> Fix SCEVExpander assert during LSR: "argument of incompatible type".

Just because we're dealing with a GEP doesn't mean we can assert the
SCEV has a pointer type. The fix is simply to ignore the SCEV pointer
type, which we really didn't need.
Fixes PR11138 webkit crash.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142058 91177308-0d34-0410-b5e6-96231b3b80d8
b414142036012dd9432c4e8c5fef09d4d49fcc22 14-Oct-2011 Eli Friedman <eli.friedman@gmail.com> Enhance the memdep interface so that users can tell the difference between a dependency which cannot be calculated and a path reaching the entry point of the function. This patch introduces isNonFuncLocal, which replaces isUnknown in some cases.

Patch by Xiaoyi Guo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141896 91177308-0d34-0410-b5e6-96231b3b80d8
d0851aae5133b138ee3f87277d0b7775994bea46 12-Oct-2011 Eric Christopher <echristo@apple.com> Make this use a public accessor too.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141752 91177308-0d34-0410-b5e6-96231b3b80d8
3c43b48fa96664318f0c1c17475114fe7015add6 12-Oct-2011 Eric Christopher <echristo@apple.com> Use public accessors on the scope that is returned.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141739 91177308-0d34-0410-b5e6-96231b3b80d8
6618a241f7ba2571a1a55b3733c4441d467baf42 12-Oct-2011 Eric Christopher <echristo@apple.com> Add a new wrapper node for a DILexicalBlock that encapsulates it and a
file. Since it should only be used when necessary propagate it through
the backend code generation and tweak testcases accordingly.

This helps with code like in clang's test/CodeGen/debug-info-line.c where
we have multiple #line directives within a single lexical block and want
to generate only a single block that contains each file change.

Part of rdar://10246360

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141729 91177308-0d34-0410-b5e6-96231b3b80d8
204494149b6f846e8f173f525b129f5508076049 11-Oct-2011 Andrew Trick <atrick@apple.com> Move replaceCongruentIVs into SCEVExapander and bias toward "expanded"

Indvars previously chose randomly between congruent IVs. Now it will
bias the decision toward IVs that SCEVExpander likes to create. This
was not done to fix any problem, it's just a welcome side effect of
factoring code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141633 91177308-0d34-0410-b5e6-96231b3b80d8
c5701910604cdf65811fabd31d41e38f1d1d4eb1 08-Oct-2011 Andrew Trick <atrick@apple.com> LSR should only reuse phis that match its formula.

Fixes rdar://problem/5064068

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141442 91177308-0d34-0410-b5e6-96231b3b80d8
e97728ecf8a0ee69562cc0e7880cfaa65200c624 04-Oct-2011 Nick Lewycky <nicholas@mxc.ca> The product of two chrec's can always be represented as a chrec.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141066 91177308-0d34-0410-b5e6-96231b3b80d8
b2ab2fa524f3f90376639037bd81924483cca0af 01-Oct-2011 Andrew Trick <atrick@apple.com> Inlining and unrolling heuristics should be aware of free truncs.

We want heuristics to be based on accurate data, but more importantly
we don't want llvm to behave randomly. A benign trunc inserted by an
upstream pass should not cause a wild swings in optimization
level. See PR11034. It's a general problem with threshold-based
heuristics, but we can make it less bad.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140919 91177308-0d34-0410-b5e6-96231b3b80d8
5c655413cf9466c29e38204ab3f19b33fffd7996 01-Oct-2011 Andrew Trick <atrick@apple.com> whitespace

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140916 91177308-0d34-0410-b5e6-96231b3b80d8
46cb5afdcd031c371c78201fb34291d9d48b2ee4 26-Sep-2011 Eli Friedman <eli.friedman@gmail.com> Enhance alias analysis for atomic instructions a bit. Upgrade a couple alias-analysis tests to the new atomic instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140557 91177308-0d34-0410-b5e6-96231b3b80d8
439780eeaef1a2c6a1105fb705a27c5c819e8d0e 26-Sep-2011 James Molloy <james.molloy@arm.com> Fix emission of debug data for global variables. getContext() on DIGlobalVariables is not valid any more.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140539 91177308-0d34-0410-b5e6-96231b3b80d8
734a67cda5a02be1654a2f89b811d7b6cbe3f5e5 15-Sep-2011 Devang Patel <dpatel@apple.com> Add support to emit debug info for C++0x nullptr type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139751 91177308-0d34-0410-b5e6-96231b3b80d8
dabc2806726a286b00313419fac8461ebe0f774c 05-Sep-2011 Duncan Sands <baldrick@free.fr> Add some simple insertvalue simplifications, for the purpose of cleaning
up do-nothing exception handling code produced by dragonegg.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139113 91177308-0d34-0410-b5e6-96231b3b80d8
252ef7a61a9455c1e5d7b8a5a5f7ec8b3a75e200 02-Sep-2011 Andrew Trick <atrick@apple.com> Comment and clarifying assert.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139036 91177308-0d34-0410-b5e6-96231b3b80d8
0e122d1c2422285c872f68fc0ae1f7e5d2739572 29-Aug-2011 Andrew Trick <atrick@apple.com> Reapply r138695. Fix PassManager stack depths.

Patch by Xiaoyi Guo!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138737 91177308-0d34-0410-b5e6-96231b3b80d8
8592a0cda4cf4ae76c5a29230fb330d0e952bb62 27-Aug-2011 Andrew Trick <atrick@apple.com> Reverting r138695 to see if it fixes clang self host.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138701 91177308-0d34-0410-b5e6-96231b3b80d8
b84619223051fd965cc64e70c8f6b70f7ae6ae85 27-Aug-2011 Andrew Trick <atrick@apple.com> Fix PassManager stack depths.

Patch by Xiaoyi Guo!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138695 91177308-0d34-0410-b5e6-96231b3b80d8
5434c1e73b6e56756719d2aebb952ac7bb3829e0 26-Aug-2011 Andrew Trick <atrick@apple.com> LoopInfo::updateUnloop fix, and verify Block->Loop maps.

Fixes an oversight, and adds verification to catch it in the unloop.ll tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138622 91177308-0d34-0410-b5e6-96231b3b80d8
93d39be5300702d8c9892ec04a492a6056926462 20-Aug-2011 Devang Patel <dpatel@apple.com> Do not use named md nodes to track variables that are completely optimized. This does not scale while doing LTO with debug info. New approach is to include list of variables in the subprogram info directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138145 91177308-0d34-0410-b5e6-96231b3b80d8
94c7ddb6f52a5200983fed0ce74dc602a7737879 17-Aug-2011 Devang Patel <dpatel@apple.com> Until now all debug info MDNodes referred to a root MDNode, a compile unit. This simplified handling of these needs in dwarf writer. However, one side effect of this is that during link time optimization all these MDNodes are _not_ uniqued. In other words there will be N number of MDNodes describing "int", "char" and all other types, which would suddenly grow when each object file starts using libraries like STL.

MDNodes graph structure such that compiler unit keeps track of important MDNodes and update dwarf writer to process mdnodes top-down instead of bottom up.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137778 91177308-0d34-0410-b5e6-96231b3b80d8
6326a4238df05dafd7547cfa2cd71111cd6702a6 16-Aug-2011 Devang Patel <dpatel@apple.com> Add a finalize() hook, that'll let DIBuilder construct compile unit lazily.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137673 91177308-0d34-0410-b5e6-96231b3b80d8
6f9d8ffe5e47e3d11176298e849cc8545c2169a2 15-Aug-2011 Devang Patel <dpatel@apple.com> Refactor. Global variables are part of compile unit so let CompileUnit create new global variable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137621 91177308-0d34-0410-b5e6-96231b3b80d8
b1831c66403315a1d84593b7c198ddbd43a574cf 12-Aug-2011 Andrew Trick <atrick@apple.com> Allow loop unrolling to get known trip counts from ScalarEvolution.

SCEV unrolling can unroll loops with arbitrary induction variables. It
is a prerequisite for -disable-iv-rewrite performance. It is also
easily handles loops of arbitrary structure including multiple exits
and is generally more robust.

This is under a temporary option to avoid affecting default
behavior for the next couple of weeks. It is needed so that I can
checkin unit tests for updateUnloop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137384 91177308-0d34-0410-b5e6-96231b3b80d8
fb62b8deb3c837bc5f4cf98543b89d08e7db9f84 11-Aug-2011 Andrew Trick <atrick@apple.com> Reapplying r136844.

An algorithm for incrementally updating LoopInfo within a
LoopPassManager. The incremental update should be extremely cheap in
most cases and can be used in places where it's not feasible to
regenerate the entire loop forest.

- "Unloop" is a node in the loop tree whose last backedge has been removed.
- Perform reverse dataflow on the block inside Unloop to propagate the
nearest loop from the block's successors.
- For reducible CFG, each block in unloop is visited exactly
once. This is because unloop no longer has a backedge and blocks
within subloops don't change parents.
- Immediate subloops are summarized by the nearest loop reachable from
their exits or exits within nested subloops.
- At completion the unloop blocks each have a new parent loop, and
each immediate subloop has a new parent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137276 91177308-0d34-0410-b5e6-96231b3b80d8
d8a2f3ab91e90a1e1da2061410bb08b18650c9ee 11-Aug-2011 Andrew Trick <atrick@apple.com> Cleanup. Remove an extraneous GraphTraits specialization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137264 91177308-0d34-0410-b5e6-96231b3b80d8
b549bcfe6c19dbb24162c75bbcc06d4a5fa90cb8 10-Aug-2011 Devang Patel <dpatel@apple.com> Distinguish between two copies of one inlined variable. Take 2.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137253 91177308-0d34-0410-b5e6-96231b3b80d8
4b4bb71bcdfd8c17cd4acb6116fc9a56c5fecd47 10-Aug-2011 Andrew Trick <atrick@apple.com> Added a SimplifyIndVar utility to simplify induction variable users
based on ScalarEvolution without changing the induction variable phis.

This utility is the main tool of IndVarSimplifyPass, but the pass also
restructures induction variables in strange ways that are sensitive to
pass ordering. This provides a way for other loop passes to simplify
new uses of induction variables created during transformation. The
utility may be used by any pass that preserves ScalarEvolution. Soon
LoopUnroll will use it.

The net effect in this checkin is to cleanup the IndVarSimplify pass
by factoring out the SimplifyIndVar algorithm into a standalone utility.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137197 91177308-0d34-0410-b5e6-96231b3b80d8
2d31ae3d9dfb153f081a5521374b2b42befd50a1 10-Aug-2011 Andrew Trick <atrick@apple.com> Cleanup. Added LoopBlocksDFS::perform for simple clients.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137195 91177308-0d34-0410-b5e6-96231b3b80d8
306afdf443a0e2d5d89c1a3ece00cfe18be1c4c4 10-Aug-2011 Andrew Trick <atrick@apple.com> Cleanup. Avoid relying on specialization of std::distance.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137191 91177308-0d34-0410-b5e6-96231b3b80d8
b1eede12818d91a32adac928c6fffcf6d2800dc0 10-Aug-2011 Andrew Trick <atrick@apple.com> Fix the LoopUnroller to handle nontrivial loops and partial unrolling.

These are not individual bug fixes. I had to rewrite a good chunk of
the unroller to make it sane. I think it was getting lucky on trivial
completely unrolled loops with no early exits. I included some fairly
simple unit tests for partial unrolling. I didn't do much stress
testing, so it may not be perfect, but should be usable now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137190 91177308-0d34-0410-b5e6-96231b3b80d8
48d726fbce7a70a2f5d7752c883731efe1e5e1c9 09-Aug-2011 Devang Patel <dpatel@apple.com> Provide method to print variable's extended name which includes inline location.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137095 91177308-0d34-0410-b5e6-96231b3b80d8
4147f39769d404cab02da4beea852ad2600dadbb 05-Aug-2011 Chandler Carruth <chandlerc@gmail.com> Temporarily revert r135528 which distinguishes between two copies of one
inlined variable, based on the discussion in PR10542.

This explodes the runtime of several passes down the pipeline due to
a large number of "copies" remaining live across a large function. This
only shows up with both debug and opt, but when it does it creates
a many-minute compile when self-hosting LLVM+Clang. There are several
other cases that show these types of regressions.

All of this is tracked in PR10542, and progress is being made on fixing
the issue. Once its addressed, the re-instated, but until then this
restores the performance for self-hosting and other opt+debug builds.

Devang, let me know if this causes any trouble, or impedes fixing it in
any way, and thanks for working on this!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136953 91177308-0d34-0410-b5e6-96231b3b80d8
0712108d22d5fdc5ea447ef701d843b25bd52d10 04-Aug-2011 Andrew Trick <atrick@apple.com> Reverting r136884 updateUnloop, which crashed a linux builder.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136857 91177308-0d34-0410-b5e6-96231b3b80d8
762797d1af1b9308c79982aedd9bd2f585f46171 04-Aug-2011 Andrew Trick <atrick@apple.com> An algorithm for incrementally updating LoopInfo within a
LoopPassManager. The incremental update should be extremely cheap in
most cases and can be used in places where it's not feasible to
regenerate the entire loop forest.

- "Unloop" is a node in the loop tree whose last backedge has been removed.
- Perform reverse dataflow on the block inside Unloop to propagate the
nearest loop from the block's successors.
- For reducible CFG, each block in unloop is visited exactly
once. This is because unloop no longer has a backedge and blocks
within subloops don't change parents.
- Immediate subloops are summarized by the nearest loop reachable from
their exits or exits within nested subloops.
- At completion the unloop blocks each have a new parent loop, and
each immediate subloop has a new parent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136844 91177308-0d34-0410-b5e6-96231b3b80d8
fbfb806e3fe697fd8ee2a59f8fd3e0790ccf0d3c 04-Aug-2011 Andrew Trick <atrick@apple.com> whitespace

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136840 91177308-0d34-0410-b5e6-96231b3b80d8
5207936a24ab9e0bfaa10e798625df65143e3716 04-Aug-2011 Andrew Trick <atrick@apple.com> An interface for iterating over a loop's blocks in DFS order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136838 91177308-0d34-0410-b5e6-96231b3b80d8
8ea45231dc6c30d0c4a55ce038a08edccc308a73 03-Aug-2011 Jakub Staszak <jstaszak@apple.com> Add more constantness in BlockFrequencyInfo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136816 91177308-0d34-0410-b5e6-96231b3b80d8
1009c3299be8c147ecd3fbd2d75ba1bafb2c84b1 03-Aug-2011 Andrew Trick <atrick@apple.com> SCEV: Use AssertingVH to catch dangling BasicBlock* when passes forget
to notify SCEV of a change. Add forgetLoop in a couple of those places.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136797 91177308-0d34-0410-b5e6-96231b3b80d8
fcb4356dee96563def584fe38eeafb3eb63c5cd8 02-Aug-2011 Andrew Trick <atrick@apple.com> Use consistent terminology for loop exit/exiting blocks. Name change only.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136677 91177308-0d34-0410-b5e6-96231b3b80d8
e2481ff8ee722e25d1e3aa192b276f9b5be5b177 01-Aug-2011 Jakub Staszak <jstaszak@apple.com> Add BlockFrequency::getEntryFrequency()

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136618 91177308-0d34-0410-b5e6-96231b3b80d8
6f6baf1bdd7531da5ddb925ffcfcf38724e9e4aa 29-Jul-2011 Jakub Staszak <jstaszak@apple.com> Add more constantness in BranchProbabilityInfo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136502 91177308-0d34-0410-b5e6-96231b3b80d8
55ba816883842e793cdeb32fcb805c4e011b527f 29-Jul-2011 Eli Friedman <eli.friedman@gmail.com> Misc optimizer+codegen work for 'cmpxchg' and 'atomicrmw'. They appear to be
working on x86 (at least for trivial testcases); other architectures will
need more work so that they actually emit the appropriate instructions for
orderings stricter than 'monotonic'. (As far as I can tell, the ARM, PPC,
Mips, and Alpha backends need such changes.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136457 91177308-0d34-0410-b5e6-96231b3b80d8
7f1cce55b5da7ef53269426e3c64586177384dca 28-Jul-2011 Jakub Staszak <jstaszak@apple.com> If run with -debug give more information about Cyclic Probability.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136403 91177308-0d34-0410-b5e6-96231b3b80d8
af7a46d5a6fa1e6dac1d83f38ba9823bea3870b6 28-Jul-2011 Jakub Staszak <jstaszak@apple.com> Fix stupid mistake from commit 136381.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136384 91177308-0d34-0410-b5e6-96231b3b80d8
2f9427c6a3ce9badd04b00de778ab6af3c3c88d6 28-Jul-2011 Jakub Staszak <jstaszak@apple.com> Speed up BlockFrequencyInfo a little bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136381 91177308-0d34-0410-b5e6-96231b3b80d8
9a24f1f070f7a9e18f7fc46214c2f2d0a38ab0f9 28-Jul-2011 Jakub Staszak <jstaszak@apple.com> Use BlockFrequency instead of uint32_t in BlockFrequencyInfo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136278 91177308-0d34-0410-b5e6-96231b3b80d8
9d9f76551977e57dc765f691be6411bc3edd0361 27-Jul-2011 Jakub Staszak <jstaszak@apple.com> Edge to itself is backedge as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136219 91177308-0d34-0410-b5e6-96231b3b80d8
8a552bb85a5e9a6c250c0a899941fbd3ae7b5006 27-Jul-2011 Eli Friedman <eli.friedman@gmail.com> Misc mid-level changes for new 'fence' instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136205 91177308-0d34-0410-b5e6-96231b3b80d8
6f3ba37ebb06de206c74d73c7c2b422cca28a16d 27-Jul-2011 Eli Friedman <eli.friedman@gmail.com> Fix AliasSetTracker so that it doesn't make any assumptions about instructions it doesn't know about (like the atomic instructions I'm adding).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136198 91177308-0d34-0410-b5e6-96231b3b80d8
5116ff671f45d48594d11360e22991a7edb13862 26-Jul-2011 Andrew Trick <atrick@apple.com> SCEV: Added a data structure for storing not-taken info per loop
exit. Added an interfaces for querying either the loop's exact/max
backedge taken count or a specific loop exit's not-taken count.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136100 91177308-0d34-0410-b5e6-96231b3b80d8
f55c1c85881afd65647bde5346f64d9685235c7c 25-Jul-2011 Jakub Staszak <jstaszak@apple.com> Rename BlockFrequency to BlockFrequencyInfo and MachineBlockFrequency to

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135937 91177308-0d34-0410-b5e6-96231b3b80d8
23f34f1c22db8df6e767a29365d668ac9ede112c 22-Jul-2011 Jakub Staszak <jstaszak@apple.com> Allow getBlockFreq to return 0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135742 91177308-0d34-0410-b5e6-96231b3b80d8
40c7e4142e2327a540eceb640392a6da4ccfb3bf 21-Jul-2011 Devang Patel <dpatel@apple.com> There are two ways to map a variable to its lexical scope. Lexical scope information is embedded in MDNode describing the variable. It is also available as a part of DebugLoc attached with DBG_VALUE instruction. DebugLoc attached with an instruction is less reliable in optimized code so use information embedded in the MDNode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135629 91177308-0d34-0410-b5e6-96231b3b80d8
c8fcfc9cd9c0940e8afdaba8b815f8f489b457ba 20-Jul-2011 Devang Patel <dpatel@apple.com> Distinguish between two copies of one inlined variable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135528 91177308-0d34-0410-b5e6-96231b3b80d8
23336b449eee301f4c4dcabbd75dedf3c75c30fc 19-Jul-2011 Devang Patel <dpatel@apple.com> Reapply r135457. This needs llvm-gcc change, that I forgot to check-in yesterday.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135504 91177308-0d34-0410-b5e6-96231b3b80d8
f51bb7cef8b0aa25506308c2ec0fcde58e1dc7ed 19-Jul-2011 Bob Wilson <bob.wilson@apple.com> Revert "Make a provision to encode inline location in a variable. This will enable dwarf writer to easily distinguish between two instances of a inlined variable in one basic block."

This reverts commit 9fec5e346efdf744b151ae6604f912908315fa7a.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135486 91177308-0d34-0410-b5e6-96231b3b80d8
b9b54ebfed02f0654897d37e8a4448d3f8087558 19-Jul-2011 Jay Foad <jay.foad@gmail.com> Convert SimplifyGEPInst to use ArrayRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135482 91177308-0d34-0410-b5e6-96231b3b80d8
1d2f569c3428d70d0cf690c9adb459ad4a3ecff2 19-Jul-2011 Jay Foad <jay.foad@gmail.com> Use ArrayRef in ConstantFoldInstOperands and ConstantFoldCall.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135477 91177308-0d34-0410-b5e6-96231b3b80d8
9fec5e346efdf744b151ae6604f912908315fa7a 19-Jul-2011 Devang Patel <dpatel@apple.com> Make a provision to encode inline location in a variable. This will enable dwarf writer to easily distinguish between two instances of a inlined variable in one basic block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135457 91177308-0d34-0410-b5e6-96231b3b80d8
db125cfaf57cc83e7dd7453de2d509bc8efd0e5e 18-Jul-2011 Chris Lattner <sabre@nondot.org> land David Blaikie's patch to de-constify Type, with a few tweaks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
12af93ae86cb4a517d1b67f9363fbf21f24f583b 16-Jul-2011 Jakub Staszak <jstaszak@apple.com> Remove "LoopInfo.h" include from BranchProbabilityInfo.h.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135353 91177308-0d34-0410-b5e6-96231b3b80d8
59a9dab4d8650d3408efa431907183e13b91867b 16-Jul-2011 Jakub Staszak <jstaszak@apple.com> Add MachineBlockFrequency analysis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135352 91177308-0d34-0410-b5e6-96231b3b80d8
d152d03a476b8d0d4b26577db26e2ba76034b0f3 16-Jul-2011 Andrew Trick <atrick@apple.com> Fix SCEVEXpander to handle arbitrary phi expansion. Includes two
related bug fixes and corresponding assertions for uninitialized data
and missing NULL check. Test cases will be included with the new LFTR.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135333 91177308-0d34-0410-b5e6-96231b3b80d8
fc6d3a49867cd38954dc40936a88f1907252c6d2 13-Jul-2011 Jay Foad <jay.foad@gmail.com> Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135040 91177308-0d34-0410-b5e6-96231b3b80d8
6d64a04a4d1c2f4f6f8877cc0811a4d4386e518f 28-Jun-2011 Andrew Trick <atrick@apple.com> Cleanup. Fix a stupid variable name.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133996 91177308-0d34-0410-b5e6-96231b3b80d8
5e7645be4c9dd2193add44d30b5fef8036d7a3ce 28-Jun-2011 Andrew Trick <atrick@apple.com> SCEVExpander: give new insts a name that identifies the reponsible pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133992 91177308-0d34-0410-b5e6-96231b3b80d8
99e0b2a8df7e3a49c0e1edd250d17604fe2fb21c 27-Jun-2011 Nick Lewycky <nicholas@mxc.ca> Move onlyUsedByLifetimeMarkers to ValueTracking so that it can be used by other
passes as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133904 91177308-0d34-0410-b5e6-96231b3b80d8
fa3f9c001fe771af7dfcd7663b9d5dc345649d43 25-Jun-2011 Devang Patel <dpatel@apple.com> Fix struct member's scope. Patch by Xi Wang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133828 91177308-0d34-0410-b5e6-96231b3b80d8
66dddd1da3e036d05f94df82221a97b7d26e3498 24-Jun-2011 Jakub Staszak <jstaszak@apple.com> Calculate backedge probability correctly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133776 91177308-0d34-0410-b5e6-96231b3b80d8
fd9533b4a35983d38804349efca8116788b311d9 23-Jun-2011 Jakub Staszak <jstaszak@apple.com> Missing files for the BlockFrequency analysis added.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133767 91177308-0d34-0410-b5e6-96231b3b80d8
44eb49c2a191108df801977c8e3dc03466c6c02a 23-Jun-2011 Jakub Staszak <jstaszak@apple.com> Introduce BlockFrequency analysis for BasicBlocks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133766 91177308-0d34-0410-b5e6-96231b3b80d8
4417e537b65c14b378aeca75b2773582dd102f63 21-Jun-2011 Andrew Trick <atrick@apple.com> IVUsers no longer needs to record the phis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133518 91177308-0d34-0410-b5e6-96231b3b80d8
7cc2b07437a1243c33324549a1904fefc5f1845e 16-Jun-2011 Jakub Staszak <jstaszak@apple.com> Introduce MachineBranchProbabilityInfo class, which has similar API to
BranchProbabilityInfo (expect setEdgeWeight which is not available here).
Branch Weights are kept in MachineBasicBlocks. To turn off this analysis
set -use-mbpi=false.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133184 91177308-0d34-0410-b5e6-96231b3b80d8
9fbd318d36e618fb08fb53bb48b7c848e617a8a7 16-Jun-2011 John McCall <rjmccall@apple.com> The ARC language-specific optimizer. Credit to Dan Gohman.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133108 91177308-0d34-0410-b5e6-96231b3b80d8
a990e071f2f29ba326b97a4288207a2c406c5b66 15-Jun-2011 Eli Friedman <eli.friedman@gmail.com> Add "unknown" results for memdep, which mean "I don't know whether a dependence for the given instruction exists in the given block". This cleans up all the existing hacks in memdep which represent this concept by returning clobber with various unrelated instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133031 91177308-0d34-0410-b5e6-96231b3b80d8
f289df2d9544bd3a0934651daa20e589544413ba 11-Jun-2011 Andrew Trick <atrick@apple.com> Branch profiling: floating-point avoidance.

Patch by: Jakub Staszak!

Introduces BranchProbability. Changes unsigned to uint32_t all over and
uint64_t only when overflow is expected.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132867 91177308-0d34-0410-b5e6-96231b3b80d8
e669d83a21d7ebf01d3c9e37a20c7348b5a77c11 09-Jun-2011 John McCall <rjmccall@apple.com> Teach the CallGraph to ignore calls to intrinsics.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132797 91177308-0d34-0410-b5e6-96231b3b80d8
9e76422b963a65f243fdbee0abed61068b82dd98 04-Jun-2011 Andrew Trick <atrick@apple.com> New BranchProbabilityInfo analysis. Patch by Jakub Staszak!

BranchProbabilityInfo provides an interface for IR passes to query the
likelihood that control follows a CFG edge. This patch provides an
initial implementation of static branch predication that will populate
BranchProbabilityInfo for branches with no external profile
information using very simple heuristics. It currently isn't hooked up
to any external profile data, so static prediction does all the work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132613 91177308-0d34-0410-b5e6-96231b3b80d8
1fc18d71deb0e23a9101c87bb7b1455098ce1c09 04-Jun-2011 Dan Gohman <gohman@apple.com> Fix BasicAA's recursion detection so that it doesn't pessimize
queries in the case of a DAG, where a query reaches a node
visited earlier, but it's not on a cycle. This avoids
MayAlias results in cases where BasicAA is expected to
return MustAlias or PartialAlias in order to protect TBAA.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132609 91177308-0d34-0410-b5e6-96231b3b80d8
da174c1d3b1fa31d7c5c47a645c66d600b4b7bd8 03-Jun-2011 Devang Patel <dpatel@apple.com> A typedef's context is not the same as type's context. It is the context of typedef decl itself. Use extra parameter to communicate this to DIBuilder.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132556 91177308-0d34-0410-b5e6-96231b3b80d8
f85092c25525f75eef6982ffa40c9b48b87da987 20-May-2011 Andrew Trick <atrick@apple.com> indvars: Prototyping Sign/ZeroExtend elimination without canonical IVs.

No functionality enabled by default. Use -disable-iv-rewrite.
Extended IVUsers to keep track of the phi that represents the users' IV.
Added the WidenIV transform to replace a narrow IV with a wide IV
by doing a one-for-one replacement of IV users instead of expanding the
SCEV expressions. [sz]exts are removed and truncs are inserted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131744 91177308-0d34-0410-b5e6-96231b3b80d8
eea6c95d5d9f202ccb4e90995dc8a4a4c439cec3 13-May-2011 Julien Lerouge <jlerouge@apple.com> Fix a source of non determinism in FindUsedTypes, use a SetVector instead of a


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131283 91177308-0d34-0410-b5e6-96231b3b80d8
201e6cdc39d5dca4e70cdd331f6f5055b3af3534 12-May-2011 Devang Patel <dpatel@apple.com> Doug convinced me that DW_AT_APPLE_objc_complete_type is more appropriate name.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131244 91177308-0d34-0410-b5e6-96231b3b80d8
b11f80e94b590c90d07254dfa2406cf504e09cd3 12-May-2011 Devang Patel <dpatel@apple.com> Let Objective-C front-end identify class extension, in dwarf output, using an attribute DW_AT_APPLE_objc_class_extension.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131238 91177308-0d34-0410-b5e6-96231b3b80d8
77a2c4c1e54b7e3c4815b276eb6a2d99a7621460 09-May-2011 Dan Gohman <gohman@apple.com> Change a few std::maps to DenseMaps.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131088 91177308-0d34-0410-b5e6-96231b3b80d8
f262e161612eb44b7bb3dd2008950be3e77b57dd 05-May-2011 Hongbin Zheng <etherzhhb@gmail.com> Minor change: Fix the typo in RegionPass.h and RegionPass.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130920 91177308-0d34-0410-b5e6-96231b3b80d8
194cfb08ffe5d1c6f457b8fd1d688540a29dfc75 02-May-2011 Duncan Sands <baldrick@free.fr> Forgot to commit the changes to this file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130695 91177308-0d34-0410-b5e6-96231b3b80d8
4034e14985af013f71f7884fa275415a3be27778 28-Apr-2011 Chris Lattner <sabre@nondot.org> teach GVN to widen integer loads when they are overaligned, when doing an
wider load would allow elimination of subsequent loads, and when the wider
load is still a native integer type. This eliminates a ton of loads on
various benchmarks involving struct fields, though it is somewhat hobbled
by clang not being very aggressive about field alignment.

This is yet another step along the way towards resolving PR6627.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130390 91177308-0d34-0410-b5e6-96231b3b80d8
7b5bd3724193b3a48e342301c1644a01a9e72f31 26-Apr-2011 Devang Patel <dpatel@apple.com> Fix an off by one error while accessing complex address element of a DIVariable.
This worked untill now because stars are aligned (i.e. num of complex address elments are always 0 or 2+ and when it is 2+ at least two elements are access together)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130225 91177308-0d34-0410-b5e6-96231b3b80d8
1f821512fc1441480b3355305e0da5267073fe1c 26-Apr-2011 Chris Lattner <sabre@nondot.org> Enhance MemDep: When alias analysis returns a partial alias result,
return it as a clobber. This allows GVN to do smart things.

Enhance GVN to be smart about the case when a small load is clobbered
by a larger overlapping load. In this case, forward the value. This
allows us to compile stuff like this:

int test(void *P) {
int tmp = *(unsigned int*)P;
return tmp+*((unsigned char*)P+1);


_test: ## @test
movl (%rdi), %ecx
movzbl %ch, %eax
addl %ecx, %eax

which has one load. We already handled the case where the smaller
load was from a must-aliased base pointer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130180 91177308-0d34-0410-b5e6-96231b3b80d8
685501836bc60f53892854253b5bbea6c48b6d7f 24-Apr-2011 Jay Foad <jay.foad@gmail.com> PR9214: Convert the DIBuilder API to use ArrayRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130086 91177308-0d34-0410-b5e6-96231b3b80d8
ddcdcc88631c6bd4ad43d9198b98bc9a829be036 23-Apr-2011 Jay Foad <jay.foad@gmail.com> Remove unused STL header includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130068 91177308-0d34-0410-b5e6-96231b3b80d8
5e06bb83f4d7b1b86659ad851324350afb04f5b0 23-Apr-2011 Devang Patel <dpatel@apple.com> Let front-end tie subprogram declaration with subprogram definition directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130028 91177308-0d34-0410-b5e6-96231b3b80d8
e9db5e29e3af91eec572bfeb8dcec908213298b0 16-Apr-2011 Devang Patel <dpatel@apple.com> Introduce support to encode Objective-C property information in debugging information generated for an interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129624 91177308-0d34-0410-b5e6-96231b3b80d8
7a2bdde0a0eebcd2125055e0eacaca040f0b766c 15-Apr-2011 Chris Lattner <sabre@nondot.org> Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129558 91177308-0d34-0410-b5e6-96231b3b80d8
562b84b3aea359d1f918184e355da82bf05eb290 11-Apr-2011 Jay Foad <jay.foad@gmail.com> Don't include Operator.h from InstrTypes.h.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129271 91177308-0d34-0410-b5e6-96231b3b80d8
9055ccdb6b33607e32ac83a8e9289fba44d1989a 09-Apr-2011 Eli Friedman <eli.friedman@gmail.com> PR9604; try to deal with RAUW updates correctly in the AST. I'm not convinced
it's completely safe to cache the AST across LICM runs even with this fix,
but this fix can't hurt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129198 91177308-0d34-0410-b5e6-96231b3b80d8
c9049a9ea8993e64b58c206fed6609a1415519f2 09-Apr-2011 Chris Lattner <sabre@nondot.org> fix a potentially serious bug in AliasSet::removeCallSite
where we shrunk the list without updating the end iterator.
By inspection, from PR9639.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129190 91177308-0d34-0410-b5e6-96231b3b80d8
da19475328ece3da19437a2e9eef035dcafa2814 06-Apr-2011 Devang Patel <dpatel@apple.com> Add support to encode function's template parameters.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128947 91177308-0d34-0410-b5e6-96231b3b80d8
1a8b9dd7fb945ab78232f3853219cc693bcb5fad 05-Apr-2011 Chris Lattner <sabre@nondot.org> remove postdom frontiers, because it is dead. Forward dom frontiers are
still used by RegionInfo :(

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128943 91177308-0d34-0410-b5e6-96231b3b80d8
cc5d992bc167ded99b039ed8fdde190a586a1562 04-Apr-2011 Tobias Grosser <grosser@fim.uni-passau.de> Region: Allow user control the printing style of the print function.

Contributed by: etherzhhb@gmail.com

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128808 91177308-0d34-0410-b5e6-96231b3b80d8
0d4b81519dc3f02bbebb4ecad86bfb590c4d1898 24-Mar-2011 Jay Foad <jay.foad@gmail.com> Fix typo in comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128216 91177308-0d34-0410-b5e6-96231b3b80d8
5fd5b125ff41088c005b7107e8cf92f281313040 18-Mar-2011 Andrew Trick <atrick@apple.com> Avoid creating canonical induction variables for non-native types.
For example, on 32-bit architecture, don't promote all uses of the IV
to 64-bits just because one use is a 64-bit cast.
Alternate implementation of the patch by Arnaud de Grandmaison.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127884 91177308-0d34-0410-b5e6-96231b3b80d8
b12a754cce0c1d5542af605203a47820edba454d 18-Mar-2011 Andrew Trick <atrick@apple.com> Added isValidRewrite() to check the result of ScalarEvolutionExpander.

SCEV may generate expressions composed of multiple pointers, which can
lead to invalid GEP expansion. Until we can teach SCEV to follow strict
pointer rules, make sure no bad GEPs creep into IR.
Fixes rdar://problem/9038671.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127839 91177308-0d34-0410-b5e6-96231b3b80d8
3228cc259b5ca00e46af36da369a451f5736cbf4 14-Mar-2011 Andrew Trick <atrick@apple.com> Added SCEV::NoWrapFlags to manage unsigned, signed, and self wrap
Added the self-wrap flag for SCEV::AddRecExpr.
A slew of temporary FIXMEs indicate the intention of the no-self-wrap flag
without changing behavior in this revision.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127590 91177308-0d34-0410-b5e6-96231b3b80d8
291bb70d9348f8e80ec53a4c17c0464c0c8441bf 02-Mar-2011 Duncan Sands <baldrick@free.fr> Remove DIFactory. Patch by Devang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126871 91177308-0d34-0410-b5e6-96231b3b80d8
e9e16c5f52c4a093f4de234d448cdebedab8938e 01-Mar-2011 Devang Patel <dpatel@apple.com> Today, the language front ends produces llvm.dbg.* intrinsics, used to encode arguments' debug info, in order any way, most of the times. However, if a front end mix-n-matches llvm.dbg.declare and llvm.dbg.value intrinsics to encode debug info for arguments then code generator needs a way to find argument order.

Use 8 bits from line number field to keep track of argument ordering while encoding debug info for an argument. That leaves 24 bit for line no, DebugLoc also allocates 24 bit for line numbers. If a function has more than 255 arguments then rest of the arguments will be ordered by llvm.dbg.* intrinsics' ordering in IR.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126793 91177308-0d34-0410-b5e6-96231b3b80d8
c92383fd0d5ec4aea4745e04071fa61d1b24230a 28-Feb-2011 Dan Gohman <gohman@apple.com> Delete the LiveValues pass. I won't get get back to the project it
was started for in the foreseeable future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126668 91177308-0d34-0410-b5e6-96231b3b80d8
50d280c14ee1c25fc8e6cb6f59af44f754edce42 22-Feb-2011 Devang Patel <dpatel@apple.com> Follow LLVM coding style.
clang uses DBuilder, so it requries corresponding change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126231 91177308-0d34-0410-b5e6-96231b3b80d8
dc8c3fdcf15a6fff6251a63869de718527c91940 19-Feb-2011 Devang Patel <dpatel@apple.com> Provide enums to build complex address calucation expressions.
(This is infact direct copy from DIFactory, which is disappearing soon.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125989 91177308-0d34-0410-b5e6-96231b3b80d8
fc0569e55aade16aac6668b4fadbbdcaeb6f2537 15-Feb-2011 Devang Patel <dpatel@apple.com> Move DbgInfoPrinter specific utlities inside DbgInfoPrinter.cpp

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125571 91177308-0d34-0410-b5e6-96231b3b80d8
81a0dc911586c77421c2255aa417dc9b350b9e20 09-Feb-2011 Chris Lattner <sabre@nondot.org> Teach instsimplify some tricks about exact/nuw/nsw shifts.
improve interfaces to instsimplify to take this info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125196 91177308-0d34-0410-b5e6-96231b3b80d8
4e8af6db184118638c21f713ad98e3292c6891c9 05-Feb-2011 Eric Christopher <echristo@apple.com> Rewrite how the indirect call bonus is handled. This now works by:

a) Making it a per call site bonus for functions that we can move from
indirect to direct calls.
b) Reduces the bonus from 500 to 100 per call site.
c) Subtracts the size of the possible newly inlineable call from the
bonus to only add a bonus if we can inline a small function to devirtualize

Also changes the bonus from a positive that's subtracted to a negative
that's added.

Fixes the remainder of rdar://8546196 by reducing the object file size
after inlining by 84%.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124916 91177308-0d34-0410-b5e6-96231b3b80d8
e7d93877c6e7029d27bfd1c137fceb472f81f390 02-Feb-2011 Devang Patel <dpatel@apple.com> Add support to describe template value parameter in debug info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124755 91177308-0d34-0410-b5e6-96231b3b80d8
7e2cb116556e1153401cd6b94d0f51db978f6902 02-Feb-2011 Devang Patel <dpatel@apple.com> Add support to describe template parameter type in debug info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124752 91177308-0d34-0410-b5e6-96231b3b80d8
8e2da0ce9d70606e10889d17f481842586132d88 01-Feb-2011 Eric Christopher <echristo@apple.com> Reapply 124275 since the Dragonegg failure was unreproducible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124641 91177308-0d34-0410-b5e6-96231b3b80d8
b476302b24f5fe89f8f68f616a3d234fc4b5ab25 29-Jan-2011 Bill Wendling <isanbard@gmail.com> This is #included by .c files. Remove C++-style comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124552 91177308-0d34-0410-b5e6-96231b3b80d8
1fca2c32cc99197215d3fd32a4ad05214c74edd1 29-Jan-2011 Frits van Bommel <fvbommel@gmail.com> Move InstCombine's knowledge of fdiv to SimplifyInstruction().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124534 91177308-0d34-0410-b5e6-96231b3b80d8
04317cc618aeae28910916469e074d8ce0fcaa03 29-Jan-2011 Andrew Trick <atrick@apple.com> Implementation of path profiling.
Modified patch by Adam Preuss.

This builds on the existing framework for block tracing, edge profiling and optimal edge profiling.
See -help-hidden for new flags.
For documentation, see the technical report "Implementation of Path Profiling..." in llvm.org/pubs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124515 91177308-0d34-0410-b5e6-96231b3b80d8
593faa53fa6d89841e601cc4571d143a6a05f0b4 28-Jan-2011 Duncan Sands <baldrick@free.fr> My auto-simplifier noticed that ((X/Y)*Y)/Y occurs several times in SPEC
benchmarks, and that it can be simplified to X/Y. (In general you can only
simplify (Z*Y)/Y to Z if the multiplication did not overflow; if Z has the
form "X/Y" then this is the case). This patch implements that transform and
moves some Div logic out of instcombine and into InstructionSimplify.
Unfortunately instcombine gets in the way somewhat, since it likes to change
(X/Y)*Y into X-(X rem Y), so I had to teach instcombine about this too.
Finally, thanks to the NSW/NUW flags, sometimes we know directly that "Z*Y"
does not overflow, because the flag says so, so I added that logic too. This
eliminates a bunch of divisions and subtractions in 447.dealII, and has good
effects on some other benchmarks too. It seems to have quite an effect on
tramp3d-v4 but it's hard to say if it's good or bad because inlining decisions
changed, resulting in massive changes all over.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124487 91177308-0d34-0410-b5e6-96231b3b80d8
eabde0cf0798e36934ffd03b071f2bd490ac1f11 26-Jan-2011 Eric Christopher <echristo@apple.com> Temporarily revert 124275 to see if it brings the dragonegg buildbot back.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124312 91177308-0d34-0410-b5e6-96231b3b80d8
5d83955b8c2bdca28d0a0c62a9d0f9bbd5a6d668 26-Jan-2011 Eric Christopher <echristo@apple.com> Separate out the constant bonus from the size reduction metrics. Rework
a few loops accordingly. Should be no functional change.

This is a step for more accurate cost/benefit analysis of devirt/inlining

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124275 91177308-0d34-0410-b5e6-96231b3b80d8
d70d1a5c44609af091f6fc3e29193f9f4756a74f 25-Jan-2011 Duncan Sands <baldrick@free.fr> According to my auto-simplifier the most common missed simplifications in
optimized code are:
(non-negative number)+(power-of-two) != 0 -> true
(x | 1) != 0 -> true
Instcombine knows about the second one of course, but only does it if X|1
has only one use. These fire thousands of times in the testsuite.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124183 91177308-0d34-0410-b5e6-96231b3b80d8
0f13bc8c23f93b5c84a71d60a8dff0142a769224 24-Jan-2011 Eric Christopher <echristo@apple.com> Perhaps a bit too much vertical whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124148 91177308-0d34-0410-b5e6-96231b3b80d8
bd1801b5553c8be3960255a92738464e0010b6f6 24-Jan-2011 Dan Gohman <gohman@apple.com> Give GetUnderlyingObject a TargetData, to keep it in sync
with BasicAA's DecomposeGEPExpression, which recently began
using a TargetData. This fixes PR8968, though the testcase
is awkward to reduce.

Also, update several off GetUnderlyingObject's users
which happen to have a TargetData handy to pass it in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124134 91177308-0d34-0410-b5e6-96231b3b80d8
55be644df6e8b8ba08ae789ee440c798f21974a0 23-Jan-2011 Cameron Zwarich <zwarich@apple.com> Convert a std::vector to a SmallVector for another 5.4% speedup on domtree.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124065 91177308-0d34-0410-b5e6-96231b3b80d8
54cdad97eb77caf841ade5827a1d5da6b2d89df3 23-Jan-2011 Cameron Zwarich <zwarich@apple.com> In the simpler version of the link-eval data structure that we use in dominator
computation, the Ancestor field is always set to the Parent, so we can remove
the explicit link entirely and merge the Parent and Ancestor fields. Instead of
checking for whether an ancestor exists for a node or not, we simply check
whether the node has already been processed. This is simpler if Compress is
inlined into Eval, so I did that as well.

This is about a 3% speedup running -domtree on test-suite + SPEC2000 & SPEC2006,
but it also opens up some opportunities for further improvement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124061 91177308-0d34-0410-b5e6-96231b3b80d8
11e222da1fe498a3c528d197ab57982e3bb5762d 23-Jan-2011 Cameron Zwarich <zwarich@apple.com> Remove useless struct fields.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124058 91177308-0d34-0410-b5e6-96231b3b80d8
53e069ffab9ab055f20b5aa9ad54fecaa2612192 23-Jan-2011 Cameron Zwarich <zwarich@apple.com> Remove friend declaration for removed function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124057 91177308-0d34-0410-b5e6-96231b3b80d8
907b56ce7ab26222fa128d5062f8dddf11c81603 23-Jan-2011 Cameron Zwarich <zwarich@apple.com> Convert a std::vector to a SmallVector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124055 91177308-0d34-0410-b5e6-96231b3b80d8
5c96c69161aa4480c432027e363d0ea1aa34acee 23-Jan-2011 Cameron Zwarich <zwarich@apple.com> Simplify some code now that we've removed the more optimal (but slower) version
of the link-eval data structure from dominator computation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124053 91177308-0d34-0410-b5e6-96231b3b80d8
5d2cf40c40d8c2763a0e5b53481063becdce6e30 18-Jan-2011 Cameron Zwarich <zwarich@apple.com> There is no point in verifying an analysis that is never updated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123743 91177308-0d34-0410-b5e6-96231b3b80d8
72d1695f12b29dddac431f18e2592a8eeaf3796a 18-Jan-2011 Cameron Zwarich <zwarich@apple.com> Remove some now-unused DominanceFrontier methods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123726 91177308-0d34-0410-b5e6-96231b3b80d8
0092b1142f5d35d204f35ec3cfe19d8de082400f 16-Jan-2011 Chris Lattner <sabre@nondot.org> remove the partial specialization pass. It is unmaintained and has bugs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123554 91177308-0d34-0410-b5e6-96231b3b80d8
c43cee3fbb3098f0647e50dd2c13bc55b027a228 14-Jan-2011 Duncan Sands <baldrick@free.fr> Move some shift transforms out of instcombine and into InstructionSimplify.
While there, I noticed that the transform "undef >>a X -> undef" was wrong.
For example if X is 2 then the top two bits must be equal, so the result can
not be anything. I fixed this in the constant folder as well. Also, I made
the transform for "X << undef" stronger: it now folds to undef always, even
though X might be zero. This is in accordance with the LangRef, but I must
admit that it is fairly aggressive. Also, I added "i32 X << 32 -> undef"
following the LangRef and the constant folder, likewise fairly aggressive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123417 91177308-0d34-0410-b5e6-96231b3b80d8
21d842c35326281798f685661b88dedcd09c13aa 14-Jan-2011 Tobias Grosser <grosser@fim.uni-passau.de> Add single entry / single exit accessors.

Add methods for accessing the (single) entry / exit edge of a region. If no such
edge exists, null is returned. Both accessors return the start block of the
corresponding edge. The edge can finally be formed by utilizing
Region::getEntry() or Region::getExit();

Contributed by: Andreas Simbuerger <simbuerg@fim.uni-passau.de>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123410 91177308-0d34-0410-b5e6-96231b3b80d8
113328db1b6c71d6bb8f62ebef193efb1a44f1a4 11-Jan-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Put the Dominator improvements back in. They were not the cause of bootstrap miscomparisons.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123273 91177308-0d34-0410-b5e6-96231b3b80d8
cbf39b58919497f711de24fa687b044805f58ae7 11-Jan-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Speculatively revert the recent improvements to Dominators.h in an attempt to track down the gcc bootstrap miscompare.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123254 91177308-0d34-0410-b5e6-96231b3b80d8
6038a6351e7a9601a1eb3ffe4623c424ae2c80a4 11-Jan-2011 Chris Lattner <sabre@nondot.org> some comment improvements.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123243 91177308-0d34-0410-b5e6-96231b3b80d8
992efb03785f2a368fbb63b09373be1d6a96ce5a 09-Jan-2011 Chris Lattner <sabre@nondot.org> Step #2 to improve trip count analysis for loops like this:

void f(int* begin, int* end) { std::fill(begin, end, 0); }

which turns into a != exit expression where one pointer is
strided and (thanks to step #1) known to not overflow, and
the other is loop invariant.

The observation here is that, though the IV is strided by
4 in this case, that the IV *has* to become equal to the
end value. It cannot "miss" the end value by stepping over
it, because if it did, the strided IV expression would
eventually wrap around.

Handle this by turning A != B into "A-B != 0" where the A-B
part is known to be NUW.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123131 91177308-0d34-0410-b5e6-96231b3b80d8
3a723ab344d9835506ed2b52a2ccd75078670fc7 09-Jan-2011 Tobias Grosser <grosser@fim.uni-passau.de> DominatorTree->print() now prints the status of the DFSNumbers correctly

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123120 91177308-0d34-0410-b5e6-96231b3b80d8
2feee6454d4c9cbb3a104b0f593d31a91a14d15a 08-Jan-2011 Chris Lattner <sabre@nondot.org> fit in 80 cols

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123085 91177308-0d34-0410-b5e6-96231b3b80d8
c3942eb95d10fac62c6b5227f344bcda3f578077 08-Jan-2011 Chris Lattner <sabre@nondot.org> make this file properly self contained.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123059 91177308-0d34-0410-b5e6-96231b3b80d8
ab6acc6ecdc4585a55059e36d81481d1c26d3ff9 03-Jan-2011 Owen Anderson <resistor@mac.com> Stub out a new updating interface to AliasAnalysis, allowing stateful analyses to be informed when
a pointer value has potentially become escaping. Implementations can choose to either fall back to
conservative responses for that value, or may recompute their analysis to accomodate the change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122777 91177308-0d34-0410-b5e6-96231b3b80d8
9ad1cb59deda265441c1614fee5ec7f7dea7625d 03-Jan-2011 Nick Lewycky <nicholas@mxc.ca> Add spliceFunction to the CallGraph interface. This allows users to efficiently
update a callGraph when performing the common operation of splicing the body to
a new function and updating all callers (such as via RAUW).

No users yet, though this is intended for DeadArgumentElimination as part of

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122728 91177308-0d34-0410-b5e6-96231b3b80d8
9fc5cdf77c812aaa80419036de27576d45894d0d 02-Jan-2011 Chris Lattner <sabre@nondot.org> split dom frontier handling stuff out to its own DominanceFrontier header,
so that Dominators.h is *just* domtree. Also prune #includes a bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122714 91177308-0d34-0410-b5e6-96231b3b80d8
86a582ddfb32816e8f0c3068e0765a1e3a364b50 02-Jan-2011 Cameron Zwarich <zwarich@apple.com> Remove an unused member function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122693 91177308-0d34-0410-b5e6-96231b3b80d8
94942cec11ba3dc2592d1195324d2315a58d7711 02-Jan-2011 Cameron Zwarich <zwarich@apple.com> Fix a typo in a variable name.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122691 91177308-0d34-0410-b5e6-96231b3b80d8
63e07d72f8175cd2d74f0693edf1b0429580d64d 02-Jan-2011 Cameron Zwarich <zwarich@apple.com> Move a load into the only branch where it is used and eliminate a temporary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122690 91177308-0d34-0410-b5e6-96231b3b80d8
2a8c22aa6824143fdf4c00d4486c65eca26f6c9f 02-Jan-2011 Cameron Zwarich <zwarich@apple.com> Add the explanatory comment from r122680's commit message to the code itself.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122689 91177308-0d34-0410-b5e6-96231b3b80d8
19feb4ca8a804aeda650cb1f700a89c2f2324b77 02-Jan-2011 Cameron Zwarich <zwarich@apple.com> Tidy up indentation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122688 91177308-0d34-0410-b5e6-96231b3b80d8
a4d93162cbb95423a9c8f35e38747c08aa8a3516 02-Jan-2011 Cameron Zwarich <zwarich@apple.com> Fix a typo, which should also fix the failure on llvm-x86_64-linux-checks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122687 91177308-0d34-0410-b5e6-96231b3b80d8
c9e152b778715afc5cdfdb98cb0e98757ed827d8 02-Jan-2011 Cameron Zwarich <zwarich@apple.com> Remove the #ifdef'd code for balancing the eval-link data structure. It doesn't
compile, and everyone's tests have shown it to be slower in practice, even for
quite large graphs.

I also hope to do an optimization that is only correct with the simpler data
structure, which would break this even further.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122684 91177308-0d34-0410-b5e6-96231b3b80d8
8252ad1351594039fa5d6633ff3eef1bafb7fdf9 02-Jan-2011 Cameron Zwarich <zwarich@apple.com> Speed up dominator computation some more by optimizing bucket processing. When
naively implemented, the Lengauer-Tarjan algorithm requires a separate bucket
for each vertex. However, this is unnecessary, because each vertex is only
placed into a single bucket (that of its semidominator), and each vertex's
bucket is processed before it is added to any bucket itself.

Instead of using a bucket per vertex, we use a single array Buckets that has two
purposes. Before the vertex V with DFS number i is processed, Buckets[i] stores
the index of the first element in V's bucket. After V's bucket is processed,
Buckets[i] stores the index of the next element in the bucket to which V now
belongs, if any.

Reading from the buckets can also be optimized. Instead of processing the bucket
of V's parent at the end of processing V, we process the bucket of V itself at
the beginning of processing V. This means that the case of the root vertex can
be simplified somewhat. It also means that we don't need to look up the DFS
number of the semidominator of every node in the bucket we are processing,
since we know it is the current index being processed.

This is a 6.5% speedup running -domtree on test-suite + SPEC2000/2006, with
larger speedups of around 12% on the larger benchmarks like GCC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122680 91177308-0d34-0410-b5e6-96231b3b80d8
19f14dcf6af11b5520acfc5c2fd4100ec1972b44 28-Dec-2010 Duncan Sands <baldrick@free.fr> Clarify that InstructionSimplify only returns values that dominate the
original instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122601 91177308-0d34-0410-b5e6-96231b3b80d8
9bc6a90146417af03144fa2f7dd94f9945b57c06 28-Dec-2010 Duncan Sands <baldrick@free.fr> Small optimization to speed up replacementPreservesLCSSAForm.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122600 91177308-0d34-0410-b5e6-96231b3b80d8
a92ff91a967c63a2395a34c9e8331a7d50d6ab10 27-Dec-2010 Chris Lattner <sabre@nondot.org> implement enough of the memset inference algorithm to recognize and insert
memsets. This is still missing one important validity check, but this is enough
to compile stuff like this:

void test0(std::vector<char> &X) {
for (std::vector<char>::iterator I = X.begin(), E = X.end(); I != E; ++I)
*I = 0;

void test1(std::vector<int> &X) {
for (long i = 0, e = X.size(); i != e; ++i)
X[i] = 0x01010101;

$ clang t.cpp -S -o - -O2 -emit-llvm | opt -loop-idiom | opt -O3 | llc


__Z5test0RSt6vectorIcSaIcEE: ## @_Z5test0RSt6vectorIcSaIcEE
## BB#0: ## %entry
subq $8, %rsp
movq (%rdi), %rax
movq 8(%rdi), %rsi
cmpq %rsi, %rax
je LBB0_2
## BB#1: ## %bb.nph
subq %rax, %rsi
movq %rax, %rdi
callq ___bzero
LBB0_2: ## %for.end
addq $8, %rsp
__Z5test1RSt6vectorIiSaIiEE: ## @_Z5test1RSt6vectorIiSaIiEE
## BB#0: ## %entry
subq $8, %rsp
movq (%rdi), %rax
movq 8(%rdi), %rdx
subq %rax, %rdx
cmpq $4, %rdx
jb LBB1_2
## BB#1: ## %for.body.preheader
andq $-4, %rdx
movl $1, %esi
movq %rax, %rdi
callq _memset
LBB1_2: ## %for.end
addq $8, %rsp

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122573 91177308-0d34-0410-b5e6-96231b3b80d8
bb89710dddf967199dfc56e8bf5d28b0003f2ee6 26-Dec-2010 Chris Lattner <sabre@nondot.org> move isBytewiseValue out to ValueTracking.h/cpp

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122565 91177308-0d34-0410-b5e6-96231b3b80d8
df3ee64d791624bf28ac3e6820bf8fdd17f1bff1 22-Dec-2010 Dan Gohman <gohman@apple.com> Constify.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122447 91177308-0d34-0410-b5e6-96231b3b80d8
82fdab335881cd90f8f7ab3ad1f1ca0bb3ee886a 21-Dec-2010 Duncan Sands <baldrick@free.fr> Pull a few more simplifications out of instcombine (there are still
plenty left though!), in particular for multiplication.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122330 91177308-0d34-0410-b5e6-96231b3b80d8
5034dd318a9dfa0dc45a3ac01e58e60f2aa2498d 15-Dec-2010 Dan Gohman <gohman@apple.com> Move Value::getUnderlyingObject to be a standalone
function so that it can live in Analysis instead of

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121885 91177308-0d34-0410-b5e6-96231b3b80d8
fea3b218d61708ea3577f4ef14c8f7677a94db95 15-Dec-2010 Duncan Sands <baldrick@free.fr> Move Sub simplifications and additional Add simplifications out of
instcombine and into InstructionSimplify.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121861 91177308-0d34-0410-b5e6-96231b3b80d8
4a34cbd2b9ba9efcdab4c4e656df2d7bd22e2604 10-Dec-2010 Dan Gohman <gohman@apple.com> Introduce a new PartialAlias response for AliasAnalysis. For most
AliasAnalysis consumers, PartialAlias will be treated as MayAlias.

For AliasAnalysis chaining, MayAlias says "procede to the next analysis".
PartialAlias will be used to indicate that the query should terminate,
even though it didn't reach MustAlias or NoAlias.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121507 91177308-0d34-0410-b5e6-96231b3b80d8
44498a640daa827220bc4758770190318f0ec69f 08-Dec-2010 Devang Patel <dpatel@apple.com> Add support to create debug info for functions and methods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121281 91177308-0d34-0410-b5e6-96231b3b80d8
0a2551de2c61b372d45b236b413a5d2e15225c0f 08-Dec-2010 Devang Patel <dpatel@apple.com> Add support to create class type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121279 91177308-0d34-0410-b5e6-96231b3b80d8
43c249cf1e417083ec8cbdfb4866a42861a7f638 08-Dec-2010 Devang Patel <dpatel@apple.com> Add support to create vector, array, enums etc...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121224 91177308-0d34-0410-b5e6-96231b3b80d8
94541efd9238ee0ab615d22dcd6182199490ae61 08-Dec-2010 Devang Patel <dpatel@apple.com> Global variable does not need linkage name.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121212 91177308-0d34-0410-b5e6-96231b3b80d8
48f17ba2a611d197082d4de730b646a4ecf68df4 08-Dec-2010 Devang Patel <dpatel@apple.com> Add support to create local variable's debug info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121211 91177308-0d34-0410-b5e6-96231b3b80d8
fe58f95f3604b394916bee7bd289e1f0e0488ec5 08-Dec-2010 Devang Patel <dpatel@apple.com> Add support to create variables, structs etc.. using DIBuilder.
This is still work in progress.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121205 91177308-0d34-0410-b5e6-96231b3b80d8
cc10244d7725f191bdc91cd62befff0c97257c7b 06-Dec-2010 Chris Lattner <sabre@nondot.org> Fix PR8728, a miscompilation I recently introduced. When optimizing
memcpy's like:
memcpy(A, B)
memcpy(A, C)

we cannot delete the first memcpy as dead if A and C might be aliases.
If so, we actually get:

memcpy(A, B)
memcpy(A, A)

which is not correct to transform into:

memcpy(A, A)

This patch was heavily influenced by Jakub Staszak's patch in PR8728, thanks

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120974 91177308-0d34-0410-b5e6-96231b3b80d8
72c194a8be83d217360ebc6b1f3ad21c5ffa16a9 06-Dec-2010 Chris Lattner <sabre@nondot.org> add a helper method.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120973 91177308-0d34-0410-b5e6-96231b3b80d8
a04096580a65b6cfbe12dabf6d695f7303750c0d 01-Dec-2010 Chris Lattner <sabre@nondot.org> teach DSE to use GetPointerBaseWithConstantOffset to analyze
may-aliasing stores that partially overlap with different base
pointers. This implements PR6043 and the non-variable part of

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120485 91177308-0d34-0410-b5e6-96231b3b80d8
ed58a6f96f605901adc0df3ca76499d52b2d1a1a 30-Nov-2010 Chris Lattner <sabre@nondot.org> move GetPointerBaseWithConstantOffset out of GVN into ValueTracking.h

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120476 91177308-0d34-0410-b5e6-96231b3b80d8
72851059224b90a3ae74ecd62fbd927a0c54a9f0 30-Nov-2010 Cameron Zwarich <zwarich@apple.com> Change the basic block map in LoopInfo from a std::map to a DenseMap. This is a 16% speedup running loops on test-suite + SPEC2000.

Reviewed by Eric Christopher.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120440 91177308-0d34-0410-b5e6-96231b3b80d8
cf82dc376a11acb1b5d46d56c032bb0b9326c682 30-Nov-2010 Chris Lattner <sabre@nondot.org> Rewrite the main DSE loop to be written in terms of reasoning
about pairs of AA::Location's instead of looking for MemDep's
"Def" predicate. This is more powerful and general, handling
memset/memcpy/store all uniformly, and implementing PR8701 and
probably obsoleting parts of memcpyoptimizer.

This also fixes an obscure bug with init.trampoline and i8
stores, but I'm not surprised it hasn't been hit yet. Enhancing
init.trampoline to carry the size that it stores would allow
DSE to be much more aggressive about optimizing them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120406 91177308-0d34-0410-b5e6-96231b3b80d8
c413330c99a573ef3ffe80a46400b1d3eca2398d 30-Nov-2010 Chris Lattner <sabre@nondot.org> death to extraneous \n's.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120405 91177308-0d34-0410-b5e6-96231b3b80d8
9dc9e81aa7412b329bbaf51a589a81475214802b 30-Nov-2010 Chris Lattner <sabre@nondot.org> getLocationForDest should work for memset as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120380 91177308-0d34-0410-b5e6-96231b3b80d8
1ab4285b721a412692e96a493ef4f2b9223902f9 30-Nov-2010 Chris Lattner <sabre@nondot.org> clean up handling of 'free', detangling it from everything else.
It can be seriously improved, but at least now it isn't intertwined
with the other logic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120377 91177308-0d34-0410-b5e6-96231b3b80d8
1f6efa3996dd1929fbc129203ce5009b620e6969 29-Nov-2010 Michael J. Spencer <bigcheesegs@gmail.com> Merge System into Support.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120298 91177308-0d34-0410-b5e6-96231b3b80d8
4cd2ad15b43f21d641330b4b09961af08646445e 23-Nov-2010 Duncan Sands <baldrick@free.fr> Expand a little on the description of what InstructionSimplify does.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120016 91177308-0d34-0410-b5e6-96231b3b80d8
b9b369fa9983843c4ed77b3a35b6e9b7933955bb 23-Nov-2010 Duncan Sands <baldrick@free.fr> Clarify that constant folding of instructions applies when all operands
are constant. There was in fact one exception to this (phi nodes) - so
remove that exception (InstructionSimplify handles this so there should
be no loss).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120015 91177308-0d34-0410-b5e6-96231b3b80d8
2974b6ffbcffcd7fb02958c7382edf45e4a30f14 23-Nov-2010 Cameron Zwarich <zwarich@apple.com> Optimize a common case in the Lengauer-Tarjan dominators algorithm. This gives a
9.7% speedup running domtree on test-suite.

Reviewed by Chris Lattner.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120003 91177308-0d34-0410-b5e6-96231b3b80d8
16f7993e0df4bd0727f8535bd47a2776bec10545 21-Nov-2010 Chris Lattner <sabre@nondot.org> the getLocationForSource/Dest methods can be static.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119929 91177308-0d34-0410-b5e6-96231b3b80d8
e90c5cb747631b315350e7ee7424048c7778bdf9 21-Nov-2010 Chris Lattner <sabre@nondot.org> add "getLocation" method to AliasAnalysis for getting the source and
destination location of a memcpy/memmove. I'm not clear about whether
TBAA works on these, so I'm leaving it out for now. Dan, please revisit
this when convenient.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119928 91177308-0d34-0410-b5e6-96231b3b80d8
f6f1f062cc8029aa75ca7d0e99fbc1e0b453d07e 21-Nov-2010 Chris Lattner <sabre@nondot.org> implement PR8576, deleting dead stores with intervening may-alias stores.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119927 91177308-0d34-0410-b5e6-96231b3b80d8
3b0aed19f0f9ed62362c04f7e18e2ada686f4055 19-Nov-2010 Duncan Sands <baldrick@free.fr> Simplify, no functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119797 91177308-0d34-0410-b5e6-96231b3b80d8
d0c6f3dafd7c3e9137d4e6415014c94137fcd3fc 18-Nov-2010 Duncan Sands <baldrick@free.fr> Factor code for testing whether replacing one value with another
preserves LCSSA form out of ScalarEvolution and into the LoopInfo
class. Use it to check that SimplifyInstruction simplifications
are not breaking LCSSA form. Fixes PR8622.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119727 91177308-0d34-0410-b5e6-96231b3b80d8
a6d60ddbbb0c33690f7e89cad2b5e60cee84b89e 18-Nov-2010 Dan Gohman <gohman@apple.com> Document the units for the Size field.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119711 91177308-0d34-0410-b5e6-96231b3b80d8
9c9fcfc719158a46cb2e41b66d7dc1a63cd48d74 18-Nov-2010 Dan Gohman <gohman@apple.com> Introduce memoization for ScalarEvolution dominates and properlyDominates
queries, and SCEVExpander getRelevantLoop queries.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119595 91177308-0d34-0410-b5e6-96231b3b80d8
56a756821842678a96f2baa8c6a53bd28fc2b69e 18-Nov-2010 Dan Gohman <gohman@apple.com> Factor out the code for purging a SCEV from all the various memoization maps.
Some of these maps may merge in the future, but for now it's convenient to have
a utility function for them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119587 91177308-0d34-0410-b5e6-96231b3b80d8
714b5290b04e08570dae4304c1c92d30c06d3c99 18-Nov-2010 Dan Gohman <gohman@apple.com> Merge the implementations of isLoopInvariant and hasComputableLoopEvolution, and
memoize the results. This improves compile time in code which highly complex
expressions which get queried many times.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119584 91177308-0d34-0410-b5e6-96231b3b80d8
4ce32db913beb6ae27df2fa0a9db5d68fd4889d2 17-Nov-2010 Dan Gohman <gohman@apple.com> Make SCEV::getType() and SCEV::print non-virtual. Move SCEV::hasOperand
to ScalarEvolution. Delete SCEV::~SCEV. SCEV is no longer virtual.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119578 91177308-0d34-0410-b5e6-96231b3b80d8
dc0e8fb9f9512622f55f73e1a434caa5c0915694 17-Nov-2010 Dan Gohman <gohman@apple.com> Move SCEV::dominates and properlyDominates to ScalarEvolution.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119570 91177308-0d34-0410-b5e6-96231b3b80d8
17ead4ff4baceb2c5503f233d0288d363ae44165 17-Nov-2010 Dan Gohman <gohman@apple.com> Move SCEV::isLoopInvariant and hasComputableLoopEvolution to be member
functions of ScalarEvolution, in preparation for memoization and
other optimizations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119562 91177308-0d34-0410-b5e6-96231b3b80d8
203a7239ae928568fe7a34c03ead4b1b3133870e 17-Nov-2010 Dan Gohman <gohman@apple.com> Verify SCEVAddRecExpr's invariant in ScalarEvolution::getAddRecExpr
instead of in SCEVAddRecExpr's constructor, in preparation for an
upcoming change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119554 91177308-0d34-0410-b5e6-96231b3b80d8
7c0fd8eb724a7228a6cf7e3e5487614c25202a91 17-Nov-2010 Dan Gohman <gohman@apple.com> Fix ScalarEvolution's range memoization to avoid using a
default ctor with ConstantRange.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119550 91177308-0d34-0410-b5e6-96231b3b80d8
2b749870d0488c3b049edf5d0c8875f56f5b1bed 17-Nov-2010 Duncan Sands <baldrick@free.fr> Move some those Xor simplifications which don't require creating new
instructions out of InstCombine and into InstructionSimplify. While
there, introduce an m_AllOnes pattern to simplify matching with integers
and vectors with all bits equal to one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119536 91177308-0d34-0410-b5e6-96231b3b80d8
d261dc650a01ac5c51ab10f97f1e35aa6a770721 17-Nov-2010 Duncan Sands <baldrick@free.fr> Previously SimplifyInstruction could report that an instruction
simplified to itself (this can only happen in unreachable blocks).
Change it to return null instead. Hopefully this will fix some
buildbot failures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119490 91177308-0d34-0410-b5e6-96231b3b80d8
6678e7b6eb534b43b92105076e6d0553e5cf7def 17-Nov-2010 Dan Gohman <gohman@apple.com> Memoize results from ScalarEvolution's getUnsignedRange and getSignedRange.
This fixes some extreme compile times on unrolled sha512 code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119455 91177308-0d34-0410-b5e6-96231b3b80d8
1845009290e4d804ad377927bd8a08cca3036adc 16-Nov-2010 Duncan Sands <baldrick@free.fr> In which I discover the existence of loops. Threading an operation
over a phi node by applying it to each operand may be wrong if the
operation and the phi node are mutually interdependent (the testcase
has a simple example of this). So only do this transform if it would
be correct to perform the operation in each predecessor of the block
containing the phi, i.e. if the other operands all dominate the phi.
This should fix the FFMPEG snow.c regression reported by İsmail Dönmez.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119347 91177308-0d34-0410-b5e6-96231b3b80d8
eff0581583ef10e2872e9baf537a04b67d992101 14-Nov-2010 Duncan Sands <baldrick@free.fr> If dom tree information is available, make it possible to pass
it to get better phi node simplification.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119055 91177308-0d34-0410-b5e6-96231b3b80d8
12a86f5b3199e72e6d967781acc76340f5920e46 14-Nov-2010 Duncan Sands <baldrick@free.fr> Strip trailing whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119038 91177308-0d34-0410-b5e6-96231b3b80d8
6d8eb156e6be727570b300bac7712f745a318c7d 11-Nov-2010 Dan Gohman <gohman@apple.com> Add helper functions for computing the Location of load, store,
and vaarg instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118845 91177308-0d34-0410-b5e6-96231b3b80d8
8e78cc4e130a8773cc8a2be2a94c4a97317ac383 11-Nov-2010 Dan Gohman <gohman@apple.com> Add comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118799 91177308-0d34-0410-b5e6-96231b3b80d8
17e8078ae14ed71f657d59c77efa3bedf171161a 11-Nov-2010 Dan Gohman <gohman@apple.com> Add brief doxygen comments for AliasResult enum values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118792 91177308-0d34-0410-b5e6-96231b3b80d8
ec9b4ac914e91791c580148cf8068c82d4b2cb91 11-Nov-2010 Dan Gohman <gohman@apple.com> Set NonLocalDepInfo's Size field to UnknownSize when invalidating
it, so that it doesn't appear to be a known size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118748 91177308-0d34-0410-b5e6-96231b3b80d8
62367045a493f9bffa433e34b68fc7dda96e1edd 10-Nov-2010 Devang Patel <dpatel@apple.com> Take care of special characters while creating named MDNode name to hold function specific local variable's info.
This fixes radar 8653152. I am checking in testcase as a separate check-in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118726 91177308-0d34-0410-b5e6-96231b3b80d8
075fb5d68fcb55d26e44c48f07dfdbbfa21ccb2a 10-Nov-2010 Dan Gohman <gohman@apple.com> Enhance GVN to do more precise alias queries for non-local memory
references. For example, this allows gvn to eliminate the load in
this example:

void foo(int n, int* p, int *q) {
p[0] = 0;
p[1] = 1;
if (n) {
*q = p[0];

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118714 91177308-0d34-0410-b5e6-96231b3b80d8
e88ccb545d0e03fd4445d361100fc95f350c6663 10-Nov-2010 Dan Gohman <gohman@apple.com> Rename AccessesArguments and AccessesArgumentsReadonly, and rewrite
their comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118696 91177308-0d34-0410-b5e6-96231b3b80d8
b395e4a0262c36b17b18aa33514b2daf2a85e9a3 10-Nov-2010 Dan Gohman <gohman@apple.com> Fix a copy+pasto Duncan noticed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118693 91177308-0d34-0410-b5e6-96231b3b80d8
68a6056dafd4913ce42606353ab1ff7208215ff2 10-Nov-2010 Dan Gohman <gohman@apple.com> Add a doesAccessArgPointees helper function, and update code to use
it, and to be consistent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118692 91177308-0d34-0410-b5e6-96231b3b80d8
432d08cbdb9ceaa333f1d6eab4f8b542fdddf9db 10-Nov-2010 Dan Gohman <gohman@apple.com> Factor out the code for testing whether a function accesses
arbitrary memory into a helper function, and adjust some comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118687 91177308-0d34-0410-b5e6-96231b3b80d8
50bcaece670fea4c936c6730fab9f4d869d2ec67 10-Nov-2010 Dan Gohman <gohman@apple.com> Give NonLocalDepResult a NonLocalDepEntry member, replacing
indivudal members holding the same data, to clarify the relationship
between NonLocalDepResult and NonLocalDepEntry.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118686 91177308-0d34-0410-b5e6-96231b3b80d8
42c31a70735e55bf82e66a9315c97d1821c9a798 10-Nov-2010 Dan Gohman <gohman@apple.com> Make ModRefBehavior a lattice. Use this to clean up AliasAnalysis
chaining and simplify FunctionAttrs' GetModRefBehavior logic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118660 91177308-0d34-0410-b5e6-96231b3b80d8
50a04d067f8803d52cababdabe5c188844c5c210 09-Nov-2010 Dan Gohman <gohman@apple.com> Convert comments to doxygen syntax.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118628 91177308-0d34-0410-b5e6-96231b3b80d8
4a53f37a1af2eb68a8153ba7c14321f41653a7a6 09-Nov-2010 Dan Gohman <gohman@apple.com> AccessesArgumentsReadonly is read-only.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118615 91177308-0d34-0410-b5e6-96231b3b80d8
db78c4873ea8c4b3dce90d761a1ad59d5bcdd6e7 09-Nov-2010 Dan Gohman <gohman@apple.com> Add a AccessesArgumentsReadonly ModRefBehavior value, so that the intrinsic
property IntrReadArgMem can be modeled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118614 91177308-0d34-0410-b5e6-96231b3b80d8
467a0adfc8b6bd4b114e024c200c159497a4cd86 09-Nov-2010 Dan Gohman <gohman@apple.com> Factor out the logic for onlyReadsMemory into a helper function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118611 91177308-0d34-0410-b5e6-96231b3b80d8
7293ac12811c8a43023830380e70c0fda941f8ec 09-Nov-2010 Dan Gohman <gohman@apple.com> Delete AccessesArgumentsAndGlobals, which was unused.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118610 91177308-0d34-0410-b5e6-96231b3b80d8
902da265f684b00b76c669c2a7cbc0f209cda187 09-Nov-2010 Dan Gohman <gohman@apple.com> Add some comments noting some correspondences between ModRefBehavior
values, LLVM IR function attributes, and LLVM intrinsic attributes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118455 91177308-0d34-0410-b5e6-96231b3b80d8
2c4c6a5e8a17909af336e3cba3d71ac354d7d9b6 08-Nov-2010 Devang Patel <dpatel@apple.com> Document parameters. Fix typos.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118424 91177308-0d34-0410-b5e6-96231b3b80d8
a25e5dbcc2371352386a01e3c1b8e76dd890272b 08-Nov-2010 Dan Gohman <gohman@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118412 91177308-0d34-0410-b5e6-96231b3b80d8
c80cbf25402e4095fafbb15a2ab1b81cf6feda77 08-Nov-2010 Dan Gohman <gohman@apple.com> Delete getIntrinsicModRefBehavior. Clients can just use the normal
getModRefBehavior now, since it now understands intrinsics as well
as normal functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118411 91177308-0d34-0410-b5e6-96231b3b80d8
6c25c920e66aa2d8f6b48454bc9770087ff7939a 08-Nov-2010 Dan Gohman <gohman@apple.com> Add comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118408 91177308-0d34-0410-b5e6-96231b3b80d8
35fcd6557f53aab69c2990b80fed4653fbaa3473 04-Nov-2010 Devang Patel <dpatel@apple.com> Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.

To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
ab70ed41f344c04dabaf180c40f04827bc9c56b5 04-Nov-2010 Devang Patel <dpatel@apple.com> Add getFile() to get DIFile of a DIType.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118247 91177308-0d34-0410-b5e6-96231b3b80d8
0e82ac07bc6e48cc343951a28e61bbf748690d6d 29-Oct-2010 Devang Patel <dpatel@apple.com> Simplify.

- DIFile F = getFieldAs<DIFile>(6);
- return F.getDirectory();
+ return getFieldAs<DIFile>(6).getDirectory();

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117662 91177308-0d34-0410-b5e6-96231b3b80d8
fb9dce3806169b8de2e48ee999441f9e9a17949a 28-Oct-2010 Devang Patel <dpatel@apple.com> Fix indentation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117601 91177308-0d34-0410-b5e6-96231b3b80d8
8f6a281e979df1578526fc8a72a3c1bd33aa3efa 28-Oct-2010 Devang Patel <dpatel@apple.com> Backward compatibility. Gracefully handle older versions of debug info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117595 91177308-0d34-0410-b5e6-96231b3b80d8
bc2bb9bbd0610bc43f08be6678431148898591aa 28-Oct-2010 Devang Patel <dpatel@apple.com> Do not work too hard to find type's file info. There is a special field to record file info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117588 91177308-0d34-0410-b5e6-96231b3b80d8
42d3a345754b216dec927252f136f1ae715710b2 28-Oct-2010 Devang Patel <dpatel@apple.com> Fix indentation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117586 91177308-0d34-0410-b5e6-96231b3b80d8
a514a4e17284617f7bff0ffa694d699da45fc882 28-Oct-2010 Devang Patel <dpatel@apple.com> Do not rely on context to find file info. It is already provided as a separate field.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117577 91177308-0d34-0410-b5e6-96231b3b80d8
f95a27192203e42f6d9c66a819f5b015f1a1d819 27-Oct-2010 Devang Patel <dpatel@apple.com> Give a name to nameless argument.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117468 91177308-0d34-0410-b5e6-96231b3b80d8
a53fe6070cae7d2feccb542b8ba24b37d3fdd027 23-Oct-2010 Benjamin Kramer <benny.kra@googlemail.com> SmallVectorize.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117213 91177308-0d34-0410-b5e6-96231b3b80d8
65513605353c7e3ee8be6fc92892f257ad399d92 20-Oct-2010 Tobias Grosser <grosser@fim.uni-passau.de> Add RegionPass support.

A RegionPass is executed like a LoopPass but on the regions detected by the
RegionInfo pass instead of the loops detected by the LoopInfo pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116905 91177308-0d34-0410-b5e6-96231b3b80d8
db4708cf86cece22539ff022cc0601612dd02ead 20-Oct-2010 Dan Gohman <gohman@apple.com> Move NoAA out of BasicAliasAnalysis.cpp into its own file, now that
it doesn't have a special relationship with BasicAliasAnalysis

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116876 91177308-0d34-0410-b5e6-96231b3b80d8
3da848bbda62b25c12335998aaa44ab361f0bf15 20-Oct-2010 Dan Gohman <gohman@apple.com> Reapply r116831 and r116839, converting AliasAnalysis to use
uint64_t, plus fixes for places I missed before.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116875 91177308-0d34-0410-b5e6-96231b3b80d8
1db839e73471a40309c2c10873b67c3b5b1b7a7b 19-Oct-2010 Dan Gohman <gohman@apple.com> Revert r116831 and r116839, which are breaking selfhost builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116858 91177308-0d34-0410-b5e6-96231b3b80d8
9cb4c7f87876ec8212bd4fae059553fcaa83f484 19-Oct-2010 Dan Gohman <gohman@apple.com> Oops, check in all the files for converting AliasAnalysis to
use uint64_t.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116839 91177308-0d34-0410-b5e6-96231b3b80d8
081c34b725980f995be9080eaec24cd3dfaaf065 19-Oct-2010 Owen Anderson <resistor@mac.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116820 91177308-0d34-0410-b5e6-96231b3b80d8
eee5400442e0812cb375ed5e17595a62f9240b80 19-Oct-2010 Dan Gohman <gohman@apple.com> Make the representation of AliasSets explicitly differentiate
between "not known yet" and "known no tbaa info" so that it
can merge them properly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116767 91177308-0d34-0410-b5e6-96231b3b80d8
fb8096dee5df60f156e770b9f96f8417e9dbd4c9 18-Oct-2010 Dan Gohman <gohman@apple.com> Don't pass the raw invalid pointer used to represent conflicting
TBAA information to AliasAnalysis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116751 91177308-0d34-0410-b5e6-96231b3b80d8
a8702eaf78e70e1eef8a63882ce97ae6d60edf5b 18-Oct-2010 Dan Gohman <gohman@apple.com> Make AliasSetTracker TBAA-aware, enabling TBAA-enabled LICM.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116743 91177308-0d34-0410-b5e6-96231b3b80d8
e98fbba91f8806526cba67cb44c08a391b84a31f 13-Oct-2010 Benjamin Kramer <benny.kra@googlemail.com> Remove noisy semicolon.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116407 91177308-0d34-0410-b5e6-96231b3b80d8
b227930cd6850e4c47358e671dbe2cdacb430def 13-Oct-2010 Tobias Grosser <grosser@fim.uni-passau.de> Add Region::isTopLevelRegion().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116402 91177308-0d34-0410-b5e6-96231b3b80d8
592316c4198023431799f8e597860b31ea7116c9 13-Oct-2010 Tobias Grosser <grosser@fim.uni-passau.de> RegionInfo: Update RegionInfo after a BB was split.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116398 91177308-0d34-0410-b5e6-96231b3b80d8
c69bd733c02a4e0ca25f7a2d6b9b05168720d373 13-Oct-2010 Tobias Grosser <grosser@fim.uni-passau.de> RegioInfo: Add getExpandedRegion().

getExpandedRegion() enables us to create non canonical regions. Those regions
can be used to define the largerst region, that fullfills a certain property.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116397 91177308-0d34-0410-b5e6-96231b3b80d8
4bcc0228dcc90385e90f22cef38b2614d3aa3cd1 13-Oct-2010 Tobias Grosser <grosser@fim.uni-passau.de> RegionInfo: Allow to update exit and entry of a region.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116396 91177308-0d34-0410-b5e6-96231b3b80d8
9649390e1fcb6d42e228364230f16409ad150fef 13-Oct-2010 Tobias Grosser <grosser@fim.uni-passau.de> RegionInfo: Enhance addSubregion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116395 91177308-0d34-0410-b5e6-96231b3b80d8
9ee5c5077690a4de31e22bb9e135deb6da3f68fb 13-Oct-2010 Tobias Grosser <grosser@fim.uni-passau.de> RegionInfo: Allow to set the parent region of a basic block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116394 91177308-0d34-0410-b5e6-96231b3b80d8
74fa7327d690e6ceda6ce77e4e5b8ef75cb12538 10-Oct-2010 Kenneth Uildriks <kennethuil@gmail.com> Now using a variant of the existing inlining heuristics to decide whether to create a given specialization of a function in PartialSpecialization. If the total performance bonus across all callsites passing the same constant exceeds the specialization cost, we create the specialization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116158 91177308-0d34-0410-b5e6-96231b3b80d8
ca52c8ba12285c0e86f1b6d3b354342c59e2a416 08-Oct-2010 Kenneth Uildriks <kennethuil@gmail.com> Start separating out code metrics into code size metrics and code performance metrics. Partial Specialization will apply the former to function specializations, and the latter to all callsites that can use a specialization, in order to decide whether to create a specialization

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116057 91177308-0d34-0410-b5e6-96231b3b80d8
7b172c6ae6c4fea90db785902b4326afb21ad584 08-Oct-2010 Devang Patel <dpatel@apple.com> Provie a clearner interface so that FE can decide whether a function has prototype or not.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115988 91177308-0d34-0410-b5e6-96231b3b80d8
d6747df5e0354256a9e440d38f21c0b3ca82af28 06-Oct-2010 Devang Patel <dpatel@apple.com> Add support for DW_TAG_unspecified_parameters.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115833 91177308-0d34-0410-b5e6-96231b3b80d8
14e8190f4329bc0ea4d8813da7486d3e05affc7c 06-Oct-2010 Dan Gohman <gohman@apple.com> Constify isReachableFromEntry.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115788 91177308-0d34-0410-b5e6-96231b3b80d8
21ea1d5b4cad8c8dee1288453f797572766c94d8 02-Oct-2010 Devang Patel <dpatel@apple.com> Add support to let FE mark explict methods as explict in debug info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115378 91177308-0d34-0410-b5e6-96231b3b80d8
3cf763dc7a9741c14432710943ab66b439562881 30-Sep-2010 Devang Patel <dpatel@apple.com> Let FE mark a variable as artificial variable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115102 91177308-0d34-0410-b5e6-96231b3b80d8
1a30123b609d48ac50f9a9e088e55683df70cfc3 29-Sep-2010 Devang Patel <dpatel@apple.com> Add support to let FE encode method access specifier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115089 91177308-0d34-0410-b5e6-96231b3b80d8
9dd2b47d444e310347debcac5cdddedbb22881e6 29-Sep-2010 Devang Patel <dpatel@apple.com> Generalize DISubprogram element to encode various flags instead of just one boolean for isArtificial.
This is a backword compatible change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115084 91177308-0d34-0410-b5e6-96231b3b80d8
3c99c769eb8995ba25de21aa686b09e53d2a7bbe 29-Sep-2010 Chris Lattner <sabre@nondot.org> remove PointerTracking from mainline, Edwin is going to move it out to ClamAV
for LLVM 2.9

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115062 91177308-0d34-0410-b5e6-96231b3b80d8
1a7ca0354a44e321d5f4839a73239e6eaec54ad5 28-Sep-2010 Devang Patel <dpatel@apple.com> Provide an interface to let FEs anchor debug info for types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114969 91177308-0d34-0410-b5e6-96231b3b80d8
e6098b620531e77b732accbcc21007abd5df927e 27-Sep-2010 Dan Gohman <gohman@apple.com> Constify properlyDominates in the same manner as dominates.
Add constified overloads for findNearestCommonDominator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114834 91177308-0d34-0410-b5e6-96231b3b80d8
4c6809d8e38b9690898700085ebbd913e035c2e2 27-Sep-2010 Dan Gohman <gohman@apple.com> Remove WriteGraph's Name argument, which it didn't use, and
rename writeHeader's Name argument to Title, to be consistent
with WriteGraph.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114829 91177308-0d34-0410-b5e6-96231b3b80d8
429c75b8654b0d1069f1897375f5801a4c5de017 25-Sep-2010 Oscar Fuentes <ofv@wanadoo.es> Avoid warnings about implicit conversions to `bool' in MSVC. This time
for real.

Patch by Nathan Jeffords!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114796 91177308-0d34-0410-b5e6-96231b3b80d8
bea77bb6e82e7f7feae71b2cafea4f6a9f6098c0 23-Sep-2010 Dan Gohman <gohman@apple.com> Fix uninitialized TBAAFlag field values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114591 91177308-0d34-0410-b5e6-96231b3b80d8
c1ac0d7623f4f2047b4ab86bd5a60a9e19432b38 22-Sep-2010 Dan Gohman <gohman@apple.com> Teach memdep about TBAA tags.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114588 91177308-0d34-0410-b5e6-96231b3b80d8
ba6ca6dd3bc4a7f30e07010c3b0b95cced719f76 22-Sep-2010 Dan Gohman <gohman@apple.com> Constify.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114574 91177308-0d34-0410-b5e6-96231b3b80d8
9f27074f42f03af640977006dc7c05005fb77991 21-Sep-2010 Dan Gohman <gohman@apple.com> Add some utility routines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114483 91177308-0d34-0410-b5e6-96231b3b80d8
28b4afc10396abaffea9035cfb752f9858f04846 21-Sep-2010 Benjamin Kramer <benny.kra@googlemail.com> Make CreateComplexVariable independent of SmallVector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114439 91177308-0d34-0410-b5e6-96231b3b80d8
ead0109f5bc010af837d0fa7c9bb2401b34fb29d 17-Sep-2010 Dan Gohman <gohman@apple.com> Add a pass which prints out all the memdep dependencies.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114121 91177308-0d34-0410-b5e6-96231b3b80d8
4e282decf3960bfa6b1fe3fd77bb51ff96121515 16-Sep-2010 Owen Anderson <resistor@mac.com> Revert r114097, adding back in the assertion against replacing an Instruction by itself. Now that CorrelatedValuePropagation is
more careful not to call SimplifyInstructionsInBlock() on an unreachable block, the issue has been fixed at a higher level. Add
a big warning to SimplifyInstructionsInBlock() to hopefully prevent this in the future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114117 91177308-0d34-0410-b5e6-96231b3b80d8
b2143b6247901ae4eca2192ee134564c4f5f7853 14-Sep-2010 Dan Gohman <gohman@apple.com> Remove the experimental AliasAnalysis::getDependency interface, which
isn't a good level of abstraction for memdep. Instead, generalize
AliasAnalysis::alias and related interfaces with a new Location
class for describing a memory location. For now, this is the same
Pointer and Size as before, plus an additional field for a TBAA tag.

Also, introduce a fixed MD_tbaa metadata tag kind.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113858 91177308-0d34-0410-b5e6-96231b3b80d8
e2d50046fd29cb3eb2483e080cb7c39b460fbb19 11-Sep-2010 Gabor Greif <ggreif@gmail.com> typoes

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113647 91177308-0d34-0410-b5e6-96231b3b80d8
f9a26b89f8815651048ed5518d99b484ac7c2ba0 09-Sep-2010 Owen Anderson <resistor@mac.com> What the loop unroller cares about, rather than just not unrolling loops with calls, is
not unrolling loops that contain calls that would be better off getting inlined. This mostly
comes up when an interleaved devirtualization pass has devirtualized a call which the inliner
will inline on a future pass. Thus, rather than blocking all loops containing calls, add
a metric for "inline candidate calls" and block loops containing those instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113535 91177308-0d34-0410-b5e6-96231b3b80d8
c8ddbdabb697b20b948c1a56af6062f26691532a 09-Sep-2010 Dan Gohman <gohman@apple.com> Extend the getDependence query with support for PHI translation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113521 91177308-0d34-0410-b5e6-96231b3b80d8
c48bf0c39451befa74b1091be2546760c72c1c91 09-Sep-2010 Dan Gohman <gohman@apple.com> Fix this comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113511 91177308-0d34-0410-b5e6-96231b3b80d8
082bf2a977b6bb91d61ac5155e1906ecc6ba47bf 09-Sep-2010 Owen Anderson <resistor@mac.com> Refactor code-size reduction estimation methods out of InlineCostAnalyzer and into CodeMetrics. They
don't use any InlineCostAnalyzer state, and are useful for other clients who don't necessarily want to use
all of InlineCostAnalyzer's logic, some of which is fairly inlining-specific.

No intended functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113499 91177308-0d34-0410-b5e6-96231b3b80d8
65924111bf648db8f20599f485be918c7aa1e7ef 08-Sep-2010 Dan Gohman <gohman@apple.com> Add a new experimental generalized dependence query interface to
AliasAnalysis, and some code for implementing the new query on top of
existing implementations by making standard alias and getModRefInfo

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113329 91177308-0d34-0410-b5e6-96231b3b80d8
fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8 07-Sep-2010 Dan Gohman <gohman@apple.com> Tidy up the getModRefInfo declarations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113275 91177308-0d34-0410-b5e6-96231b3b80d8
adc799112dc180b3cd099038c05101b85d217716 06-Sep-2010 Chris Lattner <sabre@nondot.org> pull a simple method out of LICM into a new
Loop::hasLoopInvariantOperands method. Remove
a useless and confusing Loop::isLoopInvariant(Instruction)
method, which didn't do what you thought it did.

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113133 91177308-0d34-0410-b5e6-96231b3b80d8
191bd64a39490fa75d35b9aaecdd57b00c7a8b5f 01-Sep-2010 Dan Gohman <gohman@apple.com> Revert 112442 and 112440 until the compile time problems introduced
by 112440 are resolved.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112692 91177308-0d34-0410-b5e6-96231b3b80d8
39429e2b5175d3f34c2a1cc693fefd9a4fc6919e 31-Aug-2010 Dan Gohman <gohman@apple.com> Update the descriptions of NoModRef and ModRef to be consistent
with the descriptions of Mod and Ref.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112557 91177308-0d34-0410-b5e6-96231b3b80d8
cb7f65342291caa3636cb50c0ee04b383cd79f8d 29-Aug-2010 Chris Lattner <sabre@nondot.org> two changes: 1) make AliasSet hold the list of call sites with an
assertingvh so we get a violent explosion if the pointer dangles.

2) Fix AliasSetTracker::deleteValue to remove call sites with
by-pointer comparisons instead of by-alias queries. Using
findAliasSetForCallSite can cause alias sets to get merged
when they shouldn't, and can also miss alias sets when the
call is readonly.

#2 fixes PR6889, which only repros with a .c file :(

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112452 91177308-0d34-0410-b5e6-96231b3b80d8
eaa40ff74e41176250bd6b50116ab03b0c596d5e 29-Aug-2010 Dan Gohman <gohman@apple.com> Make IVUsers iterative instead of recursive.

This has the side effect of reversing the order of most of
IVUser's results.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112442 91177308-0d34-0410-b5e6-96231b3b80d8
e8ac3f3be4b4df619368bf46aa4ed91557b5f76e 27-Aug-2010 Dan Gohman <gohman@apple.com> Switch ScalarEvolution's main Value*->SCEV* map from std::map
to DenseMap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112281 91177308-0d34-0410-b5e6-96231b3b80d8
2177a04e24b8ed8a922c5cd7ad27463de85a47d2 25-Aug-2010 Eric Christopher <echristo@apple.com> Fix header define to reflect the name of the file.

Patch by Adam Treat!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112077 91177308-0d34-0410-b5e6-96231b3b80d8
0c4720c6bdf517d02aaf71d90c0572a5aa4813bc 23-Aug-2010 Devang Patel <dpatel@apple.com> Handle qualified constants that are directly folded by FE.
PR 7920.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111820 91177308-0d34-0410-b5e6-96231b3b80d8
a3833f18bf897598121ecfb0377f1931d8e03d21 21-Aug-2010 Dan Gohman <gohman@apple.com> CreateTemporaryType doesn't needs its Context argument.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111687 91177308-0d34-0410-b5e6-96231b3b80d8
489b29b0a4ee4526e3d50ad88d3d48745baf5042 21-Aug-2010 Dan Gohman <gohman@apple.com> Introduce a new temporary MDNode concept. Temporary MDNodes are
not part of the IR, are not uniqued, and may be safely RAUW'd.
This replaces a variety of alternate mechanisms for achieving
the same effect.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111681 91177308-0d34-0410-b5e6-96231b3b80d8
30963fbe8fa0ba3a4cc35c7c6e8f24c772f1b40c 19-Aug-2010 Chris Lattner <sabre@nondot.org> move gep decomposition out of ValueTracking into BasicAA. The form of
decomposition that it is doing is very basicaa specific and is only used
by basicaa.

Now with less tree breakingness.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111433 91177308-0d34-0410-b5e6-96231b3b80d8
4ae56d725d25020106d8056c09b19319a4c49e93 18-Aug-2010 Daniel Dunbar <daniel@zuster.org> Revert r111375, "move gep decomposition out of ValueTracking into BasicAA. The
form of", it doesn't pass tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111385 91177308-0d34-0410-b5e6-96231b3b80d8
00ac77ef886f57bd421341d717849695e5fde474 18-Aug-2010 Owen Anderson <resistor@mac.com> Inform LazyValueInfo whenever a block is deleted, to avoid dangling pointer issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111382 91177308-0d34-0410-b5e6-96231b3b80d8
6b63037306c5c3dc9bf719a34243de5045a949da 18-Aug-2010 Chris Lattner <sabre@nondot.org> move gep decomposition out of ValueTracking into BasicAA. The form of
decomposition that it is doing is very basicaa specific and is only used
by basicaa.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111375 91177308-0d34-0410-b5e6-96231b3b80d8
7d0e3c01f35fae3c448761c21477faa622872044 16-Aug-2010 Dan Gohman <gohman@apple.com> Revert r111031. The way LLVM defines loop invariance, the property of an
expression being loop invariant is not equivalent to the property of
properly dominating the loop header.

Other optimizations have also made this optimization less important.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111160 91177308-0d34-0410-b5e6-96231b3b80d8
081ad68e687b24dd102ed890bae1e10d8d284cef 16-Aug-2010 Dan Gohman <gohman@apple.com> Placate overzealous compiler warnings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111152 91177308-0d34-0410-b5e6-96231b3b80d8
2f199f9952b9dd62b5a0d0f4350b8fa780ebb9cc 16-Aug-2010 Dan Gohman <gohman@apple.com> Move SCEVNAryExpr's virtual member functions out of line, and convert
them to iterators.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111140 91177308-0d34-0410-b5e6-96231b3b80d8
aadb5f5adbdb650c5cdc5ece939aaa30af91b3bc 16-Aug-2010 Dan Gohman <gohman@apple.com> Specialize FoldingSetTrait<SCEV>, providing implementations of node
comparison and hash computation which don't require constructing
temporary ID values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111131 91177308-0d34-0410-b5e6-96231b3b80d8
ef0bedaba7c1466af4275e720a73f3421b9b5631 13-Aug-2010 Dan Gohman <gohman@apple.com> Implement hasComputableLoopEvolution for Add, Mul, and Trunc operators,
since they can support trivial implementations. This avoids potentially
expensive traversals of the operands.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111031 91177308-0d34-0410-b5e6-96231b3b80d8
bd4d66d56a4e761a206dac14ccff4d37139d9ad9 11-Aug-2010 Dan Gohman <gohman@apple.com> Make LoopPass::getContainedPass return a LoopPass* instead of a Pass*
and remove casts from all its callers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110848 91177308-0d34-0410-b5e6-96231b3b80d8
af08a36bd6b9d32a5ea993849d43094fecbd5bed 11-Aug-2010 Dan Gohman <gohman@apple.com> Rename and reorder the arguments to isImpliedCond, for consistency and clarity.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110750 91177308-0d34-0410-b5e6-96231b3b80d8
6bf058c9aa59ec7893f9f3493daf9e6531699ce2 10-Aug-2010 Devang Patel <dpatel@apple.com> Add missing argument. CreateCompositeTypeEx() users, please verify.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110717 91177308-0d34-0410-b5e6-96231b3b80d8
2739896cdd3c987de3d7f9a41217b4b954287c8d 09-Aug-2010 Devang Patel <dpatel@apple.com> Refactor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110607 91177308-0d34-0410-b5e6-96231b3b80d8
8d570bf8e9eb41e2f1c283bd67cc58514b0c429a 07-Aug-2010 Dan Gohman <gohman@apple.com> Remove assignPassManager's default arguments. It's really
confusing to have different arguments for the same virtual
function at different levels of the class hierarchy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110500 91177308-0d34-0410-b5e6-96231b3b80d8
4bdeede8c7ea307b3f6192ec4f425debda948998 07-Aug-2010 Dan Gohman <gohman@apple.com> Tidy up PMStack. Add a bunch of consts, use std::vector instead of
std::deque, since this is a stack and only supports push/pop on
one end, and remove an unimplemented declaration.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110495 91177308-0d34-0410-b5e6-96231b3b80d8
90c579de5a383cee278acc3f7e7b9d0a656e6a35 06-Aug-2010 Owen Anderson <resistor@mac.com> Reapply r110396, with fixes to appease the Linux buildbot gods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110460 91177308-0d34-0410-b5e6-96231b3b80d8
e26a7b5e21a49543a727b1b2524a934e73c89772 06-Aug-2010 Dan Gohman <gohman@apple.com> Implement a proper getModRefInfo for va_arg.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110458 91177308-0d34-0410-b5e6-96231b3b80d8
13214eb8ccaef26d9f5ad79a702f4b196d357537 06-Aug-2010 Dan Gohman <gohman@apple.com> Add a comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110426 91177308-0d34-0410-b5e6-96231b3b80d8
1f74590e9d1b9cf0f1f81a156efea73f76546e05 06-Aug-2010 Owen Anderson <resistor@mac.com> Revert r110396 to fix buildbots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110410 91177308-0d34-0410-b5e6-96231b3b80d8
cb74993bdc37681ddbb80fa361575107afae1350 06-Aug-2010 Dan Gohman <gohman@apple.com> Make AA private, since subclasses shouldn't (aren't don't) access it directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110398 91177308-0d34-0410-b5e6-96231b3b80d8
9ccaf53ada99c63737547c0235baeb8454b04e80 06-Aug-2010 Owen Anderson <resistor@mac.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110396 91177308-0d34-0410-b5e6-96231b3b80d8
f66514ad3a0ae72b5ab27d55381f699880534bec 05-Aug-2010 Dan Gohman <gohman@apple.com> Delete obsolete comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110277 91177308-0d34-0410-b5e6-96231b3b80d8
e89652ccad7b2685387a8327961a46f8bac0978b 04-Aug-2010 Torok Edwin <edwintorok@gmail.com> Add a missing function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110195 91177308-0d34-0410-b5e6-96231b3b80d8
a41af344c2964573318a77e2b43eafd4d3804003 04-Aug-2010 Dan Gohman <gohman@apple.com> Remove PointerAccessInfo, which nothing was using.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110167 91177308-0d34-0410-b5e6-96231b3b80d8
79fca6fea87be7221843031870bbf2c9ae1fc555 03-Aug-2010 Dan Gohman <gohman@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110155 91177308-0d34-0410-b5e6-96231b3b80d8
e53e3772f3c8b4cba69b7d77c8b2148a080fe9ae 03-Aug-2010 Dan Gohman <gohman@apple.com> Update some comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110092 91177308-0d34-0410-b5e6-96231b3b80d8
ef1cfac9e50def9097cd3e3ab3c5cad7f4c758cc 03-Aug-2010 Dan Gohman <gohman@apple.com> Introduce a symbolic constant for ~0u for use with AliasAnalysis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110091 91177308-0d34-0410-b5e6-96231b3b80d8
847a84efd23a2c7d90429b82f6e0f19d1f913d9a 03-Aug-2010 Dan Gohman <gohman@apple.com> Add a convenient form of AliasAnalysis::alias for the case where the sizes
are unknown.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110090 91177308-0d34-0410-b5e6-96231b3b80d8
ab37f50838350e1104579fbd1f7c8820473485a5 03-Aug-2010 Dan Gohman <gohman@apple.com> Make SCEVUnknown a CallbackVH, so that it can be notified directly
of Value deletions and RAUWs, instead of relying on ScalarEvolution's
Scalars map being notified, as that's complicated at best, and
insufficient in general.

This means SCEVUnknown needs a non-trivial destructor, so introduce
a mechanism to allow ScalarEvolution to locate all the SCEVUnknowns.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110086 91177308-0d34-0410-b5e6-96231b3b80d8
c182cb5784cfe557f3c8fa6cfb208c02d2ed42d5 03-Aug-2010 Dan Gohman <gohman@apple.com> Sketch up a preliminary Type-Based Alias Analysis implementation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110077 91177308-0d34-0410-b5e6-96231b3b80d8
5b164b5a5cab577fdfc21b22b78b3207dbcfbcf1 03-Aug-2010 Devang Patel <dpatel@apple.com> Add explicit constructors. Patch by Renato Golin.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110072 91177308-0d34-0410-b5e6-96231b3b80d8
b2bdf941f66f367cfaed58497513238167910486 30-Jul-2010 Nick Lewycky <nicholas@mxc.ca> LibCallAliasAnalysis uses multiple inheritance, so it needs to implement
getAdjustedAnalysisPointer. Part of a fix to PR7760.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109883 91177308-0d34-0410-b5e6-96231b3b80d8
e6cbfa6b09e3e9ddf18449d1b64793e24af27c6b 29-Jul-2010 Eric Christopher <echristo@apple.com> Speculatively revert r109705 since it seems to be causing some build bot

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109718 91177308-0d34-0410-b5e6-96231b3b80d8
c6743207e20904008d2de016adfa6b0a9355c0e7 29-Jul-2010 Dan Gohman <gohman@apple.com> Factor out some of the code for updating old SCEVUnknown values, and
extend it to handle the case where multiple RAUWs affect a single

Add a ScalarEvolution unittest to test for this situation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109705 91177308-0d34-0410-b5e6-96231b3b80d8
dc7a235363166a61e81986c534fe11ceb44109fc 28-Jul-2010 Dan Gohman <gohman@apple.com> Add some extra friend declarations to fix a gcc-4.0 compile error.
This is a temporary fix, until more elaborate changes are ready.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109593 91177308-0d34-0410-b5e6-96231b3b80d8
f374ba2bcd3a3b993d6b3fcd9f70a29973f93175 28-Jul-2010 Dan Gohman <gohman@apple.com> Add a comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109565 91177308-0d34-0410-b5e6-96231b3b80d8
0e6fcf4be360f5d73685c213e3b4af1bb9ce2b5d 27-Jul-2010 Tobias Grosser <grosser@fim.uni-passau.de> RegionInfo: Add getMaxRegionExit()

getMaxRegionExit returns the exit of the maximal refined region starting
at a specific basic block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109496 91177308-0d34-0410-b5e6-96231b3b80d8
082d587d35a41ee06985d7867b72fb2632962281 27-Jul-2010 Tobias Grosser <grosser@fim.uni-passau.de> Add function to query RegionInfo about loops.

* contains(Loop), * getOutermostLoop()
* Improve getNameStr() to return a sensible name, if basic blocks are not named.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109490 91177308-0d34-0410-b5e6-96231b3b80d8
ab28928fe276d20cf9533ae6b858497f835c7a53 27-Jul-2010 Dan Gohman <gohman@apple.com> Use AssertingVH for InsertedValues and InsertedPostIncValues, to verify
that the values they refer to aren't being deleted underneath them.

Make sure these containters get cleared by clear(), which IndVarSimplify
and LSR both use before deleting instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109478 91177308-0d34-0410-b5e6-96231b3b80d8
cfa7fb6df5aaaf9e54fe97633167b44782224e45 26-Jul-2010 Owen Anderson <resistor@mac.com> Add an initial implementation of LazyValueInfo updating for JumpThreading. Disabled for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109424 91177308-0d34-0410-b5e6-96231b3b80d8
f8336a75c2cffe3a0b9aae5b67faf742754d7eb3 23-Jul-2010 Dan Gohman <gohman@apple.com> Eliminate getCanonicalInductionVariableIncrement's last user and
eliminate it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109270 91177308-0d34-0410-b5e6-96231b3b80d8
f96b0063674e6bf72da5429bd49097e33c2325c7 22-Jul-2010 Tobias Grosser <grosser@fim.uni-passau.de> Add new RegionInfo pass.

The RegionInfo pass detects single entry single exit regions in a function,
where a region is defined as any subgraph that is connected to the remaining
graph at only two spots.
Furthermore an hierarchical region tree is built.
Use it by calling "opt -regions analyze" or "opt -view-regions".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109089 91177308-0d34-0410-b5e6-96231b3b80d8
872814ae048df032bddf9299c850f5bda08299a9 21-Jul-2010 Dan Gohman <gohman@apple.com> Disallow null as a named metadata operand.
Make MDNode::destroy private.
Fix the one thing that used MDNode::destroy, outside of MDNode itself.

One should never delete or destroy an MDNode explicitly. MDNodes
implicitly go away when there are no references to them (implementation
details aside).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109028 91177308-0d34-0410-b5e6-96231b3b80d8
6a0dc079efe7acf7e71cc4c0948fe814f35ba091 20-Jul-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Implement loop splitting analysis.
Determine which loop exit blocks need a 'pre-exit' block inserted.
Recognize when this would be impossible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108941 91177308-0d34-0410-b5e6-96231b3b80d8
7c58dbd88c36c5d6c411ea6c046ddcff4c5841e9 20-Jul-2010 Dan Gohman <gohman@apple.com> Make getOrInsertCanonicalInductionVariable guarantee that its
result is a PHINode*.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108852 91177308-0d34-0410-b5e6-96231b3b80d8
0db42710693badaab808ccf8bcd265144ce8493d 20-Jul-2010 Stuart Hastings <stuart@apple.com> Correct line info for declarations/definitions. Radar 8063111.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108784 91177308-0d34-0410-b5e6-96231b3b80d8
92583187306cec18d73db362681ea4f8e2b41909 17-Jul-2010 Lang Hames <lhames@gmail.com> Switched to array_pod_sort as per Chris's suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108616 91177308-0d34-0410-b5e6-96231b3b80d8
60f422f894ae9aff2f508f34733be36f5a0ed20a 17-Jul-2010 Lang Hames <lhames@gmail.com> LoopSplitter - intended to split live intervals over loop boundaries.
Still very much under development. Comments and fixes will be forthcoming.

(This commit includes some small tweaks to LiveIntervals & LoopInfo to support the splitter)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108615 91177308-0d34-0410-b5e6-96231b3b80d8
9a7b37b8a35e60494cde8b2bb6b6cab587836c7a 16-Jul-2010 Tobias Grosser <grosser@fim.uni-passau.de> Add dump() to DominanceFrontier

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108512 91177308-0d34-0410-b5e6-96231b3b80d8
0764e39a921ae424e2ac8c7ba114b67040eba8f6 13-Jul-2010 Eric Christopher <echristo@apple.com> 80-columns

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108228 91177308-0d34-0410-b5e6-96231b3b80d8
6c507926532d609b1225c29878b37c562e4277f2 12-Jul-2010 Eric Christopher <echristo@apple.com> Remove tab characters and 80-col.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108127 91177308-0d34-0410-b5e6-96231b3b80d8
7c71b81a4fccd236e191dbbd6926b35fb4ac9b1e 09-Jul-2010 Gabor Greif <ggreif@gmail.com> fix clang selfhost issue (shadowing)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107970 91177308-0d34-0410-b5e6-96231b3b80d8
e07c3c46d0b5adb7d7af876fd3ea3703aebc47c1 09-Jul-2010 Gabor Greif <ggreif@gmail.com> refactor type expressions and cache operator*'s result

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107964 91177308-0d34-0410-b5e6-96231b3b80d8
8fe5ccc5850af3248992d182c5b7c079b50120fc 09-Jul-2010 Gabor Greif <ggreif@gmail.com> two more cases of reuse result of operator*, found by inspection

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107961 91177308-0d34-0410-b5e6-96231b3b80d8
4fd6b397031d7b5baa01849c065ad7ef70882d83 09-Jul-2010 Gabor Greif <ggreif@gmail.com> another case of reuse result of operator*, it is expensive to recompute

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107960 91177308-0d34-0410-b5e6-96231b3b80d8
f6c166078f8f10006dcbdde081603eccccfcefbe 09-Jul-2010 Gabor Greif <ggreif@gmail.com> reuse result of operator*, it is expensive to recompute

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107959 91177308-0d34-0410-b5e6-96231b3b80d8
99cfb69f17ccf6dca7378fe6d1c60758e5cabd1f 09-Jul-2010 Stuart Hastings <stuart@apple.com> Reverting r107918 and r107919. Radar 8063111.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107930 91177308-0d34-0410-b5e6-96231b3b80d8
c0e2639a3450e5cca5cd5082cef55a64bbd27ad4 09-Jul-2010 Stuart Hastings <stuart@apple.com> Fix decl/def debug info for template functions. Radar 8063111.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107919 91177308-0d34-0410-b5e6-96231b3b80d8
da995609e6e963eaa77346d43b0a33b81e53a785 08-Jul-2010 Gabor Greif <ggreif@gmail.com> only dereference iterator once in the loop
(by caching the result we save a potentially expensive dereference)

also use typedefs to shorten type declarations

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107883 91177308-0d34-0410-b5e6-96231b3b80d8
2dac4c1b519feaf1ef63514f07fa16aa5dc7d89a 08-Jul-2010 Duncan Sands <baldrick@free.fr> Use std::vector rather than SmallVector here because SmallVector
causes some versions of gcc to crash when building LLVM.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107869 91177308-0d34-0410-b5e6-96231b3b80d8
a0994b1a13ef3437f5442b9fec1750b150da175a 08-Jul-2010 Duncan Sands <baldrick@free.fr> Do not use std::stack because it causes obscure failures when
compiled with MSVC 2010 (PR7367). Instead use a SmallVector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107867 91177308-0d34-0410-b5e6-96231b3b80d8
9e86f4364b912ae743490ba01d6989acfd12c046 07-Jul-2010 Dan Gohman <gohman@apple.com> Remove interprocedural-basic-aa and associated code. The AliasAnalysis
interface needs implementations to be consistent, so any code which
wants to support different semantics must use a different interface.
It's not currently worthwhile to add a new interface for this new

Document that AliasAnalysis doesn't support cross-function queries.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107776 91177308-0d34-0410-b5e6-96231b3b80d8
43b8fd728b889f15ea4c65ca957a7420ce2905cd 03-Jul-2010 Dan Gohman <gohman@apple.com> Document that BasicAA respects noalias, while InterproceduralBasicAA
does not.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107546 91177308-0d34-0410-b5e6-96231b3b80d8
541481f34c7ffd49c0b55b56eab3753fda17c3e5 02-Jul-2010 Dan Gohman <gohman@apple.com> Remove an unused enum.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107507 91177308-0d34-0410-b5e6-96231b3b80d8
6be2bd516a3022721480f8fee6986617baf0944f 29-Jun-2010 Dan Gohman <gohman@apple.com> Add an Intraprocedural form of BasicAliasAnalysis, which aims to
properly handles instructions and arguments defined in different
functions, or across recursive function iterations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107109 91177308-0d34-0410-b5e6-96231b3b80d8
8d121694a3eaf377e3229a7fa325e81e83cbb2fb 28-Jun-2010 Dan Gohman <gohman@apple.com> Generalize AAEval so that it can be used both per-function and
interprocedurally. Note that as of this writing, existing alias
analysis passes are not prepared to be used interprocedurally.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107013 91177308-0d34-0410-b5e6-96231b3b80d8
02680f946b8dcbeff3b8d7236030678551b15a6c 23-Jun-2010 Gabor Greif <ggreif@gmail.com> minor enhancement to llvm::isFreeCall API: return CallInst; no functional change

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106686 91177308-0d34-0410-b5e6-96231b3b80d8
605c14fb115e89a2bad97761ae57b55e8c28ffff 23-Jun-2010 Dan Gohman <gohman@apple.com> Replace ScalarEvolution's private copy of getLoopPredecessor
with LoopInfo's public copy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106603 91177308-0d34-0410-b5e6-96231b3b80d8
5cf27f81f49b4516b1e9d269f070c88fa3228f9e 22-Jun-2010 Dan Gohman <gohman@apple.com> Split out the code for finding a unique loop predecessor from
getLoopPreheader into a separate function, for clients which don't
require a proper preheader.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106543 91177308-0d34-0410-b5e6-96231b3b80d8
485c43fc478d5e16c55e14cb2586b56cc1c4c91f 19-Jun-2010 Dan Gohman <gohman@apple.com> Factor out duplicated code for reusing and inserting casts into
a helper function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106388 91177308-0d34-0410-b5e6-96231b3b80d8
3bf63768e574a2065de1aebba12f6c2e80f4fb16 18-Jun-2010 Dan Gohman <gohman@apple.com> Revert r106304 (105548 and friends), which are the SCEVComplexityCompare
optimizations. There is still some nondeterminism remaining.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106306 91177308-0d34-0410-b5e6-96231b3b80d8
78db186d2dbaf4745f7e4beab4029db40856b54b 18-Jun-2010 Dan Gohman <gohman@apple.com> Reapply 105540, 105542, and 105548, and revert r105732.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106304 91177308-0d34-0410-b5e6-96231b3b80d8
45934330150aecbc98c2d60fe7f17fa69e62ba71 18-Jun-2010 Dan Gohman <gohman@apple.com> Don't bother calling releaseMemory before destroying the DominatorTreeBase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106287 91177308-0d34-0410-b5e6-96231b3b80d8
07587a450044e32b791baa012032f1cb11bfed88 18-Jun-2010 Dan Gohman <gohman@apple.com> Remove getIntegerSCEV; it's redundant with getConstant, and getConstant
is more consistent with the ConstantInt API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106281 91177308-0d34-0410-b5e6-96231b3b80d8
41f98a295affaca4455d180f0566335179f39fc3 17-Jun-2010 Douglas Gregor <dgregor@apple.com> Revert r106117, which was the result of me misreading the C++98/03

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106162 91177308-0d34-0410-b5e6-96231b3b80d8
0964b4a3f554a4fe330464655c458ac8ae5deb13 16-Jun-2010 Douglas Gregor <dgregor@apple.com> Eliminate a redundant "typename" keyword

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106117 91177308-0d34-0410-b5e6-96231b3b80d8
215aa15a0d0df75af8d9cef6ef49026dcc3258a8 11-Jun-2010 Stuart Hastings <stuart@apple.com> Support for nested functions/classes in debug output. (Again.) Radar 7424645.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105828 91177308-0d34-0410-b5e6-96231b3b80d8
1d451dff63e9c4241794a3645dfe4ee67efe5b22 09-Jun-2010 Evan Cheng <evan.cheng@apple.com> Revert 105540, 105542, 105544, 105546, and 105548 to unbreak bootstrapping.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105740 91177308-0d34-0410-b5e6-96231b3b80d8
42c7d23c6d56e0743169d94025264eaf17eb799d 09-Jun-2010 Kenneth Uildriks <kennethuil@gmail.com> Pulled CodeMetrics out of InlineCost.h and made it a bit more general, so it can be reused from PartialSpecializationCost

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105725 91177308-0d34-0410-b5e6-96231b3b80d8
fd447eff22637c3d47ce709468ab50b6243d0e4c 07-Jun-2010 Dan Gohman <gohman@apple.com> The FoldingSet hash data includes pointer values, so it isn't
determinstic. Instead, give SCEV objects an arbitrary sequence

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105548 91177308-0d34-0410-b5e6-96231b3b80d8
4d52c6d622811d00d40b914a4ebd1996b1eed95d 07-Jun-2010 Dan Gohman <gohman@apple.com> Optimize ScalarEvolution's SCEVComplexityCompare predicate: don't go
scrounging through SCEVUnknown contents and SCEVNAryExpr operands;
instead just do a simple deterministic comparison of the precomputed
hash data.

Also, since this is more precise, it eliminates the need for the slow
N^2 duplicate detection code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105540 91177308-0d34-0410-b5e6-96231b3b80d8
6d56b9fabcfb1fc874a6122cf41d876c4673e9d4 05-Jun-2010 Stuart Hastings <stuart@apple.com> Revert 105492 & 105493 due to a testcase regression. Radar 7424645.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105511 91177308-0d34-0410-b5e6-96231b3b80d8
25fcaff409f5c4c6da08f148ffb9404a71e8e4a7 05-Jun-2010 Dan Gohman <gohman@apple.com> LSR needs to remember inserted instructions even in postinc mode, because
there could be multiple subexpressions within a single expansion which
require insert point adjustment. This fixes PR7306.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105510 91177308-0d34-0410-b5e6-96231b3b80d8
0f1b8135673f512b3373f3e1f16607f70537be72 05-Jun-2010 Stuart Hastings <stuart@apple.com> Support for nested functions/classes in debug output. Radar 7424645.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105492 91177308-0d34-0410-b5e6-96231b3b80d8
dd9344f3face8f1978a7f9f393c31b628144d1f6 28-May-2010 Dan Gohman <gohman@apple.com> Move FindAvailableLoadedValue isSafeToLoadUnconditionally out of
lib/Transforms/Utils and into lib/Analysis so that Analysis passes
can use them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104949 91177308-0d34-0410-b5e6-96231b3b80d8
dffc308c0e34617fe1ee686429f2146ff6170325 28-May-2010 Dan Gohman <gohman@apple.com> Fix a comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104947 91177308-0d34-0410-b5e6-96231b3b80d8
a0f7ff334f86926356491ec78ab3066247dc93b1 27-May-2010 Dan Gohman <gohman@apple.com> Fix Lint printing warnings multiple times. Remove the ErrorStr
option from lintModule, which was an artifact from being
based on Verifier code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104765 91177308-0d34-0410-b5e6-96231b3b80d8
6ed0ce3240d13ff5bdb9520f8563792b58e5257a 20-May-2010 Devang Patel <dpatel@apple.com> Rename variable. add comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104274 91177308-0d34-0410-b5e6-96231b3b80d8
98e1cac52c0eb35fdf6608befd58a8d09d3459d6 14-May-2010 Devang Patel <dpatel@apple.com> Add support to preserve type info for the variables that are removed by the optimizer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103798 91177308-0d34-0410-b5e6-96231b3b80d8
9a1581b9102511282ee823ab9a29819bc060e6a5 12-May-2010 Nick Lewycky <nicholas@mxc.ca> Clear CachedFunctionInfo upon Pass::releaseMemory. Because ValueMap will abort
on RAUW of functions, this is a correctness issue instead of a mere memory
usage problem.

No testcase until the new MergeFunctions can land.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103653 91177308-0d34-0410-b5e6-96231b3b80d8
a49d8772902c2a72c298952f633ab4224cf33add 08-May-2010 Devang Patel <dpatel@apple.com> Remove DIGlobal.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103325 91177308-0d34-0410-b5e6-96231b3b80d8
47e2265a30d0a990839f81315ce6387c09d2c36b 08-May-2010 Devang Patel <dpatel@apple.com> Add DINameSpace::Verify().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103318 91177308-0d34-0410-b5e6-96231b3b80d8
2be6e6d59c6778637266aed3a334f6c53de71fc7 08-May-2010 Douglas Gregor <dgregor@apple.com> Clang is dying on this with an ambiguous conversion sequence. We're working on it

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103312 91177308-0d34-0410-b5e6-96231b3b80d8
02f0dbd97a9bc01528aa12c2f260d928683ab411 08-May-2010 Devang Patel <dpatel@apple.com> Verify variable directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103305 91177308-0d34-0410-b5e6-96231b3b80d8
e9f8f5e6004fd49f2aff4dd23db8e9b0e4454fc6 07-May-2010 Devang Patel <dpatel@apple.com> Wrap const MDNode * inside DIDescriptor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103295 91177308-0d34-0410-b5e6-96231b3b80d8
ebe57f1b30870d46b48bf3bb22d7a88c780e9848 07-May-2010 Devang Patel <dpatel@apple.com> remove DIDescriptor::getNode()

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103278 91177308-0d34-0410-b5e6-96231b3b80d8
2db49d797b86b7f3615bae17b2b016727778a6c4 07-May-2010 Devang Patel <dpatel@apple.com> Avoid DIDescriptor::getNode(). Use overloaded operators instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103272 91177308-0d34-0410-b5e6-96231b3b80d8
ef0b14593bb8dd5651606925584adb1ac1096ba5 07-May-2010 Dan Gohman <gohman@apple.com> Add a simple module-level debug info printer. It just sets up a
DebugInfoFinder and iterates over all the contents calling print.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103262 91177308-0d34-0410-b5e6-96231b3b80d8
5374195cd74b481681f41d5e1b03e5ba69c9dad0 07-May-2010 Dan Gohman <gohman@apple.com> Const-ify some stuff.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103256 91177308-0d34-0410-b5e6-96231b3b80d8
504043662ced71235b7c7d4ae3ce3cee898cb391 07-May-2010 Dan Gohman <gohman@apple.com> Convert the DebugInfo classes dump() methods into print(raw_ostream &)
methods, and add dump functions implemented in terms of the print.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103254 91177308-0d34-0410-b5e6-96231b3b80d8
752e2590585227f6f10e80978f587915d9adb2ad 01-May-2010 David Chisnall <csdavec@swan.ac.uk> Added a variant of InlineCostAnalyzer::getInlineCost() that takes the called function as an explicit argument, for use when inlining function pointers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102841 91177308-0d34-0410-b5e6-96231b3b80d8
ccff812777470d294b7d7407783ccb6111ca0d10 30-Apr-2010 Devang Patel <dpatel@apple.com> Attach AT_APPLE_optimized attribute to optimized function's debug info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102743 91177308-0d34-0410-b5e6-96231b3b80d8
5cc6f9ba4777a460d7036edbbb3e8f01fb0a3d32 30-Apr-2010 Dan Gohman <gohman@apple.com> Add some comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102731 91177308-0d34-0410-b5e6-96231b3b80d8
22070e88f2550dc31f02273b3fa78e4e9847996b 29-Apr-2010 Devang Patel <dpatel@apple.com> Missed earlier. This is part of previous check-in. (r102661 - refactor.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102662 91177308-0d34-0410-b5e6-96231b3b80d8
e979650fa5faf4b1253f623662a8d9c81a4a4fc3 24-Apr-2010 Dan Gohman <gohman@apple.com> Add a new utility function SimplifyICmpOperands. Much of this code is
refactored out of ScalarEvolution::isImpliedCond, which will be updated
to use this new utility routine soon.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102229 91177308-0d34-0410-b5e6-96231b3b80d8
70745c661de12e3e5b7892776b190f2db703509b 22-Apr-2010 Chris Lattner <sabre@nondot.org> fix file header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102049 91177308-0d34-0410-b5e6-96231b3b80d8
047542669a20505fc7c5f2d93caa5610aa3db2c5 20-Apr-2010 Chris Lattner <sabre@nondot.org> move some select simplifications out out instcombine into
inst simplify. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101873 91177308-0d34-0410-b5e6-96231b3b80d8
8a39ed75ec57c7fabde318c0d45fac014ac287f4 20-Apr-2010 Chris Lattner <sabre@nondot.org> make CallGraphNode dtor abort if a node is deleted when there are still
references to it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101847 91177308-0d34-0410-b5e6-96231b3b80d8
c056454ecfe66f7c646fedef594f4ed48a9f3bf0 19-Apr-2010 Dan Gohman <gohman@apple.com> Remove the Expr member from IVUsers. Instead of remembering the expression,
just ask ScalarEvolution for it on demand. This helps IVUsers be more robust
in the case of expressions changing underneath it. This fixes PR6862.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101819 91177308-0d34-0410-b5e6-96231b3b80d8
b5f6af644ebe504479a74341ae8b0c706e7a5fcc 17-Apr-2010 Dale Johannesen <dalej@apple.com> Add comment (lost when reverting and reapplying 101503).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101664 91177308-0d34-0410-b5e6-96231b3b80d8
ab89ff78419cf0dfa6360c7b142b9fb1490866b7 17-Apr-2010 Dale Johannesen <dalej@apple.com> Reapply 101503+101520. These are "obviously correct" [Chris]
and don't cause any problems on Darwin.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101584 91177308-0d34-0410-b5e6-96231b3b80d8
5b13a1a4c3a90c1dfd4b5c2521b5900ff367b12c 16-Apr-2010 Dan Gohman <gohman@apple.com> Revert 101520, which depended on 101503, which was reverted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101528 91177308-0d34-0410-b5e6-96231b3b80d8
f72a53db4453a45aca282bd13c1f2dbe40a08466 16-Apr-2010 Duncan Sands <baldrick@free.fr> Revert commit 101503 (johannes), in the hope of fixing the dragonegg build,
see http://google1.osuosl.org:8011/builders/dragonegg-x86_64-linux/builds/693
Original commit text:
Use a ValueMap not a std::map for the reason indicated
in the comment. This was causing nondeterministic changes
in inlining decisions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101525 91177308-0d34-0410-b5e6-96231b3b80d8
899dd9be7fb91c089ef1ae20ef44b2a286433313 16-Apr-2010 Dan Gohman <gohman@apple.com> Trim a #include.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101520 91177308-0d34-0410-b5e6-96231b3b80d8
d4ed2a8636a1662cbf1e0f077083cf780344263e 16-Apr-2010 Dale Johannesen <dalej@apple.com> Use a ValueMap not a std::map for the reason indicated
in the comment. This was causing nondeterministic changes
in inlining decisions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101503 91177308-0d34-0410-b5e6-96231b3b80d8
52d55bd224ac08dfef959527ca8257f82a80dbb0 16-Apr-2010 Dan Gohman <gohman@apple.com> Make callIsSmall accessible as a utility function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101463 91177308-0d34-0410-b5e6-96231b3b80d8
005752bbe72868b548bba93dbc1ea46ffe8e5b2c 15-Apr-2010 Dan Gohman <gohman@apple.com> Make getPredecessorWithUniqueSuccessorForBB return the unique successor
in addition to the predecessor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101374 91177308-0d34-0410-b5e6-96231b3b80d8
0a60fa33210202a38a59ae3ea8681216f234ce51 15-Apr-2010 Dan Gohman <gohman@apple.com> Constify GetConstantStringInfo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101298 91177308-0d34-0410-b5e6-96231b3b80d8
53c66eacc417c0113fba7159487b90005dc8f91e 12-Apr-2010 Dan Gohman <gohman@apple.com> Enhance ScalarEvolution::isKnownPredicate with support for
loop conditions which are invariants.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100995 91177308-0d34-0410-b5e6-96231b3b80d8
e48172710bf78ae210b2257d6ac3e0e8fb3ba792 12-Apr-2010 Dan Gohman <gohman@apple.com> Fix a comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100992 91177308-0d34-0410-b5e6-96231b3b80d8
d908bbf7275d8ae67e918dc92ff9060a905eb27a 11-Apr-2010 Dan Gohman <gohman@apple.com> Fix a #include.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100980 91177308-0d34-0410-b5e6-96231b3b80d8
3948d0b8b0a71fabf25fceba1858b2b6a60d3d00 11-Apr-2010 Dan Gohman <gohman@apple.com> Rename isLoopGuardedByCond to isLoopEntryGuardedByCond, to emphasise
that it's only testing for the entry condition, not full loop-invariant

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100979 91177308-0d34-0410-b5e6-96231b3b80d8
113902e9fba5f4baf3de3c6ac0241d49ffdfa55c 08-Apr-2010 Dan Gohman <gohman@apple.com> Add a -lint pass which checks for common sources of undefined or likely
unintended behavior.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100798 91177308-0d34-0410-b5e6-96231b3b80d8
88ccf742a3a0d9ee7b68c767ea35292e1605f0bc 08-Apr-2010 Dan Gohman <gohman@apple.com> Fix a comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100783 91177308-0d34-0410-b5e6-96231b3b80d8
448db1cdef5872713ef77beffacf502ae3450cd7 08-Apr-2010 Dan Gohman <gohman@apple.com> Generalize IVUsers to track arbitrary expressions rather than expressions
explicitly split into stride-and-offset pairs. Also, add the
ability to track multiple post-increment loops on the same expression.

This refines the concept of "normalizing" SCEV expressions used for
to post-increment uses, and introduces a dedicated utility routine for
normalizing and denormalizing expressions.

This fixes the expansion of expressions which are post-increment users
of more than one loop at a time. More broadly, this takes LSR another
step closer to being able to reason about more than one loop at a time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100699 91177308-0d34-0410-b5e6-96231b3b80d8
5c8aa950fe3484b6e115647328c196f8be64f9ed 03-Apr-2010 David Greene <greened@obbligato.org> Ok, third time's the charm. No changes from last time except the CMake
source addition. Apparently the buildbots were wrong about failures.


Add some switches helpful for debugging:

-print-before=<Pass Name>

Dump IR before running pass <Pass Name>.


Dump IR before running each pass.


Dump IR after running each pass.

These are helpful when tracking down a miscompilation. It is easy to
get IR dumps and do diffs on them, etc.

To make this work well, add a new getPrinterPass API to Pass so that
each kind of pass (ModulePass, FunctionPass, etc.) can create a Pass
suitable for dumping out the kind of object the Pass works on.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100249 91177308-0d34-0410-b5e6-96231b3b80d8
de4845c163a5847c82d7ce10ed0c320098bce6e0 02-Apr-2010 Chris Lattner <sabre@nondot.org> Switch the code generator (except the JIT) onto the new DebugLoc
representation. This eliminates the 'DILocation' MDNodes for
file/line/col tuples from -O0 -g codegen.

This remove the old DebugLoc class, making it a typedef for DebugLoc,
I'll rename NewDebugLoc next.

I didn't update the JIT to use the new apis, so it will continue to
work, but be as slow as before. Someone should eventually do this
or, better yet, rip out the JIT debug info stuff and build the JIT
on top of MC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100209 91177308-0d34-0410-b5e6-96231b3b80d8
cf5862d8ac9562e633e6ef7cb55e67c2b7ca9c0a 02-Apr-2010 Evan Cheng <evan.cheng@apple.com> Revert 100204. It broke a bunch of tests and apparently changed what passes are run during codegen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100207 91177308-0d34-0410-b5e6-96231b3b80d8
434bd8551d71384648f2e155d76b5ddbc4d1b258 02-Apr-2010 David Greene <greened@obbligato.org> Let's try this again. Re-apply 100143 including an apparent missing
<string> include. For some reason the buildbot choked on this while my
builds did not. It's probably due to a difference in system headers.


Add some switches helpful for debugging:

-print-before=<Pass Name>

Dump IR before running pass <Pass Name>.


Dump IR before running each pass.


Dump IR after running each pass.

These are helpful when tracking down a miscompilation. It is easy to
get IR dumps and do diffs on them, etc.

To make this work well, add a new getPrinterPass API to Pass so that
each kind of pass (ModulePass, FunctionPass, etc.) can create a Pass
suitable for dumping out the kind of object the Pass works on.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100204 91177308-0d34-0410-b5e6-96231b3b80d8
1d8f83d0a00e912c55ec0974eba6122666cc6fa1 02-Apr-2010 Eric Christopher <echristo@apple.com> Revert r100143.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100146 91177308-0d34-0410-b5e6-96231b3b80d8
8ef3acba00c9c42d450fa52c7d3faebce1e507dd 02-Apr-2010 David Greene <greened@obbligato.org> Add some switches helpful for debugging:

-print-before=<Pass Name>

Dump IR before running pass <Pass Name>.


Dump IR before running each pass.


Dump IR after running each pass.

These are helpful when tracking down a miscompilation. It is easy to
get IR dumps and do diffs on them, etc.

To make this work well, add a new getPrinterPass API to Pass so that
each kind of pass (ModulePass, FunctionPass, etc.) can create a Pass
suitable for dumping out the kind of object the Pass works on.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100143 91177308-0d34-0410-b5e6-96231b3b80d8
8fe7979c416cc5aad167329a2d7e7f5000f445fe 24-Mar-2010 Devang Patel <dpatel@apple.com> Do not rely on getCompileUnit() to find source file information for a subprogram.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99410 91177308-0d34-0410-b5e6-96231b3b80d8
92d7b35bd07f590f6767398294cc7587ccb73f24 24-Mar-2010 Dan Gohman <gohman@apple.com> Fix coding style.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99362 91177308-0d34-0410-b5e6-96231b3b80d8
66617633e7dcc14d8808d3118766916b2240722a 24-Mar-2010 Dan Gohman <gohman@apple.com> Generalize findNearestCommonDominator to work on post-dominators,
based on a suggestion by Jochen Wilhelmy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99361 91177308-0d34-0410-b5e6-96231b3b80d8
472fdf7090bb00af3a3f9dcbe22263120a527533 20-Mar-2010 Dan Gohman <gohman@apple.com> Clear the SCEVExpander's insertion point after making deletions,
so that the SCEVExpander doesn't retain a dangling pointer as its
insert position. The dangling pointer in this case wasn't ever used
to insert new instructions, but it was causing trouble with
SCEVExpander's code for automatically advancing its insert position
past debug intrinsics.

This fixes use-after-free errors that valgrind noticed in
test/Transforms/IndVarSimplify/2007-06-06-DeleteDanglesPtr.ll and

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99036 91177308-0d34-0410-b5e6-96231b3b80d8
6c7ed6b54949949806797bafdf545fbfecb2cef5 19-Mar-2010 Dan Gohman <gohman@apple.com> Fix more places to more thoroughly ignore debug intrinsics. This fixes
use-before-def errors in SCEVExpander-produced code in sqlite3 when debug
info with optimization is enabled, though the testcases for this are
dependent on use-list order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99001 91177308-0d34-0410-b5e6-96231b3b80d8
c93b4cff89d85a13d4eaf1551af9fab276b88450 18-Mar-2010 Dan Gohman <gohman@apple.com> Add the ability to "intern" FoldingSetNodeID data into a
BumpPtrAllocator-allocated region to allow it to be stored in a more
compact form and to avoid the need for a non-trivial destructor call.

Use this new mechanism in ScalarEvolution instead of
FastFoldingSetNode to avoid leaking memory in the case where a
FoldingSetNodeID uses heap storage, and to reduce overall memory

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98829 91177308-0d34-0410-b5e6-96231b3b80d8
f9e64729afec646fe93b51417e66e552e8e630a4 18-Mar-2010 Dan Gohman <gohman@apple.com> Reapply r98755 with a thinko which miscompiled gengtype fixed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98793 91177308-0d34-0410-b5e6-96231b3b80d8
ebf78f18df84a63295c748148f54f091234ed099 17-Mar-2010 Dan Gohman <gohman@apple.com> Revert 98755, which may be causing trouble.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98762 91177308-0d34-0410-b5e6-96231b3b80d8
0afc29c3e6ba240ee187fd34ba1ecbe1175c879e 17-Mar-2010 Dan Gohman <gohman@apple.com> Change SCEVNAryExpr's operand array from a SmallVector to a plain
pointer and length, and allocate the arrays in ScalarEvolution's
BumpPtrAllocator, so that they get released when their owning
SCEV gets released. SCEVs are immutable, so they don't need to worry
about operand array resizing. This fixes a memory leak reported
in PR6637.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98755 91177308-0d34-0410-b5e6-96231b3b80d8
f96769bed208b8a3f82b53771350dc0a743db85a 13-Mar-2010 Devang Patel <dpatel@apple.com> Remove extra parameter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98403 91177308-0d34-0410-b5e6-96231b3b80d8
cbd056074cfcd79265ee1e04e83f347355e9ad61 13-Mar-2010 Devang Patel <dpatel@apple.com> Do not overestimate code size reduction in presense of debug info.
Use CodeMetrics.analyzeBasicBlock() to estimate BB size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98401 91177308-0d34-0410-b5e6-96231b3b80d8
bbf81d88116d23fb0776412b5916f7d0b8b3ca7e 10-Mar-2010 Dan Gohman <gohman@apple.com> Add a DominatorTree argument to isLCSSA so that it doesn't have to
compute a set of reachable blocks for itself each time it is called, which
is fairly frequently.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98179 91177308-0d34-0410-b5e6-96231b3b80d8
f7477470d37ee2ab9075eaee4745fa084d424ab8 10-Mar-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Try to keep the cached inliner costs around for a bit longer for big functions.

The Caller cost info would be reset everytime a callee was inlined. If the
caller has lots of calls and there is some mutual recursion going on, the
caller cost info could be calculated many times.

This patch reduces inliner runtime from 240s to 0.5s for a function with 20000
small function calls.

This is a more conservative version of r98089 that doesn't break the clang
test CodeGenCXX/temp-order.cpp. That test relies on rather extreme inlining
for constant folding.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98099 91177308-0d34-0410-b5e6-96231b3b80d8
b5a158bab81b0b3f15d409fc433e706f8e885375 09-Mar-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Revert r98089, it was breaking a clang test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98094 91177308-0d34-0410-b5e6-96231b3b80d8
9e5d87d568498db251de19cd3c26d02cc74bb2e1 09-Mar-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Try to keep the cached inliner costs around for a bit longer for big functions.

The Caller cost info would be reset everytime a callee was inlined. If the
caller has lots of calls and there is some mutual recursion going on, the
caller cost info could be calculated many times.

This patch reduces inliner runtime from 240s to 0.5s for a function with 20000
small function calls.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98089 91177308-0d34-0410-b5e6-96231b3b80d8
4b945500a5eb1b32ee8004e40e386105ee5815eb 09-Mar-2010 Devang Patel <dpatel@apple.com> Start using DIFile. See updated SourceLevelDebugging.html for more information.

This patch updates LLVMDebugVersion to 8.
Debug info descriptors encoded using LLVMDebugVersion 7 is supported.

Corresponding llvmgcc and clang FE commits are required.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98020 91177308-0d34-0410-b5e6-96231b3b80d8
7aa81897066a20ace12c8f61ae0e5a253fb64dc2 08-Mar-2010 Devang Patel <dpatel@apple.com> Introduce DIFile. This will be used to represent header files and source file(s) in debug info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97994 91177308-0d34-0410-b5e6-96231b3b80d8
77bf295dbb0b049fdec853ced0763084c43b2438 08-Mar-2010 Devang Patel <dpatel@apple.com> Derive DIType from DIScope. This simplifies getContext() where for members the context is a type. This also eliminates need of CompileUnitMaps maintained by dwarf writer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97990 91177308-0d34-0410-b5e6-96231b3b80d8
f17f5ebbdcd67966f7841c3597d750756d5bbd38 08-Mar-2010 Devang Patel <dpatel@apple.com> Remove DbgNode checks in constructor. Debug descriptors are intended to be light weight wrappers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97988 91177308-0d34-0410-b5e6-96231b3b80d8
9dcd6f14f8c559601fa2ad1ff168dcc236f7ce05 08-Mar-2010 Devang Patel <dpatel@apple.com> isNull() is not used any more.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97979 91177308-0d34-0410-b5e6-96231b3b80d8
3c91b05d2b1751b9e4e21fd958d358ec463dcd3c 08-Mar-2010 Devang Patel <dpatel@apple.com> Avoid using DIDescriptor.isNull().
This is a first step towards eliminating checks in Descriptor constructors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97975 91177308-0d34-0410-b5e6-96231b3b80d8
0ef3fa6aabc80995c8a0bd829c85c89ef2d4c32d 08-Mar-2010 Devang Patel <dpatel@apple.com> Revert r97947.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97963 91177308-0d34-0410-b5e6-96231b3b80d8
d8cc5d5256e79a74188dfef5a12d43127330dad3 08-Mar-2010 Devang Patel <dpatel@apple.com> Avoid using DIDescriptor.isNull().
This is a first step towards eliminating unncessary constructor checks in light weight DIDescriptor wrappers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97947 91177308-0d34-0410-b5e6-96231b3b80d8
8f9db4c1d58114f54b585251f5bf61a498613b7c 07-Mar-2010 Tobias Grosser <grosser@fim.uni-passau.de> Add findNearestCommonDominator() for PostDominators.

Add a missing interface to be able to call findNearestCommonDominator
for a PostDominanceTree. The function itself is already implemented in
DominatorTreeBase. The interface however was only added to the
DominatorTree class, but not the PostDominatorClass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97915 91177308-0d34-0410-b5e6-96231b3b80d8
25ec483cfca8d3a3ba8728a4a126e04b92789069 05-Mar-2010 Eric Christopher <echristo@apple.com> Move GetStringLength and helper from SimplifyLibCalls to ValueTracking.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97793 91177308-0d34-0410-b5e6-96231b3b80d8
a9cf19670f50095eac7191a5360ed03839e87465 01-Mar-2010 Chris Lattner <sabre@nondot.org> remove anders-aa from mainline, it isn't maintained and is
tantalyzing enough that people keep trying to use it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97483 91177308-0d34-0410-b5e6-96231b3b80d8
3f46a3abeedba8d517b4182de34c821d752db058 01-Mar-2010 Dan Gohman <gohman@apple.com> Spelling fixes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97453 91177308-0d34-0410-b5e6-96231b3b80d8
67d9bf9dc4df036aad330ba5cdb663d8a7c4af11 01-Mar-2010 Dan Gohman <gohman@apple.com> Whitespace cleanups.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97452 91177308-0d34-0410-b5e6-96231b3b80d8
f6d009fb6fc19d9f7ee7cdc528bf8e83a758facc 24-Feb-2010 Dan Gohman <gohman@apple.com> Convert a few more backedge-taken count functions to use BackedgeTakenInfo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97042 91177308-0d34-0410-b5e6-96231b3b80d8
6d8f2ca646bc283c31f48b6816d5194c836dfec6 24-Feb-2010 Daniel Dunbar <daniel@zuster.org> Reapply r97010, the speculative revert failed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97036 91177308-0d34-0410-b5e6-96231b3b80d8
8c0c99016b4348bf9cc294a0f2dd60a219d4506c 24-Feb-2010 Daniel Dunbar <daniel@zuster.org> Speculatively revert r97010, "Add an argument to PHITranslateValue to specify
the DominatorTree. ...", in hopes of restoring poor old PPC bootstrap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97027 91177308-0d34-0410-b5e6-96231b3b80d8
9d2ed8e632b71914b2a668932f4f49b87c3ca0b1 24-Feb-2010 Bob Wilson <bob.wilson@apple.com> Add an argument to PHITranslateValue to specify the DominatorTree. If this
argument is non-null, pass it along to PHITranslateSubExpr so that it can
prefer using existing values that dominate the PredBB, instead of just
blindly picking the first equivalent value that it finds on a uselist.
Also when the DominatorTree is specified, have PHITranslateValue filter
out any result that does not dominate the PredBB. This is basically just
refactoring the check that used to be in GetAvailablePHITranslatedSubExpr
and also in GVN.

Despite my initial expectations, this change does not affect the results
of GVN for any testcases that I could find, but it should help compile time.
Before this change, if PHITranslateSubExpr picked a value that does not
dominate, PHITranslateWithInsertion would then insert a new value, which GVN
would later determine to be redundant and would replace. By picking a good
value to begin with, we save GVN the extra work of inserting and then
replacing a new value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97010 91177308-0d34-0410-b5e6-96231b3b80d8
31a95c524c82e36867761404d902b94f7afc695e 22-Feb-2010 Dan Gohman <gohman@apple.com> Rename a variable to avoid a -Wshadow warning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96776 91177308-0d34-0410-b5e6-96231b3b80d8
45a2d7d44ae697e28df383d31455145fb754ac58 19-Feb-2010 Dale Johannesen <dalej@apple.com> recommit 96626, evidence that it broke things appears
to be spurious

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96662 91177308-0d34-0410-b5e6-96231b3b80d8
efd9e9505167a398ba3c4924b09a47bd4d688e51 19-Feb-2010 Dale Johannesen <dalej@apple.com> Revert 96626, which causes build failure on ppc Darwin.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96653 91177308-0d34-0410-b5e6-96231b3b80d8
aa11defd1c66dbde0c757c99791c4ae4d740fc3e 19-Feb-2010 Dan Gohman <gohman@apple.com> Indvars needs to explicitly notify ScalarEvolution when it is replacing
a loop exit value, so that if a loop gets deleted, ScalarEvolution
isn't stick holding on to dangling SCEVAddRecExprs for that loop. This
fixes PR6339.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96626 91177308-0d34-0410-b5e6-96231b3b80d8
3d821aaae238534132df3982d703e758e91472cf 16-Feb-2010 Devang Patel <dpatel@apple.com> Use line and column number to distinguish two lexical blocks at the same level.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96395 91177308-0d34-0410-b5e6-96231b3b80d8
484d4a30c055eef3101d01a7a468db3413dd20d3 16-Feb-2010 Bob Wilson <bob.wilson@apple.com> Split critical edges as needed for load PRE.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96378 91177308-0d34-0410-b5e6-96231b3b80d8
455985501381777db03534c925a35e261e356395 15-Feb-2010 Dan Gohman <gohman@apple.com> When restoring a saved insert location, check to see if the saved
insert location has become an "inserted" instruction since the time
it was saved. If so, advance to the first non-"inserted" instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96203 91177308-0d34-0410-b5e6-96231b3b80d8
1d826a76f591afea445489b9a5485c345e66bf87 14-Feb-2010 Dan Gohman <gohman@apple.com> In rememberInstruction, if the value being remembered is the
current insertion point, advance the current insertion point.
This avoids a use-before-def situation in a testcase extracted
from clang which is difficult to reduce to a reasonable-sized
regression test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96151 91177308-0d34-0410-b5e6-96231b3b80d8
9269926bfb713e92e328e9578c6d8826c68dcb9d 14-Feb-2010 Dan Gohman <gohman@apple.com> Remove a 'protected' keyword, now that SCEVExpander is no longer
intended to be subclassed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96149 91177308-0d34-0410-b5e6-96231b3b80d8
39125d8ef94cbadccd7339d3344e114dedaab12c 13-Feb-2010 Dan Gohman <gohman@apple.com> Override dominates and properlyDominates for SCEVAddRecExpr, as a
SCEVAddRecExpr doesn't necessarily dominate blocks merely dominated
by all of its operands. This fixes an abort compiling 403.gcc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96056 91177308-0d34-0410-b5e6-96231b3b80d8
572645cf84060c0fc25cb91d38cb9079918b3a88 12-Feb-2010 Dan Gohman <gohman@apple.com> Reapply the new LoopStrengthReduction code, with compile time and
bug fixes, and with improved heuristics for analyzing foreign-loop

This change also flattens IVUsers, eliminating the stride-oriented
groupings, which makes it easier to work with.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95975 91177308-0d34-0410-b5e6-96231b3b80d8
f451cb870efcf9e0302d25ed05f4cac6bb494e42 10-Feb-2010 Dan Gohman <gohman@apple.com> Fix "the the" and similar typos.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95781 91177308-0d34-0410-b5e6-96231b3b80d8
c056baed8704bd715ee58e5dfe724c255e68abbd 10-Feb-2010 Dan Gohman <gohman@apple.com> Minor code simplification.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95780 91177308-0d34-0410-b5e6-96231b3b80d8
b14bc1f6f82c7f650226f39ed0256d8189eb2a1b 09-Feb-2010 Dan Gohman <gohman@apple.com> Mention IndVarSimplify in the comment by getSmallConstantTripCount, as
is done for getTripCount.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95666 91177308-0d34-0410-b5e6-96231b3b80d8
baf0c67988feec5b7698f89dce499ddb7d0c3c42 08-Feb-2010 Dan Gohman <gohman@apple.com> Add const qualifiers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95582 91177308-0d34-0410-b5e6-96231b3b80d8
b4645643de240e5b3461b03a9c6950fefe1538ac 06-Feb-2010 Devang Patel <dpatel@apple.com> Set DW_AT_artificial only if argument is marked as artificial.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95461 91177308-0d34-0410-b5e6-96231b3b80d8
aa034fa2299e41b73f60d3993f5460260e239fab 06-Feb-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Update CodeMetrics to count 'big' function calls explicitly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95453 91177308-0d34-0410-b5e6-96231b3b80d8
32efba698df6aa35335eeb44d89288352d04746d 04-Feb-2010 Dan Gohman <gohman@apple.com> Change the argument to getIntegerSCEV to be an int64_t, rather
than int. This will make it more convenient for LSR, which does
a lot of things with int64_t offsets.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95281 91177308-0d34-0410-b5e6-96231b3b80d8
4e0d19dfd9ab77f9974cb07320dfe4f7f5ffd7b9 03-Feb-2010 Devang Patel <dpatel@apple.com> Provide interface to identifiy artificial methods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95240 91177308-0d34-0410-b5e6-96231b3b80d8
ebdcbc26c77b97483afbcb906f988cc66d43606d 02-Feb-2010 Dan Gohman <gohman@apple.com> Fix function names in comments. Thanks Duncan!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95126 91177308-0d34-0410-b5e6-96231b3b80d8
f7d848349e25f470e63bc176d4d120bdcf0e1649 01-Feb-2010 Bill Wendling <isanbard@gmail.com> Add "dump" method to IVUsersOneStride.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95022 91177308-0d34-0410-b5e6-96231b3b80d8
4f8eea82d8967cffa85b9df6c9255717b059009e 01-Feb-2010 Dan Gohman <gohman@apple.com> Generalize target-independent folding rules for sizeof to handle more
cases, and implement target-independent folding rules for alignof and
offsetof. Also, reassociate reassociative operators when it leads to
more folding.

Generalize ScalarEvolution's isOffsetOf to recognize offsetof on
arrays. Rename getAllocSizeExpr to getSizeOfExpr, and getFieldOffsetExpr
to getOffsetOfExpr, for consistency with analagous ConstantExpr routines.

Make the target-dependent folder promote GEP array indices to
pointer-sized integers, to make implicit casting explicit and exposed
to subsequent folding.

And add a bunch of testcases for this new functionality, and a bunch
of related existing functionality.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94987 91177308-0d34-0410-b5e6-96231b3b80d8
0f5efe56258f8cd6ceff4d7955a5d80144cd9cb0 28-Jan-2010 Dan Gohman <gohman@apple.com> Remove SCEVAllocSizeExpr and SCEVFieldOffsetExpr, and in their place
use plain SCEVUnknowns with ConstantExpr::getSizeOf and
ConstantExpr::getOffsetOf constants. This eliminates a bunch of
special-case code.

Also add code for pattern-matching these expressions, for clients that
want to recognize them.

Move ScalarEvolution's logic for expanding array and vector sizeof
expressions into an element count times the element size, to expose
the multiplication to subsequent folding, into the regular constant

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94737 91177308-0d34-0410-b5e6-96231b3b80d8
43cda021d9425f53443b3d56bcf81afe99353ee9 27-Jan-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Fix inline cost predictions with SCIENCE.

After running a batch of measurements, it is clear that the inliner metrics
need some adjustments:

Own argument bonus: 20 -> 5
Outgoing argument penalty: 0 -> 5
Alloca bonus: 10 -> 5
Constant instr bonus: 7 -> 5
Dead successor bonus: 40 -> 5*(avg instrs/block)

The new cost metrics are generaly 25 points higher than before, so we may need
to move thresholds.

With this change, InlineConstants::CallPenalty becomes a political correction:

if (!isa<IntrinsicInst>(II) && !callIsSmall(CS.getCalledFunction()))
NumInsts += InlineConstants::CallPenalty + CS.arg_size();

The code size is accurately modelled by CS.arg_size(). CallPenalty is added
because calls tend to take a long time, so it may not be worth it to inline a
function with lots of calls.

All of the political corrections are in the InlineConstants namespace:
IndirectCallBonus, CallPenalty, LastCallToStaticBonus, ColdccPenalty,

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94615 91177308-0d34-0410-b5e6-96231b3b80d8
0fd7f9d7ffea48aa9c4965132ade33cf28f973ea 26-Jan-2010 Devang Patel <dpatel@apple.com> Add extra element to composite type. This new element will be used to record c++ class that holds current class's vtable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94586 91177308-0d34-0410-b5e6-96231b3b80d8
2e369930dc9e36728f7953a238d63925d3660612 23-Jan-2010 Devang Patel <dpatel@apple.com> Avoid using "Type" as the variable name.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94262 91177308-0d34-0410-b5e6-96231b3b80d8
476e9bd1146624fa17243ae55fdb156f905ba3d4 22-Jan-2010 Chris Lattner <sabre@nondot.org> elimiante the dynamic_cast's from opt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94160 91177308-0d34-0410-b5e6-96231b3b80d8
3660ecabbb85b31308f38938ce3f56f0a330a84b 22-Jan-2010 Chris Lattner <sabre@nondot.org> eliminate a bunch of dynamic_cast's.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94155 91177308-0d34-0410-b5e6-96231b3b80d8
7979b72febb73f7bb1d1ed095a68f210822b2e7c 22-Jan-2010 Dan Gohman <gohman@apple.com> Revert LoopStrengthReduce.cpp to pre-r94061 for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94123 91177308-0d34-0410-b5e6-96231b3b80d8
629bff692ae96dea517dc854e27b57ee6c8729ef 21-Jan-2010 Benjamin Kramer <benny.kra@googlemail.com> struct/class mismatch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94075 91177308-0d34-0410-b5e6-96231b3b80d8
a10756ee657a4d43a48cca5c166919093930ed6b 21-Jan-2010 Dan Gohman <gohman@apple.com> Re-implement the main strength-reduction portion of LoopStrengthReduction.
This new version is much more aggressive about doing "full" reduction in
cases where it reduces register pressure, and also more aggressive about
rewriting induction variables to count down (or up) to zero when doing so
reduces register pressure.

It currently uses fairly simplistic algorithms for finding reuse
opportunities, but it introduces a new framework allows it to combine
multiple strategies at once to form hybrid solutions, instead of doing
all full-reduction or all base+index.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94061 91177308-0d34-0410-b5e6-96231b3b80d8
2b98bd23cb0bfa0dc09e1bcaef83a0e606e6ec1a 19-Jan-2010 Dan Gohman <gohman@apple.com> Make SCEVAddRecExpr's getType return a pointer type when the add
has a pointer member. This helps reduce unnecessary bitcasting
and uglygeps.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93939 91177308-0d34-0410-b5e6-96231b3b80d8
1cd9275c8d612bd1c92fc7ba436b60aaead1efbf 19-Jan-2010 Dan Gohman <gohman@apple.com> Give ScalarEvolution access to the DominatorTree. It'll need this
to make more intellegent AddRec folding decisions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93930 91177308-0d34-0410-b5e6-96231b3b80d8
bafbbdde38dedf05b53b731cbc083b2c483ae64e 19-Jan-2010 Dan Gohman <gohman@apple.com> Add a new helper function to IVUsers for returning the "canonical"
form of an expression. This is the expression without the
post-increment adjustment made, which is useful in determining
which registers will be used by the expansion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93921 91177308-0d34-0410-b5e6-96231b3b80d8
9a7313af77e81fe894debafd8c93e2551a74d1a6 19-Jan-2010 Chris Lattner <sabre@nondot.org> remove extraneous ;

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93833 91177308-0d34-0410-b5e6-96231b3b80d8
756462bfbd668c6c6afe74ce20d29b77ce20ab9b 18-Jan-2010 Victor Hernandez <vhernandez@apple.com> Make findDbgDeclare/findDbgGlobalDeclare local static functions; avoid Elts array

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93764 91177308-0d34-0410-b5e6-96231b3b80d8
24dcbaf75618277b049ddf488a37ede3177613dc 16-Jan-2010 Tobias Grosser <grosser@fim.uni-passau.de> Fix PR6047

Nodes that had children outside of the post dominator tree (infinite loops)
where removed from the post dominator tree. This seems to be wrong. Leave them
in the tree.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93633 91177308-0d34-0410-b5e6-96231b3b80d8
23279f18a9759d94579de7e79be61c7aa790b8ba 16-Jan-2010 Tobias Grosser <grosser@fim.uni-passau.de> Create Generic DOTGraphTraits Printer/Viewer

Move the DOTGraphTraits dotty printer/viewer templates, that were developed for
the dominance tree into their own header file. This will allow reuse in future

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93632 91177308-0d34-0410-b5e6-96231b3b80d8
3a32865d58f015e7058444eab7085195c34da95a 15-Jan-2010 Victor Hernandez <vhernandez@apple.com> Improve llvm.dbg.declare intrinsic by referring directly to the storage in its first argument, via function-local metadata (instead of via a bitcast).
This patch also cleans up code that expects there to be a bitcast in the first argument and testcases that call llvm.dbg.declare.
It also strips old llvm.dbg.declare intrinsics that did not pass metadata as the first argument.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93531 91177308-0d34-0410-b5e6-96231b3b80d8
5f03238d629c32bb0bab78d112a42293838558e9 15-Jan-2010 Victor Hernandez <vhernandez@apple.com> Revert r93504 because older uses of llvm.dbg.declare intrinsics need to be auto-upgraded

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93515 91177308-0d34-0410-b5e6-96231b3b80d8
283ba2fbb4a40d5f7615aba070f2f7ec161d19ac 15-Jan-2010 Victor Hernandez <vhernandez@apple.com> Improve llvm.dbg.declare intrinsic by referring directly to the storage in its first argument, via function-local metadata (instead of via a bitcast).
This patch also cleans up code that expects there to be a bitcast in the first argument and testcases that call llvm.dbg.declare.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93504 91177308-0d34-0410-b5e6-96231b3b80d8
d53e42efe93f6a716d082ad63862794da0e59895 11-Jan-2010 Tobias Grosser <grosser@fim.uni-passau.de> Remove trailing white spaces in post dominators header file

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93195 91177308-0d34-0410-b5e6-96231b3b80d8
af4421d6efff5a1c91e7669933738487c609238b 11-Jan-2010 Tobias Grosser <grosser@fim.uni-passau.de> Add getNode() to post dominators.

Implement the same interface as already available for dominators.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93194 91177308-0d34-0410-b5e6-96231b3b80d8
5b7e48b56cfc0904636a0a1c0d4f7b81133c48c2 11-Jan-2010 Victor Hernandez <vhernandez@apple.com> Respond to Chris' review:
Make InsertDbgValueIntrinsic() and get Offset take and recieve a uint64_t.
Get constness correct for getVariable() and getValue().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93149 91177308-0d34-0410-b5e6-96231b3b80d8
fde781b8d6020c78bb2f3a59845dba251e84808d 08-Jan-2010 Tobias Grosser <grosser@fim.uni-passau.de> Add assert to check dominance dfs numbers.

Compare the dominance information calculated using a dominance tree walk to the
information calculated based on DFS numbers, if XDEBUG is enabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92969 91177308-0d34-0410-b5e6-96231b3b80d8
365ccd3a919b017f79140028dac15ef0c70641dd 08-Jan-2010 Tobias Grosser <grosser@fim.uni-passau.de> Remove workaround in PostDominators

Remove a FIXME and unify code that was necessary to work around broken
updateDFSNumbers(). Before updateDFSNumbers() did not work correctly for post

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92968 91177308-0d34-0410-b5e6-96231b3b80d8
ecd4694458796d8d9dd205a8eb43ff7163425bca 08-Jan-2010 Tobias Grosser <grosser@fim.uni-passau.de> Fix DFS number calculation for postdominators

The DFS number calculation for postdominators was broken. In the case of
multiple exits that form the post dominator root nodes, do not iterate over
all exits, but start from the virtual root node. Otherwise bbs, that are not
post dominated by any exit but by the virtual root node, will never be assigned
a DFS number.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92967 91177308-0d34-0410-b5e6-96231b3b80d8
b419a5cfe9fae934d6c05da173934673f5402c99 06-Jan-2010 Douglas Gregor <dgregor@apple.com> Fix struct/class mismatch

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92841 91177308-0d34-0410-b5e6-96231b3b80d8
7c422ac216fe39fc9c402a704cf296cca9dc5b22 06-Jan-2010 Duncan Sands <baldrick@free.fr> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92829 91177308-0d34-0410-b5e6-96231b3b80d8
dda30cd4af1c5f88fc00fd40b673f8e27c61379d 05-Jan-2010 Dan Gohman <gohman@apple.com> Restore dump() methods to Loop and MachineLoop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92772 91177308-0d34-0410-b5e6-96231b3b80d8
44a29e066a24e88bdf127e88be4380a5f259c4b4 05-Jan-2010 Devang Patel <dpatel@apple.com> Remove dead debug info intrinsics.
AutoUpgrade simply ignores these intrinsics now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92557 91177308-0d34-0410-b5e6-96231b3b80d8
210d0febc24551aed293b903562c19567e96fa5d 31-Dec-2009 Chris Lattner <sabre@nondot.org> this #include is ok.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92338 91177308-0d34-0410-b5e6-96231b3b80d8
f0908a351ab123a1ad7b145a5e4bc28430be0d94 31-Dec-2009 Chris Lattner <sabre@nondot.org> fix Analysis/DebugInfo.h to not include Metadata.h. Do this
by moving one method out of line and eliminating redundant checks
from other methods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92337 91177308-0d34-0410-b5e6-96231b3b80d8
5d0cacdbb6577f2449986f345858db17dc1bcf59 31-Dec-2009 Chris Lattner <sabre@nondot.org> rename "elements" of metadata to "operands". "Elements" are
things that occur in types. "operands" are things that occur
in values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92322 91177308-0d34-0410-b5e6-96231b3b80d8
bf0ca2b477e761e2c81f6c36d6c7bec055933b15 29-Dec-2009 Chris Lattner <sabre@nondot.org> remove a bunch of unneeded functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92263 91177308-0d34-0410-b5e6-96231b3b80d8
784b850e320c783ce402d5d8bbbb4b0a3ad4b69c 29-Dec-2009 Chris Lattner <sabre@nondot.org> one pass of cleanup over DebugInfo.h. Much more is still needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92261 91177308-0d34-0410-b5e6-96231b3b80d8
63c9463c62fce8cbe02176dfa2d73f375a06f1f2 23-Dec-2009 David Greene <greened@obbligato.org> Remove dump routine and the associated Debug.h from a header. Patch up
other files to compensate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92075 91177308-0d34-0410-b5e6-96231b3b80d8
49f253315dbe1f3c14c0ce6d5236089acb92f80f 23-Dec-2009 David Greene <greened@obbligato.org> Convert debug messages to use dbgs(). Generally this means
s/errs/dbgs/g except for certain special cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92013 91177308-0d34-0410-b5e6-96231b3b80d8
3fb10ac22f22568e07df720d190b4e08ca69833c 23-Dec-2009 David Greene <greened@obbligato.org> Convert debug messages to use dbgs(). Generally this means
s/errs/dbgs/g except for certain special cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92006 91177308-0d34-0410-b5e6-96231b3b80d8
0ee443d169786017d151034b8bd34225bc144c98 22-Dec-2009 Chris Lattner <sabre@nondot.org> The phi translated pointer can be computed when returning a partially cached result
instead of stored. This reduces memdep memory usage, and also eliminates a bunch of
weakvh's. This speeds up gvn on gcc.c-torture/20001226-1.c from 23.9s to 8.45s (2.8x)
on a different machine than earlier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91885 91177308-0d34-0410-b5e6-96231b3b80d8
43ea505fb07e303721d92f2b2bdda6e601868523 19-Dec-2009 Dan Gohman <gohman@apple.com> Eliminate unnecessary LLVMContexts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91729 91177308-0d34-0410-b5e6-96231b3b80d8
d281ed2d03654b9cdb290a2d7c73dfe7b826e554 18-Dec-2009 Dan Gohman <gohman@apple.com> Preserve NSW information in more places.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91656 91177308-0d34-0410-b5e6-96231b3b80d8
92329c7fbe572892c17aa2d2542a10e3ea16132f 18-Dec-2009 Dan Gohman <gohman@apple.com> Add Loop contains utility methods for testing whether a loop
contains another loop, or an instruction. The loop form is
substantially more efficient on large loops than the typical
code it replaces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91654 91177308-0d34-0410-b5e6-96231b3b80d8
6bec5bb344fc0374431aed1cb63418de607a1aec 18-Dec-2009 Dan Gohman <gohman@apple.com> Reapply LoopStrengthReduce and IVUsers cleanups, excluding the part
of 91296 that caused trouble -- the Processed list needs to be
preserved for the livetime of the pass, as AddUsersIfInteresting
is called from other passes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91641 91177308-0d34-0410-b5e6-96231b3b80d8
04149f7ffd033773adfe85e4acf3f560e29bd47d 17-Dec-2009 Evan Cheng <evan.cheng@apple.com> Revert 91280-91283, 91286-91289, 91291, 91293, 91295-91296. It apparently introduced a non-deterministic behavior in the optimizer somewhere.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91598 91177308-0d34-0410-b5e6-96231b3b80d8
6404e4e7958aa71ff210008b0e5d1cef8d138ff2 15-Dec-2009 Devang Patel <dpatel@apple.com> Add support to emit debug info for C++ namespaces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91440 91177308-0d34-0410-b5e6-96231b3b80d8
4bbf4ee1491637c247e195e19e3e4a8ee5ad72fa 15-Dec-2009 Chris Lattner <sabre@nondot.org> Remove isPod() from DenseMapInfo, splitting it out to its own
isPodLike type trait. This is a generally useful type trait for
more than just DenseMap, and we really care about whether something
acts like a pod, not whether it really is a pod.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91421 91177308-0d34-0410-b5e6-96231b3b80d8
35d913e6f3ff9267bb130c918d1286156e18797d 14-Dec-2009 Dan Gohman <gohman@apple.com> Make the IVUses member private.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91291 91177308-0d34-0410-b5e6-96231b3b80d8
440b40d86521305d631e6461314540f54659d4a2 14-Dec-2009 Dan Gohman <gohman@apple.com> Drop Loop::isNotAlreadyContainedIn in favor of Loop::contains. The
former was just exposing a LoopInfoBase implementation detail.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91286 91177308-0d34-0410-b5e6-96231b3b80d8
050959cd08db6c0efb8208271a1d64ce58893e20 11-Dec-2009 Dan Gohman <gohman@apple.com> Make getUniqueExitBlocks's precondition assert more precise, to
avoid spurious failures. This fixes PR5758.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91147 91177308-0d34-0410-b5e6-96231b3b80d8
dad451cb7c6b94b3af40f59271e24357616a05a9 09-Dec-2009 Chris Lattner <sabre@nondot.org> enhance NonLocalDepEntry to keep the per-block phi translated address
of the query.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90958 91177308-0d34-0410-b5e6-96231b3b80d8
e18b97121c286eeff5efe89150b093bf1b7b7bfc 09-Dec-2009 Chris Lattner <sabre@nondot.org> change NonLocalDepEntry from being a typedef for an std::pair to be its
own small class. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90956 91177308-0d34-0410-b5e6-96231b3b80d8
05e15f8897bd949f9d4bce073d53ed3256c71e2b 09-Dec-2009 Chris Lattner <sabre@nondot.org> Switch GVN and memdep to use PHITransAddr, which correctly handles
phi translation of complex expressions like &A[i+1]. This has the
following benefits:

1. The phi translation logic is all contained in its own class with
a strong interface and verification that it is self consistent.

2. The logic is more correct than before. Previously, if intermediate
expressions got PHI translated, we'd miss the update and scan for
the wrong pointers in predecessor blocks. @phi_trans2 is a testcase
for this.

3. We have a lot less code in memdep.

We can handle phi translation across blocks of things like @phi_trans3,
which is pretty insane :).

This patch should fix the miscompiles of 255.vortex, and I tested it
with a bootstrap of llvm-gcc, llvm-test and dejagnu of course.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90926 91177308-0d34-0410-b5e6-96231b3b80d8
6200e53f55536f812153ad910e6a69139592301b 09-Dec-2009 Chris Lattner <sabre@nondot.org> fix many input tracking bugs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90915 91177308-0d34-0410-b5e6-96231b3b80d8
af50315a29600188a6ff8b935beca6f1b59edf48 09-Dec-2009 Chris Lattner <sabre@nondot.org> instructions defined in CurBB may be intermediate nodes of the computation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90908 91177308-0d34-0410-b5e6-96231b3b80d8
7dedbf4ce3e1b62b4e0b000b38d244b50029c315 09-Dec-2009 Chris Lattner <sabre@nondot.org> add dumping and sanity checking support.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90906 91177308-0d34-0410-b5e6-96231b3b80d8
43678f41a37c077f28517c2e4889cca88cada6ce 09-Dec-2009 Chris Lattner <sabre@nondot.org> make sure that PHITransAddr keeps its 'InstInputs' list up to
date when instsimplify kicks in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90901 91177308-0d34-0410-b5e6-96231b3b80d8
0000fadb00cf971cd8ffb4ebe500777a84daf8f5 09-Dec-2009 Devang Patel <dpatel@apple.com> Revert 90858 90875 and 90805 for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90898 91177308-0d34-0410-b5e6-96231b3b80d8
34f849098bfb8850fa34fbd115ba9b2e55c85a32 08-Dec-2009 Chris Lattner <sabre@nondot.org> fix a typo (and -> add) and fix GetAvailablePHITranslatedSubExpr to not
side-effect the current object.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90837 91177308-0d34-0410-b5e6-96231b3b80d8
c59b33562c84cb627e456fa979df2242f81b5a87 07-Dec-2009 Victor Hernandez <vhernandez@apple.com> Rename DIFactory::InsertValue() as DIFactory::InsertDbgValueIntrinsic()

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90807 91177308-0d34-0410-b5e6-96231b3b80d8
4063f6bcc775bb0429dea2276694c4cdc2d4dca1 07-Dec-2009 Devang Patel <dpatel@apple.com> Add support to emit debug info for c++ style namespaces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90805 91177308-0d34-0410-b5e6-96231b3b80d8
e05a188cd630448cc25143ee8e69a36ab2e69544 07-Dec-2009 Chris Lattner <sabre@nondot.org> add accessor, improve comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90792 91177308-0d34-0410-b5e6-96231b3b80d8
2f9dac721d6b015fd16730bd51bffc86e29e6fdf 07-Dec-2009 Victor Hernandez <vhernandez@apple.com> Introduce the "@llvm.dbg.value" debug intrinsic.

The semantics of llvm.dbg.value are that starting from where it is executed, an offset into the specified user source variable is specified to get a new value.

An example:
call void @llvm.dbg.value(metadata !{ i32 7 }, i64 0, metadata !2)
Here the user source variable associated with metadata #2 gets the value "i32 7" at offset 0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90788 91177308-0d34-0410-b5e6-96231b3b80d8
9a8641201b2db8427be2a6531c043f384562c081 07-Dec-2009 Chris Lattner <sabre@nondot.org> checkpoint of the new PHITransAddr code, still not done and not used by

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90779 91177308-0d34-0410-b5e6-96231b3b80d8
4650d92748413e67004df52d7a0268df368a5b60 07-Dec-2009 John Mosby <ojomojo@gmail.com> fixed some typos in method comments, reworded some comments for clarity

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90754 91177308-0d34-0410-b5e6-96231b3b80d8
750e0e0ad0e599fe701e5492eef5c2cab05f2e5c 05-Dec-2009 Nick Lewycky <nicholas@mxc.ca> Document that memory use intrinsics may also return Def results.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90651 91177308-0d34-0410-b5e6-96231b3b80d8
210e45af3a579beeefb001c8f13c94e80407aad5 04-Dec-2009 Chris Lattner <sabre@nondot.org> add the start of a class used to handle phi translation in memdep and
gvn (this is just a skeleton so far). This will ultimately be used
to fix a nasty miscompilation with GVN.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90518 91177308-0d34-0410-b5e6-96231b3b80d8
5d11eb0ed54116b7f33507999617661fb2ae99df 03-Dec-2009 Devang Patel <dpatel@apple.com> Add support to emit debug info for virtual functions and virtual base classes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90474 91177308-0d34-0410-b5e6-96231b3b80d8
44299c9507dc25279741b28ade2d2efa0b8506ad 03-Dec-2009 Andreas Neustifter <astifter-llvm@gmx.at> Use ProfileInfo-API in ProfileInfo Loader and do more assertions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90446 91177308-0d34-0410-b5e6-96231b3b80d8
e2baf6b45549128c76a701c3edd8b4bb0b4835d4 03-Dec-2009 Andreas Neustifter <astifter-llvm@gmx.at> Converted ProfileInfo to template, added more API for ProfileInfo-preserving.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90445 91177308-0d34-0410-b5e6-96231b3b80d8
e3a18de4f66a90040fb67495578652e36a886af5 02-Dec-2009 Devang Patel <dpatel@apple.com> Add utility routine to create subprogram definition entry from subprogram declaration entry.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90282 91177308-0d34-0410-b5e6-96231b3b80d8
56f4ef3232850e29c4635d0923910acce8887bd0 30-Nov-2009 Tobias Grosser <grosser@fim.uni-passau.de> Remove ShortNames from getNodeLabel in DOTGraphTraits

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90134 91177308-0d34-0410-b5e6-96231b3b80d8
a10d598602308549d87d2c5d9848f5a72fda2b43 30-Nov-2009 Tobias Grosser <grosser@fim.uni-passau.de> Instantiate DefaultDOTGraphTraits

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90133 91177308-0d34-0410-b5e6-96231b3b80d8
2833fac27324b956cfb31be987652d2304d10761 30-Nov-2009 Tobias Grosser <grosser@fim.uni-passau.de> Small PostDominatorTree improvements

* Do not SEGFAULT if tree entryNode() is NULL
* Print function names in dotty printer

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90130 91177308-0d34-0410-b5e6-96231b3b80d8
e8a81da98d5b7373734f0702493fe22883c3e0e2 30-Nov-2009 Tobias Grosser <grosser@fim.uni-passau.de> Remove ":" after BB name in -view-cfg-only

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90129 91177308-0d34-0410-b5e6-96231b3b80d8
dd696052f0e4ecc973d105be19cf1b4b72f9a0c4 28-Nov-2009 Chris Lattner <sabre@nondot.org> Enhance InsertPHITranslatedPointer to be able to return a list of newly
inserted instructions. No functionality change until someone starts using it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90039 91177308-0d34-0410-b5e6-96231b3b80d8
6f7b210b2577fbc9247a9fc5223655390008ae89 27-Nov-2009 Chris Lattner <sabre@nondot.org> Rework InsertPHITranslatedPointer to handle the recursive case, this
fixes PR5630 and sets the stage for the next phase of goodness (testcase

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90019 91177308-0d34-0410-b5e6-96231b3b80d8
8aee8efc0c2e387faa7dae39fdf613a22889b566 27-Nov-2009 Chris Lattner <sabre@nondot.org> factor some logic out of instcombine into a new SimplifyAddInst method.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90011 91177308-0d34-0410-b5e6-96231b3b80d8
616613d7a4ddc7cefce53b2bfe3fdcdec6b032c2 27-Nov-2009 Chris Lattner <sabre@nondot.org> teach GVN's load PRE to insert computations of the address in predecessors
where it is not available. It's unclear how to get this inserted
computation into GVN's scalar availability sets, Owen, help? :)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89997 91177308-0d34-0410-b5e6-96231b3b80d8
62deff066c5ee4474be80ed2d95aca010e237343 27-Nov-2009 Chris Lattner <sabre@nondot.org> Fix phi translation in load PRE to agree with the phi
translation done by memdep, and reenable gep translation

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89992 91177308-0d34-0410-b5e6-96231b3b80d8
c514c1f5218b8fe7499a0b9a4737860344cf4c43 27-Nov-2009 Chris Lattner <sabre@nondot.org> factor some instcombine simplifications for getelementptr out to a new
SimplifyGEPInst method in InstructionSimplify.h. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89980 91177308-0d34-0410-b5e6-96231b3b80d8
1ce0eaa25fc6ecead5f9bba3c17b8af612d830ef 26-Nov-2009 Chris Lattner <sabre@nondot.org> Implement PR1143 (at -m64) by making basicaa look through extensions. We
previously already handled it at -m32 because there were no i32->i64
extensions for addressing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89959 91177308-0d34-0410-b5e6-96231b3b80d8
e405c64f6b91635c8884411447ff5756c2e6b4c3 26-Nov-2009 Chris Lattner <sabre@nondot.org> move DecomposeGEPExpression out into ValueTracking.cpp

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89956 91177308-0d34-0410-b5e6-96231b3b80d8
65dbc909f5377947026a41f29420bb8112bdf611 25-Nov-2009 Devang Patel <dpatel@apple.com> Use StringRef (again) in DebugInfo interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89866 91177308-0d34-0410-b5e6-96231b3b80d8
193f720f118f52eb05de172d936a440f335c1469 24-Nov-2009 Devang Patel <dpatel@apple.com> Emit pubtypes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89725 91177308-0d34-0410-b5e6-96231b3b80d8
e54a5e88a57a78b1e24430f27bdf0a8f7f0e8e23 23-Nov-2009 Devang Patel <dpatel@apple.com> Add CreateLocation varinat that accepts MDNode (with a default value).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89689 91177308-0d34-0410-b5e6-96231b3b80d8
c46530b6a32a53edf0d6d32bcd09ea5d76940472 23-Nov-2009 Chris Lattner <sabre@nondot.org> add a helper

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89662 91177308-0d34-0410-b5e6-96231b3b80d8
ae3d802953b5209e7e9530cd5b5d4e457a6974dc 23-Nov-2009 Nick Lewycky <nicholas@mxc.ca> Remove unused LLVMContext.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89642 91177308-0d34-0410-b5e6-96231b3b80d8
66e08cf79a052dd75bf6fa2f94abd4c0a18cb019 22-Nov-2009 Chris Lattner <sabre@nondot.org> Remove the AliasAnalysis::getMustAliases method, which is dead.

The hasNoModRefInfoForCalls isn't worth it as a filter because
basicaa provides m/r info and everything chains to it, so remove

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89599 91177308-0d34-0410-b5e6-96231b3b80d8
a58a04921deba911d6ead8d24f495cec234681c1 20-Nov-2009 Dan Gohman <gohman@apple.com> Make Loop::getLoopLatch() work on loops which don't have preheaders, as
it may be used in contexts where preheader insertion may have failed due
to an indirectbr.

Make LoopSimplify's LoopSimplify::SeparateNestedLoop properly fail in
the case that it would require splitting an indirectbr edge.

These fix PR5502.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89484 91177308-0d34-0410-b5e6-96231b3b80d8
f94b5edc452c32d9ae258e7de30c33391fda6cc9 19-Nov-2009 Dan Gohman <gohman@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89398 91177308-0d34-0410-b5e6-96231b3b80d8
3dbb9e64d6e9d1e8bf16f75ebe4fe59ffdf93dd3 18-Nov-2009 Dan Gohman <gohman@apple.com> Simplify ComputeMultiple so that it doesn't depend on TargetData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89175 91177308-0d34-0410-b5e6-96231b3b80d8
427ef4e35f16af0509f8217bed07eba745e83a9f 17-Nov-2009 Devang Patel <dpatel@apple.com> Remove dead code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89156 91177308-0d34-0410-b5e6-96231b3b80d8
ac57410a56dbe0eb944699b67f9d84cf986a127e 15-Nov-2009 Chris Lattner <sabre@nondot.org> disable copying, enforce some invariants.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88870 91177308-0d34-0410-b5e6-96231b3b80d8
1b226abcd97598b40b8b801593b168dcd201cdde 14-Nov-2009 Benjamin Kramer <benny.kra@googlemail.com> Remove dead variable found by clang++.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88803 91177308-0d34-0410-b5e6-96231b3b80d8
a2b3cdc21f51d0e24310878b0c759ec48b5e6749 13-Nov-2009 Devang Patel <dpatel@apple.com> Do not use value handle to wrap MDNode in DIDescriptor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88700 91177308-0d34-0410-b5e6-96231b3b80d8
3ddf70442f0653bf082bfffc03a03745f76b15e2 13-Nov-2009 Devang Patel <dpatel@apple.com> Revert r87059 for now. It is failing clang tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@87070 91177308-0d34-0410-b5e6-96231b3b80d8
0418c102dd324be5a7d6d3a8ad3c806c7ee74d21 13-Nov-2009 Victor Hernandez <vhernandez@apple.com> Remove unnecessary llvm.dbg.declare bitcast

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@87059 91177308-0d34-0410-b5e6-96231b3b80d8
70d75ca3107ce05bc30ad3511aa669b9fab5eb90 12-Nov-2009 Devang Patel <dpatel@apple.com> "Attach debug info with llvm instructions" mode was enabled a month ago. Now make it permanent and remove old way of inserting intrinsics to encode debug info for line number and scopes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@87014 91177308-0d34-0410-b5e6-96231b3b80d8
586f69a11881d828c056ce017b3fb432341d9657 12-Nov-2009 Evan Cheng <evan.cheng@apple.com> - Teach LSR to avoid changing cmp iv stride if it will create an immediate that
cannot be folded into target cmp instruction.
- Avoid a phase ordering issue where early cmp optimization would prevent the
later count-to-zero optimization.
- Add missing checks which could cause LSR to reuse stride that does not have
- Fix a bug in count-to-zero optimization code which failed to find the pre-inc
iv's phi node.
- Remove, tighten, loosen some incorrect checks disable valid transformations.
- Quite a bit of code clean up.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86969 91177308-0d34-0410-b5e6-96231b3b80d8
b52675b643db496bcea218bd3d5fc5e23f523c22 12-Nov-2009 Chris Lattner <sabre@nondot.org> Add a new getPredicateOnEdge method which returns more rich information for
constant constraints. Improve the LVI lattice to include inequality

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86950 91177308-0d34-0410-b5e6-96231b3b80d8
38392bbeb81233d0b342ad33166fc82ad922bc34 12-Nov-2009 Chris Lattner <sabre@nondot.org> expose edge information and switch j-t to use it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86920 91177308-0d34-0410-b5e6-96231b3b80d8
afa5a34b30f152d85164eaff4124accb9ef056a8 12-Nov-2009 Devang Patel <dpatel@apple.com> Do not use StringRef in DebugInfo interface.
This allows StringRef to skip controversial if(str) check in constructor.
Buildbots, wait for corresponding clang and llvm-gcc FE check-ins!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86914 91177308-0d34-0410-b5e6-96231b3b80d8
641c6f983eb4e40ab23732ab46ffa85bab7f0ba9 11-Nov-2009 Dan Gohman <gohman@apple.com> Fix a copy+pasto in a comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86852 91177308-0d34-0410-b5e6-96231b3b80d8
cc4d3b25f336eef135cb7125716ecb2c1979e92e 11-Nov-2009 Chris Lattner <sabre@nondot.org> stub out some LazyValueInfo interfaces, and have JumpThreading
start using them in a trivial way when -enable-jump-threading-lvi
is passed. enable-jump-threading-lvi will be my playground for

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86789 91177308-0d34-0410-b5e6-96231b3b80d8
10f2d13d580da348ba9769864f02d0d5a862c1e0 11-Nov-2009 Chris Lattner <sabre@nondot.org> Stub out a new lazy value info pass, which will eventually
vend value constraint information to the optimizer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86767 91177308-0d34-0410-b5e6-96231b3b80d8
68cf6042c14ac649c6861bbd2d00993b15a5dfa6 11-Nov-2009 Chris Lattner <sabre@nondot.org> remove redundant foward declaration. This function is already in

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86765 91177308-0d34-0410-b5e6-96231b3b80d8
53bb5c95afe4ff2627cac513221af2e4e7c5d2e3 11-Nov-2009 Devang Patel <dpatel@apple.com> Implement support to debug inlined functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86748 91177308-0d34-0410-b5e6-96231b3b80d8
0a26870d921c4f5507126f3068fc13148c426496 10-Nov-2009 Chris Lattner <sabre@nondot.org> in -dot-cfg and -dot-cfg-only, when rendering switch instructions,
put the switch value in the successor boxes like we put T/F for branches.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86747 91177308-0d34-0410-b5e6-96231b3b80d8
40d8c28b27377199b7465ba2c5a2c59c6fd12fa9 10-Nov-2009 Chris Lattner <sabre@nondot.org> move some generally useful functions out of jump threading
into libanalysis and transformutils.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86735 91177308-0d34-0410-b5e6-96231b3b80d8
6daf99bf8fa7572fac271bbcd0a8da44ffc2df44 10-Nov-2009 Devang Patel <dpatel@apple.com> Process InlinedAt location info.
Update InsertDeclare to return newly inserted llvm.dbg.declare intrinsic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86727 91177308-0d34-0410-b5e6-96231b3b80d8
8e345a1c418608c49abb7c51a090bbb36f1273bc 10-Nov-2009 Victor Hernandez <vhernandez@apple.com> Update computeArraySize() to use ComputeMultiple() to determine the array size associated with a malloc; also extend PerformHeapAllocSRoA() to check if the optimized malloc's arg had its highest bit set, so that it is safe for ComputeMultiple() to look through sext instructions while determining the optimized malloc's array size

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86676 91177308-0d34-0410-b5e6-96231b3b80d8
2b6705f5e7c7624bd7fe486298c400f1afc15f6c 10-Nov-2009 Victor Hernandez <vhernandez@apple.com> Add ComputeMultiple() analysis function that recursively determines if a Value V is a multiple of unsigned Base

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86675 91177308-0d34-0410-b5e6-96231b3b80d8
e34537856a544c83513e390ac9552a8bc3823346 10-Nov-2009 Chris Lattner <sabre@nondot.org> add a new SimplifyInstruction API, which is like ConstantFoldInstruction,
except that the result may not be a constant. Switch jump threading to
use it so that it gets things like (X & 0) -> 0, which occur when phi preds
are deleted and the remaining phi pred was a zero.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86637 91177308-0d34-0410-b5e6-96231b3b80d8
81cf4325698b48b02eddab921ac333c7f25005c3 10-Nov-2009 Jeffrey Yasskin <jyasskin@google.com> Fix DenseMap iterator constness.

This patch forbids implicit conversion of DenseMap::const_iterator to
DenseMap::iterator which was possible because DenseMapIterator inherited
(publicly) from DenseMapConstIterator. Conversion the other way around is now
allowed as one may expect.

The template DenseMapConstIterator is removed and the template parameter
IsConst which specifies whether the iterator is constant is added to

Actually IsConst parameter is not necessary since the constness can be
determined from KeyT but this is not relevant to the fix and can be addressed

Patch by Victor Zverovich!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86636 91177308-0d34-0410-b5e6-96231b3b80d8
d06094f0682f2ede03caff4892b1a57469896d48 10-Nov-2009 Chris Lattner <sabre@nondot.org> factor simplification logic for AND and OR out to InstSimplify from instcombine.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86635 91177308-0d34-0410-b5e6-96231b3b80d8
9dbb42944c4d7caddab21016b24cca31019a3faf 10-Nov-2009 Chris Lattner <sabre@nondot.org> rename SimplifyCompare -> SimplifyCmpInst and split it into
Simplify[IF]Cmp pieces. Add some predicates to CmpInst to
determine whether a predicate is fp or int.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86624 91177308-0d34-0410-b5e6-96231b3b80d8
8f73deaa8732a556046bf4ac6207be55972e3b74 10-Nov-2009 Chris Lattner <sabre@nondot.org> fix ConstantFoldCompareInstOperands to take the LHS/RHS as
individual operands instead of taking a temporary array

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86619 91177308-0d34-0410-b5e6-96231b3b80d8
9f3c25aeb3df77a336693308dc0f19a4983c99af 09-Nov-2009 Chris Lattner <sabre@nondot.org> stub out a new libanalysis "instruction simplify" interface that
takes decimated instructions and applies identities to them. This
is pretty minimal at this point, but I plan to pull some instcombine
logic out into these and similar routines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86613 91177308-0d34-0410-b5e6-96231b3b80d8
d146e986c818165cca866ee05751451706ccf36a 09-Nov-2009 Dan Gohman <gohman@apple.com> Fix an 80-column violation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86567 91177308-0d34-0410-b5e6-96231b3b80d8
9d0b704e3ea418441001dac4d1a56c2c224cdbf5 07-Nov-2009 Victor Hernandez <vhernandez@apple.com> Re-commit r86077 now that r86290 fixes the 179.art and 175.vpr ARM regressions.

Here is the original commit message:

This commit updates malloc optimizations to operate on malloc calls that have constant int size arguments.

Update CreateMalloc so that its callers specify the size to allocate:
MallocInst-autoupgrade users use non-TargetData-computed allocation sizes.
Optimization uses use TargetData to compute the allocation size.

Now that malloc calls can have constant sizes, update isArrayMallocHelper() to use TargetData to determine the size of the malloced type and the size of malloced arrays.
Extend getMallocType() to support malloc calls that have non-bitcast uses.

Update OptimizeGlobalAddressOfMalloc() to optimize malloc calls that have non-bitcast uses. The bitcast use of a malloc call has to be treated specially here because the uses of the bitcast need to be replaced and the bitcast needs to be erased (just like the malloc call) for OptimizeGlobalAddressOfMalloc() to work correctly.

Update PerformHeapAllocSRoA() to optimize malloc calls that have non-bitcast uses. The bitcast use of the malloc is not handled specially here because ReplaceUsesOfMallocWithGlobal replaces through the bitcast use.

Update OptimizeOnceStoredGlobal() to not care about the malloc calls' bitcast use.

Update all globalopt malloc tests to not rely on autoupgraded-MallocInsts, but instead use explicit malloc calls with correct allocation sizes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86311 91177308-0d34-0410-b5e6-96231b3b80d8
f55eeb918e9b4fac49853accabac5924a7716939 06-Nov-2009 Chris Lattner <sabre@nondot.org> remove some more Context arguments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86235 91177308-0d34-0410-b5e6-96231b3b80d8
7b550ccfc5a3346c17e0390a59e2d6d19bc52705 06-Nov-2009 Chris Lattner <sabre@nondot.org> remove a bunch of extraneous LLVMContext arguments
from various APIs, addressing PR5325.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86231 91177308-0d34-0410-b5e6-96231b3b80d8
df98761d08ae091420b7e9c1366de7684400fc36 06-Nov-2009 Victor Hernandez <vhernandez@apple.com> Revert r86077 because it caused crashes in 179.art and 175.vpr on ARM

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86213 91177308-0d34-0410-b5e6-96231b3b80d8
f17e9511f15a0e007ff47d0789d1a52502e8c1fb 05-Nov-2009 Dan Gohman <gohman@apple.com> Factor out the predicate code for loopsimplify form exit blocks into
a separate helper function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86159 91177308-0d34-0410-b5e6-96231b3b80d8
24f934d0551e33508c4ffd24318ea0e970db9810 05-Nov-2009 Victor Hernandez <vhernandez@apple.com> Update CreateMalloc so that its callers specify the size to allocate:
MallocInst-autoupgrade users use non-TargetData-computed allocation sizes.
Optimization uses use TargetData to compute the allocation size.

Now that malloc calls can have constant sizes, update isArrayMallocHelper() to use TargetData to determine the size of the malloced type and the size of malloced arrays.
Extend getMallocType() to support malloc calls that have non-bitcast uses.

Update OptimizeGlobalAddressOfMalloc() to optimize malloc calls that have non-bitcast uses. The bitcast use of a malloc call has to be treated specially here because the uses of the bitcast need to be replaced and the bitcast needs to be erased (just like the malloc call) for OptimizeGlobalAddressOfMalloc() to work correctly.

Update PerformHeapAllocSRoA() to optimize malloc calls that have non-bitcast uses. The bitcast use of the malloc is not handled specially here because ReplaceUsesOfMallocWithGlobal replaces through the bitcast use.

Update OptimizeOnceStoredGlobal() to not care about the malloc calls' bitcast use.

Update all globalopt malloc tests to not rely on autoupgraded-MallocInsts, but instead use explicit malloc calls with correct allocation sizes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86077 91177308-0d34-0410-b5e6-96231b3b80d8
076124ef26ff67f88663bd11f3b4d6b3d3bb3a9d 01-Nov-2009 Douglas Gregor <dgregor@apple.com> Reverting 85714, 85715, 85716, which are breaking the build

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85717 91177308-0d34-0410-b5e6-96231b3b80d8
2166f6229042a4d3d65847ebe0d453cd664682ef 01-Nov-2009 Dan Gohman <gohman@apple.com> Add a function to Passes.h to allow clients to create instances
of the ScalarEvolution pass without needing to #include ScalarEvolution.h.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85716 91177308-0d34-0410-b5e6-96231b3b80d8
34e9d7b6be970b4a6aae876e3c40a4151da67e6e 01-Nov-2009 Dan Gohman <gohman@apple.com> Don't #include Pass.h from CallGraph.h.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85715 91177308-0d34-0410-b5e6-96231b3b80d8
4c7279ac726e338400626fca5a09b5533426eb6a 31-Oct-2009 Dan Gohman <gohman@apple.com> Rename forgetLoopBackedgeTakenCount to forgetLoop, because it
clears out more information than just the stored backedge taken count.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85664 91177308-0d34-0410-b5e6-96231b3b80d8
90f48e7c91a8faa875ba889ca66b137ffd46e34a 28-Oct-2009 Victor Hernandez <vhernandez@apple.com> Extend getMallocArraySize() to determine the array size if the malloc argument is:
ArraySize * ElementSize
ElementSize * ArraySize
ArraySize << log2(ElementSize)
ElementSize << log2(ArraySize)

Refactor isArrayMallocHelper and delete isSafeToGetMallocArraySize, so that there is only 1 copy of the malloc array determining logic.
Update users of getMallocArraySize() to not bother calling isArrayMalloc() as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85421 91177308-0d34-0410-b5e6-96231b3b80d8
f006b183e2d2bebcf6968d1dd7350397c95b0325 27-Oct-2009 Victor Hernandez <vhernandez@apple.com> Rename MallocFreeHelper as MemoryBuiltins

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85286 91177308-0d34-0410-b5e6-96231b3b80d8
f2becca90b832cc02345fba063b9b439b2be33ad 27-Oct-2009 Victor Hernandez <vhernandez@apple.com> Rename MallocHelper as MallocFreeHelper, since it now also identifies calls to free()

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85181 91177308-0d34-0410-b5e6-96231b3b80d8
046e78ce55a7c3d82b7b6758d2d77f2d99f970bf 27-Oct-2009 Victor Hernandez <vhernandez@apple.com> Remove FreeInst.
Remove LowerAllocations pass.
Update some more passes to treate free calls just like they were treating FreeInst.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85176 91177308-0d34-0410-b5e6-96231b3b80d8
ac16d44e58e74bb0b5cecf3ec5e8d7de315f7d95 26-Oct-2009 Devang Patel <dpatel@apple.com> Add support to encode type info using llvm::Constant.
Patch by Talin!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85126 91177308-0d34-0410-b5e6-96231b3b80d8
8b67f774e9c38b7718b2b300b628388f966df4e0 26-Oct-2009 Chandler Carruth <chandlerc@gmail.com> Move DataTypes.h to include/llvm/System, update all users. This breaks the last
direct inclusion edge from System to Support.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85086 91177308-0d34-0410-b5e6-96231b3b80d8
32663b719b4996b3a735f22bba80d771d50f96e7 25-Oct-2009 Dan Gohman <gohman@apple.com> Rename isLoopExit to isLoopExiting, for consistency with the wording
used elsewhere - an exit block is a block outside the loop branched to
from within the loop. An exiting block is a block inside the loop that
branches out.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85019 91177308-0d34-0410-b5e6-96231b3b80d8
70b2bee8e7dda22d70475bf748385654559a0ef8 24-Oct-2009 Dan Gohman <gohman@apple.com> Make DominanceFrontier::addBasicBlock return the iterator for the newly
inserted block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85010 91177308-0d34-0410-b5e6-96231b3b80d8
66284e063a1e46500acae48bdc0e4a00652021d1 24-Oct-2009 Victor Hernandez <vhernandez@apple.com> Auto-upgrade free instructions to calls to the builtin free function.
Update all analysis passes and transforms to treat free calls just like FreeInst.
Remove RaiseAllocations and all its tests since FreeInst no longer needs to be raised.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84987 91177308-0d34-0410-b5e6-96231b3b80d8
878e4946700824954d7eb7f3ff660353db8e0d17 22-Oct-2009 Chris Lattner <sabre@nondot.org> Move some constant folding logic for loads out of instcombine into
Analysis/ConstantFolding.cpp. This doesn't change the behavior of
instcombine but makes other clients of ConstantFoldInstruction
able to handle loads. This was partially extracted from Eli's patch
in PR3152.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84836 91177308-0d34-0410-b5e6-96231b3b80d8
b839c5577d8ecb884ffb6874a14782797faec9c4 18-Oct-2009 Chris Lattner <sabre@nondot.org> add function passes for printing various dominator datastructures
accessible through opt. Patch by Tobias Grosser!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84397 91177308-0d34-0410-b5e6-96231b3b80d8
88067b9133103de3bfadd4f5166f4fb082ba2496 18-Oct-2009 Chris Lattner <sabre@nondot.org> make DOTGraphTraits public, patch by Tobias Grosser!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84396 91177308-0d34-0410-b5e6-96231b3b80d8
f0d24f1f597a84b1a164019ab81831ccd7aea47f 18-Oct-2009 Chris Lattner <sabre@nondot.org> add nodes_begin/end/iterator for dominfo, patch by Tobias Grosser!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84395 91177308-0d34-0410-b5e6-96231b3b80d8
ca24a695e7727da5df40a819d1144c32c8fb0110 17-Oct-2009 Daniel Dunbar <daniel@zuster.org> Add required #includes for freestanding .h files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84302 91177308-0d34-0410-b5e6-96231b3b80d8
2491ce03535cf8ec171570d2e28df63e4db3dd6b 15-Oct-2009 Victor Hernandez <vhernandez@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84199 91177308-0d34-0410-b5e6-96231b3b80d8
68cf03a314f19935d9096ad22dfe7d4fdcbb5c19 14-Oct-2009 Dan Gohman <gohman@apple.com> Fix resetCachedCostInfo to reset all of the cost information, instead of
just the NumBlocks field.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84056 91177308-0d34-0410-b5e6-96231b3b80d8
e7f0ed5aceed27d6f46521ec6e4c139986c5b489 13-Oct-2009 Dan Gohman <gohman@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84013 91177308-0d34-0410-b5e6-96231b3b80d8
e4aeec003f82a5263ffb168e175e6fca8b6f681d 13-Oct-2009 Dan Gohman <gohman@apple.com> Move the InlineCost code from Transforms/Utils to Analysis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83998 91177308-0d34-0410-b5e6-96231b3b80d8
6e37f4878b3e33752cd2d50818a0813733c2bd63 13-Oct-2009 Devang Patel <dpatel@apple.com> Enable "debug info attached to an instruction" mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83925 91177308-0d34-0410-b5e6-96231b3b80d8
3645b01002e7ac244c1f3d163e5e350df21d869d 09-Oct-2009 Dan Gohman <gohman@apple.com> Add the ability to track HasNSW and HasNUW on more kinds of SCEV expressions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83601 91177308-0d34-0410-b5e6-96231b3b80d8
8ef27511e32bf704e2a25ebc96858439ab58f449 08-Oct-2009 Chris Lattner <sabre@nondot.org> remove LoopVR pass. According to Nick:
"LoopVR's logic was copied into ScalarEvolution::getUnsignedRange and
::getSignedRange. Please delete LoopVR."

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83531 91177308-0d34-0410-b5e6-96231b3b80d8
beab41b874c3f15df848f9953e8e2c99182b1df8 08-Oct-2009 Devang Patel <dpatel@apple.com> Extract subprogram and compile unit information from the debug info attached to an instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83491 91177308-0d34-0410-b5e6-96231b3b80d8
c6f69e94fa46f585b59bb9d7ace3224b0e638c95 05-Oct-2009 Dan Gohman <gohman@apple.com> Remove an unnnecessary LLVMContext argument in

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83311 91177308-0d34-0410-b5e6-96231b3b80d8
e4250396ea254b374436e94f391f1adb9bd94d20 02-Oct-2009 Mike Stump <mrs@apple.com> 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?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83216 91177308-0d34-0410-b5e6-96231b3b80d8
ecbeb1a490ed6ef8f12e7a38471bdfc20942b0a3 01-Oct-2009 Devang Patel <dpatel@apple.com> Add isFOO() helpers. Fix getDirectory() and getFilename() for DIScope.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83180 91177308-0d34-0410-b5e6-96231b3b80d8
3e4c9bdb67db9b6d65b17d474e3268b520a93514 30-Sep-2009 Mike Stump <mrs@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83120 91177308-0d34-0410-b5e6-96231b3b80d8
5ccdd10b1a0ee1ce35b6e5a18eb0fcfd6f5131d3 29-Sep-2009 Devang Patel <dpatel@apple.com> Remove std::string uses from DebugInfo interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83083 91177308-0d34-0410-b5e6-96231b3b80d8
9450b0e1a6154192ca597ad27f8eb6e6e807f7a4 28-Sep-2009 Dan Gohman <gohman@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82952 91177308-0d34-0410-b5e6-96231b3b80d8
3069b3193de74bb8b76e5c0f612b4a97abf9dea6 28-Sep-2009 Dan Gohman <gohman@apple.com> Extract the code for inserting a loop into the loop queue into
a separate function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82946 91177308-0d34-0410-b5e6-96231b3b80d8
be1123464a232168299bcd9557e94e90c1daa5de 27-Sep-2009 Dan Gohman <gohman@apple.com> Remove a redundant assert.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82907 91177308-0d34-0410-b5e6-96231b3b80d8
22bf8f21b4e91eadc27207c4b0a7db3dd1756b4f 27-Sep-2009 Dan Gohman <gohman@apple.com> Add dominates and releaseMemory member functions to PostDominatorTree.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82904 91177308-0d34-0410-b5e6-96231b3b80d8
6e70e31810464289a9e9b37e0345847e3ca5d5cf 27-Sep-2009 Dan Gohman <gohman@apple.com> Add a properlyDominates member function to ScalarEvolution.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82898 91177308-0d34-0410-b5e6-96231b3b80d8
b7532e254810aba26da9b65ee2c65788695f8c30 26-Sep-2009 Dan Gohman <gohman@apple.com> Add a comment describing natural loops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82859 91177308-0d34-0410-b5e6-96231b3b80d8
48a097bfb6b2ab1ed67d2341a5b51c5d2b61af5b 22-Sep-2009 Daniel Dunbar <daniel@zuster.org> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82507 91177308-0d34-0410-b5e6-96231b3b80d8
75c7c995b7ed5a5b7527a80d2bbc2b60720b1312 22-Sep-2009 Chris Lattner <sabre@nondot.org> move DominatorTree::dominates for instructions out of line,
no functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82490 91177308-0d34-0410-b5e6-96231b3b80d8
7dd76a1088f7285f73152732de50c78b64ee5a03 19-Sep-2009 Daniel Dunbar <daniel@zuster.org> Prefer super class constructor to explicit initialization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82335 91177308-0d34-0410-b5e6-96231b3b80d8
3fc19bbbbb6b215a7417dfe63c9cb59519bcfde7 19-Sep-2009 Daniel Dunbar <daniel@zuster.org> Tabs -> spaces (really?)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82334 91177308-0d34-0410-b5e6-96231b3b80d8
f612ff6cfbf3a59842732f0280807c0714ab9025 19-Sep-2009 Daniel Dunbar <daniel@zuster.org> Strip trailing whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82332 91177308-0d34-0410-b5e6-96231b3b80d8
875646f376f6c83bf8426fdb44e1dbf312cf784e 19-Sep-2009 Nick Lewycky <nicholas@mxc.ca> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82317 91177308-0d34-0410-b5e6-96231b3b80d8
88d9839d07a6b5a03484d664913de0f2b33d3bff 18-Sep-2009 Victor Hernandez <vhernandez@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82257 91177308-0d34-0410-b5e6-96231b3b80d8
1f96e67f78110d0ac5b30a32375097a28f869c63 17-Sep-2009 Dan Gohman <gohman@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82151 91177308-0d34-0410-b5e6-96231b3b80d8
1b75f44bd9b1cf4a532940ff986c9ee8bd21564f 16-Sep-2009 Devang Patel <dpatel@apple.com> Provide a way to extract location info from DILocation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82064 91177308-0d34-0410-b5e6-96231b3b80d8
923327267949b537d7a2fdad5b7a919bd90ce085 16-Sep-2009 Andreas Neustifter <astifter-llvm@gmx.at> Reapplied r81355 with the problems fixed.
(See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090907/086737.html and

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82039 91177308-0d34-0410-b5e6-96231b3b80d8
75144f93eb7e4dbf22d308d21581ae255dd520c6 15-Sep-2009 Dan Gohman <gohman@apple.com> Fix apostrophos.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81856 91177308-0d34-0410-b5e6-96231b3b80d8
a51c39cc3265f5d0d5de87b4a3ef9332c83556e1 15-Sep-2009 Chris Lattner <sabre@nondot.org> 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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81843 91177308-0d34-0410-b5e6-96231b3b80d8
83e3c4f9d796a5da223a3ebd5d4ba985c7ecc39d 11-Sep-2009 Dan Gohman <gohman@apple.com> Give these files top-level comments that describe the current code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81473 91177308-0d34-0410-b5e6-96231b3b80d8
fabcb9127f278a77b8aae5673be1115390c55050 10-Sep-2009 Evan Cheng <evan.cheng@apple.com> Add malloc call utility functions. Patch by Victor Hernandez.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81426 91177308-0d34-0410-b5e6-96231b3b80d8
07abe17bd2f18eb0279663f686f84997527a238c 09-Sep-2009 Andreas Neustifter <astifter-llvm@gmx.at> Add the first functions for updating ProfileInfo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81359 91177308-0d34-0410-b5e6-96231b3b80d8
273a488cdfe27aee58a3774579376d4b8f791012 09-Sep-2009 Chris Lattner <sabre@nondot.org> revert r81335, which breaks the build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81347 91177308-0d34-0410-b5e6-96231b3b80d8
1f3b00272a4aa5a69bffb018bc449c84167b6bf8 09-Sep-2009 Andreas Neustifter <astifter-llvm@gmx.at> Updated ProfileInfo to have clean seperation between different sentinels.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81335 91177308-0d34-0410-b5e6-96231b3b80d8
5c89b5240c90eb8171f999e5f06f815502d0321c 08-Sep-2009 Dan Gohman <gohman@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81221 91177308-0d34-0410-b5e6-96231b3b80d8
45336a6f22de93b38d693fbdde0c96aa84f1e70f 08-Sep-2009 Chris Lattner <sabre@nondot.org> fix PR4915, a crash in -debug mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81177 91177308-0d34-0410-b5e6-96231b3b80d8
cf5128ec01f45d2bf7eadc20b253cb44486e473f 08-Sep-2009 Chris Lattner <sabre@nondot.org> add some comments to describe the invariants.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81173 91177308-0d34-0410-b5e6-96231b3b80d8
59bf4fcc0680e75b408579064d1205a132361196 06-Sep-2009 Duncan Sands <baldrick@free.fr> Public and private corrections, warned about by icc (#304).
Patch by Erick Tryzelaar.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81107 91177308-0d34-0410-b5e6-96231b3b80d8
8f78a58e14fa754cde827e46ad03f00c7a6ead01 06-Sep-2009 Evan Cheng <evan.cheng@apple.com> Revert r80926. It causes loop unswitch assertion and slow down some JIT tests significantly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81101 91177308-0d34-0410-b5e6-96231b3b80d8
8fc5ad33691b2a0672a7487da1f56b6f7f675a1b 03-Sep-2009 Dan Gohman <gohman@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80926 91177308-0d34-0410-b5e6-96231b3b80d8
f0608d829a7b8929108ac6718bd866adf710e936 03-Sep-2009 Dan Gohman <gohman@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80923 91177308-0d34-0410-b5e6-96231b3b80d8
e7125f4babb536df3a2573b6166954da7753c6b8 03-Sep-2009 Dan Gohman <gohman@apple.com> Remove references to expression "handles", which are no longer used.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80918 91177308-0d34-0410-b5e6-96231b3b80d8
3445d9a72aec68512df265705e2be7704496f541 02-Sep-2009 Dan Gohman <gohman@apple.com> Add const qualifiers to dominates' arguments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80801 91177308-0d34-0410-b5e6-96231b3b80d8
da5ea945545ca8864a873a5a33fd891ec381ec88 01-Sep-2009 Andreas Neustifter <astifter-llvm@gmx.at> OptimalEdgeProfiling: Reading in Profiles.
This enables LLVM to read the OptimalEdgeProfiles.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80715 91177308-0d34-0410-b5e6-96231b3b80d8
f771dae69aee00a16dbfb7e712bf26ab2b9d9cde 01-Sep-2009 Andreas Neustifter <astifter-llvm@gmx.at> OptimalEdgeProfiling: Creation of profiles.
This adds the instrumentation and runtime part of OptimalEdgeProfiling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80712 91177308-0d34-0410-b5e6-96231b3b80d8
da230cb876edf0d4fa8eefc289b8addfb722cd07 01-Sep-2009 Chris Lattner <sabre@nondot.org> remove CallGraphNode::replaceCallSite, it is redundant with other APIs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80708 91177308-0d34-0410-b5e6-96231b3b80d8
e885af9fb773f5a01a5b31fa0a0b7fd0489bde56 01-Sep-2009 Andreas Neustifter <astifter-llvm@gmx.at> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80667 91177308-0d34-0410-b5e6-96231b3b80d8
e7ddcfdebe357b4067f9c7d68d44616e11351a23 01-Sep-2009 Andreas Neustifter <astifter-llvm@gmx.at> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80666 91177308-0d34-0410-b5e6-96231b3b80d8
a541b0fde2ab6b8b037edf113d42da41a2c5aae9 01-Sep-2009 Chris Lattner <sabre@nondot.org> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80663 91177308-0d34-0410-b5e6-96231b3b80d8
e5b1454cdd8522831093128ddc7d7f81328d9f33 01-Sep-2009 Devang Patel <dpatel@apple.com> Add virtual destructor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80660 91177308-0d34-0410-b5e6-96231b3b80d8
f98d8fee3c5367622cf03e52f1e1b2251ac6cf3f 01-Sep-2009 Devang Patel <dpatel@apple.com> Introduce DILocation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80648 91177308-0d34-0410-b5e6-96231b3b80d8
58e7a2dfc2e0203abb5a4637bd0fcf9c1992fb95 01-Sep-2009 Devang Patel <dpatel@apple.com> Add getDirectory() and getFilename() interface to DIScope.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80647 91177308-0d34-0410-b5e6-96231b3b80d8
82dfc0cd8c3c2bf780a13cc35c1a8df7ad137477 01-Sep-2009 Devang Patel <dpatel@apple.com> Subprogram is a scope. Derive DISubprogram from DIScope.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80637 91177308-0d34-0410-b5e6-96231b3b80d8
5e005d814f13f1796cf9e32c7525a5241fface1a 01-Sep-2009 Devang Patel <dpatel@apple.com> Rename DIBlock as DILexicalBlock.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80633 91177308-0d34-0410-b5e6-96231b3b80d8
c9f322d9a62c57ba965678a874faad6d239b9256 31-Aug-2009 Devang Patel <dpatel@apple.com> Derive DICompileUnit from DIScope.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80627 91177308-0d34-0410-b5e6-96231b3b80d8
dc8f6049d11ee73835c7b7e9b7c6d0b9e6a2c9b1 31-Aug-2009 Caroline Tice <ctice@apple.com> Add flag to mark structs for Apple Block "byref" variables; also add code to
modify the type and location debug information for these variables to match the
programmer's expectations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80625 91177308-0d34-0410-b5e6-96231b3b80d8
42214899082bfb5b6f8c6a09d355fec9ef4a0e82 31-Aug-2009 Dan Gohman <gohman@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80623 91177308-0d34-0410-b5e6-96231b3b80d8
43d98b3c4ecd564d4666468983322c019819f730 31-Aug-2009 Devang Patel <dpatel@apple.com> Introduce DIScope.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80620 91177308-0d34-0410-b5e6-96231b3b80d8
6ceea33c5e5c00069453e48740aaef5fe1c0953b 31-Aug-2009 Devang Patel <dpatel@apple.com> Simplify isDerivedType() and other predicate interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80602 91177308-0d34-0410-b5e6-96231b3b80d8
be577659d3c1222cc58c33628c0baddb94d241ab 31-Aug-2009 Chris Lattner <sabre@nondot.org> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80566 91177308-0d34-0410-b5e6-96231b3b80d8
b374b90e81d0ce6b5d02041ba4f7b15a945b38d8 31-Aug-2009 Chris Lattner <sabre@nondot.org> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80533 91177308-0d34-0410-b5e6-96231b3b80d8
5095e3d1d1caef8d573534d369e37277c623064c 31-Aug-2009 Chris Lattner <sabre@nondot.org> 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

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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80527 91177308-0d34-0410-b5e6-96231b3b80d8
23603a61c9bd43224db0b52126a415901d7550b4 31-Aug-2009 Chris Lattner <sabre@nondot.org> add a dump() method on callgraph.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80524 91177308-0d34-0410-b5e6-96231b3b80d8
e4b275610a7a05b7ee4c0378a906a6330e4c4ab0 29-Aug-2009 Devang Patel <dpatel@apple.com> Reapply 79977.
Use MDNodes to encode debug info in llvm IR.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80406 91177308-0d34-0410-b5e6-96231b3b80d8
a1ba269a27ca9d776e6de77e8177fa8fa844bd5e 28-Aug-2009 Devang Patel <dpatel@apple.com> Closure is a very generic name. Use AppleBlock instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80307 91177308-0d34-0410-b5e6-96231b3b80d8
7362ce08cb2c1f0b544b18dbc21630fb4baebcfc 28-Aug-2009 Gabor Greif <ggreif@gmail.com> eliminate all 80-col violations that I have introduced in my recent checkins (and some others more)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80304 91177308-0d34-0410-b5e6-96231b3b80d8
c75cd159cd5e428c9b0c8fb761b83c86844cd287 27-Aug-2009 Dan Gohman <gohman@apple.com> Minor code simplification.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80266 91177308-0d34-0410-b5e6-96231b3b80d8
1af0513be758ea49c85e098dc1a3d54157b0def7 27-Aug-2009 Dan Gohman <gohman@apple.com> Be somewhat more consistent about const qualifiers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80264 91177308-0d34-0410-b5e6-96231b3b80d8
5753a4a0033da4add45f2e9930a4e1159d92a869 27-Aug-2009 Dan Gohman <gohman@apple.com> Global Aliases are not identifiable objects.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80263 91177308-0d34-0410-b5e6-96231b3b80d8
846a2f2703f6bb894098274964faf5dce0b68c4d 27-Aug-2009 Dan Gohman <gohman@apple.com> Handle TargetData with const.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80262 91177308-0d34-0410-b5e6-96231b3b80d8
0aeed044d6c9849351918f0535b8ce30ba2c4200 27-Aug-2009 Dan Gohman <gohman@apple.com> Strip trailing whitespace from blank lines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80259 91177308-0d34-0410-b5e6-96231b3b80d8
1e1de493949eac34bfd00d44c77364f3fbac9534 27-Aug-2009 Gabor Greif <ggreif@gmail.com> the buildbots revealed one more breakage. fix. (why didn't I see this?)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80227 91177308-0d34-0410-b5e6-96231b3b80d8
f0891be8bdbeeadb39da5575273b6645755fa383 27-Aug-2009 Gabor Greif <ggreif@gmail.com> Clean up the minor mess I caused with removing iterator.h. I shall take care of 80-col violations and the FIXME later. (Thanks goodness that I live in another continent, so the monkeypox did not strike me :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80224 91177308-0d34-0410-b5e6-96231b3b80d8
4bac4b9899ea4e56f4b5dd99887d4e460e0f13ad 26-Aug-2009 Dan Gohman <gohman@apple.com> Move ProfileInfo::Edge's operator<< out of line. Among other benefits,
this eliminates the ATTRIBUTE_USED, which wasn't being used in a manner
acceptable to some GCC versions, according to the buildbots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80103 91177308-0d34-0410-b5e6-96231b3b80d8
0ef68e8fbb25213794f88c6c42f2488341bc05c6 26-Aug-2009 Andreas Neustifter <astifter-llvm@gmx.at> Bugfix for r80100, forgot include. Sorry.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80101 91177308-0d34-0410-b5e6-96231b3b80d8
ff271e13539a43e804cab4457821a46a8bddc2ec 26-Aug-2009 Andreas Neustifter <astifter-llvm@gmx.at> Implemented comments from Daniel Dunbar.
(See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090817/084958.html)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80100 91177308-0d34-0410-b5e6-96231b3b80d8
2385e0e22ca482f2896dfa975a08db2f54926c09 26-Aug-2009 Dan Gohman <gohman@apple.com> Create a ScalarEvolution-based AliasAnalysis implementation.

This is a simple AliasAnalysis implementation which works by making
ScalarEvolution queries. ScalarEvolution has a more complete understanding
of arithmetic than BasicAA's collection of ad-hoc checks, so it handles
some cases that BasicAA misses, for example p[i] and p[i+1] within the
same iteration of a loop.

This is currently experimental. It may be that the main use for this pass
will be to help find cases where BasicAA can be profitably extended, or
to help in the development of the overall AliasAnalysis infrastructure,
however it's also possible that it could grow up to become a directly
useful pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80098 91177308-0d34-0410-b5e6-96231b3b80d8
824598883513789516a919651f4b35e7a638ec5c 26-Aug-2009 Devang Patel <dpatel@apple.com> Revert 79977. It causes llvm-gcc bootstrap failures on some platforms.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80073 91177308-0d34-0410-b5e6-96231b3b80d8
e1f515ea59df5cb989c371604bba2271e6f3ee0d 26-Aug-2009 Chris Lattner <sabre@nondot.org> fix some funky indentation

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80068 91177308-0d34-0410-b5e6-96231b3b80d8
8af76bdb7450b097efa17f7c192882111a9e8f10 26-Aug-2009 Devang Patel <dpatel@apple.com> Add isClosure() predicate. This is used to add DW_AT_APPLE_block attribute.
Patch by Caroline Tice.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80061 91177308-0d34-0410-b5e6-96231b3b80d8
2a610c7387664bc557a35ce3bb4c0d4df56e4755 25-Aug-2009 Devang Patel <dpatel@apple.com> Update DebugInfo interface to use metadata, instead of special named llvm.dbg.... global variables, to encode debugging information in llvm IR. This is mostly a mechanical change that tests metadata support very well.

This change speeds up llvm-gcc by more then 6% at "-O0 -g" (measured by compiling InstructionCombining.cpp!)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79977 91177308-0d34-0410-b5e6-96231b3b80d8
96135b617a5c752ea98388d0ed4a289c47c147b3 24-Aug-2009 Andreas Neustifter <astifter-llvm@gmx.at> This patch cleans up the ProfileInfo by
*) introducing new data type and export function of edge info for whole function (preparation for next patch).
*) renaming variables to make clear distinction between data and containers that contain this data.
*) updated comments and whitespaces.
*) made ProfileInfo::MissingValue a double (as it should be...).

(Discussed at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090817/084955.html.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79940 91177308-0d34-0410-b5e6-96231b3b80d8
9661c13c37d017df6f91a399c0160b82e8a6c39f 24-Aug-2009 Chris Lattner <sabre@nondot.org> remove a few dead insertion methods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79882 91177308-0d34-0410-b5e6-96231b3b80d8
103289e9383ad1eb66caf28c9b166aebce963a35 23-Aug-2009 Chris Lattner <sabre@nondot.org> convert LoopInfo.h and GraphWriter.h to use raw_ostream

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79836 91177308-0d34-0410-b5e6-96231b3b80d8
45cfe545ec8177262dabc70580ce05feaa1c3880 23-Aug-2009 Chris Lattner <sabre@nondot.org> Change Pass::print to take a raw ostream instead of std::ostream,
update all code that this affects.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79830 91177308-0d34-0410-b5e6-96231b3b80d8
791102fb1192ac9483274e54cbc42480c9b1af10 23-Aug-2009 Chris Lattner <sabre@nondot.org> eliminate the std::ostream form of WriteAsOperand and update clients.
This also updates dominator related stuff.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79825 91177308-0d34-0410-b5e6-96231b3b80d8
bdff548e4dd577a72094d57b282de4e765643b96 23-Aug-2009 Chris Lattner <sabre@nondot.org> eliminate the "Value" printing methods that print to a std::ostream.
This required converting a bunch of stuff off DOUT and other cleanups.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79819 91177308-0d34-0410-b5e6-96231b3b80d8
5078f84c82814e4d33846f9ef54281619d362f8a 20-Aug-2009 Dan Gohman <gohman@apple.com> Rename hasNoUnsignedOverflow and hasNoSignedOverflow to hasNoUnsignedWrap
and hasNoSignedWrap, for consistency with the nuw and nsw properties.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79539 91177308-0d34-0410-b5e6-96231b3b80d8
4c0d5d5db876b0628bdf6a2174263a1c0a9130e2 20-Aug-2009 Dan Gohman <gohman@apple.com> Various comment and whitespace cleanups.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79533 91177308-0d34-0410-b5e6-96231b3b80d8
c40f17b08774c2dcc5787fd83241e3c64ba82974 18-Aug-2009 Dan Gohman <gohman@apple.com> Generalize ScalarEvolution to be able to analyze GEPs when
TargetData is not present. It still uses TargetData when available.
This generalization also fixed some limitations in the TargetData
case; the attached testcase covers this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79344 91177308-0d34-0410-b5e6-96231b3b80d8
12ddd409535b52a7fa5157ded9a4cedd161fedb6 11-Aug-2009 Benjamin Kramer <benny.kra@googlemail.com> Make LLVMContext and LLVMContextImpl classes instead of structs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78690 91177308-0d34-0410-b5e6-96231b3b80d8
ffef8acc3e3398bdd04e947c7949befdd52faf86 11-Aug-2009 Dan Gohman <gohman@apple.com> Tidy #includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78677 91177308-0d34-0410-b5e6-96231b3b80d8
72bcdb6c9b5456cf6687c9066ae9d220ebedd80a 11-Aug-2009 Devang Patel <dpatel@apple.com> Keep track of DIType.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78602 91177308-0d34-0410-b5e6-96231b3b80d8
c43782cf7163805fb6d727382b5f807ea035b2b0 08-Aug-2009 Daniel Dunbar <daniel@zuster.org> Some ProfileInfo cleanups.
- Part of optimal static profiling patch sequence by Andreas Neustifter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78485 91177308-0d34-0410-b5e6-96231b3b80d8
55e354ac0e294bde258420f80a2cc11ea19db482 08-Aug-2009 Daniel Dunbar <daniel@zuster.org> Add a basic static ProfileInfo provider (ProfileEstimatorPass).
- Part of optimal static profiling patch sequence by Andreas Neustifter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78484 91177308-0d34-0410-b5e6-96231b3b80d8
caaa49336b47b542d7255a8455fbab2e14a20ec5 08-Aug-2009 Daniel Dunbar <daniel@zuster.org> More ProfileInfo improvements.
- Part of optimal static profiling patch sequence by Andreas Neustifter.

- Store edge, block, and function information separately for each functions
(instead of in one giant map).

- Return frequencies as double instead of int, and use a sentinel value for
missing information.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78477 91177308-0d34-0410-b5e6-96231b3b80d8
699db99c1a356eaa407ee03ebdf8553853d82bbd 07-Aug-2009 Andreas Bolka <a@bolka.at> SIV/MIV classification for LDA.

LoopDependenceAnalysis::getLoops is currently O(N*M) for a loop-nest of
depth N and a compound SCEV of M atomic SCEVs. As both N and M will
typically be very small, this should not be a problem. If it turns out
to be one, rewriting getLoops as SCEVVisitor will reduce complexity to

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78394 91177308-0d34-0410-b5e6-96231b3b80d8
bceda93251ff2cbcf54fb315e23027f426bfea80 06-Aug-2009 Devang Patel <dpatel@apple.com> Remove dead code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78335 91177308-0d34-0410-b5e6-96231b3b80d8
27a201d236913df429d6b959cbfb72b93f774ce0 06-Aug-2009 Devang Patel <dpatel@apple.com> Fix comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78313 91177308-0d34-0410-b5e6-96231b3b80d8
c9008c5cc7113ea4c3a262e346c0dfcdbca12ae6 05-Aug-2009 Daniel Dunbar <daniel@zuster.org> Make block and function count available via ProfileInfo.
- Part of optimal static profiling patch sequence by Andreas Neustifter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78247 91177308-0d34-0410-b5e6-96231b3b80d8
ee16638bfc9c17068c4b3c2dc130277785a11e20 05-Aug-2009 Daniel Dunbar <daniel@zuster.org> Remove unnecessary ProfileInfoLoader methods.
- Part of optimal static profiling patch sequence by Andreas Neustifter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78199 91177308-0d34-0410-b5e6-96231b3b80d8
831f6f6d2ae5a1ad988c8328404b052b7985ce31 05-Aug-2009 Andreas Bolka <a@bolka.at> ZIV tester for LDA.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78157 91177308-0d34-0410-b5e6-96231b3b80d8
48b2f3e4850cd27d54224cd42da8a160d6b95984 05-Aug-2009 Owen Anderson <resistor@mac.com> Factor some of the constants+context related code out into a separate header, to make LLVMContextImpl.h
not hideous. Also, fix some MSVC compile errors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78115 91177308-0d34-0410-b5e6-96231b3b80d8
5eca4525f42a99eec29be1676a7a77928853c521 03-Aug-2009 Andreas Bolka <a@bolka.at> Restrict LDA to affine subscripts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77932 91177308-0d34-0410-b5e6-96231b3b80d8
81acc554b9599bacf843e080dbf4c72fe88de0f7 31-Jul-2009 Dan Gohman <gohman@apple.com> Fix a typo in a comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77715 91177308-0d34-0410-b5e6-96231b3b80d8
a818c30d664cd4ba4b9ed69fb2048a6ea55ec9cd 31-Jul-2009 Dan Gohman <gohman@apple.com> Fix some problems with ASTCallbackVH in its use as a DenseMap key.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77696 91177308-0d34-0410-b5e6-96231b3b80d8
b4d31306a4f9e84a7ab6ace99964634adb4bf7e6 31-Jul-2009 Devang Patel <dpatel@apple.com> Process DbgDeclareInst.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77694 91177308-0d34-0410-b5e6-96231b3b80d8
b5b56ba9d4df47e618d4e0f9e1e09bf216733ee8 30-Jul-2009 Dan Gohman <gohman@apple.com> Use CallbackVH in AliasSetTracker to avoid getting stuck with
dangling Value*s.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77623 91177308-0d34-0410-b5e6-96231b3b80d8
98c65173bb27e1df4ebe87f8c864d6dc197209ca 30-Jul-2009 Devang Patel <dpatel@apple.com> s/DebugInfoEnumerator/DebugInfoFinder/g

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77615 91177308-0d34-0410-b5e6-96231b3b80d8
e802f1c4c3c4d1e27117c66d428715d01fda385d 30-Jul-2009 Devang Patel <dpatel@apple.com> walk DbgRegionStartInst and DbgRegionEndInst

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77604 91177308-0d34-0410-b5e6-96231b3b80d8
15f72dbf972f056b1685786e5118148fb528f233 29-Jul-2009 Andreas Bolka <a@bolka.at> Skeleton for pairwise subscript testing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77437 91177308-0d34-0410-b5e6-96231b3b80d8
d2f79a13463f8797fbffa0e5d577c5bddc9126fb 28-Jul-2009 Devang Patel <dpatel@apple.com> Add DebugInfoEnumerator to collect debug info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77360 91177308-0d34-0410-b5e6-96231b3b80d8
c3cc45aa8be036412726ccd02d8a6496652eac2b 28-Jul-2009 Andreas Bolka <a@bolka.at> Simplify LDA-internal interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77359 91177308-0d34-0410-b5e6-96231b3b80d8
e2d5a6c3bb9b2c3bce78bb0143d8988bf6735d44 27-Jul-2009 Devang Patel <dpatel@apple.com> 80 columns!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77243 91177308-0d34-0410-b5e6-96231b3b80d8
07ad19b509530b43e6a9acc5c1285cb560dd7198 27-Jul-2009 Dan Gohman <gohman@apple.com> Fix wording in comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77193 91177308-0d34-0410-b5e6-96231b3b80d8
7e77f7959162a601291fd5400a88908d021033d3 25-Jul-2009 Dan Gohman <gohman@apple.com> Fix a few comments to say "backedge-taken count" instead of
"trip count".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77081 91177308-0d34-0410-b5e6-96231b3b80d8
fef8bb24de86ff41d09a7787c6c52b058a853e39 25-Jul-2009 Dan Gohman <gohman@apple.com> Instead of eagerly creating new SCEVs to replace all SCEVs that are
affected after a PHI node has been analyzed, just remove affected
SCEVs from the Scalars map, so that they'll be (lazily) recreated as
needed. This avoids creating SCEV objects that aren't actually needed.

Also, rewrite the associated def-use walking code to be non-recursive
and to continue traversing past Instructions that don't have an
entry in the Scalars map.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77032 91177308-0d34-0410-b5e6-96231b3b80d8
fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0b 25-Jul-2009 Dan Gohman <gohman@apple.com> Make AliasAnalysis and related classes use

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77028 91177308-0d34-0410-b5e6-96231b3b80d8
0baa25d5391c9e94215830382d21b92b786d9ab4 25-Jul-2009 Andreas Bolka <a@bolka.at> Forward-declare raw_ostream.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77014 91177308-0d34-0410-b5e6-96231b3b80d8
d3ff30455707d479dfb883b3ea12794bb37b91b3 24-Jul-2009 Dan Gohman <gohman@apple.com> Give SCEVAddRecExpr no-signed-overflow and no-unsigned-overflow flags.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76928 91177308-0d34-0410-b5e6-96231b3b80d8
2f1b15386f84a607304fca7e26fa6b67b490df4d 24-Jul-2009 Dan Gohman <gohman@apple.com> Give the SCEV class a SubclassData field.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76927 91177308-0d34-0410-b5e6-96231b3b80d8
a271d36d7ce96bce52fcb73ca1ef028d9a9d8d0f 24-Jul-2009 Dan Gohman <gohman@apple.com> Fix whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76926 91177308-0d34-0410-b5e6-96231b3b80d8
b4c28e97f4cccd6ec8b816183bada8d0845a8966 23-Jul-2009 Andreas Bolka <a@bolka.at> Cache dependence computation using FoldingSet.

This introduces an LDA-internal DependencePair class. The intention is,
that this is a place where dependence testers can store various results
such as SCEVs describing conflicting iterations, breaking conditions,
distance/direction vectors, etc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76877 91177308-0d34-0410-b5e6-96231b3b80d8
3b59dd886a9b8eacd39dd5774aaa989f277f6c88 23-Jul-2009 Andreas Bolka <a@bolka.at> Minor cosmetics: indentation, formatting, naming.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76839 91177308-0d34-0410-b5e6-96231b3b80d8
c4999d71e162bab8c38fe104554a3b81b4f08771 22-Jul-2009 Devang Patel <dpatel@apple.com> Add replaceAllUsesWith() to FE replace debug info constructs while building complex types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76765 91177308-0d34-0410-b5e6-96231b3b80d8
e922c0201916e0b980ab3cfe91e1413e68d55647 22-Jul-2009 Owen Anderson <resistor@mac.com> Get rid of the Pass+Context magic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76702 91177308-0d34-0410-b5e6-96231b3b80d8
0f4b285a5b86b1e9c6e27bb46028dfbb77bb5db4 22-Jul-2009 Dan Gohman <gohman@apple.com> Replace the original ad-hoc code for determining whether (v pred w) implies
(x pred y) with more thorough code that does more complete canonicalization
before resorting to range checks. This helps it find more cases where
the canonicalized expressions match.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76671 91177308-0d34-0410-b5e6-96231b3b80d8
fc8deb971d2b4dff370ba93948975e33a038605d 17-Jul-2009 Dan Gohman <gohman@apple.com> Commit this change, to accompany r76232.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76238 91177308-0d34-0410-b5e6-96231b3b80d8
001dbfebcbbded8c8e74b19e838b50da2b6c6fb5 16-Jul-2009 Owen Anderson <resistor@mac.com> Move the ConstantInt uniquing table into LLVMContextImpl. This exposed a number of issues in
our current context-passing stuff, which is also fixed here

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76089 91177308-0d34-0410-b5e6-96231b3b80d8
937738649386b8188524d0cd61943214a5b93cf6 16-Jul-2009 Dan Gohman <gohman@apple.com> Add an isLoopSimplifyForm() predicate, following the example of
isLCSSAForm(), to test whether a loop is in the form guaranteed
by the LoopSimplify pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76077 91177308-0d34-0410-b5e6-96231b3b80d8
688ed8583eaa1544e8e53b039b2b8284d2e9268a 16-Jul-2009 Dan Gohman <gohman@apple.com> Tidy up #includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76072 91177308-0d34-0410-b5e6-96231b3b80d8
206613b289f60b71a76e9190d36b9ea9e47a701e 15-Jul-2009 Dan Gohman <gohman@apple.com> Fix a typo in a comment that Duncan noticed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75804 91177308-0d34-0410-b5e6-96231b3b80d8
bdc017edacb713119b24ab269d250a82d62fffeb 15-Jul-2009 Dan Gohman <gohman@apple.com> Make makeLoopInvariant report whether it made any changes or not,
and use this to simplify more code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75722 91177308-0d34-0410-b5e6-96231b3b80d8
969f28dfb6478b1759cb13a216d3dc5515a889d1 14-Jul-2009 Torok Edwin <edwintorok@gmail.com> Introduce a pointertracking pass.
For now this only computes the allocated size of the memory pointed to by a
pointer, and offset a pointer from allocated pointer.
The actual checkLimits part will come later, after another round of review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75657 91177308-0d34-0410-b5e6-96231b3b80d8
c23197a26f34f559ea9797de51e187087c039c42 14-Jul-2009 Torok Edwin <edwintorok@gmail.com> llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.
This adds location info for all llvm_unreachable calls (which is a macro now) in
!NDEBUG builds.
In NDEBUG builds location info and the message is off (it only prints
"UREACHABLE executed").

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75640 91177308-0d34-0410-b5e6-96231b3b80d8
858cb8a5e07d4fe4b516a99eef7e8c028516a679 14-Jul-2009 Daniel Dunbar <daniel@zuster.org> ProfileInfo interface tweaks.
- Add getExecutionCount(const Function).

- Add helper Edge type.

- constify.

- No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75623 91177308-0d34-0410-b5e6-96231b3b80d8
a342026504e65e2c8dc5600dab4b45ab4f94026d 14-Jul-2009 Dan Gohman <gohman@apple.com> Introduce a new LoopInfo utility function makeLoopInvariant, which
works similar to isLoopInvariant, except that it will do trivial
hoisting to try to make the value loop invariant if it isn't already.
This makes it easier for transformation passes to clear trivial
instructions out of the way (the regular LICM pass doesn't run
until relatively late). This is code factored out of LoopSimplify
and other places.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75578 91177308-0d34-0410-b5e6-96231b3b80d8
03ee68a145ab5394c070298049d93f305be93ec3 14-Jul-2009 Dan Gohman <gohman@apple.com> Forward-declare Loop and LoopInfo instead of #including LoopInfo.h.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75529 91177308-0d34-0410-b5e6-96231b3b80d8
16a2c927e95c29a316d0271c93e0490ce3bc06ce 14-Jul-2009 Dan Gohman <gohman@apple.com> Move isLCSSAForm, isLoopInvariant, getCanonicalInductionVariable,
and related functions out of LoopBase and into Loop, since they
are specific to BasicBlock-based loops. This also allows the code
to be moved out-of-line.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75523 91177308-0d34-0410-b5e6-96231b3b80d8
c8d76d5afb023a1c6b439941be3b62789fcc0ed3 13-Jul-2009 Dan Gohman <gohman@apple.com> Make Loop and MachineLoop be subclasses of LoopBase, rather than typedefs,
using the Curiously Recurring Template Pattern with LoopBase.

This will help further refactoring, and future functionality for
Loop. Also, Headers can now foward-declare Loop, instead of pulling
in LoopInfo.h or doing tricks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75519 91177308-0d34-0410-b5e6-96231b3b80d8
85b05a2e60e0e696739167b52cc7cc3e7cf390c0 13-Jul-2009 Dan Gohman <gohman@apple.com> Reapply 75252, with a fix to avoid the infinite recursion case. The
check for avoiding re-analyzing a widening cast needed to happen
earlier, as getSCEV itself may result in a isLoopGuardedByCond query.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75511 91177308-0d34-0410-b5e6-96231b3b80d8
c050fd94c29e31414591e3a18aa20049e6b3a84f 13-Jul-2009 Dan Gohman <gohman@apple.com> Convert SCEV from FoldingSetNode to FastFoldingSetNode. This eliminates
a bunch of redundent code in Profile methods, and prepares for upcoming
changes to do improved memoization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75494 91177308-0d34-0410-b5e6-96231b3b80d8
deb052a3dd0227579f86d74b3c1d70384ea5c16b 13-Jul-2009 Daniel Dunbar <daniel@zuster.org> Match declaration to definition.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75440 91177308-0d34-0410-b5e6-96231b3b80d8
460d16e126c4c7223926f5066567398ee2236651 13-Jul-2009 Daniel Dunbar <daniel@zuster.org> Match declaration to definition.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75438 91177308-0d34-0410-b5e6-96231b3b80d8
d0cca2415099e80bd11e6b2090896719b07afd93 11-Jul-2009 Nick Lewycky <nicholas@mxc.ca> Revert r75252 which was causing some crashes at compile time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75384 91177308-0d34-0410-b5e6-96231b3b80d8
c25e7581b9b8088910da31702d4ca21c4734c6d7 11-Jul-2009 Torok Edwin <edwintorok@gmail.com> assert(0) -> LLVM_UNREACHABLE.
Make llvm_unreachable take an optional string, thus moving the cerr<< out of
LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for
NDEBUG builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75379 91177308-0d34-0410-b5e6-96231b3b80d8
1afdc5f3565f09d33de888fede895540059dca4c 10-Jul-2009 Dan Gohman <gohman@apple.com> Remove ScalarEvolution::hasSCEV, which isn't being used, and which
breaks encapsulation. Also remove a dead prototype for setSCEV.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75272 91177308-0d34-0410-b5e6-96231b3b80d8
1b342583f6fc42f548912632f6aa24fc6e11986a 10-Jul-2009 Dan Gohman <gohman@apple.com> Generalize ScalarEvolution's cast-folding code to support more kinds
of loops. Add several new functions to for working with ScalarEvolution's
add-hoc value-range analysis functionality.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75252 91177308-0d34-0410-b5e6-96231b3b80d8
45524c58fd5f77b6a3f6e77d43fba85b36ec0b08 10-Jul-2009 Owen Anderson <resistor@mac.com> Finish pushing LLVMContext through the IRBuilder/ConstantFolder interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75213 91177308-0d34-0410-b5e6-96231b3b80d8
7b9547089f0363b803e55dcbde1d6b99710dfe69 10-Jul-2009 Andreas Bolka <a@bolka.at> Fix typo, trailing whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75179 91177308-0d34-0410-b5e6-96231b3b80d8
d1fbd142945f5ef0c273c3d756431f8cb9d25ded 08-Jul-2009 Owen Anderson <resistor@mac.com> Push LLVMContext _back_ through IRBuilder.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75040 91177308-0d34-0410-b5e6-96231b3b80d8
59ae6b99872953761dfda5984801d23a66692673 08-Jul-2009 Dan Gohman <gohman@apple.com> Make the code that updates ScalarEvolution's internal state in response
to a loop deletion more thorough. Don't prune the def-use tree search at
instructions that don't have SCEVs computed, because an instruction with
a user that has a computed SCEV may itself lack a computed SCEV. Also,
remove loop-related values from the ValuesAtScopes and
ConstantEvolutionLoopExitValues maps as well.

This fixes a regression in 483.xalancbmk.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75030 91177308-0d34-0410-b5e6-96231b3b80d8
9903527c142a37a25ea3b2212cb04a182331fbfa 07-Jul-2009 Owen Anderson <resistor@mac.com> Re-LLVMContext-ize DebugInfo, now with less breakage.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74920 91177308-0d34-0410-b5e6-96231b3b80d8
0bba49cebc50c7bd4662a4807bcb3ee7f42cb470 07-Jul-2009 Dan Gohman <gohman@apple.com> Change all SCEV* to SCEV *.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74918 91177308-0d34-0410-b5e6-96231b3b80d8
07cf79ef537caff6d39145f190a28a336e629b6f 07-Jul-2009 Owen Anderson <resistor@mac.com> "LLVMContext* " --> "LLVMContext *"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74878 91177308-0d34-0410-b5e6-96231b3b80d8
76f600b205606a055ec35e7d3fd1a99602329d67 07-Jul-2009 Owen Anderson <resistor@mac.com> Finish LLVMContext-ing lib/Analysis. This required pushing LLVMContext's through the ValueTracking API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74873 91177308-0d34-0410-b5e6-96231b3b80d8
508955156a25a9abc470a29e1760aa176d341cf9 06-Jul-2009 Owen Anderson <resistor@mac.com> Thread LLVMContext through the constant folding APIs, which touches a lot of files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74844 91177308-0d34-0410-b5e6-96231b3b80d8
7e1e31f467d87c834d8baf673929865907901313 03-Jul-2009 Devang Patel <dpatel@apple.com> Simplify debug info intrisinc lowering.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74733 91177308-0d34-0410-b5e6-96231b3b80d8
dfc8536d7bedbd7ce826235d7b408c4e969ccc8c 02-Jul-2009 Devang Patel <dpatel@apple.com> Fix typo.
Thanks Duncan!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74706 91177308-0d34-0410-b5e6-96231b3b80d8
9e529c3f787ec18f237c5c7f0aa8952fcc345e9a 02-Jul-2009 Devang Patel <dpatel@apple.com> Add debug info utility routines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74680 91177308-0d34-0410-b5e6-96231b3b80d8
f530c92cd55f35f64904e42e38b3a2bc92b347cb 02-Jul-2009 Dan Gohman <gohman@apple.com> Fix a bunch of other places that used operator[] to test whether
a key is present in a std::map or DenseMap to use find instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74676 91177308-0d34-0410-b5e6-96231b3b80d8
fecbc59be6a53fb487a2405799d7a452e022142d 01-Jul-2009 Andreas Bolka <a@bolka.at> Use AA to check objects before LDA.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74647 91177308-0d34-0410-b5e6-96231b3b80d8
b1d7a5d1146c30a54002b7ab49daf024e3174b95 01-Jul-2009 Misha Brukman <brukman+llvm@gmail.com> Use correct format for LLVM header #includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74620 91177308-0d34-0410-b5e6-96231b3b80d8
f67799501cb8d17107133af658b8b705081b4c92 30-Jun-2009 Andreas Bolka <a@bolka.at> Drop redundant print impl.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74553 91177308-0d34-0410-b5e6-96231b3b80d8
f35626d3cda3af2f445a04322253a0d9dca607db 28-Jun-2009 Andreas Bolka <a@bolka.at> Minimal LDA interface, maximally conservative tester.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74401 91177308-0d34-0410-b5e6-96231b3b80d8
707207adaed969c32a09ae873ac5a171b3744617 28-Jun-2009 Andreas Bolka <a@bolka.at> LDA analysis output scaffolding.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74400 91177308-0d34-0410-b5e6-96231b3b80d8
9d59d9f8495b0361c9ffd1dc82888d8e7ba5070e 27-Jun-2009 Dan Gohman <gohman@apple.com> Eliminate a layer of indirection in LoopInfo and MachineLoopInfo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74394 91177308-0d34-0410-b5e6-96231b3b80d8
1c34375f79b7786351c27ae45f0412cfdfa004ed 27-Jun-2009 Dan Gohman <gohman@apple.com> Convert ScalarEvolution to use BumpPtrAllocator and FoldingSet, instead
of a team of individual allocations and a team of std::maps.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74393 91177308-0d34-0410-b5e6-96231b3b80d8
267a385342f2e7388f178b327dd87c5f29afd51b 27-Jun-2009 Dan Gohman <gohman@apple.com> Change SCEVExpander to use an IRBuilder to emit instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74391 91177308-0d34-0410-b5e6-96231b3b80d8
667d787c0a21cf3f5dfcde03ca471162ba35b614 27-Jun-2009 Dan Gohman <gohman@apple.com> Incorporate the insertion point into the key of SCEVExpander's CSE map.
This helps it avoid reusing an instruction that doesn't dominate all
of the users, in cases where the original instruction was inserted
before all of the users were known. This may result in redundant
expansions of sub-expressions that depend on loop-unpredictable values
in some cases, however this isn't very common, and it primarily impacts
IndVarSimplify, so GVN can be expected to clean these up.

This eliminates the need for IndVarSimplify's FixUsesBeforeDefs,
which fixes several bugs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74352 91177308-0d34-0410-b5e6-96231b3b80d8
d8ac1be6862c0611cc0b3a726ad4c3141e7a3d9e 26-Jun-2009 Jeffrey Yasskin <jyasskin@google.com> Delete LoopPass::runOnFunctionBody. It was never used or implemented.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74320 91177308-0d34-0410-b5e6-96231b3b80d8
e2f9382c727df18150a161058850ff432f7fe432 26-Jun-2009 Devang Patel <dpatel@apple.com> Remove unnecessary includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74254 91177308-0d34-0410-b5e6-96231b3b80d8
13e16b65ddd679d6edb5f182d683701fdea37b85 26-Jun-2009 Devang Patel <dpatel@apple.com> Remove debug info anchors - llvm.dbg.compile_units, llvm.dbg.subprograms
and llvm.dbg.global_variables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74251 91177308-0d34-0410-b5e6-96231b3b80d8
a278f3f55212e38c0647909f51ee7d2d6e41799a 25-Jun-2009 Dan Gohman <gohman@apple.com> Add a getUniqueExitBlock utility function, similar to getExitBlock,
but for getUniqueExitBlocks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74145 91177308-0d34-0410-b5e6-96231b3b80d8
09fc0fa0b179c1544a79ead002f565e2842db40c 25-Jun-2009 Owen Anderson <resistor@mac.com> Get rid of a static boolean.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74125 91177308-0d34-0410-b5e6-96231b3b80d8
cb21010fa0d7fd7018ddd966ca5bb48a47022ad0 24-Jun-2009 Andreas Bolka <a@bolka.at> Scaffolding for LDA pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74120 91177308-0d34-0410-b5e6-96231b3b80d8
650919e8b0aa28d20b8ff11f42ba81fea8b336cc 24-Jun-2009 Dan Gohman <gohman@apple.com> Remove an obsolete comment and fix some 80-column violations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74059 91177308-0d34-0410-b5e6-96231b3b80d8
40a5a1b39ee1cd40ff9d04740386b667fb27b340 24-Jun-2009 Dan Gohman <gohman@apple.com> Extend ScalarEvolution's multiple-exit support to compute exact
trip counts in more cases.

Generalize ScalarEvolution's isLoopGuardedByCond code to recognize
And and Or conditions, splitting the code out into an
isNecessaryCond helper function so that it can evaluate Ands and Ors
recursively, and make SCEVExpander be much more aggressive about
hoisting instructions out of loops.

test/CodeGen/X86/pr3495.ll has an additional instruction now, but
it appears to be due to an arbitrary register allocation difference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74048 91177308-0d34-0410-b5e6-96231b3b80d8
6bbcba18db6d1f4bc0f0157df41cc02627bc4aa9 24-Jun-2009 Dan Gohman <gohman@apple.com> Move the special cases for constants out of getUnknown and into
createSCEV. Also, recognize UndefValue in createSCEV.

Change getIntegerSCEV's comment to avoid mentioning FP types,
and re-implement it in terms of getConstant instead of getUnknown.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74041 91177308-0d34-0410-b5e6-96231b3b80d8
4d289bf4af88759be173a1a809bf8c092d729764 24-Jun-2009 Dan Gohman <gohman@apple.com> Add an isAllOnesValue utility function, similar to isZero and isOne.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74032 91177308-0d34-0410-b5e6-96231b3b80d8
9af2fa879ca5bc900ea44d2c45534287454844de 24-Jun-2009 Devang Patel <dpatel@apple.com> It is not a good idea to have data member's name match argument's name. In fact, it is a simple receipe to waste an hour or so.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74018 91177308-0d34-0410-b5e6-96231b3b80d8
0de4fa621e60a542d9bd43c09bd596ba452f035c 24-Jun-2009 Devang Patel <dpatel@apple.com> Add DISubprogram::getReturnTypeName()

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74015 91177308-0d34-0410-b5e6-96231b3b80d8
753ad615f96c3d56d6f17983bdba88012e88677c 22-Jun-2009 Owen Anderson <resistor@mac.com> Remove the parent pointer from SCEV, since it did not end up being needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73907 91177308-0d34-0410-b5e6-96231b3b80d8
372b46cad9f745859f542f9d2216991585ae83f4 22-Jun-2009 Owen Anderson <resistor@mac.com> SCEVHandle is no more!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73906 91177308-0d34-0410-b5e6-96231b3b80d8
08367b61638b4d446ebab69e2aad6431daa77ba7 22-Jun-2009 Owen Anderson <resistor@mac.com> Banish global state from ScalarEvolution! SCEV uniquing is now done by tables attached to the ScalarEvolution pass.
This also throws out the SCEV reference counting scheme, as the the SCEVs now have a lifetime controlled by the
ScalarEvolution pass.

Note that SCEVHandle is now a no-op, and will be remove in a future commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73892 91177308-0d34-0410-b5e6-96231b3b80d8
c9759e80f45e5690c3ed3b69c2e9ffd5a1bffd9c 22-Jun-2009 Dan Gohman <gohman@apple.com> Add a getUMinFromMismatchedTypes helper function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73883 91177308-0d34-0410-b5e6-96231b3b80d8
f9a9a9928cc977970d9852292b1c139074ecf055 22-Jun-2009 Dan Gohman <gohman@apple.com> Factor out code for computing umin and smin for SCEV expressions into
helper functions. Based on a patch by Nick Lewycky.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73869 91177308-0d34-0410-b5e6-96231b3b80d8
a334aa7a106d5ebb971862f25daaadad48d96235 22-Jun-2009 Dan Gohman <gohman@apple.com> Teach ScalarEvolution how to analyze loops with multiple exit
blocks, and also exit blocks with multiple conditions (combined
with (bitwise) ands and ors). It's often infeasible to compute an
exact trip count in such cases, but a useful upper bound can often
be found.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73866 91177308-0d34-0410-b5e6-96231b3b80d8
51f53b7f5a0e859ceef995c61667905166b96f1b 22-Jun-2009 Dan Gohman <gohman@apple.com> Fix ScalarEvolution's backedge-taken count computations to check for
overflow when computing a integer division to round up.

Thanks to Nick Lewycky for noticing this!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73862 91177308-0d34-0410-b5e6-96231b3b80d8
2c364ad4a65737f3bda876f86eba0061ecbd5470 20-Jun-2009 Dan Gohman <gohman@apple.com> Make GetMinTrailingZeros a member function of ScalarEvolution,
so that it can access the TargetData member (when available) and
use ValueTracking.h information to compute information for
SCEVUnknown Values.

Also add GetMinLeadingZeros and GetMinSignBits functions,
with minimal implementations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73794 91177308-0d34-0410-b5e6-96231b3b80d8
4a7893b4527819aae229f539ab9c3eeecc6a10e2 19-Jun-2009 Owen Anderson <resistor@mac.com> Add a parent pointer to SCEV, in preparation for getting rid of the global uniquing tables. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73728 91177308-0d34-0410-b5e6-96231b3b80d8
4e8a98519ebf75ed47456ea42706aaa57ecd2c27 18-Jun-2009 Dan Gohman <gohman@apple.com> Remove the code from IVUsers that attempted to handle
casted induction variables in cases where the cast
isn't foldable. It ended up being a pessimization in
many cases. This could be fixed, but it would require
a bunch of complicated code in IVUsers' clients. The
advantages of this approach aren't visible enough to
justify it at this time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73706 91177308-0d34-0410-b5e6-96231b3b80d8
6de29f8d960505421d61c80cdb738e16720b6c0e 16-Jun-2009 Dan Gohman <gohman@apple.com> Support vector casts in more places, fixing a variety of assertion

To support this, add some utility functions to Type to help support
vector/scalar-independent code. Change ConstantInt::get and
ConstantFP::get to support vector types, and add an overload to
ConstantInt::get that uses a static IntegerType type, for

Introduce a new getConstant method for ScalarEvolution, to simplify
common use cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73431 91177308-0d34-0410-b5e6-96231b3b80d8
444f49150df8a4280ccea20fc2839cd899fc7558 15-Jun-2009 Dan Gohman <gohman@apple.com> Specialize DenseMapInfo for SCEVHandle, so that SCEVHandles can be
used as keys in DenseMaps.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73360 91177308-0d34-0410-b5e6-96231b3b80d8
a82752c9eb5fbdd1b7276fde7349ac9453eb5a75 15-Jun-2009 Dan Gohman <gohman@apple.com> Convert several parts of the ScalarEvolution framework to use
SmallVector instead of std::vector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73357 91177308-0d34-0410-b5e6-96231b3b80d8
2ce84c8d4784dfd24458a63db8d531917d2f8ba5 13-Jun-2009 Dan Gohman <gohman@apple.com> Add a ScalarEvolution::getAnyExtendExpr utility function for performing
extension with unspecified bits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73293 91177308-0d34-0410-b5e6-96231b3b80d8
86fbf2fe4cae21febffa4bb2f64cd0c2ee834694 06-Jun-2009 Dan Gohman <gohman@apple.com> Rename UnknownValue to CouldNotCompute, since it holds an instance of
SCEVCouldNotCompute, and not SCEVUnknown.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72999 91177308-0d34-0410-b5e6-96231b3b80d8
1d09de3eca23267855e28297fcb40de3632ea47b 05-Jun-2009 Dan Gohman <gohman@apple.com> Move SCEVExpander::getOrInsertCanonicalInductionVariable out of line.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72949 91177308-0d34-0410-b5e6-96231b3b80d8
a8ba2c25e9ea7b0d213b485debe5d044efde66a4 03-Jun-2009 Eli Friedman <eli.friedman@gmail.com> PR4317: Handle splits where the new block is unreachable correctly in

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72810 91177308-0d34-0410-b5e6-96231b3b80d8
7714285efd2a7f4e503f0f600667193e63ee6d08 02-Jun-2009 Dan Gohman <gohman@apple.com> Change ConstantFoldConstantExpression to accept a null
TargetData pointer. The only thing it's used for are
calls to ConstantFoldCompareInstOperands and
ConstantFoldInstOperands, which both already accept a
null TargetData pointer. This makes
ConstantFoldConstantExpression easier to use in clients
where TargetData is optional.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72741 91177308-0d34-0410-b5e6-96231b3b80d8
014d53595c06a77d0f06f92ef8a7ab15e7e05c4a 02-Jun-2009 Dan Gohman <gohman@apple.com> Delete an unnecessary forward declaration.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72740 91177308-0d34-0410-b5e6-96231b3b80d8
d9480d0f6875d8aa3a0d91942d24f0ee416b1ff1 26-May-2009 Dan Gohman <gohman@apple.com> Give SCEVNaryExpr a doxygen comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72423 91177308-0d34-0410-b5e6-96231b3b80d8
6c0866ca8373da318741cc90ad7afd1bda22bb1b 25-May-2009 Dan Gohman <gohman@apple.com> Various comment fixes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72376 91177308-0d34-0410-b5e6-96231b3b80d8
d594e6f0345b3e1e4b640a7099596ca613da16d6 25-May-2009 Dan Gohman <gohman@apple.com> Change ScalarEvolution::getSCEVAtScope to always return the original value
in the case where a loop exit value cannot be computed, instead of only in
some cases while using SCEVCouldNotCompute in others. This simplifies
getSCEVAtScope's callers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72375 91177308-0d34-0410-b5e6-96231b3b80d8
453aa4fbf1083cc7f646a0ac21e2bcc384a91ae9 24-May-2009 Dan Gohman <gohman@apple.com> Generalize SCEVExpander::visitAddRecExpr's GEP persuit, and avoid
sending SCEVUnknowns to expandAddToGEP. This avoids the need for
expandAddToGEP to bend the rules and peek into SCEVUnknown

Factor out the code for testing whether a SCEV can be factored by
a constant for use in a GEP index. This allows it to handle
SCEVAddRecExprs, by recursing.

As a result, SCEVExpander can now put more things in GEP indices,
so it emits fewer explicit mul instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72366 91177308-0d34-0410-b5e6-96231b3b80d8
b679de2a21f5ecbae81b444290d72af93aa5b0b3 24-May-2009 Torok Edwin <edwintorok@gmail.com> The rewriter may hold references to instructions that are deleted because they are trivially dead.
Fix by clearing the rewriter cache before deleting the trivially dead
Also make InsertedExpressions use an AssertingVH to catch these
bugs easier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72364 91177308-0d34-0410-b5e6-96231b3b80d8
15002a2b528e04a5edcfccbec392f5d6b19f7f6a 21-May-2009 Eli Friedman <eli.friedman@gmail.com> Fix broken logic in DominatorTreeBase::Split. Part of PR4238.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72231 91177308-0d34-0410-b5e6-96231b3b80d8
e528fca6735158caefe5d6bb58dcbd0c108845c5 21-May-2009 Eli Friedman <eli.friedman@gmail.com> Fix indentation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72227 91177308-0d34-0410-b5e6-96231b3b80d8
0a8fe7a2458f0412bce1ed282fd1a3ca6fdc51bc 20-May-2009 Duncan Sands <baldrick@free.fr> When comparing DominanceFrontier's, advance iterators
before erasing nodes, not after. Otherwise dom frontier
checking reads from freed memory.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72168 91177308-0d34-0410-b5e6-96231b3b80d8
1959b7562e57f8394496e761486f23b187ac3f1b 19-May-2009 Dan Gohman <gohman@apple.com> Make SCEVCallbackVH a private nested class inside ScalarEvolution, as
it's an implementation detail.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72122 91177308-0d34-0410-b5e6-96231b3b80d8
5be18e84766fb495b0bde3c8244c1df459a18683 19-May-2009 Dan Gohman <gohman@apple.com> Teach SCEVExpander to expand arithmetic involving pointers into GEP
instructions. It attempts to create high-level multi-operand GEPs,
though in cases where this isn't possible it falls back to casting
the pointer to i8* and emitting a GEP with that. Using GEP instructions
instead of ptrtoint+arithmetic+inttoptr helps pointer analyses that
don't use ScalarEvolution, such as BasicAliasAnalysis.

Also, make the AddrModeMatcher more aggressive in handling GEPs.
Previously it assumed that operand 0 of a GEP would require a register
in almost all cases. It now does extra checking and can do more
matching if operand 0 of the GEP is foldable. This fixes a problem
that was exposed by SCEVExpander using GEPs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72093 91177308-0d34-0410-b5e6-96231b3b80d8
6c3534c5aa6b1d34b277dfaca3af86ac41e53f0e 19-May-2009 Dan Gohman <gohman@apple.com> Add some comments noting how IndVarSimplify facilitates
LoopInfo functionality.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72091 91177308-0d34-0410-b5e6-96231b3b80d8
39592233304acbbeea8c53bac2b6a822a63a4c4b 19-May-2009 Dan Gohman <gohman@apple.com> Update a comment to reflect changes in the surrounding code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72051 91177308-0d34-0410-b5e6-96231b3b80d8
859b4824eeb2d88c441e855afe3dd7827dfd62a4 18-May-2009 Dan Gohman <gohman@apple.com> Make ScalarEvolution::isLoopGuardedByCond work even when the edge
entering a loop is a non-split critical edge.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72004 91177308-0d34-0410-b5e6-96231b3b80d8
70a1fe704831f9b842be0b2a2af5f7082b0e540c 18-May-2009 Dan Gohman <gohman@apple.com> Add an isOne() utility function to ScalarEvolution, similar to isZero()
and similar to ConstantInt's isOne().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72003 91177308-0d34-0410-b5e6-96231b3b80d8
dc817b6f4220ea386f9621800d64f4c0e36f75c7 14-May-2009 Bill Wendling <isanbard@gmail.com> Non-functionality changes:

- Reformatting.
- Use while() instead of do-while().
- Move simple constructors into .h file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71782 91177308-0d34-0410-b5e6-96231b3b80d8
467c430316b7a5b6fa8069531ca8d603b1e1197f 13-May-2009 Dan Gohman <gohman@apple.com> Add three new helper routines, getNoopOrZeroExtend,
getNoopOrSignExtend, and getTruncateOrNoop. These are similar
to getTruncateOrZeroExtend etc., except that they assert that
the conversion is either not widening or narrowing, as
appropriate. These will be used in some upcoming fixes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71632 91177308-0d34-0410-b5e6-96231b3b80d8
b877a1f5458e26bb1020d4a07637d898559fc8a7 12-May-2009 Bill Wendling <isanbard@gmail.com> More MSVC fixes -- class/struct conflicts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71601 91177308-0d34-0410-b5e6-96231b3b80d8
81db61a2e6d3c95a2738c3559a108e05e9d7a05a 12-May-2009 Dan Gohman <gohman@apple.com> Factor the code for collecting IV users out of LSR into an IVUsers class,
and generalize it so that it can be used by IndVarSimplify. Implement the
base IndVarSimplify transformation code using IVUsers. This removes
TestOrigIVForWrap and associated code, as ScalarEvolution now has enough
builtin overflow detection and folding logic to handle all the same cases,
and more. Run "opt -iv-users -analyze -disable-output" on your favorite
loop for an example of what IVUsers does.

This lets IndVarSimplify eliminate IV casts and compute trip counts in
more cases. Also, this happens to finally fix the remaining testcases
in PR1301.

Now that IndVarSimplify is being more aggressive, it occasionally runs
into the problem where ScalarEvolutionExpander's code for avoiding
duplicate expansions makes it difficult to ensure that all expanded
instructions dominate all the instructions that will use them. As a
temporary measure, IndVarSimplify now uses a FixUsesBeforeDefs function
to fix up instructions inserted by SCEVExpander. Fortunately, this code
is contained, and can be easily removed once a more comprehensive
solution is available.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71535 91177308-0d34-0410-b5e6-96231b3b80d8
fb791608115b5193419549b02825ed4337fd3a37 08-May-2009 Dan Gohman <gohman@apple.com> Fix another bug in r71252. This code supports GetElementPtr
constant exprs as well as instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71262 91177308-0d34-0410-b5e6-96231b3b80d8
6bce643c36e7263aada5058f08cd242b4ce6b87d 08-May-2009 Dan Gohman <gohman@apple.com> Add memoization for getSCEVAtScope results for instructions
which are not analyzed with SCEV techniques, which can require
brute-forcing through a large number of instructions. This
fixes a massive compile-time issue on 400.perlbench (in
particular, the loop in MD5Transform).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71259 91177308-0d34-0410-b5e6-96231b3b80d8
66a7e857aa5843da3a7d0f52aa09a5935cf565dc 08-May-2009 Dan Gohman <gohman@apple.com> Make the SCEV* form of getSCEVAtScope public, to allow ScalarEvolution
clients to use it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71258 91177308-0d34-0410-b5e6-96231b3b80d8
26466c0eb3451c5c953b3cca8940359152c4f8e3 08-May-2009 Dan Gohman <gohman@apple.com> Factor out the code for creating SCEVs for GEPs into a
separate function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71252 91177308-0d34-0410-b5e6-96231b3b80d8
1827e8263c9cb5dc29eea4999d8729f7376af4e1 08-May-2009 Dan Gohman <gohman@apple.com> Add a getExitBlock utility function to LoopInfo which returns the
exit block of a loop, if there is exactly one, similar to

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71245 91177308-0d34-0410-b5e6-96231b3b80d8
9a38e3e3991ea443e555d8060f91202a786acdd4 07-May-2009 Dan Gohman <gohman@apple.com> Revert 71165. It did more than just revert 71158 and it introduced
several regressions. The problem due to 71158 is now fixed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71176 91177308-0d34-0410-b5e6-96231b3b80d8
5b8479c38532a28d86dea8ded09a30ff68f26912 07-May-2009 Bill Wendling <isanbard@gmail.com> Temporarily revert r71158. It was causing a failure during a full bootstrap:

checking for bcopy... no
checking for getc_unlocked... Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511.
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decUtility.c:360: internal compiler error: Abort trap
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
make[4]: *** [decUtility.o] Error 1
make[4]: *** Waiting for unfinished jobs....
Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511.
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decNumber.c:5591: internal compiler error: Abort trap
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
make[4]: *** [decNumber.o] Error 1
make[3]: *** [all-stage2-libdecnumber] Error 2
make[3]: *** Waiting for unfinished jobs....

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71165 91177308-0d34-0410-b5e6-96231b3b80d8
ecb403a9d3a340009c266d05cfca2bd778c7b156 07-May-2009 Dan Gohman <gohman@apple.com> Factor out a common base class between SCEVCommutativeExpr and
SCEVAddRecExpr. This eliminates redundant code for visiting
all the operands of an expression.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71157 91177308-0d34-0410-b5e6-96231b3b80d8
16de0136404b7e4703e528ae6f641c6fb7ee2f8b 06-May-2009 Bill Wendling <isanbard@gmail.com> Add dump method to DIDescriptor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71028 91177308-0d34-0410-b5e6-96231b3b80d8
35738ac150afafe2359268d4b2169498c6c98c5f 05-May-2009 Dan Gohman <gohman@apple.com> Re-apply 70645, converting ScalarEvolution to use
CallbackVH, with fixes. allUsesReplacedWith need to
walk the def-use chains and invalidate all users of a
value that is replaced. SCEVs of users need to be
recalcualted even if the new value is equivalent. Also,
make forgetLoopPHIs walk def-use chains, since any
SCEV that depends on a PHI should be recalculated when
more information about that PHI becomes available.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70927 91177308-0d34-0410-b5e6-96231b3b80d8
77eaa6880b8209acc05de733ebaba5d146c321a0 03-May-2009 Argyrios Kyrtzidis <akyrtzi@gmail.com> -Move the DwarfWriter::ValidDebugInfo check to a static DIDescriptor::ValidDebugInfo
-Create DebugLocs without the need to have a DwarfWriter around

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70682 91177308-0d34-0410-b5e6-96231b3b80d8
f9a77b77c2324b2ca5c644909ebda387daf82fe3 03-May-2009 Dan Gohman <gohman@apple.com> Revert r70645 for now; it's causing a variety of regressions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70661 91177308-0d34-0410-b5e6-96231b3b80d8
db6fa2964176c34f0e878e101427c28782c93419 02-May-2009 Dan Gohman <gohman@apple.com> Convert ScalarEvolution to use CallbackVH for its internal map. This
makes ScalarEvolution::deleteValueFromRecords, and it's code that
subtly needed to be called before ReplaceAllUsesWith, unnecessary.

It also makes ValueDeletionListener unnecessary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70645 91177308-0d34-0410-b5e6-96231b3b80d8
fb7d35f22a958747dd3ae8861ae3ce018146131c 02-May-2009 Dan Gohman <gohman@apple.com> When ScalarEvolution is told to forget the trip count for a loop, have
it also forget any SCEVs associated with loop-header PHIs in the loop,
as they may be dependent on trip count information.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70633 91177308-0d34-0410-b5e6-96231b3b80d8
cf5ab820227dedd77fb91d0904b6dc3694a7c196 01-May-2009 Dan Gohman <gohman@apple.com> Actually insert inserted instructions into the InsertedValues map.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70557 91177308-0d34-0410-b5e6-96231b3b80d8
b52e1c587f166c6fb8b9abeaaeaee3bda944091b 01-May-2009 Dan Gohman <gohman@apple.com> Add an accessor method to allow clients to test if a given expression
is associated with a SCEV expansion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70556 91177308-0d34-0410-b5e6-96231b3b80d8
99a1302ae4c438ab532826685280c0b69687e163 01-May-2009 Dan Gohman <gohman@apple.com> Make SCEVExpander::addInsertedValue able to accept Values, not just

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70552 91177308-0d34-0410-b5e6-96231b3b80d8
3d739fe3756bf67be23c2ca54ec7b04bef89bfe0 30-Apr-2009 Dan Gohman <gohman@apple.com> Add some comments, and tidy up some whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70510 91177308-0d34-0410-b5e6-96231b3b80d8
a1af757e0af9c2fb5ade4b06408e1adfa0425c6c 30-Apr-2009 Dan Gohman <gohman@apple.com> Extend ScalarEvolution's getBackedgeTakenCount to be able to
compute an upper-bound value for the trip count, in addition to
the actual trip count. Use this to allow getZeroExtendExpr and
getSignExtendExpr to fold casts in more cases.

This may eventually morph into a more general value-range
analysis capability; there are certainly plenty of places where
more complete value-range information would allow more folding.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70509 91177308-0d34-0410-b5e6-96231b3b80d8
1e59aa1332b67256dc0e76237eab7f6dd21a25b4 29-Apr-2009 Dan Gohman <gohman@apple.com> Add some more doxygen comments to SCEVAddRec.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70354 91177308-0d34-0410-b5e6-96231b3b80d8
752ec7da506f5d41c08bd37e195750b57550ce68 23-Apr-2009 Dan Gohman <gohman@apple.com> Change SCEVExpander's expandCodeFor to provide more flexibility
with the persistent insertion point, and change IndVars to make
use of it. This fixes a bug where IndVars was holding on to a
stale insertion point and forcing the SCEVExpander to continue to
use it.

This fixes PR4038.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69892 91177308-0d34-0410-b5e6-96231b3b80d8
6cdc727f2d7f68734526ef078f4632798ad40791 22-Apr-2009 Dan Gohman <gohman@apple.com> Use BasicBlock::iterator instead of Instruction* for insert points,
to better handle inserting instructions at the end of a block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69807 91177308-0d34-0410-b5e6-96231b3b80d8
b928c57397f61e4c54274818dd63e61e21016d9d 22-Apr-2009 Dan Gohman <gohman@apple.com> Make SCEVExpanders private methods private, instead of protected.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69806 91177308-0d34-0410-b5e6-96231b3b80d8
f8a8be86e3972608741c1e1ecb89ec3c6f570552 22-Apr-2009 Dan Gohman <gohman@apple.com> De-pImpl-ify ScalarEvolution. The pImpl pattern doesn't provide much
practical benefit in the case of ScalarEvolution, and it's otherwise
a nuisance.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69749 91177308-0d34-0410-b5e6-96231b3b80d8
84923602fdc2a81957e5dee178d5737ad8e72f55 21-Apr-2009 Dan Gohman <gohman@apple.com> Factor out a common base class from SCEVTruncateExpr, SCEVZeroExtendExpr,
and SCEVSignExtendExpr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69649 91177308-0d34-0410-b5e6-96231b3b80d8
af79fb5f47b0088c6a8973a7fdbaea96973a429d 21-Apr-2009 Dan Gohman <gohman@apple.com> Introduce encapsulation for ScalarEvolution's TargetData object, and refactor
the code to minimize dependencies on TargetData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69644 91177308-0d34-0410-b5e6-96231b3b80d8
b7ef72963b2215ca23c27fa8ea777bada06994d0 21-Apr-2009 Dan Gohman <gohman@apple.com> Convert ScalarEvolution to use raw_ostream instead of OStream.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69640 91177308-0d34-0410-b5e6-96231b3b80d8
f4ccfcb70402b34ee55e0b5820cf287b95a8762f 18-Apr-2009 Dan Gohman <gohman@apple.com> Add a ScalarEvolution::getCouldNotCompute() function, and use it
instead of allocating and leaking new SCEVCouldNotCompute objects.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69452 91177308-0d34-0410-b5e6-96231b3b80d8
890f92b744fb074465bc2b7006ee753a181f62a4 18-Apr-2009 Dan Gohman <gohman@apple.com> Use more const qualifiers with SCEV interfaces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69450 91177308-0d34-0410-b5e6-96231b3b80d8
f04fa483b83227c570bc58e1684ea096430a6697 16-Apr-2009 Dan Gohman <gohman@apple.com> Teach SCEVExpander::InsertCastOfTo to avoid creating inttoptr-of-ptrtoint
and ptrtoint-of-inttoptr expressions. This fixes a regression in 300.twolf.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69293 91177308-0d34-0410-b5e6-96231b3b80d8
2d1be87ee40a4a0241d94448173879d9df2bc5b3 16-Apr-2009 Dan Gohman <gohman@apple.com> Expand GEPs in ScalarEvolution expressions. SCEV expressions can now
have pointer types, though in contrast to C pointer types, SCEV
addition is never implicitly scaled. This not only eliminates the
need for special code like IndVars' EliminatePointerRecurrence
and LSR's own GEP expansion code, it also does a better job because
it lets the normal optimizations handle pointer expressions just
like integer expressions.

Also, since LLVM IR GEPs can't directly index into multi-dimensional
VLAs, moving the GEP analysis out of client code and into the SCEV
framework makes it easier for clients to handle multi-dimensional
VLAs the same way as other arrays.

Some existing regression tests show improved optimization.
test/CodeGen/ARM/2007-03-13-InstrSched.ll in particular improved to
the point where if-conversion started kicking in; I turned it off
for this test to preserve the intent of the test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69258 91177308-0d34-0410-b5e6-96231b3b80d8
af5b6bb6a539f1d4cc3b0f0e10b3c3c9267bbfd1 15-Apr-2009 Devang Patel <dpatel@apple.com> Add a method to check that the subprogram holds debug info for the given Function or not.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69113 91177308-0d34-0410-b5e6-96231b3b80d8
56946ed5bbd60fe3276a674668cbd835f8ebc772 09-Apr-2009 Chris Lattner <sabre@nondot.org> add an accessor method, patch by John McCall!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68684 91177308-0d34-0410-b5e6-96231b3b80d8