17882 Commits

Author SHA1 Message Date
Sanjoy Das
00d88a77e1 [InstNamer] Use range-for
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302481 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 23:18:43 +00:00
Sanjoy Das
284277df9a [InstNamer] Don't check type of arguments (they're never void)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302480 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 23:18:39 +00:00
Sanjoy Das
447ca1ab6d Delete trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302479 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 23:18:36 +00:00
Adrian Prantl
28bd5d128c Make it illegal for two Functions to point to the same DISubprogram
As recently discussed on llvm-dev [1], this patch makes it illegal for
two Functions to point to the same DISubprogram and updates
FunctionCloner to also clone the debug info of a function to conform
to the new requirement. To simplify the implementation it also factors
out the creation of inlineAt locations from the Inliner into a
general-purpose utility in DILocation.

[1] http://lists.llvm.org/pipermail/llvm-dev/2017-May/112661.html
<rdar://problem/31926379>

Differential Revision: https://reviews.llvm.org/D32975

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302469 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 21:17:08 +00:00
Sanjay Patel
b8a453126a [InstCombine] add folds for not-of-shift-right
This is another step towards getting rid of dyn_castNotVal, 
so we can recommit:
https://reviews.llvm.org/rL300977

As the tests show, we were missing the lshr case for constants
and both ashr/lshr vector splat folds. The ashr case with constant
was being performed inefficiently in 2 steps. It's also possible
there was a latent bug in that case because we can't do that fold
if the constant is positive:
http://rise4fun.com/Alive/Bge



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302465 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 20:49:59 +00:00
Davide Italiano
29aef3c4af [PartialInlining] Capture by reference rather than by value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302464 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 20:44:01 +00:00
Sanjay Patel
811100c771 [InstCombine] use local variable to reduce code duplication; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302438 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 16:33:42 +00:00
Sanjay Patel
a594399826 [InstCombine/InstSimplify] add comments about code duplication; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302436 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 16:21:55 +00:00
Craig Topper
677051d58f [ConstantRange][SimplifyCFG] Add a helper method to allow SimplifyCFG to determine if a ConstantRange has more than 8 elements without requiring an allocation if the ConstantRange is 64-bits wide.
Previously SimplifyCFG used getSetSize which returns an APInt that is 1 bit wider than the ConstantRange's bit width. In the reasonably common case that the ConstantRange is 64-bits wide, this requires returning a 65-bit APInt. APInt's can only store 64-bits without a memory allocation so this is inefficient.

The new method takes the 8 as an input and tells if the range contains more than that many elements without requiring any wider math.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302385 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07 22:22:11 +00:00
Sanjay Patel
2a7ef8d5f2 [InstSimplify] use ConstantRange to simplify or-of-icmps
We can simplify (or (icmp X, C1), (icmp X, C2)) to 'true' or one of the icmps in many cases.
I had to check some of these with Alive to prove to myself it's right, but everything seems 
to check out. Eg, the deleted code in instcombine was completely ignoring predicates with
mismatched signedness.

This is a follow-up to:
https://reviews.llvm.org/rL301260
https://reviews.llvm.org/D32143


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302370 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07 15:11:40 +00:00
Kostya Serebryany
9d90a01faf [sanitizer-coverage] implement -fsanitize-coverage=no-prune,... instead of a hidden -mllvm flag. llvm part.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302319 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 23:14:40 +00:00
Craig Topper
da0638fc06 Fix spelling error in command line option description. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302311 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 22:31:11 +00:00
Matthias Braun
738a26c4e2 TargetLibraryInfo: Introduce wcslen
wcslen is part of the C99 and C++98 standards.

- This introduces the function to TargetLibraryInfo.
- Also set attributes for wcslen in llvm::inferLibFuncAttributes().

Differential Revision: https://reviews.llvm.org/D32837

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302278 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 20:25:50 +00:00
Craig Topper
ace8b39f82 [KnownBits] Add wrapper methods for setting and clear all bits in the underlying APInts in KnownBits.
This adds routines for reseting KnownBits to unknown, making the value all zeros or all ones. It also adds methods for querying if the value is zero, all ones or unknown.

Differential Revision: https://reviews.llvm.org/D32637

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302262 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 17:36:09 +00:00
Craig Topper
a76abe9fb9 [Float2Int] Replace a ConstantRange copy with a move. Remove an extra call to MapVector::find.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302256 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 17:09:29 +00:00
Aditya Kumar
978eb7c50b [LoopIdiom] check for safety while expanding
Loop Idiom recognition was generating memset in a case that
would result generating a division operation to an unsafe location.

Differential Revision: https://reviews.llvm.org/D32674

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302238 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 14:49:45 +00:00
Evgeniy Stepanov
1565077013 Remap metadata attached to global variables.
Fix for PR32577.
Global variables may have !associated metadata, which includes a reference to another global. It needs remapping.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302203 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 23:29:39 +00:00
Craig Topper
195a2d9be0 [JumpThreading] When processing compares, explicitly check that the result type is not a vector rather than check for it being an integer.
Compares always return a scalar integer or vector of integers. isIntegerTy returns false for vectors, but that's not completely obvious. So using isVectorTy is less confusing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302198 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 21:45:49 +00:00
Craig Topper
0e59845978 [JumpThreading] Change a dyn_cast that is already protected by an isa check to a static cast. Combine the with another static cast. NFC
Differential Revision: https://reviews.llvm.org/D32874

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302197 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 21:45:45 +00:00
Craig Topper
7a94f0ce91 [Float2Int] Remove return of ConstantRange from seen method. Nothing uses it so it just creates and discards a ConstantRange object for no reason.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302193 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 21:29:45 +00:00
Peter Collingbourne
e611018a3f Re-apply r302108, "IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI."
with a fix for the clang backend.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302176 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 18:03:25 +00:00
Davide Italiano
316966eef8 [NewGVN] Remove unneeded newline and format assertions. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302173 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 17:26:15 +00:00
Eric Liu
1c442aa9b7 Revert "IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI."
This reverts commit r302108. This causes crash in clang bootstrap with LTO.

Contacted the auther in the original commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302140 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 11:49:39 +00:00
Martin Storsjo
623692ec9c [ArgPromotion] Fix a truncated variable
This fixes a regression since SVN rev 273808 (which was supposed to
not change functionality).

The regression caused miscompilations (noted in the wild when targeting
AArch64) on platforms with 32 bit long.

Differential Revision: https://reviews.llvm.org/D32850

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302137 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 10:54:35 +00:00
Jonas Paulsson
245084ed3c Use right function in LoopVectorize.
-    unsigned AS = getMemInstAlignment(I);
+    unsigned AS = getMemInstAddressSpace(I);

Review: Hal Finkel

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302114 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 05:31:56 +00:00
Peter Collingbourne
df2206086c IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI.
When profiling a no-op incremental link of Chromium I found that the functions
computeImportForFunction and computeDeadSymbols were consuming roughly 10% of
the profile. The goal of this change is to improve the performance of those
functions by changing the map lookups that they were previously doing into
pointer dereferences.

This is achieved by changing the ValueInfo data structure to be a pointer to
an element of the global value map owned by ModuleSummaryIndex, and changing
reference lists in the GlobalValueSummary to hold ValueInfos instead of GUIDs.
This means that a ValueInfo will take a client directly to the summary list
for a given GUID.

Differential Revision: https://reviews.llvm.org/D32471

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302108 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 03:36:16 +00:00
Craig Topper
e6aa7aa29e [InstCombine][KnownBits] Use KnownBits better to detect nsw adds
Change checkRippleForAdd from a heuristic to a full check -
if it is provable that the add does not overflow return true, otherwise false.

Patch by Yoav Ben-Shalom

Differential Revision: https://reviews.llvm.org/D32686

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302093 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 23:22:46 +00:00
Craig Topper
64c8cdfd4f [KnownBits] Add methods for determining if KnownBits is a constant value
This patch adds isConstant and getConstant for determining if KnownBits represents a constant value and to retrieve the value. Use them to simplify code.

Differential Revision: https://reviews.llvm.org/D32785

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302091 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 23:12:29 +00:00
Craig Topper
f78221855b [KnownBits] Add zext, sext, and trunc methods to KnownBits
This patch adds zext, sext, and trunc methods to KnownBits and uses them where possible.

Differential Revision: https://reviews.llvm.org/D32784

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302088 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 22:07:25 +00:00
Xin Tong
2b3efc4c39 [TailCallElim] Remove an unused argument. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302080 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 20:37:07 +00:00
Anna Thomas
f931b1e7f3 Avoid warning of unused variable in release builds. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302068 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 19:25:04 +00:00
Sanjoy Das
822fa3007b Fix typos in comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302063 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 18:29:34 +00:00
Anna Thomas
48d0c2805c Fix PPC64 warning for missing parantheses. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302061 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 18:25:43 +00:00
Reid Kleckner
a82b376f69 [IR] Abstract away ArgNo+1 attribute indexing as much as possible
Summary:
Do three things to help with that:
- Add AttributeList::FirstArgIndex, which is an enumerator currently set
  to 1. It allows us to change the indexing scheme with fewer changes.
- Add addParamAttr/removeParamAttr. This just shortens addAttribute call
  sites that would otherwise need to spell out FirstArgIndex.
- Remove some attribute-specific getters and setters from Function that
  take attribute list indices.  Most of these were only used from
  BuildLibCalls, and doesNotAlias was only used to test or set if the
  return value is malloc-like.

I'm happy to split the patch, but I think they are probably easier to
review when taken together.

This patch should be NFC, but it sets the stage to change the indexing
scheme to this, which is more convenient when indexing into an array:
  0: func attrs
  1: retattrs
  2...: arg attrs

Reviewers: chandlerc, pete, javed.absar

Subscribers: david2050, llvm-commits

Differential Revision: https://reviews.llvm.org/D32811

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302060 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 18:17:31 +00:00
Anna Thomas
b93df0801a [RuntimeLoopUnroller] Add assert that we dont unroll non-rotated loops
Summary:
Cloning basic blocks in the loop for runtime loop unroller depends on loop being
in rotated form (i.e. loop latch target is the exit block).
Assert that this is true, so that callers of runtime loop unroller pass in
canonical loops.
The single caller of this function has that check recently added:
https://reviews.llvm.org/rL301239

Reviewers: davide

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D32801

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302058 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 17:43:59 +00:00
Anna Thomas
469af3f37f [Loop Deletion] Delete loops that are never executed
Summary:
Currently, loop deletion deletes loop where the only values
that are used outside the loop are loop-invariant.
This patch adds logic to delete loops where the loop is proven to be
never executed (i.e. the only predecessor of the loop preheader has a
constant conditional branch as terminator, and the preheader is not the
taken target). This will remove loops that become dead after
loop-unswitching generates constant conditional branches.

The next steps are:
1. moving the loop deletion implementation to LoopUtils.
2. Add logic in loop-simplifyCFG which will support changing conditional
constant branches to unconditional branches. If loops become unreachable in this
process, they can be removed using `deleteDeadLoop` function.

Reviewers: chandlerc, efriedma, sanjoy, reames

Reviewed by: sanjoy

Subscribers: mzolotukhin, llvm-commits

Differential Revision: https://reviews.llvm.org/D32494

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302015 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 11:47:11 +00:00
Matt Arsenault
921f454dae Replace hardcoded intrinsic list with speculatable attribute.
No change in which intrinsics should be speculated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301995 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 02:26:10 +00:00
Reid Kleckner
dac7487074 Re-land r301697 "[IR] Make add/remove Attributes use AttrBuilder instead of AttributeList"
This time, I fixed, built, and tested clang.

This reverts r301712.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301981 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 22:07:37 +00:00
Davide Italiano
e8a0898f79 [NewGVN] Fix typo and format comment. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301974 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 21:11:40 +00:00
Xinliang David Li
1d482c01f6 [PartialInlining] Add more early filtering
This is a follow up to the previous
inline cost patch for quicker filtering.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301959 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 18:43:21 +00:00
Matt Arsenault
5c80457142 SpeculativeExecution: Stop using whitelist for costs
Just let TTI's cost do this instead of arbitrarily restricting
this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301950 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 18:02:18 +00:00
Sanjay Patel
dc1b8f4271 [InstCombine] don't use DeMorgan's Law on integer constants (2nd try)
This was originally checked in here:
https://reviews.llvm.org/rL301923

And reverted here:
https://reviews.llvm.org/rL301924

Because there's a clang test that would fail after this. I fixed/removed the
offending CHECK lines in:
https://reviews.llvm.org/rL301928

So let's try this again. Original commit message:

This is the fold that causes the infinite loop in BoringSSL
(https://github.com/google/boringssl/blob/master/crypto/cipher/e_rc2.c)
when we fix instcombine demanded bits to prefer 'not' ops as in https://reviews.llvm.org/D32255.

There are 2 or 3 problems with dyn_castNotVal, and I don't think we can
reinstate https://reviews.llvm.org/D32255 until dyn_castNotVal is completely eliminated.

1. As shown here, it transforms 'not' into random xor. This transform is harmful to SCEV and codegen because 'not' can often be folded while random xor cannot.
2. It does not transform vector constants. This is actually a good thing, but if you don't believe the above argument, then we shouldn't have excluded vectors.
3. It tries to avoid transforming not(not(X)). That's nice, but it doesn't match the greedy nature of instcombine. If we DeMorganize a pattern that has an extra 'not' in it: ~(~(~X) & Y) --> (~X | ~Y)

  That's just another case of DeMorgan, so we should trust that we'll fold that pattern too: (~X | ~ Y) --> ~(X & Y)

Differential Revision: https://reviews.llvm.org/D32665



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301929 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 15:31:40 +00:00
Sanjay Patel
a30d9c6883 revert r301923 : [InstCombine] don't use DeMorgan's Law on integer constants
There's a clang test that is wrongly using -O1 and failing after this commit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301924 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 14:48:23 +00:00
Sanjay Patel
9697c664a6 [InstCombine] don't use DeMorgan's Law on integer constants
This is the fold that causes the infinite loop in BoringSSL 
(https://github.com/google/boringssl/blob/master/crypto/cipher/e_rc2.c) 
when we fix instcombine demanded bits to prefer 'not' ops as in D32255.

There are 2 or 3 problems with dyn_castNotVal, and I don't think we can 
reinstate D32255 until dyn_castNotVal is completely eliminated.
1. As shown here, it transforms 'not' into random xor. This transform is 
   harmful to SCEV and codegen because 'not' can often be folded while 
   random xor cannot.
2. It does not transform vector constants. This is actually a good thing, 
   but if you don't believe the above argument, then we shouldn't have 
   excluded vectors.
3. It tries to avoid transforming not(not(X)). That's nice, but it doesn't
   match the greedy nature of instcombine. If we DeMorganize a pattern 
   that has an extra 'not' in it:
   ~(~(~X) & Y) --> (~X | ~Y)

   That's just another case of DeMorgan, so we should trust that we'll fold
   that pattern too:
   (~X | ~ Y) --> ~(X & Y)

Differential Revision: https://reviews.llvm.org/D32665


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301923 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 14:31:30 +00:00
Xinliang David Li
0a9c93cad3 [PartialInlining] Hook up inline cost analysis
Differential Revision: http://reviews.llvm.org/D32666


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301894 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 02:44:14 +00:00
Xin Tong
c16e4224e1 Empty Space. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301878 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 23:08:19 +00:00
Davide Italiano
f1457bf082 [NewGVN] Don't derive incorrect implications.
In the testcase attached,  we believe %tmp1 implies %tmp4.
where:
  br i1 %tmp1, label %bb2, label %bb7
  br i1 %tmp4, label %bb5, label %bb7

because Wwhile looking at PredicateInfo stuffs we end up calling
isImpliedTrueByMatchingCmp() with the arguments backwards.

Differential Revision:  https://reviews.llvm.org/D32718

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301849 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 22:26:28 +00:00
Sanjay Patel
5ef20bbe9c [InstCombine] check one-use before applying DeMorgan nor/nand folds
If we have ~(~X & Y), it only makes sense to transform it to (X | ~Y) when we do not need 
the intermediate (~X & Y) value. In that case, we would need an extra instruction to 
generate ~Y + 'or' (as shown in the test changes).

It's ok if we have multiple uses of ~X or Y, however. In those cases, we may not reduce the
instruction count or critical path, but we might improve throughput because we can generate 
~X and ~Y in parallel. Whether that actually makes perf sense or not for a target is something 
we can't answer in IR.

Differential Revision: https://reviews.llvm.org/D32703


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301848 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 22:25:42 +00:00
Peter Collingbourne
4e235f9788 IPO: Add missing build dep.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301835 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 20:57:20 +00:00
Peter Collingbourne
6a2cc4c156 Object: Remove ModuleSummaryIndexObjectFile class.
Differential Revision: https://reviews.llvm.org/D32195

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301832 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 20:42:32 +00:00