Commit Graph

277481 Commits

Author SHA1 Message Date
Peter Smith a939257a42 [ARM][AArch64] Workaround ARM/AArch64 peculiarity in clearing icache.
Certain ARM implementations treat icache clear instruction as a memory read,
and CPU segfaults on trying to clear cache on !PROT_READ page.
We workaround this in Memory::protectMappedMemory by adding
PROT_READ to affected pages, clearing the cache, and then setting
desired protection.

This fixes "AllocationTests/MappedMemoryTest.***/3" unit-tests on
affected hardware.

Reviewers: psmith, zatrazz, kristof.beyls, lhames

Reviewed By: lhames

Subscribers: llvm-commits, krytarowski, peter.smith, jgreenhalgh, aemerson,
             rengolin

Patch by maxim-kuvrykov! 

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

llvm-svn: 319166
2017-11-28 12:34:05 +00:00
Dean Michael Berris 542485f29c [XRay][compiler-rt][Darwin] Minimal XRay build support in Darwin
This change is the first in a series of changes to get the XRay runtime
building on macOS. This first allows us to build the minimal parts of
XRay to get us started on supporting macOS development. These include:

  - CMake changes to allow targeting x86_64 initially.
  - Allowing for building the initialisation routines without
    `.preinit_array` support.
  - Use __sanitizer::SleepForMillis() to work around the lack of
    clock_nanosleep on macOS.
  - Deprecate the xray_fdr_log_grace_period_us flag, and introduce
    the xray_fdr_log_grace_period_ms flag instead, to use
    milliseconds across platforms.

Reviewers: kubamracek

Subscribers: llvm-commits, krytarowski, nglevin, mgorny

Differential Review: https://reviews.llvm.org/D39114

llvm-svn: 319165
2017-11-28 11:49:22 +00:00
Chandler Carruth c34f789e38 Add a new pass to speculate around PHI nodes with constant (integer) operands when profitable.
The core idea is to (re-)introduce some redundancies where their cost is
hidden by the cost of materializing immediates for constant operands of
PHI nodes. When the cost of the redundancies is covered by this,
avoiding materializing the immediate has numerous benefits:
1) Less register pressure
2) Potential for further folding / combining
3) Potential for more efficient instructions due to immediate operand

As a motivating example, consider the remarkably different cost on x86
of a SHL instruction with an immediate operand versus a register
operand.

This pattern turns up surprisingly frequently, but is somewhat rarely
obvious as a significant performance problem.

The pass is entirely target independent, but it does rely on the target
cost model in TTI to decide when to speculate things around the PHI
node. I've included x86-focused tests, but any target that sets up its
immediate cost model should benefit from this pass.

There is probably more that can be done in this space, but the pass
as-is is enough to get some important performance on our internal
benchmarks, and should be generally performance neutral, but help with
more extensive benchmarking is always welcome.

One awkward part is that this pass has to be scheduled after
*everything* that can eliminate these kinds of redundancies. This
includes SimplifyCFG, GVN, etc. I'm open to suggestions about better
places to put this. We could in theory make it part of the codegen pass
pipeline, but there doesn't really seem to be a good reason for that --
it isn't "lowering" in any sense and only relies on pretty standard cost
model based TTI queries, so it seems to fit well with the "optimization"
pipeline model. Still, further thoughts on the pipeline position are
welcome.

I've also only implemented this in the new pass manager. If folks are
very interested, I can try to add it to the old PM as well, but I didn't
really see much point (my use case is already switched over to the new
PM).

I've tested this pretty heavily without issue. A wide range of
benchmarks internally show no change outside the noise, and I don't see
any significant changes in SPEC either. However, the size class
computation in tcmalloc is substantially improved by this, which turns
into a 2% to 4% win on the hottest path through tcmalloc for us, so
there are definitely important cases where this is going to make
a substantial difference.

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

llvm-svn: 319164
2017-11-28 11:32:31 +00:00
Kamil Rytarowski b789ab35b3 Correct mangled_sp on NetBSD/amd64 in TSan
The proper index is 6, not 2.

Patch extracted from https://reviews.llvm.org/D40337

Reviewed and accepted by <dvyukov>.

Sponsored by <The NetBSD Foundation>

llvm-svn: 319163
2017-11-28 11:21:27 +00:00
Pavel Labath bc8cc867a1 elf-core: Convert remaining register context to use register set maps
In https://reviews.llvm.org/D39681, we started using a map instead
passing a long list of register sets to the ppc64le register context.
However, existing register contexts were still using the old method.

This converts the remaining register contexts to use this approach.
While doing that, I've had to modify the approach a bit:
- the general purpose register set is still kept as a separate field,
because this one is always present, and it's parsing is somewhat
different than that of other register sets.
- since the same register sets have different IDs on different operating
systems, but we use the same register context class to represent
different register sets, I've needed to add a layer of indirection to
translate os-specific constants (e.g. NETBSD::NT_AMD64_FPREGS) into more
generic terms (e.g. floating point register set).

While slightly more complicated, this setup allows for better separation
of concerns. The parsing code in ProcessElfCore can focus on parsing
OS-specific core file notes, and can completely ignore
architecture-specific register sets (by just storing any unrecognised
notes in a map). These notes will then be passed on to the
architecture-specific register context, which can just deal with
architecture specifics, because the OS-specific note types are hidden in
a register set description map.

This way, adding an register set, which is already supported on other
OSes, to a new OS, should in most cases be as simple as adding a new
entry into the register set description map.

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

llvm-svn: 319162
2017-11-28 11:10:23 +00:00
Pavel Labath d2cfe0e597 Fix floating point register write on new x86 linux kernels
Summary:
New linux kernels (on systems that support the XSAVES instruction) will
not update the inferior registers unless the corresponding flag in the
XSAVE header is set. Normally this flag will be set in our image of the
XSAVE area (since we obtained it from the kernel), but if the inferior
has never used the corresponding register set, the respective flag can
be clear.

This fixes the issue by making sure we explicitly set the flags
corresponding to the registers we modify. I don't try to precisely match
the flags to set on each write, as the rules could get quite complicated
-- I use a simpler over-approximation instead.

This was already caught by test_fp_register_write, but that was only
because the code that ran before main() did not use some of the register
sets. Since nothing in this test relies on being stopped in main(), I
modify the test to stop at the entry point instead, so we can be sure
the inferior did not have a chance to access these registers.

Reviewers: clayborg, valentinagiusti

Subscribers: lldb-commits

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

llvm-svn: 319161
2017-11-28 10:56:54 +00:00
Kamil Rytarowski 1d67a48124 Handle symbol renaming of sigaction for NetBSD
Summary:
NetBSD uses the __sigaction14 symbol name for historical and compat
reasons for the sigaction(2) function name.

Rename the interceptors and users of sigaction to sigaction_symname
and reuse it in the code base.

This change fixes 4 failing tests in TSan/NetBSD:

 - ThreadSanitizer-x86_64 :: signal_errno.cc
 - ThreadSanitizer-x86_64 :: signal_malloc.cc
 - ThreadSanitizer-x86_64 :: signal_sync2.cc
 - ThreadSanitizer-x86_64 :: signal_thread.cc

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, eugenis, dvyukov, kcc

Reviewed By: dvyukov

Subscribers: kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 319160
2017-11-28 10:54:58 +00:00
Sam McCall ec109029b1 [clangd] Switch from YAMLParser to JSONExpr
Summary:
 - Converted Protocol.h parse() functions to take JSON::Expr.
   These no longer detect and log unknown fields, as this is not that
   useful and no longer free.
   I haven't changed the error handling too much: fields that were
   treated as optional before are still optional, even when it's wrong.
   Exception: object properties with the wrong type are now ignored.
 - Made JSONRPCDispatcher parse using json::parse
 - The bug where 'method' must come before 'params' in the stream is
 fixed as a side-effect. (And the same bug in executeCommand).
 - Some parser crashers fixed as a side effect.
   e.g. https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3890
 - The debug stream now prettyprints the input messages with --pretty.
 - Request params are attached to traces when tracing is enabled.
 - Fixed some bugs in tests (errors tolerated by YAMLParser, and
 off-by-ones in Content-Length that our null-termination was masking)
 - Fixed a random double-escape bug in ClangdLSPServer (it was our last
 use of YAMLParser!)

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 319159
2017-11-28 09:37:43 +00:00
Florian Hahn 25ea91a838 [TailRecursionElimination] Skip debug intrinsics.
Summary:
I think we do not need to analyze debug intrinsics here, as they should
not impact codegen. This has 2 benefits: 1) slightly less work to do and
2) avoiding generating optimization remarks for converting calls to
debug intrinsics to tail calls, which are not really helpful for users.

Based on work by Sander de Smalen.

Reviewers: davide, trentxintong, aprantl

Reviewed By: aprantl

Subscribers: llvm-commits, JDevlieghere

Tags: #debug-info

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

llvm-svn: 319158
2017-11-28 09:32:25 +00:00
Sam McCall 1bb272bc74 [clangd] Add missing (but documented!) JSONExpr typed accessors
Summary:
Noticed this when I tried to port the Protocol.h parsers.
And tests for the inspect API, which caught a small bug.

Reviewers: ioeric

Subscribers: ilya-biryukov

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

llvm-svn: 319157
2017-11-28 09:25:09 +00:00
Nicolai Haehnle b4f28deda0 AMDGPU: Re-organize the outer loop of SILoadStoreOptimizer
Summary:
The entire algorithm operates per basic-block, so for cache locality
it should be better to re-optimize a basic-block immediately rather than
in a separate loop.

I don't have performance measurements.

Change-Id: I85106570bd623c4ff277faaa50ee43258e1ddcc5

Reviewers: arsenm, rampitec

Subscribers: kzhuravl, wdng, yaxunl, dstuttard, tpr, llvm-commits, t-tye

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

llvm-svn: 319156
2017-11-28 08:42:46 +00:00
Nicolai Haehnle 39980dac0b AMDGPU: Consistently check for immediates in SIInstrInfo::FoldImmediate
Summary:
The PeepholeOptimizer pass calls this function solely based on checking
DefMI->isMoveImmediate(), which only checks the MoveImm bit of the
instruction description. So it's up to FoldImmediate itself to properly
check that DefMI *actually* moves from an immediate.

I don't have a separate test case for this, but the next patch introduces
a test case which happens to crash without this change.

This error is caught by the assertion in MachineOperand::getImm().

Change-Id: I88e7cdbcf54d75e1a296822e6fe5f9a5f095bbf8

Reviewers: arsenm, rampitec

Subscribers: kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits

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

llvm-svn: 319155
2017-11-28 08:41:50 +00:00
Igor Kudrin a46522f369 Revert r319008, "[ELF] Do not keep symbols if they referenced only from discarded sections."
and r319051, "Add a missing test."

r319008 broke the LTO bots;
r319051 depends on changes in r319008.

llvm-svn: 319154
2017-11-28 08:39:40 +00:00
Max Kazantsev 6e78ad35cc [SCEV][NFC] More efficient caching in CompareValueComplexity
Currently, we use a set of pairs to cache responces like `CompareValueComplexity(X, Y) == 0`. If we had
proved that `CompareValueComplexity(S1, S2) == 0` and `CompareValueComplexity(S2, S3) == 0`,
this cache does not allow us to prove that `CompareValueComplexity(S1, S3)` is also `0`.

This patch replaces this set with `EquivalenceClasses` that merges Values into equivalence sets so that
any two values from the same set are equal from point of `CompareValueComplexity`. This, in particular,
allows us to prove the fact from example above.

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

llvm-svn: 319153
2017-11-28 08:26:43 +00:00
Martin Storsjo 2d614ced55 Fix shared library builds of lld, broken in SVN r319138
llvm-svn: 319152
2017-11-28 08:12:03 +00:00
Martin Storsjo f2508f46ca [COFF] Interpret a period as a separator for section suffix just like '$'
This allows grouping all sections like ".ctors.12345" into ".ctors".

For MinGW, the numerical values for such ctors are all zero-padded,
so a lexical sort is good enough.

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

llvm-svn: 319151
2017-11-28 08:08:37 +00:00
Martin Storsjo 04b68446eb [COFF] Implement constructor priorities
The priorities in the section name suffixes are zero padded,
allowing the linker to just do a lexical sort.

Add zero padding for .ctors sections in ELF as well.

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

llvm-svn: 319150
2017-11-28 08:07:18 +00:00
Max Kazantsev cf9b1b24ce [SCEV][NFC] More efficient caching in CompareSCEVComplexity
Currently, we use a set of pairs to cache responces like `CompareSCEVComplexity(X, Y) == 0`. If we had
proved that `CompareSCEVComplexity(S1, S2) == 0` and `CompareSCEVComplexity(S2, S3) == 0`,
this cache does not allow us to prove that `CompareSCEVComplexity(S1, S3)` is also `0`.

This patch replaces this set with `EquivalenceClasses` any two values from the same set are equal from
point of `CompareSCEVComplexity`. This, in particular, allows us to prove the fact from example above.

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

llvm-svn: 319149
2017-11-28 07:48:12 +00:00
Kevin Funk 08c2f0fabb run-clang-tidy: Use check_call instead of check_output
Summary:
Streamlines the output under Python 3.x.

Before:
```
b'Enabled checks:\n    clang-analyzer-apiModeling.google.GTest\n ...
```

After:
```
Enabled checks:
    clang-analyzer-apiModeling.google.GTest
...
```

Reviewers: cfe-commits, alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere

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

Change-Id: I6287104bc73926ae6d0f66c15c250c3cb44bee33
llvm-svn: 319148
2017-11-28 07:17:01 +00:00
Max Kazantsev 115607226a [GVN] Prevent ScalarPRE from hoisting across instructions that don't pass control flow to successors
This is to address a problem similar to those in D37460 for Scalar PRE. We should not
PRE across an instruction that may not pass execution to its successor unless it is safe
to speculatively execute it.

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

llvm-svn: 319147
2017-11-28 07:07:55 +00:00
Adam Nemet bf74f64e67 Revert "Add opt-viewer testing"
This reverts commit r319073.

Bot fails with a mismatch that looks like pygments-generated HTML.

llvm-svn: 319146
2017-11-28 06:22:29 +00:00
Martin Storsjo 0db60f3637 [test] Fix a typo in a test comment. NFC.
llvm-svn: 319145
2017-11-28 05:47:24 +00:00
Dan Gohman 3ff73cfbcd [WebAssembly] Handle errors better in fast-isel.
Fast-isel routines need to bail out in the case that fast-isel
fails on the operands.

This fixes https://bugs.llvm.org/show_bug.cgi?id=35064

llvm-svn: 319144
2017-11-28 05:36:42 +00:00
Craig Topper 640a3c1e2a [X86] Remove some unused pattern fragments from td file. NFC
llvm-svn: 319143
2017-11-28 05:23:57 +00:00
Simon Dardis 3aeb1a5404 [DAGCombine] Disable finding better chains for stores at O0
Unoptimized IR can have linear sequences of stores to an array, where the
initial GEP for the first store is formed from the pointer to the array, and the
GEP for each store after the first is formed from the previous GEP with some
offset in an inductive fashion.

The (large) resulting DAG when analyzed by DAGCombine undergoes an excessive
number of combines as each store node is examined every time its' offset node
is combined with any child of the offset. One of the transformations is
findBetterNeighborChains which assists MergeConsecutiveStores. The former
relies on repeated chain walking to do its' work, however MergeConsecutiveStores
is disabled at O0 which makes the transformation redundant.

Any optimization level other than O0 would invoke InstCombine which would
resolve the chain of GEPs into flat base + offset GEP for each store which
does not exhibit the repeated examination of each store to the array.

Disabling this optimization fixes an excessive compile time issue (30~ minutes
for the test case provided) at O0.

Reviewers: niravd, craig.topper, t.p.northover

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

llvm-svn: 319142
2017-11-28 04:07:59 +00:00
Matthias Braun eca985847c MachineVerifier: Improve register operand checks
This fixes cases where we wouldn't perform various register operand
checks just because we didn't happen to have a definition in the
MCInstrDesc. This changes the code to only skip the tests that actually
depend on the MCInstrDesc definition.

This makes the machine verifier spot the problem from
https://llvm.org/PR33071 after the pass that actually caused it.

llvm-svn: 319141
2017-11-28 03:54:20 +00:00
Matthias Braun a6d5374ee6 MachineVerifier: Improve PHI operand checking
Additional checks for phi operands:
- first operand should be a virtual register def. It should not be
  tied, implicit, internalread, earlyclobber or a read.
- The other operands should be register/mbb operands next to each other
- The register operands should not be implicit, internalread,
  earlyclobber, debug or tied.
- We can perform most of the PHI checks even for unreachable blocks.

llvm-svn: 319140
2017-11-28 03:54:19 +00:00
Matthias Braun adf7582d14 lit: Bring back -Dtool=xxx feature lost in r313928
llvm-svn: 319139
2017-11-28 03:23:07 +00:00
Rui Ueyama 53fe469162 Factor out common code to Common/Strings.cpp.
Differential Revision: https://reviews.llvm.org/D40530

llvm-svn: 319138
2017-11-28 02:15:26 +00:00
Rafael Espindola 3ecd20430c Use FILE_FLAG_DELETE_ON_CLOSE for TempFile on windows.
We won't see the temp file no more.

llvm-svn: 319137
2017-11-28 01:41:22 +00:00
Craig Topper ddbc340c20 [X86] Make zero extend from v16i1/v8i1 to v16i8/v8i16/v16i16 not scalarize under AVX512.
llvm-svn: 319136
2017-11-28 01:36:33 +00:00
Craig Topper 5befc5bfce [X86] Add command line without AVX512BW/AVX512VL to bitcast-int-to-vector-bool-zext.ll.
llvm-svn: 319135
2017-11-28 01:36:31 +00:00
Rafael Espindola 2c4e920f0c Move code. NFC.
This moves the TempFile implementation so that it can use system
specific code.

llvm-svn: 319134
2017-11-28 01:34:20 +00:00
Peter Collingbourne 1621c20ffc Reland r319090, "COFF: Do not create SectionChunks for discarded comdat sections." with a fix for debug sections.
If /debug was not specified, readSection will return a null
pointer for debug sections. If the debug section is associative with
another section, we need to make sure that the section returned from
readSection is not a null pointer before adding it as an associative
section.

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

llvm-svn: 319133
2017-11-28 01:30:07 +00:00
Stephane Sezer b108dbcc91 Remove some duplicated code in UUID.cpp
Summary: Formatting needs to be done only once. Ran check-lldb and nothing changes.

Reviewers: clayborg, davide

Reviewed By: clayborg, davide

Subscribers: zturner, davide, lldb-commits

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

llvm-svn: 319132
2017-11-28 01:26:07 +00:00
Rafael Espindola c06f55e1e8 This reverts commit r319096 and r319097.
Revert "[SROA] Propagate !range metadata when moving loads."
Revert "[Mem2Reg] Clang-format unformatted parts of this file. NFCI."

Davide says they broke a bot.

llvm-svn: 319131
2017-11-28 01:25:38 +00:00
Matthias Braun 5d01e708e1 ARM: Fix PR32578
https://llvm.org/PR32578

I simplified and converted the reproducer into a lit test.

Patch by Vedant Kumar!

llvm-svn: 319130
2017-11-28 01:17:52 +00:00
Dan Gohman 0811cd1d15 [WebAssembly] Add options for using the nontrapping-fptoint feature.
This adds ways to control use of WebAssembly's new nontrapping-fptoint
feature.

llvm-svn: 319129
2017-11-28 01:13:45 +00:00
Dan Gohman cdd48b8a6b [WebAssembly] Fix trapping behavior in fptosi/fptoui.
This adds code to protect WebAssembly's `trunc_s` family of opcodes
from values outside their domain. Even though such conversions have
full undefined behavior in C/C++, LLVM IR's `fptosi` and `fptoui` do
not, and only return undef.

This also implements the proposed non-trapping float-to-int conversion
feature and uses that instead when available.

llvm-svn: 319128
2017-11-28 01:13:40 +00:00
Rafael Espindola 9e3381e8dc Store the real binding of shared symbols.
Currently we mark every shared symbol as STB_WEAK.

That is a hack to make it easy to decide when a .so is needed or not
because of a reference to a given symbol.

That hack leaks when we create copy relocations as shown by the update
to relocation-copy-alias.s.

This patch stores the original binding when we first read a shared
symbol. We still have to update the binding to weak if we see a weak
undef, but I find the logic easier to read where it is now.

llvm-svn: 319127
2017-11-28 01:04:51 +00:00
Adrian Prantl d7f6f1636d SROA: Avoid creating a fragment expression that covers the entire variable.
Fixes PR35416.

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

llvm-svn: 319126
2017-11-28 00:57:53 +00:00
Adrian Prantl 3e0e1d0934 Move getVariableSize from Verifier.cpp into DIVariable::getSize() (NFC)
llvm-svn: 319125
2017-11-28 00:57:51 +00:00
Craig Topper 8b9cd03824 [X86] Remove unnecessary fp<->int setOperationAction lines from a hasVLX block. NFCI
These lines all exist identically either under SSE2, AVX2 or AVX512. Given that VLX implies all of those, these aren't providing anything new.

llvm-svn: 319124
2017-11-28 00:41:12 +00:00
Akira Hatanaka 9ef1daa46e Insert padding before the __cxa_exception header to ensure the thrown
object is sufficiently aligned.

r303175 annotated field unwindHeader of __cxa_exception with attribute
'aligned' to ensure the thrown object following the __cxa_exception
header was sufficiently aligned. This caused changes in the field
offsets of __cxa_exception relative to the start of the thrown object,
which was an ABI breaking change for some clients.

Instead of annotating field unwindHeader, this commit inserts extra
space before the header. This ensures the thrown object following the
header is sufficiently aligned without changing the field offsets, thus
avoiding any ABI breakages.

rdar://problem/25364625
rdar://problem/35556163

llvm-svn: 319123
2017-11-28 00:36:29 +00:00
Craig Topper ce732e7c30 [X86] Remove duplicate calls to setOperationAction. NFCI
These same calls exist a few lines down.

llvm-svn: 319122
2017-11-28 00:16:42 +00:00
Rafael Espindola bce112c9e9 Add an F_Delete flag.
For now this only changes the handle Access.

llvm-svn: 319121
2017-11-28 00:12:44 +00:00
Craig Topper dbd4a7fecc [DAGCombiner] Don't combine aext(setcc) if the setcc is already using the target's preferred result type.
With AVX512 vXi1 types are legal so we shouldn't be extending them.

This change is similar to existing code in the zext(setcc) combine.

llvm-svn: 319120
2017-11-27 23:51:40 +00:00
Craig Topper 57c02d18b9 [DAGCombiner] Use EVT::changeVectorElementTypeToInteger() instead of implementing manually.
llvm-svn: 319119
2017-11-27 23:51:31 +00:00
Rafael Espindola d19c2e8126 Add OpenFlags to the create(Unique|Temporary)File interfaces.
This will allow a future F_Delete flag to be specified when we want
the file to be automatically deleted on close.

llvm-svn: 319117
2017-11-27 23:44:11 +00:00
Reid Kleckner f9b08a382c [clang-cl] Alias /Wall to -Weverything
cl interprets this option to mean enable every supported warning, which
is what Clang's -Weverything flag does.

llvm-svn: 319116
2017-11-27 23:42:20 +00:00