platform/upstream/llvm.git
5 years ago[InstCombine] Support ssub.sat canonicalization for non-splats
Nikita Popov [Sat, 1 Dec 2018 10:58:34 +0000 (10:58 +0000)]
[InstCombine] Support ssub.sat canonicalization for non-splats

Extend ssub.sat(X, C) -> sadd.sat(X, -C) canonicalization to also
support non-splat vector constants. This is done by generalizing
the implementation of the isNotMinSignedValue() helper to return
true for constants that are non-splat, but don't contain any
signed min elements.

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

llvm-svn: 348072

5 years agoCorrect indentation.
Bill Wendling [Sat, 1 Dec 2018 09:06:26 +0000 (09:06 +0000)]
Correct indentation.

llvm-svn: 348071

5 years agoSpecify constant context in constant emitter
Bill Wendling [Sat, 1 Dec 2018 08:29:36 +0000 (08:29 +0000)]
Specify constant context in constant emitter

The constant emitter may need to evaluate the expression in a constant context.
For exasmple, global initializer lists.

llvm-svn: 348070

5 years ago[X86] Remove stale FIXME from test case. NFC
Craig Topper [Sat, 1 Dec 2018 07:45:36 +0000 (07:45 +0000)]
[X86] Remove stale FIXME from test case. NFC

This was fixed in r346581. I just forgot to remove it.

llvm-svn: 348069

5 years ago[ThinLTO] Allow importing of functions with var args
Teresa Johnson [Sat, 1 Dec 2018 05:11:46 +0000 (05:11 +0000)]
[ThinLTO] Allow importing of functions with var args

Summary:
Follow up to D54270, which allowed importing of var args functions
unless they called va_start. As pointed out in the post-commit comments
on that patch, the inliner can handle functions that call va_start in
certain situations as well. Go ahead and enable importing of all var
args functions. Measurements on a large binary show that this increases
imports and binary size by an insignificant amount.

Reviewers: davidxl

Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, llvm-commits

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

llvm-svn: 348068

5 years ago[RISCV] Remove RV64I SLLW/SRLW/SRAW patterns and add new test cases
Alex Bradbury [Sat, 1 Dec 2018 05:00:00 +0000 (05:00 +0000)]
[RISCV] Remove RV64I SLLW/SRLW/SRAW patterns and add new test cases

As noted by Eli Friedman <https://reviews.llvm.org/D52977?id=168629#1315291>,
the RV64I shift patterns for SLLW/SRLW/SRAW make some incorrect assumptions.
SRAW assumed that (sext_inreg foo, i32) could only be produced when
sign-extended an i32. However, it can be produced by input such as:

define i64 @tricky_ashr(i64 %a, i64 %b) {
  %1 = shl i64 %a, 32
  %2 = ashr i64 %1, 32
  %3 = ashr i64 %2, %b
  ret i64 %3
}

It's important not to select sraw in the above case, because sraw only uses
bits lower 5 bits from the shift, while a shift of 32-63 would be valid.

Similarly, the patterns for srlw assumed (and foo, 0xffffffff) would only be
produced when zero-extending a value that was originally i32 in LLVM IR. This
is obviously incorrect.

This patch removes the SLLW/SRLW/SRAW shift patterns for the time being and
adds test cases that would demonstrate a miscompile if the incorrect patterns
were re-added.

llvm-svn: 348067

5 years ago[clangd] Recommit the "AnyScope" changes in requests.json by rCTE347753 (reverted...
Fangrui Song [Sat, 1 Dec 2018 01:57:15 +0000 (01:57 +0000)]
[clangd] Recommit the "AnyScope" changes in requests.json by rCTE347753 (reverted by rCTE347792)

This fixes IndexBenchmark tests.

llvm-svn: 348066

5 years ago[Basic] Move DiagnosticsEngine::dump from .h to .cpp
Fangrui Song [Sat, 1 Dec 2018 01:43:05 +0000 (01:43 +0000)]
[Basic] Move DiagnosticsEngine::dump from .h to .cpp

The two LLVM_DUMP_METHOD methods have a undefined reference on clang::DiagnosticsEngine::DiagStateMap::dump.

tools/clang/tools/extra/clangd/benchmarks/IndexBenchmark links in
clangDaemon but does not link in clangBasic explicitly, which causes a
linker error "undefined symbol" in !NDEBUG + -DBUILD_SHARED_LIBS=on builds.

Move LLVM_DUMP_METHOD methods to .cpp to fix IndexBenchmark. They should
be unconditionally defined as they are also used by non-dump-method #pragma clang __debug diag_mapping

llvm-svn: 348065

5 years ago[projects] Use add_llvm_external_project for implicit projects
Shoaib Meenai [Sat, 1 Dec 2018 01:41:27 +0000 (01:41 +0000)]
[projects] Use add_llvm_external_project for implicit projects

This allows disabling implicit projects via the LLVM_TOOL_*_BUILD
variables, similar to how implicit tools can be disabled. They'll still
be enabled by default, since add_llvm_external_project defaults the
LLVM_TOOL_*_BUILD variables to ON for in-tree implciit projects.

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

llvm-svn: 348064

5 years ago[X86][LoopVectorize] Replace -mcpu=skylake-avx512 with -mattr=avx512f in some tests...
Craig Topper [Sat, 1 Dec 2018 01:38:44 +0000 (01:38 +0000)]
[X86][LoopVectorize] Replace -mcpu=skylake-avx512 with -mattr=avx512f in some tests that failed when experimenting with defaulting to -mprefer-vector-width=256 for skylake-avx512.

llvm-svn: 348063

5 years agoRelax test to also work on Windows.
Adrian Prantl [Sat, 1 Dec 2018 01:30:00 +0000 (01:30 +0000)]
Relax test to also work on Windows.

llvm-svn: 348062

5 years ago[compiler-rt] Use "ColumnLimit: 0" instead of "clang-format off" in tests
Vitaly Buka [Sat, 1 Dec 2018 01:24:29 +0000 (01:24 +0000)]
[compiler-rt] Use "ColumnLimit: 0" instead of "clang-format off" in tests

Reviewers: eugenis, jfb

Subscribers: kubamracek, dberris, llvm-commits

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

llvm-svn: 348061

5 years agoHonor -fdebug-prefix-map when creating function names for the debug info.
Adrian Prantl [Sat, 1 Dec 2018 00:24:27 +0000 (00:24 +0000)]
Honor -fdebug-prefix-map when creating function names for the debug info.

This adds a callback to PrintingPolicy to allow CGDebugInfo to remap
file paths according to -fdebug-prefix-map. Otherwise the debug info
(particularly function names for C++ lambdas) may contain paths that
should have been remapped in the debug info.

<rdar://problem/46128056>

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

llvm-svn: 348060

5 years agoUse RequireNullTerminator=false in identify_magic.
Zachary Turner [Sat, 1 Dec 2018 00:22:39 +0000 (00:22 +0000)]
Use RequireNullTerminator=false in identify_magic.

identify_magic does not need the file to be null terminated.  Passing
true here causes the file reading code to decide not to use mmap in
some rare cases (which happen to be true 100% of the time in PDB files)
which can lead to very large files failing to load.  Since it was
probably just an accident that we were passing true here (since it is
the default function parameter), this should be strictly an improvement.

llvm-svn: 348059

5 years ago[lit] Add a generic build script with a lit substitution.
Zachary Turner [Sat, 1 Dec 2018 00:22:21 +0000 (00:22 +0000)]
[lit] Add a generic build script with a lit substitution.

This adds a script called build.py as well as a lit substitution
called %build that we can use to invoke it.  The idea is that
this allows a lit test to build test inferiors without having
to worry about architecture / platform specific differences,
command line syntax, finding / configurationg a proper toolchain,
and other issues.  They can simply write something like:

%build --arch=32 -o %t.exe %p/Inputs/foo.cpp

and it will just work.  This paves the way for being able to
run lit tests with multiple configurations, platforms, and
compilers with a single test.

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

llvm-svn: 348058

5 years ago[NVPTX] Add lowering of i128 numbers as struct fields
Artem Belevich [Sat, 1 Dec 2018 00:21:52 +0000 (00:21 +0000)]
[NVPTX] Add lowering of i128 numbers as struct fields

Addition to D34555 - override VTs computation with ComputePTXValueVTs
for struct fields.

Author: Denys Zariaiev<denys.zariaiev@gmail.com>

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

llvm-svn: 348057

5 years ago[X86] Replace '-mcpu=skx' with -mattr=avx512f or -mattr=avx512bw in interleave/stride...
Craig Topper [Sat, 1 Dec 2018 00:21:49 +0000 (00:21 +0000)]
[X86] Replace '-mcpu=skx' with -mattr=avx512f or -mattr=avx512bw in interleave/strided load/store cost model tests.

llvm-svn: 348056

5 years ago[windows] Fix two minor bugs on Windows
Stella Stamenova [Sat, 1 Dec 2018 00:18:19 +0000 (00:18 +0000)]
[windows] Fix two minor bugs on Windows

1. In ProcessWindows if we fail to allocate memory, we need to return LLDB_INVALID_ADDRESS rather than 0 or nullptr as that is the invalid address that LLDB looks for
2. In RegisterContextWindows in ReadAllRegisterValues, always create a new buffer. This is what the other platforms do and data_sp is always null in all tested scenarios on Windows as well

llvm-svn: 348055

5 years ago[gn build] Add action to generate VCSRevision.h and use it to add llvm/lib/Object...
Nico Weber [Sat, 1 Dec 2018 00:02:39 +0000 (00:02 +0000)]
[gn build] Add action to generate VCSRevision.h and use it to add llvm/lib/Object/BUILD.gn

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

llvm-svn: 348054

5 years agoRevert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures.""
Fangrui Song [Fri, 30 Nov 2018 23:41:18 +0000 (23:41 +0000)]
Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures.""

It seems the two failing tests can be simply fixed after r348037

Fix 3 cases in Analysis/builtin-functions.cpp
Delete the bad CodeGen/builtin-constant-p.c for now

llvm-svn: 348053

5 years ago[codeview] Remove dead macros for codeview record serialization, NFC
Reid Kleckner [Fri, 30 Nov 2018 23:32:11 +0000 (23:32 +0000)]
[codeview] Remove dead macros for codeview record serialization, NFC

These weren't needed when we went to the yaml IO style of serialization,
which has "mapOptional".

llvm-svn: 348052

5 years agoLegacyDivergenceAnalysis: fix uninitialized value
Nicolai Haehnle [Fri, 30 Nov 2018 23:07:49 +0000 (23:07 +0000)]
LegacyDivergenceAnalysis: fix uninitialized value

Change-Id: I014502e431a68f7beddf169f6a3d19dac5dd2c26
llvm-svn: 348051

5 years agoAMDGPU: Divergence-driven selection of scalar buffer load intrinsics
Nicolai Haehnle [Fri, 30 Nov 2018 22:55:38 +0000 (22:55 +0000)]
AMDGPU: Divergence-driven selection of scalar buffer load intrinsics

Summary:
Moving SMRD to VMEM in SIFixSGPRCopies is rather bad for performance if
the load is really uniform. So select the scalar load intrinsics directly
to either VMEM or SMRD buffer loads based on divergence analysis.

If an offset happens to end up in a VGPR -- either because a floating
point calculation was involved, or due to other remaining deficiencies
in SIFixSGPRCopies -- we use v_readfirstlane.

There is some unrelated churn in tests since we now select MUBUF offsets
in a unified way with non-scalar buffer loads.

Change-Id: I170e6816323beb1348677b358c9d380865cd1a19

Reviewers: arsenm, alex-t, rampitec, tpr

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

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

llvm-svn: 348050

5 years agoAMDGPU: Fix various issues around the VirtReg2Value mapping
Nicolai Haehnle [Fri, 30 Nov 2018 22:55:29 +0000 (22:55 +0000)]
AMDGPU: Fix various issues around the VirtReg2Value mapping

Summary:
The VirtReg2Value mapping is crucial for getting consistently
reliable divergence information into the SelectionDAG. This
patch fixes a bunch of issues that lead to incorrect divergence
info and introduces tight assertions to ensure we don't regress:

1. VirtReg2Value is generated lazily; there were some cases where
   a lookup was performed before all relevant virtual registers were
   created, leading to an out-of-sync mapping. Those cases were:

  - Complex code to lower formal arguments that generated CopyFromReg
    nodes from live-in registers (fixed by never querying the mapping
    for live-in registers).

  - Code that generates CopyToReg for formal arguments that are used
    outside the entry basic block (fixed by never querying the
    mapping for Register nodes, which don't need the divergence info
    anyway).

2. For complex values that are lowered to a sequence of registers,
   all registers must be reflected in the VirtReg2Value mapping.

I am not adding any new tests, since I'm not actually aware of any
bugs that these problems are causing with trunk as-is. However,
I recently added a test case (in r346423) which fails when D53283 is
applied without this change. Also, the new assertions should provide
most of the effective test coverage.

There is one test change in sdwa-peephole.ll. The underlying issue
is that since the divergence info is now correct, the DAGISel will
select V_OR_B32 directly instead of S_OR_B32. This leads to an extra
COPY which affects the behavior of MachineLICM in a way that ends up
with the S_MOV_B32 with the constant in a different basic block than
the V_OR_B32, which is presumably what defeats the peephole.

Reviewers: alex-t, arsenm, rampitec

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

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

llvm-svn: 348049

5 years ago[DA] GPUDivergenceAnalysis for unstructured GPU kernels
Nicolai Haehnle [Fri, 30 Nov 2018 22:55:20 +0000 (22:55 +0000)]
[DA] GPUDivergenceAnalysis for unstructured GPU kernels

Summary:
This is patch #3 of the new DivergenceAnalysis

  <https://lists.llvm.org/pipermail/llvm-dev/2018-May/123606.html>

The GPUDivergenceAnalysis is intended to eventually supersede the existing
LegacyDivergenceAnalysis. The existing LegacyDivergenceAnalysis produces
incorrect results on unstructured Control-Flow Graphs:

  <https://bugs.llvm.org/show_bug.cgi?id=37185>

This patch adds the option -use-gpu-divergence-analysis to the
LegacyDivergenceAnalysis to turn it into a transparent wrapper for the
GPUDivergenceAnalysis.

Reviewers: nhaehnle

Reviewed By: nhaehnle

Subscribers: jholewinski, jvesely, jfb, llvm-commits, alex-t, sameerds, arsenm, nhaehnle

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

llvm-svn: 348048

5 years ago[x86] add tests for undef + partial undef constant folding; NFC
Sanjay Patel [Fri, 30 Nov 2018 22:54:33 +0000 (22:54 +0000)]
[x86] add tests for undef + partial undef constant folding; NFC

Keep this file sync'd with the instsimplify version (rL348045).

llvm-svn: 348047

5 years ago[X86] Split skylake-avx512 run lines in SLP vectorizer tests to cover -mprefer=vector...
Craig Topper [Fri, 30 Nov 2018 22:53:21 +0000 (22:53 +0000)]
[X86] Split skylake-avx512 run lines in SLP vectorizer tests to cover -mprefer=vector-width=256 and -mprefer-vector-width=512.

This will make these tests immune if we ever change the default behavior of -march=skylake-avx512 to prefer 256 bit vectors.

llvm-svn: 348046

5 years ago[InstSimplify] add tests for undef + partial undef constant folding; NFC
Sanjay Patel [Fri, 30 Nov 2018 22:51:34 +0000 (22:51 +0000)]
[InstSimplify] add tests for undef + partial undef constant folding; NFC

These tests should probably go under a separate test file because they
should fold with just -constprop, but they're similar to the scalar
tests already in here.

llvm-svn: 348045

5 years ago[analyzer] Deleting unnecessary test file
Kristof Umann [Fri, 30 Nov 2018 22:32:17 +0000 (22:32 +0000)]
[analyzer] Deleting unnecessary test file

That I really should've done in rC348031.

llvm-svn: 348044

5 years ago[ValueTracking] Make unit tests easier to write; NFC
Nikita Popov [Fri, 30 Nov 2018 22:22:30 +0000 (22:22 +0000)]
[ValueTracking] Make unit tests easier to write; NFC

Generalize the existing MatchSelectPatternTest class to also work
with other types of tests. This reduces the amount of boilerplate
necessary to write ValueTracking tests in general, and computeKnownBits
tests in particular.

The inherited convention is that the function must be @test and the
tested instruction %A.

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

llvm-svn: 348043

5 years agoSupport: use std::is_trivially_copyable on MSVC
Saleem Abdulrasool [Fri, 30 Nov 2018 22:13:42 +0000 (22:13 +0000)]
Support: use std::is_trivially_copyable on MSVC

MSVC 2015 and newer have std::is_trivially_copyable available for use.
We should prefer that over the std::is_class to get this check be
correct.

llvm-svn: 348042

5 years agoAdd myself as code owner for OpenBSD driver
Brad Smith [Fri, 30 Nov 2018 21:42:34 +0000 (21:42 +0000)]
Add myself as code owner for OpenBSD driver

llvm-svn: 348041

5 years agoAdd a test to verify that lldb can load a kext binary.
Jason Molenda [Fri, 30 Nov 2018 21:33:00 +0000 (21:33 +0000)]
Add a test to verify that lldb can load a kext binary.

<rdar://problem/46356062>

llvm-svn: 348040

5 years agoRevert r347417 "Re-Reinstate 347294 with a fix for the failures."
Fangrui Song [Fri, 30 Nov 2018 21:26:09 +0000 (21:26 +0000)]
Revert r347417 "Re-Reinstate 347294 with a fix for the failures."

Kept the "indirect_builtin_constant_p" test case in test/SemaCXX/constant-expression-cxx1y.cpp
while we are investigating why the following snippet fails:

  extern char extern_var;
  struct { int a; } a = {__builtin_constant_p(extern_var)};

llvm-svn: 348039

5 years ago[analyzer] Emit an error for invalid -analyzer-config inputs
Kristof Umann [Fri, 30 Nov 2018 21:24:31 +0000 (21:24 +0000)]
[analyzer] Emit an error for invalid -analyzer-config inputs

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

llvm-svn: 348038

5 years ago[ExprConstant] Try fixing __builtin_constant_p after D54355 (rC347417)
Fangrui Song [Fri, 30 Nov 2018 21:15:41 +0000 (21:15 +0000)]
[ExprConstant] Try fixing __builtin_constant_p after D54355 (rC347417)

Summary:
Reinstate the original behavior (Success(false, E)) before D54355 when this branch is
taken. This fixes spurious error of the following snippet:

  extern char extern_var;
  struct { int a; } a = {__builtin_constant_p(extern_var)};

llvm-svn: 348037

5 years ago[MachineOutliner] Outline both register save calls + no LR save calls together
Jessica Paquette [Fri, 30 Nov 2018 21:14:58 +0000 (21:14 +0000)]
[MachineOutliner] Outline both register save calls + no LR save calls together

Instead of treating the outlined functions for these as distinct frames, they
should be combined into one case. Neither allows for stack fixups, and both
generate the same frame. Thus, they ought to be considered one case.

This makes the code far easier to understand, for one thing. It also offers
some small code size improvements. It's fairly rare to see a class of outlined
functions that doesn't fall entirely into one variant (on CTMark anyway). It
does happen from time to time though.

This mostly offers some serious simplification.

Also update the test to show the added functionality.

llvm-svn: 348036

5 years agoAArch64: Don't emit CFI for SCS register in nounwind functions.
Peter Collingbourne [Fri, 30 Nov 2018 21:04:25 +0000 (21:04 +0000)]
AArch64: Don't emit CFI for SCS register in nounwind functions.

All that you can legitimately do with the CFI for a nounwind function
is get a backtrace, and adjusting the SCS register is not (currently)
required for this purpose.

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

llvm-svn: 348035

5 years ago[TableGen] Fix negation of simple predicates
Evandro Menezes [Fri, 30 Nov 2018 21:03:24 +0000 (21:03 +0000)]
[TableGen] Fix negation of simple predicates

Simple predicates, such as those defined by `CheckRegOperandSimple` or
`CheckImmOperandSimple`, were not being negated when used with `CheckNot`.

This change fixes this issue by defining the previously declared methods to
handle simple predicates.

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

llvm-svn: 348034

5 years agoAdding tests for -ast-dump; NFC.
Aaron Ballman [Fri, 30 Nov 2018 20:55:26 +0000 (20:55 +0000)]
Adding tests for -ast-dump; NFC.

This adds tests for struct and union declarations in C. It also points out a bug when dumping anonymous record types -- they are sometimes reported as being contained by something of the wrong tag type. e.g., an anonymous struct inside of a union named X reports the anonymous struct as being inside of 'struct X' rather than 'union X'.

llvm-svn: 348033

5 years agoRevert r348029. I was git-ing and jumped the gun.
Bill Wendling [Fri, 30 Nov 2018 20:44:11 +0000 (20:44 +0000)]
Revert r348029. I was git-ing and jumped the gun.

llvm-svn: 348032

5 years ago[analyzer] Evaluate all non-checker config options before analysis
Kristof Umann [Fri, 30 Nov 2018 20:44:00 +0000 (20:44 +0000)]
[analyzer] Evaluate all non-checker config options before analysis

In earlier patches regarding AnalyzerOptions, a lot of effort went into
gathering all config options, and changing the interface so that potential
misuse can be eliminited.

Up until this point, AnalyzerOptions only evaluated an option when it was
querried. For example, if we had a "-no-false-positives" flag, AnalyzerOptions
would store an Optional field for it that would be None up until somewhere in
the code until the flag's getter function is called.

However, now that we're confident that we've gathered all configs, we can
evaluate off of them before analysis, so we can emit a error on invalid input
even if that prticular flag will not matter in that particular run of the
analyzer. Another very big benefit of this is that debug.ConfigDumper will now
show the value of all configs every single time.

Also, almost all options related class have a similar interface, so uniformity
is also a benefit.

The implementation for errors on invalid input will be commited shorty.

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

llvm-svn: 348031

5 years agoRevert "Reverting r347949-r347951 because they broke the test bots."
George Karpenkov [Fri, 30 Nov 2018 20:43:42 +0000 (20:43 +0000)]
Revert "Reverting r347949-r347951 because they broke the test bots."

This reverts commit 5bad6129c012fbf186eb055be49344e790448ecc.

Hopefully fixing the issue which was breaking the bots.

llvm-svn: 348030

5 years agoWe're in a constant context in the ConstantEmitter.
Bill Wendling [Fri, 30 Nov 2018 20:40:06 +0000 (20:40 +0000)]
We're in a constant context in the ConstantEmitter.

llvm-svn: 348029

5 years agoExpect mixed path separators in FileManagerTest when resolving paths on Win32
Matthew Voss [Fri, 30 Nov 2018 19:52:50 +0000 (19:52 +0000)]
Expect mixed path separators in FileManagerTest when resolving paths on Win32

llvm-svn: 348028

5 years agoAdd a new interceptor for getvfsstat(2) from NetBSD
Kamil Rytarowski [Fri, 30 Nov 2018 19:43:53 +0000 (19:43 +0000)]
Add a new interceptor for getvfsstat(2) from NetBSD

Summary:
getvfsstat - gets list of all mounted file systems.

Add a dedicated test.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits, mgorny, #sanitizers

Tags: #sanitizers

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

llvm-svn: 348027

5 years agoRevert an inadvertent change from r348020.
Aaron Ballman [Fri, 30 Nov 2018 19:32:35 +0000 (19:32 +0000)]
Revert an inadvertent change from r348020.

llvm-svn: 348026

5 years ago[analyzer][PlistMacroExpansion] Part 5.: Support for # and ##
Kristof Umann [Fri, 30 Nov 2018 19:21:35 +0000 (19:21 +0000)]
[analyzer][PlistMacroExpansion] Part 5.: Support for # and ##

From what I can see, this should be the last patch needed to replicate macro
argument expansions.

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

llvm-svn: 348025

5 years ago[Mem2Reg] Fix nondeterministic corner case
Joseph Tremoulet [Fri, 30 Nov 2018 19:20:02 +0000 (19:20 +0000)]
[Mem2Reg] Fix nondeterministic corner case

Summary:
When mem2reg inserts phi nodes in blocks with unreachable predecessors,
it adds undef operands for those incoming edges.  When there are
multiple such predecessors, the order is currently based on the address
of the BasicBlocks.  This change fixes that by using the BBNumbers in
the sort/search predicates, as is done elsewhere in mem2reg to ensure
determinism.

Also adds a testcase with a bunch of unreachable preds, which
(nodeterministically) fails without the fix.

Reviewers: majnemer

Reviewed By: majnemer

Subscribers: mgrang, llvm-commits

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

llvm-svn: 348024

5 years agoUpdating this test, which changed after the reverts from r348020.
Aaron Ballman [Fri, 30 Nov 2018 19:15:07 +0000 (19:15 +0000)]
Updating this test, which changed after the reverts from r348020.

llvm-svn: 348023

5 years ago[DWARFv5] Verify all-or-nothing constraint on DIFile source
Scott Linder [Fri, 30 Nov 2018 19:13:38 +0000 (19:13 +0000)]
[DWARFv5] Verify all-or-nothing constraint on DIFile source

Update IR verifier to check the constraint that DIFile source is present on all
files or no files.

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

llvm-svn: 348022

5 years ago[dsymutil] Gather global and local symbol addresses in the main executable.
Jonas Devlieghere [Fri, 30 Nov 2018 18:56:10 +0000 (18:56 +0000)]
[dsymutil] Gather global and local symbol addresses in the main executable.

Usually local symbols will have their address described in the debug
map. Global symbols have to have their address looked up in the symbol
table of the main executable. By playing with 'ld -r' and export lists,
you can get a symbol described as global by the debug map while actually
being a local symbol as far as the link in concerned. By gathering the
address of local symbols, we fix this issue.

Also, we prefer a global symbol in case of a name collision to preserve
the previous behavior.

Note that using the 'ld -r' tricks, people can actually cause symbol
names collisions that dsymutil has no way to figure out. This fixes the
simple case where there is only one symbol of a given name.

rdar://problem/32826621

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

llvm-svn: 348021

5 years agoReverting r347949-r347951 because they broke the test bots.
Aaron Ballman [Fri, 30 Nov 2018 18:52:51 +0000 (18:52 +0000)]
Reverting r347949-r347951 because they broke the test bots.

http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/440/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Aosobject-retain-release.cpp

llvm-svn: 348020

5 years ago[X86] Change vXi8 MULHU lowering to unpack high and low half of lanes instead of...
Craig Topper [Fri, 30 Nov 2018 18:43:18 +0000 (18:43 +0000)]
[X86] Change vXi8 MULHU lowering to unpack high and low half of lanes instead of extracting and concating low and high half registers.

This reduces the number of shuffle operations that need to be done. The splitting strategy requires the shuffle unit for the extraction and the extension. With the unpack strategy the unpacks accomplish a splitting and extending in one operation.

llvm-svn: 348019

5 years ago[X86] Prefer lowerVectorShuffleAsBitMask over using a avx512 masked operation when...
Craig Topper [Fri, 30 Nov 2018 18:43:15 +0000 (18:43 +0000)]
[X86] Prefer lowerVectorShuffleAsBitMask over using a avx512 masked operation when avx512bw/avx512vl is enabled.

This does require a constant pool load instead of loading an immediate into a gpr, moving to a k register and masking. But its less instructions and more consistent with previous ISAs. It probably opens up more combine opportunities as one of the test cases demonstrates.

llvm-svn: 348018

5 years agoMove AST tests into their own test directory; NFC.
Aaron Ballman [Fri, 30 Nov 2018 18:43:02 +0000 (18:43 +0000)]
Move AST tests into their own test directory; NFC.

This moves everything primarily testing the functionality of -ast-dump and -ast-print into their own directory, rather than leaving the tests spread around the testing directory.

llvm-svn: 348017

5 years ago[SelectionDAG] fold FP binops with 2 undef operands to undef
Sanjay Patel [Fri, 30 Nov 2018 18:38:52 +0000 (18:38 +0000)]
[SelectionDAG] fold FP binops with 2 undef operands to undef

llvm-svn: 348016

5 years ago[clang] Fix rL348006 for windows
Kadir Cetinkaya [Fri, 30 Nov 2018 18:36:31 +0000 (18:36 +0000)]
[clang] Fix rL348006 for windows

llvm-svn: 348015

5 years ago[AMDGPU] Disable SReg Global LD/ST, perf regression
Ron Lieberman [Fri, 30 Nov 2018 18:29:17 +0000 (18:29 +0000)]
[AMDGPU] Disable SReg Global LD/ST, perf regression

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

llvm-svn: 348014

5 years agoInline a function template that is used only once. NFC.
Rui Ueyama [Fri, 30 Nov 2018 18:19:15 +0000 (18:19 +0000)]
Inline a function template that is used only once. NFC.

llvm-svn: 348013

5 years agoSkip TestRequireHWBreakpoints on Windows
Jonas Devlieghere [Fri, 30 Nov 2018 17:31:20 +0000 (17:31 +0000)]
Skip TestRequireHWBreakpoints on Windows

The test assumes that HW breakpoints are not implemented by the debug
server. Windows doesn't use these and might actually support HW
breakpoints so these tests are expected fail because they don't raise
the expected error.

llvm-svn: 348010

5 years agoRevert "[PDB] Support PDB-backed expressions evaluation"
Stella Stamenova [Fri, 30 Nov 2018 17:29:54 +0000 (17:29 +0000)]
Revert "[PDB] Support PDB-backed expressions evaluation"

This reverts commit dec87759523b2f22fcff3325bc2cd543e4cda0e7.

This commit caused the tests on Windows to run forever rather than complete.
Reverting until the commit can be fixed to not stall.

llvm-svn: 348009

5 years agoAdding tests for -ast-dump; NFC.
Aaron Ballman [Fri, 30 Nov 2018 17:19:06 +0000 (17:19 +0000)]
Adding tests for -ast-dump; NFC.

This adds tests for GenericSelectionExpr; note that it points out a minor whitespace bug for selection expression cases.

llvm-svn: 348008

5 years ago[llvm-mca] Speedup the default resource selection strategy.
Andrea Di Biagio [Fri, 30 Nov 2018 17:15:52 +0000 (17:15 +0000)]
[llvm-mca] Speedup the default resource selection strategy.

This patch removes a (potentially) slow while loop in
DefaultResourceStrategy::select(). A better (and faster) approach is to do some
bit manipulation in order to shrink the range of candidate resources.
On a release build, this change gives an average speedup of ~10%.

llvm-svn: 348007

5 years ago[clang] Fill RealPathName for virtual files.
Kadir Cetinkaya [Fri, 30 Nov 2018 17:10:11 +0000 (17:10 +0000)]
[clang] Fill RealPathName for virtual files.

Summary:
Absolute path information for virtual files were missing even if we
have already stat'd the files. This patch puts that information for virtual
files that can succesffully be stat'd.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 348006

5 years ago[clangd] Populate include graph during static indexing action.
Kadir Cetinkaya [Fri, 30 Nov 2018 16:59:00 +0000 (16:59 +0000)]
[clangd] Populate include graph during static indexing action.

Summary:
This is the second part for introducing include hierarchy into index
files produced by clangd. You can see the base patch that introduces structures
and discusses the future of the patches in D54817

Reviewers: ilya-biryukov

Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 348005

5 years agoRevert "[BTF] Add BTF DebugInfo"
Yonghong Song [Fri, 30 Nov 2018 16:54:43 +0000 (16:54 +0000)]
Revert "[BTF] Add BTF DebugInfo"

This reverts commit 9c6b970db8bc63b28ce58a129bb1580a6a3c6caf.

llvm-svn: 348004

5 years ago[OPENMP][NVPTX]Make runtime compatible with the original runtime.
Alexey Bataev [Fri, 30 Nov 2018 16:52:38 +0000 (16:52 +0000)]
[OPENMP][NVPTX]Make runtime compatible with the original runtime.

Summary:
Reworked runtime to make it compatible with the requirements of the
original runtime library. Also, simplified some code to reduce number of
function calls.

Reviewers: gtbercea, kkwli0

Subscribers: guansong, jfb, caomhin, openmp-commits

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

llvm-svn: 348003

5 years ago[x86] add tests for fake vector FP ops; NFC
Sanjay Patel [Fri, 30 Nov 2018 16:50:08 +0000 (16:50 +0000)]
[x86] add tests for fake vector FP ops; NFC

llvm-svn: 348002

5 years ago[PDB] Quote linker arguments containing spaces (mimic MSVC)
Alexandre Ganea [Fri, 30 Nov 2018 16:36:40 +0000 (16:36 +0000)]
[PDB] Quote linker arguments containing spaces (mimic MSVC)

Initial patch by Will Wilson (@lantictac)

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

llvm-svn: 348001

5 years agoDo not assume .idata is zero-initialized.
Rui Ueyama [Fri, 30 Nov 2018 16:34:56 +0000 (16:34 +0000)]
Do not assume .idata is zero-initialized.

We initialize .text section with 0xcc (INT3 instruction), so we need to
explicitly write data even if it is zero if it can be in a .text section.
If you specify /merge:.rdata=.text, .rdata (which contains .idata) is put
to .text, so we need to do this.

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

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

llvm-svn: 348000

5 years ago[BTF] Add BTF DebugInfo
Yonghong Song [Fri, 30 Nov 2018 16:22:59 +0000 (16:22 +0000)]
[BTF] Add BTF DebugInfo

This patch adds BPF Debug Format (BTF) as a standalone
LLVM debuginfo. The BTF related sections are directly
generated from IR. The BTF debuginfo is generated
only when the compilation target is BPF.

What is BTF?
============

First, the BPF is a linux kernel virtual machine
and widely used for tracing, networking and security.
  https://www.kernel.org/doc/Documentation/networking/filter.txt
  https://cilium.readthedocs.io/en/v1.2/bpf/

BTF is the debug info format for BPF, introduced in the below
linux patch
  https://github.com/torvalds/linux/commit/69b693f0aefa0ed521e8bd02260523b5ae446ad7#diff-06fb1c8825f653d7e539058b72c83332
in the patch set mentioned in the below lwn article.
  https://lwn.net/Articles/752047/

The BTF format is specified in the above github commit.
In summary, its layout looks like
  struct btf_header
  type subsection (a list of types)
  string subsection (a list of strings)

With such information, the kernel and the user space is able to
pretty print a particular bpf map key/value. One possible example below:
  Withtout BTF:
    key: [ 0x01, 0x01, 0x00, 0x00 ]
  With BTF:
    key: struct t { a : 1; b : 1; c : 0}
  where struct is defined as
    struct t { char a; char b; short c; };

How BTF is generated?
=====================

Currently, the BTF is generated through pahole.
  https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=68645f7facc2eb69d0aeb2dd7d2f0cac0feb4d69
and available in pahole v1.12
  https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=4a21c5c8db0fcd2a279d067ecfb731596de822d4

Basically, the bpf program needs to be compiled with -g with
dwarf sections generated. The pahole is enhanced such that
a .BTF section can be generated based on dwarf. This format
of the .BTF section matches the format expected by
the kernel, so a bpf loader can just take the .BTF section
and load it into the kernel.
  https://github.com/torvalds/linux/commit/8a138aed4a807ceb143882fb23a423d524dcdb35

The .BTF section layout is also specified in this patch:
with file include/llvm/BinaryFormat/BTF.h.

What use cases this patch tries to address?
===========================================

Currently, only the bpf instruction stream is required to
pass to the kernel. The kernel verifies it, jits it if configured
to do so, attaches it to a particular kernel attachment point,
and later executes when a particular event happens.

This patch tries to expand BTF to support two more use cases below:
  (1). BPF supports subroutine calls.
       During performance analysis, it would be good to
       differentiate which call is hot instead of just
       providing a virtual address. This would require to
       pass a unique identifier for each subroutine to
       the kernel, the subroutine name is a natual choice.
  (2). If a particular jitted instruction is hot, we want
       user to know which source line this jitted instruction
       belongs to. This would require the source information
       is available to various profiling tools.

Note that in a single ELF file,
  . there may be multiple loadable bpf programs,
  . for a particular to-be-loaded bpf instruction stream,
    its instructions may come from multiple PROGBITS sections,
    the bpf loader needs to merge them together to a single
    consecutive insn stream before loading to the kernel.
For example:
  section .text: subroutines funcFoo
  section _progA: calling funcFoo
  section _progB: calling funcFoo
The bpf loader could construct two loadable bpf instruction
streams and load them into the kernel:
  . _progA funcFoo
  . _progB funcFoo
So per ELF section function offset and instruction offset
will need to be adjusted before passing to the kernel, and
the kernel essentially expect only one code section regardless
of how many in the ELF file.

What do we propose and Why?
===========================

To support the above two use cases, we propose to
add an additional section, .BTF.ext, to the ELF file
which is the input of the bpf loader. A different section
is preferred since loader may need to manipulate it before
loading part of its data to the kernel.

The .BTF.ext section has a similar header to the .BTF section
and it contains two subsections for func_info and line_info.
  . the func_info maps the func insn byte offset to a func
    type in the .BTF type subsection.
  . the line_info maps the insn byte offset to a line info.
  . both func_info and line_info subsections are organized
    by ELF PROGBITS AX sections.

pahole is not a good place to implement .BTF.ext as
pahole is mostly for structure hole information and more
importantly, we want to pass the actual code to the kernel.
  . bpf program typically is small so storage overhead
    should be small.
  . in bpf land, it is totally possible that
    an application loads the bpf program into the
    kernel and then that application quits, so
    holding debug info by the user space application
    is not practical as you may not even know who
    loads this bpf program.
  . having source codes directly kept by kernel
    would ease deployment since the original source
    code does not need ship on every hosts and
    kernel-devel package does not need to be
    deployed even if kernel headers are used.

LLVM is a good place to implement.
  . The only reliable time to get the source code is
    during compilation time. This will result in both more
    accurate information and easier deployment as
    stated in the above.
  . Another consideration is for JIT. The project like bcc
    (https://github.com/iovisor/bcc)
    use MCJIT to compile a C program into bpf insns and
    load them to the kernel. The llvm generated BTF sections
    will be readily available for such cases as well.

Design and implementation of emiting .BTF/.BTF.ext sections
===========================================================

The BTF debuginfo format is defined. Both .BTF and .BTF.ext
sections are generated directly from IR when both
"-target bpf" and "-g" are specified. Note that
dwarf sections are still generated as dwarf is used
by user space tools like llvm-objdump etc. for BPF target.

This patch also contains tests to verify generated
.BTF and .BTF.ext sections for all supported types, func_info
and line_info subsections. The patch is also tested
against linux kernel bpf sample tests and selftests.

Signed-off-by: Yonghong Song <yhs@fb.com>
Differential Revision: https://reviews.llvm.org/D53736

llvm-svn: 347999

5 years ago[CodeGen] Prefer static frame index for STATEPOINT liveness args
Than McIntosh [Fri, 30 Nov 2018 16:22:41 +0000 (16:22 +0000)]
[CodeGen] Prefer static frame index for STATEPOINT liveness args

Summary:
If a given liveness arg of STATEPOINT is at a fixed frame index
(e.g. a function argument passed on stack), prefer to use this
fixed location even the address is also in a register. If we use
the register it will generate a spill, which is not necessary
since the fixed frame index can be directly recorded in the stack
map.

Patch by Cherry Zhang <cherryyz@google.com>.

Reviewers: thanm, niravd, reames

Reviewed By: reames

Subscribers: cherryyz, reames, anna, arphaman, llvm-commits

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

llvm-svn: 347998

5 years ago[SLP]PR39774: Update references of the replaced external instructions.
Alexey Bataev [Fri, 30 Nov 2018 15:14:20 +0000 (15:14 +0000)]
[SLP]PR39774: Update references of the replaced external instructions.

Summary:
An additional fix for PR39774. Need to update the references for the
RedcutionRoot instruction when it is replaced during the vectorization
phase to avoid compiler crash on reduction vectorization.

Reviewers: RKSimon, spatel

Subscribers: llvm-commits

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

llvm-svn: 347997

5 years agoAdding tests for -ast-dump; NFC.
Aaron Ballman [Fri, 30 Nov 2018 15:11:16 +0000 (15:11 +0000)]
Adding tests for -ast-dump; NFC.

This adds tests for DeclStmt and demonstrates that we don't create such an AST node for global declarations currently.

llvm-svn: 347996

5 years ago[gn build] Add build files for llvm/lib/Bitcode/Reader and llvm/lib/MC/MCParser.
Nico Weber [Fri, 30 Nov 2018 14:49:46 +0000 (14:49 +0000)]
[gn build] Add build files for llvm/lib/Bitcode/Reader and llvm/lib/MC/MCParser.

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

llvm-svn: 347995

5 years agoAdding tests for -ast-dump; NFC.
Aaron Ballman [Fri, 30 Nov 2018 14:43:21 +0000 (14:43 +0000)]
Adding tests for -ast-dump; NFC.

This adds tests for the majority of the functionality around FunctionDecl and CXXMethodDecl.

llvm-svn: 347994

5 years ago[AMDGPU] Combine DPP mov with use instructions (VOP1/2/3)
Valery Pykhtin [Fri, 30 Nov 2018 14:21:56 +0000 (14:21 +0000)]
[AMDGPU] Combine DPP mov with use instructions (VOP1/2/3)

Introduces DPP pseudo instructions and the pass that combines DPP mov with subsequent uses.

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

llvm-svn: 347993

5 years agoTableGen/ISel: Allow PatFrag predicate code to access captured operands
Nicolai Haehnle [Fri, 30 Nov 2018 14:15:13 +0000 (14:15 +0000)]
TableGen/ISel: Allow PatFrag predicate code to access captured operands

Summary:
This simplifies writing predicates for pattern fragments that are
automatically re-associated or commuted.

For example, a followup patch adds patterns for fragments of the form
(add (shl $x, $y), $z) to the AMDGPU backend. Such patterns are
automatically commuted to (add $z, (shl $x, $y)), which makes it basically
impossible to refer to $x, $y, and $z generically in the PredicateCode.

With this change, the PredicateCode can refer to $x, $y, and $z simply
as `Operands[i]`.

Test confirmed that there are no changes to any of the generated files
when building all (non-experimental) targets.

Change-Id: I61c00ace7eed42c1d4edc4c5351174b56b77a79c

Reviewers: arsenm, rampitec, RKSimon, craig.topper, hfinkel, uweigand

Subscribers: wdng, tpr, llvm-commits

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

llvm-svn: 347992

5 years ago[RISCV] Add additional CSR instruction aliases (imm. operands)
Alex Bradbury [Fri, 30 Nov 2018 14:10:52 +0000 (14:10 +0000)]
[RISCV] Add additional CSR instruction aliases (imm. operands)

This patch adds CSR instructions aliases for the cases where the instruction
takes an immediate operand but the alias doesn't have the i suffix. This is
necessary for gas/gcc compatibility.

gas doesn't do a similar conversion for fsflags or fsrm, so this should be
complete.

Differential Revision: https://reviews.llvm.org/D55008
Patch by Luís Marques.

llvm-svn: 347991

5 years agoFix parenthesis warning in IVDescriptors
Renato Golin [Fri, 30 Nov 2018 13:54:36 +0000 (13:54 +0000)]
Fix parenthesis warning in IVDescriptors

llvm-svn: 347990

5 years agoAdd a new reduction pattern match
Renato Golin [Fri, 30 Nov 2018 13:40:10 +0000 (13:40 +0000)]
Add a new reduction pattern match

Adding a new reduction pattern match for vectorizing code similar
to TSVC s3111:

for (int i = 0; i < N; i++)
  if (a[i] > b)
    sum += a[i];

This patch adds support for fadd, fsub and fmull, as well as multiple
branches and different (but compatible) instructions (ex. add+sub) in
different branches.

The difference from the previous patch(https://reviews.llvm.org/D49168)
is as follows:
 - Added check of fast-math property of fp-instruction to the
   previous patch
 - Fix/add some pattern for if-reduction.ll

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

Patch by Takahiro Miyoshi <takahiro.miyoshi@linaro.org>
     and Masakazu Ueno <masakazu.ueno@linaro.org>

llvm-svn: 347989

5 years ago[RISCV] Add UNIMP instruction (32- and 16-bit forms)
Alex Bradbury [Fri, 30 Nov 2018 13:39:17 +0000 (13:39 +0000)]
[RISCV] Add UNIMP instruction (32- and 16-bit forms)

This patch adds support for UNIMP in both 32- and 16-bit forms. The 32-bit
form can be seen as a variant of the ECALL/EBREAK/etc. family of instructions.
The 16-bit form is just all zeroes, which isn't a valid RISC-V instruction,
but still follows the 16-bit instruction form (i.e. bits 0-1 != 11).

Until recently unimp was undocumented and supported just by binutils, which
printed unimp for either the 16 or 32-bit form. Both forms are now documented
<https://github.com/riscv/riscv-asm-manual/pull/20> and binutils now supports
c.unimp <https://sourceware.org/ml/binutils-cvs/2018-11/msg00179.html>.

Differential Revision: https://reviews.llvm.org/D54316
Patch by Luís Marques.

llvm-svn: 347988

5 years agoFix warning about unused variable [NFC]
Mikael Holmen [Fri, 30 Nov 2018 13:38:33 +0000 (13:38 +0000)]
Fix warning about unused variable [NFC]

llvm-svn: 347987

5 years ago[SelectionDAG] Support result type promotion for FLT_ROUNDS_
Alex Bradbury [Fri, 30 Nov 2018 13:18:33 +0000 (13:18 +0000)]
[SelectionDAG] Support result type promotion for FLT_ROUNDS_

For targets where i32 is not a legal type (e.g. 64-bit RISC-V),
LegalizeIntegerTypes must promote the result of ISD::FLT_ROUNDS_.

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

llvm-svn: 347986

5 years ago[llvm-mca] Simplify code in class Scheduler. NFCI
Andrea Di Biagio [Fri, 30 Nov 2018 12:49:30 +0000 (12:49 +0000)]
[llvm-mca] Simplify code in class Scheduler. NFCI

llvm-svn: 347985

5 years ago[clangd] Penalize destructor and overloaded operators in code completion.
Eric Liu [Fri, 30 Nov 2018 11:17:15 +0000 (11:17 +0000)]
[clangd] Penalize destructor and overloaded operators in code completion.

Reviewers: hokein

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

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

llvm-svn: 347983

5 years ago[clangd] Drop injected class name when class scope is not explicitly specified.
Eric Liu [Fri, 30 Nov 2018 11:12:40 +0000 (11:12 +0000)]
[clangd] Drop injected class name when class scope is not explicitly specified.

Summary: E.g. allow injected "A::A" in `using A::A^` but not in "A^".

Reviewers: kadircet

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

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

llvm-svn: 347982

5 years agolyzer] [HOTFIX!] SValBuilder crash when `aggressive-binary-operation-simplification...
Adam Balogh [Fri, 30 Nov 2018 10:37:44 +0000 (10:37 +0000)]
lyzer] [HOTFIX!] SValBuilder crash when `aggressive-binary-operation-simplification` enabled

During the review of D41938 a condition check with an early exit accidentally
slipped into a branch, leaving the other branch unprotected. This may result in
an assertion later on. This hotfix moves this contition check outside of the
branch.

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

llvm-svn: 347981

5 years ago[SelectionDAG] Support promotion of PREFETCH operands
Alex Bradbury [Fri, 30 Nov 2018 10:06:31 +0000 (10:06 +0000)]
[SelectionDAG] Support promotion of PREFETCH operands

For targets where i32 is not a legal type (e.g. 64-bit RISC-V),
LegalizeIntegerTypes must promote the operands of ISD::PREFETCH.

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

llvm-svn: 347980

5 years ago[LoopSimplifyCFG] Update MemorySSA in terminator folding. PR39783
Max Kazantsev [Fri, 30 Nov 2018 10:06:23 +0000 (10:06 +0000)]
[LoopSimplifyCFG] Update MemorySSA in terminator folding. PR39783

Terminator folding transform lacks MemorySSA update for memory Phis,
while they exist within MemorySSA analysis. They need exactly the same
type of updates as regular Phis. Failing to update them properly ends up
with inconsistent MemorySSA and manifests in various assertion failures.

This patch adds Memory Phi updates to this transform.

Thanks to @jonpa for finding this!

Differential Revision: https://reviews.llvm.org/D55050
Reviewed By: asbirlea

llvm-svn: 347979

5 years ago[SelectionDAG] Support promotion of FRAMEADDR/RETURNADDR operands
Alex Bradbury [Fri, 30 Nov 2018 10:02:06 +0000 (10:02 +0000)]
[SelectionDAG] Support promotion of FRAMEADDR/RETURNADDR operands

For targets where i32 is not a legal type (e.g. 64-bit RISC-V),
LegalizeIntegerTypes must promote the operand.

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

llvm-svn: 347978

5 years ago[TargetLowering][RISCV] Introduce isSExtCheaperThanZExt hook and implement for RISC-V
Alex Bradbury [Fri, 30 Nov 2018 09:56:54 +0000 (09:56 +0000)]
[TargetLowering][RISCV] Introduce isSExtCheaperThanZExt hook and implement for RISC-V

DAGTypeLegalizer::PromoteSetCCOperands currently prefers to zero-extend
operands when it is able to do so. For some targets this is more expensive
than a sign-extension, which is also a valid choice. Introduce the
isSExtCheaperThanZExt hook and use it in the new SExtOrZExtPromotedInteger
helper. On RISC-V, we prefer sign-extension for FromTy == MVT::i32 and ToTy ==
MVT::i64, as it can be performed using a single instruction.

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

llvm-svn: 347977

5 years ago[NFC] Simplify and reduce tests for PR39783
Max Kazantsev [Fri, 30 Nov 2018 09:51:25 +0000 (09:51 +0000)]
[NFC] Simplify and reduce tests for PR39783

llvm-svn: 347976

5 years ago[NativePDB] Fix ast-reconstruction test on x86
Aleksandr Urakov [Fri, 30 Nov 2018 09:50:11 +0000 (09:50 +0000)]
[NativePDB] Fix ast-reconstruction test on x86

Summary:
This patch fixes ast-reconstruction.cpp test on x86 platform.

Patch by: leonid.mashinskiy

Reviewers: zturner, stella.stamenova

Reviewed By: zturner

Subscribers: aleksandr.urakov, lldb-commits

Tags: #lldb

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

llvm-svn: 347975

5 years ago[Target] Do not skip a stop on a breakpoint if a plan was completed
Aleksandr Urakov [Fri, 30 Nov 2018 09:45:52 +0000 (09:45 +0000)]
[Target] Do not skip a stop on a breakpoint if a plan was completed

Summary:
This patch fixes the next situation. On Windows clang-cl makes no stub before
the main function, so the main function is located exactly on module entry
point. May be it is the same on other platforms. So consider the following
sequence:

- set a breakpoint on main and stop there;
- try to evaluate expression, which requires a code execution on the debuggee
  side. Such an execution always returns to the module entry, and the plan waits
  for it there;
- the plan understands that it is complete now and removes its breakpoint. But
  the breakpoint site is still there, because we also have a breakpoint on
  entry;
- StopInfo analyzes a situation. It sees that we have stopped on the breakpoint
  site, and it sees that the breakpoint site has owners, and no one logical
  breakpoint is internal (because the plan is already completed and it have
  removed its breakpoint);
- StopInfo thinks that it's a user breakpoint and skips it to avoid recursive
  computations;
- the program continues.

So in this situation the program continues without a stop right after
the expression evaluation. To avoid this an additional check that
the plan was completed was added.

Reviewers: jingham, zturner, boris.ulasevich

Reviewed by: jingham

Tags: #lldb

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

llvm-svn: 347974

5 years ago[RISCV] Introduce codegen patterns for instructions introduced in RV64I
Alex Bradbury [Fri, 30 Nov 2018 09:38:44 +0000 (09:38 +0000)]
[RISCV] Introduce codegen patterns for instructions introduced in RV64I

As discussed in the RFC
<http://lists.llvm.org/pipermail/llvm-dev/2018-October/126690.html>, 64-bit
RISC-V has i64 as the only legal integer type.  This patch introduces patterns
to support codegen of the new instructions
introduced in RV64I: addiw, addiw, subw, sllw, slliw, srlw, srliw, sraw,
sraiw, ld, sd.

Custom selection code is needed for srliw as SimplifyDemandedBits will remove
lower bits from the mask, meaning the obvious pattern won't work:

def : Pat<(sext_inreg (srl (and GPR:$rs1, 0xffffffff), uimm5:$shamt), i32),
          (SRLIW GPR:$rs1, uimm5:$shamt)>;
This is sufficient to compile and execute all of the GCC torture suite for
RV64I other than those files using frameaddr or returnaddr intrinsics
(LegalizeDAG doesn't know how to promote the operands - a future patch
addresses this).

When promoting i32 sltu/sltiu operands, it would be more efficient to use
sign-extension rather than zero-extension for RV64. A future patch adds a hook
to allow this.

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

llvm-svn: 347973

5 years ago[docs][AtomicExpandPass] Document the alternate lowering strategy for part-word atomi...
Alex Bradbury [Fri, 30 Nov 2018 09:23:24 +0000 (09:23 +0000)]
[docs][AtomicExpandPass] Document the alternate lowering strategy for part-word atomicrmw/cmpxchg

D47882, D48130 and D48131 introduce a new lowering strategy for part-word
atomicrmw/cmpxchg and uses it to lower these operations for the RISC-V target.
Rather than having AtomicExpandPass produce the LL/SC loop in the IR level, it
instead calculates the necessary mask values and inserts a target-specific
intrinsic, which is lowered at a much later stage (after register allocation).
This ensures that architecture-specific restrictions for forward-progress in
LL/SC loops can be guaranteed.

This patch documents this new AtomicExpandPass functionality. See the previous
llvm-dev RFC for more info
<http://lists.llvm.org/pipermail/llvm-dev/2018-June/123993.html>.

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

llvm-svn: 347971

5 years agoFix a use-after-scope bug.
Haojian Wu [Fri, 30 Nov 2018 09:23:01 +0000 (09:23 +0000)]
Fix a use-after-scope bug.

llvm-svn: 347970

5 years ago[clangd] Bump vscode-clangd v0.0.8
Haojian Wu [Fri, 30 Nov 2018 09:18:31 +0000 (09:18 +0000)]
[clangd] Bump vscode-clangd v0.0.8

llvm-svn: 347969