1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00
Commit Graph

168785 Commits

Author SHA1 Message Date
Zachary Turner
8f68390df4 Add support for unittest inputs.
Occasionally it is useful to have unittest which take inputs.
While we normally try to have this test be more of a lit test
we occasionally don't have tools that can exercise the code
in the right way to test certain things.  LLDB has been using
this style of unit test for a while, particularly with regards
to how it tests core dump and minidump file parsing.  Recently
i needed this as well for the case where we want to test that
some of the PDB reading code works correctly.  It needs to
exercise the code in a way that is not covered by any dumper
and would be impractical to implement in one of the dumpers,
but requires a valid PDB file.  Since this is now needed by
more than one project, it makes sense to have this be a
generally supported thing that unit tests can do, and we just
encourage people to use this sparingly.

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

llvm-svn: 341502
2018-09-05 23:30:17 +00:00
Lang Hames
7c4fdfe5f4 Remove some unnecessary constructor arguments.
ExecutionSession defaults to creating a new shared pool if none is provided,
so explicitly passing one in is unnecessary.

llvm-svn: 341494
2018-09-05 20:57:41 +00:00
JF Bastien
d58c1ac269 NFC: more memset inline arm64 coverage
I'm looking at some codegen optimization in this area and want to make sure I understand the current codegen and don't regress it. This patch further expands the tests (which I already expanded in r341406) to capture more of the current code generation when it comes to stack-based small non-zero memset on arm64. This patch annotates some potential fixes.

llvm-svn: 341493
2018-09-05 20:35:06 +00:00
Nico Weber
9ce85d59e4 Handle zero-length debug directory entries.
Part of https://reviews.llvm.org/D51652 (tests will be in the lld repo)

llvm-svn: 341485
2018-09-05 18:01:04 +00:00
Sanjay Patel
42bcf8cc7b [DAGCombiner] try to convert pow(x, 0.25) to sqrt(sqrt(x))
This was proposed as an IR transform in D49306, but it was not clearly justifiable as a canonicalization. 
Here, we only do the transform when the target tells us that sqrt can be lowered with inline code.

This is the basic case. Some potential enhancements are in the TODO comments:

1. Generalize the transform for other exponents (allow more than 2 sqrt calcs if that's really cheaper).
2. If we have less fast-math-flags, generate code to avoid -0.0 and/or INF.
3. Allow the transform when optimizing/minimizing size (might require a target hook to get that right).

Note that by default, x86 converts single-precision sqrt calcs into sqrt reciprocal estimate with 
refinement. That codegen is controlled by CPU attributes and can be manually overridden. We have plenty 
of test coverage for that already, so I didn't bother to include extra testing for that here. AArch uses 
its full-precision ops in all cases (not sure if that's the intended behavior or not, but that should 
also be covered by existing tests).

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

llvm-svn: 341481
2018-09-05 17:01:56 +00:00
Dean Michael Berris
34d36e3ae5 [XRay] Use a function to return a constant
We do this instead of using static constexpr char arrays because MSVC
2015 cannot handle the constant initialisation of those along with the
out-of-line storage declaration.

This is a follow-up to D51672.

llvm-svn: 341479
2018-09-05 16:03:21 +00:00
Krzysztof Parzyszek
8d6a75e04c [Hexagon] Ignore unnamed globals in HexagonConstExtenders
This replaces r337723. The global list in the module can be huge with LTO,
plus the module can change between different invocations of the pass, so
there is no easy way to deterministically cache the ordering (especially
in the presence of multiple threads).

llvm-svn: 341478
2018-09-05 15:54:44 +00:00
Dean Michael Berris
9a2aaa8744 [XRay] Use const instead of constexpr in storage declaration
This should make MSVC happy with the storage provided for static
constexpr character arrays out-of-line.

Follow-up to D51672.

llvm-svn: 341477
2018-09-05 15:19:43 +00:00
Kirill Bobyrev
730e46464c [benchmark] Fix 32-bit build failure
This patch applies upstream commit:
f0901417c8

Tim Northover pointed out that benchmark build might be broken on 32-bit
macOS. This commit by Roman Lebedev (lebedev.ri) resolves the issue.

Reviewed By: lebedev.ri

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

llvm-svn: 341469
2018-09-05 14:15:39 +00:00
Benjamin Kramer
40fd323276 [ControlHeightReduction] Remove unused includes
Also clang-format them.

llvm-svn: 341468
2018-09-05 13:51:05 +00:00
Jordan Rupprecht
52282e180e [llvm-strip] Support stripping multiple input files
Summary:
Allow strip to be called on multiple input files, which is interpreted as stripping N files in place. Using multiple input files is incompatible with -o.

To allow this, create a `DriverConfig` struct which just wraps a list of `CopyConfigs`. objcopy will only ever have a single `CopyConfig`, but strip will have N (where N >= 1) CopyConfigs.

Reviewers: alexshap, jakehehrlich

Reviewed By: alexshap, jakehehrlich

Subscribers: MaskRay, jakehehrlich, llvm-commits

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

llvm-svn: 341464
2018-09-05 13:10:03 +00:00
Benjamin Kramer
1aa290ab4d [Aggressive InstCombine] Move C bindings to their own header file.
llvm-svn: 341461
2018-09-05 11:41:12 +00:00
Jonas Devlieghere
46975d210c [DebugInfo] Normalize common kinds of DWARF sub-expressions.
Normalize common kinds of DWARF sub-expressions to make debug info
encoding a bit more compact:

  DW_OP_constu [X < 32] -> DW_OP_litX
  DW_OP_constu [all ones] -> DW_OP_lit0, DW_OP_not (64-bit only)

Differential revision: https://reviews.llvm.org/D51640

llvm-svn: 341457
2018-09-05 10:18:36 +00:00
Max Kazantsev
39bd69ac41 [NFC] Add test on full IV widening
llvm-svn: 341456
2018-09-05 10:10:59 +00:00
Sander de Smalen
3be19719e3 Remove FrameAccess struct from hasLoadFromStackSlot
This removes the FrameAccess struct that was added to the interface
in D51537, since the PseudoValue from the MachineMemoryOperand
can be safely casted to a FixedStackPseudoSourceValue.

Reviewers: MatzeB, thegameg, javed.absar

Reviewed By: thegameg

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

llvm-svn: 341454
2018-09-05 08:59:50 +00:00
Dean Michael Berris
05508f6a1d [XRay] Add a RecordPrinter visitor for FDR Records
Summary:
This change adds a `RecordPrinter` type which does some basic text
serialization of the FDR record instances. This is one component of the
tool we're building to dump the records from an FDR mode log as-is.

This is a small part of D50441.

Reviewers: eizan, kpw

Subscribers: mgorny, hiraditya, llvm-commits

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

llvm-svn: 341447
2018-09-05 06:57:23 +00:00
Hsiangkai Wang
630fbe00e5 [DebugInfo] Fix bug in LiveDebugVariables.
In lib/CodeGen/LiveDebugVariables.cpp, it uses std::prev(MBBI) to
get DebugValue's SlotIndex. However, the previous instruction may be
also a debug instruction. It could not use a debug instruction to query
SlotIndex in mi2iMap.

Scan all debug instructions and use the first debug instruction to query
SlotIndex for following debug instructions. Only handle DBG_VALUE in
handleDebugValue().

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

llvm-svn: 341446
2018-09-05 05:58:53 +00:00
Richard Trieu
5cc0f882a6 Prevent unsigned overflow.
The sum of the weights is caculated in an APInt, which has a width smaller than
64.  In certain cases, the sum of the widths would overflow when calculations
are done inside an APInt, but would not if done with uint64_t.  Since the
values will be passed as uint64_t in the function call anyways, do all the math
in 64 bits.  Also added an assert in case the probabilities overflow 64 bits.

llvm-svn: 341444
2018-09-05 04:19:15 +00:00
Fangrui Song
36e6b77321 Fix -Wunused-function in release build after rL341386
llvm-svn: 341443
2018-09-05 03:10:20 +00:00
Heejin Ahn
9f8667c989 [WebAssembly] clang-format (NFC)
Summary: This patch runs clang-format on all wasm-only files.

Reviewers: aardappel, dschuff, sunfish, tlively

Subscribers: MatzeB, sbc100, jgravelle-google, llvm-commits

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

llvm-svn: 341439
2018-09-05 01:27:38 +00:00
Reid Kleckner
4678c409ee Fix -Wunused-private-variable on non-Windows
I didn't want to use ifdefs in headers, but I'll do it to pacify a
warning.

llvm-svn: 341436
2018-09-05 00:18:05 +00:00
Reid Kleckner
d11aae6992 [Windows] Convert from UTF-8 to UTF-16 when writing to a Windows console
Summary:
Calling WriteConsoleW is the most reliable way to print Unicode
characters to a Windows console.

If binary data gets printed to the console, attempting to re-encode it
shouldn't be a problem, since garbage in can produce garbage out.

This breaks printing strings in the local codepage, which WriteConsoleA
knows how to handle. For example, this can happen when user source code
is encoded with the local codepage, and an LLVM tool quotes it while
emitting a caret diagnostic. This is unfortunate, but well-behaved tools
should validate that their input is UTF-8 and escape non-UTF-8
characters before sending them to raw_fd_ostream. Clang already does
this, but not all LLVM tools do this.

One drawback to the current implementation is printing a string a byte
at a time doesn't work. Consider this LLVM code:
  for (char C : MyStr) outs() << C;

Because outs() is now unbuffered, we wil try to convert each byte to
UTF-16, which will fail. However, this already didn't work, so I think
we may as well update callers that do that as we find them to print
complete portions of strings. You can see a real example of this in my
patch to SourceMgr.cpp

Fixes PR38669 and PR36267.

Reviewers: zturner, efriedma

Subscribers: llvm-commits, hiraditya

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

llvm-svn: 341433
2018-09-05 00:08:56 +00:00
Sanjay Patel
3d57fb8f30 [InstCombine] fix xor-or-xor fold to check uses and handle commutes
I'm probably missing some way to use m_Deferred to remove the code
duplication, but that can be a follow-up.

The improvement in demand_shrink_nsw.ll is an example of missing
the fold because the pattern matching was deficient. I didn't try
to follow the bits in that test, but Alive says it's correct:
https://rise4fun.com/Alive/ugc

llvm-svn: 341426
2018-09-04 23:22:13 +00:00
Sanjay Patel
20ab06d834 [InstCombine] update tests checks; NFC
llvm-svn: 341424
2018-09-04 23:08:23 +00:00
Wouter van Oortmerssen
b3dd0636f3 [WebAssembly] Fixed stale assert message in WebAssemblyMCInstLower
llvm-svn: 341423
2018-09-04 22:59:05 +00:00
Steven Wu
60afa177aa [ThinLTO] Fix memory corruption in ThinLTOCodeGenerator when CodeGenOnly was specified
Summary:
Issue occurs when doing ThinLTO with CodeGenOnly flag.
TMBuilder.TheTriple is assigned to by multiple threads in an unsafe way resulting in double-free of std::string memory.

Pseudocode:
if (CodeGenOnly) {
  // Perform only parallel codegen and return.
  ThreadPool Pool;
  int count = 0;
  for (auto &ModuleBuffer : Modules) {
    Pool.async([&](int count) {
    ...
      /// Now call OutputBuffer = codegen(*TheModule);
      /// Which turns into initTMBuilder(moduleTMBuilder, Triple(TheModule.getTargetTriple()));
      /// Which turns into

      TMBuilder.TheTriple = std::move(TheTriple);   // std::string = "....."
      /// So, basically std::string assignment to same string on multiple threads = memory corruption

  }

  return;
}

Patch by Alex Borcan

Reviewers: llvm-commits, steven_wu

Reviewed By: steven_wu

Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, llvm-commits

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

llvm-svn: 341422
2018-09-04 22:54:17 +00:00
Jordan Rupprecht
8c109ac65d [llvm-strip] Allow copying relocation sections without symbol tables.
Summary:
Fixes the error "Link field value 0 in section .rela.plt is invalid" when copying/stripping certain binaries. Minimal repro:

```
$ cat /tmp/a.c
int main() { return 0; }
$ clang -static /tmp/a.c -o /tmp/a
$ llvm-strip /tmp/a -o /tmp/b
llvm-strip: error: Link field value 0 in section .rela.plt is invalid.
```

Reviewers: jakehehrlich, alexshap

Subscribers: llvm-commits

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

llvm-svn: 341419
2018-09-04 22:28:49 +00:00
Zhaoshi Zheng
7cb7429e0d Revert "Revert r341269: [Constant Hoisting] Hoisting Constant GEP Expressions"
Reland r341269. Use std::stable_sort when sorting constant condidates.

Reverting commit, r341365:

  Revert r341269: [Constant Hoisting] Hoisting Constant GEP Expressions

  One of the tests is failing 50% of the time when expensive checks are
  enabled. Not sure how deep the problem is so just reverting while the
  author can investigate so that the bots stop repeatedly failing and
  blaming things incorrectly. Will respond with details on the original
  commit.

Original commit, r341269:

  [Constant Hoisting] Hoisting Constant GEP Expressions

  Leverage existing logic in constant hoisting pass to transform constant GEP
  expressions sharing the same base global variable. Multi-dimensional GEPs are
  rewritten into single-dimensional GEPs.

  https://reviews.llvm.org/D51396

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

llvm-svn: 341417
2018-09-04 22:17:03 +00:00
Anna Thomas
d0c6bf40cb [LV] First order recurrence phis should not be treated as uniform
This is fix for PR38786.
First order recurrence phis were incorrectly treated as uniform,
which caused them to be vectorized as uniform instructions.

Patch by Ayal Zaks and Orivej Desh!

Reviewed by: Anna

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

llvm-svn: 341416
2018-09-04 22:12:23 +00:00
Sanjay Patel
5d0534e4b6 [InstCombine] add tests for xor-or-xor fold; NFC
There are 2 bugs shown here that were untested before:
1. We fail to perform the fold in 1/2 the possible commuted variants.
2. When the fold is done, it disregards extra uses.

llvm-svn: 341415
2018-09-04 22:10:23 +00:00
Thomas Lively
c7841b3d66 [WebAssembly][NFC] Add colon to label in test
llvm-svn: 341414
2018-09-04 21:51:32 +00:00
Scott Linder
cf2ce3c6d5 [AMDGPU] Legalize VGPR Rsrc operands for MUBUF instructions
Emit a waterfall loop in the general case for a potentially-divergent Rsrc
operand. When practical, avoid this by using Addr64 instructions.

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

llvm-svn: 341413
2018-09-04 21:50:47 +00:00
Hiroshi Yamauchi
3b619a8745 Fix a memory leak after rL341386.
Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

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

llvm-svn: 341412
2018-09-04 21:28:22 +00:00
Thomas Lively
1312bc6529 [WebAssembly][NFC] Fix formatting and tests
Summary: Small fixes

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

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

llvm-svn: 341411
2018-09-04 21:26:17 +00:00
Sanjay Patel
e15dec4563 [InstCombine] make ((X & C) ^ C) form consistent for vectors
It would be better to create a 'not' here, but that's not possible yet.

llvm-svn: 341410
2018-09-04 21:17:14 +00:00
Krzysztof Parzyszek
87af4ff655 [Hexagon] Don't packetize new-value stores with any other stores
llvm-svn: 341409
2018-09-04 21:07:27 +00:00
Jessica Paquette
bce4b693c0 [NFC] Improve clarity in emitInstrCountChangedRemark
Add a "CouldOnlyImpactOneFunction" bool that's true when we pass in a function.

Just cleaning up a little bit, since I'm going to add in the per-function
remarks soon from D51467.

llvm-svn: 341407
2018-09-04 21:03:43 +00:00
JF Bastien
d91dbee4c9 NFC: expand memset inline arm64 coverage
I'm looking at some codegen optimization in this area and want to make sure I understand the current codegen and don't regress it. This patch simply expands the two existing tests to capture more of the current code generation when it comes to heap-based and stack-based small memset on arm64. The tested code is already pretty good, notably when it comes to using STP, FP stores, FP immediate generation, and folding one of the stores into a stack spill when possible. The uses of STUR could be improved, and some more pairing could occur. Straying from bzero patterns currently yield suboptimal code, and I expect a variety of small changes could make things way better.

llvm-svn: 341406
2018-09-04 21:02:00 +00:00
Sanjay Patel
750584b948 [InstCombine] simplify code for xor folds; NFCI
This is just a cleanup step. The TODO comments show
what is wrong with the 'and' version of the fold.
Fixing this should be part of recommitting:
rL300977

llvm-svn: 341405
2018-09-04 21:00:13 +00:00
Martin Storsjo
3bc21d8a2b [MinGW] Move code for indicating "potentially not DSO local" into shouldAssumeDSOLocal. NFC.
On Windows, if shouldAssumeDSOLocal returns false, it's either a
dllimport reference, or a reference that we should treat as non-local
and create a stub for.

Clean up AArch64Subtarget::ClassifyGlobalReference a little while
touching the flag handling relating to dllimport.

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

llvm-svn: 341402
2018-09-04 20:56:28 +00:00
Martin Storsjo
3d5c7d84ef [MinGW] [AArch64] Add stubs for potential automatic dllimported variables
The runtime pseudo relocations can't handle the AArch64 format PC
relative addressing in adrp+add/ldr pairs. By using stubs, the potentially
dllimported addresses can be touched up by the runtime pseudo relocation
framework.

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

llvm-svn: 341401
2018-09-04 20:56:21 +00:00
Reid Kleckner
5b5de5fce2 Fix unused variable warning
llvm-svn: 341400
2018-09-04 20:34:47 +00:00
Fedor Sergeev
293faf6963 [SimpleLoopUnswitch] remove a chain of dead blocks at once
Recent change to deleteDeadBlocksFromLoop was not enough to
fix all the problems related to dead blocks after nontrivial
unswitching of switches.

We need to delete all the dead blocks that were created during
unswitching, otherwise we will keep having problems with phi's
or dead blocks.

This change removes all the dead blocks that are reachable from the loop,
not trying to track whether these blocks are newly created by unswitching
or not. While not completely correct, we are unlikely to get loose but
reachable dead blocks that do not belong to our loop nest.

It does fix all the failures currently known, in particular PR38778.

Reviewed By: asbirlea
Differential Revision: https://reviews.llvm.org/D51519

llvm-svn: 341398
2018-09-04 20:19:41 +00:00
Jordan Rupprecht
97dfb8a76f [Codegen] Fix test added in rL341380: AArch64SelectionDAGTest needs to link against Analysis lib.
llvm-svn: 341397
2018-09-04 20:19:17 +00:00
David Bolvansky
2b323c39a7 Set console mode when -fansi-escape-codes is enabled
Summary:
Windows console now supports supports ANSI escape codes, but we need to enable it using SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_PROCESSING flag.

Fixes https://bugs.llvm.org/show_bug.cgi?id=38817


Tested on Windows 10, screenshot:
https://i.imgur.com/bqYq0Uy.png

Reviewers: zturner, chandlerc

Reviewed By: zturner

Subscribers: llvm-commits

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

llvm-svn: 341396
2018-09-04 19:23:05 +00:00
Petr Hosek
76928b42ba [CMake] Provide a custom target to install LLVM libraries
This simplifies installing all LLVM libraries when doing component
build; now you can include llvm-libraries in distribution components.

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

llvm-svn: 341395
2018-09-04 19:10:37 +00:00
Sanjay Patel
db413159fc [InstCombine] improve xor+and/or tests
The tests attempted to check for commuted variants
of these folds, but complexity-based canonicalization
meant we had no coverage for at least 1/2 of the cases.

Also, the folds correctly check hasOneUse(), but there
was no coverage for that.

llvm-svn: 341394
2018-09-04 19:06:46 +00:00
Matt Arsenault
96fe4a902d AMDGPU: Fix DAG divergence not reporting flat loads
Match behavior in DAG of r340343

llvm-svn: 341393
2018-09-04 18:58:19 +00:00
Matt Arsenault
f67c2cb6e0 DAG: Factor out helper function for odd vector sizes
llvm-svn: 341392
2018-09-04 18:47:43 +00:00
Hiroshi Yamauchi
de62de353b Fix build failures after rL341386.
Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

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

llvm-svn: 341391
2018-09-04 18:10:54 +00:00