platform/upstream/llvm.git
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

6 years agoRename a few checks from misc- to bugprone-.
Alexander Kornienko [Wed, 28 Feb 2018 14:47:20 +0000 (14:47 +0000)]
Rename a few checks from misc- to bugprone-.

Summary:
rename_check.py {misc,bugprone}-forwarding-reference-overload
rename_check.py {misc,bugprone}-macro-repeated-side-effects
rename_check.py {misc,bugprone}-lambda-function-name
rename_check.py {misc,bugprone}-misplaced-widening-cast

Reviewers: hokein, sammccall, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: klimek, cfe-commits, mgorny

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

llvm-svn: 326327

6 years ago[WebAssembly] Fix copy-paste error in debugging string
Nicholas Wilson [Wed, 28 Feb 2018 14:03:18 +0000 (14:03 +0000)]
[WebAssembly] Fix copy-paste error in debugging string

llvm-svn: 326326

6 years ago[clangd] A few more fixes for STL header mapping.
Eric Liu [Wed, 28 Feb 2018 14:02:18 +0000 (14:02 +0000)]
[clangd] A few more fixes for STL header mapping.

llvm-svn: 326325

6 years ago[analyzer] Fix a compiler warning
Gabor Horvath [Wed, 28 Feb 2018 14:01:48 +0000 (14:01 +0000)]
[analyzer] Fix a compiler warning

llvm-svn: 326324

6 years ago[analyzer] Support for naive cross translation unit analysis
Gabor Horvath [Wed, 28 Feb 2018 13:23:10 +0000 (13:23 +0000)]
[analyzer] Support for naive cross translation unit analysis

The aim of this patch is to be minimal to enable incremental development of
the feature on the top of the tree. This patch should be an NFC when the
feature is turned off. It is turned off by default and still considered as
experimental.

Technical details are available in the EuroLLVM Talk:
http://llvm.org/devmtg/2017-03//2017/02/20/accepted-sessions.html#7

Note that the initial prototype was done by A. Sidorin et al.: http://lists.llvm.org/pipermail/cfe-dev/2015-October/045730.html

Contributions to the measurements and the new version of the code: Peter Szecsi, Zoltan Gera, Daniel Krupp, Kareem Khazem.

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

llvm-svn: 326323

6 years ago[mips] Begin reworking instruction predicates for ISAs/encodings (1/N)
Simon Dardis [Wed, 28 Feb 2018 13:02:44 +0000 (13:02 +0000)]
[mips] Begin reworking instruction predicates for ISAs/encodings (1/N)

The MIPS backend has inconsistent usage of instruction predicates
for assembly and code generation. The issue arises from supporting three
encodings, two (MIPS and microMIPS) of which have a near 1:1 instruction
mapping across ISA revisions and a third encoding with a more restricted
set of instructions (MIPS16e).

To enforce consistent usage, each of the ISA_* adjectives has (or will
have) the relevant encoding attached to it along the relevant ISA revision
where the instruction is defined.

Each instruction, pattern or alias will then have the correct ISA adjective
attached to it, and the base instruction description classes will have any
predicates relating to ISA encoding or revision removed.

Pseudo instructions will also be guarded for the encoding or ABI that they are
supported in.

Finally, the hasStandardEncoding() / inMicroMipsMode() / inMips16Mode() methods
of MipsSubtarget will be changed such that only one can be true at any one time.

The result of this is that code generation and assembly will produce the
correct encoding up front, while code generated from pseudo instructions
and other inserted sequences of instructions will be able to rely on the mapping
tables to produce the correct encoding. This should fix numerous bugs where
the result 'happens' to be correct but has edge cases where microMIPS and MIPS
have subtle differences (e.g. microMIPSR6 using 'j', 'jal' instructions.)

This patch starts the process by changing most of the ISA adjectives to make
use of the EncodingPredicate member of PredicateControl. Follow on patches
will annotate instructions with their correct ISA adjective and eliminate
the usage of "let Predicates = [..]", "let AdditionalPredicates = [..]" and
"isCodeGenOnly = 1" in the cases where it was used to control instruction
availability.

Contributions from Nitesh Jain.

Reviewers: atanasyan

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

llvm-svn: 326322

6 years ago[clang-tidy] Fix 'add_new_check.py --udpate-docs'
Alexander Kornienko [Wed, 28 Feb 2018 12:21:38 +0000 (12:21 +0000)]
[clang-tidy] Fix 'add_new_check.py --udpate-docs'

llvm-svn: 326321

6 years ago[GlobalIsel][X86] Support G_INTTOPTR instruction.
Alexander Ivchenko [Wed, 28 Feb 2018 12:11:53 +0000 (12:11 +0000)]
[GlobalIsel][X86] Support G_INTTOPTR instruction.

Add legalization/selection for x86/x86_64 and
corresponding tests.

Reviewed By: igorb

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

llvm-svn: 326320

6 years agoFix typo. NFC
Xin Tong [Wed, 28 Feb 2018 12:09:53 +0000 (12:09 +0000)]
Fix typo. NFC

llvm-svn: 326319

6 years ago[MergeICmp] Fix a bug in MergeICmp that can lead to a block being processed more...
Xin Tong [Wed, 28 Feb 2018 12:08:00 +0000 (12:08 +0000)]
[MergeICmp] Fix a bug in MergeICmp that can lead to a block being processed more than once.

Summary:
Fix a bug in MergeICmp that can lead to a BCECmp block being processed more than once and eventually lead to a broken LLVM module.
The problem is that if the non-constant value is not produced by the last block, the producer will be processed once when the its parent block
is processed and second time when the last block is processed.

We end up having 2 same BCECmpBlock in the merge queue. And eventually lead to a broken LLVM module.

Reviewers: courbet, davide

Reviewed By: courbet

Subscribers: llvm-commits

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

llvm-svn: 326318

6 years ago[IR] - Make User construction exception safe
Klaus Kretzschmar [Wed, 28 Feb 2018 11:32:23 +0000 (11:32 +0000)]
[IR] - Make User construction exception safe

There are many instruction ctors that call the setName method of the Value base class, which can throw a bad_alloc exception in OOM situations.
In such situations special User delete operators are called which are not implemented yet.

Example:
 Lets look at the construction of a CallInst instruction during IR generation:

static CallInst *Create(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args, .. ){
...

return new (TotalOps, DescriptorBytes) CallInst(Ty, Func, Args, Bundles, NameStr, InsertBefore);

}

CallInst::CalInst(Value* Func, ...) {
...
Op<-1>() = Func;
....
setName(name); // throws
...
}
Op<-1>() returns a reference to a Use object of the CallInst instruction and the operator= inserts this use object into the UseList of Func.
The same object is removed from that UseList by calling the User::operator delete If the CallInst object is deleted.
Since setName can throw a bad_alloc exception (if LLVM_ENABLE_EXCEPTIONS is switched on), the unwind chain runs into assertions ("Constructor throws?") in
special User::operator deletes operators:

operator delete(void* Usr, unsigned)
operator delete(void* Usr, unsigned, bool)
This situation can be fixed by simlpy calling the User::operator delete(void*) in these unimplemented methods.

To ensure that this additional call succeeds all information that is necessary to calculate the storage pointer from the Usr address
must be restored in the special case that a sublass has changed this information, e.g. GlobalVariable can change the NumberOfOperands.

Reviewd by: rnk

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

llvm-svn: 326316

6 years ago[Dominators] Remove verifyDomTree and add some verifying for Post Dom Trees
David Green [Wed, 28 Feb 2018 11:00:08 +0000 (11:00 +0000)]
[Dominators] Remove verifyDomTree and add some verifying for Post Dom Trees

Removes verifyDomTree, using assert(verify()) everywhere instead, and
changes verify a little to always run IsSameAsFreshTree first in order
to print good output when we find errors. Also adds verifyAnalysis for
PostDomTrees, which will allow checking of PostDomTrees it the same way
we check DomTrees and MachineDomTrees.

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

llvm-svn: 326315

6 years ago[clang-tidy] Add a test for readability-implicit-bool-conversion with bitfields.
Alexander Kornienko [Wed, 28 Feb 2018 10:30:25 +0000 (10:30 +0000)]
[clang-tidy] Add a test for readability-implicit-bool-conversion with bitfields.

llvm-svn: 326314

6 years ago[clangd] Prefer the definition of a TagDecl (e.g. class) as CanonicalDeclaration.
Eric Liu [Wed, 28 Feb 2018 09:33:15 +0000 (09:33 +0000)]
[clangd] Prefer the definition of a TagDecl (e.g. class) as CanonicalDeclaration.

Summary:
Currently, we pick the first declaration of a symbol in a TU, which is considered
canonical in the clangIndex, as the canonical declaration in clangd. This causes
forward declarations that might appear in a random header to be used as a
canonical declaration, which is not desirable for features like go-to-declaration
or include insertion.

For example, for class X, we would consider the forward declaration in fwd.h to
be the canonical declaration, while the preferred canonical declaration should
be the actual definition in x.h.
```
// fwd.h
class X;  // forward decl

// x.h
class X {};
```

This patch fixes the issue by making symbol collector favor the actual definition of
a TagDecl (i.e. class/struct/enum/union) found in a header file over the first seen
declarations in a TU. Other symbol types like functions are not handled because
using the first seen declarations as canonical declarations is usually a good
heuristic for them.

Reviewers: sammccall

Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits

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

llvm-svn: 326313

6 years ago[OMPT] Fix inconsistent testcases
Joachim Protze [Wed, 28 Feb 2018 09:28:51 +0000 (09:28 +0000)]
[OMPT] Fix inconsistent testcases

The main change of this patch is to insert {{.*}} in current_address=[[RETURN_ADDRESS_END]].
This is needed to match any of the alternatively printed addresses.

Additionally, clang-format is applied to the two tests.

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

llvm-svn: 326312

6 years ago[GlobalIsel][X86] Support G_PTRTOINT instruction.
Alexander Ivchenko [Wed, 28 Feb 2018 09:18:47 +0000 (09:18 +0000)]
[GlobalIsel][X86] Support G_PTRTOINT instruction.

Add legalization/selection for x86/x86_64 and
corresponding tests.

Reviewed By: igorb

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

llvm-svn: 326311

6 years ago[clangd] A few minor fixes for STL internal header mapping.
Eric Liu [Wed, 28 Feb 2018 08:56:11 +0000 (08:56 +0000)]
[clangd] A few minor fixes for STL internal header mapping.

llvm-svn: 326310

6 years ago[RISCV] Update two tests after r326208
Alex Bradbury [Wed, 28 Feb 2018 08:20:47 +0000 (08:20 +0000)]
[RISCV] Update two tests after r326208

llvm-svn: 326309

6 years ago[X86] Don't use EXTRACT_ELEMENT from v1i1 with i8/i32 result type when we need to...
Craig Topper [Wed, 28 Feb 2018 08:14:28 +0000 (08:14 +0000)]
[X86] Don't use EXTRACT_ELEMENT from v1i1 with i8/i32 result type when we need to guarantee zeroes in the upper bits of return.

An extract_element where the result type is larger than the scalar element type is semantically an any_extend of from the scalar element type to the result type. If we expect zeroes in the upper bits of the i8/i32 we need to mae sure those zeroes are explicit in the DAG.

For these cases the best way to accomplish this is use an insert_subvector to pad zeroes to the upper bits of the v1i1 first. We extend to either v16i1(for i32) or v8i1(for i8). Then bitcast that to a scalar and finish with a zero_extend up to i32 if necessary. We can't extend past v16i1 because that's the largest mask size on KNL. But isel is smarter enough to know that a zext of a bitcast from v16i1 to i16 can use a KMOVW instruction. The insert_subvectors will be dropped during isel because we can determine that the producing instruction already zeroed the upper bits of the k-register.

llvm-svn: 326308

6 years ago[ObjC] Allow declaring __strong pointer fields in structs in Objective-C
Akira Hatanaka [Wed, 28 Feb 2018 07:15:55 +0000 (07:15 +0000)]
[ObjC] Allow declaring __strong pointer fields in structs in Objective-C
ARC mode.

Declaring __strong pointer fields in structs was not allowed in
Objective-C ARC until now because that would make the struct non-trivial
to default-initialize, copy/move, and destroy, which is not something C
was designed to do. This patch lifts that restriction.

Special functions for non-trivial C structs are synthesized that are
needed to default-initialize, copy/move, and destroy the structs and
manage the ownership of the objects the __strong pointer fields point
to. Non-trivial structs passed to functions are destructed in the callee
function.

rdar://problem/33599681

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

llvm-svn: 326307

6 years ago[X86] Change the masked FPCLASS implementation to use AND instead of OR to combine...
Craig Topper [Wed, 28 Feb 2018 06:19:55 +0000 (06:19 +0000)]
[X86] Change the masked FPCLASS implementation to use AND instead of OR to combine the mask results.

While the description for the instruction does mention OR, its talking about how the individual classification test results are ORed together.

The incoming mask is used as a zeroing write mask. If the bit is 1 the classification is written to the output. The bit is 0 the output is 0. This equivalent to an AND.

Here is pseudocode from the intrinsics guide

FOR j := 0 to 1
        i := j*64
        IF k1[j]
                k[j] := CheckFPClass_FP64(a[i+63:i], imm8[7:0])
        ELSE
                k[j] := 0
        FI
ENDFOR
k[MAX:2] := 0

llvm-svn: 326306

6 years ago[ELF] Process linker scripts deeper when declaring symbols.
Igor Kudrin [Wed, 28 Feb 2018 05:55:56 +0000 (05:55 +0000)]
[ELF] Process linker scripts deeper when declaring symbols.

We should process symbols inside output section declarations the same way as top-level ones.

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

llvm-svn: 326305

6 years ago[ARM] Cortex-A57 scheduler fix for ARM backend (missed 16-bit, v8.1/v8.2/v8.3, thumb...
Andrew Zhogin [Wed, 28 Feb 2018 05:53:18 +0000 (05:53 +0000)]
[ARM] Cortex-A57 scheduler fix for ARM backend (missed 16-bit, v8.1/v8.2/v8.3, thumb and pseudo instructions)

Added missed scheduling info for ARM Cortex A57 (AArch32) to have CompleteModel with this checkCompleteness fix: https://reviews.llvm.org/D43235.

Reviewed By: RKSimon

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

llvm-svn: 326304

6 years ago[SLP] Added new tests and updated existing for jumbled load, NFC.
Mohammad Shahid [Wed, 28 Feb 2018 04:19:34 +0000 (04:19 +0000)]
[SLP] Added new tests and updated existing for jumbled load, NFC.

llvm-svn: 326303

6 years agoAdd EmulateInstructionPPC64.cpp to xcode project file.
Jason Molenda [Wed, 28 Feb 2018 04:11:37 +0000 (04:11 +0000)]
Add EmulateInstructionPPC64.cpp to xcode project file.

llvm-svn: 326302

6 years ago[WebAssembly] Fix variable name.
Rui Ueyama [Wed, 28 Feb 2018 03:43:38 +0000 (03:43 +0000)]
[WebAssembly] Fix variable name.

llvm-svn: 326301

6 years ago[WebAssembly] Remove unnecessary namespace specifiers. NFC.
Rui Ueyama [Wed, 28 Feb 2018 03:38:14 +0000 (03:38 +0000)]
[WebAssembly] Remove unnecessary namespace specifiers. NFC.

llvm-svn: 326300

6 years agoFix a couple of cases where we would fail to correctly parse deduced class template...
Richard Smith [Wed, 28 Feb 2018 03:02:23 +0000 (03:02 +0000)]
Fix a couple of cases where we would fail to correctly parse deduced class template specialization types.

Specifically, we would not properly parse these types within template arguments
(for non-type template parameters), and in tentative parses. Fixing both of
these essentially requires that we parse deduced template specialization types
as types in all contexts, even in template argument lists -- in particular,
tentative parsing may look ahead and annotate a deduced template specialization
type before we figure out that we're actually supposed to treat the tokens as a
template-name. We deal with this by simply permitting deduced template
specialization types when parsing template arguments, and converting them to
template template arguments.

llvm-svn: 326299

6 years agoUpdate cxx_status to mark "SVN" items as "Clang 6" instead.
Richard Smith [Wed, 28 Feb 2018 03:02:07 +0000 (03:02 +0000)]
Update cxx_status to mark "SVN" items as "Clang 6" instead.

llvm-svn: 326298

6 years ago[WebAssembly] Simplify initializeSymbols and merge it with ObjFile::parse. NFC.
Rui Ueyama [Wed, 28 Feb 2018 02:57:37 +0000 (02:57 +0000)]
[WebAssembly] Simplify initializeSymbols and merge it with ObjFile::parse. NFC.

This patch simplifies initializeSymbols. Since that function is called
at the tail context of ObjFile::parse, and the function is called only
once from that function, that's effectively just a continuation of
ObjFile::parse. So this patch merge it with ObjFile::parse.

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

llvm-svn: 326296

6 years ago[analyzer] [tests] Write to logfile instead of stdout while updating
George Karpenkov [Wed, 28 Feb 2018 01:55:23 +0000 (01:55 +0000)]
[analyzer] [tests] Write to logfile instead of stdout while updating

reference results

llvm-svn: 326295

6 years ago[WebAssembly] Add test for `--undefined` flag. NFC.
Sam Clegg [Wed, 28 Feb 2018 01:42:16 +0000 (01:42 +0000)]
[WebAssembly] Add test for `--undefined` flag. NFC.

Specifically the case where the undefined symbol is not found
during the link.

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

llvm-svn: 326294

6 years ago[WebAssembly] Simplify Symbol::getWasmType. NFC.
Rui Ueyama [Wed, 28 Feb 2018 01:10:50 +0000 (01:10 +0000)]
[WebAssembly] Simplify Symbol::getWasmType. NFC.

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

llvm-svn: 326293

6 years ago[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings...
Eugene Zelenko [Wed, 28 Feb 2018 01:10:04 +0000 (01:10 +0000)]
[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 326292

6 years ago[WebAssembly] Inline translateVA as it's trivial.
Rui Ueyama [Wed, 28 Feb 2018 01:01:34 +0000 (01:01 +0000)]
[WebAssembly] Inline translateVA as it's trivial.

The problem I want to address now is that chunks have too many data
members for "offsets", and their origins are not well defined.
For example, InputSegment has OutputSegmentOffset, but it's base class
also has OutputOffset. That's very confusing.

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

llvm-svn: 326291

6 years ago[RuntimeDyld][MachO] Support ARM64_RELOC_BRANCH26 for BL instructions by
Lang Hames [Wed, 28 Feb 2018 00:58:21 +0000 (00:58 +0000)]
[RuntimeDyld][MachO] Support ARM64_RELOC_BRANCH26 for BL instructions by
relaxing an assertion.

llvm-svn: 326290

6 years ago[WebAssembly] Remove ELF-ness.
Rui Ueyama [Wed, 28 Feb 2018 00:57:28 +0000 (00:57 +0000)]
[WebAssembly] Remove ELF-ness.

These output section names are ELF-specific. We shouldn't have this rule
for WebAssembly.

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

llvm-svn: 326289

6 years agoupdate_mir_test_checks: Use the regexes from UpdateTestChecks.common
Justin Bogner [Wed, 28 Feb 2018 00:56:24 +0000 (00:56 +0000)]
update_mir_test_checks: Use the regexes from UpdateTestChecks.common

Some of the update_*_test_checks regexes have been moved into a
library, so we might as well use them in update_mir_test_checks.
Also includes minor bugfixes to the regexes that are there so we
don't regress update_mir_test_checks

llvm-svn: 326288

6 years ago[ELF] Rename test/ELF/note-loadaddr.c to .s NFC
Fangrui Song [Wed, 28 Feb 2018 00:53:51 +0000 (00:53 +0000)]
[ELF] Rename test/ELF/note-loadaddr.c to .s NFC

llvm-svn: 326287

6 years ago[WebAssembly] Do not use inheritance to define SubSection.
Rui Ueyama [Wed, 28 Feb 2018 00:52:42 +0000 (00:52 +0000)]
[WebAssembly] Do not use inheritance to define SubSection.

SubSection inherited from SyntheticSection, and SyntheticSection inherits
from OutputSection, so SubSection was an OutputSection. But that's wrong
because SubSection is not actually a WebAssembly output section.
It shares some functionalities with OutputSection, but overall it's very
different.

This patch removes that inheritance.

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

llvm-svn: 326286

6 years ago[WebAssembly] Refactor ObjFile::initializeSymbols.
Rui Ueyama [Wed, 28 Feb 2018 00:50:54 +0000 (00:50 +0000)]
[WebAssembly] Refactor ObjFile::initializeSymbols.

The main purpose of this change is to make initializeSymbols shorter.

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

llvm-svn: 326285

6 years agoupdate_mir_test_checks: Drop support for vreg block checks
Justin Bogner [Wed, 28 Feb 2018 00:44:46 +0000 (00:44 +0000)]
update_mir_test_checks: Drop support for vreg block checks

Since vregs are printed in the instruction stream now, checking the
vreg block is always redundant. Remove the temporary feature that
allowed us to do that.

This reverts r316134

llvm-svn: 326284

6 years ago[WebAssembly] Do not use Subsection as a local variable name.
Rui Ueyama [Wed, 28 Feb 2018 00:39:30 +0000 (00:39 +0000)]
[WebAssembly] Do not use Subsection as a local variable name.

That variable hides the class of the same name.

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

llvm-svn: 326283

6 years ago[WebAssembly] Do not use default arguments for SymbolTable.
Rui Ueyama [Wed, 28 Feb 2018 00:37:03 +0000 (00:37 +0000)]
[WebAssembly] Do not use default arguments for SymbolTable.

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

llvm-svn: 326282

6 years ago[WebAssembly] Do not remove existing output file.
Rui Ueyama [Wed, 28 Feb 2018 00:33:59 +0000 (00:33 +0000)]
[WebAssembly] Do not remove existing output file.

FileOutputBuffer automatically removes an existing file, so we don't
need to do that. Actually doing that is discouraged because when the
linker fails to create an output for some reason after instantiating
FileOutputBufffer, FileOutputBuffer removes a temporary file and don't
touch an existing file. That's an desired behavior from the user's
point of view.

(Internally, FileOutputBuffer writes its contents to a temporary file
and then rename it over to an existing file on commit()).

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

llvm-svn: 326281

6 years ago[WebAssembly] Remove redundant local variables.
Rui Ueyama [Wed, 28 Feb 2018 00:31:16 +0000 (00:31 +0000)]
[WebAssembly] Remove redundant local variables.

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

llvm-svn: 326280

6 years ago[WebAssembly] Simplify createLikingSection.
Rui Ueyama [Wed, 28 Feb 2018 00:28:07 +0000 (00:28 +0000)]
[WebAssembly] Simplify createLikingSection.

Summary: [WebAssembly] Simplify createLikingSection.

Reviewers: sbc100

Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits

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

llvm-svn: 326279

6 years agoAMDGPU: Move run and check lines around to match processor order in AMDGPU.h
Konstantin Zhuravlyov [Wed, 28 Feb 2018 00:27:00 +0000 (00:27 +0000)]
AMDGPU: Move run and check lines around to match processor order in AMDGPU.h

llvm-svn: 326278

6 years ago[WebAssembly] Inline accessor functions that are called only once.
Rui Ueyama [Wed, 28 Feb 2018 00:26:26 +0000 (00:26 +0000)]
[WebAssembly] Inline accessor functions that are called only once.

Looks like these accessor functions are a bit overly defensive, and
due to the amount of code, that part isn't easy to read. We have
code to log translation results in writeTo and writeRelocations, so
I don't think we need to log it again in these functions.
I think the new function is much easier to understand.

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

llvm-svn: 326277

6 years ago[WebAssembly] Remove trivial accessors.
Rui Ueyama [Wed, 28 Feb 2018 00:20:29 +0000 (00:20 +0000)]
[WebAssembly] Remove trivial accessors.

{set,get}OutputSegment don't hide anything, so remove them.

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

llvm-svn: 326276

6 years ago[WebAssembly] Use more specific type and simplify code.
Rui Ueyama [Wed, 28 Feb 2018 00:18:34 +0000 (00:18 +0000)]
[WebAssembly] Use more specific type and simplify code.

Instead of {Function,Global,Data}Symbol, use Defined{Function,Global,Data}
because undefined symbol should never reach this function.

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

llvm-svn: 326275

6 years ago[WebAssembly] Remove LastDefinedKind for consistency with undefined kinds. NFC.
Rui Ueyama [Wed, 28 Feb 2018 00:16:11 +0000 (00:16 +0000)]
[WebAssembly] Remove LastDefinedKind for consistency with undefined kinds. NFC.

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

llvm-svn: 326274