platform/upstream/llvm.git
4 years ago[WebAssembly] Mangle the argc/argv `main` as `__wasm_argc_argv`.
Dan Gohman [Mon, 25 Nov 2019 17:50:58 +0000 (09:50 -0800)]
[WebAssembly] Mangle the argc/argv `main` as `__wasm_argc_argv`.

WebAssembly enforces a rule that caller and callee signatures must
match. This means that the traditional technique of passing `main`
`argc` and `argv` even when it doesn't need them doesn't work.

Currently the backend renames `main` to `__original_main`, however this
doesn't interact well with LTO'ing libc, and the name isn't intuitive.
This patch allows us to transition to `__main_argc_argv` instead.

This implements the proposal in
https://github.com/WebAssembly/tool-conventions/pull/134
with a flag to disable it when targeting Emscripten, though this is
expected to be temporary, as discussed in the proposal comments.

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

4 years ago[WebAssembly] Teach lld how to demangle "__main_argc_argv".
Dan Gohman [Thu, 27 Feb 2020 15:51:37 +0000 (07:51 -0800)]
[WebAssembly] Teach lld how to demangle "__main_argc_argv".

WebAssembly requires that caller and callee signatures match, so it
can't do the usual trick of passing more arguments to main than it
expects. Instead WebAssembly will mangle "main" with argc/argv
parameters as "__main_argc_argv". This patch teaches lld how to
demangle it.

This patch is part of https://reviews.llvm.org/D70700.

4 years ago[WebAssembly] Add an `isWasm` target triple predicate.
Dan Gohman [Thu, 27 Feb 2020 15:49:56 +0000 (07:49 -0800)]
[WebAssembly] Add an `isWasm` target triple predicate.

This simplies code which needs to apply the same logic to both wasm32
and wasm64.

This patch is part of https://reviews.llvm.org/D70700.

4 years ago[InstCombine] Add PR14365 test cases + vector equivalents.
Simon Pilgrim [Thu, 27 Feb 2020 15:53:22 +0000 (15:53 +0000)]
[InstCombine] Add PR14365 test cases + vector equivalents.

4 years ago[CostModel][X86] Improve extract/insert element costs (PR43605)
Simon Pilgrim [Thu, 27 Feb 2020 15:36:13 +0000 (15:36 +0000)]
[CostModel][X86] Improve extract/insert element costs (PR43605)

This tries to improve the accuracy of extract/insert element costs by accounting for subvector extraction/insertion for >128-bit vectors and the shuffling of elements to/from the 0'th index.

It also adds INSERTPS for f32 types and PINSR/PEXTR costs for integer types (at the moment we assume the same cost as MOVD/MOVQ - which isn't always true).

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

4 years agoRevert "[ARM] Add CPSR as an implicit use of t2IT"
Sam Parker [Thu, 27 Feb 2020 15:36:53 +0000 (15:36 +0000)]
Revert "[ARM] Add CPSR as an implicit use of t2IT"

This reverts commit e58229fded0407f3e4f77cd87bedcd4d35bb7c89.

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

4 years ago[Debuginfo][NFC] Unify error reporting routines inside DebugInfoDWARF.
Alexey Lapshin [Thu, 27 Feb 2020 14:53:00 +0000 (17:53 +0300)]
[Debuginfo][NFC] Unify error reporting routines inside DebugInfoDWARF.

Summary:
Error reporting in DebugInfoDWARF library currently done in three ways :

1. Direct calls to WithColor::error()/WithColor::warning()
2. ErrorPolicy defaultErrorHandler(Error E);
3. void dumpWarning(Error Warning);

additionally, other locations could have more variations:

lld/ELF/SyntheticSection.cpp
    if (Error e = cu->tryExtractDIEsIfNeeded(false)) {
      error(toString(sec) + ": " + toString(std::move(e)));

DebugInfo/DWARF/DWARFUnit.cpp
  if (Error e = tryExtractDIEsIfNeeded(CUDieOnly))
    WithColor::error() << toString(std::move(e));

Thus error reporting could look inconsistent. To have a consistent error
messages it is necessary to have a possibility to redefine error
reporting functions. This patch creates two handlers and allows to
redefine them. It also patches all places inside DebugInfoDWARF
to use these handlers.

The intention is always to use following handlers for error reporting
purposes inside DebugInfoDWARF:

DebugInfo/DWARF/DWARFContext.h

std::function<void(Error E)> RecoverableErrorHandler = WithColor::defaultErrorHandler;
std::function<void(Error E)> WarningHandler = WithColor::defaultWarningHandler;

This is last patch from series of patches: D74481, D74635, D75118.

Reviewers: jhenderson, dblaikie, probinson, aprantl, JDevlieghere

Reviewed By: jhenderson

Subscribers: grimar, hiraditya, llvm-commits

Tags: #llvm, #debug-info

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

4 years ago[DA] Delinearization of fixed-size multi-dimensional arrays
Bardia Mahjour [Wed, 26 Feb 2020 17:51:58 +0000 (12:51 -0500)]
[DA] Delinearization of fixed-size multi-dimensional arrays

Summary:
Currently the dependence analysis in LLVM is unable to compute accurate
dependence vectors for multi-dimensional fixed size arrays.
This is mainly because the delinearization algorithm in scalar evolution
relies on parametric terms to be present in the access functions. In the
case of fixed size arrays such parametric terms are not present, but we
can use the indexes from GEP instructions to recover the subscripts for
each dimension of the arrays. This patch adds this ability under the
existing option `-da-disable-delinearization-checks`.

Authored By: bmahjour

Reviewer: Meinersbur, sebpop, fhahn, dmgreen, grosser, etiotto, bollu

Reviewed By: Meinersbur

Subscribers: hiraditya, arphaman, Whitney, ppc-slack, llvm-commits

Tags: #llvm

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

4 years ago[SYCL] Driver option to select SYCL version
Ruyman [Fri, 26 Jul 2019 15:21:01 +0000 (16:21 +0100)]
[SYCL] Driver option to select SYCL version

Summary:
User can select the version of SYCL the compiler will
use via the flag -sycl-std, similar to -cl-std.

The flag defines the LangOpts.SYCLVersion option to the
version of SYCL. The default value is undefined.
If driver is building SYCL code, flag is set to the default SYCL
version (1.2.1)

The preprocessor uses this variable to define CL_SYCL_LANGUAGE_VERSION macro,
which should be defined according to SYCL 1.2.1 standard.

Only valid value at this point for the flag is 1.2.1.

Co-Authored-By: David Wood <Q0KPU0H1YOEPHRY1R2SN5B5RL@david.davidtw.co>
Signed-off-by: Ruyman Reyes <ruyman@codeplay.com>
Subscribers: ebevhan, Anastasia, cfe-commits

Tags: #clang

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

Signed-off-by: Alexey Bader <alexey.bader@intel.com>
4 years ago[Hexagon] Do not use init_arrays by default
Krzysztof Parzyszek [Thu, 27 Feb 2020 15:04:56 +0000 (09:04 -0600)]
[Hexagon] Do not use init_arrays by default

4 years ago[mlir] NFC - Move runner utils from mlir-cpu-runner to ExecutionEngine
Nicolas Vasilache [Thu, 27 Feb 2020 14:51:15 +0000 (09:51 -0500)]
[mlir] NFC - Move runner utils from mlir-cpu-runner to ExecutionEngine

Runner utils are useful beyond just CPU and hiding them within the test directory
makes it unnecessarily harder to reuse in other projects.

4 years agoRevert "Devirtualize a call on alloca without waiting for post inline cleanup and...
Kirill Bobyrev [Thu, 27 Feb 2020 14:58:39 +0000 (15:58 +0100)]
Revert "Devirtualize a call on alloca without waiting for post inline cleanup and next"

This reverts commit 59fb9cde7a4a96fe8485a80d9010e4420ffdca82.

The patch caused internal miscompilations.

4 years ago[AMDGPU][ConstantFolding] Fold llvm.amdgcn.fract intrinsic
Jay Foad [Wed, 26 Feb 2020 15:16:57 +0000 (15:16 +0000)]
[AMDGPU][ConstantFolding] Fold llvm.amdgcn.fract intrinsic

Reviewers: nhaehnle, arsenm, rampitec

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

Tags: #llvm

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

4 years agoFix cppcheck definition/declaration arg mismatch warnings. NFCI.
Simon Pilgrim [Thu, 27 Feb 2020 14:34:37 +0000 (14:34 +0000)]
Fix cppcheck definition/declaration arg mismatch warnings. NFCI.

4 years ago[X86] Use Subtarget.useSoftFloat() in X86TargetLowering constructor
Simon Pilgrim [Thu, 27 Feb 2020 14:27:16 +0000 (14:27 +0000)]
[X86] Use Subtarget.useSoftFloat() in X86TargetLowering constructor

Avoid use of X86TargetLowering::useSoftFloat() in the constructor as its a virtual function

4 years agoAdding some documentation for __builtin_dump_struct.
Aaron Ballman [Thu, 27 Feb 2020 14:29:40 +0000 (09:29 -0500)]
Adding some documentation for __builtin_dump_struct.

4 years agoAdd GPU lowerings for the different log ops.
Adrian Kuegel [Thu, 27 Feb 2020 12:03:05 +0000 (13:03 +0100)]
Add GPU lowerings for the different log ops.

Summary: This adds GPU lowerings for log, log10 and log2.

Reviewers: mravishankar, herhut

Subscribers: jholewinski, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, llvm-commits

Tags: #llvm

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

4 years agoFix shadow variable warning. NFC.
Simon Pilgrim [Thu, 27 Feb 2020 14:23:05 +0000 (14:23 +0000)]
Fix shadow variable warning. NFC.

4 years agoFix shadow variable warnings. NFC.
Simon Pilgrim [Thu, 27 Feb 2020 14:20:30 +0000 (14:20 +0000)]
Fix shadow variable warnings. NFC.

4 years ago[X86] LowerMSCATTER/MGATHER - reduce scope of MaskVT. NFCI.
Simon Pilgrim [Thu, 27 Feb 2020 14:02:20 +0000 (14:02 +0000)]
[X86] LowerMSCATTER/MGATHER - reduce scope of MaskVT. NFCI.

Fixes cppcheck warning.

4 years agoFix uninitialized variable warning. NFC.
Simon Pilgrim [Thu, 27 Feb 2020 13:55:31 +0000 (13:55 +0000)]
Fix uninitialized variable warning. NFC.

4 years ago[mlir] fix wrong symbol order in AffineApplyNormalizer
Alex Zinenko [Thu, 27 Feb 2020 13:45:54 +0000 (14:45 +0100)]
[mlir] fix wrong symbol order in AffineApplyNormalizer

Summary:
AffineApplyNormalizer provides common logic for folding affine maps that appear
in affine.apply into other affine operations that use the result of said
affine.apply. In the process, affine maps of both operations are composed.
During the composition `A.compose(B)` the symbols from the map A are placed
before those of the map B in a single concatenated symbol list. However,
AffineApplyNormalizer was ordering the operands of the operation being
normalized by iteratively appending the symbols into a single list accoridng to
the operand order, regardless of whether these operands are symbols of the
current operation or of the map that is being folded into it. This could lead
to wrong order of symbols and, when the symbols were bound to constant values,
to visibly incorrect folding of constants into affine maps as reported in
PR45031. Make sure symbols operands to the current operation are always placed
before symbols coming from the folded maps.

Update the test that was exercising the incorrect folder behavior. For some
reason, the order of symbol operands was swapped in the test input compared to
the previous operations, making it easy to assume the correct maps were
produced whereas they were swapping the symbols back due to the problem
described above.

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

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

4 years ago[clangd][NFC] Don't query the index if the rename symbol is function
Haojian Wu [Thu, 27 Feb 2020 13:46:01 +0000 (14:46 +0100)]
[clangd][NFC] Don't query the index if the rename symbol is function
local.

This would save an unnecessary index query when renaming a function
local symbol in cross-file rename mode.

4 years ago[X86] createVariablePermute - handle case where recursive createVariablePermute call...
Simon Pilgrim [Thu, 27 Feb 2020 13:52:16 +0000 (13:52 +0000)]
[X86] createVariablePermute - handle case where recursive createVariablePermute call fails

Account for the case where a recursive createVariablePermute call with a wider vector type fails.

Original test case from @craig.topper (Craig Topper)

4 years ago[clang-format] Recognize C# named argument colons as a token type
Jonathan Coe [Thu, 27 Feb 2020 13:46:43 +0000 (13:46 +0000)]
[clang-format] Recognize C# named argument colons as a token type

Summary:
No longer merge 'name' and ':' into a single token.

Ensure that line breaks cannot be placed before or after a named-argument colon.

Ensure that no space is inserted before a named-argument colon.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits, MyDeveloperDay

Tags: #clang-format, #clang

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

4 years agoRevert "make -fmodules-codegen and -fmodules-debuginfo work also with PCHs"
Hans Wennborg [Thu, 27 Feb 2020 13:33:43 +0000 (14:33 +0100)]
Revert "make -fmodules-codegen and -fmodules-debuginfo work also with PCHs"

This caused PR44953. See also the discussion on D74846.

This reverts commit cbc9d22e49b434b6ceb2eb94b67079d02e0a7b74.

4 years ago[CallSiteInfo] Handle bundles when updating call site info
Djordje Todorovic [Thu, 27 Feb 2020 10:44:53 +0000 (11:44 +0100)]
[CallSiteInfo] Handle bundles when updating call site info

This will address the issue: P8198 and P8199 (from D73534).

The methods was not handle bundles properly.

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

4 years ago[AArch64][SVE] Add intrinsics for first-faulting gather loads
Andrzej Warzynski [Fri, 21 Feb 2020 13:59:02 +0000 (13:59 +0000)]
[AArch64][SVE] Add intrinsics for first-faulting gather loads

Summary:
The following intrinsics are added:
  * @llvm.aarch64.sve.ldff1.gather
  * @llvm.aarch64.sve.ldff1.gather.index
  * @llvm.aarch64.sve.ldff1.gather_sxtw
  * @llvm.aarch64.sve.ldff1.gather.uxtw
  * @llvm.aarch64.sve.ldff1.gather_sxtw.index
  * @llvm.aarch64.sve.ldff1.gather.uxtw.index
  * @llvm.aarch64.sve.ldff1.gather.scalar.offset

Although this patch is quite substantial, the vast majority of the
implementation is just a 'copy & paste' of the implementation of regular
gather loads, including tests. There's only a handful of new
definitions:
  * AArch64ISD nodes defined in AArch64ISelLowering.h (e.g. GLDFF1)
  * Seleciton DAG Types in AArch64SVEInstrInfo.td (e.g.
    AArch64ldff1_gather)
  * intrinsics in IntrinsicsAArch64.td (e.g. aarch64_sve_ldff1_gather)
  * Pseudo instructions in SVEInstrFormats.td to workaround the issue of
    use-before-def for the FFR register.

Reviewed By: sdesmalen

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

4 years ago[driver][darwin] Don't use -platform_version flag by default (PR44813)
Hans Wennborg [Thu, 27 Feb 2020 12:48:26 +0000 (13:48 +0100)]
[driver][darwin] Don't use -platform_version flag by default (PR44813)

The code in llvmorg-10-init-12188-g25ce33a6e4f is a breaking change for
users of older linkers who don't pass a version parameter, which
prevents a drop-in clang upgrade. Old tools can't know about what future
tools will do, so as a general principle the burden should be new tools
to be compatible by default. Also, for comparison, none of the other
tests of Version within AddLinkArgs add any new behaviors unless the
version is explicitly specified. Therefore, this patch changes the
-platform_version behavior from opt-out to opt-in.

Patch by David Major!

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

4 years ago[AVX] Cleanup check prefixes
Simon Pilgrim [Thu, 27 Feb 2020 12:27:18 +0000 (12:27 +0000)]
[AVX] Cleanup check prefixes

We were missing some coverage for avx512bw targets as the update script can be pretty dumb about check prefix orders...

4 years agoRequire asserts for debuginline-cost-delta.ll test
Kirill Bobyrev [Thu, 27 Feb 2020 12:16:12 +0000 (13:16 +0100)]
Require asserts for debuginline-cost-delta.ll test

-debug-only=inline-cost does not exist in optimized builds without
asserts and therefore the test fails for such configurations.

Related revision: c965fd942f1d2de6179cd1a2f78c78fa4bd74626

4 years ago[ARM] Fixup FP16 bitcasts
David Green [Tue, 25 Feb 2020 11:26:53 +0000 (11:26 +0000)]
[ARM] Fixup FP16 bitcasts

Under fp16 we optimise the bitcast between a VMOVhr and a CopyToReg via
custom lowering. This rewrites that to be a DAG combine instead, which
helps produce better code in the cases where the bitcast is actaully
legal.

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

4 years ago[clang-format] Handle commas in [] in C#
Jonathan Coe [Thu, 27 Feb 2020 11:39:57 +0000 (11:39 +0000)]
[clang-format] Handle commas in [] in C#

Summary:
Respect setting `SpacesInSquareBrackets` for commas in square brackets in C# code.

Reviewers: krasimir, MyDeveloperDay

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

4 years ago[MC][ARM] Resolve some pcrel fixups at assembly time (PR44929)
Hans Wennborg [Thu, 27 Feb 2020 11:35:10 +0000 (12:35 +0100)]
[MC][ARM] Resolve some pcrel fixups at assembly time (PR44929)

MC currently does not emit these relocation types, and lld does not
handle them. Add FKF_Constant as a work-around of some ARM code after
D72197. Eventually we probably should implement these relocation types.

By Fangrui Song!

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

4 years ago[InstCombine] Fix confusing variable name.
Jay Foad [Thu, 27 Feb 2020 11:27:49 +0000 (11:27 +0000)]
[InstCombine] Fix confusing variable name.

4 years ago[lldb] Show the actual error when 'watchpoint set expression' failed
Raphael Isemann [Thu, 27 Feb 2020 10:46:10 +0000 (11:46 +0100)]
[lldb] Show the actual error when 'watchpoint set expression' failed

Currently we only show the user that the expression failed but not
what is actually wrong with it. This just dumps the error we get
back alongside the other output to the error stream.

This should also help with finding out with why sometimees the
TestWatchLocationWithWatchSet.py test fails here on the LLDB
incremental bot on Green Dragon.

4 years agoRevert "[Hexagon] Improve casting of boolean HVX vectors to scalars"
Kirill Bobyrev [Thu, 27 Feb 2020 10:58:32 +0000 (11:58 +0100)]
Revert "[Hexagon] Improve casting of boolean HVX vectors to scalars"

This reverts commit 7691790dfd1011d08f5468f63952d7690755aad4.

The patch is failing tests with MSAN:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/39054/steps/check-llvm%20msan/logs/stdio

4 years ago[DebugInfo][ARM] Fix noreg case when checkig if it is an addImm
Djordje Todorovic [Thu, 27 Feb 2020 09:30:41 +0000 (10:30 +0100)]
[DebugInfo][ARM] Fix noreg case when checkig if it is an addImm

This fixes a build failure with an ARM buildbot.

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

4 years ago[DebugInfo] Describe call site values for chains of expression producing instrs
David Stenberg [Thu, 27 Feb 2020 08:54:37 +0000 (09:54 +0100)]
[DebugInfo] Describe call site values for chains of expression producing instrs

Summary:
If the describeLoadedValue() hook produced a DIExpression when
describing a instruction, and it was not possible to emit a call site
entry directly (the value operand was not an immediate nor a preserved
register), then that described value could not be inserted into the
worklist, and would instead be dropped, meaning that the parameter's
call site value couldn't be described.

This patch extends the worklist so that each entry has an DIExpression
that is built up when iterating through the instructions.

This allows us to describe instruction chains like this:

  $reg0 = mv $fp
  $reg0 = add $reg0, offset
  call @call_with_offseted_fp

Since DW_OP_LLVM_entry_value operations can't be combined with any other
expression, such call site entries will not be emitted. I have added a
test, dbgcall-site-expr-entry-value.mir, which verifies that we don't
assert or emit broken DWARF in such cases.

Reviewers: djtodoro, aprantl, vsk

Reviewed By: djtodoro, vsk

Subscribers: hiraditya, llvm-commits

Tags: #debug-info, #llvm

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

4 years ago[DebugInfo][NFC] Move out lambdas from collectCallSiteParameters()
David Stenberg [Thu, 27 Feb 2020 08:53:31 +0000 (09:53 +0100)]
[DebugInfo][NFC] Move out lambdas from collectCallSiteParameters()

Summary:
This is a preparatory patch for D75036, in which a debug expression is
associated with each parameter register in the worklist. In that patch
the two lambda functions addToWorklist() and finishCallSiteParams() grow
a bit, so move those out to separate functions. This patch also prepares
for each parameter register having their own expression moving the
creation of the DbgValueLoc into finishCallSiteParams().

Reviewers: djtodoro, vsk

Reviewed By: djtodoro, vsk

Subscribers: hiraditya, llvm-commits

Tags: #debug-info, #llvm

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

4 years ago[lldb][NFC] Fix several -Wdocumentation warnings
Raphael Isemann [Thu, 27 Feb 2020 10:16:16 +0000 (11:16 +0100)]
[lldb][NFC] Fix several -Wdocumentation warnings

The GetOffset documentation was copied from the function above
so I completely deleted that one. The rest was just outdated
documentation that didn't keep up with renamed or changed
function parameters/return types.

4 years ago[ARM] Add CPSR as an implicit use of t2IT
Sam Parker [Thu, 27 Feb 2020 10:10:40 +0000 (10:10 +0000)]
[ARM] Add CPSR as an implicit use of t2IT

This use is already attached to the BUNDLE instruction but is lost
after finalisation.

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

4 years ago[lldb] Skip TestWasm.py on sanitized builds until D75200 has landed
Raphael Isemann [Thu, 27 Feb 2020 09:45:26 +0000 (10:45 +0100)]
[lldb] Skip TestWasm.py on sanitized builds until D75200 has landed

4 years ago[clang,ARM,MVE] Remove redundant #includes in test file.
Simon Tatham [Thu, 27 Feb 2020 09:36:43 +0000 (09:36 +0000)]
[clang,ARM,MVE] Remove redundant #includes in test file.

I made that file by pasting together several pieces, and forgot to
take out the #include <arm_mve.h> from the tops of the later ones, so
the test was pointlessly including the same header five times. NFC.

4 years ago[NFC][ARM] Add test case
Sam Parker [Thu, 27 Feb 2020 09:38:13 +0000 (09:38 +0000)]
[NFC][ARM] Add test case

4 years ago[AArch64] Peephole optimization: merge AND and TST instructions
Sjoerd Meijer [Thu, 27 Feb 2020 09:23:47 +0000 (09:23 +0000)]
[AArch64] Peephole optimization: merge AND and TST instructions

In some cases Clang does not perform merging of instructions AND and TST (aka
ANDS xzr).

Example:

  tst x2, x1
  and x3, x2, x1

to:

  ands x3, x2, x1

This patch add such merging during instruction selection: when AND is replaced
with ANDS instruction in LowerSELECT_CC, all users of AND also should be
changed for using this ANDS instruction

Short discussion on mailing list:
http://llvm.1065342.n5.nabble.com/llvm-dev-ARM-Peephole-optimization-instructions-tst-add-tp133109.html

Patch by Pavel Kosov.

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

4 years ago[clangd] Get rid of lexer usage in AST.cpp
Kadir Cetinkaya [Wed, 26 Feb 2020 17:22:27 +0000 (18:22 +0100)]
[clangd] Get rid of lexer usage in AST.cpp

Reviewers: sammccall

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

Tags: #clang

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

4 years ago[libc] Add CMake script to check host cpu features
Guillaume Chatelet [Thu, 20 Feb 2020 14:00:45 +0000 (15:00 +0100)]
[libc] Add CMake script to check host cpu features

Summary:
Tested on MacOSX and Linux.
For robustness we can go the OpenCV way and add individual c++ files with intrinsics.
https://github.com/opencv/opencv/blob/master/cmake/checks/cpu_avx2.cpp

Reviewers: sivachandra, abrachet

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Tags: #libc-project

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

4 years ago[clangd] Get rid of getBeginningOfIdentifier helper
Kadir Cetinkaya [Wed, 26 Feb 2020 14:23:40 +0000 (15:23 +0100)]
[clangd] Get rid of getBeginningOfIdentifier helper

Reviewers: sammccall

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

Tags: #clang

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

4 years ago[MLIR] Add `take_back()` to STLExtras.h for completeness.
Alexander Belyaev [Wed, 26 Feb 2020 20:12:39 +0000 (21:12 +0100)]
[MLIR] Add `take_back()` to STLExtras.h for completeness.

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

4 years ago[libc] Add an optional `NAME` argument to `add_entrypoint_object` rule.
Siva Chandra Reddy [Fri, 21 Feb 2020 06:05:52 +0000 (22:05 -0800)]
[libc] Add an optional `NAME` argument to `add_entrypoint_object` rule.

This argument can be used to specify the entrypoint name if it is different
from the target name.

Reviewers: gchatelet, abrachet

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

4 years agoSome fixes for open breaks on MacOS and UBSan
ogiroux [Thu, 27 Feb 2020 00:49:37 +0000 (16:49 -0800)]
Some fixes for open breaks on MacOS and UBSan

4 years agoFix buildbot break after c46b85aaf4d4
Nemanja Ivanovic [Thu, 27 Feb 2020 03:56:11 +0000 (21:56 -0600)]
Fix buildbot break after c46b85aaf4d4

I added test cases that rely on the availability of the PPC target into
the general directory for the loop vectorizer. This causes failures on
bots that don't build the PPC target. Moving them to the PowerPC directory
to fix this.

4 years ago[LoopVectorize] Fix cost for calls to functions that have vector versions
Nemanja Ivanovic [Wed, 26 Feb 2020 23:13:14 +0000 (17:13 -0600)]
[LoopVectorize] Fix cost for calls to functions that have vector versions

A recent commit
(https://reviews.llvm.org/rG66c120f02560ef528a60924104ead66f330190f1) changed
the cost for calls to functions that have a vector version for some
vectorization factor. However, no check is performed for whether the
vectorization factor matches the current one being cost modeled. This leads to
attempts to widen call instructions to a vectorization factor for which such a
function does not exist, which in turn leads to an assertion failure.

This patch adds the check for vectorization factor (i.e. not just that the
called function has a vector version for some VF, but that it has a vector
version for this VF).

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

4 years agoAMDGPU/GlobalISel: Add missing test for G_UMULH
Matt Arsenault [Thu, 27 Feb 2020 03:29:33 +0000 (22:29 -0500)]
AMDGPU/GlobalISel: Add missing test for G_UMULH

4 years agoGlobalISel: Fix lowering for G_UADDE/G_USUBE
Matt Arsenault [Wed, 26 Feb 2020 22:21:10 +0000 (17:21 -0500)]
GlobalISel: Fix lowering for G_UADDE/G_USUBE

The type parameter passed into lower is invalid and should be removed
from the function.

4 years agoAMDGPU/GlobalISel: Add missing G_[US]ADDE/G_[US]SUBE tests
Matt Arsenault [Wed, 26 Feb 2020 22:12:54 +0000 (17:12 -0500)]
AMDGPU/GlobalISel: Add missing G_[US]ADDE/G_[US]SUBE tests

The s64 case currently crashes, so leave that for later.

4 years agoGlobalISel: Cleanup code with MachineIRBuilder features
Matt Arsenault [Wed, 26 Feb 2020 22:18:43 +0000 (17:18 -0500)]
GlobalISel: Cleanup code with MachineIRBuilder features

4 years ago[docs][LoopTerminology] Add Loop Simplify Form description.
Stefanos Baziotis [Thu, 27 Feb 2020 02:36:11 +0000 (20:36 -0600)]
[docs][LoopTerminology] Add Loop Simplify Form description.

Information taken from https://youtu.be/3pRhvQi7Z10?t=481 and
comments in LoopSimplify.h.

Reviewed By: Meinersbur

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

4 years ago[X86] Add test cases showing incorrect setting of nofpexcept flag due to CSE occuring...
Craig Topper [Thu, 27 Feb 2020 02:06:59 +0000 (18:06 -0800)]
[X86] Add test cases showing incorrect setting of nofpexcept flag due to CSE occuring during SelectionDAG creation.

These tests generate two nodes that are identical except for the
metadata that indicates their exception behavior. The nodes get
CSEd by SelectionDAG, but the nofpexcept flag is being set based
only on the fpexcept.ignore node being created last.

We need to detect this case and intersect the flags similar to
what is already done with fast math flags.

4 years ago[ELF][test] Rename SHF_LINK_ORDER related "metadata" to "linkorder"
Fangrui Song [Thu, 27 Feb 2020 00:24:58 +0000 (16:24 -0800)]
[ELF][test] Rename SHF_LINK_ORDER related "metadata" to "linkorder"

Test cleanups.

4 years agoCost Annotation Writer for InlineCost
Kirill Naumov [Wed, 26 Feb 2020 23:44:42 +0000 (15:44 -0800)]
Cost Annotation Writer for InlineCost

Add extra diagnostics for the inline cost analysis under
-print-instruction-deltas cl option. When enabled along with
-debug-only=inline-cost it prints the IR of inline candidate
annotated with cost and threshold change per every instruction.

Reviewed By: apilipenko, davidxl, mtrofin

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

4 years ago[X86] Add proper MachinePointerInfo to stack store created in LowerWin64_i128OP.
Craig Topper [Thu, 27 Feb 2020 00:54:38 +0000 (16:54 -0800)]
[X86] Add proper MachinePointerInfo to stack store created in LowerWin64_i128OP.

4 years ago[libc++] Workaround unused variable warning in test
Louis Dionne [Thu, 27 Feb 2020 00:29:49 +0000 (19:29 -0500)]
[libc++] Workaround unused variable warning in test

This only showed up in C++11/C++14 where the static_assert below was
ifdef'd out, and the variable was indeed unused.

4 years ago[X86] Explicitly pass Destination VT and debug location to BuildFILD. NFC
Craig Topper [Thu, 27 Feb 2020 00:16:03 +0000 (16:16 -0800)]
[X86] Explicitly pass Destination VT and debug location to BuildFILD. NFC

We'd already passed most everything else. Might was well pass
these two things and stop passing Op.

4 years ago[X86] Explicitly pass Pointer, MachinePointerInfo and Alignment to BuildFILD.
Craig Topper [Thu, 27 Feb 2020 00:02:32 +0000 (16:02 -0800)]
[X86] Explicitly pass Pointer, MachinePointerInfo and Alignment to BuildFILD.

Previously this code was called into two ways, either a FrameIndexSDNode
was passed in StackSlot. Or a load node was passed in the argument
called StackSlot. This was determined by a dyn_cast to FrameIndexSDNode.

In the case of a load, we had to go find the real pointer from
operand 0 and cast the node to MemSDNode to find the pointer info.

For the stack slot case, the code assumed that the stack slot
was perfectly aligned despite not being the creator of the slot.

This commit modifies the interface to make the caller responsible
for passing all of the required information to avoid all the
guess work and reverse engineering.

I'm not aware of any issues with the original code after an
earlier commit to fix the alignment of one of the stack objects.
This is just clean up to make the code less surprising.

4 years agoRevert "[libc++] Do not set the `availability=XXX` feature when not testing against...
Louis Dionne [Thu, 27 Feb 2020 00:14:34 +0000 (19:14 -0500)]
Revert "[libc++] Do not set the `availability=XXX` feature when not testing against a system libc++"

This reverts commit 7dd6a862e, which broke more tests than it fixed.

4 years ago[libc++] Temporarily disable availability markup for the C++20 Synchronization library
Louis Dionne [Thu, 27 Feb 2020 00:09:07 +0000 (19:09 -0500)]
[libc++] Temporarily disable availability markup for the C++20 Synchronization library

The markup wasn't quite right, and that broke compilation with availability
markup enabled. I'm disabling it until I have time to fix it properly to
get the CI mostly green again.

4 years agoPR44978: Accept as an extension some cases where destructor name lookup
Richard Smith [Wed, 26 Feb 2020 22:50:04 +0000 (14:50 -0800)]
PR44978: Accept as an extension some cases where destructor name lookup
is ambiguous, but only one of the possible lookup results could possibly
be right.

Clang recently started diagnosing ambiguity in more cases, and this
broke the build of Firefox. GCC, ICC, MSVC, and previous versions of
Clang all accept some forms of ambiguity here (albeit different ones in
each case); this patch mostly accepts anything any of those compilers
accept.

4 years agoDisable memory leak checking in a test to work around a bot failure
Erik Pilkington [Wed, 26 Feb 2020 22:47:02 +0000 (14:47 -0800)]
Disable memory leak checking in a test to work around a bot failure

This leak is expected, see the discussion on commit 85fb997

4 years agoVisit previously unreachable nodes in the debug info metadata verifier.
Adrian Prantl [Wed, 26 Feb 2020 22:12:30 +0000 (14:12 -0800)]
Visit previously unreachable nodes in the debug info metadata verifier.

This allows for diagnosing malformed LLVM IR debug info metadata such
as the one in the testcase.

<rdar://problem/59756060>

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

4 years ago[X86] Query constant pool object alignment instead of hardcoding.
Craig Topper [Wed, 26 Feb 2020 22:11:19 +0000 (14:11 -0800)]
[X86] Query constant pool object alignment instead of hardcoding.

4 years ago[X86] Use proper alignment for stack temporary and correct MachinePointerInfo for...
Craig Topper [Wed, 26 Feb 2020 22:10:50 +0000 (14:10 -0800)]
[X86] Use proper alignment for stack temporary and correct MachinePointerInfo for stack accesses in LowerUINT_TO_FP.

4 years ago[X86] Use correct MachineMemOperand for stack load in LowerFLT_ROUNDS_
Craig Topper [Wed, 26 Feb 2020 21:41:00 +0000 (13:41 -0800)]
[X86] Use correct MachineMemOperand for stack load in LowerFLT_ROUNDS_

4 years ago[X86] Add proper MachinePointerInfo to the loads/stores created for moving data betwe...
Craig Topper [Wed, 26 Feb 2020 19:46:40 +0000 (11:46 -0800)]
[X86] Add proper MachinePointerInfo to the loads/stores created for moving data between SSE and X87 in X86DAGToDAGISel::PreprocessISelDAG

4 years ago[ObjectFileMachO] Fix a build error on embedded.
Davide Italiano [Wed, 26 Feb 2020 22:31:06 +0000 (14:31 -0800)]
[ObjectFileMachO] Fix a build error on embedded.

4 years ago[AArch64][GlobalISel] Fixup <32b heterogeneous regbanks of G_PHIs just before selection.
Amara Emerson [Mon, 24 Feb 2020 22:27:32 +0000 (14:27 -0800)]
[AArch64][GlobalISel] Fixup <32b heterogeneous regbanks of G_PHIs just before selection.

Since all types <32b on gpr end up being assigned gpr32 regclasses, we can end
up with PHIs here which try to select between a gpr32 and an fpr16. Ideally RBS
shouldn't be selecting heterogenous regbanks for operands if possible, but we
still need to be able to deal with it here.

To fix this, if we have a gpr-bank operand < 32b in size and at least one other
operand is on the fpr bank, then we add cross-bank copies to homogenize the
operand banks. For simplicity the bank that we choose to settle on is whatever
bank the def operand has. For example:

%endbb:
  %dst:gpr(s16) = G_PHI %in1:gpr(s16), %bb1, %in2:fpr(s16), %bb2
 =>
%bb2:
  ...
  %in2_copy:gpr(s16) = COPY %in2:fpr(s16)
  ...
%endbb:
  %dst:gpr(s16) = G_PHI %in1:gpr(s16), %bb1, %in2_copy:gpr(s16), %bb2

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

4 years ago[ASTMatchers] HasNameMatcher handles `extern "C"`
Nathan James [Wed, 26 Feb 2020 22:06:38 +0000 (22:06 +0000)]
[ASTMatchers] HasNameMatcher handles `extern "C"`

Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=42193 | hasName AST matcher is confused by extern "C" in namespace. ]]

Reviewers: klimek, aaron.ballman, gribozavr2

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[DebugInfo][NFC] Remove handler with ErrorPolicy from DWARFContext.
Alexey Lapshin [Tue, 25 Feb 2020 15:45:42 +0000 (18:45 +0300)]
[DebugInfo][NFC] Remove handler with ErrorPolicy from DWARFContext.

Summary:
Current LLVM code base does not use error handler with ErrorPolicy.
This patch removes ErrorPolicy from DWARFContext.

This patch is extracted from the D74308.

Reviewers: jhenderson, dblaikie, grimar, aprantl, JDevlieghere

Reviewed By: grimar

Subscribers: hiraditya, llvm-commits

Tags: #llvm, #debug-info

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

4 years agoUpdate the ARC docs for non-trivial ownership in structs.
John McCall [Wed, 26 Feb 2020 21:40:46 +0000 (16:40 -0500)]
Update the ARC docs for non-trivial ownership in structs.

4 years ago[MC] Pull out a relaxFragment helper [NFC]
Philip Reames [Wed, 26 Feb 2020 21:29:07 +0000 (13:29 -0800)]
[MC] Pull out a relaxFragment helper [NFC]

Having this as it's own function helps to reduce indentation and allows use of return instead of wiring a value over the switch.  A lambda would have also worked, but with slightly deeper nesting.

4 years ago[llvm-objcopy] Enable --discard-all for MachO
Alexander Shaposhnikov [Wed, 26 Feb 2020 19:32:44 +0000 (11:32 -0800)]
[llvm-objcopy] Enable --discard-all for MachO

In this diff we enable the option --discard-all for MachO.

Test plan: make check-all

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

4 years ago[mlir][spirv] Refactoring to avoid calling the same function twice
Lei Zhang [Wed, 26 Feb 2020 20:35:46 +0000 (15:35 -0500)]
[mlir][spirv] Refactoring to avoid calling the same function twice

4 years ago[scudo][standalone] Various improvements wrt RSS
Kostya Kortchinsky [Tue, 25 Feb 2020 22:23:34 +0000 (14:23 -0800)]
[scudo][standalone] Various improvements wrt RSS

Summary:
This patch includes several changes to reduce the overall footprint
of the allocator:
- for realloc'd chunks: only keep the same chunk when lowering the size
  if the delta is within a page worth of bytes;
- when draining a cache: drain the beginning, not the end; we add pointers
  at the end, so that meant we were draining the most recently added
  pointers;
- change the release code to account for an freed up last page: when
  scanning the pages, we were looking for pages fully covered by blocks;
  in the event of the last page, if it's only partially covered, we
  wouldn't mark it as releasable - even what follows the last chunk is
  all 0s. So now mark the rest of the page as releasable, and adapt the
  test;
- add a missing `setReleaseToOsIntervalMs` to the cacheless secondary;
- adjust the Android classes based on more captures thanks to pcc@'s
  tool.

Reviewers: pcc, cferris, hctim, eugenis

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years ago[libc] Fix typo of namespace in round implementation.
Paula Toth [Wed, 26 Feb 2020 20:15:26 +0000 (12:15 -0800)]
[libc] Fix typo of namespace in round implementation.

Summary: Fixed typos in namespace declarations and comments in the files under `src/math/round`.

Reviewers: sivachandra, abrachet

Reviewed By: sivachandra, abrachet

Subscribers: MaskRay, tschuett, libc-commits

Tags: #libc-project

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

4 years agoFix for the test failues introduced in https://reviews.llvm.org/D74704.
Leonard Chan [Wed, 26 Feb 2020 20:23:15 +0000 (12:23 -0800)]
Fix for the test failues introduced in https://reviews.llvm.org/D74704.

4 years ago[dsymutil] Avoid copying swiftinterfaces from the SDK into the dsym bundle
Adrian Prantl [Wed, 26 Feb 2020 17:35:00 +0000 (09:35 -0800)]
[dsymutil] Avoid copying swiftinterfaces from the SDK into the dsym bundle

This patch fixes a bug that would cause dsymutil to collect
.swiftinterface files for the Swift stdlib and other SDK
modules. There is no advantage in copying these since they should be
loaded from the ones bundled with LLDB's embedded Swift compiler
instead and copying them will cause LLDB to recompile them from source
instead of loading their prebuilt cached counterparts in the SDK.

rdar://problem/57463247

Differential Revisions: https://reviews.llvm.org/D75196

4 years ago[ms] Rename ParsingInlineAsm functions/variables to reflect MS-specificity.
Eric Astor [Wed, 26 Feb 2020 20:12:52 +0000 (15:12 -0500)]
[ms] Rename ParsingInlineAsm functions/variables to reflect MS-specificity.

Summary: ParsingInlineAsm was a misleading name. These values are only set for MS-style inline assembly.

Reviewed By: rnk

Tags: #clang, #llvm

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

4 years ago[VectorCombine] add a debug flag to skip all transforms
Sanjay Patel [Wed, 26 Feb 2020 20:14:35 +0000 (15:14 -0500)]
[VectorCombine] add a debug flag to skip all transforms

As suggested in D75145 -

I'm not sure why, but several passes have this kind of disable/enable flag
implemented at the pass manager level. But that means we have to duplicate
the flag for both pass managers and add code to check the flag every time
the pass appears in the pipeline.

We want a debug option to see if this pass is misbehaving regardless of the
pass managers, so just add a disablement check at the single point before
any transforms run.

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

4 years ago[mlir][spirv] Add some folders for spv.LogicalAnd/spv.LogicalOr
Lei Zhang [Wed, 26 Feb 2020 17:47:02 +0000 (12:47 -0500)]
[mlir][spirv] Add some folders for spv.LogicalAnd/spv.LogicalOr

This commit handles folding spv.LogicalAnd/spv.LogicalOr when
one of the operands is constant true/false.

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

4 years ago[clang] fix error detection in consteval calls
Tyker [Wed, 26 Feb 2020 17:59:09 +0000 (18:59 +0100)]
[clang] fix error detection in consteval calls

Summary:
code like:
```
consteval int f() {
  int *A = new int(0);
  return *A;
}

int i1 = f();
```
currently doesn't generate any error.

Reviewers: rsmith

Reviewed By: rsmith

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

4 years ago[SimpleLoopUnswitch] Remove unnecessary include; NFC
Nikita Popov [Wed, 26 Feb 2020 19:40:43 +0000 (20:40 +0100)]
[SimpleLoopUnswitch] Remove unnecessary include; NFC

4 years ago[CVP] Simplify cmp of local phi node
Nikita Popov [Fri, 3 Jan 2020 17:40:18 +0000 (18:40 +0100)]
[CVP] Simplify cmp of local phi node

CVP currently does not simplify cmps with instructions in the same
block, because LVI getPredicateAt() currently does not provide
much useful information for that case (D69686 would change that,
but is stuck.) However, if the instruction is a Phi node, then
LVI can compute the result of the predicate by threading it into
the predecessor blocks, which allows it simplify some conditions
that nothing else can handle. Relevant code:
https://github.com/llvm/llvm-project/blob/6d6a4590c5d4c7fc7445d72fe685f966b0a8cafb/llvm/lib/Analysis/LazyValueInfo.cpp#L1904-L1927

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

4 years ago[TSan] Add CMake check for minimal SDK requirements on Darwin
Julian Lettner [Wed, 26 Feb 2020 18:33:18 +0000 (10:33 -0800)]
[TSan] Add CMake check for minimal SDK requirements on Darwin

Fails with the following message in the error case:
```
CMake Error at /path/to/llvm-project/compiler-rt/lib/tsan/CMakeLists.txt:119 (message):
  Building the TSan runtime requires at least macOS SDK 10.12
```

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

Reviewed By: dmajor, delcypher

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

4 years ago[InstCombine] Simplify DCE code; NFC
Nikita Popov [Wed, 26 Feb 2020 19:10:09 +0000 (20:10 +0100)]
[InstCombine] Simplify DCE code; NFC

As pointed out on D75008, MadeIRChange is already set by
eraseInstFromFunction(), which also already does a debug print.

4 years ago[CVP] Add test for cmp of local phi; NFC
Nikita Popov [Fri, 3 Jan 2020 17:39:20 +0000 (18:39 +0100)]
[CVP] Add test for cmp of local phi; NFC

4 years ago[AVR] Fix private label prefix
Ayke van Laethem [Tue, 25 Feb 2020 16:15:34 +0000 (17:15 +0100)]
[AVR] Fix private label prefix

This is a small pet peeve from me. This change makes sure the AVR backend uses
the correct private label prefix (.L) so that private labels are hidden in
avr-objdump.

Example code:

    define i8 @foo(i1 %cond) {
      br i1 %cond, label %then, label %else
    then:
      ret i8 3
    else:
      ret i8 5
    }

When compiling this:
  llc -march=avr -filetype=obj -o test.o test.ll
and then dumping it:
  avr-objdump -d test.o
You would previously get an ugly temporary label:

    00000000 <foo>:
       0:        81 70       andi       r24, 0x01    ; 1
       2:        80 30       cpi        r24, 0x00    ; 0
       4:        f9 f3       breq       .-2          ; 0x4 <foo+0x4>
       6:        83 e0       ldi        r24, 0x03    ; 3
       8:        08 95       ret

    0000000a <LBB0_2>:
       a:        85 e0       ldi        r24, 0x05    ; 5
       c:        08 95       ret

This patch fixes that, the output is now:

    00000000 <foo>:
       0:        81 70       andi       r24, 0x01    ; 1
       2:        80 30       cpi        r24, 0x00    ; 0
       4:        01 f0       breq       .+0          ; 0x6 <foo+0x6>
       6:        83 e0       ldi        r24, 0x03    ; 3
       8:        08 95       ret
       a:        85 e0       ldi        r24, 0x05    ; 5
       c:        08 95       ret

Note that as you can see the breq operand is different. However it is
still the same after linking:

       4:        11 f0       breq       .+4

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

4 years ago[AVR] Don't adjust addresses by 2 for absolute values
Ayke van Laethem [Fri, 7 Feb 2020 12:06:40 +0000 (13:06 +0100)]
[AVR] Don't adjust addresses by 2 for absolute values

Adjusting by 2 breaks DWARF output. With this fix, programs start to
compile and produce valid DWARF output.

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

4 years ago[InstCombine] Remove trivially empty ranges from end
Nikita Popov [Sat, 22 Feb 2020 17:37:10 +0000 (18:37 +0100)]
[InstCombine] Remove trivially empty ranges from end

InstCombine removes pairs of start+end intrinsics that don't
have anything in between them. Currently this is done by starting
at the start intrinsic and scanning forwards. This patch changes
it to start at the end intrinsic and scan backwards.

The motivation here is as follows: When we process the start
intrinsic, we have not yet looked at the following instructions,
which may still get folded/removed. If they do, we will only be
able to remove the start/end pair on the next iteration. When we
process the end intrinsic, all the instructions before it have
already been visited, and we don't run into this problem.

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

4 years agoFix LLP64 detection in SwapByteOrder.h
Reid Kleckner [Wed, 26 Feb 2020 18:41:59 +0000 (10:41 -0800)]
Fix LLP64 detection in SwapByteOrder.h

MSVC does not define __LONG_MAX__, so we were just getting lucky in this
conditional:
  #if __LONG_MAX__ == __INT_MAX__

Undefined identifiers evaluate to zero in preprocessor conditionals, so
this became true, which happens to work for MSVC platforms.

Instead, use this pattern and let the compiler constant fold:
  return sizeof(long) == sizeof(int) ? SwapByteOrder_32((uint32_t)C)
                                     : SwapByteOrder_64((uint64_t)C);