2 years ago[libc++][Apple] Use CLOCK_MONOTONIC_RAW instead of CLOCK_UPTIME_RAW for steady_clock
Louis Dionne [Mon, 10 Feb 2020 17:30:43 +0000 (18:30 +0100)]
[libc++][Apple] Use CLOCK_MONOTONIC_RAW instead of CLOCK_UPTIME_RAW for steady_clock

In D27429, we switched the Apple implementation of steady_clock::now()
from clock_gettime(CLOCK_MONOTONIC) to clock_gettime(CLOCK_UPTIME_RAW).
The purpose was to get nanosecond precision, and also to improve the
performance of the implementation.

However, it appears that CLOCK_UPTIME_RAW does not satisfy the requirements
of the Standard, since it is not strictly speaking monotonic. Indeed, the
clock does not increment while the system is asleep, which had been
mentioned in D27429 but somehow not addressed.

This patch switches to CLOCK_MONOTONIC_RAW, which is monotonic, increased
during sleep, and also has nanosecond precision.


Reviewers: bruno, howard.hinnant, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits, mclow.lists, EricWF

Tags: #libc

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

2 years ago[AArch64][SVE] Add addsub carry long instrinsics
Danilo Carvalho Grael [Wed, 12 Feb 2020 15:36:15 +0000 (10:36 -0500)]
[AArch64][SVE] Add addsub carry long instrinsics

Add intrinsics for the following instructions:
- adclb, adclt, sbclb, sbclt

Reviewers: kmclaughlin, c-rhodes, sdesmalen, efriedma, rengolin

Reviewed By: kmclaughlin

Subscribers: tschuett, kristof.beyls, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm

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

2 years agoRevert "Revert "Change clang option -ffp-model=precise to select ffp-contract=on""
Melanie Blower [Tue, 11 Feb 2020 22:40:23 +0000 (14:40 -0800)]
Revert "Revert "Change clang option -ffp-model=precise to select ffp-contract=on""

This reverts commit 99c5bcbce89f07e68ccd89891a0300346705d013.
Change clang option -ffp-model=precise to select ffp-contract=on
Including some small touch-ups to the original commit

Reviewers: rjmccall, Andy Kaylor

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

2 years ago[PowerPC] Add options for PPC to enable/disable using non-volatile CR
Victor Huang [Wed, 12 Feb 2020 15:22:36 +0000 (09:22 -0600)]
[PowerPC] Add options for PPC to enable/disable using non-volatile CR

An option is added for PowerPC to disable use of non-volatile CR
register fields and avoid CR spilling in the prologue.

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

2 years ago[libc++] span: Guard against overflow in span::subspan
Louis Dionne [Wed, 12 Feb 2020 15:20:09 +0000 (16:20 +0100)]
[libc++] span: Guard against overflow in span::subspan

The calculation _Offset + _Count <= size() may overflow, so use
_Count <= size() - _Offset instead. Note that this is safe due to
the previous constraint that _Offset <= size().

Patch by Michael Schellenberger Costa.

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

2 years ago[PowerPC] Add support for intrinsic llvm.ppc.eieio
Anil Mahmud [Mon, 3 Feb 2020 18:34:44 +0000 (12:34 -0600)]
[PowerPC] Add support for intrinsic llvm.ppc.eieio

Add support for the intrinsic llvm.ppc.eieio to emit the instruction eieio.

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

2 years ago[PowerPC] Add support for intrinsics llvm.ppc.dcbfl and llvm.ppc.dcbflp
Anil Mahmud [Mon, 3 Feb 2020 17:03:54 +0000 (11:03 -0600)]
[PowerPC] Add support for intrinsics llvm.ppc.dcbfl and llvm.ppc.dcbflp

Added support for the intrinsic llvm.ppc.dcbfl and llvm.ppc.dcbflp.
These will be used for emitting cache control instructions dcbfl and dcbflp
which are actually mnemonics for using dcbf instruction with different
immediate arguments.

dcbfl ra, rb -> dcbf ra, rb, 1
dcbflp, ra, rb -> dcbf ra, rb, 3

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

2 years agoAMDGPU/GlobalISel: Split 96-bit load/store select tests out
Matt Arsenault [Wed, 12 Feb 2020 14:56:36 +0000 (09:56 -0500)]
AMDGPU/GlobalISel: Split 96-bit load/store select tests out

These are only legal on CI+. The test would fail in a debug build, but
not a release due to the partial selection since the pre-selection
legality assert only happens in a debug build.

2 years ago[MC][AVR] Fix AVR test following 740bc366
James Henderson [Wed, 12 Feb 2020 14:56:09 +0000 (14:56 +0000)]
[MC][AVR] Fix AVR test following 740bc366

2 years ago[DebugInfo] Add checks for v2 directory and file name table terminators
James Henderson [Wed, 12 Feb 2020 14:37:10 +0000 (14:37 +0000)]
[DebugInfo] Add checks for v2 directory and file name table terminators

The DWARFv2-4 specification for the line table header states that the
include directories and file name tables both end with a single null
byte. Prior to this change, the parser did not detect if this byte was
missing, because it also stopped reading the tables once it reached the
prologue end, as claimed by the header_length field. This change adds a
check that the terminator has been seen at the end of each table.

Reviewed by: dblaikie, MaskRay

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

2 years ago[DebugInfo] Add check for zero debug line opcode_base
James Henderson [Tue, 11 Feb 2020 12:17:33 +0000 (12:17 +0000)]
[DebugInfo] Add check for zero debug line opcode_base

The number of standard opcodes is defined to be opcode_base - 1, so a
value of 0 for the opcode_base caused a crash as an attempt was made to
reserve many entries in a vector. This change fixes the crash, by
issuing a warning and skipping reading of standard opcode lengths in the
event of an opcode_base of 0.

Reviewed by: dblaikie

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

2 years ago[DebugInfo] Print version in error message in decimal
James Henderson [Tue, 11 Feb 2020 14:11:01 +0000 (14:11 +0000)]
[DebugInfo] Print version in error message in decimal

Also remove some test duplication and add a test case that shows the
maximum version is rejected (this also shows that the value in the error
message is actually in decimal, and not just missing an 0x prefix).

Reviewed by: dblaikie

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

2 years agoRe-reapply: Recover debug intrinsics when killing duplicated/empty blocks
stozer [Wed, 12 Feb 2020 13:41:18 +0000 (13:41 +0000)]
Re-reapply: Recover debug intrinsics when killing duplicated/empty blocks

This reverts commit 636c93ed11a5f98b5c3ff88241460d61cb7785bb.

The original patch caused build failures on TSan buildbots. Commit 6ded69f294a9
fixes this issue by reducing the rate at which empty debug intrinsics
propagate, reducing the memory footprint and preventing a fatal spike.

2 years agoAMDGPU/GlobalISel: Widen non-power-of-2 load results
Matt Arsenault [Tue, 21 Jan 2020 18:23:45 +0000 (13:23 -0500)]
AMDGPU/GlobalISel: Widen non-power-of-2 load results

Load extra bits if suitably aligned. This allows using widened
3-vector loads on SI, and fixes legalization for <9 x s32> (which LSV
apparently forms frequently on lowered kernel argument lists).

Fix incorrectly treating these as legal on SI. This should emit a
64-bit store and a 32-bit store.

I think all of the load and store rules are just about complete, but
due for a rewrite.

2 years ago[Concepts] Add missing TPA commit to requires expression parsing
Saar Raz [Wed, 12 Feb 2020 14:23:55 +0000 (16:23 +0200)]
[Concepts] Add missing TPA commit to requires expression parsing

If an error had occurred when annotating a scope spec during the tentative parse
for a type-requirement, we would not revert nor commit the tentative parse, triggerring
an assertion failure.

Commit the TPA in this case and then do error recovery.

2 years agoRecommit "[DSE] Add first version of MemorySSA-backed DSE (Bottom up walk)."
Florian Hahn [Tue, 11 Feb 2020 18:27:41 +0000 (18:27 +0000)]
Recommit "[DSE] Add first version of MemorySSA-backed DSE (Bottom up walk)."

This includes a fix for the santizier failures.

This reverts the revert commit

2 years ago[mlir] Linalg fusion: ignore indexed_generic producers
Alex Zinenko [Wed, 12 Feb 2020 14:08:38 +0000 (15:08 +0100)]
[mlir] Linalg fusion: ignore indexed_generic producers

They are currently not supported and we should not attempt fusing them.

2 years ago[mlir] StdToLLVM: Add error when the sourceMemRef of a subview is not a llvm type.
Pierre Oechsel [Wed, 12 Feb 2020 09:26:01 +0000 (10:26 +0100)]
[mlir] StdToLLVM: Add error when the sourceMemRef of a subview is not a llvm type.

A memref_cast casting to a memref with a non identity map can't be
lowered to llvm. Take the following case:


func @invalid_memref_cast(%arg0: memref<?x?xf64>) {
  %c1 = constant 1 : index
  %c0 = constant 0 : index
  %5 = memref_cast %arg0 : memref<?x?xf64> to memref<?x?xf64, #map1>
  %25 = std.subview %5[%c0, %c0][%c1, %c1][] : memref<?x?xf64, #map1> to memref<?x?xf64, #map1>

When lowering the subview mlir was assuming `%5` to have an llvm type
(which is not the case as mlir failed to lower the memref_cast).

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

2 years agoFix unused function warning (PR44808)
Hans Wennborg [Wed, 12 Feb 2020 14:12:31 +0000 (15:12 +0100)]
Fix unused function warning (PR44808)

2 years ago[MLIR][CUDA] Fix build file for mlir-cuda-runner
Stephan Herhut [Wed, 12 Feb 2020 13:35:32 +0000 (14:35 +0100)]
[MLIR][CUDA] Fix build file for mlir-cuda-runner

This was broken recently when moving from dialect registration via
static initializers to explicit intialization.

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

2 years ago[Concepts] Do not check constraints if not all template arguments have been deduced
Saar Raz [Wed, 12 Feb 2020 13:58:51 +0000 (15:58 +0200)]
[Concepts] Do not check constraints if not all template arguments have been deduced

We previously checked the constraints of instantiated function templates even in cases where
PartialOverloading was true and not all template arguments have been deduced, which caused crashes
in clangd (bug 44714).

We now check if all arguments have been deduced before checking constraints in partial overloading

2 years ago[AggressiveInstCombine] Add test with baseline CHECKs for aggressive inst combine...
Ayman Musa [Wed, 12 Feb 2020 13:00:25 +0000 (15:00 +0200)]
[AggressiveInstCombine] Add test with baseline CHECKs for aggressive inst combine for ICmp instruction.

2 years ago[libcxx] Don't assume cwd name in std::filesystem tests
Sergej Jaskiewicz [Wed, 12 Feb 2020 13:07:30 +0000 (16:07 +0300)]
[libcxx] Don't assume cwd name in std::filesystem tests

In `std::filesystem::proximate` tests we assume that the current working directory's name
is `fs.op.proximate`. This is fine when we're running the tests locally.

However, if we're running those tests on a remote machine via SSH, the directory layout may be
different. For example, currently we copy each test executable individually into
a temporary directory on the target board using SCP, so the assumption about the working directory name
doesn't necessarily hold.

This patch is the only thing that is necessary for all libc++ tests to pass when run remotely.

Reviewers: ldionne, EricWF, mclow.lists

Reviewed By: ldionne, EricWF

Subscribers: christof, dexonsmith, libcxx-commits

Tags: #libc

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

2 years agoRevert "[AggressiveInstCombine] Add support for ICmp instr that feeds a select intsr...
Ayman Musa [Wed, 12 Feb 2020 13:04:49 +0000 (15:04 +0200)]
Revert "[AggressiveInstCombine] Add support for ICmp instr that feeds a select intsr's condition operand."

This reverts commit cf155150f992270c88e586ffc61973d2552b72e8.

2 years ago[AggressiveInstCombine] Add support for ICmp instr that feeds a select intsr's condit...
Ayman Musa [Wed, 12 Feb 2020 12:33:31 +0000 (14:33 +0200)]
[AggressiveInstCombine] Add support for ICmp instr that feeds a select intsr's condition operand.

2 years ago[mlir][spirv] Introduce spv.func
Lei Zhang [Fri, 7 Feb 2020 16:30:19 +0000 (11:30 -0500)]
[mlir][spirv] Introduce spv.func

Thus far we have been using builtin func op to model SPIR-V functions.
It was because builtin func op used to have special treatment in
various parts of the core codebase (e.g., pass pipelines, etc.) and
it's easy to bootstrap the development of the SPIR-V dialect. But
nowadays with general op concepts and region support we don't have
such limitations and it's time to tighten the SPIR-V dialect for

This commits introduces a spv.func op to properly model SPIR-V
functions. Compared to builtin func op, it can provide the following

* We can control the full op so we can integrate SPIR-V information
  bits (e.g., function control) in a more integrated way and define
  our own assembly form and enforcing better verification.
* We can have a better dialect and library boundary. At the current
  moment only functions are modelled with an external op. With this
  change, all ops modelling SPIR-V concpets will be spv.* ops and
  registered to the SPIR-V dialect.
* We don't need to special-case func op anymore when creating
  ConversionTarget declaring SPIR-V dialect as legal. This is quite
  important given we'll see more and more conversions in the future.

In the process, bumps a few FuncOp methods to the FunctionLike trait.

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

2 years agoReapply "[DebugInfo] Prevent explosion of debug intrinsics during jump threading"
stozer [Wed, 12 Feb 2020 11:48:20 +0000 (11:48 +0000)]
Reapply "[DebugInfo] Prevent explosion of debug intrinsics during jump threading"

This reverts commit 6ded69f294a9a62a68b0a07aa987c8165a4b31e7.

2 years agoFix MLIR build when the NVPTX target isn't configured
Mehdi Amini [Wed, 12 Feb 2020 10:06:50 +0000 (10:06 +0000)]
Fix MLIR build when the NVPTX target isn't configured

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

2 years ago[unittests] Fix TargetLibraryInfoTest.ValidProto
Ehud Katz [Wed, 12 Feb 2020 12:13:14 +0000 (14:13 +0200)]
[unittests] Fix TargetLibraryInfoTest.ValidProto

2 years ago[AggressiveInstCombine] Add support for select instruction.
Ayman Musa [Tue, 28 Jan 2020 13:17:15 +0000 (15:17 +0200)]
[AggressiveInstCombine] Add support for select instruction.

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

2 years ago[TargetLowering] Add NegatibleCost enum for isNegatibleForFree return codes
Simon Pilgrim [Wed, 12 Feb 2020 11:42:25 +0000 (11:42 +0000)]
[TargetLowering] Add NegatibleCost enum for isNegatibleForFree return codes

The isNegatibleForFree/getNegatedExpression methods currently rely on a raw char value to indicate whether a negation is beneficial or not.

This patch replaces the char return value with an NegatibleCost enum to more clearly demonstrate what is implied.

It also renames isNegatibleForFree to getNegatibleCost to more accurately reflect whats going on.

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

2 years ago[analyzer]StreamChecker refactoring (NFC).
Balázs Kéri [Wed, 12 Feb 2020 10:26:38 +0000 (11:26 +0100)]
[analyzer]StreamChecker refactoring (NFC).

Reviewers: Szelethus

Reviewed By: Szelethus

Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, donat.nagy, Charusso, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

2 years ago[lldb/DWARF] Use DWARFDebugInfoEntry * in ElaboratingDIEIterator
Pavel Labath [Wed, 12 Feb 2020 11:47:43 +0000 (12:47 +0100)]
[lldb/DWARF] Use DWARFDebugInfoEntry * in ElaboratingDIEIterator

This is simpler, faster, and sufficient to uniquely idenify a DIE.

2 years agoRevert "[DebugInfo] Prevent explosion of debug intrinsics during jump threading"
stozer [Wed, 12 Feb 2020 11:47:01 +0000 (11:47 +0000)]
Revert "[DebugInfo] Prevent explosion of debug intrinsics during jump threading"

This reverts commit fe6f6cd6b8e647c5b4ac82f4fcd56c057c2ef8ce.

Found test failure on several buildbots.

2 years ago[NFC][AggressiveInstCombine] Remove redundant std::max.
Ayman Musa [Wed, 12 Feb 2020 11:40:40 +0000 (13:40 +0200)]
[NFC][AggressiveInstCombine] Remove redundant std::max.

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

2 years ago[LLDB] Fix GCC warnings about extra semicolons. NFC.
Martin Storsjö [Wed, 12 Feb 2020 09:22:26 +0000 (11:22 +0200)]
[LLDB] Fix GCC warnings about extra semicolons. NFC.

2 years ago[DebugInfo] Prevent explosion of debug intrinsics during jump threading
stozer [Mon, 27 Jan 2020 16:05:34 +0000 (16:05 +0000)]
[DebugInfo] Prevent explosion of debug intrinsics during jump threading

This patch is a fix following the revert of 72ce759
and fixes the failure that it caused.

The above patch failed on the Thread Sanitizer buildbot with an out of
memory error. After an investigation, the cause was identified as an
explosion in debug intrinsics while running the Jump Threading pass on
ModuleMap.ll. The above patched prevented debug intrinsics from being
dropped when their Basic Block was deleted due to being "empty". In this
case, one of the functions in ModuleMap.ll had (after many optimization
passes) a very large number of debug intrinsics representing a set of
repeatedly inlined variables. Previously the vast majority of these were
silently dropped during Jump Threading when their blocks were deleted,
but as of the above patch they survived for longer, causing a large
increase in the number of debug intrinsics. These intrinsics were then
repeatedly cloned by the Jump Threading pass as edges were threaded,
multiplying the intrinsic count further. The memory consumed by this
process spiralled out of control, crashing the buildbot that uses TSan
(which has an estimated 5-10x memory overhead compared to non-sanitized

This patch adds RemoveRedundantDbgInstrs to the Jump Threading pass, in
order to reduce the number of debug intrinsics down to a manageable
amount in cases where many intrinsics for the same variable end up
bunched together contiguously, as in this case.

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

2 years ago[ConstantFolding] Fold calls to FP remainder function
Ehud Katz [Wed, 12 Feb 2020 11:14:09 +0000 (13:14 +0200)]
[ConstantFolding] Fold calls to FP remainder function

With the fixed implementation of the "remainder" operation in
rG9d0956ebd471, we can now add support to folding calls to it.

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

2 years ago[AMDGPU] Add one more pass to LLVMInitializeAMDGPUTarget
Jay Foad [Wed, 12 Feb 2020 11:15:56 +0000 (11:15 +0000)]
[AMDGPU] Add one more pass to LLVMInitializeAMDGPUTarget

2 years ago[DebugInfo][test][NFC] Remove case numbers
James Henderson [Tue, 11 Feb 2020 13:33:29 +0000 (13:33 +0000)]
[DebugInfo][test][NFC] Remove case numbers

This reduces the noise caused by adding cases earlier in the sequence.

Reviewed by: dblaikie

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

2 years agoRevert "[DebugInfo] Enable the debug entry values feature by default"
Djordje Todorovic [Wed, 12 Feb 2020 10:54:29 +0000 (11:54 +0100)]
Revert "[DebugInfo] Enable the debug entry values feature by default"

This reverts commit rG9f6ff07f8a39.

Found a test failure on clang-with-thin-lto-ubuntu buildbot.

2 years ago[llvm-objdump] Add column headers for relocation printing
Liad Mordekoviz [Tue, 11 Feb 2020 11:10:57 +0000 (11:10 +0000)]
[llvm-objdump] Add column headers for relocation printing

This allows us better readability and compatibility with what GNU
objdump prints.

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

Reviewed by: jhenderson, MaskRay

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

2 years ago[ARM] MVE vector reduce add tests. NFC
David Green [Tue, 11 Feb 2020 12:17:03 +0000 (12:17 +0000)]
[ARM] MVE vector reduce add tests. NFC

2 years ago[llvm-objcopy] Fix pipeline syntax
Kadir Cetinkaya [Wed, 12 Feb 2020 10:34:40 +0000 (11:34 +0100)]
[llvm-objcopy] Fix pipeline syntax

2 years ago[lldb] Pass a valid SourceLocation to Sema::RequireCompleteType in ASTResultSynthesizer
Raphael Isemann [Mon, 10 Feb 2020 07:13:09 +0000 (08:13 +0100)]
[lldb] Pass a valid SourceLocation to Sema::RequireCompleteType in ASTResultSynthesizer

Sema::RequireCompleteTypeImpl is supposed to have an assert that checks that the
SourceLocation that is passed in is always valid. It's currently commented out, but
as soon as this assert goes active, nearly every LLDB expression will start crashing as
we always pass in an invalid SourceLocation from the ASTResultSynthesizer.

This patch just passes in the valid SourceLocation of the expression (which is
the SourceLocation where the complete type is required) to prevent that from happening.

2 years ago[clang] Add -fignore-exceptions
jasonliu [Tue, 11 Feb 2020 09:52:56 +0000 (09:52 +0000)]
[clang] Add -fignore-exceptions


This is trying to implement the functionality proposed in:
An exception can throw, but no cleanup is going to happen.
A module compiled with exceptions on, can catch the exception throws
from module compiled with -fignore-exceptions.

The use cases for enabling this option are:
1. Performance analysis of EH instrumentation overhead
2. The ability to QA non EH functionality when EH functionality is not available.
3. User of EH enabled headers knows the calls won't throw in their program and
   wants the performance gain from ignoring EH construct.

The implementation tried to accomplish that by removing any landing pad code
 that might get generated.

Reviewed by: aaron.ballman

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

2 years agoRevert "[SCCP] Remove forcedconstant, go to overdefined instead"
Florian Hahn [Wed, 12 Feb 2020 09:41:19 +0000 (09:41 +0000)]
Revert "[SCCP] Remove forcedconstant, go to overdefined instead"

This causes a crash for the reproducer below

 enum { a };
 enum b { c, d };
 static _Bool g(struct f *h, enum b i) {
   i &&j();
   return a;
 static k(char h, enum b i) {
   _Bool l = g(e, i);
 m(h) {
   k(h, c);
   g(h, d);

This reverts commit aadb635e04854220064b77cc10d0e6772f5492fd.

2 years ago[CodeGen] Fix the computation of the alignment of split stores.
Clement Courbet [Mon, 10 Feb 2020 10:27:53 +0000 (11:27 +0100)]
[CodeGen] Fix the computation of the alignment of split stores.

Right now the alignment of the lower half of a store is computed as
align/2, which fails for unaligned stores (align = 1), and is overly
pessimitic for, e.g. a 8 byte store aligned to 4 bytes.
Fixes PR44851
Fixes PR44877

Reviewers: gchatelet, spatel, lebedev.ri

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

2 years ago[NFC?][SCEV][LoopVectorize] Add datalayout to the X86/float-induction-x86.ll test
Roman Lebedev [Wed, 12 Feb 2020 09:27:38 +0000 (12:27 +0300)]
[NFC?][SCEV][LoopVectorize] Add datalayout to the X86/float-induction-x86.ll test

Currently, `SCEVExpander::isHighCostExpansionHelper()` has the following logic:
  if (auto *UDivExpr = dyn_cast<SCEVUDivExpr>(S)) {
    // If the divisor is a power of two and the SCEV type fits in a native
    // integer (and the LHS not expensive), consider the division cheap
    // irrespective of whether it occurs in the user code since it can be
    // lowered into a right shift.
    if (auto *SC = dyn_cast<SCEVConstant>(UDivExpr->getRHS()))
      if (SC->getAPInt().isPowerOf2()) {
        if (isHighCostExpansionHelper(UDivExpr->getLHS(), L, At,
                                      BudgetRemaining, TTI, Processed))
          return true;
        const DataLayout &DL =
        unsigned Width = cast<IntegerType>(UDivExpr->getType())->getBitWidth();
        return DL.isIllegalInteger(Width);

Since this test does not have a datalayout specified,
`SCEVExpander::isHighCostExpansionHelper()` says that
`[[TMP2:%.*]] = lshr exact i64 [[TMP1]], 5` is high-cost, and didn't perform it.

But future patches will change that logic to solely rely on cost-model,
without any such datalayout checks, so i think it is best to show
that that change is ephemeral, and can already happen without costmodel changes.

Reviewers: reames, fhahn, sanjoy, craig.topper, RKSimon

Reviewed By: RKSimon

Subscribers: javed.absar, llvm-commits

Tags: #llvm

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

2 years ago[DebugInfo] Enable the debug entry values feature by default
Djordje Todorovic [Mon, 10 Feb 2020 10:06:44 +0000 (11:06 +0100)]
[DebugInfo] Enable the debug entry values feature by default

This patch enables the debug entry values feature.

  - Remove the (CC1) experimental -femit-debug-entry-values option
  - Enable it for x86, arm and aarch64 targets
  - Resolve the test failures
  - Leave the llc experimental option for targets that do not
    support the CallSiteInfo yet

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

2 years agoRemove static registration for dialects, and the "alwayslink" hack for passes
Mehdi Amini [Wed, 12 Feb 2020 09:03:40 +0000 (09:03 +0000)]
Remove static registration for dialects, and the "alwayslink" hack for passes

In the previous state, we were relying on forcing the linker to include
all libraries in the final binary and the global initializer to self-register
every piece of the system. This change help moving away from this model, and
allow users to compose pieces more freely. The current change is only "fixing"
the dialect registration and avoiding relying on "whole link" for the passes.
The translation is still relying on the global registry, and some refactoring
is needed to make this all more convenient.

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

2 years ago[CodeGenPrepare] Add more store splitting tests for PR44877.
Clement Courbet [Wed, 12 Feb 2020 08:05:27 +0000 (09:05 +0100)]
[CodeGenPrepare] Add more store splitting tests for PR44877.

2 years ago[lldb][NFC] Remove GetConstTypeName and GetConstQualifiedTypeName from CompilerType
Raphael Isemann [Wed, 12 Feb 2020 08:35:19 +0000 (09:35 +0100)]
[lldb][NFC] Remove GetConstTypeName and GetConstQualifiedTypeName from CompilerType

Beside these two functions just being wrappers around GetTypeName they are also
just a leftover from migrating the CompilerType interface to ConstString.

2 years ago[lldb][NFC] Move common_completions mapping out of CommandCompletions header.
Raphael Isemann [Wed, 12 Feb 2020 08:22:59 +0000 (09:22 +0100)]
[lldb][NFC] Move common_completions mapping out of CommandCompletions header.

2 years ago[mlir] Revise naming of MLIROptMain and MLIRMlirOptLib
Marius Brehler [Wed, 12 Feb 2020 08:41:40 +0000 (09:41 +0100)]
[mlir] Revise naming of MLIROptMain and MLIRMlirOptLib

* Rename CMake target MLIROptMain to MLIROptLib:
   The target provides the main library
* Rename CMake target MLIRMlirOptLib to MLIRMlirOptMain:
   The target provides the main() entry function

At the moment, the Bazel configuration of TenorFlow maps the target
MlirOptLib to "lib/Support/MlirOptMain.cpp" and MlirOptMain to
"tools/mlir-opt/mlir-opt.cpp". This is the other way around in the CMake
configuration. As discussed in the context of the pull request
https://github.com/tensorflow/tensorflow/pull/36301, it seems useful to
revise the naming in the MLIR repo.

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

2 years ago[APFloat] Fix FP remainder operation
Ehud Katz [Wed, 12 Feb 2020 08:42:55 +0000 (10:42 +0200)]
[APFloat] Fix FP remainder operation

Reimplement IEEEFloat::remainder() function.

Fix PR3359.

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

2 years ago[lldb] Move implementation of GetDisplayName to TypeSystem class
Raphael Isemann [Wed, 12 Feb 2020 08:10:19 +0000 (09:10 +0100)]
[lldb] Move implementation of GetDisplayName to TypeSystem class

CompilerType doesn't implement logic.

2 years ago[yaml2obj][test] - Simplify the test: yaml2obj/ELF/call-graph-profile-section.yaml
Georgii Rymar [Tue, 11 Feb 2020 11:13:16 +0000 (14:13 +0300)]
[yaml2obj][test] - Simplify the test: yaml2obj/ELF/call-graph-profile-section.yaml

Now with the new functionality that allows creating "defines", it is
possible to reduce this test (I tried to find another ones, but seems others
were already fixed previously).

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

2 years agoAMDGPU: llvm.amdgcn.writelane is a source of divergence
Nicolai Hähnle [Tue, 11 Feb 2020 13:40:00 +0000 (14:40 +0100)]
AMDGPU: llvm.amdgcn.writelane is a source of divergence


  %r = call i32 @llvm.amdgcn.writelane(i32 0, i32 1, i32 2)

This produces a value that is 0 on lane 1, and 2 everywhere else; i.e.,
it is divergent.

Reported-by: Marek Olsak <Marek.Olsak@amd.com>
Reviewers: arsenm, foad, mareko

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

Tags: #llvm

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

2 years agoSelectionDAG: Fix bug in ClusterNeighboringLoads
Nicolai Hähnle [Fri, 7 Feb 2020 21:08:36 +0000 (22:08 +0100)]
SelectionDAG: Fix bug in ClusterNeighboringLoads

The method attempts to find loads that can be legally clustered by
looking for loads consuming the same chain glue token.

However, the old code looks at _all_ users of values produced by the
chain node -- including uses of the loaded/returned value of volatile
loads or atomics. This could lead to circular dependencies which then
failed during scheduling.

With this change, we filter out users by getResNo, i.e. by which
SDValue value they use, to ensure that we only look at users of the
chain glue token.

This appears to be a rather old bug, which is perhaps surprising.
However, the test case is actually quite fragile (i.e., it is hidden
by fairly small changes), and the test _must_ use volatile loads for
the bug to manifest.

Reviewers: arsenm, bogner, craig.topper, foad

Subscribers: MatzeB, jvesely, wdng, hiraditya, javed.absar, jfb, kerbowa, llvm-commits

Tags: #llvm

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

2 years ago[lldb][NFC] Move all completer subclasses into source file
Raphael Isemann [Wed, 12 Feb 2020 07:56:03 +0000 (08:56 +0100)]
[lldb][NFC] Move all completer subclasses into source file

They are all implementation details so let's keep them out of the interface.
Also makes this code more readable by keeping these small classes
not spread over header and source file.

2 years ago[MLIR] Support memrefs with complex element types.
Alexander Belyaev [Wed, 12 Feb 2020 08:04:15 +0000 (09:04 +0100)]
[MLIR] Support memrefs with complex element types.

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

2 years ago[VE] Bit operator isel
Kazushi (Jam) Marukawa [Wed, 12 Feb 2020 08:01:30 +0000 (09:01 +0100)]
[VE] Bit operator isel

Summary: Isel and tests for bswap,brev,ctpop,ctlz,ctty,rotl,rotr

Reviewed By: arsenm

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

2 years ago[lldb][NFC] Remove eCustomCompletion mode
Raphael Isemann [Wed, 12 Feb 2020 06:57:00 +0000 (07:57 +0100)]
[lldb][NFC] Remove eCustomCompletion mode

It's not used by anyone. Also if something implements its own
completion it could just not call the method instead of having
a parameter that makes the function a no-op.

2 years ago[X86] Add test case for SoftPromoteHalf of STRICT_FP_EXTEND/STRICT_FP_ROUND.
Craig Topper [Wed, 12 Feb 2020 07:27:26 +0000 (23:27 -0800)]
[X86] Add test case for SoftPromoteHalf of STRICT_FP_EXTEND/STRICT_FP_ROUND.

Tests that should have been with 0daf9b8e41327b1511b2bbc272184ff4fdb8de79

2 years ago[X86] Remove unnecessary hasSideEffects = 0, mayLoad = 1 from an instruction with...
Craig Topper [Wed, 12 Feb 2020 07:16:32 +0000 (23:16 -0800)]
[X86] Remove unnecessary hasSideEffects = 0, mayLoad = 1 from an instruction with a pattern. NFC

2 years ago[X86] Correct the predicate on some patterns for 128 and 256 EVEX versions of VCVTPS2PH.
Craig Topper [Wed, 12 Feb 2020 07:13:28 +0000 (23:13 -0800)]
[X86] Correct the predicate on some patterns for 128 and 256 EVEX versions of VCVTPS2PH.

These should require AVX512VL not AVX512F. The legacy VEX patterns
will match first unless AVX512VL is enabled so this doesn't cause
a functional issue.

2 years ago[DebugInfo] Add support for DWARF64 into DWARFDebugAddr.
Igor Kudrin [Mon, 8 Jul 2019 14:55:36 +0000 (21:55 +0700)]
[DebugInfo] Add support for DWARF64 into DWARFDebugAddr.

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

2 years ago[DebugInfo] Simplify DWARFDebugAddr.
Igor Kudrin [Thu, 6 Feb 2020 07:14:12 +0000 (14:14 +0700)]
[DebugInfo] Simplify DWARFDebugAddr.

The patch removes unnecessary members of DWARFDebugAddr and further
simplifies the implementation by separating parsing methods of tables
in the DWARFv5 and pre-standard formats.

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

2 years ago[DebugInfo] Refine error messages in DWARFDebugAddr.
Igor Kudrin [Thu, 6 Feb 2020 09:30:30 +0000 (16:30 +0700)]
[DebugInfo] Refine error messages in DWARFDebugAddr.

As a preparation for the subsequent patches, this updates the wordings
of some error messages in DWARFDebugAddr.

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

2 years ago[DebugInfo] Use "an address table" in diagnostic messages of DWARFDebugAddr.
Igor Kudrin [Tue, 11 Feb 2020 08:55:12 +0000 (15:55 +0700)]
[DebugInfo] Use "an address table" in diagnostic messages of DWARFDebugAddr.

This replaces a collocation "a .debug_addr table" with "an address table"
because the latter sounds more accurate.

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

2 years ago[DebugInfo] Do not dump header field for pre-DWARFv5 address tables.
Igor Kudrin [Thu, 6 Feb 2020 13:34:10 +0000 (20:34 +0700)]
[DebugInfo] Do not dump header field for pre-DWARFv5 address tables.

As there is no header in pre-DWARFv5 address tables, and we fill
the class data members with some artificial values, we should not
dump them as that might be misleading.

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

2 years ago[DebugInfo] Fix reading addresses in DWARFDebugAddr.
Igor Kudrin [Tue, 11 Feb 2020 12:43:20 +0000 (19:43 +0700)]
[DebugInfo] Fix reading addresses in DWARFDebugAddr.

As addresses in the address tables may have relocations, thus,
the relocations should be resolved to read the correct address.
That is especially important for targets that use RELA relocations
because in that case addends are stored in relocation sections.

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

2 years ago[X86][LegalizeTypes] Add SoftPromoteHalf support STRICT_FP_EXTEND and STRICT_FP_ROUND
Craig Topper [Wed, 12 Feb 2020 04:24:51 +0000 (20:24 -0800)]
[X86][LegalizeTypes] Add SoftPromoteHalf support STRICT_FP_EXTEND and STRICT_FP_ROUND

This adds a strict version of FP16_TO_FP and FP_TO_FP16 and uses
them to implement soft promotion for the half type. This is
enough to provide basic support for __fp16 with strictfp.

Add the necessary X86 support to use VCVTPS2PH/VCVTPH2PS when F16C
is enabled.

2 years ago[lldb] Remove skipIfFreeBSD from TestCompletion
Raphael Isemann [Wed, 12 Feb 2020 06:13:48 +0000 (07:13 +0100)]
[lldb] Remove skipIfFreeBSD from TestCompletion

This was skipped because of an pexpect issue (http://llvm.org/pr22784),
but this test is no longer using pexpect and is running fine on FreeBSD.

2 years ago[CMake] Delete llvm_add_go_executable and a reference to TARGET llvm-go
Fangrui Song [Wed, 12 Feb 2020 04:45:05 +0000 (20:45 -0800)]
[CMake] Delete llvm_add_go_executable and a reference to TARGET llvm-go

llvm-go was deleted by 102814b4d36ad004a2e37cd2a1e84bd2c3593d29.

2 years agoRevert "Reland "[Support] make report_fatal_error `abort` instead of `exit`""
Yuanfang Chen [Wed, 12 Feb 2020 04:39:34 +0000 (20:39 -0800)]
Revert "Reland "[Support] make report_fatal_error `abort` instead of `exit`""

This reverts commit rGcd5b308b828e, rGcd5b308b828e, rG8cedf0e2994c.

There are issues to be investigated for polly bots and bots turning on

2 years ago[TestConstVariable] Clean-up XFAIL lists.
Davide Italiano [Wed, 12 Feb 2020 04:30:12 +0000 (20:30 -0800)]
[TestConstVariable] Clean-up XFAIL lists.

These versions of `clang` are ancient history.

2 years agoAMDGPU: Use conditions directly in division expansion
Matt Arsenault [Tue, 11 Feb 2020 20:13:42 +0000 (15:13 -0500)]
AMDGPU: Use conditions directly in division expansion

This was creating a select on true/false values, and then comparing
that later. This produced more work for later combines, which can be
avoided by just using the boolean values. This was copied from the
original DAG expansion, which also has the same problem. This doesn't
have a observable change using SelectionDAG, but since GlobalISel is
missing these optimizations, the final code was noticeably longer.

2 years ago[OpenMP][Offloading] Added support for multiple streams so that multiple kernels...
Johannes Doerfert [Wed, 12 Feb 2020 04:06:32 +0000 (22:06 -0600)]
[OpenMP][Offloading] Added support for multiple streams so that multiple kernels can be executed concurrently

Reviewed By: jdoerfert

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

2 years agoTemporarily XFAIL these two tests.
Yuanfang Chen [Wed, 12 Feb 2020 03:18:23 +0000 (19:18 -0800)]
Temporarily XFAIL these two tests.


2 years agoFix two more test cases for https://reviews.llvm.org/D74456.
Yuanfang Chen [Wed, 12 Feb 2020 02:34:34 +0000 (18:34 -0800)]
Fix two more test cases for https://reviews.llvm.org/D74456.

2 years agoReland "[Support] make report_fatal_error `abort` instead of `exit`"
Yuanfang Chen [Tue, 11 Feb 2020 02:33:05 +0000 (18:33 -0800)]
Reland "[Support] make report_fatal_error `abort` instead of `exit`"

Reland D67847 after D73742 is committed. Replace `sys::Process::Exit(1)`
with `abort` in `report_fatal_error`.

After this patch, for tools turning on `CrashRecoveryContext`,
crash handler installed by `CrashRecoveryContext` is called unless
they installed a non-returning handler using `llvm::install_fatal_error_handler`
like `cc1_main` currently does.

Reviewers: rnk, MaskRay, aganea, hans, espindola, jhenderson

Subscribers: jholewinski, qcolombet, dschuff, jyknight, emaste, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, hiraditya, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, steven_wu, rogfer01, MartinMosbeck, brucehoult, the_o, dexonsmith, PkmX, rupprecht, jocewei, jsji, Jim, dmgreen, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, kerbowa, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

2 years agoRemoved declared but non-existent createMaterializeVectorsPass() (NFC)
Mehdi Amini [Wed, 12 Feb 2020 02:05:31 +0000 (02:05 +0000)]
Removed declared but non-existent createMaterializeVectorsPass() (NFC)

2 years ago[lld][WebAssembly] Fail if bitcode objects are pulled in after LTO
Sam Clegg [Fri, 20 Dec 2019 01:30:24 +0000 (17:30 -0800)]
[lld][WebAssembly] Fail if bitcode objects are pulled in after LTO

This can happen if lto::LTO::getRuntimeLibcallSymbols doesn't return
an complete/accurate list of libcalls.  In this case new bitcode
object can be linked in after LTO.

For example the WebAssembly backend currently calls:
  setLibcallName(RTLIB::FPROUND_F32_F16, "__truncsfhf2");

But `__truncsfhf2` is not part of `getRuntimeLibcallSymbols` so if
this symbol is generated during LTO the link will currently fail.

Without this change the linker crashes because the bitcode symbol
makes it all the way to the output phase.

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

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

2 years ago[compiler-rt] Compile __powitf2 under wasm
Sam Clegg [Sat, 8 Feb 2020 02:15:15 +0000 (18:15 -0800)]
[compiler-rt] Compile __powitf2 under wasm

See https://github.com/emscripten-core/emscripten/issues/10374
See https://reviews.llvm.org/D74274

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

2 years ago[test] Improve test/CodeGen/X86/linux-preemption.ll
Fangrui Song [Wed, 12 Feb 2020 01:17:08 +0000 (17:17 -0800)]
[test] Improve test/CodeGen/X86/linux-preemption.ll

2 years ago[AMDGPU][GlobalISel] Refactor selectDS1Addr1Offset/selectDS64Bit4ByteAligned
Austin Kerbow [Fri, 7 Feb 2020 16:29:23 +0000 (08:29 -0800)]
[AMDGPU][GlobalISel] Refactor selectDS1Addr1Offset/selectDS64Bit4ByteAligned

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

2 years agoRe-land "[MS] Overhaul how clang passes overaligned args on x86_32"
Reid Kleckner [Wed, 12 Feb 2020 00:03:26 +0000 (16:03 -0800)]
Re-land "[MS] Overhaul how clang passes overaligned args on x86_32"

This brings back 2af74e27ed7d0832cbdde9cb969aaca7a42e99f9 and reverts

The changes were correct, the code that was broken contained an ODR
violation that assumed that these types are passed equivalently:
  struct alignas(uint64_t) Wrapper { uint64_t P };
  void f(uint64_t p);
  void f(Wrapper p);

MSVC does not pass them the same way, and so clang-cl should not pass
them the same way either.

2 years ago[lldb/Plugins] Rename OSPython plugin to OperatingSystemPython (NFC)
Jonas Devlieghere [Wed, 12 Feb 2020 00:31:26 +0000 (16:31 -0800)]
[lldb/Plugins] Rename OSPython plugin to OperatingSystemPython (NFC)

Rename the plugin to match both the directory structure and the class.

2 years agoReverted the remainings of c1c9819ef91aab51b5a23fb3027adac5a2f551cc
Galina Kistanova [Wed, 12 Feb 2020 00:20:06 +0000 (16:20 -0800)]
Reverted the remainings of c1c9819ef91aab51b5a23fb3027adac5a2f551cc
as it has left broken llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast buildbot for long time.

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

2 years agoRewrite default "could not attach" msg to point to hints
Jason Molenda [Wed, 12 Feb 2020 00:17:35 +0000 (16:17 -0800)]
Rewrite default "could not attach" msg to point to hints
about where more information can be found about why it
may have failed.

2 years agoAMDGPU: Don't expand more special div cases in IR
Matt Arsenault [Tue, 11 Feb 2020 19:57:09 +0000 (14:57 -0500)]
AMDGPU: Don't expand more special div cases in IR

These have nicer expansions implemented in the DAG. Ideally we would
either directly implement all of these special expansions, or stop
expanding division in the IR.

2 years agoFix MSVC build with C++ EH enabled
Reid Kleckner [Tue, 11 Feb 2020 23:50:27 +0000 (15:50 -0800)]
Fix MSVC build with C++ EH enabled

Mark the CrashRecoveryContextImpl constructor noexcept, so that MSVC
won't emit an unwind helper to clean up the allocation from `new` if the
constructor throws an exception.

Otherwise, MSVC complains:
  llvm\lib\Support\CrashRecoveryContext.cpp(220): error C2712: \
  Cannot use __try in functions that require object unwinding

The other simple fix would be to wrap `new` in a static helper or

Users have reported that Tensorflow builds LLVM with /EHsc.

2 years ago[lldb/Plugins] Move PlatformRemoteiOS into PlatformMacOSX (NFCI)
Jonas Devlieghere [Tue, 11 Feb 2020 23:52:41 +0000 (15:52 -0800)]
[lldb/Plugins] Move PlatformRemoteiOS into PlatformMacOSX (NFCI)

Move the logic for initialization and termination for PlatformRemoteiOS
into PlatformMacOSX, like we did for the other Darwin platforms in

2 years agoAMDGPU: Don't report 2-byte alignment as fast
Matt Arsenault [Mon, 10 Feb 2020 15:30:34 +0000 (10:30 -0500)]
AMDGPU: Don't report 2-byte alignment as fast

This is apparently worse than 1-byte alignment. This does not attempt
to decompose 2-byte aligned wide stores, but will stop trying to
produce them.

Also fix bug in LoadStoreVectorizer which was decreasing the alignment
and vectorizing stack accesses. It was assuming a stack object was an
alloca that could have its base alignment changed, which is not true
if the pointer is derived from a function argument.

2 years ago[llvm-objcopy][WebAssembly] Add dump/add/remove-section support
Derek Schuff [Tue, 11 Feb 2020 23:13:40 +0000 (15:13 -0800)]
[llvm-objcopy][WebAssembly] Add dump/add/remove-section support

Add support for adding, removing, and dumping wasm sections to objcopy

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

2 years agoUse std::foo_t rather than std::foo in LLVM.
Justin Lebar [Tue, 11 Feb 2020 04:33:08 +0000 (20:33 -0800)]
Use std::foo_t rather than std::foo in LLVM.

Summary: C++14 migration. No functional change.

Reviewers: bkramer, JDevlieghere, lebedev.ri

Subscribers: MatzeB, hiraditya, jkorous, dexonsmith, arphaman, kadircet, lebedev.ri, usaxena95, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

2 years ago[OpenMP] Switch default C++ standard to C++ 14
Johannes Doerfert [Tue, 11 Feb 2020 23:08:48 +0000 (17:08 -0600)]
[OpenMP] Switch default C++ standard to C++ 14

Reviewed By: JonChesterfield

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

2 years agoAMDGPU: Add baseline tests for CGP div expansion
Matt Arsenault [Tue, 11 Feb 2020 18:54:17 +0000 (13:54 -0500)]
AMDGPU: Add baseline tests for CGP div expansion

These cases are harmed by expanding division early in the IR, before