platform/upstream/llvm.git
5 years ago[InstSimplify] add tests for fcmp of maxnum with constants; NFC
Sanjay Patel [Thu, 16 May 2019 15:00:11 +0000 (15:00 +0000)]
[InstSimplify] add tests for fcmp of maxnum with constants; NFC

Sibling tests for rL360899 (D61691).

llvm-svn: 360905

5 years ago[llvm-objdump]Split section-filter.test in two to remove X86 dependency
James Henderson [Thu, 16 May 2019 14:49:10 +0000 (14:49 +0000)]
[llvm-objdump]Split section-filter.test in two to remove X86 dependency

This allows the generic parts of section-filter.test to be tested on all
targets. The X86-specific parts have been moved to another test.

llvm-svn: 360904

5 years agoAMDGPU: Assume xnack is enabled by default
Matt Arsenault [Thu, 16 May 2019 14:48:34 +0000 (14:48 +0000)]
AMDGPU: Assume xnack is enabled by default

This is the conservatively correct default. It is always safe to
assume xnack is enabled, but not the converse.

Introduce a feature to blacklist targets where xnack can never be
meaningfully enabled. I'm not sure the targets this is applied to is
100% correct.

llvm-svn: 360903

5 years agoResubmit: [Salvage] Change salvage debug info implementation to use DW_OP_LLVM_conver...
Stephen Tozer [Thu, 16 May 2019 14:41:01 +0000 (14:41 +0000)]
Resubmit: [Salvage] Change salvage debug info implementation to use DW_OP_LLVM_convert where needed

Fixes issue: https://bugs.llvm.org/show_bug.cgi?id=40645

Previously, LLVM had no functional way of performing casts inside of a
DIExpression(), which made salvaging cast instructions other than Noop casts
impossible. With the recent addition of DW_OP_LLVM_convert this salvaging is
now possible, and so can be used to fix the attached bug as well as any cases
where SExt instruction results are lost in the debugging metadata. This patch
introduces this fix by expanding the salvage debug info method to cover these
cases using the new operator.

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

llvm-svn: 360902

5 years ago[llvm-objdump] Add "REQUIES: x86-registered-target" to section-filter.test after...
Fangrui Song [Thu, 16 May 2019 14:40:31 +0000 (14:40 +0000)]
[llvm-objdump] Add "REQUIES: x86-registered-target" to section-filter.test after rL360893

Appease the hexagon buildbot that doesn't build X86. Disassemblers
require Target/X86 support.

llvm-svn: 360901

5 years agoAdd AIX Version Macros
Xing Xue [Thu, 16 May 2019 14:22:37 +0000 (14:22 +0000)]
Add AIX Version Macros

Summary:
- This patch checks the AIX version and defines the appropriate macros.
- Follow up to a comment on D59048.

Author: andusy

Reviewers: hubert.reinterpretcast, jasonliu, sfertile, xingxue

Reviewed By: sfertile

Subscribers: jsji, cfe-commits

Tags: #clang

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

llvm-svn: 360900

5 years ago[InstSimplify] fold fcmp (minnum, X, C1), C2
Sanjay Patel [Thu, 16 May 2019 14:03:10 +0000 (14:03 +0000)]
[InstSimplify] fold fcmp (minnum, X, C1), C2
   minnum(X, LesserC) == C --> false
   minnum(X, LesserC) >= C --> false
   minnum(X, LesserC) >  C --> false
   minnum(X, LesserC) != C --> true
   minnum(X, LesserC) <= C --> true
   minnum(X, LesserC) <  C --> true

maxnum siblings will follow if there are no problems here.

We should be able to perform some other combines when the constants
are equal or greater-than too, but that would go in instcombine.

We might also generalize this by creating an FP ConstantRange
(similar to what we do for integers).

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

llvm-svn: 360899

5 years agoFixes for builds that require strict X/Open and POSIX compatiblity
Xing Xue [Thu, 16 May 2019 14:02:13 +0000 (14:02 +0000)]
Fixes for builds that require strict X/Open and POSIX compatiblity

Summary:
- Use alternative to MAP_ANONYMOUS for allocating mapped memory if it isn't available
- Use strtok_r instead of strsep as part of getting program path
- Don't try to find the width of a terminal using "struct winsize" and TIOCGWINSZ on POSIX builds. These aren't defined under POSIX (even though some platforms make them available when they shouldn't), so just check if we are doing a X/Open or POSIX compliant build first.

Author: daltenty

Reviewers: hubert.reinterpretcast, xingxue, andusy

Reviewed By: hubert.reinterpretcast

Subscribers: MaskRay, jsji, hiraditya, kristina, llvm-commits

Tags: #llvm

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

llvm-svn: 360898

5 years ago[RISCV][NFC] Add nounwind attribute to functions missing it in test/CodeGen/RISCV
Alex Bradbury [Thu, 16 May 2019 13:56:23 +0000 (13:56 +0000)]
[RISCV][NFC] Add nounwind attribute to functions missing it in test/CodeGen/RISCV

This is in preparation for emitting CFI directives.

llvm-svn: 360897

5 years ago[clang] Handle lround/llround builtins
Adhemerval Zanella [Thu, 16 May 2019 13:43:25 +0000 (13:43 +0000)]
[clang] Handle lround/llround builtins

As for other floating-point rounding builtins that can be optimized
when build with -fno-math-errno, this patch adds support for lround
and llround.  It currently only optimize for AArch64 backend.

Reviewed By: efriedma

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

llvm-svn: 360896

5 years ago[tests][go]Add -stdlib=libc++ to build GO test if LLVM is built with libc++
Xing Xue [Thu, 16 May 2019 13:32:55 +0000 (13:32 +0000)]
[tests][go]Add -stdlib=libc++ to build GO test if LLVM is built with libc++

When libc++ is used to build LLVM libraries, these libraries have dependencies on libc++ and C++ STL signatures in these libraries are corresponding to libc++ implementation. Therefore, -stdlib=libc++ is required on the C++ compiler command for building GO tests that link with these LLVM libraries.

Reviewers: hubert.reinterpretcast, sfertile, amyk, EricWF

Reviewed By: sfertile, hubert.reinterpretcast

Subscribers: jsji, llvm-commits

Tags: #llvm

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

llvm-svn: 360895

5 years ago[AArch64] Handle ISD::LROUND and ISD::LLROUND
Adhemerval Zanella [Thu, 16 May 2019 13:30:18 +0000 (13:30 +0000)]
[AArch64] Handle ISD::LROUND and ISD::LLROUND

This patch optimizes ISD::LROUND and ISD::LLROUND to fcvtas
instruction. It currently only handles the scalar version.

llvm-svn: 360894

5 years ago[llvm-objdump]Improve testing of some switches #1
James Henderson [Thu, 16 May 2019 13:28:36 +0000 (13:28 +0000)]
[llvm-objdump]Improve testing of some switches #1

This is the first in a set of patches I have to improve testing of
llvm-objdump. This patch targets --all-headers, --section, and
--full-contents. In the --section case, it deletes a pre-canned binary
which is only used by the one test and replaces it with yaml.

Reviewed by: grimar, MaskRay

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

llvm-svn: 360893

5 years agoRecommit [Object] Change object::SectionRef::getContents() to return Expected<StringRef>
Fangrui Song [Thu, 16 May 2019 13:24:04 +0000 (13:24 +0000)]
Recommit [Object] Change object::SectionRef::getContents() to return Expected<StringRef>

r360876 didn't fix 2 call sites in clang.

Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now.

Follow-up of D61781.

llvm-svn: 360892

5 years agoReland "[analyzer] Add an example plugin for checker dependency handling"
Kristof Umann [Thu, 16 May 2019 13:22:04 +0000 (13:22 +0000)]
Reland "[analyzer] Add an example plugin for checker dependency handling"

Buildbots complained that they couldn't find the newly added plugins.

The solution was to move the check-clang cmake target closer to the bottom of
the file, after the new dependencies are added.

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

llvm-svn: 360891

5 years agoFix hwloc topology traversal code unable to handle situation where L2 cache is common...
Paul Osmialowski [Thu, 16 May 2019 13:16:24 +0000 (13:16 +0000)]
Fix hwloc topology traversal code unable to handle situation where L2 cache is common for the packages

Currently cores within package that share the same L2 cache are grouped together.
The current logic behind this assumes that the L2 cache is always at deeper
(or the same) level than the package itself. In case when L2 cache is common
for all packages (and the packages are at deeper level than L2 cache) the whole of
the further topology discovery fails to find any computational units resulting in
following assertion:

Assertion failure at kmp_affinity.cpp(715): nActiveThreads == __kmp_avail_proc.
OMP: Error #13: Assertion failure at kmp_affinity.cpp(715).

This patch adds a bit of a logic that prevents such situation from occurring.

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

llvm-svn: 360890

5 years ago[CodeGen] Add lround/llround builtins
Adhemerval Zanella [Thu, 16 May 2019 13:15:27 +0000 (13:15 +0000)]
[CodeGen] Add lround/llround builtins

This patch add the ISD::LROUND and ISD::LLROUND along with new
intrinsics.  The changes are straightforward as for other
floating-point rounding functions, with just some adjustments
required to handle the return value being an interger.

The idea is to optimize lround/llround generation for AArch64
in a subsequent patch.  Current semantic is just route it to libm
symbol.

llvm-svn: 360889

5 years agoGlobalISel: Add buildFMA to MachineIRBuilder
Matt Arsenault [Thu, 16 May 2019 13:04:20 +0000 (13:04 +0000)]
GlobalISel: Add buildFMA to MachineIRBuilder

llvm-svn: 360888

5 years agoRegAllocFast: Improve hinting heuristic
Matt Arsenault [Thu, 16 May 2019 12:50:39 +0000 (12:50 +0000)]
RegAllocFast: Improve hinting heuristic

Trace through multiple COPYs when looking for a physreg source. Add
hinting for vregs that will be copied into physregs (we only hinted
for vregs getting copied to a physreg previously).  Give hinted a
register a bonus when deciding which value to spill.  This is part of
my rewrite regallocfast series. In fact this one doesn't even have an
effect unless you also flip the allocation to happen from back to
front of a basic block. Nonetheless it helps to split this up to ease
review of D52010

Patch by Matthias Braun

llvm-svn: 360887

5 years ago[DominatorTree] Print roots unconditionally in `print()`.
Clement Courbet [Thu, 16 May 2019 12:48:56 +0000 (12:48 +0000)]
[DominatorTree] Print roots unconditionally in `print()`.

Summary:
This came up in a debugging session. I was failing to update the root of
the tree, and got during verification:

```
DominatorTree is different than a freshly computed one!
        Current:
=============================--------------------------------
Inorder Dominator Tree: DFSNumbers invalid: 0 slow queries.
  [1] %"entry+land.rhs.i" {4294967295,4294967295} [0]
    [2] %opeq1.exit {4294967295,4294967295} [1]

        Freshly computed tree:
=============================--------------------------------
Inorder Dominator Tree: DFSNumbers invalid: 0 slow queries.
  [1] %"entry+land.rhs.i" {4294967295,4294967295} [0]
    [2] %opeq1.exit {4294967295,4294967295} [1]
```

We now print:

```
DominatorTree is different than a freshly computed one!
        Current:
=============================--------------------------------
Inorder Dominator Tree: DFSNumbers invalid: 0 slow queries.
  [1] %"entry+land.rhs.i" {4294967295,4294967295} [0]
    [2] %opeq1.exit {4294967295,4294967295} [1]
Roots: <badref>

        Freshly computed tree:
=============================--------------------------------
Inorder Dominator Tree: DFSNumbers invalid: 0 slow queries.
  [1] %"entry+land.rhs.i" {4294967295,4294967295} [0]
    [2] %opeq1.exit {4294967295,4294967295} [1]
Roots: %"entry+land.rhs.i"
```

Reviewers: kuhar, asbirlea

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 360886

5 years agoFix isInSystemMacro in presence of macro and pasted token
Serge Guelton [Thu, 16 May 2019 12:40:00 +0000 (12:40 +0000)]
Fix isInSystemMacro in presence of macro and pasted token

When a warning is raised from the expansion of a system macro that
involves pasted token, there was still situations were they were not
skipped, as showcased by this issue:
https://bugzilla.redhat.com/show_bug.cgi?id=1472437

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

llvm-svn: 360885

5 years ago[NFC] Fixup FileCheck option name in tests added in rL360881
Roman Lebedev [Thu, 16 May 2019 12:39:34 +0000 (12:39 +0000)]
[NFC] Fixup FileCheck option name in tests added in rL360881

llvm-svn: 360884

5 years ago[clang-tidy] Removed superfluous and slightly annoying newlines in run-clang-tidy...
Jonas Toth [Thu, 16 May 2019 12:39:22 +0000 (12:39 +0000)]
[clang-tidy] Removed superfluous and slightly annoying newlines in run-clang-tidy's output.

Summary: The output of clang-tidy itself already has enough newlines, so the resulting output is more in line with the usual compiler output.

Patch by svenpanne.

Reviewers: alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: JonasToth, cfe-commits

Tags: #clang

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

llvm-svn: 360883

5 years ago[clang-tidy] Handle member variables in readability-simplify-boolean-expr
Jonas Toth [Thu, 16 May 2019 12:35:00 +0000 (12:35 +0000)]
[clang-tidy] Handle member variables in readability-simplify-boolean-expr

- Add readability-simplify-boolean-expr test cases for member variables
Fixes PR40179

Patch by LegalizeAdulthood.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: JonasToth

Subscribers: jdoerfert, xazax.hun, cfe-commits

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

llvm-svn: 360882

5 years ago[NFC][CodeGen] Add some more tests for pulling binops through shifts
Roman Lebedev [Thu, 16 May 2019 12:26:53 +0000 (12:26 +0000)]
[NFC][CodeGen] Add some more tests for pulling binops through shifts

The ashr variant may see relaxation in https://reviews.llvm.org/D61918

llvm-svn: 360881

5 years agoGlobalISel: Add buildXor/buildNot
Matt Arsenault [Thu, 16 May 2019 12:23:04 +0000 (12:23 +0000)]
GlobalISel: Add buildXor/buildNot

llvm-svn: 360880

5 years agoGlobalISel: Add DstOp version of buildIntrinsic
Matt Arsenault [Thu, 16 May 2019 12:22:56 +0000 (12:22 +0000)]
GlobalISel: Add DstOp version of buildIntrinsic

llvm-svn: 360879

5 years agoRevert r360876 "[Object] Change object::SectionRef::getContents() to return Expected...
Hans Wennborg [Thu, 16 May 2019 12:08:34 +0000 (12:08 +0000)]
Revert r360876 "[Object] Change object::SectionRef::getContents() to return Expected<StringRef>"

It broke the Clang build, see llvm-commits thread.

> Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now.
>
> Follow-up of D61781.

llvm-svn: 360878

5 years agoAMDGPU/GlobalISel: Correct regbank for 1-bit and/or/xor
Matt Arsenault [Thu, 16 May 2019 12:06:41 +0000 (12:06 +0000)]
AMDGPU/GlobalISel: Correct regbank for 1-bit and/or/xor

Bool values should use the scc/vcc regbank since r350611.

llvm-svn: 360877

5 years ago[Object] Change object::SectionRef::getContents() to return Expected<StringRef>
Fangrui Song [Thu, 16 May 2019 11:33:48 +0000 (11:33 +0000)]
[Object] Change object::SectionRef::getContents() to return Expected<StringRef>

Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now.

Follow-up of D61781.

llvm-svn: 360876

5 years ago[lld-link] Add missing "REQUIRES: x86" to COFF/lib-module-asm.ll test.
Yvan Roux [Thu, 16 May 2019 11:29:30 +0000 (11:29 +0000)]
[lld-link] Add missing "REQUIRES: x86" to COFF/lib-module-asm.ll test.

This should fix ARM bots.

llvm-svn: 360875

5 years agoDWARFContext: Return empty data extractors instead of null pointers
Pavel Labath [Thu, 16 May 2019 11:19:02 +0000 (11:19 +0000)]
DWARFContext: Return empty data extractors instead of null pointers

Summary:
There are several reasons for doing this:
- generally, there's no reason to differentiate between a section being
  absent and it being present, but empty
- it matches more closely what llvm DWARF parser is doing (which also
  doesn't differentiate the two cases)
- SymbolFileDWARF also doesn't differentiate the two cases, which makes
  porting the rest of sections easier
- it fixes a bug in how the return-null-if-empty logic was implemented
  (it returned nullptr only the second time we tried to get the
  debug_aranges section), which meant that we hit an assert when trying
  to parse an empty-but-present section

Reviewers: JDevlieghere, clayborg, aprantl

Subscribers: zturner, lldb-commits

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

llvm-svn: 360874

5 years ago[crt] Mark dso_handle test as xfailing on ARM.
Yvan Roux [Thu, 16 May 2019 11:13:49 +0000 (11:13 +0000)]
[crt] Mark dso_handle test as xfailing on ARM.

This is a temporary action to fix the bots.

llvm-svn: 360873

5 years agoDWARF: Add ability to reference debug info coming from multiple sections
Pavel Labath [Thu, 16 May 2019 11:07:58 +0000 (11:07 +0000)]
DWARF: Add ability to reference debug info coming from multiple sections

Summary:
This patch adds the ability to precisely address debug info in
situations when a single file can have more than one debug-info-bearing
sections (as is the case with type units in DWARF v4).

The changes here can be classified into roughly three categories:
- the code which addresses a debug info by offset gets an additional
  argument, which specifies the section one should look into.
- the DIERef class also gets an additional member variable specifying
  the section. This way, code dealing with DIERefs can know which
  section is the object referring to.
- the user_id_t encoding steals one bit from the dwarf_id field to store
  the section. This means the total number of separate object files
  (apple .o, or normal .dwo) is limited to 2 billion, but that is fine
  as it's not possible to hit that number without switching to DWARF64
  anyway.

This patch is functionally equivalent to (and inspired by) the two
patches (D61503 and D61504) by Jan Kratochvil, but there are differences
in the implementation:
- it uses an enum instead of a bool flag to differentiate the sections
- it increases the size of DIERef struct instead of reducing the amount
  of addressable debug info
- it sets up DWARFDebugInfo to store the units in a single vector
  instead of two. This sets us up for the future in which type units can
  also live in the debug_info section, and I believe it's cleaner
  because there's no need for unit index remapping

There are no tests with this patch as this is essentially NFC until
we start parsing type units from the debug_types section.

Reviewers: JDevlieghere, clayborg, aprantl

Subscribers: arphaman, jankratochvil, lldb-commits

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

llvm-svn: 360872

5 years ago[AArch64][SVE2] Asm: implement CMLA/SQRDCMLAH instructions
Cullen Rhodes [Thu, 16 May 2019 09:42:22 +0000 (09:42 +0000)]
[AArch64][SVE2] Asm: implement CMLA/SQRDCMLAH instructions

Summary:
This patch adds support for the indexed and unpredicated vectors forms
of the CMLA and SQRDCMLAH instructions.

The specification can be found here:
https://developer.arm.com/docs/ddi0602/latest

Reviewed By: SjoerdMeijer

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

llvm-svn: 360871

5 years ago[AArch64][SVE2] Asm: implement CDOT instruction
Cullen Rhodes [Thu, 16 May 2019 09:33:44 +0000 (09:33 +0000)]
[AArch64][SVE2] Asm: implement CDOT instruction

Summary:
The complex DOT instructions perform a dot-product on quadtuplets from
two source vectors and the resuling wide real or wide imaginary is
accumulated into the destination register. The instructions come in two
forms:

Vector form, e.g.
  cdot z0.s, z1.b, z2.b, #90    - complex dot product on four 8-bit quad-tuplets,
                                  accumulating results in 32-bit elements. The
                                  complex numbers in the second source vector are
                                  rotated by 90 degrees.

  cdot z0.d, z1.h, z2.h, #180   - complex dot product on four 16-bit quad-tuplets,
                                  accumulating results in 64-bit elements.
                                  The complex numbers in the second source
                                  vector are rotated by 180 degrees.

Indexed form, e.g.
  cdot z0.s, z1.b, z2.b[3], #0  - complex dot product on four 8-bit quad-tuplets,
                                  with specified quadtuplet from second source vector,
                                  accumulating results in 32-bit elements.
  cdot z0.d, z1.h, z2.h[1], #0  - complex dot product on four 16-bit quad-tuplets,
                                  with specified quadtuplet from second source vector,
                                  accumulating results in 64-bit elements.

The specification can be found here:
https://developer.arm.com/docs/ddi0602/latest

Reviewed By: SjoerdMeijer, rovka

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

llvm-svn: 360870

5 years ago[clang-tidy] Do not list enabled checks when -quiet is given to run-clang-tidy.
Jonas Toth [Thu, 16 May 2019 09:22:39 +0000 (09:22 +0000)]
[clang-tidy] Do not list enabled checks when -quiet is given to run-clang-tidy.

Summary: When run-clang-tidy is given the -quiet flag, do not output the potentially hundreds of enabled check names at the beginning.

Patch by svenpanne.

Reviewers: alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: JonasToth, cfe-commits

Tags: #clang

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

llvm-svn: 360869

5 years agoSimplify Triple::ppc64{,le} checks with Triple::isPPC64()
Fangrui Song [Thu, 16 May 2019 09:07:33 +0000 (09:07 +0000)]
Simplify Triple::ppc64{,le} checks with Triple::isPPC64()

While here, update some ppc64le specific check to isPPC64(), if it
applies to big-endian as well, in the hope that it will ease the support
of big-endian if people are interested in this area. The big-endian
variant is used by at least FreeBSD, Gentoo Linux, Adélie Linux, and
Void Linux.

llvm-svn: 360868

5 years ago[AArch64][SVE2] Asm: add unpredicated integer multiply instructions
Cullen Rhodes [Thu, 16 May 2019 09:07:26 +0000 (09:07 +0000)]
[AArch64][SVE2] Asm: add unpredicated integer multiply instructions

Summary:
Add support for the following instructions:

  * MUL (indexed and unpredicated vectors forms)
  * SQDMULH (indexed and unpredicated vectors forms)
  * SQRDMULH (indexed and unpredicated vectors forms)
  * SMULH (unpredicated, predicated form added in SVE)
  * UMULH (unpredicated, predicated form added in SVE)
  * PMUL (unpredicated)

The specification can be found here:
https://developer.arm.com/docs/ddi0602/latest

Reviewed By: SjoerdMeijer, rovka

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

llvm-svn: 360867

5 years agoAdd missing "REQUIRES: x86" to the lto/irmover-warning.ll test.
Igor Kudrin [Thu, 16 May 2019 09:04:52 +0000 (09:04 +0000)]
Add missing "REQUIRES: x86" to the lto/irmover-warning.ll test.

llvm-svn: 360866

5 years agoSimplify ArchSpec::IsMIPS()
Fangrui Song [Thu, 16 May 2019 08:37:32 +0000 (08:37 +0000)]
Simplify ArchSpec::IsMIPS()

llvm-svn: 360865

5 years agoAdd Triple::isPPC64()
Fangrui Song [Thu, 16 May 2019 08:31:22 +0000 (08:31 +0000)]
Add Triple::isPPC64()

llvm-svn: 360864

5 years ago[builtin] Fixed definitions of builtins that rely on the int/long long type is 32...
Karl-Johan Karlsson [Thu, 16 May 2019 07:18:02 +0000 (07:18 +0000)]
[builtin] Fixed definitions of builtins that rely on the int/long long type is 32/64 bits

Summary:
The definition of the builtins __builtin_bswap32, __builtin_bitreverse32, __builtin_rotateleft32 and __builtin_rotateright32 rely on that the int type is 32 bits wide on the target.
The defintions of the builtins __builtin_bswap64, __builtin_bitreverse64, __builtin_rotateleft64, and __builtin_rotateright64 rely on that the long long type is 64 bits wide.

On targets where this is not the case (e.g. AVR) clang will generate faulty code (wrong llvm assembler intrinsics).

This patch add support for using 'Z' (the int32_t type) in Bultins.def. The builtins above are changed to be based on the int32_t type instead of the int type, and the int64_t type instead of the long long type.

The AVR backend (experimental) have a native int type that is only 16 bits wide. The supplied testcase will therefore fail if running the testcase on trunk as clang will convert e.g. __builtin_bitreverse32 into llvm.bitreverse.i16 on AVR.

Reviewers: dylanmckay, spatel, rsmith, efriedma

Reviewed By: efriedma

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

llvm-svn: 360863

5 years ago[PPC] Fix 32-bit build of libunwind
Martin Storsjo [Thu, 16 May 2019 06:49:20 +0000 (06:49 +0000)]
[PPC] Fix 32-bit build of libunwind

Clang integrated assembler was unable to build libunwind PPC32 assembly code,
present in functions used to save/restore register context.

This change consists in replacing the assembly style used in libunwind source,
to one that is compatible with both Clang integrated assembler as well as
GNU assembler.

Patch by Leandro Lupori!

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

llvm-svn: 360862

5 years ago[PPC64][libunwind] Fix r2 not properly restored
Martin Storsjo [Thu, 16 May 2019 06:49:13 +0000 (06:49 +0000)]
[PPC64][libunwind] Fix r2 not properly restored

This change makes each unwind step inspect the instruction at the
return address and, if needed, read r2 from its saved location and
modify the context appropriately.

The unwind logic is able to handle both ELFv1 and ELFv2 stacks.

Reported by Bug 41050

Patch by Leandro Lupori!

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

llvm-svn: 360861

5 years ago[llvm-readobj] - Revert r360676 partially. NFC.
George Rimar [Thu, 16 May 2019 06:22:51 +0000 (06:22 +0000)]
[llvm-readobj] - Revert r360676 partially. NFC.

In the r360676 "Apply clang format. NFC" I applied clang-format
for whole ELFDumper.cpp. It caused a little discussion,
one of the points mentioned was that previously nicely lined up
tables are not so nice now.

This patch reverts them.

llvm-svn: 360860

5 years agoReland r360771 "[MergeICmps] Simplify the code."
Clement Courbet [Thu, 16 May 2019 06:18:02 +0000 (06:18 +0000)]
Reland r360771 "[MergeICmps] Simplify the code."

This revision does not seem to be the culprit.

llvm-svn: 360859

5 years ago[LTO] Improve readability of module IDs
Igor Kudrin [Thu, 16 May 2019 05:23:25 +0000 (05:23 +0000)]
[LTO] Improve readability of module IDs

Module IDs can appear in diagnostic messages.
This patch adds some auxiliary symbols to improve their readability.

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

llvm-svn: 360858

5 years ago[IRMover] Improve diagnostic messages for conflicting metadata
Igor Kudrin [Thu, 16 May 2019 05:23:13 +0000 (05:23 +0000)]
[IRMover] Improve diagnostic messages for conflicting metadata

This does the similar for error messages as rL344011 has done for warnings.

With llvm::lto::LTO, the error might appear when LTO::run() is executed.
In that case, the calling code cannot know which module causes the error
and, subsequently, cannot hint the user.

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

llvm-svn: 360857

5 years agoGlobalISel: Add buildFConstant for APFloat
Matt Arsenault [Thu, 16 May 2019 04:09:06 +0000 (04:09 +0000)]
GlobalISel: Add buildFConstant for APFloat

llvm-svn: 360853

5 years agoGlobalISel: Add some FP instructions to MachineIRBuilder
Matt Arsenault [Thu, 16 May 2019 04:08:55 +0000 (04:08 +0000)]
GlobalISel: Add some FP instructions to MachineIRBuilder

This makes FP legalization code more convenient.

llvm-svn: 360852

5 years agoGlobalISel: Fix indentation
Matt Arsenault [Thu, 16 May 2019 04:08:46 +0000 (04:08 +0000)]
GlobalISel: Fix indentation

llvm-svn: 360851

5 years agoGlobalISel: Add G_FCOPYSIGN
Matt Arsenault [Thu, 16 May 2019 04:08:39 +0000 (04:08 +0000)]
GlobalISel: Add G_FCOPYSIGN

llvm-svn: 360850

5 years agoFix missing const
Matt Arsenault [Thu, 16 May 2019 04:08:25 +0000 (04:08 +0000)]
Fix missing const

llvm-svn: 360849

5 years ago[libFuzzer] Increase merge-sigusr sleep after sending signal.
Matt Morehouse [Thu, 16 May 2019 04:00:41 +0000 (04:00 +0000)]
[libFuzzer] Increase merge-sigusr sleep after sending signal.

Test is flaky on buildbot at least partially due to the fuzz target not
exiting before we read its output.

llvm-svn: 360848

5 years agoPemove SymbolTable::addBitcode as it is redundant.
Rui Ueyama [Thu, 16 May 2019 03:54:50 +0000 (03:54 +0000)]
Pemove SymbolTable::addBitcode as it is redundant.

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

llvm-svn: 360846

5 years agoConsistently return `Symbol *` from SymbolTable's add-family functions.
Rui Ueyama [Thu, 16 May 2019 03:54:41 +0000 (03:54 +0000)]
Consistently return `Symbol *` from SymbolTable's add-family functions.

llvm-svn: 360845

5 years agoDe-template parseFile() and SymbolTable's add-family functions.
Rui Ueyama [Thu, 16 May 2019 03:45:13 +0000 (03:45 +0000)]
De-template parseFile() and SymbolTable's add-family functions.

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

llvm-svn: 360844

5 years agoFix prof branch_weights in entry_counts_missing_dbginfo.ll test
Yevgeny Rouban [Thu, 16 May 2019 03:39:09 +0000 (03:39 +0000)]
Fix prof branch_weights in entry_counts_missing_dbginfo.ll test

Removed extra parameter from !prof branch_weights metadata of
a call instruction according to the spec.

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

llvm-svn: 360843

5 years agoRevert r360833 until I can work out the issue with Win32 bots
Kristina Brooks [Thu, 16 May 2019 03:30:08 +0000 (03:30 +0000)]
Revert r360833 until I can work out the issue with Win32 bots

This reverts "r360833: [Clang][PP] Add the __FILE_NAME__ builtin macro."

The tests are failing on Windows bots, reverting the patchset until I can
work out why.

llvm-svn: 360842

5 years agoIntroduce CommonSymbol.
Rui Ueyama [Thu, 16 May 2019 03:29:03 +0000 (03:29 +0000)]
Introduce CommonSymbol.

Previously, we handled common symbols as a kind of Defined symbol,
but what we were doing for common symbols is pretty different from
regular defined symbols.

Common symbol and defined symbol are probably as different as shared
symbol and defined symbols are different.

This patch introduces CommonSymbol to represent common symbols.
After symbols are resolved, they are converted to Defined symbols
residing in a .bss section.

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

llvm-svn: 360841

5 years ago[libFuzzer] Also kill parent process in merge-siguser.test.
Matt Morehouse [Thu, 16 May 2019 03:04:44 +0000 (03:04 +0000)]
[libFuzzer] Also kill parent process in merge-siguser.test.

llvm-svn: 360840

5 years agoFix assumption about Win32 paths in r360833
Kristina Brooks [Thu, 16 May 2019 02:46:12 +0000 (02:46 +0000)]
Fix assumption about Win32 paths in r360833

Attempt to fix Windows buildbots due to differences in
path handling (caused by r360833).

llvm-svn: 360839

5 years agoSimplify SymbolTable::add{Defined,Undefined,...} functions.
Rui Ueyama [Thu, 16 May 2019 02:14:00 +0000 (02:14 +0000)]
Simplify SymbolTable::add{Defined,Undefined,...} functions.

SymbolTable's add-family functions have lots of parameters because
when they have to create a new symbol, they forward given arguments
to Symbol's constructors. Therefore, the functions take at least as
many arguments as their corresponding constructors.

This patch simplifies the add-family functions. Now, the functions
take a symbol instead of arguments to construct a symbol. If there's
no existing symbol, a given symbol is memcpy'ed to the symbol table.
Otherwise, the functions attempt to merge the existing and a given
new symbol.

I also eliminated `CanOmitFromDynSym` parameter, so that the functions
take really one argument.

Symbol classes are trivially constructible, so looks like constructing
them to pass to add-family functions is as cheap as passing a lot of
arguments to the functions. A quick benchmark showed that this patch
seems performance-neutral.

This is a preparation for
http://lists.llvm.org/pipermail/llvm-dev/2019-April/131902.html

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

llvm-svn: 360838

5 years agoFix regression in r360311 caused by reversed bool arguments.
Richard Smith [Thu, 16 May 2019 02:06:16 +0000 (02:06 +0000)]
Fix regression in r360311 caused by reversed bool arguments.

llvm-svn: 360837

5 years ago[libFuzzer] Fix typo in merge-sigusr.test.
Matt Morehouse [Thu, 16 May 2019 01:56:11 +0000 (01:56 +0000)]
[libFuzzer] Fix typo in merge-sigusr.test.

llvm-svn: 360836

5 years ago[libFuzzer] Use PID to send signals rather than process name.
Matt Morehouse [Thu, 16 May 2019 01:32:39 +0000 (01:32 +0000)]
[libFuzzer] Use PID to send signals rather than process name.

pkill reads the process name as a pattern, not a raw name.  This means
that if the process name contains + or other regex characters, pkill
fails.

llvm-svn: 360835

5 years agoFix typo in comment of CSAction -> Action.
Eric Christopher [Thu, 16 May 2019 01:07:54 +0000 (01:07 +0000)]
Fix typo in comment of CSAction -> Action.

llvm-svn: 360834

5 years ago[Clang][PP] Add the __FILE_NAME__ builtin macro.
Kristina Brooks [Thu, 16 May 2019 00:52:41 +0000 (00:52 +0000)]
[Clang][PP] Add the __FILE_NAME__ builtin macro.

This patch adds the `__FILE_NAME__` macro that expands to the
last component of the path, similar to `__FILE__` except with
a guarantee that only the last path component (without the
separator) will be rendered.

I intend to follow through with discussion of this with WG14
as a potential inclusion in the C standard or failing that,
try to discuss this with GCC developers since this extension
is desired by GCC and Clang users/developers alike.

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

llvm-svn: 360833

5 years ago[ELF] Fix typo in header guard. NFC.
Sam Clegg [Thu, 16 May 2019 00:45:50 +0000 (00:45 +0000)]
[ELF] Fix typo in header guard. NFC.

llvm-svn: 360832

5 years ago[ORC] Modify DenseMap hashing for SymbolStringPtrs.
Lang Hames [Thu, 16 May 2019 00:21:10 +0000 (00:21 +0000)]
[ORC] Modify DenseMap hashing for SymbolStringPtrs.

Modifies the DenseMapInfo<SymbolStringPtr>::getHashValue method to take its
argument by const-ref rather than by value (to avoid unnecessary ref-counting
operations) and to defer to DenseMapInfo<void*> for the hash value computation
(since SymbolStringPtrs are just pointers under the hood).

llvm-svn: 360831

5 years ago[JITLink][MachO] Use getSymbol64TableEntry for 64-bit MachO files.
Lang Hames [Thu, 16 May 2019 00:21:07 +0000 (00:21 +0000)]
[JITLink][MachO] Use getSymbol64TableEntry for 64-bit MachO files.

Fixes a think-o. No test case: The nlist and nlist64 data structures happen to
line up for this field, so there's no way to construct a failing test case.

llvm-svn: 360830

5 years agoFix GN build
Vitaly Buka [Thu, 16 May 2019 00:19:37 +0000 (00:19 +0000)]
Fix GN build

llvm-svn: 360829

5 years agoMake tentative parsing to detect template-argument-lists less aggressive
Richard Smith [Wed, 15 May 2019 23:36:14 +0000 (23:36 +0000)]
Make tentative parsing to detect template-argument-lists less aggressive
(and less wrong).

It's not correct to assume that X<something, Type> is always a
template-id; there are a few cases where the comma takes us into a
non-expression syntactic context in which 'Type' might be permissible.
Stop doing that.

This slightly regresses our error recovery on the cases where the
construct is intended to be a template-id. We typically do still manage
to diagnose a missing 'template' keyword, but we realize this too late
to properly recover from the error.

This fixes a regression introduced by r360308.

llvm-svn: 360827

5 years ago[mips] Always use _LARGEFILE_SOURCE / _FILE_OFFSET_BITS for building MIPS 32-bit
Simon Atanasyan [Wed, 15 May 2019 22:27:19 +0000 (22:27 +0000)]
[mips] Always use _LARGEFILE_SOURCE / _FILE_OFFSET_BITS for building MIPS 32-bit

When MIPS 32-bit compiler-rt is building on 32-bit host or using 32-bit
`DLLVM_HOST_TRIPLE` the `_LARGEFILE_SOURCE` and the `_FILE_OFFSET_BITS=64`
macros defined by statements from the `HandleLLVMOptions.cmake`. In case
of building 32-bit libraries on 64-bit host using default host triple
these macros are not defined. As a result assertions check a consistency
between the `struct_kernel_stat_sz` constant and the `struct_kernel_stat_sz`
start to fail.

To resolve this problem and enable building both 32/64-bit versions
of MIPS compiler-rt libraries on 64-bit host at once always explicitly
define the `_LARGEFILE_SOURCE` and the `_FILE_OFFSET_BITS=64` macros
for MIPS 32-bit.

llvm-svn: 360825

5 years ago[libFuzzer] Echo fuzzer output on sigusr tests.
Matt Morehouse [Wed, 15 May 2019 22:26:48 +0000 (22:26 +0000)]
[libFuzzer] Echo fuzzer output on sigusr tests.

Improves debuggability when the fuzz target crashes.

llvm-svn: 360824

5 years ago[X86] Delay creating index register negations during address matching until after...
Craig Topper [Wed, 15 May 2019 21:59:53 +0000 (21:59 +0000)]
[X86] Delay creating index register negations during address matching until after we know for sure the match will succeed

If we're trying to match an LEA, its possible the LEA match will be deemed unprofitable. In which case the negation we created in matchAddress would be left dangling in the SelectionDAG. This could artificially increase use counts for other nodes in the DAG. Though I don't have an example of that. But it just seems like bad form to have dangling nodes in isel.

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

llvm-svn: 360823

5 years agoUpdate LLDB license on the LLDB home page to Apache+LLVM.
Adrian Prantl [Wed, 15 May 2019 21:58:43 +0000 (21:58 +0000)]
Update LLDB license on the LLDB home page to Apache+LLVM.

llvm-svn: 360822

5 years agoGet back the navigation sidebar on the LLDB website.
Adrian Prantl [Wed, 15 May 2019 21:49:00 +0000 (21:49 +0000)]
Get back the navigation sidebar on the LLDB website.

This returns the look & feel of the Sphinx-generated LLDB website to
the original pre-Sphinx layout.

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

llvm-svn: 360819

5 years ago[codeview] Fix SDNode representation of annotation labels
Reid Kleckner [Wed, 15 May 2019 21:46:05 +0000 (21:46 +0000)]
[codeview] Fix SDNode representation of annotation labels

Before this change, they were erroneously constructed with the EH_LABEL
SDNode opcode, which caused other passes to interact with them in
incorrect ways. See the FIXME about fastisel that this addresses in the
existing test case.

Fixes PR41890

llvm-svn: 360818

5 years ago[mips] Use range-based `for` loops. NFC
Simon Atanasyan [Wed, 15 May 2019 21:26:25 +0000 (21:26 +0000)]
[mips] Use range-based `for` loops. NFC

llvm-svn: 360817

5 years ago[AArch64] only indicate CFI on Windows if we emitted CFI
Mandeep Singh Grang [Wed, 15 May 2019 21:23:41 +0000 (21:23 +0000)]
[AArch64] only indicate CFI on Windows if we emitted CFI

Summary:
Otherwise, we emit directives for CFI without any actual CFI opcodes to
go with them, which causes tools to malfunction.  The technique is
similar to what the x86 backend already does.

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

Patch by: froydnj (Nathan Froyd)

Reviewers: mstorsjo, eli.friedman, rnk, mgrang, ssijaric

Reviewed By: rnk

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

Tags: #llvm

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

llvm-svn: 360816

5 years ago[X86] Strengthen type constraints on some specialized X86 ISD opcodes that don't...
Craig Topper [Wed, 15 May 2019 21:16:28 +0000 (21:16 +0000)]
[X86] Strengthen type constraints on some specialized X86 ISD opcodes that don't have any flexibility. NFC

These particular instructions only operate on 128-bit vectors and have no wider equivalents. And the
element size is always known.

One could argue that MOVSS/MOVSD could be merged, but that's probably disruptive to code in
X86ISelLowering and probably low value.

llvm-svn: 360815

5 years ago[NFC][InstCombine] Add some more tests for pulling binops through shifts
Roman Lebedev [Wed, 15 May 2019 21:15:44 +0000 (21:15 +0000)]
[NFC][InstCombine] Add some more tests for pulling binops through shifts

The ashr variant may see relaxation in https://reviews.llvm.org/D61938

llvm-svn: 360814

5 years ago[codeview] Finish support for reading and writing S_ANNOTATION records
Reid Kleckner [Wed, 15 May 2019 20:53:39 +0000 (20:53 +0000)]
[codeview] Finish support for reading and writing S_ANNOTATION records

Implement dumping via llvm-pdbutil and llvm-readobj.

llvm-svn: 360813

5 years agoRevert llvm-svn: 360807
Cameron McInally [Wed, 15 May 2019 20:48:50 +0000 (20:48 +0000)]
Revert llvm-svn: 360807

Somehow submitted this patch twice.

llvm-svn: 360812

5 years ago[clang-format] Fixed self assignment
David Bolvansky [Wed, 15 May 2019 20:29:33 +0000 (20:29 +0000)]
[clang-format] Fixed self assignment

Reviewers: MyDeveloperDay, RKSimon

Reviewed By: MyDeveloperDay

Subscribers: RKSimon, cfe-commits

Tags: #clang

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

llvm-svn: 360810

5 years ago[OpenMP][Bugfix] Move double and float versions of abs under c++ macro
Gheorghe-Teodor Bercea [Wed, 15 May 2019 20:28:23 +0000 (20:28 +0000)]
[OpenMP][Bugfix] Move double and float versions of abs under c++ macro

Summary:
This is a fix for the reported bug:

[[ https://bugs.llvm.org/show_bug.cgi?id=41861 | 41861 ]]

abs functions need to be moved under the c++ macro to avoid conflicts with included headers.

Reviewers: tra, jdoerfert, hfinkel, ABataev, caomhin

Reviewed By: jdoerfert

Subscribers: guansong, cfe-commits

Tags: #clang

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

llvm-svn: 360809

5 years agoPre-commit unary fneg tests to InstSimplify
Cameron McInally [Wed, 15 May 2019 20:27:37 +0000 (20:27 +0000)]
Pre-commit unary fneg tests to InstSimplify

llvm-svn: 360808

5 years agoAdd unary fneg to InstSimplify/fp-nan.ll
Cameron McInally [Wed, 15 May 2019 20:27:35 +0000 (20:27 +0000)]
Add unary fneg to InstSimplify/fp-nan.ll

llvm-svn: 360807

5 years ago[c++20] For P1327R1: support dynamic_cast in constant expression
Richard Smith [Wed, 15 May 2019 20:22:21 +0000 (20:22 +0000)]
[c++20] For P1327R1: support dynamic_cast in constant expression
evaluation.

llvm-svn: 360806

5 years agoRevert "[analyzer] Add a test for plugins using checker dependencies"
Kristof Umann [Wed, 15 May 2019 20:19:51 +0000 (20:19 +0000)]
Revert "[analyzer] Add a test for plugins using checker dependencies"

Buildbots don't seem to find the new plugin.

llvm-svn: 360805

5 years ago[OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions
Gheorghe-Teodor Bercea [Wed, 15 May 2019 20:18:21 +0000 (20:18 +0000)]
[OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

Summary: In OpenMP device offloading we must ensure that unde C++ 17, the inclusion of cstdlib will works correctly.

Reviewers: ABataev, tra, jdoerfert, hfinkel, caomhin

Reviewed By: jdoerfert

Subscribers: Hahnfeld, guansong, cfe-commits

Tags: #clang

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

llvm-svn: 360804

5 years ago[CodeGenObjC] invoke objc_autorelease, objc_retain when necessary
Erik Pilkington [Wed, 15 May 2019 20:15:01 +0000 (20:15 +0000)]
[CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

Any of these methods can be overridden, so we need to invoke these functions.

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

llvm-svn: 360802

5 years ago[lldb] [test] Skip one more TestMiBreak on NetBSD
Michal Gorny [Wed, 15 May 2019 20:03:31 +0000 (20:03 +0000)]
[lldb] [test] Skip one more TestMiBreak on NetBSD

llvm-svn: 360800

5 years ago[analyzer] Add a test for plugins using checker dependencies
Kristof Umann [Wed, 15 May 2019 19:47:26 +0000 (19:47 +0000)]
[analyzer] Add a test for plugins using checker dependencies

Also, I moved the existing analyzer plugin to test/ as well, in order not to
give the illusion that the analyzer supports plugins -- it's capable of handling
them, but does not _support_ them.

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

llvm-svn: 360799

5 years agoUncomment LLVM_FALLTHROUGH.
Pete Couperus [Wed, 15 May 2019 19:46:17 +0000 (19:46 +0000)]
Uncomment LLVM_FALLTHROUGH.

llvm-svn: 360798

5 years agoAdd unary fneg to InstSimplify/fp-nan.ll
Cameron McInally [Wed, 15 May 2019 19:37:03 +0000 (19:37 +0000)]
Add unary fneg to InstSimplify/fp-nan.ll

llvm-svn: 360797

5 years ago[PredicateInfo] Do not process unreachable operands.
Taewook Oh [Wed, 15 May 2019 19:35:38 +0000 (19:35 +0000)]
[PredicateInfo] Do not process unreachable operands.

Summary: We should excluded unreachable operands from processing as their DFS visitation order is undefined. When `renameUses` function sorts `OpsToRename` (https://fburl.com/d2wubn60), the comparator assumes that the parent block of the operand has a corresponding dominator tree node. This is not the case for unreachable operands and crashes the compiler.

Reviewers: dberlin, mgrang, davide

Subscribers: efriedma, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 360796

5 years agoPermit cross-CU references
Jan Kratochvil [Wed, 15 May 2019 19:22:33 +0000 (19:22 +0000)]
Permit cross-CU references

So far dw_offset_t was global for the whole SymbolFileDWARF but with
.debug_types the same dw_offset_t may mean two different things depending on
its section (=CU). So references now return whole new referenced DWARFDIE
instead of just dw_offset_t.

This means that some functions have to now handle 16 bytes instead of 8 bytes
but I do not see that anywhere performance critical.

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

llvm-svn: 360795