platform/upstream/llvm.git
5 years ago[Analyzer] Define and use diff_plist in tests, NFC
Mikhail Maltsev [Mon, 17 Sep 2018 10:19:46 +0000 (10:19 +0000)]
[Analyzer] Define and use diff_plist in tests, NFC

This patch defines a new substitution and uses it to reduce
duplication in the Clang Analyzer test cases.

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

llvm-svn: 342365

5 years ago[llvm-objcopy] Add missing alias for --strip-all-gnu
Alexander Shaposhnikov [Mon, 17 Sep 2018 09:45:12 +0000 (09:45 +0000)]
[llvm-objcopy] Add missing alias for --strip-all-gnu

This diff adds -S as an alias for --strip-all-gnu
(for compatibility with binutils' objcopy).

Patch by Dmitry Golovin!

Test plan: make check-all

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

llvm-svn: 342364

5 years ago[clang-Format] Fix indentation of member call after block
Ilya Biryukov [Mon, 17 Sep 2018 07:46:20 +0000 (07:46 +0000)]
[clang-Format] Fix indentation of member call after block

Summary:
before patch:
> echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google

```
test() {
  ([]() -> {
    int b = 32;
    return 3;
  })
      .as();
});
```

after patch:
> echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google

```
test() {
  ([]() -> {
    int b = 32;
    return 3;
  }).as();
});
```

Patch by Anders Karlsson (ank)!

Reviewers: klimek

Reviewed By: klimek

Subscribers: danilaml, acoomans, klimek, cfe-commits

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

llvm-svn: 342363

5 years ago[clangd] Get rid of AST matchers in SymbolCollector. NFC
Eric Liu [Mon, 17 Sep 2018 07:43:49 +0000 (07:43 +0000)]
[clangd] Get rid of AST matchers in SymbolCollector. NFC

Reviewers: ilya-biryukov, kadircet

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 342362

5 years agoFix typo
Fangrui Song [Mon, 17 Sep 2018 07:40:42 +0000 (07:40 +0000)]
Fix typo

llvm-svn: 342361

5 years ago[NFC] Turn unsigned counters into boolean flags
Max Kazantsev [Mon, 17 Sep 2018 06:33:29 +0000 (06:33 +0000)]
[NFC] Turn unsigned counters into boolean flags

llvm-svn: 342360

5 years agoscan-build: Add support of the option --exclude like in scan-build-py
Sylvestre Ledru [Mon, 17 Sep 2018 06:31:46 +0000 (06:31 +0000)]
scan-build: Add support of the option --exclude like in scan-build-py

Summary:
To exclude thirdparty code.

To test:
With /tmp/foo.c

```
void test() {
    int x;
    x = 1; // warn
}
```

```
$ scan-build --exclude non-existing/  --exclude /tmp/ -v gcc -c foo.c

scan-build: Using '/usr/lib/llvm-7/bin/clang' for static analysis
scan-build: Emitting reports for this run to '/tmp/scan-build-2018-09-16-214531-8410-1'.
foo.c:3:3: warning: Value stored to 'x' is never read
  x = 1; // warn
  ^   ~
1 warning generated.
scan-build: File '/tmp/foo.c' deleted: part of an ignored directory.
scan-build: 0 bugs found.
```

Reviewers: jroelofs

Reviewed By: jroelofs

Subscribers: whisperity, cfe-commits

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

llvm-svn: 342359

5 years ago[Lexer] Add xray_instrument feature
Petr Hosek [Mon, 17 Sep 2018 05:25:47 +0000 (05:25 +0000)]
[Lexer] Add xray_instrument feature

This can be used to detect whether the code is being built with XRay
instrumentation using the __has_feature(xray_instrument) predicate.

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

llvm-svn: 342358

5 years ago[sanitizer_common] Fuchsia now supports .preinit_array
Petr Hosek [Mon, 17 Sep 2018 05:22:26 +0000 (05:22 +0000)]
[sanitizer_common] Fuchsia now supports .preinit_array

Support for .preinit_array has been implemented in Fuchsia's libc,
add Fuchsia to the list of platforms that support this feature.

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

llvm-svn: 342357

5 years ago[XRay] Simplify FDR buffer management
Dean Michael Berris [Mon, 17 Sep 2018 03:09:01 +0000 (03:09 +0000)]
[XRay] Simplify FDR buffer management

Summary:
This change makes XRay FDR mode use a single backing store for the
buffer queue, and have indexes into that backing store instead. We also
remove the reliance on the internal allocator implementation in the FDR
mode logging implementation.

In the process of making this change we found an inconsistency with the
way we're returning buffers to the queue, and how we're setting the
extents. We take the chance to simplify the way we're managing the
extents of each buffer. It turns out we do not need the indirection for
the extents, so we co-host the atomic 64-bit int with the buffer object.
It also seems that we've not been returning the buffers for the thread
running the flush functionality when writing out the files, so we can
run into a situation where we could be missing data.

We consolidate all the allocation routines now into xray_allocator.h,
where we used to have routines defined in xray_buffer_queue.cc.

Reviewers: mboerger, eizan

Subscribers: jfb, llvm-commits

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

llvm-svn: 342356

5 years ago[XRay] Fix FDR initialization
Dean Michael Berris [Mon, 17 Sep 2018 02:49:17 +0000 (02:49 +0000)]
[XRay] Fix FDR initialization

Follow-up to D51606.

llvm-svn: 342355

5 years ago[DebugInfo] Fix build when std::vector::iterator is a pointer
Kristina Brooks [Sun, 16 Sep 2018 22:21:59 +0000 (22:21 +0000)]
[DebugInfo] Fix build when std::vector::iterator is a pointer

std::vector::iterator type may be a pointer, then
iterator::value_type fails to compile since iterator is not a class,
namespace, or enumeration.

Patch by orivej (Orivej Desh)

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

llvm-svn: 342354

5 years ago[NFC] Minor refactoring to setup the stage for supporting pointers in ExprMutationAna...
Shuai Wang [Sun, 16 Sep 2018 21:09:50 +0000 (21:09 +0000)]
[NFC] Minor refactoring to setup the stage for supporting pointers in ExprMutationAnalyzer

llvm-svn: 342353

5 years ago[X86][SSE] Always enable ISD::SRL -> ISD::MULHU for v8i16
Simon Pilgrim [Sun, 16 Sep 2018 20:28:38 +0000 (20:28 +0000)]
[X86][SSE] Always enable ISD::SRL -> ISD::MULHU for v8i16

For constant non-uniform cases we'll never introduce more and/andn/or selects than already occur in generic pre-SSE41 ISD::SRL lowering.

llvm-svn: 342352

5 years agoscan-build: remove trailing whitespaces
Sylvestre Ledru [Sun, 16 Sep 2018 19:51:16 +0000 (19:51 +0000)]
scan-build: remove trailing whitespaces

llvm-svn: 342351

5 years agoAlso manages clang-X as tool for scan-build
Sylvestre Ledru [Sun, 16 Sep 2018 19:36:59 +0000 (19:36 +0000)]
Also manages clang-X as tool for scan-build

Summary:
This will make
scan-build-7 clang-7 -c foo.c &> /dev/null

Reviewers: jroelofs

Subscribers: kristina, cfe-commits

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

llvm-svn: 342350

5 years ago[X86][AVX] Enable ISD::SRL -> ISD::MULHU for v16i16
Simon Pilgrim [Sun, 16 Sep 2018 19:20:47 +0000 (19:20 +0000)]
[X86][AVX] Enable ISD::SRL -> ISD::MULHU for v16i16

Now that rL340913 has landed with improved v16i16 selects as shuffles.

llvm-svn: 342349

5 years ago[DAGCombiner] try to convert pow(x, 1/3) to cbrt(x)
Sanjay Patel [Sun, 16 Sep 2018 16:50:26 +0000 (16:50 +0000)]
[DAGCombiner] try to convert pow(x, 1/3) to cbrt(x)

This is a follow-up suggested in D51630 and originally proposed as an IR transform in D49040.

Copying the motivational statement by @evandro from that patch:
"This transformation helps some benchmarks in SPEC CPU2000 and CPU2006, such as 188.ammp,
447.dealII, 453.povray, and especially 300.twolf, as well as some proprietary benchmarks.
Otherwise, no regressions on x86-64 or A64."

I'm proposing to add only the minimum support for a DAG node here. Since we don't have an
LLVM IR intrinsic for cbrt, and there are no other DAG ways to create a FCBRT node yet, I
don't think we need to worry about DAG builder, legalization, a strict variant, etc. We
should be able to expand as needed when adding more functionality/transforms. For reference,
these are transform suggestions currently listed in SimplifyLibCalls.cpp:

//   * cbrt(expN(X))  -> expN(x/3)
//   * cbrt(sqrt(x))  -> pow(x,1/6)
//   * cbrt(cbrt(x))  -> pow(x,1/9)

Also, given that we bail out on long double for now, there should not be any logical
differences between platforms (unless there's some platform out there that has pow()
but not cbrt()).

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

llvm-svn: 342348

5 years ago[x86] fix uses check in broadcast transform (PR38949)
Sanjay Patel [Sun, 16 Sep 2018 15:41:56 +0000 (15:41 +0000)]
[x86] fix uses check in broadcast transform (PR38949)

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

It's not clear to me that we even need a one-use check in this fold.
Ie, 2 independent loads might be better than a load+dependent shuffle.

Note that the existing re-use tests are not affected. We actually do form a
broadcast node in those tests now because there's no extra use of the
insert_subvector node in those cases. But something later in isel pattern
matching decides that it is not worth using a broadcast for the full load in
those tests:

Legalized selection DAG: %bb.0 'test_broadcast_2f64_4f64_reuse:'
  t7: v2f64,ch = load<(load 16 from %ir.p0)> t0, t2, undef:i64
      t4: i64,ch = CopyFromReg t0, Register:i64 %1
    t10: ch = store<(store 16 into %ir.p1)> t7:1, t7, t4, undef:i64
      t18: v4f64 = insert_subvector undef:v4f64, t7, Constant:i64<0>
    t20: v4f64 = insert_subvector t18, t7, Constant:i64<2>

Becomes:
  t7: v2f64,ch = load<(load 16 from %ir.p0)> t0, t2, undef:i64
      t4: i64,ch = CopyFromReg t0, Register:i64 %1
    t10: ch = store<(store 16 into %ir.p1)> t7:1, t7, t4, undef:i64
    t21: v4f64 = X86ISD::SUBV_BROADCAST t7

ISEL: Starting selection on root node: t21: v4f64 = X86ISD::SUBV_BROADCAST t7
...
  Created node: t27: v4f64 = INSERT_SUBREG IMPLICIT_DEF:v4f64, t7, TargetConstant:i32<7>
  Morphed node: t21: v4f64 = VINSERTF128rr t27, t7, TargetConstant:i8<1>

llvm-svn: 342347

5 years ago[x86] add failure to splat test (PR38949); NFC
Sanjay Patel [Sun, 16 Sep 2018 14:59:04 +0000 (14:59 +0000)]
[x86] add failure to splat test (PR38949); NFC

llvm-svn: 342346

5 years ago[NFC][InstCombine] One more test pattern for comparisons with low-bit-mask.
Roman Lebedev [Sun, 16 Sep 2018 12:51:09 +0000 (12:51 +0000)]
[NFC][InstCombine] One more test pattern for comparisons with low-bit-mask.

https://rise4fun.com/Alive/UGzE <- non-canonical, but has extra uses.

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

llvm-svn: 342345

5 years agoFix -Wdangling-else gcc warning. NFCI.
Simon Pilgrim [Sun, 16 Sep 2018 12:30:41 +0000 (12:30 +0000)]
Fix -Wdangling-else gcc warning. NFCI.

llvm-svn: 342344

5 years ago[NFC][InstCombine] Some more tests for comparisons with low-bit-mask.
Roman Lebedev [Sun, 16 Sep 2018 08:05:06 +0000 (08:05 +0000)]
[NFC][InstCombine] Some more tests for comparisons with low-bit-mask.

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

llvm-svn: 342343

5 years ago[ELF] Use llvm::toLower instead of libc call tolower
Fangrui Song [Sat, 15 Sep 2018 23:59:13 +0000 (23:59 +0000)]
[ELF] Use llvm::toLower instead of libc call tolower

tolower() has some overhead because current locale is considered (though in lld the default "C" locale is used which does not matter too much). llvm::toLower is more efficient as it compiles to a compare and a conditional jump, as opposed to a libc call if tolower is used.

Disregarding locale also matches gdb's behavior (gdb/minsyms.h):

    #define SYMBOL_HASH_NEXT(hash, c) \
      ((hash) * 67 + TOLOWER ((unsigned char) (c)) - 113)

where TOLOWER (include/safe-ctype.h) is a macro that uses a lookup table under the hood which is similar to llvm::toLower.

Reviewers: ruiu, espindola

Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 342342

5 years agoconfigure: Rework support for gfx9+ devices that were added post LLVM 3.9
Jan Vesely [Sat, 15 Sep 2018 22:02:01 +0000 (22:02 +0000)]
configure: Rework support for gfx9+ devices that were added post LLVM 3.9

v2: Fix reference to Vega12/20 enabling commit

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewer: Aaron Watry
llvm-svn: 342341

5 years ago[NFC] cosmetic tweaks to ExprMutationAnalyzer to be more consistent
Shuai Wang [Sat, 15 Sep 2018 21:38:18 +0000 (21:38 +0000)]
[NFC] cosmetic tweaks to ExprMutationAnalyzer to be more consistent
especially considering future changes.

llvm-svn: 342340

5 years ago[llvm-readobj] Make some commonly used short options visibile in -help
Fangrui Song [Sat, 15 Sep 2018 21:27:46 +0000 (21:27 +0000)]
[llvm-readobj] Make some commonly used short options visibile in -help

For people who use llvm-readelf as a replacement of GNU readelf, they would like to see -d -r ... listed in llvm-readelf -help. It also helps understanding the confusing -s (which is unfortunately different in semantics).

Reviewers: phosek, ruiu, echristo

Reviewed By: ruiu, echristo

Subscribers: llvm-commits

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

llvm-svn: 342339

5 years ago.travis: Add llvm-7 build
Jan Vesely [Sat, 15 Sep 2018 20:00:37 +0000 (20:00 +0000)]
.travis: Add llvm-7 build

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewer: Aaron Watry
llvm-svn: 342338

5 years ago.travis: Use source whitelist alias for llvm-6 repository
Jan Vesely [Sat, 15 Sep 2018 20:00:12 +0000 (20:00 +0000)]
.travis: Use source whitelist alias for llvm-6 repository

Fixes issue with unauthenticated packages.
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewer: Aaron Watry

llvm-svn: 342337

5 years agoRevert r342148 (and follow-on fix attempts r342154, r342180, r342182, r342193)
Nico Weber [Sat, 15 Sep 2018 19:04:27 +0000 (19:04 +0000)]
Revert r342148 (and follow-on fix attempts r342154, r342180, r342182, r342193)

Many bots buildling with make have been broken for several days, e.g.
http://lab.llvm.org:8011/builders/lld-x86_64-darwin13

llvm-svn: 342336

5 years ago[InstCombine] Support (sub (sext x), (sext y)) --> (sext (sub x, y)) and (sub (zext...
Craig Topper [Sat, 15 Sep 2018 18:54:10 +0000 (18:54 +0000)]
[InstCombine] Support (sub (sext x), (sext y)) --> (sext (sub x, y)) and (sub (zext x), (zext y)) --> (zext (sub x, y))

Summary:
If the sub doesn't overflow in the original type we can move it above the sext/zext.

This is similar to what we do for add. The overflow checking for sub is currently weaker than add, so the test cases are constructed for what is supported.

Reviewers: spatel

Reviewed By: spatel

Subscribers: llvm-commits

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

llvm-svn: 342335

5 years agolld-link: Set PDB GUID to hash of PDB contents instead of to a random byte sequence.
Nico Weber [Sat, 15 Sep 2018 18:37:22 +0000 (18:37 +0000)]
lld-link: Set PDB GUID to hash of PDB contents instead of to a random byte sequence.

Previously, lld-link would use a random byte sequence as the PDB GUID. Instead,
use a hash of the PDB file contents.

To not disturb llvm-pdbutil pdb2yaml, the hash generation is an opt-in feature
on InfoStreamBuilder and ldb/COFF/PDB.cpp always sets it.

Since writing the PDB computes this ID which also goes in the exe, the PDB
writing code now must be called before writeBuildId(). writeBuildId() for that
reason is no longer included in the "Code Layout" timer.

Since the PDB GUID is now a function of the PDB contents, the PDB Age is always
set to 1. There was a long comment above loadExistingBuildId (now gone) about
how not changing the GUID and only incrementing the age was important, but
according to the discussion in PR35914 that comment was incorrect.

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

llvm-svn: 342334

5 years agoGive InfoStreamBuilder an opt-in method to write a hash of the PDB as GUID.
Nico Weber [Sat, 15 Sep 2018 18:35:51 +0000 (18:35 +0000)]
Give InfoStreamBuilder an opt-in method to write a hash of the PDB as GUID.

Naively computing the hash after the PDB data has been generated is in practice
as fast as other approaches I tried. I also tried online-computing the hash as
parts of the PDB were written out (https://reviews.llvm.org/D51887; that's also
where all the measuring data is) and computing the hash in parallel
(https://reviews.llvm.org/D51957). This approach here is simplest, without
being slower.

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

llvm-svn: 342333

5 years agolld-link: print demangled symbol names for "undefined symbol" diagnostics
Nico Weber [Sat, 15 Sep 2018 18:27:09 +0000 (18:27 +0000)]
lld-link: print demangled symbol names for "undefined symbol" diagnostics

For this, add a few toString() calls when printing the "undefined symbol"
diagnostics; toString() already does demangling on Windows hosts.

Also make lld::demangleMSVC() (called by toString(Symbol*)) call LLVM's
microsoftDemangle() instead of UnDecorateSymbolName() so that it works on
non-Windows hosts – this makes both updating tests easier and provides a better
user experience for people doing cross-links.

This doesn't yet do the right thing for symbols starting with __imp_, but that
can be improved in a follow-up.

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

llvm-svn: 342332

5 years agoMerge Demangle change in r342330 to libcxxabi.
Nico Weber [Sat, 15 Sep 2018 18:25:49 +0000 (18:25 +0000)]
Merge Demangle change in r342330 to libcxxabi.

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

llvm-svn: 342331

5 years agoUpdate microsoftDemangle() to work more like itaniumDemangle().
Nico Weber [Sat, 15 Sep 2018 18:24:20 +0000 (18:24 +0000)]
Update microsoftDemangle() to work more like itaniumDemangle().

* Use same method of initializing the output stream and its buffer
* Allow a nullptr Status pointer
* Don't print the mangled name on demangling error
* Write to N (if it is non-nullptr)

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

llvm-svn: 342330

5 years ago[lldb-mi] Correct regex in the symbol-list-lines test
Alexander Polyakov [Sat, 15 Sep 2018 17:05:20 +0000 (17:05 +0000)]
[lldb-mi] Correct regex in the symbol-list-lines test

Summary:
The test failed in case of compiling a test suite with
gcc (checked versions are 5.2.0 and 7.3.0) because it
adds one more line entry comparing to clang. It doesn't
break the test's logic, so I just added a regex that matches
this case.

Reviewers: tatyana-krasnukha, aprantl, clayborg

Reviewed By: aprantl

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 342329

5 years ago[X86][SSE] Fix insertps load combine test name
Simon Pilgrim [Sat, 15 Sep 2018 16:57:04 +0000 (16:57 +0000)]
[X86][SSE] Fix insertps load combine test name

The existing test was called extract_lane_insertps_5123 but it was in fact doing a <6,1,2,3> shuffle. I've fixed the name and added the <5,1,2,3> test case as well.

llvm-svn: 342328

5 years ago[X86] Remove an fp->int->fp domain crossing in LowerUINT_TO_FP_i64.
Craig Topper [Sat, 15 Sep 2018 16:23:35 +0000 (16:23 +0000)]
[X86] Remove an fp->int->fp domain crossing in LowerUINT_TO_FP_i64.

Summary: This unfortunately adds a move, but isn't that better than going to the int domain and back?

Reviewers: RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 342327

5 years ago[X86] Fold (movmsk (setne (and X, (1 << C)), 0)) -> (movmsk (X << C))
Craig Topper [Sat, 15 Sep 2018 16:23:33 +0000 (16:23 +0000)]
[X86] Fold (movmsk (setne (and X, (1 << C)), 0)) -> (movmsk (X << C))

Summary:
MOVMSK only care about the sign bit so we don't need the setcc to fill the whole element with 0s/1s. We can just shift the bit we're looking for into the sign bit. This saves a constant pool load.

Inspired by PR38840.

Reviewers: RKSimon, spatel

Reviewed By: RKSimon

Subscribers: lebedev.ri, llvm-commits

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

llvm-svn: 342326

5 years ago[NFC] minor cleanup in PassManagerInternal.h
Fedor Sergeev [Sat, 15 Sep 2018 14:56:12 +0000 (14:56 +0000)]
[NFC] minor cleanup in PassManagerInternal.h

A few changes found necessary for upcoming PassInstrumentation patch:
  - name() methods made const
  - properly forward arguments in AnalysisPassModel::run

Separated out of the main D47858 patch.

llvm-svn: 342325

5 years ago[InstCombine][x86] try harder to convert blendv intrinsic to generic IR (PR38814)
Sanjay Patel [Sat, 15 Sep 2018 14:25:44 +0000 (14:25 +0000)]
[InstCombine][x86] try harder to convert blendv intrinsic to generic IR (PR38814)

Missing optimizations with blendv are shown in:
https://bugs.llvm.org/show_bug.cgi?id=38814

If this works, it's an easier and more powerful solution than adding pattern matching
for a few special cases in the backend. The potential danger with this transform in IR
is that the condition value can get separated from the select, and the backend might
not be able to make a blendv out of it again. I don't think that's too likely, but
I've kept this patch minimal with a 'TODO', so we can test that theory in the wild
before expanding the transform.

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

llvm-svn: 342324

5 years agoFix line endings. NFCI.
Simon Pilgrim [Sat, 15 Sep 2018 14:20:53 +0000 (14:20 +0000)]
Fix line endings. NFCI.

llvm-svn: 342323

5 years ago[OPENMP] Move OMPClauseReader/Writer classes to ASTReader/Writer (NFC)
Kelvin Li [Sat, 15 Sep 2018 13:54:15 +0000 (13:54 +0000)]
[OPENMP] Move OMPClauseReader/Writer classes to ASTReader/Writer (NFC)

Move declarations for OMPClauseReader, OMPClauseWriter to ASTReader.h
and ASTWriter.h and move implementation to ASTReader.cpp and
ASTWriter.cpp. This change helps generalize the serialization of
OpenMP clauses and will be used in the future implementation of new
OpenMP directives (e.g. requires).

Patch by Patrick Lyster

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

llvm-svn: 342322

5 years ago[InstCombine] Inefficient pattern for high-bits checking 3 (PR38708)
Roman Lebedev [Sat, 15 Sep 2018 12:04:13 +0000 (12:04 +0000)]
[InstCombine] Inefficient pattern for high-bits checking 3 (PR38708)

Summary:
It is sometimes important to check that some newly-computed value
is non-negative and only n bits wide (where n is a variable.)
There are many ways to check that:
https://godbolt.org/z/o4RB8D
The last variant seems best?
(I'm sure there are some other variations i haven't thought of..)

The last (as far i know?) pattern, non-canonical due to the extra use.
https://godbolt.org/z/aCMsPk
https://rise4fun.com/Alive/I6f

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

Reviewers: spatel, craig.topper, RKSimon

Reviewed By: spatel

Subscribers: llvm-commits

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

llvm-svn: 342321

5 years ago[XRay] Remove the unused variable
Petr Hosek [Sat, 15 Sep 2018 06:25:17 +0000 (06:25 +0000)]
[XRay] Remove the unused variable

This broke the fdr-single-thread test after FDRLoggingOptions struct
has been removed in r342318.

llvm-svn: 342320

5 years ago[CodeGenPrepare] Preserve debug locs in OptimizeExtractBits
Vedant Kumar [Sat, 15 Sep 2018 04:08:52 +0000 (04:08 +0000)]
[CodeGenPrepare] Preserve debug locs in OptimizeExtractBits

CodeGenPrepare has a transform that sinks {lshr, trunc} pairs to make it
easier for the backend to emit fancy extract-bits instructions (e.g UBFX).

Teach it to preserve debug locations and salvage debug values.

llvm-svn: 342319

5 years ago[XRay] Remove the deprecated __xray_log_init API
Petr Hosek [Sat, 15 Sep 2018 02:55:42 +0000 (02:55 +0000)]
[XRay] Remove the deprecated __xray_log_init API

This API has been deprecated three months ago and shouldn't be used
anymore, all clients should migrate to the new string based API.

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

llvm-svn: 342318

5 years ago[analyzer] Temporary disabling svalbuilder-rearrange-comparisons test
George Karpenkov [Sat, 15 Sep 2018 02:35:06 +0000 (02:35 +0000)]
[analyzer] Temporary disabling svalbuilder-rearrange-comparisons test

As debug printing has changed, and format was not guaranteed to be
stable.
Artem is currently working on a better solution.

llvm-svn: 342317

5 years ago[analyzer] Further printing improvements: use declarations,
George Karpenkov [Sat, 15 Sep 2018 02:34:45 +0000 (02:34 +0000)]
[analyzer] Further printing improvements: use declarations,

skip pointers whenever redundant, use unique prefixes.

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

llvm-svn: 342316

5 years agoGenerate unique identifiers for Decl objects
George Karpenkov [Sat, 15 Sep 2018 02:03:58 +0000 (02:03 +0000)]
Generate unique identifiers for Decl objects

The generated identifier is stable across multiple runs,
and can be a great visualization or debugging aide.

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

llvm-svn: 342315

5 years ago[analyzer] Generate and use stable identifiers for LocationContext
George Karpenkov [Sat, 15 Sep 2018 02:03:36 +0000 (02:03 +0000)]
[analyzer] Generate and use stable identifiers for LocationContext

Those are not created in the allocator.
Since they are created fairly rarely, a counter overhead should not
affect the memory consumption.

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

llvm-svn: 342314

5 years ago[analyzer] Dump reproducible identifiers for statements in exploded graph in store
George Karpenkov [Sat, 15 Sep 2018 02:03:17 +0000 (02:03 +0000)]
[analyzer] Dump reproducible identifiers for statements in exploded graph in store

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

llvm-svn: 342313

5 years ago[analyzer] Use correct end-of-line character when printing statements for exploded...
George Karpenkov [Sat, 15 Sep 2018 02:02:56 +0000 (02:02 +0000)]
[analyzer] Use correct end-of-line character when printing statements for exploded graph

Prevents bad centering.

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

llvm-svn: 342312

5 years agoStmtPrinter: allow customizing the end-of-line character
George Karpenkov [Sat, 15 Sep 2018 02:02:31 +0000 (02:02 +0000)]
StmtPrinter: allow customizing the end-of-line character

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

llvm-svn: 342311

5 years ago[analyzer] Dump unique identifiers for statements in exploded graph
George Karpenkov [Sat, 15 Sep 2018 02:02:09 +0000 (02:02 +0000)]
[analyzer] Dump unique identifiers for statements in exploded graph

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

llvm-svn: 342310

5 years agoSupport generating unique identifiers for Stmt objects
George Karpenkov [Sat, 15 Sep 2018 02:01:47 +0000 (02:01 +0000)]
Support generating unique identifiers for Stmt objects

The generated identifiers are stable across multiple runs, and can be a
great debug or visualization aid.

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

llvm-svn: 342309

5 years ago[analyzer] Skip printing duplicate nodes, even if nodes have multiple predecessors...
George Karpenkov [Sat, 15 Sep 2018 02:01:26 +0000 (02:01 +0000)]
[analyzer] Skip printing duplicate nodes, even if nodes have multiple predecessors/successors

Still generate a node, but leave the redundant field empty.

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

llvm-svn: 342308

5 years ago[modules] Don't bother creating a global module fragment when building a
Richard Smith [Sat, 15 Sep 2018 01:59:39 +0000 (01:59 +0000)]
[modules] Don't bother creating a global module fragment when building a
header module.

llvm-svn: 342307

5 years ago[modules] Support use of -E on modules built from the command line.
Richard Smith [Sat, 15 Sep 2018 01:21:18 +0000 (01:21 +0000)]
[modules] Support use of -E on modules built from the command line.

llvm-svn: 342306

5 years ago[modules] Driver support for precompiling a collection of files as a single
Richard Smith [Sat, 15 Sep 2018 01:21:16 +0000 (01:21 +0000)]
[modules] Driver support for precompiling a collection of files as a single
action.

llvm-svn: 342305

5 years ago[modules] Frontend support for building a header module from a list of
Richard Smith [Sat, 15 Sep 2018 01:21:15 +0000 (01:21 +0000)]
[modules] Frontend support for building a header module from a list of
headaer files.

llvm-svn: 342304

5 years ago[WebAssembly][NFC] Generalize operand numbers in SIMD tests
Thomas Lively [Sat, 15 Sep 2018 01:12:48 +0000 (01:12 +0000)]
[WebAssembly][NFC] Generalize operand numbers in SIMD tests

Reviewers: aheejin, dschuff

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

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

llvm-svn: 342303

5 years ago[WebAssembly] SIMD shifts
Thomas Lively [Sat, 15 Sep 2018 00:45:31 +0000 (00:45 +0000)]
[WebAssembly] SIMD shifts

Summary:
Implement shifts of vectors by i32. Since LLVM defines shifts as
binary operations between two vectors, this involves pattern matching
on splatted shift operands. For v2i64 shifts any i32 shift operands
have to be zero extended in the input and any i64 shift operands have
to be wrapped in the output. Depends on D52007.

Reviewers: aheejin, dschuff

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

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

llvm-svn: 342302

5 years agoFix filesystem race issue in SampleProfTest introduced in rL342283.
Wei Mi [Sat, 15 Sep 2018 00:04:15 +0000 (00:04 +0000)]
Fix filesystem race issue in SampleProfTest introduced in rL342283.

Before this fix, multiple invocations of testRoundTrip will create multiple
writers which share the same file as output destination. That could introduce
filesystem race issue when multiple subtests are executed concurrently. This
patch assign writers with different files as their output destinations.

llvm-svn: 342301

5 years agoStyle fix. NFC.
Rui Ueyama [Fri, 14 Sep 2018 23:51:17 +0000 (23:51 +0000)]
Style fix. NFC.

llvm-svn: 342300

5 years agoRename GdbIndex.{cpp,h} -> DWARF.{cpp,h}.
Rui Ueyama [Fri, 14 Sep 2018 23:51:05 +0000 (23:51 +0000)]
Rename GdbIndex.{cpp,h} -> DWARF.{cpp,h}.

These files used to contain classes and functions for .gdb_index,
but they are moved to SyntheticSections.{cpp,h}, so the name is now
irrelevant.

llvm-svn: 342299

5 years agoRevert r342297: Discard uncompressed buffer after creating .gdb_index contents.
Rui Ueyama [Fri, 14 Sep 2018 23:28:13 +0000 (23:28 +0000)]
Revert r342297: Discard uncompressed buffer after creating .gdb_index contents.

Looks like it broke some local builds that use -gdb-index.

llvm-svn: 342298

5 years agoDiscard uncompressed buffer after creating .gdb_index contents.
Rui Ueyama [Fri, 14 Sep 2018 22:57:39 +0000 (22:57 +0000)]
Discard uncompressed buffer after creating .gdb_index contents.

Once we create .gdb_index contents, .zdebug_gnu_pub{names,types}
are useless, so there's no need to keep their uncompressed data
in memory.

I observed that for a test case in which lld creates a 3GB .gdb_index
section, the maximum resident set size reduced from 43GB to 29GB after
this patch.

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

llvm-svn: 342297

5 years ago[WebAssembly] SIMD neg
Thomas Lively [Fri, 14 Sep 2018 22:35:12 +0000 (22:35 +0000)]
[WebAssembly] SIMD neg

Summary: Depends on D52007.

Reviewers: aheejin, dschuff

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

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

llvm-svn: 342296

5 years ago[PDB] Make the pretty dumper output modified types.
Zachary Turner [Fri, 14 Sep 2018 22:29:19 +0000 (22:29 +0000)]
[PDB] Make the pretty dumper output modified types.

Currently if we got something like `const Foo` we'd ignore it and
just rely on printing the unmodified `Foo` later on.  However,
for testing the native reading code we really would like to be able
to see these so that we can verify that the native reader can
actually handle them.  Instead of printing out the full type though,
just print out the header.

llvm-svn: 342295

5 years ago[COFF] Provide __CTOR_LIST__ and __DTOR_LIST__ symbols for MinGW
Martin Storsjo [Fri, 14 Sep 2018 22:26:59 +0000 (22:26 +0000)]
[COFF] Provide __CTOR_LIST__ and __DTOR_LIST__ symbols for MinGW

MinGW uses these kind of list terminator symbols for traversing
the constructor/destructor lists. These list terminators are
actual pointers entries in the lists, with the values 0 and
(uintptr_t)-1 (instead of just symbols pointing to the start/end
of the list).

(This mechanism exists in both the mingw-w64 crt startup code and
in libgcc; normally the mingw-w64 one is used, but a DLL build of
libgcc uses the libgcc one. Therefore it's not trivial to change
the mechanism without lots of cross-project synchronization and
potentially invalidating some combinations of old/new versions
of them.)

When mingw-w64 has been used with lld so far, the CRT startup object
files have so far provided these symbols, ending up with different,
incompatible builds of the CRT startup object files depending on
whether binutils or lld are going to be used.

In order to avoid the need of different configuration of the CRT startup
object files depending on what linker to be used, provide these symbols
in lld instead. (Mingw-w64 checks at build time whether the linker
provides these symbols or not.) This unifies this particular detail
between the two linkers.

This does disallow the use of the very latest lld with older versions
of mingw-w64 (the configure check for the list was added recently;
earlier it simply checked whether the CRT was built with gcc or clang),
and requires rebuilding the mingw-w64 CRT. But the number of users of
lld+mingw still is low enough that such a change should be tolerable,
and unifies this aspect of the toolchains, easing interoperability
between the toolchains for the future.

The actual test for this feature is added in ctors_dtors_priority.s,
but a number of other tests that checked absolute output addresses
are updated.

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

llvm-svn: 342294

5 years ago[BreakFalseDeps] Fix bad formatting. NFC
Craig Topper [Fri, 14 Sep 2018 22:26:09 +0000 (22:26 +0000)]
[BreakFalseDeps] Fix bad formatting. NFC

llvm-svn: 342293

5 years ago[InstCombine] refactor mul narrowing folds; NFCI
Sanjay Patel [Fri, 14 Sep 2018 22:23:35 +0000 (22:23 +0000)]
[InstCombine] refactor mul narrowing folds; NFCI

Similar to rL342278:
The test diffs are all cosmetic due to the change in
value naming, but I'm including that to show that the
new code does perform these folds rather than something
else in instcombine.

D52075 should be able to use this code too rather than
duplicating all of the logic.

llvm-svn: 342292

5 years agoAttempt to unbreak the build after r342286.
Adrian Prantl [Fri, 14 Sep 2018 21:43:45 +0000 (21:43 +0000)]
Attempt to unbreak the build after r342286.

llvm-svn: 342291

5 years agotest/Driver/output-file-cleanup.c: delete non-readable temporary file
Fangrui Song [Fri, 14 Sep 2018 21:36:35 +0000 (21:36 +0000)]
test/Driver/output-file-cleanup.c: delete non-readable temporary file

%t-dir/2.c made tools (rsync, ripgrep, ...) sad (EACCES warning).

llvm-svn: 342290

5 years ago[InstCombine] add/use overflowing math helper functions; NFC
Sanjay Patel [Fri, 14 Sep 2018 21:30:07 +0000 (21:30 +0000)]
[InstCombine] add/use overflowing math helper functions; NFC

The mul case can already be refactored to use this similar to
rL342278.
The sub case is proposed in D52075.

llvm-svn: 342289

5 years ago[PowerPC] Fix the calling convention for i1 arguments on PPC32
Lion Yang [Fri, 14 Sep 2018 21:26:05 +0000 (21:26 +0000)]
[PowerPC] Fix the calling convention for i1 arguments on PPC32

Summary:
Integer types smaller than i32 must be extended to i32 by default.
The feature "crbits" introduced at r202451 handles i1 as a special case,
but it did not extend properly.
The caller was, therefore, passing i1 stack arguments by writing 0/1 to
the first byte of the 4-byte stack object and callee was
reading the first byte for the value.

"crbits" is enabled if the optimization level is greater than 1,
which is very common in "release builds".
Such discrepancies with ABI specification also introduces
potential incompatibility with programs or libraries
built with other compilers e.g. GCC.

Fixes PR38661

Reviewers: hfinkel, cuviper

Subscribers: sylvestre.ledru, glaubitz, nagisa, nemanjai, kbarton, llvm-commits

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

llvm-svn: 342288

5 years ago[WebAssembly][NFC] Move SIMD encoding tests to dedicated file
Thomas Lively [Fri, 14 Sep 2018 21:21:42 +0000 (21:21 +0000)]
[WebAssembly][NFC] Move SIMD encoding tests to dedicated file

Summary:
This change makes the tests more focused and avoids problematic
interactions between the testing modes and instruction encoding. This
change also allows the other tests to use less verbose output and
stricter checks.

Reviewers: aheejin, dschuff, aardappel

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

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

llvm-svn: 342287

5 years agoAdd missing include.
Zachary Turner [Fri, 14 Sep 2018 21:19:52 +0000 (21:19 +0000)]
Add missing include.

llvm-svn: 342286

5 years ago[codeview] Remove dead code
Reid Kleckner [Fri, 14 Sep 2018 21:14:08 +0000 (21:14 +0000)]
[codeview] Remove dead code

llvm-svn: 342285

5 years ago[PDB] Refactor a little of the Symbol creation code.
Zachary Turner [Fri, 14 Sep 2018 21:03:57 +0000 (21:03 +0000)]
[PDB] Refactor a little of the Symbol creation code.

Eventually we need to be able to support nested types, which don't
have an associated CVType record.  To handle this, remove the
CVType from all of the record classes, and instead store the
deserialized record.  Then move the deserialization up to the thing
that creates the type.  This actually makes error handling better
anyway as we can return an invalid symbol instead of asserting false.

llvm-svn: 342284

5 years ago[SampleFDO] Add FunctionOffsetTable in compact binary format profile.
Wei Mi [Fri, 14 Sep 2018 20:52:59 +0000 (20:52 +0000)]
[SampleFDO] Add FunctionOffsetTable in compact binary format profile.

The patch saves a function offset table which maps function name index to the
offset of its function profile to the start of the binary profile. By using
the function offset table, for those function profiles which will not be used
when compiling a module, the profile reader does't have to read them. For
profile size around 10~20M, it saves ~10% compile time.

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

llvm-svn: 342283

5 years agoMark index-tools.test as REQUIRES: shell so that it does not run with the internal...
Reid Kleckner [Fri, 14 Sep 2018 20:51:07 +0000 (20:51 +0000)]
Mark index-tools.test as REQUIRES: shell so that it does not run with the internal lit shell which does not support "if"

llvm-svn: 342282

5 years agoRelax assumption about default method calling convention in new test
Reid Kleckner [Fri, 14 Sep 2018 20:50:39 +0000 (20:50 +0000)]
Relax assumption about default method calling convention in new test

llvm-svn: 342281

5 years ago[IRInterpreter] Minor cleanups, add comments. NFCI.
Davide Italiano [Fri, 14 Sep 2018 20:48:34 +0000 (20:48 +0000)]
[IRInterpreter] Minor cleanups, add comments. NFCI.

llvm-svn: 342280

5 years agotest/Other/can-execute.txt: delete %t after the test
Fangrui Song [Fri, 14 Sep 2018 20:41:42 +0000 (20:41 +0000)]
test/Other/can-execute.txt: delete %t after the test

This test constructs a non-readable file of mode 0111, which lingers in the test output directory and will cause EACCES to various tools (rg, rsync, ...)

llvm-svn: 342279

5 years ago[InstCombine] refactor add narrowing folds; NFCI
Sanjay Patel [Fri, 14 Sep 2018 20:40:46 +0000 (20:40 +0000)]
[InstCombine] refactor add narrowing folds; NFCI

The test diffs are all cosmetic due to the change in
value naming, but I'm including that to show that the
new code does perform these folds rather than something
else in instcombine.

llvm-svn: 342278

5 years agoHotColdSplit: fix invalid SSA due to outlining
Sebastian Pop [Fri, 14 Sep 2018 20:36:19 +0000 (20:36 +0000)]
HotColdSplit: fix invalid SSA due to outlining

The test used to fail with an invalid phi node: the two predecessors were outlined
and the SSA representation was left invalid. The patch adds the exit block to the
cold region.

llvm-svn: 342277

5 years agoHotColdSplit: fix isSingleEntrySingleExit
Sebastian Pop [Fri, 14 Sep 2018 20:36:14 +0000 (20:36 +0000)]
HotColdSplit: fix isSingleEntrySingleExit

remove duplicate entries from isSingleEntrySingleExit: the Entry block is
already added by the loop over the dominance frontier.

Remove the heuristic from isOutlineCandidate that a region is too small when it
only contains a basic block. With this change we now grow regions starting from
a block and we continue adding to the ValidColdRegion. Check the heuristic just
before code generation.

llvm-svn: 342276

5 years agoHotColdSplit: add back propagation to extend cold regions
Sebastian Pop [Fri, 14 Sep 2018 20:36:10 +0000 (20:36 +0000)]
HotColdSplit: add back propagation to extend cold regions

Also fix a problem in forward propagation:
  const TerminatorInst *TI = It->getTerminator();
was set outside the while loop that iterates over It.

llvm-svn: 342275

5 years ago[InstCombine] add more tests for add narrowing folds; NFC
Sanjay Patel [Fri, 14 Sep 2018 20:33:40 +0000 (20:33 +0000)]
[InstCombine] add more tests for add narrowing folds; NFC

llvm-svn: 342274

5 years ago[WebAssembly][NFC] Fix unconventional test names
Thomas Lively [Fri, 14 Sep 2018 20:22:45 +0000 (20:22 +0000)]
[WebAssembly][NFC] Fix unconventional test names

Reviewers: aheejin, dschuff

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

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

llvm-svn: 342273

5 years agoRemove unused DIASession field
Reid Kleckner [Fri, 14 Sep 2018 20:16:31 +0000 (20:16 +0000)]
Remove unused DIASession field

llvm-svn: 342272

5 years ago[analyzer] Handle forwarding reference better in ExprMutationAnalyzer.
Shuai Wang [Fri, 14 Sep 2018 20:07:18 +0000 (20:07 +0000)]
[analyzer] Handle forwarding reference better in ExprMutationAnalyzer.

Summary:
We used to treat an `Expr` mutated whenever it's passed as non-const
reference argument to a function. This results in false positives in
cases like this:
```
int x;
std::vector<int> v;
v.emplace_back(x); // `x` is passed as non-const reference to `emplace_back`
```
In theory the false positives can be suppressed with
`v.emplace_back(std::as_const(x))` but that's considered overly verbose,
inconsistent with existing code and spammy as diags.

This diff handles such cases by following into the function definition
and see whether the argument is mutated inside.

Reviewers: lebedev.ri, JonasToth, george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin, mikhail.ramalho, Szelethus, cfe-commits

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

llvm-svn: 342271

5 years agoAMDGPU: Clear the bits before they are being set in program resource registers
Konstantin Zhuravlyov [Fri, 14 Sep 2018 20:00:36 +0000 (20:00 +0000)]
AMDGPU: Clear the bits before they are being set in program resource registers

Change by Tony Tye

llvm-svn: 342270

5 years agoFix lit/example/many-tests pickling issue
Alex Langford [Fri, 14 Sep 2018 19:44:09 +0000 (19:44 +0000)]
Fix lit/example/many-tests pickling issue

Summary:
The multiprocess module uses pickling to transfer
information between processes and does not know how to pickle
the class created in the lit.cfg file and thus the example
fails.

Implement ManyTests in a separate file and import for the
example test passes

Patch by Nathan Lanza <nathan@lanza.io>

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

llvm-svn: 342269

5 years agoTest commit access
Lion Yang [Fri, 14 Sep 2018 19:43:11 +0000 (19:43 +0000)]
Test commit access

Remove trailing spaces

llvm-svn: 342268

5 years ago[NFC][clangd] silence pedantic extra ';' warning
Jonas Toth [Fri, 14 Sep 2018 19:42:37 +0000 (19:42 +0000)]
[NFC][clangd] silence pedantic extra ';' warning

llvm-svn: 342267

5 years agoFix lldb-vscode README.md
Alex Langford [Fri, 14 Sep 2018 19:41:20 +0000 (19:41 +0000)]
Fix lldb-vscode README.md

Summary: The readme was missing "-" characters to enable links

Patch by Nathan Lanza <nathan@lanza.io>

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

llvm-svn: 342266