Kostya Serebryany [Tue, 4 Sep 2018 23:57:09 +0000 (23:57 +0000)]
[hwasan] remove stale Thread:: data members. While doing so noticed that GetThreadStackAndTls was always called with 'at_initialization=true', fixed that.
llvm-svn: 341431
Kostya Serebryany [Tue, 4 Sep 2018 23:26:08 +0000 (23:26 +0000)]
[hwasan] add a unique id to a thread and add debug prints for thread creation/destruction
llvm-svn: 341428
Sanjay Patel [Tue, 4 Sep 2018 23:22:13 +0000 (23:22 +0000)]
[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
Frederic Riss [Tue, 4 Sep 2018 23:09:49 +0000 (23:09 +0000)]
Change TestCompletion to only ever look inside of BaseDir
TestCompletion was failing quite frequently on our Linux bots. Some tracing
revealed that when we are iterating BaseDir we are not getting all the entries.
More specifically, we are sometimes missing the entry corresponding to the
TestCompletion directory that the first test in DirCompletionAbsolute is
looking for. BaseDir is the directory where lit is creating all the temporary
files. The semantics of opendir/readdir are unclear when it comes to iterating
over a directory that changes contents, but it seems like on Linux you might
fail to list an entry even if it was there before opendir and is still present
throughout the iteration. Changing the test to only look inside of the test-
specific directory seems to fix the instability.
This commit also removes some assertions that were added to try to track down
this issue.
llvm-svn: 341425
Sanjay Patel [Tue, 4 Sep 2018 23:08:23 +0000 (23:08 +0000)]
[InstCombine] update tests checks; NFC
llvm-svn: 341424
Wouter van Oortmerssen [Tue, 4 Sep 2018 22:59:05 +0000 (22:59 +0000)]
[WebAssembly] Fixed stale assert message in WebAssemblyMCInstLower
llvm-svn: 341423
Steven Wu [Tue, 4 Sep 2018 22:54:17 +0000 (22:54 +0000)]
[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
Richard Trieu [Tue, 4 Sep 2018 22:53:19 +0000 (22:53 +0000)]
[ODRHash] Extend hash to support all Type's.
llvm-svn: 341421
Kostya Serebryany [Tue, 4 Sep 2018 22:43:30 +0000 (22:43 +0000)]
[sanitizer] optimize internal_memset for the most performance critical case (16-byte-aligned)
llvm-svn: 341420
Jordan Rupprecht [Tue, 4 Sep 2018 22:28:49 +0000 (22:28 +0000)]
[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
Tim Shen [Tue, 4 Sep 2018 22:20:11 +0000 (22:20 +0000)]
Revert r341373, since it fails on some targets.
Differential Revision: https://reviews.llvm.org/D51354
llvm-svn: 341418
Zhaoshi Zheng [Tue, 4 Sep 2018 22:17:03 +0000 (22:17 +0000)]
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
Anna Thomas [Tue, 4 Sep 2018 22:12:23 +0000 (22:12 +0000)]
[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
Sanjay Patel [Tue, 4 Sep 2018 22:10:23 +0000 (22:10 +0000)]
[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
Thomas Lively [Tue, 4 Sep 2018 21:51:32 +0000 (21:51 +0000)]
[WebAssembly][NFC] Add colon to label in test
llvm-svn: 341414
Scott Linder [Tue, 4 Sep 2018 21:50:47 +0000 (21:50 +0000)]
[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
Hiroshi Yamauchi [Tue, 4 Sep 2018 21:28:22 +0000 (21:28 +0000)]
Fix a memory leak after rL341386.
Reviewers: davidxl
Reviewed By: davidxl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D51658
llvm-svn: 341412
Thomas Lively [Tue, 4 Sep 2018 21:26:17 +0000 (21:26 +0000)]
[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
Sanjay Patel [Tue, 4 Sep 2018 21:17:14 +0000 (21:17 +0000)]
[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
Krzysztof Parzyszek [Tue, 4 Sep 2018 21:07:27 +0000 (21:07 +0000)]
[Hexagon] Don't packetize new-value stores with any other stores
llvm-svn: 341409
Sterling Augustine [Tue, 4 Sep 2018 21:06:59 +0000 (21:06 +0000)]
When a relocation to an undefined symbol is an R_X86_64_PC32, an input
section will not have an input file. Don't crash under those circumstances.
Neither clang nor llvm-mc generates R_X86_64_PC32 relocations due to
https://reviews.llvm.org/D43383, which makes it hard to write a test case.
However, gcc does generate such relocations. I want to get a fix in now,
but will figure out a way to actually exercise this code path as soon
as I can.
llvm-svn: 341408
Jessica Paquette [Tue, 4 Sep 2018 21:03:43 +0000 (21:03 +0000)]
[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
JF Bastien [Tue, 4 Sep 2018 21:02:00 +0000 (21:02 +0000)]
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
Sanjay Patel [Tue, 4 Sep 2018 21:00:13 +0000 (21:00 +0000)]
[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
Charles Davis [Tue, 4 Sep 2018 20:57:50 +0000 (20:57 +0000)]
[CMake] Don't use -rtlib=compiler-rt with -nodefaultlibs.
Summary:
This switch only has an effect at link time. It changes the default
compiler support library to `compiler-rt`. With `-nodefaultlibs`, this
library won't get linked anyway; Clang actually warns about that.
Reviewers: mstorsjo, rnk
Subscribers: dberris, mgorny, christof, cfe-commits
Differential Revision: https://reviews.llvm.org/D51645
llvm-svn: 341404
Martin Storsjo [Tue, 4 Sep 2018 20:56:56 +0000 (20:56 +0000)]
[COFF] Allow exporting all symbols from system libraries specfied with -wholearchive:
When building a shared libc++.dll, it pulls in libc++abi.a statically
with the --wholearchive flag. If such a build is done with
--export-all-symbols, it's reasonable to assume that everything
from that library also should be exported with the same rules as normal
local object files, even though we normally avoid autoexporting things
from libc++abi.a in other cases when linking a DLL (user code).
Differential Revision: https://reviews.llvm.org/D51529
llvm-svn: 341403
Martin Storsjo [Tue, 4 Sep 2018 20:56:28 +0000 (20:56 +0000)]
[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
Martin Storsjo [Tue, 4 Sep 2018 20:56:21 +0000 (20:56 +0000)]
[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
Reid Kleckner [Tue, 4 Sep 2018 20:34:47 +0000 (20:34 +0000)]
Fix unused variable warning
llvm-svn: 341400
Sergey Dmitriev [Tue, 4 Sep 2018 20:23:09 +0000 (20:23 +0000)]
[libomptarget] Remove `Devices` from `RTLInfoTy`
This patch removes unused field `Devices` from `RTLInfoTy`.
Differential Revision: https://reviews.llvm.org/D51653
llvm-svn: 341399
Fedor Sergeev [Tue, 4 Sep 2018 20:19:41 +0000 (20:19 +0000)]
[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
Jordan Rupprecht [Tue, 4 Sep 2018 20:19:17 +0000 (20:19 +0000)]
[Codegen] Fix test added in rL341380: AArch64SelectionDAGTest needs to link against Analysis lib.
llvm-svn: 341397
David Bolvansky [Tue, 4 Sep 2018 19:23:05 +0000 (19:23 +0000)]
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
Petr Hosek [Tue, 4 Sep 2018 19:10:37 +0000 (19:10 +0000)]
[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
Sanjay Patel [Tue, 4 Sep 2018 19:06:46 +0000 (19:06 +0000)]
[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
Matt Arsenault [Tue, 4 Sep 2018 18:58:19 +0000 (18:58 +0000)]
AMDGPU: Fix DAG divergence not reporting flat loads
Match behavior in DAG of r340343
llvm-svn: 341393
Matt Arsenault [Tue, 4 Sep 2018 18:47:43 +0000 (18:47 +0000)]
DAG: Factor out helper function for odd vector sizes
llvm-svn: 341392
Hiroshi Yamauchi [Tue, 4 Sep 2018 18:10:54 +0000 (18:10 +0000)]
Fix build failures after rL341386.
Reviewers: davidxl
Reviewed By: davidxl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D51647
llvm-svn: 341391
Nico Weber [Tue, 4 Sep 2018 18:00:14 +0000 (18:00 +0000)]
clang-cl: Pass /Brepro to linker if it was passed to the compiler
Differential Revision: https://reviews.llvm.org/D51635
llvm-svn: 341390
Dan Gohman [Tue, 4 Sep 2018 17:46:12 +0000 (17:46 +0000)]
[WebAssembly] Fix operand rewriting in inline asm lowering.
Use MachineOperand::ChangeToImmediate rather than reassigning
MachineOperands to new values created from MachineOperand::CreateImm,
so that their parent pointers are preserved.
This fixes "Instruction has operand with wrong parent set" errors
reported by the MachineVerifier.
llvm-svn: 341389
Charles Davis [Tue, 4 Sep 2018 17:40:26 +0000 (17:40 +0000)]
[CMake] Remove variable reference that isn't used.
Summary:
This variable is never defined, so its value is always empty. Since
`libunwind` is needed to build the C++ ABI library in the first place,
it should never be linked to the C++ ABI library anyway.
Reviewers: mstorsjo, rnk
Subscribers: mgorny, christof, cfe-commits
Differential Revision: https://reviews.llvm.org/D51644
llvm-svn: 341388
David Bolvansky [Tue, 4 Sep 2018 17:19:15 +0000 (17:19 +0000)]
Terminate debugger if an assert was hit
Reviewers: JDevlieghere, teemperor, #lldb
Reviewed By: JDevlieghere
Subscribers: clayborg, lemo, lldb-commits
Differential Revision: https://reviews.llvm.org/D51604
llvm-svn: 341387
Hiroshi Yamauchi [Tue, 4 Sep 2018 17:19:13 +0000 (17:19 +0000)]
[PGO] Control Height Reduction
Summary:
Control height reduction merges conditional blocks of code and reduces the
number of conditional branches in the hot path based on profiles.
if (hot_cond1) { // Likely true.
do_stg_hot1();
}
if (hot_cond2) { // Likely true.
do_stg_hot2();
}
->
if (hot_cond1 && hot_cond2) { // Hot path.
do_stg_hot1();
do_stg_hot2();
} else { // Cold path.
if (hot_cond1) {
do_stg_hot1();
}
if (hot_cond2) {
do_stg_hot2();
}
}
This speeds up some internal benchmarks up to ~30%.
Reviewers: davidxl
Reviewed By: davidxl
Subscribers: xbolva00, dmgreen, mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D50591
llvm-svn: 341386
Matt Morehouse [Tue, 4 Sep 2018 17:08:47 +0000 (17:08 +0000)]
[libFuzzer] Enable tests on Windows
Summary:
Enable tests on Windows and make check-fuzzer pass on it. Make
check-fuzzer pass on Windows by fixing libFuzzer, fixing tests, and by
disabling tests on Windows. Most of these are disabled temporarily as
support for the tests and the features they test will be added
incrementally. Other tests will not be enabled since they require
things that are not on Windows (eg: afl_driver tests). Every test
that was explicitly disabled on Windows has a comment explaining why
(unless obvious like merge-posix.test).
The lit.cfg file was modified to support running tests on windows.
fuzzer-dirs.test was fixed by making the Windows implementation print
the same error message as the posix version.
merge-control-file.test was fixed by making the test binary end with
the ".exe" extension (on all platforms).
Patch By: metzman
Reviewers: morehouse
Reviewed By: morehouse
Subscribers: srhines, mgorny
Differential Revision: https://reviews.llvm.org/D51549
llvm-svn: 341385
Matt Morehouse [Tue, 4 Sep 2018 17:04:30 +0000 (17:04 +0000)]
[TSan] Update assembly test again.
Previous commit incorrectly updated the read1 case.
llvm-svn: 341384
Matt Morehouse [Tue, 4 Sep 2018 16:34:26 +0000 (16:34 +0000)]
[TSan] Update assembly code check.
The new assembly makes our benchmark faster, so it should be safe to
update the check.
llvm-svn: 341381
Scott Linder [Tue, 4 Sep 2018 16:33:34 +0000 (16:33 +0000)]
[CodeGen] Fix remaining zext() assertions in SelectionDAG
Fix remaining cases not committed in https://reviews.llvm.org/D49574
Differential Revision: https://reviews.llvm.org/D50659
llvm-svn: 341380
Francis Visoiu Mistrih [Tue, 4 Sep 2018 16:31:53 +0000 (16:31 +0000)]
[MachO] Fix inconsistency between error messages when validating LC_DYSYMTAB
llvm-svn: 341379
Francis Visoiu Mistrih [Tue, 4 Sep 2018 16:31:48 +0000 (16:31 +0000)]
[MachO] Fix LC_DYSYMTAB validation for external symbols
We were validating the same index (ilocalsym) twice, while iextdefsym
was never validated.
llvm-svn: 341378
Jonas Devlieghere [Tue, 4 Sep 2018 16:21:37 +0000 (16:21 +0000)]
[dwarfdump] Improve -diff option by hiding more data.
The -diff option makes it easy to diff dwarf by hiding addresses and
offsets. However not all of them were hidden, which should be fixed by
this patch.
Differential revision: https://reviews.llvm.org/D51593
llvm-svn: 341377
Sam McCall [Tue, 4 Sep 2018 16:19:40 +0000 (16:19 +0000)]
[clangd] Load static index asynchronously, add tracing.
Summary:
Like D51475 but simplified based on recent patches.
While here, clarify that loadIndex() takes a filename, not file content.
Reviewers: ioeric
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Differential Revision: https://reviews.llvm.org/D51638
llvm-svn: 341376
Sam McCall [Tue, 4 Sep 2018 16:16:50 +0000 (16:16 +0000)]
[clangd] Define a compact binary serialization fomat for symbol slab/index.
Summary:
This is intended to replace the current YAML format for general use.
It's ~10x more compact than YAML, and ~40% more compact than gzipped YAML:
llvmidx.riff = 20M, llvmidx.yaml = 272M, llvmidx.yaml.gz = 32M
It's also simpler/faster to read and write.
The format is a RIFF container (chunks of (type, size, data)) with:
- a compressed string table
- simple binary encoding of symbols (with varints for compactness)
It can be extended to include occurrences, Dex posting lists, etc.
There's no rich backwards-compatibility scheme, but a version number is included
so we can detect incompatible files and do ad-hoc back-compat.
Alternatives considered:
- compressed YAML or JSON: bulky and slow to load
- llvm bitstream: confusing model and libraries are hard to use. My attempt
produced slightly larger files, and the code was longer and slower.
- protobuf or similar: would be really nice (esp for back-compat) but the
dependency is a big hassle
- ad-hoc binary format without a container: it seems clear we're going
to add posting lists and occurrences here, and that they will benefit
from sharing a string table. The container makes it easy to debug
these pieces in isolation, and make them optional.
Reviewers: ioeric
Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits
Differential Revision: https://reviews.llvm.org/D51585
llvm-svn: 341375
Kirill Bobyrev [Tue, 4 Sep 2018 15:45:56 +0000 (15:45 +0000)]
[clangd] NFC: Change quality type to float
Reviewed by: sammccall
Differential Revision: https://reviews.llvm.org/D51636
llvm-svn: 341374
Christian Bruel [Tue, 4 Sep 2018 15:22:13 +0000 (15:22 +0000)]
Fix the -print-multi-directory flag to print the selected multilib.
Summary: Fix -print-multi-directory to print the selected multilib
Reviewers: jroelofs
Reviewed By: jroelofs
Subscribers: srhines, cfe-commits
Differential Revision: https://reviews.llvm.org/D51354
llvm-svn: 341373
Jonas Hahnfeld [Tue, 4 Sep 2018 15:13:28 +0000 (15:13 +0000)]
[libomptarget][CUDA] Use cuDeviceGetAttribute, NFCI.
cuDeviceGetProperties has apparently been deprecated since CUDA 5.0.
Nvidia started using annotations only in CUDA 9.2, so nobody noticed
nor cared before.
The new function returns the same values, tested with a P100.
Differential Revision: https://reviews.llvm.org/D51624
llvm-svn: 341372
Jonas Hahnfeld [Tue, 4 Sep 2018 15:13:23 +0000 (15:13 +0000)]
[libomptarget] PR38704: Fix erase of ShadowPtrMap
erase() invalidates the iterator and returns a new one pointing
to the following element. The code now follows the example at
https://en.cppreference.com/w/cpp/container/map/erase.
(The added testcase crashes without this patch.)
Reported by David Binderman (https://llvm.org/PR38704)!
Differential Revision: https://reviews.llvm.org/D51623
llvm-svn: 341371
Jonas Hahnfeld [Tue, 4 Sep 2018 15:13:17 +0000 (15:13 +0000)]
[libomptarget][NVPTX] Drop dead code and data structures, NFCI.
* cg and HasCancel in WorkDescr were never read and can be removed.
* This eliminates the last use of priv in ThreadPrivateContext.
* CounterGroup is unused afterwards.
* Remove duplicate external declares in omptarget-nvptx.cu that are
already in the header omptarget-nvptx.h.
Differential Revision: https://reviews.llvm.org/D51622
llvm-svn: 341370
Kirill Bobyrev [Tue, 4 Sep 2018 15:10:40 +0000 (15:10 +0000)]
[clangd] Move buildStaticIndex() to SymbolYAML
`buildStaticIndex()` is used by two other tools that I'm building, now
it's useful outside of `tool/ClangdMain.cpp`.
Also, slightly refactor the code while moving it to the different source
file.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D51626
llvm-svn: 341369
Sam McCall [Tue, 4 Sep 2018 14:39:56 +0000 (14:39 +0000)]
[clangd] SymbolOccurrences -> Refs and cleanup
Summary:
A few things that I noticed while merging the SwapIndex patch:
- SymbolOccurrences and particularly SymbolOccurrenceSlab are unwieldy names,
and these names appear *a lot*. Ref, RefSlab, etc seem clear enough
and read/format much better.
- The asymmetry between SymbolSlab and RefSlab (build() vs freeze()) is
confusing and irritating, and doesn't even save much code.
Avoiding RefSlab::Builder was my idea, but it was a bad one; add it.
- DenseMap<SymbolID, ArrayRef<Ref>> seems like a reasonable compromise for
constructing MemIndex - and means many less wasted allocations than the
current DenseMap<SymbolID, vector<Ref*>> for FileIndex, and none for
slabs.
- RefSlab::find() is not actually used for anything, so we can throw
away the DenseMap and keep the representation much more compact.
- A few naming/consistency fixes: e.g. Slabs,Refs -> Symbols,Refs.
Reviewers: ioeric
Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits
Differential Revision: https://reviews.llvm.org/D51605
llvm-svn: 341368
Ilya Biryukov [Tue, 4 Sep 2018 14:15:53 +0000 (14:15 +0000)]
Adding HardLink Support to VirtualFileSystem.
Summary:
Added support of creating a hardlink from one file to another file.
After a hardlink is added between two files, both file will have the same:
1. UniqueID (inode)
2. Size
3. Buffer
This will bring replay of compilation closer to the actual compilation. There are instances where clang checks for the UniqueID of the file/header to be loaded which leads to a different behavior during replay as all files have different UniqueIDs.
Patch by Utkarsh Saxena!
Reviewers: ilya-biryukov
Reviewed By: ilya-biryukov
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D51359
llvm-svn: 341366
Chandler Carruth [Tue, 4 Sep 2018 13:36:44 +0000 (13:36 +0000)]
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.
llvm-svn: 341365
Sven van Haastregt [Tue, 4 Sep 2018 12:46:21 +0000 (12:46 +0000)]
Fix some Wundef warnings in Compiler.h
Check for definedness of the __cpp_sized_deallocation and
__cpp_aligned_new feature test macros. These will not be defined
when the feature is not available, and that prevents any code that
includes this header from compiling with -Wundef -Werror.
Differential Revision: https://reviews.llvm.org/D51171
llvm-svn: 341364
Chandler Carruth [Tue, 4 Sep 2018 12:38:00 +0000 (12:38 +0000)]
[x86/SLH] Add a real Clang flag and LLVM IR attribute for Speculative
Load Hardening.
Wires up the existing pass to work with a proper IR attribute rather
than just a hidden/internal flag. The internal flag continues to work
for now, but I'll likely remove it soon.
Most of the churn here is adding the IR attribute. I talked about this
Kristof Beyls and he seemed at least initially OK with this direction.
The idea of using a full attribute here is that we *do* expect at least
some forms of this for other architectures. There isn't anything
*inherently* x86-specific about this technique, just that we only have
an implementation for x86 at the moment.
While we could potentially expose this as a Clang-level attribute as
well, that seems like a good question to defer for the moment as it
isn't 100% clear whether that or some other programmer interface (or
both?) would be best. We'll defer the programmer interface side of this
for now, but at least get to the point where the feature can be enabled
without relying on implementation details.
This also allows us to do something that was really hard before: we can
enable *just* the indirect call retpolines when using SLH. For x86, we
don't have any other way to mitigate indirect calls. Other architectures
may take a different approach of course, and none of this is surfaced to
user-level flags.
Differential Revision: https://reviews.llvm.org/D51157
llvm-svn: 341363
Simon Pilgrim [Tue, 4 Sep 2018 12:17:10 +0000 (12:17 +0000)]
Remove lambda default parameter to silence -Wpedantic warning. NFCI.
llvm-svn: 341362
Aaron Ballman [Tue, 4 Sep 2018 12:03:49 +0000 (12:03 +0000)]
Disable -Wnoexcept-type due to false positives with GCC.
GCC triggers false positives if a nothrow function is called through a template argument. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80985 for details. The LLVM libraries have no stable C++ API, so the warning is not useful.
llvm-svn: 341361
Chandler Carruth [Tue, 4 Sep 2018 11:55:57 +0000 (11:55 +0000)]
Revert r341342: Dwarf .debug section compression support (zlib, zlib-gnu).
Also reverts follow-up commits r341343 and r341344.
The primary commit continues to break some build bots even after the
fixes in r341343 for UBSan issues:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/5823
It is also failing for me locally (linux, x86-64).
llvm-svn: 341360
Chandler Carruth [Tue, 4 Sep 2018 10:59:10 +0000 (10:59 +0000)]
[x86/SLH] Teach SLH to harden against the "ret2spec" attack by
implementing the proposed mitigation technique described in the original
design document.
The idea is to check after calls that the return address used to arrive
at that location is in fact the correct address. In the event of
a mis-predicted return which reaches a *valid* return but not the
*correct* return, this will detect the mismatch much like it would
a mispredicted conditional branch.
This is the last published attack vector that I am aware of in the
Spectre v1 space which is not mitigated by SLH+retpolines. However,
don't read *too* much into that: this is an area of ongoing research
where we expect more issues to be discovered in the future, and it also
makes no attempt to mitigate Spectre v4. Still, this is an important
completeness bar for SLH.
The change here is of course delightfully simple. It was predicated on
cutting support for post-instruction symbols into LLVM which was not at
all simple. Many thanks to Hal Finkel, Reid Kleckner, and Justin Bogner
who helped me figure out how to do a bunch of the complex changes
involved there.
Differential Revision: https://reviews.llvm.org/D50837
llvm-svn: 341358
Kristina Brooks [Tue, 4 Sep 2018 10:54:09 +0000 (10:54 +0000)]
Do not leak the Mach host port in sys::getHostCPUName()
Patch by rsesek (Robert Sesek)
llvm-svn: 341357
Chandler Carruth [Tue, 4 Sep 2018 10:44:21 +0000 (10:44 +0000)]
[x86/SLH] Teach SLH to harden indirect branches and switches without
retpolines.
This implements the core design of tracing the intended target into the
target, checking it, and using that to update the predicate state. It
takes advantage of a few interesting aspects of SLH to make it a bit
easier to implement:
- We already split critical edges with conditional branches, so we can
assume those are gone.
- We already unfolded any memory access in the indirect branch
instruction itself.
I've left hard errors in place to catch if any of these somewhat subtle
invariants get violated.
There is some code that I can factor out and share with D50837 when it
lands, but I didn't want to couple landing the two patches, so I'll do
that in a follow-up cleanup commit if alright.
Factoring out the code to handle different scenarios of materializing an
address remains frustratingly hard. In a bunch of cases you want to fold
one of the cases into an immediate operand of some other instruction,
and you also have both symbols and basic blocks being used which require
different methods on the MI builder (and different operand kinds).
Still, I'll take a stab at sharing at least some of this code in
a follow-up if I can figure out how.
Differential Revision: https://reviews.llvm.org/D51083
llvm-svn: 341356
Nicola Zaghen [Tue, 4 Sep 2018 10:29:48 +0000 (10:29 +0000)]
[InstCombine] Fold icmp ugt/ult (add nuw X, C2), C --> icmp ugt/ult X, (C - C2)
Support for sgt/slt was added in rL294898, this adds the same cases also for unsigned compares.
This is the Alive proof: https://rise4fun.com/Alive/nyY
Differential Revision: https://reviews.llvm.org/D50972
llvm-svn: 341353
David Chisnall [Tue, 4 Sep 2018 10:07:27 +0000 (10:07 +0000)]
Revert "Disable the GNUstep v2 ABI on Windows."
This reverts commit
b4547c9cadd2f8adfe3f3182e4c56e466c5256cb.
Apparently git llvm push from the monorepo does not respect branches and
pushes the current branch to master.
llvm-svn: 341352
David Chisnall [Tue, 4 Sep 2018 09:23:18 +0000 (09:23 +0000)]
Disable the GNUstep v2 ABI on Windows.
The code remains so that we can potentially reenable it in a point
release, but the driver will reject it. Several issues were raised
during testing that made it clear that this was not quite ready for
general consumption.
Approved by: Hans Wennborg
llvm-svn: 341350
Fedor Sergeev [Tue, 4 Sep 2018 08:21:37 +0000 (08:21 +0000)]
[NFC] correcting patterns in time-passes test to fix buildbot
llvm-svn: 341348
Max Kazantsev [Tue, 4 Sep 2018 06:34:40 +0000 (06:34 +0000)]
[NFC] Add assert to detect LCSSA breaches early
llvm-svn: 341347
Fedor Sergeev [Tue, 4 Sep 2018 06:12:28 +0000 (06:12 +0000)]
[PassTiming] reporting time-passes separately for multiple pass instances of the same pass
Summary:
Refactoring done by rL340872 accidentally appeared to be non-NFC, changing the way how
multiple instances of the same pass are handled - aggregation of results by PassName
forced data for multiple instances to be merged together and reported as one line.
Getting back to creating/reporting timers per pass instance.
Reporting was a bit enhanced by counting pass instances and adding #<num> suffix
to the pass description. Note that it is instances that are being counted,
not invocations of them.
time-passes test updated to account for multiple passes being run.
Reviewers: paquette, jhenderson, MatzeB, skatkov
Reviewed By: skatkov
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D51535
llvm-svn: 341346
Max Kazantsev [Tue, 4 Sep 2018 05:01:35 +0000 (05:01 +0000)]
[IndVars] Fix usage of SCEVExpander to not mess with SCEVConstant. PR38674
This patch removes the function `expandSCEVIfNeeded` which behaves not as
it was intended. This function tries to make a lookup for exact existing expansion
and only goes to normal expansion via `expandCodeFor` if this lookup hasn't found
anything. As a result of this, if some instruction above the loop has a `SCEVConstant`
SCEV, this logic will return this instruction when asked for this `SCEVConstant` rather
than return a constant value. This is both non-profitable and in some cases leads to
breach of LCSSA form (as in PR38674).
Whether or not it is possible to break LCSSA with this algorithm and with some
non-constant SCEVs is still in question, this is still being investigated. I wasn't
able to construct such a test so far, so maybe this situation is impossible. If it is,
it will go as a separate fix.
Rather than do it, it is always correct to just invoke `expandCodeFor` unconditionally:
it behaves smarter about insertion points, and as side effect of this it will choose a
constant value for SCEVConstants. For other SCEVs it may end up finding a better insertion
point. So it should not be worse in any case.
NOTE: So far the only known case for which this transform may break LCSSA is mapping
of SCEVConstant to an instruction. However there is a suspicion that the entire algorithm
can compromise LCSSA form for other cases as well (yet not proved).
Differential Revision: https://reviews.llvm.org/D51286
Reviewed By: etherzhhb
llvm-svn: 341345
Puyan Lotfi [Tue, 4 Sep 2018 01:58:32 +0000 (01:58 +0000)]
[NFC][llvm-objcopy] clang-formating Object.cpp
llvm-svn: 341344
Puyan Lotfi [Tue, 4 Sep 2018 01:57:30 +0000 (01:57 +0000)]
[NFC][llvm-objcopy] Fixing a ubi-san problem with unaligned memory writes.
llvm-svn: 341343
Puyan Lotfi [Mon, 3 Sep 2018 22:25:56 +0000 (22:25 +0000)]
[llvm-objcopy] Dwarf .debug section compression support (zlib, zlib-gnu).
Usage:
llvm-objcopy --compress-debug-sections=zlib foo.o
llvm-objcopy --compress-debug-sections=zlib-gnu foo.o
In both cases the debug section contents is compressed with zlib. In the GNU
style case the header is the "ZLIB" magic string followed by the uint64 big-
endian decompressed size. In the non-GNU mode the header is the
Elf(32|64)_Chdr.
Decompression support is coming soon.
Differential Revision: https://reviews.llvm.org/D49678
llvm-svn: 341342
Sanjay Patel [Mon, 3 Sep 2018 22:11:47 +0000 (22:11 +0000)]
[AArch64][x86] add tests for pow(x, 0.25); NFC
Folds for this were proposed in D49306, but we
decided the transform is better suited for the backend.
llvm-svn: 341341
David Bolvansky [Mon, 3 Sep 2018 22:09:08 +0000 (22:09 +0000)]
[NFC] Fixed enum constant in boolean context error
Summary:
/home/xbolva00/LLVM/llvm/tools/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:656:59: warning: enum constant in boolean context [-Wint-in-bool-context]
if (mh.magic == llvm::MachO::MH_CIGAM || llvm::MachO::MH_MAGIC)
^~~~~~~~
/home/xbolva00/LLVM/llvm/tools/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:658:62: warning: enum constant in boolean context [-Wint-in-bool-context]
if (mh.magic == llvm::MachO::MH_CIGAM_64 || llvm::MachO::MH_MAGIC_64)
Reviewers: JDevlieghere, teemperor
Reviewed By: teemperor
Subscribers: abidh, lldb-commits
Differential Revision: https://reviews.llvm.org/D51600
llvm-svn: 341340
David Bolvansky [Mon, 3 Sep 2018 22:08:30 +0000 (22:08 +0000)]
[NFC] Use llvm_unreachable instead of lldb::assert
Summary: Fixes implicit fall through warnings
Reviewers: JDevlieghere, teemperor
Reviewed By: teemperor
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D51601
llvm-svn: 341339
Simon Atanasyan [Mon, 3 Sep 2018 20:48:55 +0000 (20:48 +0000)]
[mips] Disable the selection of mixed microMIPS/MIPS code
This patch modifies hasStandardEncoding() / inMicroMipsMode() /
inMips16Mode() methods of the MipsSubtarget class so only one can be
true at any one time. That prevents the selection of microMIPS and MIPS
instructions and patterns that are defined in TableGen files at the same
time. A few new patterns and instruction definitions hae been added to
keep test cases passed.
Differential revision: https://reviews.llvm.org/D51483
llvm-svn: 341338
Sam McCall [Mon, 3 Sep 2018 20:26:26 +0000 (20:26 +0000)]
[clangd] Fix index-twice regression from r341242
llvm-svn: 341337
Sanjay Patel [Mon, 3 Sep 2018 18:40:56 +0000 (18:40 +0000)]
[InstCombine] simplify xor/not folds; NFCI
llvm-svn: 341336
Sanjay Patel [Mon, 3 Sep 2018 18:21:59 +0000 (18:21 +0000)]
[InstCombine] allow add+not --> sub for arbitrary vector constants.
llvm-svn: 341335
David Bolvansky [Mon, 3 Sep 2018 18:21:21 +0000 (18:21 +0000)]
[ClangUserExpression][NFC] Removed unused code
llvm-svn: 341334
Brian Gesiak [Mon, 3 Sep 2018 18:13:46 +0000 (18:13 +0000)]
Revert r341329 due to MSAN error
Pushing https://reviews.llvm.org/rL341329 revealed an MSAN error. Revert it
so that we can fix the error.
llvm-svn: 341333
Sanjay Patel [Mon, 3 Sep 2018 18:04:21 +0000 (18:04 +0000)]
[InstCombine] consolidate tests for ~(X+C); NFC
llvm-svn: 341332
Sid Manning [Mon, 3 Sep 2018 17:59:10 +0000 (17:59 +0000)]
Revert [Hexagon] Add support for getRegisterByName.
Support required to build the Hexagon Linux kernel.
llvm-svn: 341331
Florian Hahn [Mon, 3 Sep 2018 17:37:39 +0000 (17:37 +0000)]
[SLC] Support expanding pow(x, n+0.5) to x * x * ... * sqrt(x)
Reviewers: evandro, efriedma, spatel
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D51435
llvm-svn: 341330
Brian Gesiak [Mon, 3 Sep 2018 17:30:57 +0000 (17:30 +0000)]
Re-push "[Option] Fix PR37006 prefix choice in findNearest"
Summary:
Original changeset (https://reviews.llvm.org/D46776) by @modocache. It was
reverted after the PS4 bot failed.
The issue has been determined to be with the way the PS4 SDK handles this
particular option. https://reviews.llvm.org/D50410 removes this test, so we
can push this again.
Patch by Arnaud Coomans!
Reviewers: cfe-commits, modocache
Reviewed By: modocache
Differential Revision: https://reviews.llvm.org/D50515
llvm-svn: 341329
Jonas Hahnfeld [Mon, 3 Sep 2018 17:24:23 +0000 (17:24 +0000)]
[libomptarget][NVPTX] Fix __kmpc_spmd_kernel_deinit
If the runtime is uninitialized the master thread must Enqueue the
state object, and ALL threads must return immediately.
Found post-commit of https://reviews.llvm.org/D51222.
llvm-svn: 341328
Brian Gesiak [Mon, 3 Sep 2018 16:55:02 +0000 (16:55 +0000)]
Removing -debug-info-macros from option suggestions test
Summary:
https://reviews.llvm.org/D46776 added better support for prefixes for the
"did you mean ...?" command line option suggestions. One of the tests was
checking against the `-debug-info-macro` option, which was failing on the
PS4 build bot. Tests would succeed against the `--help` and `--version`
options.
From https://llvm.org/devmtg/2013-11/slides/Robinson-PS4Toolchain.pdf, it
looks like the PS4 SDK forces optimizations and *could be* disabling the
`-debug-info-macro` altogether.
This diff removes `-debug-info-macro` altogether.
Patch by Arnaud Coomans!
Test Plan: untested since we do not have access to a PS4 with the SDK.
Reviewers: cfe-commits, modocache
Reviewed By: modocache
Differential Revision: https://reviews.llvm.org/D50410
llvm-svn: 341327
Andrea Di Biagio [Mon, 3 Sep 2018 16:47:34 +0000 (16:47 +0000)]
[X86] Remove wrong ReadAdvance from multiclass sse_fp_unop_s.
A ReadAdvance was incorrectly added to the SchedReadWrite list associated with
the following SSE instructions:
sqrtss
sqrtsd
rsqrtss
rcpss
As a consequence, a wrong operand latency was computed for the register operand
used as the base address of the folded load operand.
This patch removes the wrong ReadAdvance, and updates the llvm-mca test cases.
There is still a problem with correctly modeling partial register writes on XMM
registers This other problem is currently tracked here:
https://bugs.llvm.org/show_bug.cgi?id=38813
Differential Revision: https://reviews.llvm.org/D51542
llvm-svn: 341326
Sam McCall [Mon, 3 Sep 2018 16:37:59 +0000 (16:37 +0000)]
[clangd] Some nitpicking around the new split (preamble/main) dynamic index
Summary:
- DynamicIndex doesn't implement ParsingCallbacks, to make its role clearer.
ParsingCallbacks is a separate object owned by the receiving TUScheduler.
(I tried to get rid of the "index-like-object that doesn't implement index"
but it was too messy).
- Clarified(?) docs around DynamicIndex - fewer details up front, more details
inside.
- Exposed dynamic index from ClangdServer for memory monitoring and more
direct testing of its contents (actual tests not added here, wanted to get
this out for review)
- Removed a redundant and sligthly confusing filename param in a callback
Reviewers: ilya-biryukov
Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Differential Revision: https://reviews.llvm.org/D51221
llvm-svn: 341325
Argyrios Kyrtzidis [Mon, 3 Sep 2018 16:26:36 +0000 (16:26 +0000)]
Add header guards to some headers that are missing them
llvm-svn: 341324
Argyrios Kyrtzidis [Mon, 3 Sep 2018 16:22:05 +0000 (16:22 +0000)]
Add header guards to some headers that are missing them
Also adjust some of dsymutil's headers to put the header guards at the top,
otherwise the compiler will not recognize them as header guards.
llvm-svn: 341323
Ilya Biryukov [Mon, 3 Sep 2018 15:25:27 +0000 (15:25 +0000)]
[clangd] Avoid crashes in override completions
Summary: NamedDecl::getName cannot be called on non-identifier names.
Reviewers: kadircet, ioeric, hokein, sammccall
Reviewed By: ioeric
Subscribers: MaskRay, jkorous, arphaman, cfe-commits
Differential Revision: https://reviews.llvm.org/D51598
llvm-svn: 341322
Sam McCall [Mon, 3 Sep 2018 15:23:01 +0000 (15:23 +0000)]
[clangd] Fix ambiguous make_unique with c++17. NFC
llvm-svn: 341321