platform/upstream/llvm.git
6 years ago[ELF] - Do not remove empty sections that use symbols in expressions.
George Rimar [Thu, 1 Mar 2018 12:27:04 +0000 (12:27 +0000)]
[ELF] - Do not remove empty sections that use symbols in expressions.

This is PR36515.

Currenly if we have a script like .debug_info 0 : { *(.debug_info) },
we would not remove this section and keep it in the output.
That does not work, because it is common case for
debug sections to have a zero address expression.
Patch changes behavior so that we remove only sections
that do not use symbols in its expressions.

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

llvm-svn: 326430

6 years ago[SCCP] Fix unused variable warning in release builds.
Benjamin Kramer [Thu, 1 Mar 2018 11:31:44 +0000 (11:31 +0000)]
[SCCP] Fix unused variable warning in release builds.

llvm-svn: 326429

6 years ago[OMPT] Fix task-type test with GCC
Joachim Protze [Thu, 1 Mar 2018 11:26:15 +0000 (11:26 +0000)]
[OMPT] Fix task-type test with GCC

This is similar to D43882. The runtime needs to be initialized before calling print_ids(0)

http://lab.llvm.org:8011/builders/openmp-gcc-x86_64-linux-debian/builds/60

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

llvm-svn: 326428

6 years ago[ELF] - Fix eh-frame-reloc-out-of-range.test.
George Rimar [Thu, 1 Mar 2018 10:38:51 +0000 (10:38 +0000)]
[ELF] - Fix eh-frame-reloc-out-of-range.test.

Was broken after recent testcases changes.

llvm-svn: 326427

6 years ago[clang-format] Add SpaceBeforeColon option
Francois Ferrand [Thu, 1 Mar 2018 10:09:13 +0000 (10:09 +0000)]
[clang-format] Add SpaceBeforeColon option

Summary:
When disabled, this option allows removing the space before colon,
making it act more like the semi-colon. When enabled (default), the
current behavior is not affected.

This mostly affects C++11 loop, initializer list, inheritance list and
container literals:

  class Foo: Bar {}
  Foo::Foo(): a(a) {}
  for (auto i: myList) {}
  f({a: 1, b: 2, c: 3});

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: xvallspl, teemperor, karies, cfe-commits, klimek

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

llvm-svn: 326426

6 years ago[dsymutil] Move string pool into its own implementatino file. NFC.
Jonas Devlieghere [Thu, 1 Mar 2018 10:05:54 +0000 (10:05 +0000)]
[dsymutil] Move string pool into its own implementatino file. NFC.

The DwarfLinker implementation is already relatively large with over 4k
LOC. This commit moves the implementation of NonRelocatableStringpool
into a separate cpp file.

llvm-svn: 326425

6 years ago[WebAssembly] Reorder exports to match symbol table order
Nicholas Wilson [Thu, 1 Mar 2018 09:38:02 +0000 (09:38 +0000)]
[WebAssembly] Reorder exports to match symbol table order

This fixes a TODO introduced in rLLD325861.

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

llvm-svn: 326424

6 years ago[PATCH] [compiler-rt, RISCV] Support builtins for RISC-V
Shiva Chen [Thu, 1 Mar 2018 07:47:27 +0000 (07:47 +0000)]
[PATCH] [compiler-rt, RISCV] Support builtins for RISC-V

Summary:
Support builtins for RISC-V, RV32 and RV64.

Reviewers: asb, apazos, mgrang

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

llvm-svn: 326420

6 years agoFunction definition may have uninstantiated body
Serge Pavlov [Thu, 1 Mar 2018 07:04:11 +0000 (07:04 +0000)]
Function definition may have uninstantiated body

Current implementation of `FunctionDecl::isDefined` does not take into
account redeclarations that do not have bodies, but the bodies can be
instantiated from corresponding templated definition. This behavior does
not allow to detect function redefinition in the cases where friend
functions is defined in class templates. For instance, the code:
```
    template<typename T> struct X { friend void f() {} };
    X<int> xi;
    void f() {}
```
compiles successfully but must fail due to redefinition of `f`. The
declaration of the friend `f` is created when the containing template
`X` is instantiated, but it does not have a body as per 14.5.4p4
because `f` is not odr-used.

With this change the function `Sema::CheckForFunctionRedefinition`
considers functions with uninstantiated bodies as definitions.

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

llvm-svn: 326419

6 years ago[SCEV] Smart range calculation for SCEVUnknown Phis
Max Kazantsev [Thu, 1 Mar 2018 06:56:48 +0000 (06:56 +0000)]
[SCEV] Smart range calculation for SCEVUnknown Phis

The range of SCEVUnknown Phi which merges values `X1, X2, ..., XN`
can be evaluated as `U(Range(X1), Range(X2), ..., Range(XN))`.

Reviewed By: sanjoy
Differential Revision: https://reviews.llvm.org/D43810

llvm-svn: 326418

6 years ago[X86] Stop passing two arguments by reference. NFC
Craig Topper [Thu, 1 Mar 2018 06:25:13 +0000 (06:25 +0000)]
[X86] Stop passing two arguments by reference. NFC

I think these used to be out parameters, but they haven't been for a while.

llvm-svn: 326417

6 years agoRemove redundant casts. NFC
George Burgess IV [Thu, 1 Mar 2018 05:43:23 +0000 (05:43 +0000)]
Remove redundant casts. NFC

So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and
`dyn_cast`s for fun. This is a portion of what it found for clang; I
plan to do similar cleanups in LLVM and other subprojects when I find
time.

Because of the volume of changes, I explicitly avoided making any change
that wasn't highly local and obviously correct to me (e.g. we still have
a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading
is a thing and the cast<Bar> did actually change the type -- just up the
class hierarchy).

I also tried to leave the types we were cast<>ing to somewhere nearby,
in cases where it wasn't locally obvious what we were dealing with
before.

llvm-svn: 326416

6 years agoConvert more tests as linker scripts instead of assembly.
Rui Ueyama [Thu, 1 Mar 2018 04:21:42 +0000 (04:21 +0000)]
Convert more tests as linker scripts instead of assembly.

llvm-svn: 326415

6 years ago[test] Restore cleanup behavior in TestQuoting.py
Vedant Kumar [Thu, 1 Mar 2018 03:03:38 +0000 (03:03 +0000)]
[test] Restore cleanup behavior in TestQuoting.py

Before the change to compile tests out-of-tree, the cleanup classmethod
in TestQuoting.py would remove a temp file. After the change it threw an
exception due to a malformed call to getBuildArtifact().

Bring back the old behavior.

llvm-svn: 326414

6 years ago[Support] Fix comments for handleAllErrors: it calls llvm_unreachable if the
Lang Hames [Thu, 1 Mar 2018 02:52:17 +0000 (02:52 +0000)]
[Support] Fix comments for handleAllErrors: it calls llvm_unreachable if the
contract is violated, not report_fatal_error.

llvm-svn: 326413

6 years agoWe were getting the wrong dynamic type if there were two classes with the same basename.
Jim Ingham [Thu, 1 Mar 2018 02:44:34 +0000 (02:44 +0000)]
We were getting the wrong dynamic type if there were two classes with the same basename.

There's a bug in FindTypes, it ignores the exact flag if you pass a name that doesn't begin with
:: and pass eTypeClassAny for the type.

In this case we always know that the name we get from the vtable name is absolute so we can
work around the bug by prepending the "::".  This doesn't fix the FindTypes bug.

<rdar://problem/38010986>

llvm-svn: 326412

6 years ago[WebAssembly] Remove unused forward declaration.
Rui Ueyama [Thu, 1 Mar 2018 02:37:26 +0000 (02:37 +0000)]
[WebAssembly] Remove unused forward declaration.

llvm-svn: 326411

6 years agoDo not create multiple NOTE segments.
Rui Ueyama [Thu, 1 Mar 2018 02:31:29 +0000 (02:31 +0000)]
Do not create multiple NOTE segments.

Previously, we didn't try to make effort to put .note sections next
to each other in the output file, so two .note sections were likely
to be stored to two separate NOTE segments. That's undesirable because
we should create as few segments as possible in general.

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

llvm-svn: 326410

6 years agoExpand test a bit.
Rafael Espindola [Thu, 1 Mar 2018 02:25:40 +0000 (02:25 +0000)]
Expand test a bit.

It now includes both linkerscript and non linkerscript variants.

Extracted from a patch by Rui while I was trying to figure out what
exactly was changing.

llvm-svn: 326409

6 years ago[analyzer] [tests] Create a directory for the log file
George Karpenkov [Thu, 1 Mar 2018 02:18:54 +0000 (02:18 +0000)]
[analyzer] [tests] Create a directory for the log file

llvm-svn: 326408

6 years ago[XRay] cache symbolized function names for a repeatedly queried function ID
Martin Pelikan [Thu, 1 Mar 2018 01:59:24 +0000 (01:59 +0000)]
[XRay] cache symbolized function names for a repeatedly queried function ID

Summary:
Processing 2 GB XRay traces with "llvm-xray convert -symbolize" needs to
go over each trace record and symbolize the function name refered to by
its ID.  Currently this happens by asking the LLVM symbolizer code every
single time.  A simple cache can save around 30 minutes of processing of
that trace.

llvm-xray's resident memory usage increased negligibly with this cache.

Reviewers: dberris

Subscribers: llvm-commits

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

llvm-svn: 326407

6 years ago[RuntimeDyld][MachO] Fix assertion in encodeAddend, add missing directive to
Lang Hames [Thu, 1 Mar 2018 01:44:33 +0000 (01:44 +0000)]
[RuntimeDyld][MachO] Fix assertion in encodeAddend, add missing directive to
test case.

r326290 fixed the assertion for decodeAddend, but not encodeAddend. The
regression test failed to catch this because it was missing the
subsections_via_symbols flag, so the desired relocation was not applied.

This patch also fixes the formatting of the assertion from r326290.

llvm-svn: 326406

6 years ago[analyzer] Add a checker for mmap()s which are both writable and executable.
Artem Dergachev [Thu, 1 Mar 2018 01:27:46 +0000 (01:27 +0000)]
[analyzer] Add a checker for mmap()s which are both writable and executable.

This is a security check that warns when both PROT_WRITE and PROT_EXEC are
set during mmap(). If mmap()ed memory is both writable and executable, it makes
it easier for the attacker to execute arbitrary code when contents of this
memory are compromised. Some applications require such mmap()s though, such as
different sorts of JIT.

Re-applied after a revert in r324167.

Temporarily stays in the alpha package because it needs a better way of
determining macro values that are not immediately available in the AST.

Patch by David Carlier!

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

llvm-svn: 326405

6 years ago[IPSCCP] do not break musttail invariant (PR36485)
Reid Kleckner [Thu, 1 Mar 2018 01:19:18 +0000 (01:19 +0000)]
[IPSCCP] do not break musttail invariant (PR36485)

Do not replace results of `musttail` calls with a constant if the
call itself can't be removed.

Do not zap returns of `musttail` callees, if the call site can't be
removed and replaced with a constant.

Do not zap returns of `musttail`-calling blocks, this breaks
invariant too.

Patch by Fedor Indutny

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

llvm-svn: 326404

6 years agoConvert more .s files to linker script files.
Rui Ueyama [Thu, 1 Mar 2018 01:19:12 +0000 (01:19 +0000)]
Convert more .s files to linker script files.

Summary:
This change removes large "echo" commands from the test by writing
tests themselves as linker scripts.

Reviewers: rafael

Subscribers: emaste, javed.absar, llvm-commits, arichardson

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

llvm-svn: 326403

6 years ago[CFG] [analyzer] Recall that we only skip NoOp casts in construction contexts.
Artem Dergachev [Thu, 1 Mar 2018 01:09:24 +0000 (01:09 +0000)]
[CFG] [analyzer] Recall that we only skip NoOp casts in construction contexts.

For now. We should also add support for ConstructorConversion casts as presented
in the attached test case, but this requires more changes because AST around
them seems different.

The check was originally present but was accidentally lost during r326021.

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

llvm-svn: 326402

6 years agoSimplify removing empty output sections.
Rafael Espindola [Thu, 1 Mar 2018 01:08:00 +0000 (01:08 +0000)]
Simplify removing empty output sections.

With this the meaning of the Live bit in output sections is clear: we
have at some point added a input section into it.

llvm-svn: 326401

6 years ago[ELF] Fix a test comment. NFC
Fangrui Song [Thu, 1 Mar 2018 01:05:04 +0000 (01:05 +0000)]
[ELF] Fix a test comment. NFC

llvm-svn: 326400

6 years agoAdd another entitlement that we need for debugserver.
Jason Molenda [Thu, 1 Mar 2018 01:04:07 +0000 (01:04 +0000)]
Add another entitlement that we need for debugserver.
<rdar://problem/29855293>

llvm-svn: 326399

6 years ago[WebAssembly] Use Twine rather than StringRef for logging messages
Sam Clegg [Thu, 1 Mar 2018 00:42:57 +0000 (00:42 +0000)]
[WebAssembly] Use Twine rather than StringRef for logging messages

Also add missing tracing to writeU8.

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

llvm-svn: 326398

6 years agoStart setting dllimport/dllexport in setGVProperties.
Rafael Espindola [Thu, 1 Mar 2018 00:35:47 +0000 (00:35 +0000)]
Start setting dllimport/dllexport in setGVProperties.

This is the next step in setting dso_local for COFF.

The patches changes setGVProperties to first set dllimport/dllexport
and changes a few cases that were setting dllimport/dllexport
manually. With this a few more GVs are marked dso_local.

llvm-svn: 326397

6 years ago[GlobalISel][AArch64] Adding -disable-gisel-legality-check CL option
Roman Tereshin [Thu, 1 Mar 2018 00:27:48 +0000 (00:27 +0000)]
[GlobalISel][AArch64] Adding -disable-gisel-legality-check CL option

Currently it's impossible to test InstructionSelect pass with MIR which
is considered illegal by the Legalizer in Assert builds. In early stages
of porting an existing backend from SelectionDAG ISel to GlobalISel,
however, we would have very basic CallLowering, Legalizer, and
RegBankSelect implementations, but rather functional Instruction Select
with quite a few patterns selectable due to the semi-automatic porting
process borrowing them from SelectionDAG ISel.

As we are trying to define legality as a property of being selectable by
the instruction selector, it would be nice to be able to easily check
what the selector can do in its current state w/o the legality check
provided by the Legalizer getting in the way.

It also seems beneficial to have a regression testing set up that would
not allow the selector to silently regress in its support of the MIR not
supported yet by the previous passes in the GlobalISel pipeline.

This commit adds -disable-gisel-legality-check command line option to
llc that disables those legality checks in RegBankSelect and
InstructionSelect passes.

It also adds quite a few MIR test cases for AArch64's Instruction
Selector. Every one of them would fail on the legality check at the
moment, but will select just fine if the check is disabled. Every test
MachineFunction is intended to exercise a specific selection rule and
that rule only, encoded in the MachineFunction's name by the rule's
number, ID, and index of its GIM_Try opcode in TableGen'erated
MatchTable (-optimize-match-table=false).

Reviewers: ab, dsanders, qcolombet, rovka

Reviewed By: bogner

Subscribers: kristof.beyls, volkan, aditya_nandakumar, aemerson,
rengolin, t.p.northover, javed.absar, llvm-commits

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

llvm-svn: 326396

6 years ago[DWARF] Emit a split line table only if there are split type units.
Paul Robinson [Thu, 1 Mar 2018 00:12:35 +0000 (00:12 +0000)]
[DWARF] Emit a split line table only if there are split type units.

A .debug_info.dwo section doesn't use the .debug_line.dwo section.

llvm-svn: 326395

6 years ago[DAE] don't remove args of musttail target/caller
Reid Kleckner [Thu, 1 Mar 2018 00:09:35 +0000 (00:09 +0000)]
[DAE] don't remove args of musttail target/caller

`musttail` requires identical signatures of caller and callee. Removing
arguments breaks `musttail` semantics.

PR36441

Patch by Fedor Indutny

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

llvm-svn: 326394

6 years ago[X86] Make sure we don't combine (fneg (fma X, Y, Z)) to a target specific node when...
Craig Topper [Thu, 1 Mar 2018 00:08:38 +0000 (00:08 +0000)]
[X86] Make sure we don't combine (fneg (fma X, Y, Z)) to a target specific node when there are no FMA instructions.

This would cause a 'cannot select' error at isel when we should have emitted a lib call and an xor.

Fixes PR36553.

llvm-svn: 326393

6 years agoPass a GlobalDecl to SetCommonAttributes. NFC.
Rafael Espindola [Thu, 1 Mar 2018 00:06:55 +0000 (00:06 +0000)]
Pass a GlobalDecl to SetCommonAttributes. NFC.

Part of D43900.

llvm-svn: 326392

6 years agoInline a trivial function. NFC.
Rafael Espindola [Thu, 1 Mar 2018 00:00:02 +0000 (00:00 +0000)]
Inline a trivial function. NFC.

llvm-svn: 326391

6 years ago[NVPTX] Lower loads from global constants using ld.global.nc (aka LDG).
Justin Lebar [Wed, 28 Feb 2018 23:58:05 +0000 (23:58 +0000)]
[NVPTX] Lower loads from global constants using ld.global.nc (aka LDG).

Summary:
After D43914, loads from global variables in addrspace(1) happen with
ld.global.  But since they're constants, even better would be to use
ld.global.nc, aka ldg.

Reviewers: tra

Subscribers: jholewinski, sanjoy, hiraditya, llvm-commits

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

llvm-svn: 326390

6 years ago[NVPTX] Use addrspacecast instead of target-specific intrinsics in NVPTXGenericToNVVM.
Justin Lebar [Wed, 28 Feb 2018 23:57:48 +0000 (23:57 +0000)]
[NVPTX] Use addrspacecast instead of target-specific intrinsics in NVPTXGenericToNVVM.

Summary:
NVPTXGenericToNVVM was using target-specific intrinsics to do address
space casts.  Using the addrspacecast instruction is (a lot) simpler.
But it also has the advantage of being understandable to other passes.
In particular, InferAddrSpaces is able to understand these address space
casts and remove them in most cases.

Reviewers: tra

Subscribers: jholewinski, sanjoy, hiraditya, llvm-commits

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

llvm-svn: 326389

6 years agoPass a GlobalDecl to setNonAliasAttributes. NFC.
Rafael Espindola [Wed, 28 Feb 2018 23:54:23 +0000 (23:54 +0000)]
Pass a GlobalDecl to setNonAliasAttributes. NFC.

Also part of D43900.

llvm-svn: 326388

6 years ago[MIRParser] Accept overloaded intrinsic names w/o type suffixes
Roman Tereshin [Wed, 28 Feb 2018 23:51:49 +0000 (23:51 +0000)]
[MIRParser] Accept overloaded intrinsic names w/o type suffixes

Function::lookupIntrinsicID is somewhat forgiving as it comes to
overloaded intrinsics' names: it returns an ID as soon as the name
provided has a prefix that matches a registered intrinsic's name w/o
actually checking that the rest of the name encodes all the concrete arg
types, let alone that those types are compatible with the intrinsic's
definition.

That's probably fine and comes in handy in MIR serialization: we don't
care about IR types at MIR level and every intrinsic should be
selectable based on its ID and low-level types (LLTs) of its operands,
including the overloaded ones, so there is no point in serializing
mangled IR types as part of the intrinsic's name.

However, lookupIntrinsicID is somewhat inconsistent in its forgiveness:
if the name provided is actually an exact match, it will refuse to
return the ID if the intrinsic is overloaded. There is probably no
real reason for that and it renders MIRParser incapable to deserialize
MIR MIRPrinter serialized.

This commit fixes it.

Reviewers: rnk, aditya_nandakumar, qcolombet, thegameg, dsanders,
marcello.maggioni

Reviewed By: bogner

Subscribers: javed.absar, llvm-commits

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

llvm-svn: 326387

6 years ago[clang-tidy] Another batch of checks to rename from misc- to bugprone-.
Alexander Kornienko [Wed, 28 Feb 2018 23:47:15 +0000 (23:47 +0000)]
[clang-tidy] Another batch of checks to rename from misc- to bugprone-.

Summary:
clang-tidy/rename_check.py {misc,bugprone}-suspicious-semicolon
clang-tidy/rename_check.py {misc,bugprone}-suspicious-string-compare
clang-tidy/rename_check.py {misc,bugprone}-swapped-arguments
clang-tidy/rename_check.py {misc,bugprone}-undelegated-constructor --check_class_name UndelegatedConstructor

Reviewers: hokein, sammccall, aaron.ballman

Subscribers: klimek, mgorny, xazax.hun, cfe-commits

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

llvm-svn: 326386

6 years agoPass a GlobalDecl to SetInternalFunctionAttributes. NFC.
Rafael Espindola [Wed, 28 Feb 2018 23:46:35 +0000 (23:46 +0000)]
Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.

This just reduces the noise in a followup patch.

Part of D43900.

llvm-svn: 326385

6 years agoRename more checks from misc- to bugprone-.
Alexander Kornienko [Wed, 28 Feb 2018 23:30:29 +0000 (23:30 +0000)]
Rename more checks from misc- to bugprone-.

Summary:
clang-tidy/rename_check.py {misc,bugprone}-string-integer-assignment
clang-tidy/rename_check.py {misc,bugprone}-string-literal-with-embedded-nul
clang-tidy/rename_check.py {misc,bugprone}-suspicious-enum-usage
clang-tidy/rename_check.py {misc,bugprone}-suspicious-missing-comma

Reviewers: hokein, sammccall, aaron.ballman

Subscribers: klimek, cfe-commits, mgorny

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

llvm-svn: 326384

6 years ago[libcxx] Fix last_write_time test for filesystems that don't support very small times.
Volodymyr Sapsai [Wed, 28 Feb 2018 23:27:40 +0000 (23:27 +0000)]
[libcxx] Fix last_write_time test for filesystems that don't support very small times.

APFS minimum supported file write time is -2^63 nanoseconds, which doesn't go
as far as `file_time_type::min()` that is equal to -2^63 microseconds on macOS.

This change doesn't affect filesystems that support `file_time_type` range only
for in-memory file time representation but not for on-disk representation. Such
filesystems are considered as `SupportsMinTime`.

rdar://problem/35865151

Reviewers: EricWF, Hahnfeld

Subscribers: jkorous-apple, mclow.lists, cfe-commits, christof

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

llvm-svn: 326383

6 years agoUse DenseMap::lookup() instead of find() and a hand-written null check.
Rui Ueyama [Wed, 28 Feb 2018 23:03:06 +0000 (23:03 +0000)]
Use DenseMap::lookup() instead of find() and a hand-written null check.

llvm-svn: 326382

6 years agobuild: add the ability to create a symlink for dsymutil
Saleem Abdulrasool [Wed, 28 Feb 2018 23:00:50 +0000 (23:00 +0000)]
build: add the ability to create a symlink for dsymutil

Add a `LLVM_INSTALL_CCTOOLS_SYMLINKS` to mirror
`LLVM_INSTALL_BINUTILS_SYMLINKS`.  For now, this allows us to create
symlinks for `dsymutil` to `llvm-dsymutil`.  This option is off by
default, but the user can enable it.

llvm-svn: 326381

6 years ago[X86] Regenerate cmpxchg tests
Simon Pilgrim [Wed, 28 Feb 2018 22:57:23 +0000 (22:57 +0000)]
[X86] Regenerate cmpxchg tests

Add 64-bit cmpxchg8b tests

llvm-svn: 326380

6 years ago[WebAssembly] Reduce code repetition. NFC.
Rui Ueyama [Wed, 28 Feb 2018 22:51:51 +0000 (22:51 +0000)]
[WebAssembly] Reduce code repetition. NFC.

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

llvm-svn: 326379

6 years agoFix up the gtest targets for changes in the UnwindAssembly tests.
Jim Ingham [Wed, 28 Feb 2018 22:41:11 +0000 (22:41 +0000)]
Fix up the gtest targets for changes in the UnwindAssembly tests.

llvm-svn: 326378

6 years ago[InstCombine] simplify code for X * -1.0 --> -X; NFC
Sanjay Patel [Wed, 28 Feb 2018 22:30:04 +0000 (22:30 +0000)]
[InstCombine] simplify code for X * -1.0 --> -X; NFC

I've added random FMF to one of the tests to show those are propagated.

llvm-svn: 326377

6 years ago[GlobalOpt] don't change CC of musttail calle(e|r)
Jonas Devlieghere [Wed, 28 Feb 2018 22:28:44 +0000 (22:28 +0000)]
[GlobalOpt] don't change CC of musttail calle(e|r)

When the function has musttail call - its cc is fixed to be equal to the
cc of the musttail callee. In such case (and in the case of the musttail
callee), GlobalOpt should not change the cc to fastcc as it will break
the invariant.

This fixes PR36546

Patch by: Fedor Indutny (indutny)

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

llvm-svn: 326376

6 years ago[X86] Lower extract_element from k-registers by bitcasting from v16i1 to i16 and...
Craig Topper [Wed, 28 Feb 2018 22:23:55 +0000 (22:23 +0000)]
[X86] Lower extract_element from k-registers by bitcasting from v16i1 to i16 and extending/truncating.

This is equivalent to what isel was doing anyway but by canonicalizing earlier we can remove some patterns.

llvm-svn: 326375

6 years agoAdd ability to collect memory limit.
Han Ming Ong [Wed, 28 Feb 2018 22:18:45 +0000 (22:18 +0000)]
Add ability to collect memory limit.

Reviewer: Jason Molenda

<rdar://problem/37686560>

llvm-svn: 326374

6 years ago[hwasan] update the asm snippet in the docs to match the current default behaviour
Kostya Serebryany [Wed, 28 Feb 2018 21:58:19 +0000 (21:58 +0000)]
[hwasan] update the asm snippet in the docs to match the current default behaviour

llvm-svn: 326373

6 years ago[X86][AVX512] Improve support for signed saturation truncation stores
Simon Pilgrim [Wed, 28 Feb 2018 21:42:19 +0000 (21:42 +0000)]
[X86][AVX512] Improve support for signed saturation truncation stores

Matches what we already manage for unsigned saturation truncation stores

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

llvm-svn: 326372

6 years agoMake sure that clang-format doesn't reorder include files.
Rui Ueyama [Wed, 28 Feb 2018 21:32:24 +0000 (21:32 +0000)]
Make sure that clang-format doesn't reorder include files.

clang-format won't reorder include files if there is a blank line.
Thanks to Nico for the tips.

llvm-svn: 326371

6 years agoAttempt to fix cl-include.c on Windows.
Nico Weber [Wed, 28 Feb 2018 20:58:06 +0000 (20:58 +0000)]
Attempt to fix cl-include.c on Windows.

llvm-svn: 326370

6 years agoAdapt some tests to work with PPC64le architecture
Pavel Labath [Wed, 28 Feb 2018 20:57:26 +0000 (20:57 +0000)]
Adapt some tests to work with PPC64le architecture

Summary: Merge branch 'master' into adaptPPC64tests

Reviewers: clayborg, alexandreyy, labath

Reviewed By: clayborg, alexandreyy

Subscribers: luporl, lbianc, alexandreyy, lldb-commits

Differential Revision: https://reviews.llvm.org/D42917
Patch by Ana Julia Caetano <ana.caetano@eldorado.org.br>.

llvm-svn: 326369

6 years ago[OpenMP] Extend NVPTX SPMD implementation of combined constructs
Carlo Bertolli [Wed, 28 Feb 2018 20:48:35 +0000 (20:48 +0000)]
[OpenMP] Extend NVPTX SPMD implementation of combined constructs

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

This patch extends the SPMD implementation to all target constructs and guards this implementation under a new flag.

llvm-svn: 326368

6 years agoRevert "[lldb] Use vFlash commands when writing to target's flash memory regions"
Pavel Labath [Wed, 28 Feb 2018 20:42:29 +0000 (20:42 +0000)]
Revert "[lldb] Use vFlash commands when writing to target's flash memory regions"

This reverts commit r326261 as it introduces inconsistencies in the
handling of load addresses for ObjectFileELF -- some parts of the class
use physical addresses, and some use virtual. This has manifested itself
as us not being able to set the load address of the vdso "module" on
android.

llvm-svn: 326367

6 years ago[Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19
Krzysztof Parzyszek [Wed, 28 Feb 2018 20:31:55 +0000 (20:31 +0000)]
[Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19

llvm-svn: 326366

6 years ago[clangd] Try to fix failures on clang-x64-ninja-win7 build bot.
Eric Liu [Wed, 28 Feb 2018 20:31:00 +0000 (20:31 +0000)]
[clangd] Try to fix failures on clang-x64-ninja-win7 build bot.

llvm-svn: 326365

6 years ago[Hexagon] Implement target feature +reserved-r19
Krzysztof Parzyszek [Wed, 28 Feb 2018 20:29:36 +0000 (20:29 +0000)]
[Hexagon] Implement target feature +reserved-r19

llvm-svn: 326364

6 years agoWrite some tests as linker scripts instead of assembly files.
Rui Ueyama [Wed, 28 Feb 2018 20:22:42 +0000 (20:22 +0000)]
Write some tests as linker scripts instead of assembly files.

Some linker script test cases contain only a few lines of assembly
and a long linker script. Such tests are easier to maintain if we
write the main test file as a linkier script instead of assembly.

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

llvm-svn: 326363

6 years agoCodeGenObjCXX: handle inalloca appropriately for msgSend variant
Saleem Abdulrasool [Wed, 28 Feb 2018 20:16:12 +0000 (20:16 +0000)]
CodeGenObjCXX: handle inalloca appropriately for msgSend variant

objc_msgSend_stret takes a hidden parameter for the returned structure's
address for the construction.  When the function signature is rewritten
for the inalloca passing, the return type is no longer marked as
indirect but rather inalloca stret.  This enhances the test for the
indirect return to check for that case as well.  This fixes the
incorrect return classification for Windows x86.

llvm-svn: 326362

6 years ago[InstCombine] Split the FP constant code out of lookThroughFPExtensions and use nullp...
Craig Topper [Wed, 28 Feb 2018 20:14:34 +0000 (20:14 +0000)]
[InstCombine] Split the FP constant code out of lookThroughFPExtensions and use nullptr as a sentinel

Currently this code's control flow very much assumes that there are no meaningful checks after determining that it's a ConstantFP. So whenever it wants to stop it just does "return V". But V is also the variable name it uses when it wants to return a new value. So 'return V' appears multiple times with different meanings.

This patch just moves all the code into a helper function and returns nullptr when it wants to stop.

I've split this from D43774 while I try to figure out how to best handle the vector case there. But this change by itself at least seemed like a readability improvement.

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

llvm-svn: 326361

6 years agoAttempt to build breakage caused by r326339.
Rui Ueyama [Wed, 28 Feb 2018 20:11:33 +0000 (20:11 +0000)]
Attempt to build breakage caused by r326339.

clang-format automatically sorted the #include lines, but I believe
Windows.h needs to be included before Dbghelp.h.

llvm-svn: 326360

6 years agoLosen time contraint to accommodate system loads
Lei Huang [Wed, 28 Feb 2018 20:05:24 +0000 (20:05 +0000)]
Losen time contraint to accommodate system loads

llvm-svn: 326359

6 years agoFix llvm-config --system-libs output on FreeBSD and NetBSD
Dimitry Andric [Wed, 28 Feb 2018 20:04:21 +0000 (20:04 +0000)]
Fix llvm-config --system-libs output on FreeBSD and NetBSD

Summary:
For various reasons, CMake's detection mechanism for `backtrace()`
returns an absolute path `/usr/lib/libexecinfo.so` on FreeBSD and
NetBSD.

Since `tools/llvm-config/CMakeLists.txt` only checks if system
libraries start with `-`, this causes `llvm-config --system-libs` to
produce the following incorrect output:

```
-lrt -l/usr/lib/libexecinfo.so -ltinfo -lpthread -lz -lm
```

Fix it by removing the path and the `lib` prefix, to make it look like a
regular short library name, suitable for appending to a `-l` link flag.

This also fixes the `Bindings/Go/go.test` test case, since that always
died with "unable to find library -l/usr/lib/libexecinfo.so".

Reviewers: chandlerc, emaste, joerg, krytarowski

Reviewed By: krytarowski

Subscribers: hans, bdrewery, mgorny, hintonda, llvm-commits

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

llvm-svn: 326358

6 years ago[clang-cl] Implement /X
Nico Weber [Wed, 28 Feb 2018 19:49:07 +0000 (19:49 +0000)]
[clang-cl] Implement /X

/X makes cl stop looking in %INCLUDE%. Implement this for clang-cl.

As it turns out, the return in ToolChains/MSVC.cpp, AddClangSystemIncludeArgs()
for -nostdlibinc is already in the right place (but -nostdlibinc isn't exposed
by clang-cl), so just alias /X to that.

https://reviews.llvm.org/D43888

llvm-svn: 326357

6 years ago[WebAssembly] Remove unneeded --no-gc-sections flag from tests. NFC.
Sam Clegg [Wed, 28 Feb 2018 19:40:03 +0000 (19:40 +0000)]
[WebAssembly] Remove unneeded --no-gc-sections flag from tests. NFC.

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

llvm-svn: 326356

6 years agoFix gcc -Wreturn-type warnings after r326307.
Nico Weber [Wed, 28 Feb 2018 19:28:47 +0000 (19:28 +0000)]
Fix gcc -Wreturn-type warnings after r326307.

llvm-svn: 326355

6 years ago[Documentation] Split Clang-tidy changes in Release Notes into sections: new checks...
Eugene Zelenko [Wed, 28 Feb 2018 19:15:49 +0000 (19:15 +0000)]
[Documentation] Split Clang-tidy changes in Release Notes into sections: new checks, new aliases, renamed checks; sort all of them alphabetically. Enforce 80 characters line length limit. Highlight C++ keywords.

llvm-svn: 326354

6 years ago[AMDGPU] added writelane intrinsic
Tim Renouf [Wed, 28 Feb 2018 19:10:32 +0000 (19:10 +0000)]
[AMDGPU] added writelane intrinsic

Summary:
For use by LLPC SPV_AMD_shader_ballot extension.

The v_writelane instruction was already implemented for use by SGPR
spilling, but I had to add an extra dummy operand tied to the
destination, to represent that all lanes except the selected one keep
the old value of the destination register.

.ll test changes were due to schedule changes caused by that new
operand.

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

llvm-svn: 326353

6 years agoFixed spelling mistake in comments of LLVM Analysis passes
Vedant Kumar [Wed, 28 Feb 2018 19:08:52 +0000 (19:08 +0000)]
Fixed spelling mistake in comments of LLVM Analysis passes

Patch by Reshabh Sharma!

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

llvm-svn: 326352

6 years ago[profile] Test the exported symbol set for empty programs
Vedant Kumar [Wed, 28 Feb 2018 19:00:16 +0000 (19:00 +0000)]
[profile] Test the exported symbol set for empty programs

Programs without any code in them should export the exact same set of
symbols as programs with code, at least on Darwin. This is done to make
text-based API verification possible for certain Darwin frameworks.

llvm-svn: 326351

6 years ago[InstrProfiling] Emit the runtime hook when no counters are lowered
Vedant Kumar [Wed, 28 Feb 2018 19:00:08 +0000 (19:00 +0000)]
[InstrProfiling] Emit the runtime hook when no counters are lowered

The API verification tool tapi has difficulty processing frameworks
which enable code coverage, but which have no code. The profile lowering
pass does not emit the runtime hook in this case because no counters are
lowered.

While the hook is not needed for program correctness (the profile
runtime doesn't have to be linked in), it's needed to allow tapi to
validate the exported symbol set of instrumented binaries.

It was not possible to add a workaround in tapi for empty binaries due
to an architectural issue: tapi generates its expected symbol set before
it inspects a binary. Changing that model has a higher cost than simply
forcing llvm to always emit the runtime hook.

rdar://36076904

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

llvm-svn: 326350

6 years ago[NVPTX] Removed always-true predicates in NVPTX.
Artem Belevich [Wed, 28 Feb 2018 18:51:22 +0000 (18:51 +0000)]
[NVPTX] Removed always-true predicates in NVPTX.

NVPTX stopped supporting GPUs older than sm_20 (Fermi) quite a while back.
Removal of support of pre-Fermi GPUs made a lot of predicates in the NVPTX
backend pointless as they can't ever be false any more.
It's time to retire them. NFC intended.

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

llvm-svn: 326349

6 years agoAdd "%" operator to the linker script.
Rui Ueyama [Wed, 28 Feb 2018 18:38:13 +0000 (18:38 +0000)]
Add "%" operator to the linker script.

This patch improves compatibility with GNU linkers.

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

llvm-svn: 326348

6 years agoInline a trivial function. NFC.
Rui Ueyama [Wed, 28 Feb 2018 18:25:00 +0000 (18:25 +0000)]
Inline a trivial function. NFC.

llvm-svn: 326347

6 years ago[RISCV] Force enable int128 for compiling long double routines
Mandeep Singh Grang [Wed, 28 Feb 2018 18:24:09 +0000 (18:24 +0000)]
[RISCV] Force enable int128 for compiling long double routines

Summary:
For RISCV32, we must force enable int128 for compiling long double routines using the flag -fforce-enable-int128.

Related clang patch: https://reviews.llvm.org/D43105

Reviewers: asb, kito-cheng, apazos, compnerd, howard.hinnant

Reviewed By: kito-cheng

Subscribers: shiva0217, efriedma, mgorny, hintonda, llvm-commits, #sanitizers

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

llvm-svn: 326346

6 years agoFix use after free in PDB linker.
Zachary Turner [Wed, 28 Feb 2018 18:09:18 +0000 (18:09 +0000)]
Fix use after free in PDB linker.

When merging in types from a type server PDB, we would use a
pointer into the type server PDB's mapped file buffer directly
to avoid copying data.  However, we would close the type server
PDB after we finished merging in its types, which would unmap
all of its memory.  This would lead to a use after free.

We fix this by making a strong reference in the PDBLinker class
to all referenced type server PDBs, thereby making it safe to
hold pointers into its memory mapped contents.

This fixes llvm.org/pr36455

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

llvm-svn: 326345

6 years agoSimplify. NFC.
Rafael Espindola [Wed, 28 Feb 2018 18:05:37 +0000 (18:05 +0000)]
Simplify. NFC.

llvm-svn: 326344

6 years ago[GlobalISel] Print/Parse FailedISel MachineFunction property
Roman Tereshin [Wed, 28 Feb 2018 17:55:45 +0000 (17:55 +0000)]
[GlobalISel] Print/Parse FailedISel MachineFunction property

FailedISel MachineFunction property is part of the CodeGen pipeline
state as much as every other property, notably, Legalized,
RegBankSelected, and Selected. Let's make that part of the state also
serializable / de-serializable, so if GlobalISel aborts on some of the
functions of a large module, but not the others, it could be easily seen
and the state of the pipeline could be maintained through llc's
invocations with -stop-after / -start-after.

To make MIR printable and generally to not to break it too much too
soon, this patch also defers cleaning up the vreg -> LLT map until
ResetMachineFunctionPass.

To make MIR with FailedISel: true also machine verifiable, machine
verifier is changed so it treats a MIR-module as non-regbankselected and
non-selected if there is FailedISel property set.

Reviewers: qcolombet, ab

Reviewed By: dsanders

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

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

llvm-svn: 326343

6 years ago[CUDA] Include single GPU binary, NFCI.
Jonas Hahnfeld [Wed, 28 Feb 2018 17:53:46 +0000 (17:53 +0000)]
[CUDA] Include single GPU binary, NFCI.

Binaries for multiple architectures are combined by fatbinary,
so the current code was effectively not needed.

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

llvm-svn: 326342

6 years ago[TLS] use emulated TLS if the target supports only this mode
Chih-Hung Hsieh [Wed, 28 Feb 2018 17:48:55 +0000 (17:48 +0000)]
[TLS] use emulated TLS if the target supports only this mode

Emulated TLS is enabled by llc flag -emulated-tls,
which is passed by clang driver.
When llc is called explicitly or from other drivers like LTO,
missing -emulated-tls flag would generate wrong TLS code for targets
that supports only this mode.
Now use useEmulatedTLS() instead of Options.EmulatedTLS to decide whether
emulated TLS code should be generated.
Unit tests are modified to run with and without the -emulated-tls flag.

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

llvm-svn: 326341

6 years ago[WebAssembly] Use toArrayRef. NFC.
Rui Ueyama [Wed, 28 Feb 2018 17:43:15 +0000 (17:43 +0000)]
[WebAssembly] Use toArrayRef. NFC.

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

llvm-svn: 326340

6 years agoMerge {COFF,ELF}/Strings.cpp to Common/Strings.cpp.
Rui Ueyama [Wed, 28 Feb 2018 17:38:19 +0000 (17:38 +0000)]
Merge {COFF,ELF}/Strings.cpp to Common/Strings.cpp.

This should resolve the issue that lld build fails in some hosts
that uses case-insensitive file system.

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

llvm-svn: 326339

6 years ago[OMPT] Fix ompt_get_task_info() and add tests for it
Joachim Protze [Wed, 28 Feb 2018 17:36:18 +0000 (17:36 +0000)]
[OMPT] Fix ompt_get_task_info() and add tests for it

The thread_num parameter of ompt_get_task_info() was not being used previously,
but need to be set.

The print_task_type() function (form the task-types.c testcase) was merged into
the print_ids() function (in callback.h). Testing of ompt_get_task_info() was
added to the task-types.c testcase. It was not tested extensively previously.

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

llvm-svn: 326338

6 years ago[WebAssembly] Return a StringRef instead of std::string from getSectionName(). NFC.
Rui Ueyama [Wed, 28 Feb 2018 17:33:04 +0000 (17:33 +0000)]
[WebAssembly] Return a StringRef instead of std::string from getSectionName(). NFC.

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

llvm-svn: 326337

6 years ago[WebAssembly] Improve WasmSignatureDenseMapInfo.
Rui Ueyama [Wed, 28 Feb 2018 17:32:50 +0000 (17:32 +0000)]
[WebAssembly] Improve WasmSignatureDenseMapInfo.

Let X and Y be types. Previously, functions F(X, Y) and G(Y, X) had
the same hash value because their hash values are computed as follows:

  hash(F) = hash(X) + hash(Y)
  hash(G) = hash(Y) + hash(X)

This patch fixes the issue by using hash_combine.

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

llvm-svn: 326336

6 years ago[WebAssembly] Reorder symbol table to match MC order
Nicholas Wilson [Wed, 28 Feb 2018 17:20:51 +0000 (17:20 +0000)]
[WebAssembly] Reorder symbol table to match MC order

Update LLD test expectations for new symbol ordering introduced by
Differential D43685.

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

llvm-svn: 326335

6 years ago[WebAssembly] Reorder symbol table to match MC order
Nicholas Wilson [Wed, 28 Feb 2018 17:19:48 +0000 (17:19 +0000)]
[WebAssembly] Reorder symbol table to match MC order

This removes a TODO introduced in rL325860

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

llvm-svn: 326334

6 years ago[ARM] Lower lower saturate to 0 and lower saturate to -1 using bit-operations
Pablo Barrio [Wed, 28 Feb 2018 17:13:07 +0000 (17:13 +0000)]
[ARM] Lower lower saturate to 0 and lower saturate to -1 using bit-operations

Summary:
Expressions of the form x < 0 ? 0 :  x; and x < -1 ? -1 : x can be lowered using bit-operations instead of branching or conditional moves

In thumb-mode this results in a two-instruction sequence, a shift followed by a bic or or while in ARM/thumb2 mode that has flexible second operand the shift can be folded into a single bic/or instructions. In most cases this results in smaller code and possibly less branches, and in no case larger than before.

Patch by Martin Svanfeldt

Reviewers: fhahn, pbarrio, rogfer01

Reviewed By: pbarrio, rogfer01

Subscribers: chrib, yroux, eugenis, efriedma, rogfer01, aemerson, javed.absar, kristof.beyls, llvm-commits

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

llvm-svn: 326333

6 years agoTest commit access: apply clang-format suggestion
Joel E. Denny [Wed, 28 Feb 2018 16:57:33 +0000 (16:57 +0000)]
Test commit access: apply clang-format suggestion

llvm-svn: 326332

6 years ago[InstCombine] auto-generate complete checks; NFC
Sanjay Patel [Wed, 28 Feb 2018 16:53:45 +0000 (16:53 +0000)]
[InstCombine] auto-generate complete checks; NFC

llvm-svn: 326331

6 years ago[InstCombine] move invariant call out of loop; NFC
Sanjay Patel [Wed, 28 Feb 2018 16:50:51 +0000 (16:50 +0000)]
[InstCombine] move invariant call out of loop; NFC

We really shouldn't need a 2-loop here at all, but that's another cleanup.

llvm-svn: 326330

6 years ago[InstCombine] move constant check into foldBinOpIntoSelectOrPhi; NFCI
Sanjay Patel [Wed, 28 Feb 2018 16:36:24 +0000 (16:36 +0000)]
[InstCombine] move constant check into foldBinOpIntoSelectOrPhi; NFCI

Also, rename 'foldOpWithConstantIntoOperand' because that's annoyingly
vague. The constant check is redundant in some cases, but it allows
removing duplication for most of the calls.

llvm-svn: 326329

6 years ago[DEBUGINFO] Add flag for DWARF2 or less to use sections as references.
Alexey Bataev [Wed, 28 Feb 2018 15:02:59 +0000 (15:02 +0000)]
[DEBUGINFO] Add flag for DWARF2 or less to use sections as references.

Summary:
Some targets does not support labels inside debug sections, but support
references in form `section +|- offset`. Patch adds initial support
for this. Also, this patch disables emission of all additional debug
  sections that may have labels inside of it (like pub sections and
  string tables).

Reviewers: probinson, echristo

Subscribers: JDevlieghere, llvm-commits

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

llvm-svn: 326328