1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00
Commit Graph

149156 Commits

Author SHA1 Message Date
Matthias Braun
be57ef6b4f SimplifyLibCalls: Optimize wcslen
Refactor the strlen optimization code to work for both strlen and wcslen.

This especially helps with programs in the wild where people pass
L"string"s to const std::wstring& function parameters and the wstring
constructor gets inlined.

This also fixes a lingerind API problem/bug in getConstantStringInfo()
where zeroinitializers would always give you an empty string (without a
length) back regardless of the actual length of the initializer which
did not work well in the TrimAtNul==false causing the PR mentioned
below.

Note that the fixed getConstantStringInfo() needed fixes to SelectionDAG
memcpy lowering and may lead to some cases for out-of-bounds
zeroinitializer accesses not getting optimized anymore. So some code
with UB may produce out of bound memory reads now instead of just
producing zeros.

The refactoring "accidentally" fixes http://llvm.org/PR32124

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

llvm-svn: 303461
2017-05-19 22:37:09 +00:00
Matthias Braun
207ce95fd3 Verifier: Check wchar_size module flag.
Differential Revision: https://reviews.llvm.org/D32974

llvm-svn: 303460
2017-05-19 22:37:01 +00:00
Reid Kleckner
1bad4eeadf Fix off-by-one bug in AttributeList::addAttributes index handling
getParamAlignment expects an argument number, not an AttributeList
index.

Johan Englan, who works on LDC, found this bug and told me about it off
list.

llvm-svn: 303458
2017-05-19 22:23:47 +00:00
Galina Kistanova
708aeafa8b Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
llvm-svn: 303457
2017-05-19 21:08:28 +00:00
Evgeniy Stepanov
dd1cee8363 [safestack] Disable stack coloring by default.
Workaround for apparent miscompilation of PR32143.

llvm-svn: 303456
2017-05-19 20:58:48 +00:00
Galina Kistanova
d13253bac9 Added missing break.
llvm-svn: 303454
2017-05-19 20:31:51 +00:00
Daniel Berlin
dd45d67563 NewGVN: Fix PR32838.
This is a complicated bug involving two issues:
1. What do we do with phi nodes when we prove all arguments are not
live?
2. When is it safe to use value leaders to determine if we can ignore
an argumnet?

llvm-svn: 303453
2017-05-19 20:22:20 +00:00
Daniel Berlin
9a6de8c496 NewGVN: Print out the StoredValue of a StoreExpression
llvm-svn: 303452
2017-05-19 20:22:14 +00:00
Simon Pilgrim
617f8f51f2 Fix line-endings.
llvm-svn: 303448
2017-05-19 19:47:29 +00:00
Davide Italiano
a7bec40095 [InstCombine] *Actually* commit the test showing the miscompile.
Clarify a comment while I'm here.

llvm-svn: 303447
2017-05-19 19:41:11 +00:00
Zachary Turner
c669552325 Resubmit "[CodeView] Provide a common interface for type collections."
This was originally reverted because it was a breaking a bunch
of bots and the breakage was not surfacing on Windows.  After much
head-scratching this was ultimately traced back to a bug in the
lit test runner related to its pipe handling.  Now that the bug
in lit is fixed, Windows correctly reports these test failures,
and as such I have finally (hopefully) fixed all of them in this
patch.

llvm-svn: 303446
2017-05-19 19:26:58 +00:00
Davide Italiano
39dbad2716 [InstCombine] Add tests to demonstrate the miscompile in PR33078.
llvm-svn: 303445
2017-05-19 19:23:24 +00:00
Daniel Berlin
b97033247e Last of the major pieces to NewGVN - yay!
Summary:
NewGVN: Handle equivalence between phi of ops and op of phis.

This makes our GVN mostly-complete. It would be complete, modulo some
deliberate choices we make.  This means it detects roughly all herband
equivalences in polynomial time, including cases notoriously hard for
other GVN's to detect.  It also detects a very large swath of the
cases we currently rely on instcombine to detect that involve folding
upwards through phis.

Fixes PR 31125, 31463, PR 31868

Reviewers: davide

Subscribers: Prazek, llvm-commits

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

llvm-svn: 303444
2017-05-19 19:01:27 +00:00
Daniel Berlin
6cc057f1a8 NewGVN: Get rid of most dominating leader check
llvm-svn: 303443
2017-05-19 19:01:24 +00:00
Daniel Berlin
090cfd56ce BasicAA: Uninserted instructions have no parent, and notDifferentParent explicitly allows for this case, but getParent crashes when handed one.
llvm-svn: 303442
2017-05-19 19:01:21 +00:00
Amaury Sechet
1a98857ddd [DAGCombine] (addcarry 0, 0, X) -> (ext/trunc X)
Summary:
While this makes some case better and some case worse - so it's unclear if it is a worthy combine just by itself - this is a useful canonicalisation.

As per discussion in D32756 .

Reviewers: jyknight, nemanjai, mkuper, spatel, RKSimon, zvi, bkramer

Subscribers: llvm-commits

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

llvm-svn: 303441
2017-05-19 18:20:44 +00:00
Zachary Turner
59ae1d0687 [lit] Take the last error when executing pipelines.
This seems to have been present since the beginning of time,
which is quite surprising.  The symptom was this: Suppose you
have a test with a run line that looks like this:

  RUN: foo | FileCheck %s

foo prints some output and then due to a bug in the program it
asserts.  On Windows this results in the program returning a
negative exit code.  But if enough output had been printed
already by the tool so that the FileCheck match would succeed
then FileCheck would return 0, and because of bad logic in
lit this 0 return value would overwrite the failed return
value from previous items in the pipeline.  This only happened
with negative exit codes.

The most sensible behavior is to just take whatever the first
exit code is.  There is no logical ordering defined on exit
codes, so comparing with < and > does not make a lot of sense.
Instead, as soon as we find the first non-successful return
value, that should be the result of the entire expression.

This fixes the issue, as now tests which fail on non-Windows
platforms also fail for me on Windows as well.

llvm-svn: 303440
2017-05-19 18:12:07 +00:00
Anna Thomas
12404856c4 [NFC][loopIdiom] Clang format change rL303434
llvm-svn: 303439
2017-05-19 18:00:30 +00:00
Adrian Prantl
e05ec162ad ThinLTO: Verify bitcode before lauching the ThinLTOCodeGenerator.
rdar://problem/31233625

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

llvm-svn: 303438
2017-05-19 17:55:02 +00:00
Adrian Prantl
af6e8a6aed Rewrite llvm-lto's codegen() using ThinCodeGenerator::run(). NFC-ish.
Differential Revision: https://reviews.llvm.org/D33360

llvm-svn: 303437
2017-05-19 17:54:58 +00:00
Matthias Braun
d0b8ae859d Fix typo in test
llvm-svn: 303436
2017-05-19 17:25:20 +00:00
Simon Pilgrim
fd189ebdef [X86][FMA] Tests showing missed fmsubadd opportunities (PR30633)
llvm-svn: 303435
2017-05-19 17:19:26 +00:00
Anna Thomas
2c1b97f8da [LoopIdiom] Refactor return value of isLegalStore [NFC]
Summary:

This NFC simply refactors the return value of LoopIdiomRecognize::isLegalStore() from bool to an enumeration, and
removes the return-through-parameter mechanism that the function was using. This function is constructed such that it will
only ever recognize a single store idiom (memset, memset_pattern, or memcpy), and never a combination of these. As such it
makes much more sense for the return value to be the single idiom that the store matches, rather than
having a separate argument-return for each idiom -- it's cleaner, and makes it clearer that
only a single idiom can be matched.

Patch by Daniel Neilson!

Reviewers: anna, sanjoy, davide, haicheng

Reviewed By: anna, haicheng

Subscribers: haicheng, mzolotukhin, llvm-commits

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

llvm-svn: 303434
2017-05-19 17:05:36 +00:00
Craig Topper
75a1245a01 [InstSimplify] Fix 80 column violation. NFC
llvm-svn: 303433
2017-05-19 16:56:53 +00:00
Craig Topper
e1fe9f0a92 [APInt] Add support for dividing or remainder by a uint64_t or int64_t.
Summary:
This patch adds udiv/sdiv/urem/srem/udivrem/sdivrem methods that can divide by a uint64_t. This makes division consistent with all the other arithmetic operations.

This modifies the interface of the divide helper method to work on raw arrays instead of APInts. This way we can pass the uint64_t in for the RHS without wrapping it in an APInt. This required moving all the Quotient and Remainder allocation handling up to the callers. For udiv/urem this was as simple as just creating the Quotient/Remainder with the right size when they were declared. For udivrem we have to rely on reallocate not changing the contents of the variable LHS or RHS is aliased with the Quotient or Remainder APInts. We also have to zero the upper bits of Remainder and Quotient that divide doesn't write to if lhsWords/rhsWords is smaller than the width.

I've update the toString method to use the new udivrem.

Reviewers: hans, dblaikie, RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 303431
2017-05-19 16:43:54 +00:00
Dmitry Preobrazhensky
f571a2ff8a [AMDGPU][MC] Corrected disassembler to decode instructions with 2 literals
See bug 32922: https://bugs.llvm.org//show_bug.cgi?id=32922

Reviewers: artem.tamazov, vpykhtin

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

llvm-svn: 303428
2017-05-19 14:27:52 +00:00
Artur Pilipenko
da4913b16b [LoopPredication] NFC. Extract LoopICmp struct and parseLoopICmp helper
llvm-svn: 303427
2017-05-19 14:02:46 +00:00
Artur Pilipenko
b9d74555a8 [LoopPredication] NFC. Extract LoopPredication::expandCheck helper
llvm-svn: 303426
2017-05-19 14:00:58 +00:00
Artur Pilipenko
5312236f74 [LoopPredication] NFC. Extract CanExpand helper lambda
llvm-svn: 303425
2017-05-19 14:00:04 +00:00
Artur Pilipenko
231491f091 [LoopPredication] NFC. Add an early exit if there is no guards in the loop
llvm-svn: 303424
2017-05-19 13:59:34 +00:00
Dmitry Preobrazhensky
53c7c408ae [AMDGPU][MC] Fixed bugs in export instruction
See Bugs 33019, 33056:
  https://bugs.llvm.org//show_bug.cgi?id=33019
  https://bugs.llvm.org//show_bug.cgi?id=33056

Reviewers: artem.tamazov, vpykhtin

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

llvm-svn: 303423
2017-05-19 13:36:09 +00:00
Guy Blank
4b4c372886 [X86][AVX512] Make i1 illegal in the CodeGen
This patch defines the i1 type as illegal in the X86 backend for AVX512.
For DAG operations on <N x i1> types (build vector, extract vector element, ...) i8 is used, and should be truncated/extended.
This should produce better scalar code for i1 types since GPRs will be used instead of mask registers.

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

llvm-svn: 303421
2017-05-19 12:35:15 +00:00
Daniel Sanders
ba45842e7a [globalisel][tablegen] Demote OptForSize/OptForMinSize/ForCodeSize to per-function predicates.
Summary:
This causes them to be re-computed more often than necessary but resolves
objections that were raised post-commit on r301750.

Reviewers: qcolombet, ab, t.p.northover, rovka, kristof.beyls

Reviewed By: qcolombet

Subscribers: igorb, llvm-commits

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

llvm-svn: 303418
2017-05-19 11:08:33 +00:00
Amara Emerson
7af0aadc40 Fix vector pass-through value being unused in IRBuilder::CreateMaskedGather
Also s/0/nullptr in the call site in LV.

llvm-svn: 303416
2017-05-19 10:40:18 +00:00
Volkan Keles
7a10f07850 [GlobalISel] IRTranslator: Translate ConstantStruct
Reviewers: qcolombet, ab, t.p.northover, aditya_nandakumar, dsanders

Reviewed By: qcolombet

Subscribers: rovka, kristof.beyls, javed.absar, igorb, llvm-commits

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

llvm-svn: 303412
2017-05-19 09:47:02 +00:00
Craig Topper
19745008f4 [APInt] Use b.negate() in place of b = -std::move(b). NFCI
llvm-svn: 303411
2017-05-19 07:37:25 +00:00
Zachary Turner
ee00265d77 Fix compilation failure.
llvm-svn: 303410
2017-05-19 06:25:09 +00:00
Zachary Turner
4a5590fa6b Revert "[CodeView] Provide a common interface for type collections."
This is a squash of ~5 reverts of, well, pretty much everything
I did today.  Something is seriously broken with lit on Windows
right now, and as a result assertions that fire in tests are
triggering failures.  I've been breaking non-Windows bots all
day which has seriously confused me because all my tests have
been passing, and after running lit with -a to view the output
even on successful runs, I find out that the tool is crashing
and yet lit is still reporting it as a success!

At this point I don't even know where to start, so rather than
leave the tree broken for who knows how long, I will get this
back to green, and then once lit is fixed on Windows, hopefully
hopefully fix the remaining set of problems for real.

llvm-svn: 303409
2017-05-19 05:57:45 +00:00
Zachary Turner
92c35d4ced Don't crash if someone tries to visit an empty type stream.
llvm-svn: 303408
2017-05-19 05:18:09 +00:00
Zachary Turner
34aa3d3b80 [CodeView] Reduce memory usage in TypeSerializer.
We were using a BumpPtrAllocator to allocate stable storage for
a record, then trying to insert that into a hash table.  If a
collision occurred, the bytes were never inserted and the
allocation was unnecessary.  At the cost of an extra hash
computation, check first if it exists, and only if it does do
we allocate and insert.

llvm-svn: 303407
2017-05-19 04:56:48 +00:00
Davide Italiano
ce12003dd3 [NewGVN] Delete the old store when we find congruent to a load.
(or non-store, more in general). Fixes PR33086. Caught by the
store verifier.

llvm-svn: 303406
2017-05-19 04:06:10 +00:00
Zachary Turner
27dd822a80 Fix a broken test.
Similar to my previous fix, it turns out llvm-pdbdump has been
printing an incorrect value since the beginning of time, but
we didn't know it was incorrect.  Specifically, we were interpreting
a TypeIndex as referencing a type from the TPI stream when it
actually should come from the IPI stream.  So we were printing a
string that looked like a valid string, but was just from the
wrong place.

llvm-svn: 303403
2017-05-19 03:04:08 +00:00
Adam Nemet
ee90d5e61d Revert "[ADT] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC)."
This reverts commit r303383.

This breaks the modules-enabled macOS build with:

lib/Support/LockFileManager.cpp:86:7: error: declaration of 'gethostuuid' must be imported from module 'Darwin.POSIX.unistd' before it is required

llvm-svn: 303402
2017-05-19 02:56:37 +00:00
Zachary Turner
00a4a5626f Fix crasher in CodeView test.
Apparently this was always broken, but previously we were more
graceful about it and we would print "unknown udt" if we couldn't
find the type index, whereas now we just segfault because we
assume it's valid.  But this exposed a real bug, which is that
we weren't looking in the right place.  So fix that, and also
fix this crash at the same time.

llvm-svn: 303397
2017-05-19 00:56:39 +00:00
Matthias Braun
78b1b99fdb LiveIntervalAnalysis: Fix missing case in pruneSubRegValues()
pruneSubRegValues() needs to remove subregister ranges starting at
instructions that later get removed by eraseInstrs(). It missed to check
one case in which eraseInstrs() would remove an instruction.

Fixes http://llvm.org/PR32688

llvm-svn: 303396
2017-05-19 00:18:03 +00:00
Matthias Braun
6f700dbc36 Fix typo
llvm-svn: 303395
2017-05-19 00:17:59 +00:00
Zachary Turner
a71b96013a Fix another warning.
llvm-svn: 303394
2017-05-18 23:30:51 +00:00
Davide Italiano
02c672ba76 [NewGVN] Break infinite recursion in singleReachablePHIPath().
We can have cycles between PHIs and this causes singleReachablePhi()
to call itself indefintely (until we run out of stack). The proper
solution would be that of computing SCCs, but it's not worth for
now, so just keep a visited set and give up when we find a cycle.
Thanks to Dan for the discussion/help with this.

Fixes PR33014.

llvm-svn: 303393
2017-05-18 23:22:44 +00:00
Zachary Turner
cb522db549 Fix some build errors and warnings.
llvm-svn: 303391
2017-05-18 23:12:42 +00:00
Zachary Turner
4d00f79887 [CodeView] Raise the source to ID map out of the TypeStreamMerger.
This map will be needed to rewrite symbol streams after re-writing
the corresponding type streams.

llvm-svn: 303390
2017-05-18 23:04:08 +00:00