platform/upstream/llvm.git
4 years ago[RISCV] Handle variable sized objects with the stack need to be realigned
Shiva Chen [Tue, 15 Oct 2019 07:11:35 +0000 (15:11 +0800)]
[RISCV] Handle variable sized objects with the stack need to be realigned

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

4 years agoDebugInfo: Use loclistx for DWARFv5 location lists to reduce the number of relocations
David Blaikie [Tue, 12 Nov 2019 22:15:37 +0000 (14:15 -0800)]
DebugInfo: Use loclistx for DWARFv5 location lists to reduce the number of relocations

This only implements the non-dwo part, but loclistx is necessary to use
location lists in DWARFv5, so it's a precursor to that work - and
generally reduces relocations (only using one reloc, then
indexes/relative offsets for all location list references) in non-split
DWARF.

4 years ago[llvm-cov] Fix illegal cast from uint64_t to int64_t
Sajjad Mirza [Sat, 16 Nov 2019 02:09:53 +0000 (18:09 -0800)]
[llvm-cov] Fix illegal cast from uint64_t to int64_t

Summary:
Counters are stored as uint64_t in the coverage mapping, but
exporting in JSON requires signed integers. Clamp the values to the
smaller range to make the conversion safe.

Reviewers: Dor1s, vsk

Reviewed By: Dor1s

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[lldb-vscode] support the completion request
Walter Erquinigo [Wed, 30 Oct 2019 23:46:06 +0000 (16:46 -0700)]
[lldb-vscode] support the completion request

Summary:
The DAP has a completion request that has been unimplemented. It allows showing autocompletion tokens inside the Debug Console.
I implemented it in a very simple fashion mimicking what the user would see when autocompleting an expression inside the CLI.
There are two cases: normal variables and commands. The latter occurs when a text is prepepended with ` in the Debug Console.
These two cases work well and have tests.

Reviewers: clayborg, aadsm

Subscribers: lldb-commits

Tags: #lldb

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

4 years agoAvoid including Builtins.h in Preprocessor.h
Reid Kleckner [Sat, 16 Nov 2019 00:36:00 +0000 (16:36 -0800)]
Avoid including Builtins.h in Preprocessor.h

Builtins are rarely if ever accessed via the Preprocessor. They are
typically found on the ASTContext, so there should be no performance
penalty to using a pointer indirection to store the builtin context.

4 years agoFix -Wunused-result warnings in LLDB
Reid Kleckner [Thu, 14 Nov 2019 23:27:49 +0000 (15:27 -0800)]
Fix -Wunused-result warnings in LLDB

Three uses of try_lock intentionally ignore the result, as explained in
the comment. Make that explicit with a void cast.

Add what appears to be a missing return in the clang expression parser
code. It's a functional change, but presumably the right one.

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

4 years agoAdd a testcase for Clang modules being updated within one LLDB session.
Adrian Prantl [Sat, 16 Nov 2019 00:25:46 +0000 (16:25 -0800)]
Add a testcase for Clang modules being updated within one LLDB session.

This actually works as expected, but wasn't explicitly tested before.

4 years agoDebugInfo: Templatize rnglist header parsing to setup for reuse with loclist header...
David Blaikie [Fri, 15 Nov 2019 23:48:31 +0000 (15:48 -0800)]
DebugInfo: Templatize rnglist header parsing to setup for reuse with loclist header parsing

4 years ago[WebAssembly] Fix miscompile of select with and
Thomas Lively [Fri, 15 Nov 2019 23:30:48 +0000 (15:30 -0800)]
[WebAssembly] Fix miscompile of select with and

Summary:
Rolls back the remaining bad optimizations introduced in
eb15d00193f. Some of them were already rolled back in e661f946a7db and
this finishes the job.

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

Reviewers: dschuff, aheejin

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

Tags: #llvm

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

4 years ago[COFF] Don't error if the only inputs are from /wholearchive:
Reid Kleckner [Thu, 7 Nov 2019 21:50:31 +0000 (13:50 -0800)]
[COFF] Don't error if the only inputs are from /wholearchive:

Fixes PR43744

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

4 years agoDon't add optnone or noinline if the function is already marked as
Akira Hatanaka [Fri, 15 Nov 2019 23:27:56 +0000 (15:27 -0800)]
Don't add optnone or noinline if the function is already marked as
always_inline.

The assertion in SetLLVMFunctionAttributesForDefinition used to fail
when there was attribute OptimizeNone on the AST function and attribute
always_inline on the IR function. This happens because base destructors
are annotated with always_inline when the code is compiled with
-fapple-kext (see r124757).

rdar://problem/57169694

4 years agodotest: Add a way for the run_to_* helpers to register dylibs
Fred Riss [Fri, 8 Nov 2019 01:32:29 +0000 (17:32 -0800)]
dotest: Add a way for the run_to_* helpers to register dylibs

Summary:
To run the testsuite remotely the executable needs to be uploaded to
the target system. The Target takes care of this by default.

When the test uses additional shared libraries, those won't be handled
by default and need to be registered with the target using
test.registerSharedLibrariesWithTarget(target, dylib).

Calling this API requires a target, so it doesn't mesh well with the
run_to_* helpers that we've been advertising as the right way to write
tests.

This patch adds an extra_images argument to all the helpers and does
the registration automatically when running a remote
testsuite. TestWeakSymbols.py was converted to use this new scheme.

Reviewers: jingham

Subscribers: lldb-commits

Tags: #lldb

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

4 years ago[clang-tidy] Give readability-redundant-string-init a customizable list of string...
Mitchell Balan [Fri, 15 Nov 2019 23:09:27 +0000 (18:09 -0500)]
[clang-tidy] Give readability-redundant-string-init a customizable list of string types to fix

Summary:
This patch adds a feature requested in https://reviews.llvm.org/D69238 to enable `readability-redundant-string-init` to take a list of strings to apply the fix to rather than hard-coding `basic_string`. It adds a `StringNames` option of semicolon-delimited names of string classes to which to apply this fix. Tests ensure this works with test class out::TestString as well as std::string and std::wstring as before. It should be applicable to llvm::StringRef, QString, etc.

Note: This commit was previously reverted due to a failing unit test. That test has been fixed in this version.

Reviewers: MyDeveloperDay, aaron.ballman, hokein, alexfh, JonasToth, gribozavr2

Patch by: poelmanc

Subscribers: gribozavr2, xazax.hun, Eugene.Zelenko, cfe-commits

Tags: #clang-tools-extra, #clang

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

4 years ago[clang-tidy] Fix readability-redundant-string-init for c++17/c++2a
Mitchell Balan [Fri, 15 Nov 2019 22:00:32 +0000 (17:00 -0500)]
[clang-tidy] Fix readability-redundant-string-init for c++17/c++2a

Summary:
`readability-redundant-string-init` was one of several clang-tidy checks documented as failing for C++17. (The failure mode in C++17 is that it changes `std::string Name = ""`; to `std::string Name = Name;`, which actually compiles but crashes at run-time.)

Analyzing the AST with `clang -Xclang -ast-dump` showed that the outer `CXXConstructExprs` that previously held the correct SourceRange were being elided in C++17/2a, but the containing `VarDecl` expressions still had all the relevant information. So this patch changes the fix to get its source ranges from `VarDecl`.

It adds one test `std::string g = "u", h = "", i = "uuu", j = "", k;` to confirm proper warnings and fixit replacements in a single `DeclStmt` where some strings require replacement and others don't. The readability-redundant-string-init.cpp and readability-redundant-string-init-msvc.cpp tests now pass for C++11/14/17/2a.

Reviewers: gribozavr, etienneb, alexfh, hokein, aaron.ballman, gribozavr2

Patch by: poelmanc

Subscribers: NoQ, MyDeveloperDay, Eugene.Zelenko, dylanmckay, cfe-commits

Tags: #clang, #clang-tools-extra

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

4 years agoDon't use end-of-line comments for the DebugInfoKind enum, NFC
Reid Kleckner [Fri, 15 Nov 2019 22:06:23 +0000 (14:06 -0800)]
Don't use end-of-line comments for the DebugInfoKind enum, NFC

These are long comments, and I find the new structure easier to read.

4 years ago[GISel][CombinerHelper] Use uses() instead of operands() when traversing use operands.
Quentin Colombet [Fri, 15 Nov 2019 21:33:35 +0000 (13:33 -0800)]
[GISel][CombinerHelper] Use uses() instead of operands() when traversing use operands.

NFC

4 years ago[GISel][CombinerHelper] Add support for scalar type for the result of shuffle vector
Quentin Colombet [Fri, 15 Nov 2019 21:24:27 +0000 (13:24 -0800)]
[GISel][CombinerHelper] Add support for scalar type for the result of shuffle vector

LLVM IR of 1-element vectors get lower into scalar in GISel. As a
result, shuffle vector may also produce a scalar.

This patch teaches the shuffle combiner how to deal with scalars when
they are in the destination type of a shuffle vector.

For now, we just support the easy case where this can be lowered to
a plain copy. For other cases, we leave the shuffle vector as is.

This type of IR are seen in O0 pipelines. E.g., as produced with
SingleSource/UnitTests/Vector/AArch64/aarch64_neon_intrinsics.c.

rdar://problem/57198904

4 years agoRevert "[clang-tidy] Give readability-redundant-string-init a customizable list of...
Mitchell Balan [Fri, 15 Nov 2019 21:46:58 +0000 (16:46 -0500)]
Revert "[clang-tidy] Give readability-redundant-string-init a customizable list of string types to fix"

This reverts commit 96fbc32cb9ea23b1e7e3ff6906ec3ccda9500982.

4 years ago[clang-tidy] Give readability-redundant-string-init a customizable list of string...
Mitchell Balan [Fri, 15 Nov 2019 21:42:43 +0000 (16:42 -0500)]
[clang-tidy] Give readability-redundant-string-init a customizable list of string types to fix

Summary:
This patch adds a feature requested in https://reviews.llvm.org/D69238 to enable `readability-redundant-string-init` to take a list of strings to apply the fix to rather than hard-coding `basic_string`. It adds a `StringNames` option of semicolon-delimited names of string classes to which to apply this fix. Tests ensure this works with test class out::TestString as well as std::string and std::wstring as before. It should be applicable to llvm::StringRef, QString, etc.

Reviewers: MyDeveloperDay, aaron.ballman, hokein, alexfh, JonasToth, gribozavr2

Patch by: poelmanc

Subscribers: gribozavr2, xazax.hun, Eugene.Zelenko, cfe-commits

Tags: #clang-tools-extra, #clang

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

4 years agogn build: Merge 631be5c0d41
LLVM GN Syncbot [Fri, 15 Nov 2019 21:34:55 +0000 (21:34 +0000)]
gn build: Merge 631be5c0d41

4 years agoRemove Support/Options.h, it is unused
Reid Kleckner [Thu, 14 Nov 2019 22:47:11 +0000 (14:47 -0800)]
Remove Support/Options.h, it is unused

It was added in 2014 in 732e0aa9fb84f1 with one use in Scalarizer.cpp.
That one use was then removed when porting to the new pass manager in
2018 in b6f76002d9158628e78.

While the RFC and the desire to get off of static initializers for
cl::opt all still stand, this code is now dead, and I think we should
delete this code until someone is ready to do the migration.

There were many clients of CommandLine.h that were it transitively
through LLVMContext.h, so I cleaned that up in 4c1a1d3cf97e1ede466.

Reviewers: beanz

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

4 years agoRevert "re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and...
Alexandre Ganea [Fri, 15 Nov 2019 21:21:17 +0000 (16:21 -0500)]
Revert "re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial"

This reverts commit 9c1baa23526c6d7d06eafefbf82d73bfe9bb3aaf.

4 years ago[clang-tidy] modernize-use-override new option AllowOverrideAndFinal
Mitchell Balan [Fri, 15 Nov 2019 21:13:48 +0000 (16:13 -0500)]
[clang-tidy] modernize-use-override new option AllowOverrideAndFinal

Summary:
In addition to adding `override` wherever possible, clang-tidy's `modernize-use-override` nicely removes `virtual` when `override` or `final` is specified, and further removes override when final is specified. While this is great default behavior, when code needs to be compiled with gcc at high warning levels that include `gcc -Wsuggest-override` or `gcc -Werror=suggest-override`, clang-tidy's removal of the redundant `override` keyword causes gcc to emit a warning or error. This discrepancy / conflict has been noted by others including a comment on Stack Overflow and by Mozilla's Firefox developers.

This patch adds an AllowOverrideAndFinal option defaulting to 0 - thus preserving current behavior - that when enabled allows both `override` and `final` to co-exist, while still fixing all other issues.

The patch includes a test file verifying all combinations of virtual/override/final, and mentions the new option in the release notes.

Reviewers: alexfh, djasper, JonasToth

Patch by: poelmanc

Subscribers: JonasToth, cfe-commits

Tags: #clang

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

4 years ago[SimplifyCFG] propagate fast-math-flags (FMF) from phi to select
Sanjay Patel [Fri, 15 Nov 2019 21:06:43 +0000 (16:06 -0500)]
[SimplifyCFG] propagate fast-math-flags (FMF) from phi to select

This is another step towards having FMF apply only to FP values
rather than those + fcmp. See PR38086 for one of the original
discussions/motivations:
https://bugs.llvm.org/show_bug.cgi?id=38086

And the test here is derived from PR39535:
https://bugs.llvm.org/show_bug.cgi?id=39535

Currently, we lose FMF when converting any phi to select in
SimplifyCFG. There are a small number of similar changes needed
to correct within SimplifyCFG, so it should be quick to patch
this pass up.

FMF was extended to select and phi with:
D61917
D67564

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

4 years ago[clang-tidy] modernize-use-using work with multi-argument templates
Mitchell Balan [Fri, 15 Nov 2019 19:30:41 +0000 (14:30 -0500)]
[clang-tidy] modernize-use-using work with multi-argument templates

Summary:
If clang-tidy's modernize-use-using feature finds any commas that are not within parentheses, it won't create a fix. That means it won't change lines like:
  typedef std::pair<int, int> Point;
to
  using Point = std::pair<int, int>;
or even:
  typedef std::map<std::string, Foo> MyMap;
  typedef std::vector<int,MyCustomAllocator<int>> MyVector;

This patch allows the fix to apply to lines with commas if they are within parentheses or angle brackets that were not themselves within parentheses.

Reviewers: alexfh, hokein, aaron.ballman

Patch by: poelmanc

Subscribers: jonathanmeier, cfe-commits

Tags: #clang, #clang-tools-extra

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

4 years agore-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them...
Alexandre Ganea [Fri, 15 Nov 2019 21:01:25 +0000 (16:01 -0500)]
re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

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

4 years agogn build: Merge d6de5f12d48
LLVM GN Syncbot [Fri, 15 Nov 2019 20:50:43 +0000 (20:50 +0000)]
gn build: Merge d6de5f12d48

4 years agoRevert "[LoadStoreVectorize] Use '||' instead of '|' between sides with function...
Richard Smith [Fri, 15 Nov 2019 20:49:35 +0000 (12:49 -0800)]
Revert "[LoadStoreVectorize] Use '||' instead of '|' between sides with function calls. NFCI."

This broke two tests. Presumably the non-short-circuting '|' was
intentional here.

This reverts commit f7efea0ded8e16c7751b378523407a491016edd6.

4 years ago[mips] Enable `la` pseudo instruction on 64-bit arch.
Simon Atanasyan [Mon, 11 Nov 2019 21:10:31 +0000 (00:10 +0300)]
[mips] Enable `la` pseudo instruction on 64-bit arch.

This patch makes LLVM compatible with GAS. It accepts `la` pseudo
instruction on arch with 64-bit pointers and just shows a warning.

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

4 years ago[mips] Do not emit R_MIPS_JALR for sym+offset in case of O32 ABI
Simon Atanasyan [Sat, 9 Nov 2019 06:29:42 +0000 (09:29 +0300)]
[mips] Do not emit R_MIPS_JALR for sym+offset in case of O32 ABI

O32 ABI uses relocations in REL format. Relocation's addend is written
in place. R_MIPS_JALR relocation points to the `jalr` instruction which
does not have a place to store the relocation addend. So it's impossible
to save non-zero "offset". This patch blocks emission of `R_MIPS_JALR`
relocations in such cases.

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

4 years agoAdd a missing triple in ast-dump-decl-json.m
Alex Richardson [Fri, 15 Nov 2019 20:14:06 +0000 (20:14 +0000)]
Add a missing triple in ast-dump-decl-json.m

Since there was no triple argument this test started failing on macOS bots,
where the mangled names are prefixed with an underscore.

4 years ago[LoopCacheAnalysis]: Fix assertion failure during cost computation
Rachel Craik [Fri, 15 Nov 2019 19:56:26 +0000 (14:56 -0500)]
[LoopCacheAnalysis]: Fix assertion failure during cost computation

Ensure the stride and trip count have the same type before multiplying them during reference cost calculation

Reviewed By: jdoefert

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

4 years ago[-gmodules] Let LLDB log a warning if the Clang module hash mismatches.
Adrian Prantl [Thu, 14 Nov 2019 21:57:49 +0000 (13:57 -0800)]
[-gmodules] Let LLDB log a warning if the Clang module hash mismatches.

This feature is mostly there to aid debugging of Clang module issues,
since the only useful actual the end-user can to is to recompile their
program.

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

4 years agoAdd RTTI support to the SymbolFile class hierarchy
Adrian Prantl [Fri, 15 Nov 2019 18:13:16 +0000 (10:13 -0800)]
Add RTTI support to the SymbolFile class hierarchy

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

4 years agoRename posix/FileSystem.cpp to FileSystemPosix.cpp
Adrian Prantl [Fri, 15 Nov 2019 19:47:55 +0000 (11:47 -0800)]
Rename posix/FileSystem.cpp to FileSystemPosix.cpp

to avoid a linker warning on Darwin about two files having the same name.

4 years ago[GCOV] Skip artificial functions from being emitted
Alexandre Ganea [Fri, 15 Nov 2019 19:23:05 +0000 (14:23 -0500)]
[GCOV] Skip artificial functions from being emitted

This is a patch to support  D66328, which was reverted until this lands.

Enable a compiler-rt test that used to fail previously with D66328.

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

4 years ago[OpenMP 5.0] - Extend defaultmap, by Chi Chun Chen.
cchen [Fri, 15 Nov 2019 18:02:06 +0000 (13:02 -0500)]
[OpenMP 5.0] - Extend defaultmap, by Chi Chun Chen.

Summary:
For the extended defaultmap, most of the work is inside sema.
The only difference for codegen is to set different initial
maptype for different implicit-behavior.

Reviewers: jdoerfert, ABataev

Reviewed By: ABataev

Subscribers: dreachem, sandoval, cfe-commits

Tags: #clang, #openmp

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

4 years ago[SVFS] Inject TLI Mappings in VFABI attribute.
Francesco Petrogalli [Mon, 11 Nov 2019 19:42:18 +0000 (19:42 +0000)]
[SVFS] Inject TLI Mappings in VFABI attribute.

This patch introduces a function pass to inject the scalar-to-vector
mappings stored in the TargetLIbraryInfo (TLI) into the Vector
Function ABI (VFABI) variants attribute.

The test is testing the injection for three vector libraries supported
by the TLI (Accelerate, SVML, MASSV).

The pass does not change any of the analysis associated to the
function.

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

4 years ago[clangd] Don't repeat class template args when printing constructor definitions
Sam McCall [Fri, 15 Nov 2019 18:23:04 +0000 (19:23 +0100)]
[clangd] Don't repeat class template args when printing constructor definitions

This fixes part of https://github.com/clangd/clangd/issues/76

4 years ago[AST] Let DeclarationNameInfo printing use PrintingPolicy, and fix const-correctness
Sam McCall [Fri, 15 Nov 2019 18:19:17 +0000 (19:19 +0100)]
[AST] Let DeclarationNameInfo printing use PrintingPolicy, and fix const-correctness

4 years ago[llvm-objcopy][MachO] Implement --redefine-sym and --redefine-syms
Fangrui Song [Wed, 13 Nov 2019 21:10:15 +0000 (13:10 -0800)]
[llvm-objcopy][MachO] Implement --redefine-sym and --redefine-syms

Similar to D46029 (ELF) and D70036 (COFF), but for MachO.
Note, when --strip-symbol (not implemented for MachO) is also specified,
--redefine-sym executes before --strip-symbol.

Reviewed By: jhenderson, seiya

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

4 years ago[ThinLTO] Fix -Wunused-function in NDEBUG builds after llvmorg-10-init-9933-g3d708bf5c26
Fangrui Song [Fri, 15 Nov 2019 18:00:23 +0000 (10:00 -0800)]
[ThinLTO] Fix -Wunused-function in NDEBUG builds after llvmorg-10-init-9933-g3d708bf5c26

4 years ago[DebugInfo] Allow spill slots in call site parameter descriptions
Vedant Kumar [Thu, 14 Nov 2019 17:20:58 +0000 (09:20 -0800)]
[DebugInfo] Allow spill slots in call site parameter descriptions

Allow call site paramter descriptions to reference spill slots. Spill
slots are not visible to high-level LLVM IR, so they can safely be
referenced during entry value evaluation (as they cannot be clobbered by
some other function).

This gives a 5% increase in the number of call site parameter DIEs in an
LTO x86_64 build of the xnu kernel.

This reverts commit eb4c98ca3d2590bad9f6542afbf3a7824d2b53fa (
[DebugInfo] Exclude memory location values as parameter entry values),
effectively reintroducing the portion of D60716 which dealt with memory
locations (authored by Djordje, Nikola, Ananth, and Ivan).

This partially addresses llvm.org/PR43343. However, not all memory
operands forwarded to callees live in spill slots. In the xnu build, it
may be possible to use an escape analysis to increase the number of call
site parameter by another 15% (more details in PR43343).

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

4 years ago[LoadStoreVectorize] Use '||' instead of '|' between sides with function calls. NFCI.
Dávid Bolvanský [Fri, 15 Nov 2019 17:50:36 +0000 (18:50 +0100)]
[LoadStoreVectorize] Use '||' instead of '|' between sides with function calls. NFCI.

Fixes warning from PVS Studio

4 years ago[CMake] Configure the Info.plist so it contains a real version number.
Jonas Devlieghere [Fri, 15 Nov 2019 17:46:27 +0000 (09:46 -0800)]
[CMake] Configure the Info.plist so it contains a real version number.

Use CMake to configure the Info.plist file so that we have a real
version number in things like crash reporter.

4 years ago[libc++] [chrono] Fix year_month_weekday::ok() implementation.
Marek Kurdej [Fri, 15 Nov 2019 12:04:47 +0000 (13:04 +0100)]
[libc++] [chrono] Fix year_month_weekday::ok() implementation.

Reviewers: ldionne, EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: christof, dexonsmith, libcxx-commits

Tags: #libc

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

4 years ago[libcxx] use __builtin_isnan in std::isnan.
Ilya Tokar [Fri, 15 Nov 2019 17:29:02 +0000 (12:29 -0500)]
[libcxx] use __builtin_isnan in std::isnan.

Summary: This allows std::isnan to be fully inlined, instead of generating calls.

Reviewers: EricWF

Reviewed By: EricWF

Subscribers: christof, ldionne

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

4 years agoComment the fact that DWARFDebugInfoEntry isn't copyable.
Adrian Prantl [Fri, 15 Nov 2019 17:14:30 +0000 (09:14 -0800)]
Comment the fact that DWARFDebugInfoEntry isn't copyable.

4 years ago[clang-format] Flexible line endings
Cameron Desrochers [Fri, 15 Nov 2019 16:48:06 +0000 (11:48 -0500)]
[clang-format] Flexible line endings

Line ending detection is now set with the `DeriveLineEnding` option.
CRLF can now be used as the default line ending by setting `UseCRLF`.
When line ending detection is disabled, all line endings are converted
according to the `UseCRLF` option.

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

4 years ago[MirNamer][Canonicalizer]: Perform instruction semantic based renaming
Aditya Nandakumar [Fri, 15 Nov 2019 16:23:32 +0000 (08:23 -0800)]
[MirNamer][Canonicalizer]: Perform instruction semantic based renaming

https://reviews.llvm.org/D70210

Previously:

Due to sensitivity of the algorithm with gaps, and extra instructions,
when diffing, often we see naming being off by a few. Makes the diff
unreadable even for tests with 7 and 8 instructions respectively.
Naming can change depending on candidates (and order of picking
candidates). Suddenly if there's one extra instruction somewhere, the
entire subtree would be named completely differently.
No consistent naming of similar instructions which occur in different
functions. If we try to do something like count the frequency
distribution of various differences across suite, then the above
sensitivity issues are going to result in poor results.
Instead:

Name instruction based on semantics of the instruction (hash of the
opcode and operands). Essentially for a given instruction that occurs in
any module/function it'll be named similarly (ie semantic). This has
some nice properties
Can easily look at many instructions and just check the hash and if
they're named similarly, then it's the same instruction. Makes it very
easy to spot the same instruction both multiple times, as well as across
many functions (useful for frequency distribution).
Independent of traversal/candidates/depth of graph. No need to keep
track of last index/gaps/skip count etc.
No off by few issues with diffs. I've tried the old vs new
implementation in files ranging from 30 to 700 instructions. In both
cases with the old algorithm, diffs are a sea of red, where as for the
semantic version, in both cases, the diffs line up beautifully.
Simplified implementation of the main loop (simple iteration) , no keep
track of what's visited and not.
Handle collision just by incrementing a counter. Roughly
bb[N]_hash_[CollisionCount].
Additionally with the new implementation, we can probably avoid doing
the hoisting of instructions to various places, as they'll likely be
named the same resulting in differences only based on collision (ie
regardless of whether the instruction is hoisted or not/close to use or
not, it'll be named the same hash which should result in use of the
instruction be identical with the only change being the collision count)
which is very easy to spot visually.

4 years ago[clangd] Fix typo in symbol kind conversion
Sam McCall [Fri, 15 Nov 2019 14:46:17 +0000 (15:46 +0100)]
[clangd] Fix typo in symbol kind conversion

Reviewers: hokein

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

Tags: #clang

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

4 years ago[scudo][standalone] Enabled SCUDO_DEBUG for tests + fixes
Kostya Kortchinsky [Thu, 14 Nov 2019 22:33:23 +0000 (14:33 -0800)]
[scudo][standalone] Enabled SCUDO_DEBUG for tests + fixes

Summary:
`SCUDO_DEBUG` was not enabled for unit tests, meaning the `DCHECK`s
were never tripped. While turning this on, I discovered that a few
of those not-exercised checks were actually wrong. This CL addresses
those incorrect checks.

Not that to work in tests `CHECK_IMPL` has to explicitely use the
`scudo` namespace. Also changes a C cast to a C++ cast.

Reviewers: hctim, pcc, cferris, eugenis, vitalybuka

Subscribers: mgorny, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years ago[clangd] Don't consider class template params part of constructor name.
Sam McCall [Fri, 15 Nov 2019 14:08:16 +0000 (15:08 +0100)]
[clangd] Don't consider class template params part of constructor name.

Summary:
This is shorter and usually the extra info is noise.
There are cases where the params become type-parameter-0-0 that are hard to fix.

This affects a few features:
 - 'name' field in structured hover API (not exposed yet)
 - 'name' field in locateSymbolAt (not exposed in LSP)
 - 'document/symbol' - the symbol is hierarchically nested in the class
   template, or written as foo<t>::foo when defined out-of-line.

Added a test case for hover from https://github.com/clangd/clangd/issues/76.
This patch fixes one field, but no fewer than four others are wrong!
I'll fix them...

Reviewers: hokein

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

Tags: #clang

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

4 years ago[clangd] Fix SelectionTree behavior on constructor init-lists.
Sam McCall [Fri, 15 Nov 2019 15:07:34 +0000 (16:07 +0100)]
[clangd] Fix SelectionTree behavior on constructor init-lists.

Summary:
For the constructor Foo() : classmember(arg) {}

The AST looks like:
 - CXXCtorInitializer  classmember(arg)
   - CXXConstructExpr  classmember(arg)
     - DeclRefExpr:                arg

We want the 'classmember' to be associated with the CXXCtorInitializer, not the
CXXConstructExpr. (CXXConstructExpr is known to have bad ranges).
So just early-claim it.

Thanks @hokein for tracking down/reducing the bug.

Reviewers: hokein

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

Tags: #clang

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

4 years agoAdd read-only data assembly writing for aix
diggerlin [Fri, 15 Nov 2019 16:30:19 +0000 (11:30 -0500)]
Add read-only data assembly writing for aix

SUMMARY:
The patch will emit read-only variable assembly code for aix.

Reviewers: daltenty,Xiangling_Liao
Subscribers: rupprecht, seiyai,hiraditya

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

4 years ago[llvm-objcopy][NFC] Use generated object file in COFF/add-section.test
Sergey Dmitriev [Wed, 13 Nov 2019 04:19:17 +0000 (20:19 -0800)]
[llvm-objcopy][NFC] Use generated object file in COFF/add-section.test

Updated LIT test from D70205 to use generated object file with extended relocation table.

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

4 years ago[X86][SSE] Add test for extractelement from volatile vector load
Simon Pilgrim [Fri, 15 Nov 2019 15:59:33 +0000 (15:59 +0000)]
[X86][SSE] Add test for extractelement from volatile vector load

Mentioned in D70267

4 years agoImplement target(branch-protection) attribute for AArch64
Momchil Velikov [Fri, 15 Nov 2019 11:34:47 +0000 (11:34 +0000)]
Implement target(branch-protection) attribute for AArch64

This patch implements `__attribute__((target("branch-protection=...")))`
in a manner, compatible with the analogous GCC feature:

https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/AArch64-Function-Attributes.html#AArch64-Function-Attributes

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

4 years agoclang: enable unwind tables on FreeBSD !amd64
Ed Maste [Fri, 15 Nov 2019 14:30:24 +0000 (09:30 -0500)]
clang: enable unwind tables on FreeBSD !amd64

There doesn't seem to be much sense in defaulting "on" unwind tables on
amd64 and not on other arches. It causes surprising differences between
platforms, such as the PR below[1].

Prior to this change, FreeBSD inherited the default implementation of the
method from the Gnu.h Generic_Elf => Generic_GCC parent class, which
returned true only for amd64 targets.  Override that and opt on always,
similar to, e.g., NetBSD's driver.

[1] https://bugs.freebsd.org/241562

Patch by cem (Conrad Meyer).

Reviewed By: dim

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

4 years ago[clangd] Replace getLangOpts().isHeaderFile usage with isHeaderFile helper.
Haojian Wu [Fri, 15 Nov 2019 15:24:19 +0000 (16:24 +0100)]
[clangd] Replace getLangOpts().isHeaderFile usage with isHeaderFile helper.

Summary:
The helper is more correct to detect header file, this would fix our
issues caused by false positive before.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

4 years ago[clangd] Add isHeaderFile helper.
Haojian Wu [Wed, 13 Nov 2019 15:30:07 +0000 (16:30 +0100)]
[clangd] Add isHeaderFile helper.

Summary:
we have a few places using `ASTCtx.getLangOpts().IsHeaderFile` to
determine a header file, but it relies on "-x c-header" compiler flag,
if the compilation command doesn't have this flag, we will get a false
positive. We are encountering this issue in bazel build system.

To solve this problem, we infer the file from file name, actual changes will
come in follow-ups.

Reviewers: sammccall

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

Tags: #clang

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

4 years ago[RISCV] Match GCC `-march`/`-mabi` driver defaults
Sam Elliott [Fri, 15 Nov 2019 15:10:02 +0000 (15:10 +0000)]
[RISCV] Match GCC `-march`/`-mabi` driver defaults

Summary:
Clang/LLVM is a cross-compiler, and so we don't have to make a choice
about `-march`/`-mabi` at build-time, but we may have to compute a
default `-march`/`-mabi` when compiling a program. Until now, each
place that has needed a default `-march` has calculated one itself.

This patch adds a single place where a default `-march` is calculated,
in order to avoid calculating different defaults in different places.

This patch adds a new function `riscv::getRISCVArch` which encapsulates
this logic based on GCC's for computing a default `-march` value
when none is provided. This patch also updates the logic in
`riscv::getRISCVABI` to match the logic in GCC's build system for
computing a default `-mabi`.

This patch also updates anywhere that `-march` is used to now use the
new function which can compute a default. In particular, we now
explicitly pass a `-march` value down to the gnu assembler.

GCC has convoluted logic in its build system to choose a default
`-march`/`-mabi` based on build options, which would be good to match.
This patch is based on the logic in GCC 9.2.0. This commit's logic is
different to GCC's only for baremetal targets, where we default
to rv32imac/ilp32 or rv64imac/lp64 depending on the target triple.

Tests have been updated to match the new logic.

Reviewers: asb, luismarques, rogfer01, kito-cheng, khchen

Reviewed By: asb, luismarques

Subscribers: sameer.abuasal, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, s.egerton, pzheng, cfe-commits

Tags: #clang

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

4 years ago[CodeComplete] Constructor overload candidates report as vector(int) instead of vecto...
Sam McCall [Fri, 15 Nov 2019 13:52:04 +0000 (14:52 +0100)]
[CodeComplete] Constructor overload candidates report as vector(int) instead of vector<string>(int)

Summary:
This is shorter, shouldn't be confusing (is consistent with how they're declared),
and avoids messy cases that are printed as myclass<type-param-0-0>(int) in the
case of partial specialization.

Fixes part of https://github.com/clangd/clangd/issues/76

Reviewers: hokein, lh123

Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[ARM,MVE] Add reversed isel patterns for MVE `vcmp qN,rN`
Simon Tatham [Fri, 15 Nov 2019 14:05:02 +0000 (14:05 +0000)]
[ARM,MVE] Add reversed isel patterns for MVE `vcmp qN,rN`

Summary:
As well as vector/vector compare instructions, MVE also has a family
of comparisons taking a vector and a scalar, which compare every lane
of the vector against the same value. We generate those at isel time
using isel patterns that match `(ARMvcmp vector, (ARMvdup scalar))`.

This commit adds corresponding patterns for the operand-reversed form
`(ARMvcmp (ARMvdup scalar), vector)`, with condition codes swapped as
necessary. That way, we can still generate the vector/scalar compare
instruction if the IR happens to have been rearranged to put the
operands the other way round, which can happen in some optimization
phases. Previously, a vcmp the other way round was handled by emitting
a `vdup` instruction to //explicitly// replicate the scalar input into
a vector, and then doing a vector/vector comparison.

I haven't added a new test, because it turned out that several
existing tests were already exhibiting that failure mode. So just
updating the expected output in the existing MVE codegen tests
demonstrates what's been improved.

Reviewers: ostannard, MarkMurrayARM, dmgreen

Reviewed By: dmgreen

Subscribers: kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[Clang][ASTImporter] Added visibility check for ClassTemplateDecl.
Balázs Kéri [Fri, 15 Nov 2019 14:05:20 +0000 (15:05 +0100)]
[Clang][ASTImporter] Added visibility check for ClassTemplateDecl.

Summary:
ASTImporter makes now difference between class templates with same
name in different translation units if these are not visible outside.

Reviewers: martong, a.sidorin, shafik

Reviewed By: martong

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits

Tags: #clang

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

4 years ago[AMDGPU] Lower llvm.amdgcn.s.buffer.load.v3[i|f]32
Piotr Sobczak [Tue, 12 Nov 2019 10:46:54 +0000 (11:46 +0100)]
[AMDGPU] Lower llvm.amdgcn.s.buffer.load.v3[i|f]32

Summary: Add lowering support for 32-bit vec3 variant of s.buffer.load intrinsic.

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

Tags: #llvm

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

4 years agoRecommit "[ThinLTO] Add correctness check for RO/WO variable import"
evgeny [Fri, 15 Nov 2019 13:13:19 +0000 (16:13 +0300)]
Recommit "[ThinLTO] Add correctness check for RO/WO variable import"

ValueInfo has user-defined 'operator bool' which allows incorrect implicit conversion
to GlobalValue::GUID (which is unsigned long). This causes bugs which are hard to
track and should be removed in future.

4 years agoFix TestFormatters.py stepping too far
Diana Picus [Thu, 14 Nov 2019 10:27:41 +0000 (11:27 +0100)]
Fix TestFormatters.py stepping too far

TestFormatters.py has a sequence of three 'next' commands to get past
all the initializations in the test function. On AArch64 (and
potentially other platforms), this was one 'next' too many and we ended
up outside our frame.

This patch replaces the sequence with a 'thread until ' the line of the
return from the function, so we should stop after all the
initializations but before actually returning.

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

4 years agogn build: Merge e6584b2b7b2
LLVM GN Syncbot [Fri, 15 Nov 2019 12:57:26 +0000 (12:57 +0000)]
gn build: Merge e6584b2b7b2

4 years agoMove floating point related entities to namespace level
Serge Pavlov [Thu, 29 Aug 2019 12:29:11 +0000 (19:29 +0700)]
Move floating point related entities to namespace level

Enumerations that describe rounding mode and exception behavior were
defined inside ConstrainedFPIntrinsic. It makes sense to use the same
definitions to represent the same properties in other cases, not only
in constrained intrinsics. It was however inconvenient as required to
include constrained intrinsics definitions even if they were not needed.
Also using long scope prefix reduced readability.

This change moves these definitioins to the namespace llvm::fp.
No functional changes.

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

4 years ago[update_cc_test_checks.py] Use -ast-dump=json to get mangled name
Alex Richardson [Fri, 15 Nov 2019 12:50:10 +0000 (12:50 +0000)]
[update_cc_test_checks.py] Use -ast-dump=json to get mangled name

Summary:
Using c-index-test is fragile since it does not parse all the clang
arguments that are used in the RUN: line. This can result in incorrect
mangled names that do not match any of the generated IR.
For example macOS triples include a leading underscore (which was handled
with a hack in the current script). For the CHERI target we have added
new qualifiers which affect C++ name mangling, but will be included added
by update_cc_test_checks since it parses the source file with the host
triple because it ignores the -triple= argument passed to clang -cc1.

Using the new feature of including the mangled name in the JSON AST dump
(see D69564), we can parse the output of the RUN: command with
"-fsyntax-only -ast-dump=json" appended.
This should make the script less fragile and also forks one process less.

Reviewers: MaskRay, xbolva00

Reviewed By: MaskRay

Subscribers: llvm-commits

Tags: #llvm

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

4 years agoInclude the mangled name in -ast-dump=json
Alex Richardson [Fri, 15 Nov 2019 12:33:16 +0000 (12:33 +0000)]
Include the mangled name in -ast-dump=json

I am planning to use this feature to make update_cc_test_checks.py less fragile
by obtaining the mangled names directly from -ast-dump=json. Currently,
it uses c-index-test which ignores the -triple=, etc. arguments that are
in the RUN: line and therefore does not generate checks for some targets.

The AST dump tests were updated using the following command:
`python $LLVM_BINDIR/gen_ast_dump_json_test.py --update --source $LLVM_SRC/clang/test/AST/*-json.*`

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: rsmith, MaskRay, cfe-commits

Tags: #clang

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

4 years ago[NFC] Regenerate ast-dump-json tests
Alex Richardson [Tue, 12 Nov 2019 12:02:07 +0000 (12:02 +0000)]
[NFC] Regenerate ast-dump-json tests

This was done by running `python $LLVM_BINDIR/gen_ast_dump_json_test.py --update --source $LLVM_SRC/clang/test/AST/*-json.*`
Only changes are whitespace and line endings.

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

4 years ago[gen_ast_dump_json_test.py] Allow updating multiple files in one go
Alex Richardson [Tue, 12 Nov 2019 12:00:51 +0000 (12:00 +0000)]
[gen_ast_dump_json_test.py] Allow updating multiple files in one go

With this change it is possible to update all JSON dump tests using the
following command:
python $LLVM_BINDIR/gen_ast_dump_json_test.py --update --source $LLVM_SRC/clang/test/AST/*-json.*

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

4 years ago[gen_ast_dump_json_test.py] Copy to binary directory to omit --clang argument
Alex Richardson [Tue, 12 Nov 2019 11:47:54 +0000 (11:47 +0000)]
[gen_ast_dump_json_test.py] Copy to binary directory to omit --clang argument

The script will now check if a clang binary exists in the same directory
and default to that instead of requiring a --clang argument. The script
is copied to the clang build directory using CMake configure_file() with
COPYONLY. This ensures that the version in the build directory is updated
any time the source version changes.

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

4 years ago[gen_ast_dump_json_test.py] Skip manual tests when using --update
Alex Richardson [Tue, 29 Oct 2019 12:58:10 +0000 (12:58 +0000)]
[gen_ast_dump_json_test.py] Skip manual tests when using --update

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

4 years ago[gen_ast_dump_json_test.py] Infer --filters flags when using --update
Alex Richardson [Tue, 29 Oct 2019 12:32:16 +0000 (12:32 +0000)]
[gen_ast_dump_json_test.py] Infer --filters flags when using --update

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

4 years ago[gen_ast_dump_json_test.py] Parse RUN: lines with --update
Alex Richardson [Tue, 29 Oct 2019 12:06:46 +0000 (12:06 +0000)]
[gen_ast_dump_json_test.py] Parse RUN: lines with --update

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

4 years ago[gen_ast_dump_json_test.py] Add a --update flag
Alex Richardson [Tue, 29 Oct 2019 11:50:08 +0000 (11:50 +0000)]
[gen_ast_dump_json_test.py] Add a --update flag

This will allow updating the JSON tests for new format changes. Instead of
simply appending the JSON to the input file, the script will now make a
copy of the input file up to the "CHECK lines have been autogenerated"
disclaimer and then append the new JSON.

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

4 years agoDWARFDebugLoc(v4): Add an incremental parsing function
Pavel Labath [Tue, 5 Nov 2019 13:46:54 +0000 (14:46 +0100)]
DWARFDebugLoc(v4): Add an incremental parsing function

Summary:
This adds a visitLocationList function to the DWARF v4 location lists,
similar to what already exists for DWARF v5. It follows the approach
outlined in previous patches (D69672), where the parsed form is always
stored in the DWARF v5 format, which makes it easier for generic code to
be built on top of that. v4 location lists are "upgraded" during
parsing, and then this upgrade is undone while dumping.

Both "inline" and section-based dumping is rewritten to reuse the
existing "generic" location list dumper. This means that the output
format is consistent for all location lists (the only thing one needs to
implement is the function which prints the "raw" form of a location
list), and that debug_loc dumping correctly processes base address
selection entries, etc.

The previous existing debug_loc functionality (e.g.,
parseOneLocationList) is rewritten on top of the new API, but it is not
removed as there is still code which uses them. This will be done in
follow-up patches, after I build the API to access the "interpreted"
location lists in a generic way (as that is what those users really
want).

Reviewers: dblaikie, probinson, JDevlieghere, aprantl, SouraVX

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[CodeGen] Increase the size of a SmallVector
Jay Foad [Fri, 15 Nov 2019 11:05:39 +0000 (11:05 +0000)]
[CodeGen] Increase the size of a SmallVector

The SmallVector reserve() call in
MachineInstrExpressionTrait::getHashValue accounted for over 3% of all
calls to malloc() when I compiled a bunch of graphics shaders for the
AMDGPU target. Its initial size was only enough for machine instructions
with up to 7 operands, but for AMDGPU 8 and 10 operands are very common.
Here's a histogram of number of operands for each call to getHashValue,
gathered from the same collection of shaders:

1  13503
2  254273
3  135781
4  422508
5  614997
6  194953
7  287248
8  1517255
9  31218
10 1191269
11 70731
12 24
13 77
15 84
17 4692
27 16
33 705
49 6

Typical instructions with 8 and 10 operands are floating point
arithmetic and multiply-accumulate instructions like:

%83:vgpr_32 = V_MUL_F32_e64 0, killed %82:vgpr_32, 0, killed %81:vgpr_32, 0, 0, implicit $exec
%330:vgpr_32 = V_MAC_F32_e64 0, killed %327:vgpr_32, 0, killed %329:sgpr_32, 0, %328:vgpr_32(tied-def 0), 0, 0, implicit $exec

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

4 years agoRevert "[clang] Remove the DIFlagArgumentNotModified debug info flag"
Djordje Todorovic [Fri, 15 Nov 2019 10:59:47 +0000 (11:59 +0100)]
Revert "[clang] Remove the DIFlagArgumentNotModified debug info flag"

This reverts commit rG1643734741d2 due to LLDB test failure.

4 years ago[ARM][MVE] tail-predication
Sjoerd Meijer [Fri, 15 Nov 2019 11:01:13 +0000 (11:01 +0000)]
[ARM][MVE] tail-predication

This is a follow up of d90804d, to also flag fmcp instructions as instructions
that we do not support in tail-predicated vector loops.

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

4 years ago[MIPS GlobalISel] Select andi, ori and xori
Petar Avramovic [Fri, 15 Nov 2019 10:41:25 +0000 (11:41 +0100)]
[MIPS GlobalISel] Select andi, ori and xori

Introduce IntImmLeaf version of PatLeaf immZExt16 for 32-bit immediates.
Change immZExt16 with imm32ZExt16 for andi, ori and xori.
This keeps same behavior for SDAG and allows for GlobalISel selectImpl
to select 'G_CONSTANT imm' + G_AND, G_OR, G_XOR into ANDi, ORi, XORi,
respectively, when 32-bit imm satisfies imm32ZExt16 predicate: zero
extending 16 low bits of imm is equal to imm.
Large number of test changes comes from zero extending of small types
which is transformed into 'and' with bitmask in legalizer.

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

4 years ago[MIPS GlobalISel] Select addiu
Petar Avramovic [Fri, 15 Nov 2019 10:36:13 +0000 (11:36 +0100)]
[MIPS GlobalISel] Select addiu

Introduce IntImmLeaf version of PatLeaf immSExt16 for 32-bit immediates.
Change immSExt16 with imm32SExt16 for addiu.
This keeps same behavior for SDAG and allows for GlobalISel selectImpl
to select 'G_CONSTANT imm' + G_ADD into ADDIu when 32-bit imm satisfies
imm32SExt16 predicate: sign extending 16 low bits of imm is equal to imm.

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

4 years ago[Scalarizer] Treat values from unreachable blocks as undef
Mikael Holmen [Fri, 15 Nov 2019 09:29:47 +0000 (10:29 +0100)]
[Scalarizer] Treat values from unreachable blocks as undef

Summary:
When scalarizing PHI nodes we might try to examine/rewrite
InsertElement nodes in predecessors. If those predecessors
are unreachable from entry, then the IR in those blocks could
have unexpected properties resulting in infinite loops in
Scatterer::operator[].
By simply treating values originating from instructions in
unreachable blocks as undef we do not need to analyse them
further.

This fixes PR41723.

Reviewers: bjope

Reviewed By: bjope

Subscribers: bjope, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[clang] Remove the DIFlagArgumentNotModified debug info flag
Djordje Todorovic [Fri, 15 Nov 2019 09:47:35 +0000 (10:47 +0100)]
[clang] Remove the DIFlagArgumentNotModified debug info flag

It turns out that the ExprMutationAnalyzer can be very slow when AST
gets huge in some cases. The idea is to move this analysis to the LLVM
back-end level (more precisely, in the LiveDebugValues pass). The new
approach will remove the performance regression, simplify the
implementation and give us front-end independent implementation.

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

4 years ago[ARM,MVE] Add intrinsics for vector get/set lane.
Simon Tatham [Fri, 15 Nov 2019 09:53:15 +0000 (09:53 +0000)]
[ARM,MVE] Add intrinsics for vector get/set lane.

This adds the `vgetq_lane` and `vsetq_lane` families, to copy between
a scalar and a specified lane of a vector.

One of the new `vgetq_lane` intrinsics returns a `float16_t`, which
causes a compile error if `%clang_cc1` doesn't get the option
`-fallow-half-arguments-and-returns`. The driver passes that option to
cc1 already, but I've had to edit all the explicit cc1 command lines
in the existing MVE intrinsics tests.

A couple of fixes are included for the code I wrote up front in
MveEmitter to support lane-index immediates (and which nothing has
tested until now): the type was wrong (`uint32_t` instead of `int`)
and the range was off by one.

I've also added a method of bypassing the default promotion to `i32`
that is done by the MveEmitter code generation: it's sensible to
promote short scalars like `i16` to `i32` if they're going to be
passed to custom IR intrinsics representing a machine instruction
operating on GPRs, but not if they're going to be passed to standard
IR operations like `insertelement` which expect the exact type.

Reviewers: ostannard, MarkMurrayARM, dmgreen

Reviewed By: dmgreen

Subscribers: kristof.beyls, cfe-commits

Tags: #clang

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

4 years ago[ARM,MVE] Add intrinsics for 'administrative' vector operations.
Simon Tatham [Wed, 13 Nov 2019 15:23:38 +0000 (15:23 +0000)]
[ARM,MVE] Add intrinsics for 'administrative' vector operations.

This batch of intrinsics includes lots of things that move vector data
around or change its type without really affecting its value very
much. It includes the `vreinterpretq` family (cast one vector type to
another); `vuninitializedq` (create a vector of a given type with
don't-care contents); and `vcreateq` (make a 128-bit vector out of two
`uint64_t` halves).

These are all implemented using completely standard IR that's already
tested in existing LLVM unit tests, so I've just written a clang test
to check the IR is correct, and left it at that.

I've also added some richer infrastructure to the MveEmitter Tablegen
backend, to make it specify the exact integer type of integer
arguments passed to IR construction functions, and wrap those
arguments in a `static_cast` in the autogenerated C++. That was
necessary to prevent an overloading ambiguity when passing the integer
literal `0` to `IRBuilder::CreateInsertElement`, because otherwise, it
could mean either a null pointer `llvm::Value *` or a zero `uint64_t`.

Reviewers: ostannard, MarkMurrayARM, dmgreen

Subscribers: kristof.beyls, cfe-commits

Tags: #clang

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

4 years ago[AST] Use written names instead of `type-param-0-0` in more cases when printing types...
Sam McCall [Thu, 14 Nov 2019 13:16:14 +0000 (14:16 +0100)]
[AST] Use written names instead of `type-param-0-0` in more cases when printing types and decls.

Summary:
This doesn't cover decls in diagnostics, which use NamedDecl::getNameForDiagnostic().
(That should also be fixed later I think).

This covers some cases of https://github.com/clangd/clangd/issues/76
(hover, but not outline or sighelp)

Reviewers: hokein

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

Tags: #clang

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

4 years agoFix GCC -Wcast-qual warnings
Hans Wennborg [Fri, 15 Nov 2019 08:48:50 +0000 (09:48 +0100)]
Fix GCC -Wcast-qual warnings

4 years agoGCC 5.3 build fix
Hans Wennborg [Fri, 15 Nov 2019 08:46:44 +0000 (09:46 +0100)]
GCC 5.3 build fix

It was failing with

  llvm/lib/ExecutionEngine/Orc/DebugUtils.cpp:56:10:
  error: could not convert ‘Obj’ from ‘std::unique_ptr<llvm::MemoryBuffer>’
  to ‘llvm::Expected<std::unique_ptr<llvm::MemoryBuffer> >’
     return Obj;
            ^

4 years agoAMDGPU: Change boolean content type to 0 or 1
Matt Arsenault [Mon, 11 Nov 2019 09:16:38 +0000 (14:46 +0530)]
AMDGPU: Change boolean content type to 0 or 1

The usage of target boolean checks is overly inflexible, since sext
and zext of a compare are equally cheap. The choice is arbitrary, but
using 0/1 to some degree is the choice of lower resistance since
that's what most targets use. This enables a few combines that don't
bother to support ZeroOrNegativeOneBooleanContent.

4 years agoAMDGPU: Try to commute sub of boolean ext
Matt Arsenault [Thu, 14 Nov 2019 08:03:33 +0000 (13:33 +0530)]
AMDGPU: Try to commute sub of boolean ext

Avoids another regression in a future patch.

4 years agoGlobalISel: Lower s1 source G_SITOFP/G_UITOFP
Matt Arsenault [Fri, 15 Nov 2019 06:29:12 +0000 (11:59 +0530)]
GlobalISel: Lower s1 source G_SITOFP/G_UITOFP

4 years agoUnbreak the clang test suite when hexagon-link is not available
David Zarzycki [Fri, 15 Nov 2019 06:45:20 +0000 (08:45 +0200)]
Unbreak the clang test suite when hexagon-link is not available

All of the other tests are of the form {{hexagon-link|ld}} so this
probably should be too.

4 years agogn build: Merge 16f38dda292
LLVM GN Syncbot [Fri, 15 Nov 2019 05:27:58 +0000 (05:27 +0000)]
gn build: Merge 16f38dda292

4 years ago[ORC] Add a utility to support dumping JIT'd objects to disk for debugging.
Lang Hames [Thu, 14 Nov 2019 23:58:21 +0000 (15:58 -0800)]
[ORC] Add a utility to support dumping JIT'd objects to disk for debugging.

Adds a DumpObjects utility that can be used to dump JIT'd objects to disk.
Instances of DebugObjects may be used by ObjectTransformLayer as no-op
transforms.

This patch also adds an ObjectTransformLayer to LLJIT and an example of how
to use this utility to dump JIT'd objects in LLJIT.

4 years ago[llvm-objcopy][MachO] Implement --remove-section
Seiya Nuta [Fri, 15 Nov 2019 03:37:55 +0000 (12:37 +0900)]
[llvm-objcopy][MachO] Implement --remove-section

Reviewers: alexshap, rupprecht, jhenderson

Reviewed By: rupprecht, jhenderson

Subscribers: jakehehrlich, abrachet, llvm-commits

Tags: #llvm

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

4 years agoAdd a test to cover structural match for recursive data types
Bruno Cardoso Lopes [Thu, 14 Nov 2019 21:44:18 +0000 (13:44 -0800)]
Add a test to cover structural match for recursive data types

This didn't use to work prior to r370639, now that this is supported
add a testcase to prevent regressions.

rdar://problem/53602368