Commit Graph

4819 Commits

Author SHA1 Message Date
Craig Topper
390ff499f0 Remove x86_sse42_crc32_64_8 intrinsic. It has no functional difference from x86_sse42_crc32_32_8 and was not mapped to a clang builtin. I'm not even sure why this form of the instruction is even called out explicitly in the docs. Also add AutoUpgrade support to convert it into the other intrinsic with appropriate trunc and zext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192672 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-15 05:20:47 +00:00
Matt Arsenault
cee51c4803 Rename DataLayout variables TD -> DL
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191927 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-03 19:50:01 +00:00
Benjamin Kramer
4d63c8daec CaptureTracking: Plug a loophole in the "too many uses" heuristic.
The heuristic was added to avoid spending too much compile time A specially
crafted test case (PR17461, PR16474) with many uses on a select or bitcast
instruction can still trigger the slow case. Add a check for that case.

This only affects compile time, don't have a good way to test it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191896 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-03 13:24:02 +00:00
Chandler Carruth
dd5d86d992 Remove the very substantial, largely unmaintained legacy PGO
infrastructure.

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
runtimes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191835 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-02 15:42:23 +00:00
Rafael Espindola
8819c84aed Remove several unused variables.
Patch by Alp Toker.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191757 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-01 13:32:03 +00:00
Benjamin Kramer
341562b9fb SCEVExpander: Fix a regression I introduced by to eagerly adding RAII objects.
PR17425.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191741 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-01 12:17:11 +00:00
Benjamin Kramer
d427882166 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
2013-09-30 15:40:17 +00:00
Benjamin Kramer
2f08433210 ObjectSizeOffsetEvaluator: Don't run into infinite recursion if we have a cyclic GEP.
Those can occur in dead code. PR17402.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191644 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-29 19:39:13 +00:00
Manman Ren
e5f32cf320 TBAA: try to fix the dragonegg bots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191585 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-27 22:59:21 +00:00
Matt Arsenault
9ed1a3cddb Minor code simplification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191579 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-27 22:38:23 +00:00
Matt Arsenault
b060a46b0d Use type helper functions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191574 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-27 22:18:51 +00:00
Manman Ren
9e81c3bdb2 TBAA: handle scalar TBAA format and struct-path aware TBAA format.
Remove the command line argument "struct-path-tbaa" since we should not depend
on command line argument to decide which format the IR file is using. Instead,
we check the first operand of the tbaa tag node, if it is a MDNode, we treat
it as struct-path aware TBAA format, otherwise, we treat it as scalar TBAA
format.

When clang starts to use struct-path aware TBAA format no matter whether
struct-path-tbaa is no, and we can auto-upgrade existing bc files, the support
for scalar TBAA format can be dropped.

Existing testing cases are updated to use the struct-path aware TBAA format.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191538 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-27 18:34:27 +00:00
Benjamin Kramer
09b16f3bb5 MemoryBuiltins: Remove posix_memalign from the list and replace it with a TODO.
This code isn't ready to deal with allocation functions where the return is not
the allocated pointer. The checks below will reject posix_memalign anyways.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191319 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-24 17:49:08 +00:00
Benjamin Kramer
d44f9f2ff8 MemoryBuiltins: Reinstate optimizing (uninitialized) loads from operator new.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191315 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-24 17:34:29 +00:00
Benjamin Kramer
989779ccc7 MemoryBuiltins: Fix operator new bits.
We really don't want to optimize malloc return value checks away.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191313 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-24 17:15:14 +00:00
Benjamin Kramer
6629210aaf Teach MemoryBuiltins and InstructionSimplify that operator new never returns NULL.
This is safe per C++11 18.6.1.1p3: [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
2013-09-24 16:37:51 +00:00
Benjamin Kramer
baca5334db InstSimplify: Fold equality comparisons between non-inbounds GEPs.
Overflow doesn't affect the correctness of equalities. Computing this is cheap,
we just reuse the computation for the inbounds case and try to peel of more
non-inbounds GEPs. This pattern is unlikely to ever appear in code generated by
Clang, but SCEV occasionally produces it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191200 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-23 14:16:38 +00:00
Matt Arsenault
2334b0e802 Fix a constant folding address space place I missed.
If address space 0 was smaller than the address space
in a constant inttoptr/ptrtoint pair, the wrong mask size
would be used.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190899 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-17 23:23:16 +00:00
Eric Christopher
2bc3cd83b3 Move variable into assert to avoid unused variable warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190886 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-17 21:13:57 +00:00
Arnold Schwaighofer
65457b679a 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
2013-09-17 18:06:50 +00:00
Krzysztof Parzyszek
e7262388ed In AliasSetTracker, do not change the alias set to "mod/ref" when adding
a volatile load, or a volatile store.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190631 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-12 20:15:50 +00:00
Matt Arsenault
180df81c8f Move variable under condition where it is used
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190567 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-12 01:07:58 +00:00
Hal Finkel
4f7e2c38e8 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
2013-09-11 19:25:43 +00:00
Matt Arsenault
14807bd8c8 Teach ScalarEvolution about pointer address spaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190425 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10 19:55:24 +00:00
Manman Ren
0b3d39235a TBAA: add isTBAAVtableAccess to MDNode so clients can call the function
instead of having its own implementation.

The implementation of isTBAAVtableAccess is in TypeBasedAliasAnalysis.cpp
since it is related to the format of TBAA metadata.

The path for struct-path tbaa will be exercised by
test/Instrumentation/ThreadSanitizer/read_from_global.ll, vptr_read.ll, and
vptr_update.ll when struct-path tbaa is on by default.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190216 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-06 22:47:05 +00:00
Hal Finkel
f208398528 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
2013-08-29 03:33:15 +00:00
Hal Finkel
32f258b96a 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
2013-08-29 03:29:57 +00:00
Matt Arsenault
f9355c80d5 Handle address spaces in TargetTransformInfo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189527 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-28 22:41:57 +00:00
Matt Arsenault
e3e5f77d77 Fix lint assert on integer vector division
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189290 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-26 23:29:33 +00:00
Jakub Staszak
394e5a9ee8 Remove trailing spaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189173 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-24 14:16:00 +00:00
Richard Sandiford
a8a7099c18 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
2013-08-23 10:27:02 +00:00
Bill Wendling
dd778b230e Reorder headers according to lint.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188932 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-21 21:14:19 +00:00
Jakub Staszak
328a4fbfbb Add some constantness.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188844 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-20 23:04:15 +00:00
Matt Arsenault
80f495aab0 Teach ConstantFolding about pointer address spaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188831 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-20 21:20:04 +00:00
Matt Arsenault
c4d070ad07 Fix assert with GEP ptr vector indexing structs
Also fix it calculating the wrong value. The struct index
is not a ConstantInt, so it was being interpreted as an array
index.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188713 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-19 21:43:16 +00:00
Hal Finkel
19046ec19c Fix SCEVExpander creating distinct duplicate PHI entries
This fixes SCEVExpander so that it does not create multiple distinct induction
variables for duplicate PHI entries. Specifically, given some code like this:

do.body6:                                         ; preds = %do.body6, %do.body6, %if.then5
  %end.0 = phi i8* [ undef, %if.then5 ], [ %incdec.ptr, %do.body6 ], [ %incdec.ptr, %do.body6 ]
...

Note that it is legal to have multiple entries for a basic block so long as the
associated value is the same. So the above input is okay, but expanding an
AddRec in this loop could produce code like this:

do.body6:                                         ; preds = %do.body6, %do.body6, %if.then5
  %indvar = phi i64 [ %indvar.next, %do.body6 ], [ %indvar.next1, %do.body6 ], [ 0, %if.then5 ]
  %end.0 = phi i8* [ undef, %if.then5 ], [ %incdec.ptr, %do.body6 ], [ %incdec.ptr, %do.body6 ]
...
  %indvar.next = add i64 %indvar, 1
  %indvar.next1 = add i64 %indvar, 1

And this is not legal because there are two PHI entries for %do.body6 each with
a distinct value.

Unfortunately, I don't have an in-tree test case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188614 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-18 00:16:23 +00:00
Nick Lewycky
72dba254ae 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
2013-08-13 00:03:47 +00:00
Matt Arsenault
89fa38e15c Slightly simplify code with helper functions
e.g. Use Ty->getPointerElementType()
instead of cast<PointerType>(Ty)->getElementType()

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188223 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 23:15:58 +00:00
Matt Arsenault
b36f2f729d Add some braces, and spaces around operators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188219 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 22:56:15 +00:00
Matt Arsenault
d080fb103f Teach ValueTracking about address spaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188140 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-10 17:34:08 +00:00
Evgeniy Stepanov
35d2102133 Disable inlining between sanitized and non-sanitized functions.
Inlining between functions with different values of sanitize_* attributes
leads to over- or under-sanitizing, which is always bad.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187967 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-08 08:22:39 +00:00
Hal Finkel
41418d17cc Add ISD::FROUND for libm round()
All libm floating-point rounding functions, except for round(), had their own
ISD nodes. Recent PowerPC cores have an instruction for round(), and so here I'm
adding ISD::FROUND so that round() can be custom lowered as well.

For the most part, this is straightforward. I've added an intrinsic
and a matching ISD node just like those for nearbyint() and friends. The
SelectionDAG pattern I've named frnd (because ISD::FP_ROUND has already claimed
fround).

This will be used by the PowerPC backend in a follow-up commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187926 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-07 22:49:12 +00:00
Jakub Staszak
62d6fa5e8f Remove extraneous semicolon.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187806 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-06 16:40:40 +00:00
Matt Arsenault
6b4dde71cf Minor address space code simplification.
Remove assertion that the verifier should catch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187692 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-03 01:03:12 +00:00
Matt Arsenault
7eef3bdd7b Teach InstructionSimplify about pointer address spaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187635 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-02 00:10:44 +00:00
Andrew Trick
d832d32f57 Fix a severe compile time problem when forming large SCEV expressions.
This fix is very lightweight. The same fix already existed for AddRec
but was missing for NAry expressions.

This is obviously an improvement and I'm unsure how to test compile
time problems.

Patch by Xiaoyi Guo!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187475 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-31 02:43:40 +00:00
David Majnemer
36850ad779 isKnownToBeAPowerOfTwo: Strengthen isKnownToBeAPowerOfTwo's analysis on add instructions
Call into ComputeMaskedBits to figure out which bits are set on both add
operands and determine if the value is a power-of-two-or-zero or not.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187445 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-30 21:01:36 +00:00
Nick Lewycky
b66d765993 Also update CMakeLists.txt for r187283.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187284 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-27 01:25:51 +00:00
Nick Lewycky
81e480463d 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
2013-07-27 01:24:00 +00:00
Tom Stellard
57e6b2d1f3 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
2013-07-27 00:01:07 +00:00
Richard Smith
72c8331ec1 Treat nothrow forms of ::operator delete and ::operator delete[] as
deallocation functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186798 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-21 23:11:42 +00:00
Andrew Trick
360fef5f43 Comment: try to clarify loop iteration order.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186774 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-20 23:10:31 +00:00
Matt Arsenault
ff29d235ed Have InlineCost check constant fcmps
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186758 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-20 04:09:00 +00:00
Nick Lewycky
717b3f02ff Give 'hasPath' a longer but clearer name 'isPotentiallyReachable'. Also expand
the comment. No functionality change. This change broken out of
http://llvm-reviews.chandlerc.com/D996 .


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186558 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-18 02:34:51 +00:00
Craig Topper
4172a8abba Add 'const' qualifiers to static const char* variables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186371 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-16 01:17:10 +00:00
Craig Topper
a0ec3f9b7b 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
2013-07-14 04:42:23 +00:00
Andrew Trick
6f71dd765a Remove a bunch of old SCEVExpander FIXME's for preserving NoWrap.
The great thing about the SCEVAddRec No-Wrap flag (unlike nsw/nuw) is
that is can be preserved while normalizing (reassociating and
factoring).

The bad thing is that is can't be tranfered back to IR, which is one
of the reasons I don't like the concept of SCEVExpander.

Sorry, I can't think of a direct way to test this, which is why these
were FIXMEs for so long. I just think it's a good time to finally
clean it up.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186273 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-14 03:10:08 +00:00
Andrew Trick
409443b1c6 Teach indvars to generate nsw/nuw flags when widening an induction variable.
Fixes PR16600.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186272 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-14 02:50:07 +00:00
Nick Lewycky
8a23270ce6 Fix logic error optimizing "icmp pred (urem X, Y), Y" where pred is signed.
Fixes PR16605.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186229 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 23:42:57 +00:00
Arnold Schwaighofer
c0a11edba6 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
cost.
Tests and cost model for targets will be in follow-up commits.

radar://14351991

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186187 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 19:16:02 +00:00
Shuxin Yang
a10369920f 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
2013-07-12 07:25:38 +00:00
Craig Topper
9e639e8fd9 Use SmallVectorImpl& instead of SmallVector to avoid repeating small vector size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186098 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 16:22:38 +00:00
Benjamin Kramer
0a230e0d98 Don't use a potentially expensive shift if all we want is one set bit.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186095 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 16:05:50 +00:00
Craig Topper
2ebba647ea Fix indentation. No functional change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186065 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 05:39:44 +00:00
David Majnemer
8c5c6f0e09 InstSimplify: X >> X -> 0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185973 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-09 22:01:22 +00:00
Hal Finkel
033e0a94cb Don't crash in SE dealing with ashr x, -1
ScalarEvolution::getSignedRange uses ComputeNumSignBits from ValueTracking on
ashr instructions. ComputeNumSignBits can return zero, but this case was not
handled correctly by the code in getSignedRange which was calling:
  APInt::getSignedMinValue(BitWidth).ashr(NS - 1)
with NS = 0, resulting in an assertion failure in APInt::ashr.

Now, we just return the conservative result (as with NS == 1).

Another bug found by llvm-stress.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185955 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-09 18:16:16 +00:00
David Majnemer
ab6ceab8a6 ValueTracking: Fix bugs in isKnownToBeAPowerOfTwo
(add nsw x, (and x, y)) isn't a power of two if x is zero, it's zero
(add nsw x, (xor x, y)) isn't a power of two if y has bits set that aren't set in x


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185954 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-09 18:11:10 +00:00
Shuxin Yang
5e915e6e36 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.

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

 rdar://14283433


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185843 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-08 17:33:13 +00:00
Nick Lewycky
37ade2b801 Eliminate trivial redundant loads across nocapture+readonly calls to uncaptured
pointer arguments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185776 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-07 10:15:16 +00:00
David Majnemer
429aead069 isKnownToBeAPowerOfTwo: Fix a typo in a comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185748 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-06 02:24:59 +00:00
Nick Lewycky
dc89737bcd Extend 'readonly' and 'readnone' to work on function arguments as well as
functions. Make the function attributes pass add it to known library functions
and when it can deduce it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185735 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-06 00:29:58 +00:00
Craig Topper
6227d5c690 Use SmallVectorImpl::iterator/const_iterator instead of SmallVector to avoid specifying the vector size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185606 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-04 01:31:24 +00:00
Craig Topper
365ef0b197 Use SmallVectorImpl::iterator/const_iterator instead of SmallVector to avoid specifying the vector size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185540 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-03 15:07:05 +00:00
David Majnemer
58b6dc032a ValueTracking: Teach isKnownToBeAPowerOfTwo about (ADD X, (XOR X, Y)) where X is a power of two
This allows us to simplify urem instructions involving the add+xor to
turn into simpler math.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185272 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-29 23:44:53 +00:00
Preston Briggs
26ba495309 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185187 91177308-0d34-0410-b5e6-96231b3b80d8 2013-06-28 18:44:48 +00:00
Michael Gottesman
2253a2f52f Added support for the Builtin attribute.
The Builtin attribute is an attribute that can be placed on function call site that signal that even though a function is declared as being a builtin,

rdar://problem/13727199

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185049 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-27 00:25:01 +00:00
Benjamin Kramer
75b5162154 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
2013-06-25 13:34:40 +00:00
Nick Lewycky
45dec48dc3 Fix xemacs mode line, don't put them in .cpp files (just header files). No
functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183709 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-10 23:10:59 +00:00
Aaron Ballman
f56a6ded63 Silencing an MSVC warning about */ being found outside of a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183175 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-04 01:01:56 +00:00
Andrew Trick
cd8e3c4dcf Prevent loop-unroll from making assumptions about undefined behavior.
Fixes rdar:14036816, PR16130.

There is an opportunity to compute precise trip counts for 'or'
expressions and multi-exit loops.
rdar:14038809: Optimize trip count computation for multi-exit loops.

To do this we need to record the fact that ExitLimit assumes NSW. When
it does not we can safely assume that the loop trip count is the
minimum ExitLimt across all subexpressions and loop exits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183060 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-31 23:34:46 +00:00
Quentin Colombet
06f5ebc5a1 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.

<rdar://problem/13806271>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183045 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-31 21:29:03 +00:00
Andrew Trick
616011418e 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
2013-05-31 06:43:25 +00:00
Paul Redmond
ee21b6f7b4 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
    llvm.mem.parallel_loop_access
  - 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
    already_vectorized
- update existing tests that used llvm.loop.parallel and
  llvm.vectorizer.already_vectorized

Reviewed by: Nadav Rotem


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182802 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-28 20:00:34 +00:00
Michael Kuperstein
9f5de6dadc 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
2013-05-28 08:17:48 +00:00
Michael J. Spencer
c6af2432c8 Replace Count{Leading,Trailing}Zeros_{32,64} with count{Leading,Trailing}Zeros.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182680 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-24 22:23:49 +00:00
Diego Novillo
fe808927ac Do not reserve space for the ColdEdges and NormalEdges vectors.
Discussion and rationale at
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130520/175698.html

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182653 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-24 17:00:22 +00:00
Diego Novillo
77226a03dc 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
2013-05-24 12:26:52 +00:00
David Majnemer
cb9d4667b7 isKnownToBeAPowerOfTwo: (X & Y) + Y is a power of 2 or zero if y is also.
This is useful if something that looks like (x & (1 << y)) ? 64 : 32 is
the divisor in a modulo operation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182200 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-18 19:30:37 +00:00
Richard Smith
eb351eb849 Respect the 'nobuiltin' attribute when determining if a call is to a memory builtin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181978 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-16 04:12:04 +00:00
David Blaikie
453f4f0130 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
2013-05-15 07:36:59 +00:00
Matt Arsenault
8b9dc21d6f Fix unchecked uses of DominatorTree in MemoryDependenceAnalysis.
Use unknown results for places where it would be needed

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181176 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-06 02:07:24 +00:00
Tobias Grosser
333403abbd RegionInfo: Do not crash if unreachable block is found
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181025 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-03 15:48:34 +00:00
Filip Pizlo
40be1e8566 This patch breaks up Wrap.h so that it does not have to include all of
the things, and renames it to CBindingWrapping.h.  I also moved 
CBindingWrapping.h into Support/.

This new file just contains the macros for defining different wrap/unwrap 
methods.

The calls to those macros, as well as any custom wrap/unwrap definitions 
(like for array of Values for example), are put into corresponding C++ 
headers.

Doing this required some #include surgery, since some .cpp files relied 
on the fact that including Wrap.h implicitly caused the inclusion of a 
bunch of other things.

This also now means that the C++ headers will include their corresponding 
C API headers; for example Value.h must include llvm-c/Core.h.  I think 
this is harmless, since the C API headers contain just external function 
declarations and some C types, so I don't believe there should be any 
nasty dependency issues here.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180881 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-01 20:59:00 +00:00
Manman Ren
a5b314c27a Struct-path aware TBAA: change the format of TBAAStructType node.
We switch the order of offset and field type to make TBAAStructType node
(name, parent node, offset) similar to scalar TBAA node (name, parent node).
TypeIsImmutable is added to TBAAStructTag node.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180654 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-27 00:26:11 +00:00
Manman Ren
2ff97832e5 Struct-path aware TBAA: update getMostGenericTBAA
The tag is of type TBAANode when flag EnableStructPathTBAA is off.

Move implementation of MDNode::getMostGenericTBAA to TypeBasedAliasAnalysis.cpp
since it depends on how to interprete the MDNodes for scalar TBAA and
struct-path aware TBAA.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180068 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-22 23:00:44 +00:00
Eric Christopher
3e39731e88 Move C++ code out of the C headers and into either C++ headers
or the C++ files themselves. This enables people to use
just a C compiler to interoperate with LLVM.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180063 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-22 22:47:22 +00:00
Benjamin Kramer
eb733d2a1b ConstantFolding: ComputeMaskedBits wants the scalar size for vectors.
Fixes PR15791.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179859 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-19 16:56:24 +00:00
Bill Wendling
d58b50b99b A limit of 500 was still a bit too high for some tests.
PR15000 has a testcase where the time to compile was bordering on 30s. When I
dropped the limit value to 100, it became a much more managable 6s. The compile
time seems to increase in a roughly linear fashion based on increasing the limit
value. (See the runtimes below.)

So, let's lower the limit to 100 so that they can get a more reasonable compile
time.

Limit Value  Time
-----------  ----
10           0.9744s
20           1.8035s
30           2.3618s
40           2.9814s
50           3.6988s
60           4.5486s
70           4.9314s
80           5.8012s
90           6.4246s
100          7.0852s
110          7.6634s
120          8.3553s
130          9.0552s
140          9.6820s
150          9.8804s
160         10.8901s
170         10.9855s
180         12.0114s
190         12.6816s
200         13.2754s
210         13.9942s
220         13.8097s
230         14.3272s
240         15.7753s
250         15.6673s
260         16.0541s
270         16.7625s
280         17.3823s
290         18.8213s
300         18.6120s
310         20.0333s
320         19.5165s
330         20.2505s
340         20.7068s
350         21.1833s
360         22.9216s
370         22.2152s
380         23.9390s
390         23.4609s
400         24.0426s
410         24.6410s
420         26.5208s
430         27.7155s
440         26.4142s
450         28.5646s
460         27.3494s
470         29.7255s
480         29.4646s
490         30.5001s


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179713 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-17 20:02:32 +00:00
Benjamin Kramer
8848680ce0 Fix a scalability issue with complex ConstantExprs.
This is basically the same fix in three different places. We use a set to avoid
walking the whole tree of a big ConstantExprs multiple times.

For example: (select cmp, (add big_expr 1), (add big_expr 2))
We don't want to visit big_expr twice here, it may consist of thousands of
nodes.

The testcase exercises this by creating an insanely large ConstantExprs out of
a loop. It's questionable if the optimizer should ever create those, but this
can be triggered with real C code. Fixes PR15714.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179458 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-13 12:53:18 +00:00
Manman Ren
4df1854f26 Aliasing rules for struct-path aware TBAA.
Added PathAliases to check if two struct-path tags can alias.
Added command line option -struct-path-tbaa.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179337 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-11 23:24:18 +00:00
Tobias Grosser
d03fdfb97c 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
2013-04-10 06:54:49 +00:00
Nadav Rotem
8e4df489d0 Revert r176408 and r176407 to address PR15540.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179111 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-09 18:16:05 +00:00
Nadav Rotem
e43e2d8cf0 Revert 179071 because it is not the right way to support non standard new/new[] operators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179084 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-09 04:43:46 +00:00
Nadav Rotem
0a9b452aa4 c++ new operators are not malloc-like functions because they do not return uninitialized memory.
Users may overide new-operators and implement any function that they like.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179071 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-08 23:40:47 +00:00
NAKAMURA Takumi
92c3742319 InstructionSimplify.cpp: Fix a ligature, "fi", to get rid of utf8 in comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179066 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-08 23:05:21 +00:00
Arnold Schwaighofer
6bf4f67641 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.

radar://13576547

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178807 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-04 23:26:21 +00:00
Matt Arsenault
71246fb830 Build fixes for STLPort + GCC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178356 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-29 18:48:45 +00:00
Matt Arsenault
7d4ff60b55 Fix loop style
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178355 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-29 18:48:42 +00:00
Arnold Schwaighofer
742dbc1fc8 BasicAA: Only query twice if the result of the more general query was MayAlias
This is a compile time optimization. Before the patch we would do two traversals
on each call to aliasGEP - one with a set size parameter one with UnknownSize.
We can do better by first checking the result of the alias query with
UnknownSize.
Only if this one returns MayAlias do we query a second time using size and type.

This recovers an about 7% compile time regression on spec/ammp.

radar://12349960

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178045 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-26 18:07:53 +00:00
Andrew Trick
e74c2e86cb 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
2013-03-26 03:14:53 +00:00
Manman Ren
a2e3834d16 Support in AAEvaluator to print alias queries of loads/stores with TBAA tags.
Add "evaluate-tbaa" to print alias queries of loads/stores. Alias queries
between pointers do not include TBAA tags.

Add testing case for "placement new". TBAA currently says NoAlias.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177772 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-22 22:34:41 +00:00
Jakub Staszak
7f19e5db5f Remove 'else' after 'return'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177607 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-20 23:53:45 +00:00
Jakub Staszak
6178e5f50c Remove trailing spaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177584 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-20 21:47:51 +00:00
Manman Ren
90842427b2 Check whether a pointer is non-null (isKnownNonNull) in isKnownNonZero.
This handles the case where we have an inbounds GEP with alloca as the pointer.
This fixes the regression in PR12750 and rdar://13286434.
Note that we can also fix this by handling some GEP cases in isKnownNonNull.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177321 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-18 21:23:25 +00:00
Patrik Hagglund
ac5b3915aa Small fix for cost analysis of ptrtoint.
This seems to be a "copy-paste error" introducecd in r156140.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176863 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-12 13:18:30 +00:00
Jakub Staszak
ec3bb4b660 Remove unneeded #includes. Use forward declarations instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176783 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-10 00:34:01 +00:00
Michael Ilseman
cacf971079 Early exit from getAllocationData() and isFreeCall() for intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176722 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-08 21:15:00 +00:00
Michael Ilseman
9333ffb6db Remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176720 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-08 21:03:09 +00:00
David Blaikie
423de3f047 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
2013-03-08 18:17:46 +00:00
Jakub Staszak
b1b6c17081 Simplify code. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176646 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-07 20:22:39 +00:00
Jakub Staszak
a9cd5164c4 Change NULL to 0.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176642 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-07 20:01:47 +00:00
Jakub Staszak
b6aebf1cf3 ArrayRef ca accept one element. Simplify code a little bit, also it matches now
coding in the other places of the file.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-07 20:01:19 +00:00
Shuxin Yang
985dac6579 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.

rdar://11311484

Thank Arnold for code review.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176562 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-06 17:48:48 +00:00
Jakub Staszak
603e874c64 Use dyn_cast instead of isa && cast. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176537 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-06 00:16:16 +00:00
Nuno Lopes
b443a0aeac 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
2013-03-02 11:36:24 +00:00
Nuno Lopes
2bc689c846 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
2013-03-02 11:23:34 +00:00
Benjamin Kramer
8611d4449a Cost model support for lowered math builtins.
We make the cost for calling libm functions extremely high as emitting the
calls is expensive and causes spills (on x86) so performance suffers. We still
vectorize important calls like ceilf and friends on SSE4.1. and fabs.

Differential Revision: http://llvm-reviews.chandlerc.com/D466

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176287 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-28 19:09:33 +00:00
Shuxin Yang
d2eaf45af4 Fix a problem in alias analysis. It is about the misinterpretation of "Object".
This problem is exposed by r171325 which is already reverted. It is rather
hard to fabricate a testing case without it.

r171325 should *NOT* be resurrected as it has a potential problem although 
this problem dosen't directly contribute to PR14988.

The bug is tracked by:
  - rdar://13063553, and
  - http://llvm.org/bugs/show_bug.cgi?id=14988

Thank Arnold for coming up a better solution to this problem. After
comparing this solution and my original proposal, I decided to ditch mine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176225 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-28 00:24:45 +00:00
Michael Ilseman
616025007a Constant fold vector bitcasts of halves similarly to how floats and doubles are folded. Test case included.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176131 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-26 22:51:07 +00:00
Kostya Serebryany
8eec41fc77 Unify clang/llvm attributes for asan/tsan/msan (LLVM part)
These are two related changes (one in llvm, one in clang).
LLVM: 
- rename address_safety => sanitize_address (the enum value is the same, so we preserve binary compatibility with old bitcode)
- rename thread_safety => sanitize_thread
- rename no_uninitialized_checks -> sanitize_memory

CLANG: 
- add __attribute__((no_sanitize_address)) as a synonym for __attribute__((no_address_safety_analysis))
- add __attribute__((no_sanitize_thread))
- add __attribute__((no_sanitize_memory))

for S in address thread memory
If -fsanitize=S is present and __attribute__((no_sanitize_S)) is not
set llvm attribute sanitize_S


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176075 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-26 06:58:09 +00:00
Chad Rosier
4ffec108a9 Formatting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175692 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-20 23:57:30 +00:00
Nick Lewycky
9d90163bc3 Teach the DataLayout aware constant folder to be much more aggressive towards
'and' instructions. This is a pattern that shows up a lot in ubsan binaries.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175128 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-14 03:23:37 +00:00
Pekka Jaaskelainen
5d0ce79e26 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
2013-02-13 18:08:57 +00:00
Kostya Serebryany
7bce462c15 [tsan] disable load widening in ThreadSanitizer mode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175034 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-13 05:59:45 +00:00
Arnold Schwaighofer
4fc6484ee2 Cost model: Add check for reverse shuffles to CostModel analysis
Check for reverse shuffles in the CostModel analysis pass and query
TargetTransform info accordingly. This allows us we can write test cases for
reverse shuffles.

radar://13171406

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174932 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-12 02:40:37 +00:00
Bob Wilson
58446916b7 Revert "Add LLVMContext::emitWarning methods and use them. <rdar://problem/12867368>"
This reverts r171041. This was a nice idea that didn't work out well.
Clang warnings need to be associated with warning groups so that they can
be selectively disabled, promoted to errors, etc. This simplistic patch didn't
allow for that. Enhancing it to provide some way for the backend to specify
a front-end warning type seems like overkill for the few uses of this, at
least for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174748 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-08 21:48:29 +00:00
Arnold Schwaighofer
fb55a8fd7c 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.

radar://13097204

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174713 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-08 14:50:48 +00:00
Michael Ilseman
f89de816ae Identify and simplify idempotent intrinsics. Test case included.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174650 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-07 19:26:05 +00:00
Owen Anderson
ec643abe69 Conditionalize constant folding of math intrinsics on the availability of an implementation on the host. This is a little bit unfortunate, but until someone decides to implement a full libm for APFloat, we don't have a better way to get this functionality.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174561 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-07 00:21:34 +00:00
Owen Anderson
42258e0ea8 Signficantly generalize our ability to constant fold floating point intrinsics, including ones on half types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174555 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-06 22:43:31 +00:00
Benjamin Kramer
faf601ee93 ConstantFolding: Fix a crash when encoutering a truncating inttoptr.
This was introduced in r173293.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174424 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-05 19:04:36 +00:00
Nuno Lopes
cc00cc7e04 use GEP::accumulateConstantOffset() to replace custom written code to compute GEP offset
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174279 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-03 13:17:11 +00:00
Benjamin Kramer
d9f32c20da InstSimplify: stripAndComputeConstantOffsets can be called with vectors of pointers too.
Prepare it for vectors of pointers and handle simple cases. We don't handle
complicated cases because accumulateConstantOffset bails on pointer vectors.
Fixes selfhost on i386.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174179 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-01 15:21:10 +00:00
Dan Gohman
901261d558 Add a comment explaining an unavailable optimization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174131 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-01 00:49:06 +00:00
Dan Gohman
fdd1eafe86 Rewrite instsimplify's handling if icmp on pointer values to remove the
remaining use of AliasAnalysis concepts such as isIdentifiedObject to
prove pointer inequality.

@external_compare in test/Transforms/InstSimplify/compare.ll shows a simple
case where a noalias argument can be equal to a global variable address, and
while AliasAnalysis can get away with saying that these pointers don't alias,
instsimplify cannot say that they are not equal.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174122 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-01 00:11:13 +00:00
Dan Gohman
ac08785eda An alloca can be equal to an argument. It can't *alias* an alloca, but it could
be equal, since there's nothing preventing a caller from correctly predicting
the stack location of an alloca.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174119 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31 23:49:33 +00:00
Dan Gohman
3e3de565e9 Change stripAndComputeConstantOffsets to accept a NULL DataLayout pointer
as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174030 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31 02:50:36 +00:00
Dan Gohman
819f9d6bf9 Add a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174028 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31 02:45:26 +00:00
Dan Gohman
de0eb19248 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
2013-01-31 02:40:59 +00:00
Dan Gohman
a070d2a035 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
2013-01-31 02:00:45 +00:00
Dan Gohman
5f1686f0b0 Minor code simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174005 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31 00:32:11 +00:00
Dan Gohman
f2335dcb17 stripAndComputeConstantOffsets is only called on pointers; check this
with an assert instead of failing and requiring callers to check for failure.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173998 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31 00:12:20 +00:00
Benjamin Kramer
e574246489 ConstantFolding: Add a missing folding that leads to a miscompile.
We use constant folding to see if an intrinsic evaluates to the same value as a
constant that we know. If we don't take the undefinedness into account we get a
value that doesn't match the actual implementation, and miscompiled code.

This was uncovered by Chandler's simplifycfg changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173356 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-24 16:28:28 +00:00
Benjamin Kramer
1094b41c7b ConstantFolding: Tweak r173289, it should evaluate in the intptr type, not the index type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173293 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-23 21:21:24 +00:00
Benjamin Kramer
b4d201ec54 ConstantFolding: Evaluate GEP indices in the index type.
This fixes some edge cases that we would get wrong with uint64_ts.
PR14986.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173289 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-23 20:41:05 +00:00
Chandler Carruth
13086a658a 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
2013-01-22 11:26:02 +00:00
Tim Northover
0a29cb0454 Make APFloat constructor require explicit semantics.
Previously we tried to infer it from the bit width size, with an added
IsIEEE argument for the PPC/IEEE 128-bit case, which had a default
value. This default value allowed bugs to creep in, where it was
inappropriate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173138 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-22 09:46:31 +00:00
Chandler Carruth
a5157e68d1 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
2013-01-21 13:04:33 +00:00
Chandler Carruth
184e3ff52c Sink InlineCost.cpp into IPA -- it is now officially an interprocedural
analysis. How cute that it wasn't previously. ;]

Part of this confusion stems from the flattened header file tree. Thanks
to Benjamin for pointing out the goof on IRC, and we're considering
un-flattening the headers, so speak now if that would bug you.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173033 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-21 12:09:41 +00:00
Chandler Carruth
b5da8a4ae1 Move the inline cost analysis's primary cost query to TTI instead of the
old CodeMetrics system. TTI has the specific advantage of being
extensible and customizable by targets to reflect target-specific cost
metrics.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173032 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-21 12:05:16 +00:00
Chandler Carruth
8d6c0f4dee 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
2013-01-21 11:55:09 +00:00
Chandler Carruth
86953b5795 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
2013-01-21 11:39:18 +00:00
Chandler Carruth
1e05bd9e71 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
2013-01-21 01:27:39 +00:00
Renato Golin
053a211983 Revert CostTable algorithm, will re-write
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172992 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-20 20:57:20 +00:00
Renato Golin
065db2347f Fix 80-col and early exit in cost model
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172877 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-19 00:42:16 +00:00
Bill Wendling
167ede898a 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
2013-01-17 21:28:46 +00:00
Renato Golin
d3c965d625 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
2013-01-16 21:29:55 +00:00
Andrew Trick
1ba5769676 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
2013-01-14 21:00:37 +00:00
Nuno Lopes
29eb2cc00c 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
2013-01-13 18:02:57 +00:00
Dmitri Gribenko
96f498bd9f Remove redundant 'llvm::' qualifications
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172358 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-13 16:01:15 +00:00
Andrew Trick
74c1be27a4 Update CMakeLists for CallPrinter.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172222 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-11 17:34:05 +00:00
Andrew Trick
a125cacf7d 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
2013-01-11 17:28:14 +00:00
Nadav Rotem
14925e6b88 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
2013-01-09 22:29:00 +00:00
Nadav Rotem
83be7b0dd3 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
2013-01-09 01:15:42 +00:00
Chandler Carruth
3251e81d79 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
2013-01-07 15:26:48 +00:00
Chandler Carruth
e4ba75f43e 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
2013-01-07 14:41:08 +00:00
Chandler Carruth
6554666e00 Move the initialization to the Analysis library as well as the pass.
This was (somewhat distressingly) only caught be the ocaml bindings
tests...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171690 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 03:33:08 +00:00
Chandler Carruth
d1b8ef97c4 Make the popcnt support enums and methods have more clear names and
follow the conding conventions regarding enumerating a set of "kinds" of
things.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171687 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 03:16:03 +00:00
Chandler Carruth
be04929f7f 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
2013-01-07 03:08:10 +00:00
Chandler Carruth
194bd71b06 Switch the cost model analysis over to just the TTI interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171619 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-05 10:09:33 +00:00
Manman Ren
c55bd47105 Memory Dependence Analysis: fix a miscompile that uses DT to approxmiate the
reachablity.

We conservatively approximate the reachability analysis by saying it is not
reachable if there is a single path starting from "From" and the path does not
reach "To".

rdar://12801584


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171512 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-04 19:19:47 +00:00
Chandler Carruth
351ba145a7 Actually update the CMake and Makefile builds correctly, and update the
code that includes Intrinsics.gen directly.

This never showed up in my testing because the old Intrinsics.gen was
still kicking around in the make build system and was correct there. =[
Thankfully, some of the bots to clean rebuilds and that caught this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171373 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-02 12:09:16 +00:00
Chandler Carruth
0b8c9a80f2 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
2013-01-02 11:36:10 +00:00
Chandler Carruth
c2c50cdcdc Rename VMCore directory to IR.
Aside from moving the actual files, this patch only updates the build
system and the source file comments under lib/... that are relevant.

I'll be updating other docs and other files in smaller subsequnet
commits.

While I've tried to test this, but it is entirely possible that there
will still be some build system fallout.

Also, note that I've not changed the library name itself: libLLVMCore.a
is still the library name. I'd be interested in others' opinions about
whether we should rename this as well (I think we should, just not sure
what it might break)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171359 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-02 09:10:48 +00:00
Nuno Lopes
5cec34754d reimplement GetPointerBaseWithConstantOffset().
The new code is an improved copy of the code I deleted from Analysis/Loads.cpp.
One less compute-constant-gep-offset implementation. yay :)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171326 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-31 20:48:35 +00:00
Nuno Lopes
0a9ff4cab3 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
2012-12-31 20:45:10 +00:00
Benjamin Kramer
44365353a4 Revert "add support for PHI nodes to ObjectSizeOffsetVisitor"
This reverts r171298. Breaks clang selfhost.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171318 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-31 19:51:10 +00:00
Nuno Lopes
2e594fa85c revert r171306, since we cannot compare APInts with different bitwidths
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171308 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-31 18:01:36 +00:00
Nuno Lopes
1ef05b1a2a use ValueTracking's GetPointerBaseWithConstantOffset() function instead of a local implementation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171307 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-31 17:42:11 +00:00
Nuno Lopes
a44766a4dd minor code simplification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171306 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-31 17:25:24 +00:00
Nuno Lopes
41be2fb1f9 add support for GlobalAlias to ObjectSizeOffsetVisitor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171303 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-31 16:23:48 +00:00
Nuno Lopes
729e602082 add support for PHI nodes to ObjectSizeOffsetVisitor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171298 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-31 13:52:36 +00:00
Nuno Lopes
98281a2050 convert a bunch of callers from DataLayout::getIndexedOffset() to GEP::accumulateConstantOffset().
The later API is nicer than the former, and is correct regarding wrap-around offsets (if anyone cares).
There are a few more places left with duplicated code, which I'll remove soon.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171259 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-30 16:25:48 +00:00
Bill Wendling
831737d329 Remove the Function::getFnAttributes method in favor of using the AttributeSet
directly.

This is in preparation for removing the use of the 'Attribute' class as a
collection of attributes. That will shift to the AttributeSet class instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171253 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-30 10:32:01 +00:00
Chandler Carruth
a84e7508eb Nuke some dead code that snuck in some how. I thought I had already
deleted this, but apparantly not. Charmingly, Clang didn't warn on it
but GCC did.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171197 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-28 14:50:51 +00:00
Chandler Carruth
73527d30cd Fix a stunning oversight in the inline cost analysis. It was never
propagating one of the values it simplified to a constant across
a myriad of instructions. Notably, ptrtoint instructions when we had
a constant pointer (say, 0) didn't propagate that, blocking a massive
number of down-stream optimizations.

This was uncovered when investigating why we fail to inline and delete
the boilerplate in:

  void f() {
    std::vector<int> v;
    v.push_back(1);
  }

It turns out most of the efforts I've made thus far to improve the
analysis weren't making it far purely because of this. After this is
fixed, the store-to-load forwarding patch enables LLVM to optimize the
above to an empty function. We still can't nuke a second push_back, but
for different reasons.

There is a very real chance this will cause somewhat noticable changes
in inlining behavior, so please let me know if you see regressions (or
improvements!) because of this patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171196 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-28 14:43:42 +00:00
Chandler Carruth
ba94204e94 Teach the inline cost analysis about calls that can be simplified and
how to propagate constants through insert and extract value
instructions.

With the recent improvements to instsimplify, this allows inline cost
analysis to constant fold through intrinsic functions, including notably
the with.overflow intrinsic math routines which often show up inside of
STL abstractions. This is yet another piece in the puzzle of breaking
down the code for:

  void f() {
    std::vector<int> v;
    v.push_back(1);
  }

But it still isn't enough. There are a pile of bugs in inline cost still
blocking this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171195 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-28 14:23:32 +00:00
Chandler Carruth
e949aa1c91 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
2012-12-28 14:23:29 +00:00
Chandler Carruth
c98bd9f1a7 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
about.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171189 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-28 11:30:55 +00:00
Bob Wilson
a0be09f511 Add LLVMContext::emitWarning methods and use them. <rdar://problem/12867368>
When the backend is used from clang, it should produce proper diagnostics
instead of just printing messages to errs(). Other clients may also want to
register their own error handlers with the LLVMContext, and the same handler
should work for warnings in the same way as the existing emitError methods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171041 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-24 18:15:21 +00:00