platform/upstream/llvm.git
4 years ago[analyzer] LoopWidening: fix crash by avoiding aliased references invalidation
Abbas Sabra [Tue, 9 Jun 2020 09:49:47 +0000 (12:49 +0300)]
[analyzer] LoopWidening: fix crash by avoiding aliased references invalidation

Summary: LoopWidening is invalidating references coming from type
aliases which lead to a crash.

Patch by Abbas Sabra!

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

4 years ago[clang-format] Brace breaking for C# lambdas
Jonathan Coe [Mon, 8 Jun 2020 20:22:02 +0000 (21:22 +0100)]
[clang-format] Brace breaking for C# lambdas

Reviewers: krasimir, MyDeveloperDay

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

4 years ago[Matrix] Add __builtin_matrix_transpose to Clang.
Florian Hahn [Tue, 9 Jun 2020 08:56:14 +0000 (09:56 +0100)]
[Matrix] Add __builtin_matrix_transpose to Clang.

This patch add __builtin_matrix_transpose to Clang, as described in
clang/docs/MatrixTypes.rst.

Reviewers: rjmccall, jfb, rsmith, Bigcheese

Reviewed By: rjmccall

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

4 years ago[AArch64][AsmParser] Fix debug output in a few instructions
Cullen Rhodes [Tue, 9 Jun 2020 08:53:09 +0000 (08:53 +0000)]
[AArch64][AsmParser] Fix debug output in a few instructions

Summary:
In the parsing of BTIHint, PSBHint and Prefetch the identifier token
should be lexed after creating the operand, otherwise the StringRef is
moved before being copied and the debug output is incorrect.

Prefetch example:

    $ echo "prfm   pldl1keep, [x2]" | ./bin/llvm-mc \
        -triple aarch64-none-linux-gnu -show-encoding -debug

    Before:

      Matching formal operand class MCK_Prefetch against actual operand at
      index 1 (<prfop ,>): match success using generic matcher

    After:

      Matching formal operand class MCK_Prefetch against actual operand at
      index 1 (<prfop pldl1keep>): match success using generic matcher

Reviewed By: david-arm

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

4 years ago[DebugInfo] Check for errors when reading data for extended opcode
James Henderson [Thu, 21 May 2020 14:14:16 +0000 (15:14 +0100)]
[DebugInfo] Check for errors when reading data for extended opcode

Previously, if an extended opcode was truncated, it would manifest as an
"unexpected line op length error" which wasn't quite accurate. This
change checks for errors any time data is read whilst parsing an
extended opcode, and reports any errors detected.

Reviewed by: MaskRay, labath, aprantl

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

4 years agoFix unused variable warning
Guillaume Chatelet [Tue, 9 Jun 2020 08:56:05 +0000 (08:56 +0000)]
Fix unused variable warning

4 years ago[AArch64][SVE] Implement structured load intrinsics
Cullen Rhodes [Tue, 26 May 2020 10:50:35 +0000 (10:50 +0000)]
[AArch64][SVE] Implement structured load intrinsics

Summary:
This patch adds initial support for the following instrinsics:

    * llvm.aarch64.sve.ld2
    * llvm.aarch64.sve.ld3
    * llvm.aarch64.sve.ld4

For loading two, three and four vectors worth of data. Basic codegen is
implemented with reg+reg and reg+imm addressing modes being addressed
in a later patch.

The types returned by these intrinsics have a number of elements that is a
multiple of the elements in a 128-bit vector for a given type and N, where N is
the number of vectors being loaded, i.e. 2, 3 or 4. Thus, for 32-bit elements
the types are:

    LD2 : <vscale x 8 x i32>
    LD3 : <vscale x 12 x i32>
    LD4 : <vscale x 16 x i32>

This is implemented with target-specific intrinsics for each variant that take
the same operands as the IR intrinsic but return N values, where the type of
each value is a full vector, i.e. <vscale x 4 x i32> in the above example.
These values are then concatenated using the standard concat_vector intrinsic
to maintain type legality with the IR.

These intrinsics are intended for use in the Arm C Language
Extension (ACLE).

Reviewed By: sdesmalen

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

4 years ago[VE] Support Transfer Control Instructions in MC layer
Kazushi (Jam) Marukawa [Tue, 9 Jun 2020 08:39:03 +0000 (10:39 +0200)]
[VE] Support Transfer Control Instructions in MC layer

Summary:
Add regression tests of asmparser, mccodeemitter, and disassembler for
transfer control instructions.  Add FENCEI/FENCEM/FENCEC/SVOB instructions
also.  Add new instruction format to represent FENCE* instructions too.

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

4 years ago[AMDGPU/MemOpsCluster] Implement new heuristic for computing max mem ops cluster...
hsmahesha [Tue, 9 Jun 2020 08:38:35 +0000 (14:08 +0530)]
[AMDGPU/MemOpsCluster] Implement new heuristic for computing max mem ops cluster size

Summary:
Make use of both the - (1) clustered bytes and (2) cluster length, to decide on
the max number of mem ops that can be clustered. On an average, when loads
are dword or smaller, consider `5` as max threshold, otherwise `4`. This heuristic
is purely based on different experimentation conducted, and there is no analytical
logic here.

Reviewers: foad, rampitec, arsenm, vpykhtin

Reviewed By: foad, rampitec

Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, Anastasia, t-tye, hiraditya, kerbowa, llvm-commits

Tags: #llvm

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

4 years ago[VE] Support lowering to NND instruction
Kazushi (Jam) Marukawa [Tue, 9 Jun 2020 08:17:20 +0000 (10:17 +0200)]
[VE] Support lowering to NND instruction

Summary:
Support NND instruction of Aurora VE.  Add hasAndNot function also
for optimization.

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

4 years ago[AVR][test] Remove test for naked function containing a return.
Simon Wallis [Tue, 9 Jun 2020 07:32:46 +0000 (08:32 +0100)]
[AVR][test] Remove test for naked function containing a return.

Summary:
Remove an old test for an explicit return in a naked function from test/CodeGen/AVR/return.ll

clang no longer allows a C return in a naked function.

This test is causing failure of the patch https://reviews.llvm.org/D80715

Reviewers: llvm-commits, dylanmckay

Reviewed By: dylanmckay

Subscribers: Jim

Tags: #llvm

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

Change-Id: Id218027e520247ae480b92e7801a660fbe0cf29b

4 years ago[Alignment] Fix deprecation message
Guillaume Chatelet [Tue, 9 Jun 2020 08:05:13 +0000 (08:05 +0000)]
[Alignment] Fix deprecation message

4 years ago[AMDGPU] Enable structurizer workarounds by default
Sameer Sahasrabuddhe [Tue, 9 Jun 2020 07:44:15 +0000 (13:14 +0530)]
[AMDGPU] Enable structurizer workarounds by default

Reviewed By: nhaehnle

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

4 years ago[MachineVerifier] Add TiedOpsRewritten flag to fix verify two-address error
Kang Zhang [Tue, 9 Jun 2020 07:39:42 +0000 (07:39 +0000)]
[MachineVerifier] Add TiedOpsRewritten flag to fix verify two-address error

Summary:
Currently, MachineVerifier will attempt to verify that tied operands
satisfy register constraints as soon as the function is no longer in
SSA form. However, PHIElimination will take the function out of SSA
form while TwoAddressInstructionPass will actually rewrite tied operands
to match the constraints. PHIElimination runs first in the pipeline.
Therefore, whenever the MachineVerifier is run after PHIElimination,
it will encounter verification errors on any tied operands.

This patch adds a function property called TiedOpsRewritten that will be
set by TwoAddressInstructionPass and will control when the verifier checks
tied operands.

Reviewed By: nemanjai

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

4 years ago[AArch64] Fix branch, terminator, etc properties for BRA* instructions.
Kristof Beyls [Tue, 9 Jun 2020 07:11:02 +0000 (08:11 +0100)]
[AArch64] Fix branch, terminator, etc properties for BRA* instructions.

Tests relying on some of these fixes will be added for this in follow-on
patches that introduce new features that require these properties to be
correct.

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

4 years ago[CodeGen] Ensure callers of CreateStackTemporary use sensible alignments
David Sherwood [Tue, 2 Jun 2020 10:16:23 +0000 (11:16 +0100)]
[CodeGen] Ensure callers of CreateStackTemporary use sensible alignments

In two instances of CreateStackTemporary we are sometimes promoting
alignments beyond the stack alignment. I have introduced a new function
called getReducedAlign that will return the alignment for the broken
down parts of illegal vector types. For example, on NEON a <32 x i8>
type is made up of two <16 x i8> types - in this case the sensible
alignment is 16 bytes, not 32.

In the legalization code wherever we create stack temporaries I have
started using the reduced alignments instead for illegal vector types.

I added a test to

  CodeGen/AArch64/build-one-lane.ll

that tries to insert an element into an illegal fixed vector type
that involves creating a temporary stack object.

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

4 years ago[NFCI][CostModel] Unify getCmpSelInstrCost
Sam Parker [Tue, 26 May 2020 13:28:34 +0000 (14:28 +0100)]
[NFCI][CostModel] Unify getCmpSelInstrCost

Add cases for icmp, fcmp and select into the switch statement of the
generic getUserCost implementation with getInstructionThroughput then
calling into it. The BasicTTI and backend implementations have be set
to return a default value (1) when a cost other than throughput is
being queried.

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

4 years ago[CodeGen,AArch64] Fix up warnings in splitStores
David Sherwood [Thu, 28 May 2020 13:22:49 +0000 (14:22 +0100)]
[CodeGen,AArch64] Fix up warnings in splitStores

The code for trying to split up stores is designed for NEON vectors,
where we support arbitrary alignments. It's an optimisation designed
to improve performance by using smaller, aligned stores. However,
we currently only support 16 byte alignments for SVE vectors anyway
so we may as well bail out early.

This change fixes up remaining warnings in a couple of tests:

  CodeGen/AArch64/sve-callbyref-notailcall.ll
  CodeGen/AArch64/sve-calling-convention-byref.ll

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

4 years ago[AMDGPU] Custom lowering of i64 umulo/smulo
Stanislav Mekhanoshin [Mon, 8 Jun 2020 20:52:16 +0000 (13:52 -0700)]
[AMDGPU] Custom lowering of i64 umulo/smulo

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

4 years ago[X86] Autogenerate complete checks and add encoding information. NFC
Craig Topper [Tue, 9 Jun 2020 05:23:48 +0000 (22:23 -0700)]
[X86] Autogenerate complete checks and add encoding information. NFC

I think we're using an inefficient CMP encoding for absolute
symbols that would fit in an 8-bit value. This is a pattern
priority issue in isel.

4 years ago[libc][NFC] Add few more missing entrypoints to the entrypoint list.
Siva Chandra Reddy [Tue, 9 Jun 2020 05:08:42 +0000 (22:08 -0700)]
[libc][NFC] Add few more missing entrypoints to the entrypoint list.

They were likely missed while rebasing.

4 years ago[libc][NFC] Add bzero to list of entrypoints.
Siva Chandra Reddy [Tue, 9 Jun 2020 00:31:04 +0000 (17:31 -0700)]
[libc][NFC] Add bzero to list of entrypoints.

A new LLVM libc specific extension standard spec has been added.

4 years ago[NFC][PowerPC] Remove the redundant InstAlias for OR instruction
Kang Zhang [Tue, 9 Jun 2020 03:32:27 +0000 (03:32 +0000)]
[NFC][PowerPC] Remove the redundant InstAlias for OR instruction

Summary:
We have handle the InstAlias for OR instructions, but we handle it
agagin in PPCInstPrinter.cpp.
This patch is to Remove the redundant InstAlias for OR instruction.

Reviewed By: steven.zhang

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

4 years agotest: repair lld builder
Saleem Abdulrasool [Tue, 9 Jun 2020 02:22:02 +0000 (19:22 -0700)]
test: repair lld builder

Add the explicit `-arch x86_64` to the invocation.

4 years ago[APInt] set all bits for getBitsSetWithWrap if loBit == hiBit
Chen Zheng [Tue, 9 Jun 2020 02:43:04 +0000 (22:43 -0400)]
[APInt] set all bits for getBitsSetWithWrap if loBit == hiBit

differentiate getBitsSetWithWrap & getBitsSet when loBit == hiBit
getBitsSetWithWrap sets all bits;
getBitsSet does nothing.

Reviewed By: lkail, RKSimon, lebedev.ri

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

4 years ago[PowerPC] Fix pattern for DCBFL/DCBFLP instrinsics.
Anil Mahmud [Tue, 9 Jun 2020 01:54:59 +0000 (20:54 -0500)]
[PowerPC] Fix pattern for DCBFL/DCBFLP instrinsics.

The previous implementation used "asm parser only" pseudo-instructions in their
output patterns. Those are not meant to emit code and will caused crashes when
built with -filetype=obj.

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

4 years ago[PowerPC] Remove extra instruction left by emitRLDICWhenLoweringJumpTables
Anil Mahmud [Tue, 9 Jun 2020 01:43:56 +0000 (20:43 -0500)]
[PowerPC] Remove extra instruction left by emitRLDICWhenLoweringJumpTables

The function emitRLDICWhenLoweringJumpTables in PPCMIPeephole.cpp
was supposed to convert a pair of RLDICL and RLDICR to a single RLDIC,
but it was leaving out the RLDICL instruction. This PR fixes the bug.

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

4 years ago[PowerPC] Fix incorrect PC Relative relocations for Big Endian
Stefan Pintilie [Tue, 9 Jun 2020 01:20:42 +0000 (20:20 -0500)]
[PowerPC] Fix incorrect PC Relative relocations for Big Endian

Fix the incorrect PC Relative relocations for Big Endian for 34 bit offsets.
The offset should be zero for both BE and LE in this situation.

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

4 years agoMake myself code owner of InferAddressSpaces
Matt Arsenault [Sat, 15 Jun 2019 17:25:03 +0000 (13:25 -0400)]
Make myself code owner of InferAddressSpaces

The original author isn't active, and I've made most of the commits to
it.

4 years agolld: initial pass at supporting TBD
Saleem Abdulrasool [Fri, 5 Jun 2020 18:18:33 +0000 (11:18 -0700)]
lld: initial pass at supporting TBD

Add support to lld to use Text Based API stubs for linking.  This is
support is incomplete not filtering out platforms.  It also does not
account for architecture specific API handling and potentially does not
correctly handle trees of re-exports with inlined libraries being
treated as direct children of the top level library.

4 years ago[mlir] Unranked memref type has no rank
Jacques Pienaar [Tue, 9 Jun 2020 01:00:35 +0000 (18:00 -0700)]
[mlir] Unranked memref type has no rank

Summary:
UnrankedMemRefType doesn't have a rank but previously this was just
checking for unranked tensor. Avoids failure later if one queries the shape
post checking if ranked.

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

4 years ago[AArch64] Support expression results as immediate values in mov
Jian Cai [Tue, 9 Jun 2020 00:56:46 +0000 (17:56 -0700)]
[AArch64] Support expression results as immediate values in mov

Summary:
This patch adds support of using the result of an expression as an
immediate value. For example,

0:
.skip 4
 1:
mov x0, 1b - 0b

is assembled to

mov x0, #4

Currently it does not support expressions requiring relocation unless
explicitly specified. This fixes PR#45781.

Reviewers: peter.smith, ostannard, efriedma

Reviewed By: efriedma

Subscribers: nickdesaulniers, llozano, manojgupta, efriedma, ostannard, kristof.beyls, hiraditya, danielkiss, llvm-commits

Tags: #llvm

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

4 years ago[AMDGPU][NFC] Skip processing intrinsics that do not become real instructions
dfukalov [Sat, 6 Jun 2020 00:47:05 +0000 (03:47 +0300)]
[AMDGPU][NFC] Skip processing intrinsics that do not become real instructions

Reviewers: rampitec

Reviewed By: rampitec

Subscribers: arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, kerbowa, llvm-commits

Tags: #llvm

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

4 years ago[libc][NFC][Obvious] Add names to various string entrypoints.
Siva Chandra Reddy [Tue, 9 Jun 2020 00:09:28 +0000 (17:09 -0700)]
[libc][NFC][Obvious] Add names to various string entrypoints.

4 years agoRevert "[arm][darwin] Don't generate libcalls for wide shifts on Darwin"
Eli Friedman [Mon, 8 Jun 2020 23:35:10 +0000 (16:35 -0700)]
Revert "[arm][darwin] Don't generate libcalls for wide shifts on Darwin"

This reverts commit 2ba016cd5ce50a3683d3e6c2c62f00e1cccfd8b5.

This is causing a failure on the clang-cmake-armv7-full bot, and there
are outstanding review comments.

4 years ago[InstrProfiling] Use -fuse-ld=lld in instrprof-gc-sections test
Petr Hosek [Mon, 8 Jun 2020 23:34:57 +0000 (16:34 -0700)]
[InstrProfiling] Use -fuse-ld=lld in instrprof-gc-sections test

This was accidentally omitted in 603d58b leading to a test failure
on some of the bots that don't use lld as the default linker.

4 years ago[MLIR][SPIRVToLLVM] Add skeleton for SPIR-V to LLVM dialect conversion
George Mitenkov [Mon, 8 Jun 2020 22:20:52 +0000 (18:20 -0400)]
[MLIR][SPIRVToLLVM] Add skeleton for SPIR-V to LLVM dialect conversion

These commits set up the skeleton for SPIR-V to LLVM dialect conversion.
I created SPIR-V to LLVM pass, registered it in Passes.td, InitAllPasses.h.
Added a pattern for `spv.BitwiseAndOp` and tests for it. Integer, float
and vector types are converted through LLVMTypeConverter.

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

4 years ago[MLIR][Toy] Fix a few typos in the comments/docs.
KareemErgawy [Mon, 8 Jun 2020 22:18:06 +0000 (18:18 -0400)]
[MLIR][Toy] Fix a few typos in the comments/docs.

Fixes a few typos and errors in MLIR's Toy tutorial docs and comments.

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

4 years ago[InstrProfiling] Use !associated metadata for counters, data and values
Petr Hosek [Sat, 13 Jul 2019 21:02:07 +0000 (14:02 -0700)]
[InstrProfiling] Use !associated metadata for counters, data and values

The !associated metadata may be attached to a global object declaration
with a single argument that references another global object. This
metadata prevents discarding of the global object in linker GC unless
the referenced object is also discarded.

Furthermore, when a function symbol is discarded by the linker, setting
up !associated metadata allows linker to discard counters, data and
values associated with that function symbol. This is not possible today
because there's metadata to guide the linker. This approach is also used
by other instrumentations like sanitizers.

Note that !associated metadata is only supported by ELF, it does not have
any effect on non-ELF targets.

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

4 years agoRevert "[InstrProfiling] Use !associated metadata for counters, data and values"
Petr Hosek [Mon, 8 Jun 2020 21:37:27 +0000 (14:37 -0700)]
Revert "[InstrProfiling] Use !associated metadata for counters, data and values"

This reverts commit 39b3c41b65302a969fa5507402976a255a07c158 due to
a failing associated.ll test.

4 years agoStabilize alloca slices sort in SROA
Stanislav Mekhanoshin [Mon, 8 Jun 2020 15:27:07 +0000 (08:27 -0700)]
Stabilize alloca slices sort in SROA

Slice::operator<() has a non-deterministic behavior. If we have
identical slices comparison will depend on the order or operands.
Normally that does not result in unstable compilation results
because the order in which slices are inserted into the vector
is deterministic and llvm::sort() normally behaves as a stable
sort, although that is not guaranteed.

However, there is test option -sroa-random-shuffle-slices which
is used to check exactly this aspect. The vector is first randomly
shuffled and then sorted. The same shuffling happens without this
option under expensive llvm checks.

I have managed to write a test which has hit this problem.

There are no fields in the Slice class to resolve the instability.
We only have offsets, IsSplittable and Use, but neither Use nor
User have anything suitable for predictable comparison.

I have switched to stable_sort which has to be sufficient and
removed that randon shuffle option.

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

4 years agoRemove improper uses of DiagnosticErrorTrap and hasErrorOccurred.
Richard Smith [Mon, 8 Jun 2020 21:04:54 +0000 (14:04 -0700)]
Remove improper uses of DiagnosticErrorTrap and hasErrorOccurred.

DiagnosticErrorTrap is usually inappropriate because it indicates
whether an error message was rendered in a given region (and is
therefore affected by -ferror-limit and by suppression of errors if we
see an invalid declaration).

hasErrorOccurred() is usually inappropriate because it indicates
whethere an "error:" message was displayed, regardless of whether the
message was a warning promoted to an error, and therefore depends on
things like -Werror that are usually irrelevant.

Where applicable, CodeSynthesisContexts are used to attach notes to
the first diagnostic produced in a region of code, isnstead of using an
error trap and then attaching a note to whichever diagnostic happened to
be produced last (or suppressing the note if the final diagnostic is a
disabled warning!).

This is mostly NFC.

4 years agoAdd #includes so that ROCm.h is compilable stand-alone.
Sterling Augustine [Mon, 8 Jun 2020 21:11:14 +0000 (14:11 -0700)]
Add #includes so that ROCm.h is compilable stand-alone.

Summary:
ROCm.h had been getting the declarations for various data structures
by being #included next to them, rather than #includeing them itself.

This change fixes that by explicitly including the appropriate headers.

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[DebugInfo] Fix assertion for extern void type
Yonghong Song [Sat, 6 Jun 2020 01:37:38 +0000 (18:37 -0700)]
[DebugInfo] Fix assertion for extern void type

Commit d77ae1552fc2 ("[DebugInfo] Support to emit debugInfo
for extern variables") added support to emit debuginfo
for extern variables. Currently, only BPF target enables to
emit debuginfo for extern variables.

But if the extern variable has "void" type, the compilation will
fail.

  -bash-4.4$ cat t.c
  extern void bla;
  void *test() {
    void *x = &bla;
    return x;
  }
  -bash-4.4$ clang -target bpf -g -O2 -S t.c
  missing global variable type
  !1 = distinct !DIGlobalVariable(name: "bla", scope: !2, file: !3, line: 1,
                                  isLocal: false, isDefinition: false)
  ...
  fatal error: error in backend: Broken module found, compilation aborted!
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace,
      preprocessed source, and associated run script.
  Stack dump:
  ...

The IR requires a DIGlobalVariable must have a valid type and the
"void" type does not generate any type, hence the above fatal error.

Note that if the extern variable is defined as "const void", the
compilation will succeed.

-bash-4.4$ cat t.c
extern const void bla;
const void *test() {
  const void *x = &bla;
  return x;
}
-bash-4.4$ clang -target bpf -g -O2 -S t.c
-bash-4.4$ cat t.ll
...
!1 = distinct !DIGlobalVariable(name: "bla", scope: !2, file: !3, line: 1,
                                type: !6, isLocal: false, isDefinition: false)
!6 = !DIDerivedType(tag: DW_TAG_const_type, baseType: null)
...

Since currently, "const void extern_var" is supported by the
debug info, it is natural that "void extern_var" should also
be supported. This patch disabled assertion of "void extern_var"
in IR verifier and add proper guarding when emiting potential
null debug info type to dwarf types.

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

4 years ago[InstrProfiling] Use !associated metadata for counters, data and values
Petr Hosek [Sat, 13 Jul 2019 21:02:07 +0000 (14:02 -0700)]
[InstrProfiling] Use !associated metadata for counters, data and values

The !associated metadata may be attached to a global object declaration
with a single argument that references another global object. This
metadata prevents discarding of the global object in linker GC unless
the referenced object is also discarded.

Furthermore, when a function symbol is discarded by the linker, setting
up !associated metadata allows linker to discard counters, data and
values associated with that function symbol. This is not possible today
because there's metadata to guide the linker. This approach is also used
by other instrumentations like sanitizers.

Note that !associated metadata is only supported by ELF, it does not have
any effect on non-ELF targets.

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

4 years ago[Support] FoldingSetNodeID::AddString(): reserve memory
Roman Lebedev [Mon, 8 Jun 2020 20:26:54 +0000 (23:26 +0300)]
[Support] FoldingSetNodeID::AddString(): reserve memory

Summary:
It is traditionally potentially very inefficient to not preallocate the memory,
but rely on reallocation every time you push something into vector.

For example, looking at unity build of RawSpeed
(`-O3 -g0 -emit-llvm -Xclang -disable-llvm-optzns`),
the memory story is as follows:
```
total runtime: 11.34s.
calls to allocation functions: 2694053 (237612/s)
temporary memory allocations: 645188 (56904/s)
peak heap memory consumption: 231.36MB
peak RSS (including heaptrack overhead): 397.39MB
```

Looking at details, `FoldingSetNodeID::AddString()` is noteworthy, frequently called and is allocation-heavy.

But it is quite obvious how many times we will push into `Bits` - we will push `String.size()` itself,
and then we will push once per every 4 bytes of `String` (padding last block).

And if we preallocate, we get:
```
total runtime: 11.20s.
calls to allocation functions: 2594704 (231669/s)
temporary memory allocations: 560004 (50000/s)
peak heap memory consumption: 231.36MB
peak RSS (including heaptrack overhead): 398.06MB
```
Which is a measurable win:
```
total runtime: -0.14s.                             #  -1.23 %
calls to allocation functions: -99349 (719920/s)   #  -3.69 %
temporary memory allocations: -85184 (617275/s)    # -13.2 % (!)
peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B
```

Reviewers: efriedma, nikic, bkramer

Reviewed By: bkramer

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[lld] Fix shared library build by adding the missing dependency.
Michael Liao [Mon, 8 Jun 2020 20:12:58 +0000 (16:12 -0400)]
[lld] Fix shared library build by adding the missing dependency.

4 years agoMore robust fix for crash on invalid range-based for statement.
Richard Smith [Mon, 8 Jun 2020 18:52:14 +0000 (11:52 -0700)]
More robust fix for crash on invalid range-based for statement.

Reliably mark the loop variable declaration in a range for as having an
invalid initializer if anything goes wrong building the initializer. We
previously based this determination on whether an error was emitted,
which is not a reliable signal due to error suppression (during error
recovery etc).

Also, properly mark the variable as having initializer errors rather
than simply marking it invalid. This is necessary to mark any structured
bindings as invalid too.

This generalizes the previous fix in
936ec89e91e2dda8b6110b1fd1f9920509d7a17b.

4 years ago[XCOFF][AIX] report_fatal_error when an overflow section is needed
jasonliu [Mon, 8 Jun 2020 18:51:33 +0000 (18:51 +0000)]
[XCOFF][AIX] report_fatal_error when an overflow section is needed

If there are more than 65534 relocation entries in a single section,
we should generate an overflow section.
Since we don't support overflow section for now, we should generate
an error.

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

4 years agoApply fix from D81179 only from GCC < 8
Valentin Clement [Mon, 8 Jun 2020 18:38:18 +0000 (14:38 -0400)]
Apply fix from D81179 only from GCC < 8

Summary: Apply workaround done in D81179 only for GCC < 8. As @klausler mentioned in D81179 we want to avoid additional checks for other compilers that do not need them.

Reviewers: DavidTruby, klausler, jdoerfert, sscalpone

Reviewed By: klausler, sscalpone

Subscribers: llvm-commits, tskeith, isuruf, klausler

Tags: #flang, #llvm

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

4 years agoRevert "Reland D80966 [codeview] Put !heapallocsite on calls to operator new"
Arthur Eubanks [Mon, 8 Jun 2020 19:48:03 +0000 (12:48 -0700)]
Revert "Reland D80966 [codeview] Put !heapallocsite on calls to operator new"

This reverts commit b6e143aa5448bbe29da7b045072e66a31813bced.

Causes https://bugs.chromium.org/p/chromium/issues/detail?id=1092370#c5.
Will investigate and reland (again).

4 years ago[gn build] Port bb677cacc80
LLVM GN Syncbot [Mon, 8 Jun 2020 19:44:56 +0000 (19:44 +0000)]
[gn build] Port bb677cacc80

4 years ago[SuffixTree][MachOpt] Factoring out Suffix Tree and adding Unit Tests
Andrew Litteken [Wed, 8 Apr 2020 22:21:49 +0000 (15:21 -0700)]
[SuffixTree][MachOpt] Factoring out Suffix Tree and adding Unit Tests

This moves the SuffixTree test used in the Machine Outliner and moves it into Support for use in other outliners elsewhere in the compilation pipeline.

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

4 years ago[TSan] Revert removal of ignore_interceptors_accesses flag
Julian Lettner [Mon, 8 Jun 2020 19:01:14 +0000 (12:01 -0700)]
[TSan] Revert removal of ignore_interceptors_accesses flag

This flag suppresses TSan FPs on Darwin.  I removed this flag
prematurely and have been dealing with the fallout ever since.

This commit puts back the flag, reverting 7d1085cb [1].

[1] https://reviews.llvm.org/D55075

4 years agoAdd a flag to debug automatic variable initialization
Jian Cai [Mon, 8 Jun 2020 18:53:23 +0000 (11:53 -0700)]
Add a flag to debug automatic variable initialization

Summary:
Add -ftrivial-auto-var-init-stop-after= to limit the number of times
stack variables are initialized when -ftrivial-auto-var-init= is used to
initialize stack variables to zero or a pattern. This flag can be used
to bisect uninitialized uses of a stack variable exposed by automatic
variable initialization, such as http://crrev.com/c/2020401.

Reviewers: jfb, vitalybuka, kcc, glider, rsmith, rjmccall, pcc, eugenis, vlad.tsyrklevich

Reviewed By: jfb

Subscribers: phosek, hubert.reinterpretcast, srhines, MaskRay, george.burgess.iv, dexonsmith, inglorion, gbiv, llozano, manojgupta, cfe-commits

Tags: #clang

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

4 years agoRevert "[clangd] Resolve driver symlinks, and look up unknown relative drivers in...
Nico Weber [Mon, 8 Jun 2020 19:20:16 +0000 (15:20 -0400)]
Revert "[clangd] Resolve driver symlinks, and look up unknown relative drivers in PATH."

This reverts commit 806342b8ef54ec07511d0ce5d3d1335451e952da.
Breaks check-clangd on macOS, https://reviews.llvm.org/D75414#2080076

4 years ago[AArch64] Fix ldst-opt of multiple disjunct subregs.
Florian Hahn [Mon, 8 Jun 2020 18:25:14 +0000 (19:25 +0100)]
[AArch64] Fix ldst-opt of multiple disjunct subregs.

Currently aarch64-ldst-opt will incorrectly rename registers with
multiple disjunct subregisters (e.g. result of LD3). This patch updates
the canRenameUpToDef to bail out if it encounters such a register class
that contains the register to rename.

Fixes PR46105.

Reviewers: efriedma, dmgreen, paquette, t.p.northover

Reviewed By: efriedma

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

4 years ago[flang] Fix issue of flang/runtime/config.h not being found in out of tree builds
Isuru Fernando [Mon, 8 Jun 2020 19:13:58 +0000 (14:13 -0500)]
[flang] Fix issue of flang/runtime/config.h not being found in out of tree builds

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

Reviewers: DavidTruby, jdoerfert, PeteSteinfeld, sscalpone, tskeith

Reviewed By: PeteSteinfeld, sscalpone, tskeith

Subscribers: mgorny, llvm-commits, tskeith

Tags: #llvm, #flang

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

4 years ago[PGO] CallPromotion: Don't try to pass sret args to varargs functions
Hans Wennborg [Mon, 8 Jun 2020 16:36:56 +0000 (18:36 +0200)]
[PGO] CallPromotion: Don't try to pass sret args to varargs functions

It's not allowed by the verifier.

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

4 years agoMove *San module passes later in the NPM pipeline
Arthur Eubanks [Thu, 28 May 2020 22:00:17 +0000 (15:00 -0700)]
Move *San module passes later in the NPM pipeline

Summary:
This fixes pr33372.cpp under the new pass manager.

ASan adds padding to globals. For example, it will change a {i32, i32, i32} to a {{i32, i32, i32}, [52 x i8]}. However, when loading from the {i32, i32, i32}, InstCombine may (after various optimizations) end up loading 16 bytes instead of 12, likely because it thinks the [52 x i8] padding is ok to load from. But ASan checks that padding should not be loaded from.

Ultimately this is an issue of *San passes wanting to be run after all optimizations. This change moves the module passes right next to the corresponding function passes.

Also remove comment that's no longer relevant, this is the last ASan/MSan/TSan failure under the NPM (hopefully...).

As mentioned in https://reviews.llvm.org/rG1285e8bcac2c54ddd924ffb813b2b187467ac2a6, NPM doesn't support LTO + sanitizers, so modified some tests that test for that.

Reviewers: leonardchan, vitalybuka

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[libc++] Improve tests for iterators.operations
Louis Dionne [Mon, 8 Jun 2020 18:58:46 +0000 (14:58 -0400)]
[libc++] Improve tests for iterators.operations

Reduce duplication between the constexpr and the non-constexpr test cases,
and add tests for the return type of the various operations.

4 years ago[X86] Prevent LowerSELECT from causing suboptimal codegen for __builtin_ffs(X) - 1.
Craig Topper [Mon, 8 Jun 2020 18:26:11 +0000 (11:26 -0700)]
[X86] Prevent LowerSELECT from causing suboptimal codegen for __builtin_ffs(X) - 1.

LowerSELECT sees the CMP with 0 and wants to use a trick with SUB
and SBB. But we can use the flags from the BSF/TZCNT.

Fixes PR46203.

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

4 years ago[ModuloSchedule] Support instructions with > 1 destination when walking canonical...
Hendrik Greving [Fri, 5 Jun 2020 18:34:34 +0000 (11:34 -0700)]
[ModuloSchedule] Support instructions with > 1 destination when walking canonical use.

Fixes a minor bug that led to finding the wrong register if the definition had more
than one register destination.

4 years ago[InstCombine] improve matching for sext-lshr-trunc patterns, part 2
Sanjay Patel [Mon, 8 Jun 2020 18:09:04 +0000 (14:09 -0400)]
[InstCombine] improve matching for sext-lshr-trunc patterns, part 2

Similar to rG42f488b63a04

This is intended to preserve the logic of the existing transform,
but remove unnecessary restrictions on uses and types.

https://rise4fun.com/Alive/oS0

  Name: narrow input
  Pre: C1 <= width(C1) - 24
  %B = sext i8 %A
  %C = lshr %B, C1
  %r = trunc %C to i24
  =>
  %s = ashr i8 %A, trunc(umin(C1, 7))
  %r = sext i8 %s to i24

  Name: wide input
  Pre: C1 <= width(C1) - 24
  %B = sext i24 %A
  %C = lshr %B, C1
  %r = trunc %C to i8
  =>
  %s = ashr i24 %A, trunc(umin(C1, 23))
  %r = trunc i24 %s to i8

4 years ago[InstCombine] add tests for sext+lshr+trunc; NFC
Sanjay Patel [Mon, 8 Jun 2020 17:08:40 +0000 (13:08 -0400)]
[InstCombine] add tests for sext+lshr+trunc; NFC

Shows missing transforms with extra uses and vectors.

4 years ago[SVE] Eliminate calls to default-false VectorType::get() from llvm-stress
Christopher Tetreault [Mon, 8 Jun 2020 18:07:25 +0000 (11:07 -0700)]
[SVE] Eliminate calls to default-false VectorType::get() from llvm-stress

Reviewers: efriedma, kmclaughlin, sdesmalen, MaskRay, JDevlieghere

Reviewed By: sdesmalen

Subscribers: tschuett, rkruppe, psnobl, llvm-commits

Tags: #llvm

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

4 years ago[DebugInfo] Reduce SalvageDebugInfo() functions
Chris Jackson [Mon, 8 Jun 2020 17:44:11 +0000 (18:44 +0100)]
[DebugInfo] Reduce SalvageDebugInfo() functions

- Now all SalvageDebugInfo() calls will mark undef if the salvage
  attempt fails.

 Reviewed by: vsk, Orlando

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

4 years agoRename arg name in __clang_hip_math.h
Yaxun (Sam) Liu [Mon, 8 Jun 2020 17:42:52 +0000 (13:42 -0400)]
Rename arg name in __clang_hip_math.h

__sptr is a keyword for ms-extension. Change it from __sptr to __sinptr.

4 years agolld: improve the `-arch` handling for MachO
Saleem Abdulrasool [Sat, 6 Jun 2020 02:54:58 +0000 (19:54 -0700)]
lld: improve the `-arch` handling for MachO

Use the default target triple configured by the user to determine the
default architecture for `ld64.lld`.  Stash the architecture in the
configuration as when linking against TBDs, we will need to filter out
the symbols based upon the architecture.  Treat the Haswell slice as it
is equivalent to `x86_64` but with the extra Haswell extensions (e.g.
AVX2, FMA3, BMI1, etc).  This will make it easier to add new
architectures in the future.

This change also changes the failure mode where an invalid `-arch`
parameter will result in the linker exiting without further processing.

4 years ago[AArch64] Add a ldst-opt test with undef operands (NFC).
Florian Hahn [Mon, 8 Jun 2020 17:29:17 +0000 (18:29 +0100)]
[AArch64] Add a ldst-opt test with undef operands (NFC).

This patch adds a test to check that we do not use an undef renamable
register for renaming the other operand in a LDP instruction, as
suggested in D81108.

4 years ago[NFC] Fix quadratic LexicalScopes::constructScopeNest
Jan-Willem Maessen [Mon, 8 Jun 2020 17:38:16 +0000 (18:38 +0100)]
[NFC] Fix quadratic LexicalScopes::constructScopeNest

We sometimes have functions with large numbers of sibling basic
blocks (usually with an error path exit from each one). This was
triggering the qudratic behavior in this function - after visiting
each child llvm would re-scan the parent from the beginning again. We
modify the work stack to record the next index to be worked on
alongside the pointer. This avoids the need to linearly search for
the next unfinished child.

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

4 years ago[SVE] Eliminate calls to default-false VectorType::get() from CodeGen
Christopher Tetreault [Mon, 8 Jun 2020 17:12:08 +0000 (10:12 -0700)]
[SVE] Eliminate calls to default-false VectorType::get() from CodeGen

Reviewers: efriedma, c-rhodes, david-arm, spatel, craig.topper, aqjune, paquette, arsenm, gchatelet

Reviewed By: spatel, gchatelet

Subscribers: wdng, tschuett, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm

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

4 years ago[PGO][PGSO] Enable non-cold code size opts under non-partial-profile sample PGO.
Hiroshi Yamauchi [Tue, 2 Jun 2020 17:50:59 +0000 (10:50 -0700)]
[PGO][PGSO] Enable non-cold code size opts under non-partial-profile sample PGO.

Summary: Following up D78949.

Reviewers: davidxl

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[gn build] Port 550b5995233
LLVM GN Syncbot [Mon, 8 Jun 2020 16:55:22 +0000 (16:55 +0000)]
[gn build] Port 550b5995233

4 years ago[NFC] [libcxx] Remove shared_ptr's no-rvalue unique_ptr converting constructor.
zoecarver [Mon, 8 Jun 2020 16:47:48 +0000 (09:47 -0700)]
[NFC] [libcxx] Remove shared_ptr's no-rvalue unique_ptr converting constructor.

All compilers supported by libc++ have rvalues in C++03 mode so, there is no need for this non-rvalue overload.

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

4 years ago[Support] Replace 'DisableColors' boolean with 'ColorMode' enum
Jonas Devlieghere [Mon, 8 Jun 2020 16:46:34 +0000 (09:46 -0700)]
[Support] Replace 'DisableColors' boolean with 'ColorMode' enum

Replace the DisableColors with a ColorMode which can be set to Auto,
Enabled and Disabled. The purpose of this change is to make it possible
to ignore the command line option not only for disabling colors, but
also for enabling them.

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

4 years agoAMDGPU/GlobalISel: Precommit regenerated check lines
Matt Arsenault [Mon, 8 Jun 2020 16:46:55 +0000 (12:46 -0400)]
AMDGPU/GlobalISel: Precommit regenerated check lines

The update_*test_checks scripts miss new stuff added at the end of
lines. Regenerate checks so the new mode register operands don't show
up in the diff of a future patch.

4 years ago[Sema][CodeComplete][ObjC] Don't include arrow/dot fixits
David Goldman [Fri, 5 Jun 2020 14:57:33 +0000 (10:57 -0400)]
[Sema][CodeComplete][ObjC] Don't include arrow/dot fixits

Summary:
Exempt ObjC from arrow/dot fixits since this has limited value for
Objective-C, where properties (referenced by dot syntax) are normally
backed by ivars (referenced by arrow syntax).

In addition, the current implementation doesn't properly mark
the fix it condition for Objective-C.

This was initially added in https://reviews.llvm.org/D41537
for C++ and then later C, don't believe the Objective-C changes
were intentional.

Reviewers: sammccall, yvvan

Subscribers: jfb, cfe-commits

Tags: #clang

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

4 years ago[clangd] Drop unnecessary FS modifications in FindSymbolsTests
Kadir Cetinkaya [Mon, 8 Jun 2020 16:17:42 +0000 (18:17 +0200)]
[clangd] Drop unnecessary FS modifications in FindSymbolsTests

4 years agoReland D80979 [clang] Implement VectorType logic not operator
Fangrui Song [Mon, 8 Jun 2020 16:32:30 +0000 (09:32 -0700)]
Reland D80979 [clang] Implement VectorType logic not operator

With a fix to use -triple %itanium_abi_triple

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

4 years agoUpdates to the 'CLion Integration' section in ClangFormat docs
Ilya Biryukov [Mon, 8 Jun 2020 16:20:10 +0000 (19:20 +0300)]
Updates to the 'CLion Integration' section in ClangFormat docs

This commit updates the 'CLion Integration' section in ClangFormat docs.
Key changes:
- clang-format is enabled automatically when there is a config file;
- formatting now works for indentations;
- if clang-format is enabled without a config file, CLion suggests creating it based on the IDE settings or uses the LLVM style by default.

Patch by Marina Kalashina!

Reviewers: sylvestre.ledru, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ilya-biryukov, klimek, MyDeveloperDay, sammccall, gribozavr2

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

4 years ago[Support] Move color handling from raw_fd_ostream to raw_ostream
Jonas Devlieghere [Mon, 8 Jun 2020 15:47:55 +0000 (08:47 -0700)]
[Support] Move color handling from raw_fd_ostream to raw_ostream

Move the color handling code from raw_fd_ostream to raw_ostream. This
makes it possible to use colors with any ostream when enabled. The
existing behavior where only raw_fd_ostream supports colors by default
remains unchanged.

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

4 years ago[InstCombine] improve matching for sext-lshr-trunc patterns
Sanjay Patel [Mon, 8 Jun 2020 15:37:43 +0000 (11:37 -0400)]
[InstCombine] improve matching for sext-lshr-trunc patterns

This is intended to preserve the logic of the existing transform,
but remove unnecessary restrictions on uses and types.

https://rise4fun.com/Alive/pYfR

  Pre: C1 <= width(C1) - 8
  %B = sext i8 %A
  %C = lshr %B, C1
  %r = trunc %C to i8
   =>
  %r = ashr i8 %A, trunc(umin(C1, 7))

4 years ago[ObjC] Fix AST serialization for pseudo-strong parameters
David Goldman [Fri, 5 Jun 2020 18:00:13 +0000 (14:00 -0400)]
[ObjC] Fix AST serialization for pseudo-strong parameters

This bit was assumed to be always false for ParmVarDecls, but attribute
objc_externally_retained now can produce it.

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

4 years ago[mlir] Lower Shape binary ops (AddOp, MulOp) to Standard.
Alexander Belyaev [Mon, 8 Jun 2020 15:48:01 +0000 (17:48 +0200)]
[mlir] Lower Shape binary ops (AddOp, MulOp) to Standard.

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

4 years ago[AST] Fix a clang crash on an invalid for-range statement.
Haojian Wu [Mon, 8 Jun 2020 12:52:20 +0000 (14:52 +0200)]
[AST] Fix a clang crash on an invalid for-range statement.

Summary:
crash stack:

```
llvm-project/clang/lib/AST/ASTContext.cpp:2248: clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type *) const: Assertion `!A->getDeducedType().isNull() && "cannot request the size of an undeduced or dependent auto type"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
 #0 0x00000000025bb0bf llvm::sys::PrintStackTrace(llvm::raw_ostream&) llvm-project/llvm/lib/Support/Unix/Signals.inc:564:13
 #1 0x00000000025b92b0 llvm::sys::RunSignalHandlers() llvm-project/llvm/lib/Support/Signals.cpp:69:18
 #2 0x00000000025bb535 SignalHandler(int) llvm-project/llvm/lib/Support/Unix/Signals.inc:396:3
 #3 0x00007f9ef9298110 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14110)
 #4 0x00007f9ef8d72761 raise /build/glibc-M65Gwz/glibc-2.30/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f9ef8d5c55b abort /build/glibc-M65Gwz/glibc-2.30/stdlib/abort.c:81:7
 #6 0x00007f9ef8d5c42f get_sysdep_segment_value /build/glibc-M65Gwz/glibc-2.30/intl/loadmsgcat.c:509:8
 #7 0x00007f9ef8d5c42f _nl_load_domain /build/glibc-M65Gwz/glibc-2.30/intl/loadmsgcat.c:970:34
 #8 0x00007f9ef8d6b092 (/lib/x86_64-linux-gnu/libc.so.6+0x34092)
 #9 0x000000000458abe0 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const llvm-project/clang/lib/AST/ASTContext.cpp:0:5
```

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[clangd] Resolve driver symlinks, and look up unknown relative drivers in PATH.
Sam McCall [Thu, 28 May 2020 12:24:30 +0000 (14:24 +0200)]
[clangd] Resolve driver symlinks, and look up unknown relative drivers in PATH.

Summary:
This fixes a reported bug: if clang and libc++ are installed under
/usr/lib/llvm-11/...  but there'- a symlink /usr/bin/clang++-11, then a
compile_commands.json with "/usr/bin/clang++-11 -stdlib=libc++" would previously
look for libc++ under /usr/include instead of /usr/lib/llvm-11/include.
The PATH change makes this work if the compiler is just "clang++-11" too.

As this is now doing IO potentially on every getCompileCommand(), we cache
the results for each distinct driver.

While here:
- Added a Memoize helper for this as multithreaded caching is a bit noisy.
- Used this helper to simplify QueryDriverDatabase and reduce blocking there.
  (This makes use of the fact that llvm::Regex is now threadsafe)

Reviewers: kadircet

Subscribers: jyknight, ormris, ilya-biryukov, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[InstCombine] reduce code duplication in visitTrunc(); NFC
Sanjay Patel [Mon, 8 Jun 2020 15:15:13 +0000 (11:15 -0400)]
[InstCombine] reduce code duplication in visitTrunc(); NFC

4 years ago[InstCombine] add tests for sext+lshr+trunc; NFC
Sanjay Patel [Mon, 8 Jun 2020 13:33:00 +0000 (09:33 -0400)]
[InstCombine] add tests for sext+lshr+trunc; NFC

Shows missing transforms with extra uses and vectors.

4 years ago[TEST] TreeTest.cpp - Add a comma to avoid build error with -werror
Shengchen Kan [Mon, 8 Jun 2020 13:43:24 +0000 (21:43 +0800)]
[TEST] TreeTest.cpp - Add a comma to avoid build error with -werror

Summary:
The macro `INSTANTIATE_TEST_CASE_P` is defined as
```
\# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \
...
```

If we build the test case with -werror, we will get an error like
```
error: ISO C++11 requires at least one argument for the "..." in a
variadic macro

testing::ValuesIn(TestClangConfig::allConfigs()));
                                                ^
```
This patch fixes that.

Reviewers: gribozavr, hlopko, eduucaldas, gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

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

4 years agoThread safety analysis: Add note for double unlock
Aaron Puchert [Mon, 8 Jun 2020 14:30:06 +0000 (16:30 +0200)]
Thread safety analysis: Add note for double unlock

Summary:
When getting a warning that we release a capability that isn't held it's
sometimes not clear why. So just like we do for double locking, we add a
note on the previous release operation, which marks the point since when
the capability isn't held any longer.

We can find this previous release operation by looking up the
corresponding negative capability.

Reviewers: aaron.ballman, delesley

Reviewed By: aaron.ballman

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

4 years agoThread safety analysis: Support deferring locks
Aaron Puchert [Mon, 8 Jun 2020 14:29:53 +0000 (16:29 +0200)]
Thread safety analysis: Support deferring locks

Summary:
The standard std::unique_lock can be constructed to manage a lock without
initially acquiring it by passing std::defer_lock as second parameter.
It can be acquired later by calling lock().

To support this, we use the locks_excluded attribute. This might seem
like an odd choice at first, but its consistent with the other
annotations we support on scoped capability constructors. By excluding
the lock we state that it is currently not in use and the function
doesn't change that, which is exactly what the constructor does.

Along the way we slightly simplify handling of scoped capabilities.

Reviewers: aaron.ballman, delesley

Reviewed By: aaron.ballman

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

4 years agoFix build after removing llvm/CodeGen/GlobalISel/Types.h
Aaron Puchert [Mon, 8 Jun 2020 14:58:12 +0000 (16:58 +0200)]
Fix build after removing llvm/CodeGen/GlobalISel/Types.h

Removing the include was probably just forgotten after
f13ba22227ea221af55bdad43c94e9cc43ef0926.

4 years ago[Alignment][NFC] Deprecate dead code from CallingConvLower.h
Guillaume Chatelet [Mon, 8 Jun 2020 07:25:57 +0000 (07:25 +0000)]
[Alignment][NFC] Deprecate dead code from CallingConvLower.h

Summary: This is a followup on D81196.

Reviewers: courbet

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years agotsan: add OpenBSD support for Go
Dmitry Vyukov [Mon, 8 Jun 2020 14:45:39 +0000 (16:45 +0200)]
tsan: add OpenBSD support for Go

With the race_debug_openbsd_amd64.syso file created via this diff,
Go's race detector is able to detect a race in the example code
link: https://golang.org/doc/articles/race_detector.html
Reviewed-in: https://reviews.llvm.org/D80469
Author: qbit (Aaron Bieber)

4 years ago[ObjectYAML] Add support for error handling in DWARFYAML. NFC.
Xing GUO [Mon, 8 Jun 2020 14:48:32 +0000 (22:48 +0800)]
[ObjectYAML] Add support for error handling in DWARFYAML. NFC.

This patch intends to be an NFC-patch. Test cases will be added in a follow-up patch.

Reviewed By: jhenderson, grimar

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

4 years ago[flang] Use LLVM's flags
Isuru Fernando [Mon, 8 Jun 2020 14:08:35 +0000 (15:08 +0100)]
[flang] Use LLVM's flags

Summary:
The only difference is that LLVM_ENABLE_WERROR is set to OFF
by default, but we enable this in a standalone flang build

This commit fixes some windows issues with the flags

Reviewers: DavidTruby, jdoerfert, sscalpone

Reviewed By: DavidTruby, sscalpone

Subscribers: ormris, richard.barton.arm, mehdi_amini, Meinersbur, ChinouneMehdi, tskeith, mgorny, llvm-commits

Tags: #llvm, #flang

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

4 years agoGlobalISel: Remove dead include
Matt Arsenault [Mon, 8 Jun 2020 14:25:57 +0000 (10:25 -0400)]
GlobalISel: Remove dead include

4 years ago[CostModel] Follow-up to buildbot fix
Sam Parker [Mon, 8 Jun 2020 14:25:03 +0000 (15:25 +0100)]
[CostModel] Follow-up to buildbot fix

Adding type checks into the other backends that call
getTypeLegalizationCost.

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

4 years agoGlobalISel: Remove deprecated methods
Matt Arsenault [Mon, 8 Jun 2020 14:18:33 +0000 (10:18 -0400)]
GlobalISel: Remove deprecated methods

These have very few users to begin with, and have been marked
deprecated for 2 months which should be long enough for out of tree
targets.