platform/upstream/llvm.git
4 years ago[yaml2obj][MachO] - Fix PubName/PubType handling.
Georgii Rymar [Thu, 11 Jun 2020 20:18:40 +0000 (23:18 +0300)]
[yaml2obj][MachO] - Fix PubName/PubType handling.

`PubName` and `PubType` are optional fields since D80722.

They are defined as:
  Optional<PubSection> PubNames;
  Optional<PubSection> PubTypes;

And initialized in the following way:
  IO.mapOptional("debug_pubnames", DWARF.PubNames);
  IO.mapOptional("debug_pubtypes", DWARF.PubTypes);

But problem is that because of the issue in `YAMLTraits.cpp`,
when there are no `debug_pubnames`/`debug_pubtypes` keys in a YAML description,
they are not initialized to `Optional::None` as the code expects, but they
are initialized to default `PubSection()` instances.

Because of this, the `if` condition in the following code is always true:

if (Obj.DWARF.PubNames)
  Err = DWARFYAML::emitPubSection(OS, *Obj.DWARF.PubNames,
                                  Obj.IsLittleEndian);

What means `emitPubSection` is always called and it writes few values.

This patch fixes the issue. I've reduced `sizeofcmds` by size of data
previously written because of this bug.

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

4 years ago[lldb] Don't print IRForTarget errors directly to the console
Raphael Isemann [Fri, 12 Jun 2020 08:08:08 +0000 (10:08 +0200)]
[lldb] Don't print IRForTarget errors directly to the console

Summary:

When we get an error back from IRForTarget we directly print that error to the
debugger output stream instead of putting it in the result object. The result
object only gets a vague "The expression could not be prepared to run in the
target" error message that doesn't actually tell the user what went wrong.

This patch just puts the IRForTarget errors into the status object that is
returned to the caller instead of directly printing it to the debugger. Also
updates one test that now can actually check for the error message it is
supposed to check for (instead of the default error which is all we had before).

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

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

4 years ago[PowerPC] refactor convertToImmediateForm - NFC
Chen Zheng [Fri, 12 Jun 2020 06:58:34 +0000 (02:58 -0400)]
[PowerPC] refactor convertToImmediateForm - NFC

This is a NFC patch to make convertToImmediateForm a light wrapper
for converting xform and imm form instructions on PowerPC.

Reviewed By: Steven.zhang

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

4 years ago[cmake] Don't pass -z discard-unused to Illumos ld
Rainer Orth [Fri, 12 Jun 2020 07:56:42 +0000 (09:56 +0200)]
[cmake] Don't pass -z discard-unused to Illumos ld

I'm currently working to port `libc++` to Solaris.  There exists a slightly
bitrotten port already, which was done on Illumos, an OpenSolaris
derivative.  In order not to break that port with my work, I need to test
the result on both Solaris and Illumos.  While doing so, it turned out that
Illumos `ld` doesn't support the `-z discard-sections=unused` option
currently used on SunOS unconditionally.

While there exists a patch
<https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/developer/clang-90/patches/02-cmake_modules_AddLLVM.cmake.patch>
for LLVM 9.0 in the OpenIndiana repository, it apparently hasn't been
submitted upstream and is completely wrong: it replaces
`-z discard-sections=unused` with `-z ignore`.  In terms of the equivalent
`gld` options, this means replacing `--gc-sections` with `--as-needed`.

This patch instead tests if the linker actually supports the option before
using it.

Tested on `amd64-pc-solaris2.11` (all of Solaris 11.4, 11.3 and OpenIndiana
2020.04).

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

4 years ago[clang] Rename Decl::isHidden() to isUnconditionallyVisible().
Martin Boehme [Mon, 8 Jun 2020 13:37:44 +0000 (15:37 +0200)]
[clang] Rename Decl::isHidden() to isUnconditionallyVisible().

Also invert the sense of the return value.

As pointed out by the FIXME that this change resolves, isHidden() wasn't
a very accurate name for this function.

I haven't yet changed any of the strings that are output in
ASTDumper.cpp / JSONNodeDumper.cpp / TextNodeDumper.cpp in response to
whether isHidden() is set because

a) I'm not sure whether it's actually desired to change these strings
   (would appreciate feedback on this), and

b) In any case, I'd like to get this pure rename out of the way first,
   without any changes to tests. Changing the strings that are output in
   the various ...Dumper.cpp files will require changes to quite a few
   tests, and I'd like to make those in a separate change.

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

Reviewed By: rsmith

4 years ago[InstCombine] "X - (X / C) * C == 0" to "X & C-1 == 0"
EgorBo [Fri, 12 Jun 2020 07:08:17 +0000 (10:08 +0300)]
[InstCombine] "X - (X / C) * C == 0" to "X & C-1 == 0"

Summary:
"X % C == 0" is optimized to "X & C-1 == 0" (where C is a power-of-two)
However, "X % Y" can also be represented as "X - (X / Y) * Y" so if I rewrite the initial expression:
"X - (X / C) * C == 0" it's not currently optimized to "X & C-1 == 0", see godbolt: https://godbolt.org/z/KzuXUj

This is my first contribution to LLVM so I hope I didn't mess things up

Reviewers: lebedev.ri, spatel

Reviewed By: lebedev.ri

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[NFC][InstCombine] Tests for "X - (X / C) * C == 0" pattern
EgorBo [Fri, 12 Jun 2020 07:01:21 +0000 (10:01 +0300)]
[NFC][InstCombine] Tests for "X - (X / C) * C == 0" pattern

See https://reviews.llvm.org/D79369

4 years ago[llvm/Object] Reimplment basic_symbol_iterator in TapiFile
Jonas Devlieghere [Fri, 12 Jun 2020 07:01:54 +0000 (00:01 -0700)]
[llvm/Object] Reimplment basic_symbol_iterator in TapiFile

Use indices into the Symbols vector instead of casting the objects in
the vector and dereferencing std::vector::end().

This change is NFC modulo the Windows failure reported by
llvm-clang-x86_64-expensive-checks-win.

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

4 years ago[AArch64] Extend AArch64SLSHardeningPass to harden BLR instructions.
Kristof Beyls [Thu, 11 Jun 2020 08:23:15 +0000 (09:23 +0100)]
[AArch64] Extend AArch64SLSHardeningPass to harden BLR instructions.

To make sure that no barrier gets placed on the architectural execution
path, each
  BLR x<N>
instruction gets transformed to a
  BL __llvm_slsblr_thunk_x<N>
instruction, with __llvm_slsblr_thunk_x<N> a thunk that contains
__llvm_slsblr_thunk_x<N>:
  BR x<N>
  <speculation barrier>

Therefore, the BLR instruction gets split into 2; one BL and one BR.
This transformation results in not inserting a speculation barrier on
the architectural execution path.

The mitigation is off by default and can be enabled by the
harden-sls-blr subtarget feature.

As a linker is allowed to clobber X16 and X17 on function calls, the
above code transformation would not be correct in case a linker does so
when N=16 or N=17. Therefore, when the mitigation is enabled, generation
of BLR x16 or BLR x17 is avoided.

As BLRA* indirect calls are not produced by LLVM currently, this does
not aim to implement support for those.

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

4 years agoRevert "[mlir][spirv] Enhance structure type member decoration handling"
Mehdi Amini [Fri, 12 Jun 2020 05:00:47 +0000 (05:00 +0000)]
Revert "[mlir][spirv] Enhance structure type member decoration handling"

This reverts commit 5d74df5b03e46b7bd3700e3595c7008a6905b288.

This broke the MSVC build:  <bits/stdint-uintn.h> isn't available on Windows

4 years ago[JumpThreading] Handle zero !prof branch_weights
Yevgeny Rouban [Fri, 12 Jun 2020 04:55:15 +0000 (11:55 +0700)]
[JumpThreading] Handle zero !prof branch_weights

Avoid division by zero in updatePredecessorProfileMetadata().

Reviewers: yamauchi
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81499

4 years ago[X86] Add a helper lambda to getIntelProcessorTypeAndSubtype to select feature bits...
Craig Topper [Fri, 12 Jun 2020 04:14:45 +0000 (21:14 -0700)]
[X86] Add a helper lambda to getIntelProcessorTypeAndSubtype to select feature bits from the correct 32-bit feature variable.

We have three 32 bit variables containing feature bits. But our
enum is a flat 96 bit space. So we need to pick which of the
variables to use based on the bit value. We used to do this
manually by mentioning the correct variable and subtracting an
offset from the enum. But this is error prone.

4 years ago[StackSafety] Fix byval handling
Vitaly Buka [Fri, 12 Jun 2020 01:56:20 +0000 (18:56 -0700)]
[StackSafety] Fix byval handling

We don't need process paramenters which marked as
byval as we are not going to pass interested allocas
without copying.

If we pass value into byval argument, we just handle that
as Load of corresponding type and stop that branch of analysis.

4 years ago[llvm-objcopy][MachO] Fix cmdsize of LC_RPATH
Alexander Shaposhnikov [Fri, 12 Jun 2020 02:55:04 +0000 (19:55 -0700)]
[llvm-objcopy][MachO] Fix cmdsize of LC_RPATH

Fix the calculation of the field cmdsize (in the function buildRPathLoadCommand)
to account for the null byte terminator.

Patch by Sameer Arora!

Test plan: make check-all

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

4 years ago[lldb/Test] Fix ASan/TSan workaround for Xcode Python 3
Jonas Devlieghere [Fri, 12 Jun 2020 02:29:26 +0000 (19:29 -0700)]
[lldb/Test] Fix ASan/TSan workaround for Xcode Python 3

The Python 3 interpreter in Xcode has a relative RPATH and dyld fails to
load it when we copy it into the build directory.

This patch adds an additional check that the copied binary can be
executed. If it doesn't, we assume we're dealing with the Xcode python
interpreter and return the path to the real executable. That is
sufficient for the sanitizers because only system binaries need to be
copied to work around SIP.

This patch also moves all that logic out of LLDBTest and into the lit
configuration so that it's executed only once per test run, instead of
once for every test. Although I didn't benchmark the difference this
should result in a mild speedup.

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

4 years ago[BPF] fix incorrect type in BPFISelDAGToDAG readonly load optimization
Yonghong Song [Thu, 11 Jun 2020 02:13:37 +0000 (19:13 -0700)]
[BPF] fix incorrect type in BPFISelDAGToDAG readonly load optimization

In BPF Instruction Selection DAGToDAG transformation phase,
BPF backend had an optimization to turn load from readonly data
section to direct load of the values. This phase is implemented
before libbpf has readonly section support and before alu32
is supported.

This phase however may generate incorrect type when alu32 is
enabled. The following is an example,
  -bash-4.4$ cat ~/tmp2/t.c
  struct t {
    unsigned char a;
    unsigned char b;
    unsigned char c;
  };
  extern void foo(void *);
  int test() {
    struct t v = {
      .b = 2,
    };
    foo(&v);
    return 0;
  }

The compiler will turn local variable "v" into a readonly section.
During instruction selection phase, the compiler generates two
loads from readonly section, one 2 byte load or 1 byte load, e.g., for 2 loads,
  t8: i32,ch = load<(dereferenceable load 2 from `i8* getelementptr inbounds
       (%struct.t, %struct.t* @__const.test.v, i64 0, i32 0)`, align 1),
       anyext from i16> t3, GlobalAddress:i64<%struct.t* @__const.test.v> 0, undef:i64
  t9: ch = store<(store 2 into %ir.v1.sub1), trunc to i16> t3, t8,
    FrameIndex:i64<0>, undef:i64

BPF backend changed t8 to i64 = Constant<2> and eventually the generated machine IR:
  t10: i64 = MOV_ri TargetConstant:i64<2>
  t40: i32 = SLL_ri_32 t10, TargetConstant:i32<8>
  t41: i32 = OR_ri_32 t40, TargetConstant:i64<0>
  t9: ch = STH32<Mem:(store 2 into %ir.v1.sub1)> t41, TargetFrameIndex:i64<0>,
      TargetConstant:i64<0>, t3

Note that t10 in the above is not correct. The type should be i32 and instruction
should be MOV_ri_32. The reason for incorrect insn selection is BPF insn selection
generated an i64 constant instead of an i32 constant as specified in the original
load instruction. Such incorrect insn sequence eventually caused the following
fatal error when a COPY insn tries to copy a 64bit register to a 32bit subregister.
  Impossible reg-to-reg copy
  UNREACHABLE executed at ../lib/Target/BPF/BPFInstrInfo.cpp:42!

This patch fixed the issue by using the load result type instead of always i64
when doing readonly load optimization.

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

4 years agoRevert "[PowerPC][NFC] Testing ROTL of v1i128."
Esme-Yi [Fri, 12 Jun 2020 02:23:52 +0000 (02:23 +0000)]
Revert "[PowerPC][NFC] Testing ROTL of v1i128."

This reverts commit 174192af0106be9764aeda34988f27dc2c1bd4c4.

4 years ago[llvm][llvm-nm] add TextAPI/MachO support
Cyndy Ishida [Fri, 12 Jun 2020 01:32:45 +0000 (18:32 -0700)]
[llvm][llvm-nm] add TextAPI/MachO support

Summary:
This completes the needed glueing to support reading tbd files from nm.
This includes specifying which slice filtering with `--arch` and a new
option specifically for tbd files `--add-inlinedinfo` which will show
the reexported libraries that are appended in the tbd file.

Reviewers: ributzka, steven_wu, JDevlieghere, jhenderson

Reviewed By: JDevlieghere

Subscribers: hiraditya, MaskRay, dexonsmith, rupprecht, llvm-commits

Tags: #llvm

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

4 years agoVerify MemorySSA after all updates.
Alina Sbirlea [Fri, 12 Jun 2020 01:16:33 +0000 (18:16 -0700)]
Verify MemorySSA after all updates.

Verify after completing all updates.
Resolves PR46275.

4 years agoInstall the MLIRTableGen static library.
Stella Laurenzo [Thu, 11 Jun 2020 21:01:52 +0000 (14:01 -0700)]
Install the MLIRTableGen static library.

Summary: * This library is special because of its dependencies so seems to have been inadvertently left out of installs.

Reviewers: antiagainst

Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes

Tags: #mlir

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

4 years agoEnable FileCheck -enable-var-scope by default in MLIR test
Mehdi Amini [Fri, 12 Jun 2020 00:34:35 +0000 (00:34 +0000)]
Enable FileCheck -enable-var-scope by default in MLIR test

This option avoids to accidentally reuse variable across -LABEL match,
it can be explicitly opted-in by prefixing the variable name with $

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

4 years agoUse python3 in generate-test-checks.py.
Wen-Heng (Jack) Chung [Fri, 12 Jun 2020 00:15:16 +0000 (19:15 -0500)]
Use python3 in generate-test-checks.py.

Summary: Upgrade to python3 in generate-test-checks.py .

Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes

Tags: #mlir

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

4 years ago[mlir][spirv] Enhance structure type member decoration handling
HazemAbdelhafez [Wed, 10 Jun 2020 23:15:55 +0000 (19:15 -0400)]
[mlir][spirv] Enhance structure type member decoration handling

Modify structure type in SPIR-V dialect to support:
1) Multiple decorations per structure member
2) Key-value based decorations (e.g., MatrixStride)

This commit kept the Offset decoration separate from members'
decorations container for easier implementation and logical clarity.
As such, all references to Structure layoutinfo are now offsetinfo,
and any member layout defining decoration (e.g., RowMajor for Matrix)
will be add to the members' decorations container along with its
value if any.

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

4 years agoTidy up unsigned -> Register fixups.
Eric Christopher [Thu, 11 Jun 2020 23:42:23 +0000 (16:42 -0700)]
Tidy up unsigned -> Register fixups.

4 years ago[mlir] Add additional header
Jacques Pienaar [Thu, 11 Jun 2020 23:45:37 +0000 (16:45 -0700)]
[mlir] Add additional header

Fix gcc10 build and closes: https://bugs.llvm.org/show_bug.cgi?id=45680

4 years agoAdd a diagnostic string to an assert.
Eric Christopher [Thu, 11 Jun 2020 23:34:31 +0000 (16:34 -0700)]
Add a diagnostic string to an assert.

4 years agoAMDGPU/GlobalISel: Fix select of private <2 x s16> load
Matt Arsenault [Thu, 11 Jun 2020 23:19:13 +0000 (19:19 -0400)]
AMDGPU/GlobalISel: Fix select of private <2 x s16> load

4 years ago[VectorCombine] remove unused parameters; NFC
Sanjay Patel [Thu, 11 Jun 2020 20:50:03 +0000 (16:50 -0400)]
[VectorCombine] remove unused parameters; NFC

4 years ago[StackSafety,NFC] Fix use of CallBase API
Vitaly Buka [Thu, 11 Jun 2020 20:47:50 +0000 (13:47 -0700)]
[StackSafety,NFC] Fix use of CallBase API

Code does not need iterate arguments and can get ArgNo from
CallBase::getArgOperandNo.

4 years agoAMDGPU/GlobalISel: Fix select of <8 x s64> scalar load
Matt Arsenault [Thu, 11 Jun 2020 12:54:00 +0000 (08:54 -0400)]
AMDGPU/GlobalISel: Fix select of <8 x s64> scalar load

4 years ago[CodeGen] Simplify the way lifetime of block captures is extended
Akira Hatanaka [Wed, 3 Jun 2020 23:41:50 +0000 (16:41 -0700)]
[CodeGen] Simplify the way lifetime of block captures is extended

Rather than pushing inactive cleanups for the block captures at the
entry of a full expression and activating them during the creation of
the block literal, just call pushLifetimeExtendedDestroy to ensure the
cleanups are popped at the end of the scope enclosing the block
expression.

rdar://problem/63996471

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

4 years ago[lldb/Test] Unify DYLD_INSERT_LIBRARIES solution for ASan and TSan
Jonas Devlieghere [Thu, 11 Jun 2020 22:39:49 +0000 (15:39 -0700)]
[lldb/Test] Unify DYLD_INSERT_LIBRARIES solution for ASan and TSan

Add the same fix for loading the sanitizer runtime for TSan as we
currently have for ASan and unify the code with a helper function.

4 years agoAMDGPU/GlobalISel: Set insert point when emitting control flow pseudos
Matt Arsenault [Thu, 11 Jun 2020 22:28:31 +0000 (18:28 -0400)]
AMDGPU/GlobalISel: Set insert point when emitting control flow pseudos

This was implicitly assuming the branch instruction was the next after
the pseudo. It's possible for another non-terminator instruction to be
inserted between the intrinsic and the branch, so adjust the insertion
point. Fixes a non-terminator after terminator verifier error (which
without the verifier, manifested itself as an infinite loop in
analyzeBranch much later on).

4 years ago[MLIR][SPIRVToLLVM] Added conversion for SPIR-V comparison ops
George Mitenkov [Thu, 11 Jun 2020 22:46:09 +0000 (18:46 -0400)]
[MLIR][SPIRVToLLVM] Added conversion for SPIR-V comparison ops

Implemented `FComparePattern` and `IComparePattern` classes
that provide conversion of SPIR-V comparison ops (such as
`spv.FOrdGreaterThanEqual` and others) to LLVM dialect.
Also added tests in `comparison-ops-to-llvm.mlir`.

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

4 years ago[InlineCost] Preparational patch for creation of Printer pass.
Kirill Naumov [Thu, 11 Jun 2020 20:24:14 +0000 (20:24 +0000)]
[InlineCost] Preparational patch for creation of Printer pass.

- Renaming the printer class, flag
- Refactoring
- Changing some tests

This patch is a preparational stage for introducing a new printing pass and new
functionality to the existing Annotation Writer. I plan to extend
this functionality for this tool to be more useful when looking at the inline
process.

4 years ago[Support] Don't tie errs() to outs() by default
Fangrui Song [Thu, 11 Jun 2020 22:19:05 +0000 (15:19 -0700)]
[Support] Don't tie errs() to outs() by default

This reverts part of D81156.

Accessing errs() concurrently was safe before and racy after D81156.
(`errs() << 'a'` is always racy)

Accessing outs() and errs() concurrently was safe before and racy after D81156.

Don't tie errs() to outs() by default to fix the fallout.
llvm-dwarfdump is single-threaded and opting in the tie behavior is safe.

4 years agoSet the LLVM FP optimization flags conservatively.
John McCall [Thu, 11 Jun 2020 22:09:36 +0000 (18:09 -0400)]
Set the LLVM FP optimization flags conservatively.

Functions can have local pragmas that override the global settings.
We set the flags eagerly based on global settings, but if we emit
an expression under the influence of a pragma, we clear the
appropriate flags from the function.

In order to avoid doing a ton of redundant work whenever we emit
an FP expression, configure the IRBuilder to default to global
settings, and only reconfigure it when we see an FP expression
that's not using the global settings.

Patch by Michele Scandale!

https://reviews.llvm.org/D80462

4 years agoFixed assertion in SROA if block has ho successors
Stanislav Mekhanoshin [Thu, 11 Jun 2020 17:45:42 +0000 (10:45 -0700)]
Fixed assertion in SROA if block has ho successors

BasicBlock::isLegalToHoistInto() asserts if block does not
have successors. The case is degenarate but assertion still
needs to be avoided.

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

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

4 years ago[X86] Remove unnecessary #if around call to isCpuIdSupported in getHostCPUName.
Craig Topper [Thu, 11 Jun 2020 21:54:41 +0000 (14:54 -0700)]
[X86] Remove unnecessary #if around call to isCpuIdSupported in getHostCPUName.

The exact same #if is already inside isCpuIdSupported and causes
it to return true. The definition of isCpuIdSupported isn't
conditional so we should be able just rely on its body doing
the right thing.

4 years ago[WebAssembly] Make BR_TABLE non-duplicable
Thomas Lively [Thu, 11 Jun 2020 22:11:45 +0000 (15:11 -0700)]
[WebAssembly] Make BR_TABLE non-duplicable

Summary:
After their range checks were removed in 7f50c15be5c0, br_tables
started being duplicated into their predecessors by tail
folding. Unfortunately, when the br_tables were in loops this
transformation introduced bad irreducible control flow which was later
expanded into even more br_tables. This commit abuses the
`isNotDuplicable` property to prevent this irreducible control flow
from being introduced. This change saves a few dozen bytes of code
size and has a negligible affect on performance for most of the large
Emscripten benchmarks, but can improve performance significantly on
microbenchmarks of switches in loops.

Reviewers: aheejin, dschuff

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

Tags: #llvm

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

4 years ago[lldb] Check if thread was suspended during previous stop added.
Ilya Bukonkin [Thu, 11 Jun 2020 21:59:19 +0000 (14:59 -0700)]
[lldb] Check if thread was suspended during previous stop added.

Encountered the following situation: Let we started thread T1 and it hit
breakpoint on B1 location. We suspended T1 and continued the process.
Then we started thread T2 which hit for example the same location B1.
This time in a breakpoint callback we decided not to stop returning
false.

Expected result: process continues (as if T2 did not hit breakpoint) its
workflow with T1 still suspended. Actual result: process do stops (as if
T2 callback returned true).

Solution: We need invalidate StopInfo for threads that was previously
suspended just because something that is already inactive can not be the
reason of stop. Thread::GetPrivateStopInfo() may be appropriate place to
do it, because it gets called (through Thread::GetStopInfo()) every time
before process reports stop and user gets chance to change
m_resume_state again i.e if we see m_resume_state == eStateSuspended
it definitely means it was set during previous stop and it also means
this thread can not be stopped again (cos' it was frozen during
previous stop).

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

4 years ago[mlir][Affine] Revisit fusion candidates after successful fusion
Diego Caballero [Thu, 11 Jun 2020 21:39:44 +0000 (14:39 -0700)]
[mlir][Affine] Revisit fusion candidates after successful fusion

This patch changes the fusion algorithm so that after fusing two loop nests
we revisit previously visited nodes so that they are considered again for
fusion in the context of the new fused loop nest.

Reviewed By: bondhugula

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

4 years agoRe-land "Migrate the rest of COFFObjectFile to Error"
Reid Kleckner [Thu, 11 Jun 2020 20:00:54 +0000 (13:00 -0700)]
Re-land "Migrate the rest of COFFObjectFile to Error"

This reverts commit 101fbc01382edd89ea7b671104c68b30b2446cc0.

Remove leftover debugging attribute.

Update LLDB as well, which was missed before.

4 years ago[clangd] Set CWD in semaCodeComplete
Kadir Cetinkaya [Thu, 11 Jun 2020 20:49:52 +0000 (22:49 +0200)]
[clangd] Set CWD in semaCodeComplete

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

Tags: #clang

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

4 years agoFix incorrect call to ExprResult::get()
Alex Richardson [Thu, 11 Jun 2020 21:23:27 +0000 (22:23 +0100)]
Fix incorrect call to ExprResult::get()

Res is already a ExprResult, so if we call .get(), we will convert an
ExprError() result into an unset result. I discovered this in our downstream
CHERI target where this resulted in a crash due to a NULL-dereference.
It appears that this was introduced in SVN revision 201788 (8690a6860a45ba36e39b4ff0dbe434195e125d11)

Reviewed By: Anastasia
Differential Revision: https://reviews.llvm.org/D81608

4 years ago[GlobalISel][test] Add REQUIRES: asserts after D76934
Fangrui Song [Thu, 11 Jun 2020 20:50:56 +0000 (13:50 -0700)]
[GlobalISel][test] Add REQUIRES: asserts after D76934

4 years ago[mlir] Remove Broadcastable ODS trait
Jacques Pienaar [Thu, 11 Jun 2020 20:45:09 +0000 (13:45 -0700)]
[mlir] Remove Broadcastable ODS trait

Alias to ResultsBroadcastableShape ODS trait which matches C++ class.

4 years ago[libc++] Allow specifying arbitrary custom executors with the new format
Louis Dionne [Thu, 11 Jun 2020 19:41:38 +0000 (15:41 -0400)]
[libc++] Allow specifying arbitrary custom executors with the new format

The integration between CMake and executor selection in the new format
wasn't very flexible -- only the default executor and SSH executors were
supported.

This patch makes it possible to specify arbitrary executors with the new
format. With the new testing format, a custom executor is just a script
that gets called with a command-line to execute, and some arguments like
--env, --codesign_identity and --execdir. As such, the default executor
is just run.py.

Remote execution with the SSH executor can be achived by specifying
LIBCXX_EXECUTOR="<path-to-ssh.py> --host <host>". Similarly, arbitrary
scripts can be provided.

4 years ago[mlir] Fix some of the warnings in MLIR code.
Alexander Belyaev [Thu, 11 Jun 2020 17:22:48 +0000 (19:22 +0200)]
[mlir] Fix some of the warnings in MLIR code.

Summary:
* extra ';' in the following files:
    mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
    mlir/lib/Dialect/Shape/IR/Shape.cpp

* base class â€˜mlir::ConvertVectorToSCFBase<ConvertVectorToSCFPass>’
  should be explicitly initialized in the copy constructor [-Wextra] in
    mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp

* warning: â€˜bool Expression::operator==(const Expression&) const’
  defined but not used [-Wunused-function] in
    mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp

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

4 years ago[X86] Force VIA PadLock crypto instructions to emit a 0xF3 prefix when they encode...
Craig Topper [Thu, 11 Jun 2020 19:45:54 +0000 (12:45 -0700)]
[X86] Force VIA PadLock crypto instructions to emit a 0xF3 prefix when they encode to match what GNU as does.

The spec for these says they need 0xf3 but also mentions REP
before the mnemonic. But I don't think its fair to users to make
them write REP first. And gas doesn't make them. objdump seems to
disassemble with or without the prefix and just prints any 0xf3
as REP.

4 years ago[GISel][NFC]: Add unit test for clarifying CSE behavior
Aditya Nandakumar [Thu, 11 Jun 2020 19:29:12 +0000 (12:29 -0700)]
[GISel][NFC]: Add unit test for clarifying CSE behavior

Add a unit test that shows how CSE works if we install an observer
at the machine function level and not use the CSEMIRBuilder to build
instructions.

https://reviews.llvm.org/D81625

4 years agoAdd to the Coding Standard our that single-line bodies omit braces
Erich Keane [Mon, 1 Jun 2020 19:14:34 +0000 (12:14 -0700)]
Add to the Coding Standard our that single-line bodies omit braces

This is a rule that seems to have been enforced for the better part of
the decade, so we should document it for new contributors.

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

4 years ago[clang] TextNodeDumper: Dump the trait spelling of {Type,ArrayType,Expression}TraitExpr
Bruno Ricci [Thu, 11 Jun 2020 16:36:28 +0000 (17:36 +0100)]
[clang] TextNodeDumper: Dump the trait spelling of {Type,ArrayType,Expression}TraitExpr

nodes using the new helper functions introduced
in 78e636b3f2f0b0487130b31fade4f95ab179a18c.

4 years ago[clang][NFC] Assert that the enumerator value of {Type,ArrayType,UnaryExprOrType...
Bruno Ricci [Thu, 11 Jun 2020 16:29:15 +0000 (17:29 +0100)]
[clang][NFC] Assert that the enumerator value of {Type,ArrayType,UnaryExprOrType,Expression}Traits

is valid and does not overflow in the bit-field for its storage in more places.
This is a follow-up to 78e636b3f2f0b0487130b31fade4f95ab179a18c. NFC.

4 years ago[clang][NFC] Remove two hard-coded lists of ArrayTypeTrait and ExpressionTrait
Bruno Ricci [Thu, 11 Jun 2020 16:24:04 +0000 (17:24 +0100)]
[clang][NFC] Remove two hard-coded lists of ArrayTypeTrait and ExpressionTrait

These two were missed in 78e636b3f2f0b0487130b31fade4f95ab179a18c.

4 years ago[libc] Add implementation of few floating point manipulation functions.
Siva Chandra Reddy [Tue, 2 Jun 2020 21:04:57 +0000 (14:04 -0700)]
[libc] Add implementation of few floating point manipulation functions.

Implementations of copysign[f], frexp[f], logb[f], and modf[f] are added.

Reviewers: asteinhauser

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

4 years ago[X86] Replace TB with PS on instructions that are documented in the SDM with 'NP'
Craig Topper [Thu, 11 Jun 2020 19:18:52 +0000 (12:18 -0700)]
[X86] Replace TB with PS on instructions that are documented in the SDM with 'NP'

'NP' means that the instruction is not recognized with a 66, F2 or F3
prefix. It will either #UD or decode to a different instruction.

All of the cases are here should fall into the #UD variety since
we should be detecting the collision with other instructions when
we build the disassembler tables.

4 years ago[AArch64] Regenerate SVE test llvm-ir-to-intrinsic.ll.
Eli Friedman [Thu, 11 Jun 2020 19:13:18 +0000 (12:13 -0700)]
[AArch64] Regenerate SVE test llvm-ir-to-intrinsic.ll.

4 years ago[libc++abi] Simplify the logic for finding libc++ from libc++abi
Louis Dionne [Thu, 11 Jun 2020 17:50:40 +0000 (13:50 -0400)]
[libc++abi] Simplify the logic for finding libc++ from libc++abi

Since we have the monorepo, libc++abi's build requires a sibling checkout
of the libc++ sources. Hence, the logic for finding libc++ can be greatly
simplified.

4 years ago[OPENMP50]Codegen for scan directive in simd loops.
Alexey Bataev [Thu, 11 Jun 2020 15:28:59 +0000 (11:28 -0400)]
[OPENMP50]Codegen for scan directive in simd loops.

Added codegen for scan directives in simd loop. The codegen transforms
original code:
```
int x = 0;
 #pragma omp simd reduction(inscan, +: x)
for (..) {
  <first part>
  #pragma omp scan inclusive(x)
  <second part>
}
```
into
```
int x = 0;
for (..) {
  int x_priv = 0;
  <first part>
  x = x_priv + x;
  x_priv = x;
  <second part>
}
```
and
```
int x = 0;
 #pragma omp simd reduction(inscan, +: x)
for (..) {
  <first part>
  #pragma omp scan exclusive(x)
  <second part>
}
```
into
```
int x = 0;
for (..) {
  int x_priv = 0;
  <second part>
  int temp = x;
  x = x_priv + x;
  x_priv = temp;
  <first part>
}
```

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

4 years ago [flang] Semantics for SELECT TYPE
sameeran joshi [Sun, 19 Apr 2020 11:10:37 +0000 (16:40 +0530)]
[flang] Semantics for SELECT TYPE

    Summary:
    Added support for all semantic checks except C1157
    was previously implemented.

    Address review comments.

    Reviewers: PeteSteinfeld, tskeith, klausler, DavidTruby, kiranktp, anchu-rajendran, sscalpone

    Subscribers: kiranchandramohan, llvm-commits, flang-commits

    Tags: #llvm, #flang

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

4 years ago[clang] Frontend components for the relative vtables ABI (round 2)
Leonard Chan [Thu, 11 Jun 2020 18:17:08 +0000 (11:17 -0700)]
[clang] Frontend components for the relative vtables ABI (round 2)

This patch contains all of the clang changes from D72959.

- Generalize the relative vtables ABI such that it can be used by other targets.
- Add an enum VTableComponentLayout which controls whether components in the
  vtable should be pointers to other structs or relative offsets to those structs.
  Other ABIs can change this enum to restructure how components in the vtable
  are laid out/accessed.
- Add methods to ConstantInitBuilder for inserting relative offsets to a
  specified position in the aggregate being constructed.
- Fix failing tests under new PM and ASan and MSan issues.

See D72959 for background info.

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

4 years agoRegenerated SROA phi-gep.ll test. NFC.
Stanislav Mekhanoshin [Thu, 11 Jun 2020 17:50:12 +0000 (10:50 -0700)]
Regenerated SROA phi-gep.ll test. NFC.

4 years ago[PCH] Support writing BuiltinBitCastExprs to PCHs
hyd-dev [Thu, 11 Jun 2020 16:30:16 +0000 (12:30 -0400)]
[PCH] Support writing BuiltinBitCastExprs to PCHs

eee944e7f adds the new BuiltinBitCastExpr, but does not set the Code member of
ASTStmtWriter. This is not correct and causes an assertion failue in
ASTStmtWriter::emit() when building PCHs that contain __builtin_bit_cast.  This
commit adds serialization::EXPR_BUILTIN_BIT_CAST and handles
ASTStmtWriter::Code properly.

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

4 years ago[mlir][rocdl] Fixing breakage of dim operator from 904f91db
jerryyin [Thu, 11 Jun 2020 15:10:21 +0000 (15:10 +0000)]
[mlir][rocdl] Fixing breakage of dim operator from 904f91db

Summary:
* Update the unit test dimOp index to be an operand
* Refactored the constant naming

Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes

Tags: #mlir

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

4 years ago[NFC] clean up the AsmPrinter::emitLinkage for AIX part
diggerlin [Thu, 11 Jun 2020 17:33:51 +0000 (13:33 -0400)]
[NFC] clean up the AsmPrinter::emitLinkage for AIX part

SUMMARY:

Since we deal with aix emitLinkage in the PPCAIXAsmPrinter::emitLinkage() in the patch https://reviews.llvm.org/D75866. It do not go to AsmPrinter::emitLinkage() any more, we clean up some aix related code in the AsmPrinter::emitLinkage()

Reviewers:  Jason liu

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

4 years ago[lldb/Test] Ensure inline tests have a unique build directory
Jonas Devlieghere [Thu, 11 Jun 2020 16:35:19 +0000 (09:35 -0700)]
[lldb/Test] Ensure inline tests have a unique build directory

Inline tests have one method named 'test' which means that multiple
inline tests in the same file end up sharing the same build directory
per variant.

This patch overrides the getBuildDirBasename method for the InlineTest
class to include the test name.

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

4 years ago[mlir][shape] Add assemblyFormat for `shape.add`.
Alexander Belyaev [Thu, 11 Jun 2020 10:40:18 +0000 (12:40 +0200)]
[mlir][shape] Add assemblyFormat for `shape.add`.

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

4 years ago[VectorCombine] add tests for compare scalarization; NFC
Sanjay Patel [Wed, 10 Jun 2020 18:05:21 +0000 (14:05 -0400)]
[VectorCombine] add tests for compare scalarization; NFC

4 years agoAMDGPU/GlobalISel: Fix lower for f64->f16 G_FPTRUNC
Petar Avramovic [Thu, 11 Jun 2020 15:55:59 +0000 (17:55 +0200)]
AMDGPU/GlobalISel: Fix lower for f64->f16 G_FPTRUNC

Put AND before ADD in LegalizerHelper::lowerFPTRUNC_F64_TO_F16
in order to match algorithm from AMDGPUTargetLowering::LowerFP_TO_FP16.

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

4 years ago[llvm-objdump] Decrease instruction indentation for non-x86
Fangrui Song [Thu, 11 Jun 2020 16:05:59 +0000 (09:05 -0700)]
[llvm-objdump] Decrease instruction indentation for non-x86

Place the instruction at the 24th column (0-based indexing), matching
GNU objdump ARM/AArch64/powerpc/etc when the address is low.

This is beneficial for non-x86 targets which have short instruction
lengths.

```
// GNU objdump AArch64
   0:   91001062        add     x2, x3, #0x4
  400078:       91001062        add     x2, x3, #0x4
// llvm-objdump, with this patch
       0: 62 10 00 91   add     x2, x3, #4
  400078: 62 10 00 91   add     x2, x3, #4
// llvm-objdump, if we change to print a word instead of bytes in the future
       0: 91001062      add     x2, x3, #4
  400078: 91001062      add     x2, x3, #4

// GNU objdump Thumb
   0:   bf00            nop

// GNU objdump Power ISA 3.1 64-bit instruction
// 0:   00 00 10 04     plwa    r3,0
// 4:   00 00 60 a4
```

Reviewed By: jhenderson

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

4 years agoRevert "[OPENMP50]Codegen for scan directive in simd loops."
Alexey Bataev [Thu, 11 Jun 2020 15:22:14 +0000 (11:22 -0400)]
Revert "[OPENMP50]Codegen for scan directive in simd loops."

This reverts commit fb80e67f10eea7177b0ff9c618c8231363b6f2fc to resolve
the issue with asan buildbots.

4 years ago[llvm][NFC] Factor some common data in InlineAdvice
Mircea Trofin [Tue, 9 Jun 2020 21:33:46 +0000 (14:33 -0700)]
[llvm][NFC] Factor some common data in InlineAdvice

Summary:
Other derivations will all want to emit optimization remarks and, as
part of that, use debug info.

Additionally, drive-by const-ing.

Reviewers: davidxl, dblaikie

Subscribers: aprantl, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[X86] Fold vXi1 OR(KSHIFTL(X,NumElts/2),Y) -> KUNPCK
Simon Pilgrim [Thu, 11 Jun 2020 14:38:39 +0000 (15:38 +0100)]
[X86] Fold vXi1 OR(KSHIFTL(X,NumElts/2),Y) -> KUNPCK

Convert shift+or bool vector patterns into CONCAT_VECTORS if we know this will be lowered to KUNPCK (which requires 16+ vector elements).

Fixes PR32547

4 years ago[mlir][rocdl] Adding vector to ROCDL dialect lowering
jerryyin [Fri, 5 Jun 2020 16:53:41 +0000 (16:53 +0000)]
[mlir][rocdl] Adding vector to ROCDL dialect lowering

* Created the vector to ROCDL lowering pass
  * The lowering pass lowers vector transferOps to rocdl mubufOps
* Added unit test and functional test

4 years agoFix return status of DataFlowSanitizer pass
serge-sans-paille [Thu, 4 Jun 2020 07:13:39 +0000 (09:13 +0200)]
Fix return status of DataFlowSanitizer pass

Take into account added functions, global values and attribute change.

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

4 years ago[OPENMP50]Codegen for use_device_addr clauses.
Alexey Bataev [Mon, 25 May 2020 20:06:31 +0000 (16:06 -0400)]
[OPENMP50]Codegen for use_device_addr clauses.

Summary:
Added codegen for use_device_addr clause. The components of the list
items are mapped as a kind of RETURN components and then the returned
base address is used instead of the real address of the base declaration
used in the use_device_addr expressions.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits, caomhin

Tags: #clang

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

4 years ago[IR] Clean up dead instructions after simplifying a conditional branch
Jay Foad [Mon, 18 May 2020 18:12:29 +0000 (19:12 +0100)]
[IR] Clean up dead instructions after simplifying a conditional branch

Change BasicBlock::removePredecessor to optionally return a vector of
instructions which might be dead. Use this in ConstantFoldTerminator to
delete them if they are dead.

Reapply with a bug fix: don't drop the "!KeepOneInputPHIs" argument when
removePredecessor calls PHINode::removeIncomingValue.

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

4 years ago[IR] Remove assert from ShuffleVectorInst
Sam Parker [Thu, 11 Jun 2020 13:52:17 +0000 (14:52 +0100)]
[IR] Remove assert from ShuffleVectorInst

Which triggers on valid, but not useful, IR such as a undef mask.

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

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

4 years ago[gn build] Port 78e636b3f2f
LLVM GN Syncbot [Thu, 11 Jun 2020 13:36:59 +0000 (13:36 +0000)]
[gn build] Port 78e636b3f2f

4 years ago[clang][NFC] Generate the {Type,ArrayType,UnaryExprOrType,Expression}Traits...
Bruno Ricci [Thu, 11 Jun 2020 13:08:27 +0000 (14:08 +0100)]
[clang][NFC] Generate the {Type,ArrayType,UnaryExprOrType,Expression}Traits...

...enumerations from TokenKinds.def and use the new macros from TokenKinds.def
to remove the hard-coded lists of traits.

All the information needed to generate these enumerations is already present
in TokenKinds.def. The motivation here is to be able to dump the trait spelling
without hard-coding the list in yet another place.

Note that this change the order of the enumerators in the enumerations (except
that in the TypeTrait enumeration all unary type traits are before all binary
type traits, and all binary type traits are before all n-ary type traits).

Apart from the aforementioned ordering which is relied upon, after this patch
no code in clang or in the various clang tools depend on the specific ordering
of the enumerators.

No functional changes intended.

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

Reviewed By: aaron.ballman

4 years agoRevert "[IR] Clean up dead instructions after simplifying a conditional branch"
Jay Foad [Thu, 11 Jun 2020 13:22:16 +0000 (14:22 +0100)]
Revert "[IR] Clean up dead instructions after simplifying a conditional branch"

This reverts commit 4494e45316a0bfaabb6bb1450fb0f49a0e6832af.

It caused problems for sanitizer buildbots.

4 years agoAdd AST_SIGNATURE record to unhashed control block of PCM files
Daniel Grumberg [Wed, 13 May 2020 16:07:47 +0000 (17:07 +0100)]
Add AST_SIGNATURE record to unhashed control block of PCM files

Summary:
This record is constructed by hashing the bytes of the AST block in a similiar
fashion to the SIGNATURE record. This new signature only means anything if the
AST block is fully relocatable, i.e. it does not embed absolute offsets within
the PCM file. This change ensure this does not happen by replacing these offsets
with offsets relative to the nearest relevant subblock of the AST block.

Reviewers: Bigcheese, dexonsmith

Subscribers: dexonsmith, cfe-commits

Tags: #clang

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

4 years ago[OPENMP50]Codegen for scan directive in simd loops.
Alexey Bataev [Fri, 5 Jun 2020 19:17:14 +0000 (15:17 -0400)]
[OPENMP50]Codegen for scan directive in simd loops.

Added codegen for scandirectives in simd loop. The codegen transforms
original code:

```
int x = 0;
 #pragma omp simd reduction(inscan, +: x)
for (..) {
  <first part>
  #pragma omp scan inclusive(x)
  <second part>
}
```
into
```
int x = 0;
for (..) {
  int x_priv = 0;
  <first part>
  x = x_priv + x;
  x_priv = x;
  <second part>
}
```
and
```
int x = 0;
 #pragma omp simd reduction(inscan, +: x)
for (..) {
  <first part>
  #pragma omp scan exclusive(x)
  <second part>
}
```
into
```
int x = 0;
for (..) {
  int x_priv = 0;
  <second part>
  int temp = x;
  x = x_priv + x;
  x_priv = temp;
  <first part>
}
```

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

4 years agoAdd missing lambda capture from rGf529c0a8a149.
Simon Pilgrim [Thu, 11 Jun 2020 12:57:39 +0000 (13:57 +0100)]
Add missing lambda capture from rGf529c0a8a149.

4 years agoFix unused variable warning. NFCI.
Simon Pilgrim [Thu, 11 Jun 2020 12:48:42 +0000 (13:48 +0100)]
Fix unused variable warning. NFCI.

We're only using the D2 iteration value inside the assert (the only component of the loop) - move the entire loop inside the assert by using llvm::all_of.

4 years ago[X86][AVX512] Add second test case for PR32547
Simon Pilgrim [Thu, 11 Jun 2020 12:32:48 +0000 (13:32 +0100)]
[X86][AVX512] Add second test case for PR32547

Demonstrate missing support for OR(X,KSHIFTL(Y,8)) -> KUNPCKBW as well as the existing OR(KSHIFTL(X,8),Y) -> KUNPCKBW test.

4 years ago[clang][NFC] Fix a Wdocumentation warning in Basic/TargetInfo.h
Bruno Ricci [Thu, 11 Jun 2020 12:29:44 +0000 (13:29 +0100)]
[clang][NFC] Fix a Wdocumentation warning in Basic/TargetInfo.h

4 years ago[IR] Clean up dead instructions after simplifying a conditional branch
Jay Foad [Mon, 18 May 2020 18:12:29 +0000 (19:12 +0100)]
[IR] Clean up dead instructions after simplifying a conditional branch

Change BasicBlock::removePredecessor to optionally return a vector of
instructions which might be dead. Use this in ConstantFoldTerminator to
delete them if they are dead.

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

4 years ago[clang] Convert a default argument expression to the parameter type...
Bruno Ricci [Thu, 11 Jun 2020 12:13:05 +0000 (13:13 +0100)]
[clang] Convert a default argument expression to the parameter type...

...before checking that the default argument is valid with
CheckDefaultArgumentVisitor.

Currently the restrictions on a default argument are checked with the visitor
CheckDefaultArgumentVisitor in ActOnParamDefaultArgument before
performing the conversion to the parameter type in SetParamDefaultArgument.

This was fine before the previous patch but now some valid code post-CWG 2346
is rejected:

void test() {
  const int i2 = 0;
  extern void h2a(int x = i2);     // FIXME: ok, not odr-use
  extern void h2b(int x = i2 + 0); // ok, not odr-use
}

This is because the reference to i2 in h2a has not been marked yet with
NOUR_Constant. i2 is marked NOUR_Constant when the conversion to the parameter
type is done, which is done just after.

The solution is to do the conversion to the parameter type before checking
the restrictions on default arguments with CheckDefaultArgumentVisitor.
This has the side-benefit of improving some diagnostics.

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

Reviewed By: rsmith

4 years ago[lldb] Remove Scalar operator= overloads
Pavel Labath [Wed, 10 Jun 2020 13:26:50 +0000 (15:26 +0200)]
[lldb] Remove Scalar operator= overloads

The are not needed as Scalar is implicitly constructible from all of
these types (so the compiler will use a combination of a constructor +
move assignment instead), and they make it very easy for implementations
of assignment and construction operations to diverge.

4 years ago[MemCpyOptimizer] Simplify API of processStore and processMem* functions
Jay Foad [Wed, 10 Jun 2020 08:18:56 +0000 (09:18 +0100)]
[MemCpyOptimizer] Simplify API of processStore and processMem* functions

Previously these functions either returned a "changed" flag or a "repeat
instruction" flag, and could also modify an iterator to control which
instruction would be processed next.

Simplify this by always returning a "changed" flag, and handling all of
the "repeat instruction" functionality by modifying the iterator.

No functional change intended except in this case:
// If the source and destination of the memcpy are the same, then zap it.
... where the previous code failed to process the instruction after the
zapped memcpy.

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

4 years ago[clang] CWG 2082 and 2346: loosen the restrictions on parameters and local variables...
Bruno Ricci [Thu, 11 Jun 2020 11:41:08 +0000 (12:41 +0100)]
[clang] CWG 2082 and 2346: loosen the restrictions on parameters and local variables in default arguments.

This patch implements the resolution of CWG 2082 and CWG 2346.

The resolution of CWG 2082 changed [dcl.fct.default]p7 and p9 to allow
a parameter or local variable to appear in a default argument if not
in a potentially-evaluated expression.

The resolution of CWG 2346 changed [dcl.fct.default]p7 to allow a local
variable to appear in a default argument if not odr-used.

An issue remains after this patch
(see the FIXME in test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp).
This is addressed by the next patch.

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

Reviewed By: rsmith, erichkeane

4 years ago[clang][NFC] Various NFCs in CheckDefaultArgumentVisitor
Bruno Ricci [Thu, 11 Jun 2020 10:53:47 +0000 (11:53 +0100)]
[clang][NFC] Various NFCs in CheckDefaultArgumentVisitor

Before the next patches do the following NFCs:
  - Make it a const visitor; CheckDefaultArgumentVisitor should
    really not modify the visited nodes.

  - clang-format

  - Take a reference to Sema instead of a pointer and pass it
    as the first argument to the constructor. This is for
    consistency with the other similar visitors.

  - Use range for loops when appropriate as per the style guide.

  - Use `const auto *" when appropriate as per the style guide.

4 years ago[llvm/DWARFDebugLine] Remove spurious full stop from warning messages
Pavel Labath [Thu, 11 Jun 2020 11:13:31 +0000 (13:13 +0200)]
[llvm/DWARFDebugLine] Remove spurious full stop from warning messages

Other warnings messages don't have a trailing full stop.

4 years ago[mlir][linalg] Fix the type (indicies->indices).
Alexander Belyaev [Thu, 11 Jun 2020 11:08:24 +0000 (13:08 +0200)]
[mlir][linalg] Fix the type (indicies->indices).

4 years ago[llvm/DWARFDebugLine] Fix a typo in one warning message
Pavel Labath [Thu, 11 Jun 2020 11:04:26 +0000 (13:04 +0200)]
[llvm/DWARFDebugLine] Fix a typo in one warning message

4 years ago[mlir] Add new builders to linalg.reshape.
Alexander Belyaev [Thu, 11 Jun 2020 09:49:30 +0000 (11:49 +0200)]
[mlir] Add new builders to linalg.reshape.

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

4 years ago[DebugInfo] Refactor SalvageDebugInfo and SalvageDebugInfoForDbgValues
Chris Jackson [Thu, 11 Jun 2020 09:28:39 +0000 (10:28 +0100)]
[DebugInfo] Refactor SalvageDebugInfo and SalvageDebugInfoForDbgValues

- Simplify the salvaging interface and the algorithm in InstCombine

Reviewers: vsk, aprantl, Orlando, jmorse, TWeaver

Reviewed by: Orlando

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

4 years ago[yaml2obj] - Allocate the file space for SHT_NOBITS sections in some cases.
Georgii Rymar [Wed, 10 Jun 2020 12:28:57 +0000 (15:28 +0300)]
[yaml2obj] - Allocate the file space for SHT_NOBITS sections in some cases.

This teaches yaml2obj to allocate file space for a no-bits section
when there is a non-nobits section in the same segment that follows it.

It was discussed in D78005 thread and matches GNU linkers and LLD behavior.

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