platform/upstream/llvm.git
4 years ago[Inliner] Inlining should honor nobuiltin attributes
Teresa Johnson [Thu, 6 Feb 2020 21:28:41 +0000 (13:28 -0800)]
[Inliner] Inlining should honor nobuiltin attributes

Summary:
Final patch in series to fix inlining between functions with different
nobuiltin attributes/options, which was specifically an issue in LTO.
See discussion on D61634 for background.

The prior patch in this series (D67923) enabled per-Function TLI
construction that identified the nobuiltin attributes.

Here I have allowed inlining to proceed if the callee's nobuiltins are a
subset of the caller's nobuiltins, but not in the reverse case, which
should be conservatively correct. This is controlled by a new option,
-inline-caller-superset-nobuiltin, which is enabled by default.

Reviewers: hfinkel, gchatelet, chandlerc, davidxl

Subscribers: arsenm, jvesely, nhaehnle, mehdi_amini, eraman, hiraditya, haicheng, dexonsmith, kerbowa, llvm-commits

Tags: #llvm

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

4 years agoFix MSVC "32-bit shift implicitly converted to 64 bits" warning. NFCI.
Simon Pilgrim [Fri, 28 Feb 2020 15:19:57 +0000 (15:19 +0000)]
Fix MSVC "32-bit shift implicitly converted to 64 bits" warning. NFCI.

4 years ago[TargetLowering] SimplifyDemandedBits - fix SCALAR_TO_VECTOR knownbits bug
Simon Pilgrim [Fri, 28 Feb 2020 15:18:08 +0000 (15:18 +0000)]
[TargetLowering] SimplifyDemandedBits - fix SCALAR_TO_VECTOR knownbits bug

We can only report the knownbits for a SCALAR_TO_VECTOR node if we only demand the 0'th element - the upper elements are undefined and shouldn't be trusted.

This is causing a number of regressions that need addressing but we need to get the bugfix in first.

4 years ago[Transform][MemCpyOpt] Add missing DebugLoc to %tmpbitcast
Pierre-vh [Wed, 26 Feb 2020 13:41:33 +0000 (13:41 +0000)]
[Transform][MemCpyOpt] Add missing DebugLoc to %tmpbitcast

Fix for https://bugs.llvm.org/show_bug.cgi?id=37967

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

4 years agoReland 7691790dfd1011d08f5468f63952d7690755aad4 with a MSAN fix
Krzysztof Parzyszek [Wed, 26 Feb 2020 15:56:12 +0000 (09:56 -0600)]
Reland 7691790dfd1011d08f5468f63952d7690755aad4 with a MSAN fix

In some cases when HexagonTargetLowering::allowsMemoryAccess returned
true, it did not set the "Fast" argument, leaving it uninitialized.

[Hexagon] Improve casting of boolean HVX vectors to scalars

- Mark memory access for bool vectors as disallowed in target lowering.
  This will prevent combining bitcasts of bool vectors with stores.
- Replace the actual bitcasting code with a faster version.
- Handle casting of v16i1 to i16.

4 years ago[ARM] MVE VMLAS
David Green [Fri, 28 Feb 2020 11:02:20 +0000 (11:02 +0000)]
[ARM] MVE VMLAS

This addes extra patterns for the VMLAS MVE instruction, which performs
Qda = Qda * Qn + Rm, a similar pattern to the existing VMLA. The sinking
of splat(Rm) into the loop is already performed, meaning we just need
extra Pat's in tablegen.

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

4 years ago[ARM] Additional MVE VMLA tests. NFC
David Green [Thu, 27 Feb 2020 18:46:39 +0000 (18:46 +0000)]
[ARM] Additional MVE VMLA tests. NFC

4 years agoSkip TemplateSpecializedType in modernize-pass-by-value.
Karasev Nikita [Fri, 28 Feb 2020 14:17:16 +0000 (09:17 -0500)]
Skip TemplateSpecializedType in modernize-pass-by-value.

Existing 'modernize-pass-by-value' check works only with non template values in
initializers. Fixes PR37210.

4 years ago[cmake][msvc] Don't disable C4345 any more.
Simon Pilgrim [Fri, 28 Feb 2020 13:56:48 +0000 (13:56 +0000)]
[cmake][msvc] Don't disable C4345 any more.

This shouldn't be relevant now that we just support VS2017+.

4 years ago[Utils] Make some scripts directly executable
Jay Foad [Fri, 28 Feb 2020 13:39:54 +0000 (13:39 +0000)]
[Utils] Make some scripts directly executable

4 years ago[AMDGPU] Mark the scheduling model as complete
Jay Foad [Fri, 28 Feb 2020 13:22:44 +0000 (13:22 +0000)]
[AMDGPU] Mark the scheduling model as complete

4 years ago[AMDGPU] Update a comment missed in 74e2974ac6a
Jay Foad [Fri, 28 Feb 2020 13:20:55 +0000 (13:20 +0000)]
[AMDGPU] Update a comment missed in 74e2974ac6a

4 years agoFix buildbots after c074f5234d29439116f0e0be6033ea9331e85394.
Alexey Lapshin [Fri, 28 Feb 2020 12:06:53 +0000 (15:06 +0300)]
Fix buildbots after c074f5234d29439116f0e0be6033ea9331e85394.

Removed unused function getSectionByName() from dsymutil/DwarfStreamer.cpp.

4 years ago[clang-tidy] Added virtual isLanguageVersionSupported to ClangTidyCheck
Nathan James [Fri, 28 Feb 2020 13:03:30 +0000 (13:03 +0000)]
[clang-tidy] Added virtual isLanguageVersionSupported to ClangTidyCheck

Summary:
Motivated by [[ https://bugs.llvm.org/show_bug.cgi?id=45045 | Tune inspections to a specific C++ standard. ]]
Moves the isLanguageVersionSupported virtual function from `MakeSmartPtrCheck` to the base `ClangTidyCheck` class.
This will disable registering matchers or pp callbacks on unsupported language versions for a check.
Having it as a standalone function is cleaner than manually disabling the check in the register function and should hopefully
encourage check developers to actually restrict the check based on language version.
As an added bonus this could enable automatic detection of what language version a check runs on for the purpose of documentation generation

Reviewers: aaron.ballman, gribozavr2, Eugene.Zelenko, JonasToth, alexfh, hokein

Reviewed By: gribozavr2

Subscribers: xazax.hun, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[clang-format] Improve C# handling of spaces in square brackets
Jonathan Coe [Fri, 28 Feb 2020 12:44:15 +0000 (12:44 +0000)]
[clang-format] Improve C# handling of spaces in square brackets

Reviewers: MyDeveloperDay, krasimir

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

4 years ago[RISCV] Compress instructions based on function features
Simon Cook [Fri, 28 Feb 2020 11:52:55 +0000 (11:52 +0000)]
[RISCV] Compress instructions based on function features

When running under LTO, it is common to not specify the architecture
spec, which is used for setting up the target machine, and instead rely
on features specified in each function to generate the correct
instructions.

This works for the code generator, but the RISC-V backend uses the
AsmPrinter to do instruction compression, which does not see these
features but instead uses a MCSubtargetInfo object to see whether
compression is enabled. Since this is configured based on the
TargetMachine at startup, it will result in compressed instructions not
being emitted when it has not been given the 'c' TargetFeature, but the
function has it.

This changes the RISCVAsmPrinter to re-initialize the STI feature set
based on the current MachineFunction, such that compressed instructions
are now correctly emitted regardless of the method used to enable them.

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

4 years ago[gn build] Port 6af859dcca2
LLVM GN Syncbot [Fri, 28 Feb 2020 11:49:23 +0000 (11:49 +0000)]
[gn build] Port 6af859dcca2

4 years ago[ELF][LLD][ARM] Add missing REQUIRES: arm to tests
Peter Smith [Fri, 28 Feb 2020 11:44:32 +0000 (11:44 +0000)]
[ELF][LLD][ARM] Add missing REQUIRES: arm to tests

Fix buildbots that don't build ARM backend.

4 years ago[DebugInfo] Re-implement LexicalScopes dominance method, add unit tests
Jeremy Morse [Fri, 28 Feb 2020 10:41:23 +0000 (10:41 +0000)]
[DebugInfo] Re-implement LexicalScopes dominance method, add unit tests

Way back in D24994, the combination of LexicalScopes::dominates and
LiveDebugValues was identified as having worst-case quadratic complexity,
but it wasn't triggered by any code path at the time. I've since run into a
scenario where this occurs, in a very large basic block where large numbers
of inlined DBG_VALUEs are present.

The quadratic-ness comes from LiveDebugValues::join calling "dominates" on
every variable location, and LexicalScopes::dominates potentially touching
every instruction in a block to test for the presence of a scope. We have,
however, already computed the presence of scopes in blocks, in the
"InstrRanges" of each scope. This patch switches the dominates method to
examine whether a block is present in a scope's InsnRanges, avoiding
walking through the whole block.

At the same time, fix getMachineBasicBlocks to account for the fact that
InsnRanges can cover multiple blocks, and add some unit tests, as Lexical
Scopes didn't have any.

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

4 years agoLet EarlyCSE fold equivalent freeze instructions
Juneyoung Lee [Fri, 28 Feb 2020 09:47:57 +0000 (18:47 +0900)]
Let EarlyCSE fold equivalent freeze instructions

Summary:
This patch makes EarlyCSE fold equivalent freeze instructions.

Another optimization that I think will be useful is to remove freeze if its operand is used as a branch condition or at llvm.assume:

```
  %c = ...
  br i1 %c, label %A, ..
A:
  %d = freeze %c ; %d can be optimized to %c because %c cannot be poison or undef (or 'br %c' would be UB otherwise)
```

If it make sense for EarlyCSE to support this as well, I will make a patch for this.

Reviewers: spatel, reames, lebedev.ri

Reviewed By: lebedev.ri

Subscribers: lebedev.ri, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[LLD][ELF][ARM] Implement Thumb pc-relative relocations for adr and ldr
Peter Smith [Sun, 23 Feb 2020 19:46:46 +0000 (19:46 +0000)]
[LLD][ELF][ARM] Implement Thumb pc-relative relocations for adr and ldr

MC will now output the R_ARM_THM_PC8, R_ARM_THM_PC12 and
R_ARM_THM_PREL_11_0 relocations. These are short-ranged relocations that
are used to implement the adr rd, literal and ldr rd, literal pseudo
instructions.

The instructions use a new RelExpr called R_ARM_PCA in order to calculate
the required S + A - Pa expression, where Pa is AlignDown(P, 4) as the
instructions add their immediate to AlignDown(PC, 4). We also do not want
these relocations to generate or resolve against a PLT entry as the range
of these relocations is so short they would never reach.

The R_ARM_THM_PC8 has a special encoding convention for the relocation
addend, the immediate field is unsigned, yet the addend must be -4 to
account for the Thumb PC bias. The ABI (not the architecture) uses the
convention that the 8-byte immediate of 0xff represents -4.

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

4 years ago[MC][ELF][ARM] Add relocations for some pc-relative fixups
Peter Smith [Sun, 23 Feb 2020 10:49:51 +0000 (10:49 +0000)]
[MC][ELF][ARM] Add relocations for some pc-relative fixups

Add ELF relocations for the following fixups:
fixup_thumb_adr_pcrel_10 -> R_ARM_THM_PC8
fixup_thumb_cp -> R_ARM_THM_PC8
fixup_t2_adr_pcrel_12 -> R_ARM_THM_PREL_11_0
fixup_t2_ldst_pcrel_12 -> R_ARM_THM_PC12

While these relocations are short-ranged there is support in the open
source ELF linker's in binutils and soon to be in LLD. MC will no longer
resolve pc-relative fixups to global symbols due to interpositioning
concerns. We can handle these at link time by implementing the relocations.

The R_ARM_THM_PC8 has some extra encoding rules for addends that llvm-mc
sidesteps by not supporting addends for these instructions, using the wide
Thumb 2 instruction if it is available. I think that this is a reasonable
compromise given that these are rare.

This partiall reverts D72892, the Thumb fixups no longer need to be
evaluated at assembly time.

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

4 years ago[NFC][ARM] Add tests
Sam Parker [Fri, 28 Feb 2020 11:22:09 +0000 (11:22 +0000)]
[NFC][ARM] Add tests

4 years ago[AMDGPU] Precommit some scheduler related test updates
Jay Foad [Thu, 27 Feb 2020 21:16:46 +0000 (21:16 +0000)]
[AMDGPU] Precommit some scheduler related test updates

Summary:
The point of this is to make some tests with manual checks robust
against scheduler tweaks, so that only autogenerated test updates will
be required when pushing D68338 "[AMDGPU] Remove dubious logic in
bidirectional list scheduler".

Reviewers: arsenm, rampitec, vpykhtin

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

Tags: #llvm

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

4 years ago[RDA] Track implicit-defs
Sam Parker [Fri, 28 Feb 2020 11:14:42 +0000 (11:14 +0000)]
[RDA] Track implicit-defs

Ensure that we're recording implicit defs, as well as visiting implicit
uses and implicit defs when we're walking through operands.

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

4 years ago[clang-format] Recognize C# nullable types
Jonathan Coe [Fri, 28 Feb 2020 10:26:40 +0000 (10:26 +0000)]
[clang-format] Recognize C# nullable types

Summary:
Do not confuse C# nullable types with conditional expressions.

Do not put a space before the `?` in `[access-modifier] Type? variableName;`

Reviewers: krasimir, MyDeveloperDay

Reviewed By: krasimir, MyDeveloperDay

Subscribers: cfe-commits, MyDeveloperDay

Tags: #clang-format, #clang

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

4 years ago[ARM][Thumb2] support .w assembler qualifier for dmb/dsb/isb
Stefan Agner [Fri, 28 Feb 2020 11:03:14 +0000 (11:03 +0000)]
[ARM][Thumb2] support .w assembler qualifier for dmb/dsb/isb

Support the explicit wide assembler qualifier for the dmb/dsb/isb synchronization barrier instructions.

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

4 years ago[ARM][Thumb2] Support .w assembler qualifier for pld/pldw/pli
Stefan Agner [Fri, 28 Feb 2020 10:55:53 +0000 (10:55 +0000)]
[ARM][Thumb2] Support .w assembler qualifier for pld/pldw/pli

Accept explicit wide assembler qualifier for the pld/pldw/pli.

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

4 years ago[NFC] [Test commit] Testing commit access with new email
Djordje Todorovic [Fri, 28 Feb 2020 11:00:34 +0000 (12:00 +0100)]
[NFC] [Test commit] Testing commit access with new email

4 years ago[mlir] Fix the build by using correct symbol name
Kirill Bobyrev [Fri, 28 Feb 2020 10:30:19 +0000 (11:30 +0100)]
[mlir] Fix the build by using correct symbol name

s/ArrayRef/llvm::ArrayRef/g since it's outside llvm namespace.

Related revision: 9227a74b7e8ff9b9cb5924e03547b940dc06e331

4 years ago[DWARFLinker][NFC] Remove usages of "const object::ObjectFile" from DWARFLinker.
Alexey Lapshin [Sat, 22 Feb 2020 11:33:58 +0000 (14:33 +0300)]
[DWARFLinker][NFC] Remove usages of "const object::ObjectFile" from DWARFLinker.

Summary:
DWARFContext has all the required information to access source debug info.
It is not necessary to use "const object::ObjectFile" to create DWARFContext.
Thus this patch removes all usages of "const object::ObjectFile"
from DWARFLinker. Instead, already created DWARFContext is passed
to DWARFLinker. The purpose is to not depend on "const object::ObjectFile".

The patch looks big, but most of changes are renamings and movements.

Testing: it passes "check-all" lit testing. MD5 checksum for clang .dSYM bundle
matches for the dsymutil with/without that patch.

Reviewers: JDevlieghere, friss, dblaikie, aprantl

Reviewed By: JDevlieghere

Subscribers: hiraditya, llvm-commits

Tags: #llvm, #debug-info

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

4 years ago[debuginfo-tests][dexter] Add a test tool --calculate-average option
Pierre-vh [Wed, 26 Feb 2020 14:46:51 +0000 (14:46 +0000)]
[debuginfo-tests][dexter] Add a test tool --calculate-average option

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

4 years ago[lldb] Use llvm MC as the source of dwarf/eh register numbers for X86 ABIs
Pavel Labath [Fri, 28 Feb 2020 09:46:48 +0000 (10:46 +0100)]
[lldb] Use llvm MC as the source of dwarf/eh register numbers for X86 ABIs

x86_64 ABIs were converted with 07355c1c0. This does the same with i386.

4 years agoSROA: Don't drop atomic load/store alignments (PR45010)
Hans Wennborg [Thu, 27 Feb 2020 16:01:09 +0000 (17:01 +0100)]
SROA: Don't drop atomic load/store alignments (PR45010)

SROA will drop the explicit alignment on allocas when the ABI guarantees
enough alignment. Because the alignment on new load/store instructions
are set based on the alloca's alignment, that means SROA would end up
dropping the alignment from atomic loads and stores, which is not
allowed (see bug). For those, make sure to always carry over the
alignment from the previous instruction.

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

4 years agoNo longer generate calls to *_finite
serge-sans-paille [Fri, 21 Feb 2020 14:51:19 +0000 (15:51 +0100)]
No longer generate calls to *_finite

According to Joseph Myers, a libm maintainer

> They were only ever an ABI (selected by use of -ffinite-math-only or
> options implying it, which resulted in the headers using "asm" to redirect
> calls to some libm functions), not an API. The change means that ABI has
> turned into compat symbols (only available for existing binaries, not for
> anything newly linked, not included in static libm at all, not included in
> shared libm for future glibc ports such as RV32), so, yes, in any case
> where tools generate direct calls to those functions (rather than just
> following the "asm" annotations on function declarations in the headers),
> they need to stop doing so.

As a consequence, we should no longer assume these symbols are available on the
target system.

Still keep the TargetLibraryInfo for constant folding.

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

4 years agollvm-ar: Fix MinGW compilation
Hans Wennborg [Fri, 28 Feb 2020 08:59:24 +0000 (09:59 +0100)]
llvm-ar: Fix MinGW compilation

llvm-ar is using CompareStringOrdinal which is available
only starting with Windows Vista (WINVER 0x600).

Fix this by hoising WindowsSupport.h, which sets _WIN32_WINNT
to 0x0601, up to llvm/include/llvm/Support and use it in llvm-ar.

Patch by Cristian Adam!

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

4 years ago[ASTImporter] Improved import of AlignedAttr.
Balázs Kéri [Fri, 28 Feb 2020 07:32:32 +0000 (08:32 +0100)]
[ASTImporter] Improved import of AlignedAttr.

Summary:
It is not enough to clone the attributes at import.
They can contain reference to objects that should be imported.
This work is done now for AlignedAttr.

Reviewers: martong, a.sidorin, shafik

Reviewed By: shafik

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

Tags: #clang

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

4 years ago[clangd] Get rid of lexer usage in ObjCLocalizeStringLiteral tweak
Kadir Cetinkaya [Thu, 27 Feb 2020 09:35:14 +0000 (10:35 +0100)]
[clangd] Get rid of lexer usage in ObjCLocalizeStringLiteral tweak

Reviewers: hokein

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

Tags: #clang

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

4 years ago[clangd] Use tokenize instead of raw lexer in SourceCode/lex
Kadir Cetinkaya [Thu, 27 Feb 2020 14:10:54 +0000 (15:10 +0100)]
[clangd] Use tokenize instead of raw lexer in SourceCode/lex

Reviewers: hokein, sammccall

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

Tags: #clang

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

4 years ago[DebugInfo] Fix parsing DWARF64 units in DWP.
Igor Kudrin [Wed, 26 Feb 2020 15:02:33 +0000 (22:02 +0700)]
[DebugInfo] Fix parsing DWARF64 units in DWP.

The integrity check code allowed only DWARF32 units.

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

4 years ago[DebugInfo] Avoid crashing when parsing an invalid unit header in DWP.
Igor Kudrin [Wed, 26 Feb 2020 14:23:43 +0000 (21:23 +0700)]
[DebugInfo] Avoid crashing when parsing an invalid unit header in DWP.

The integrity checks for index entries in DWARFUnitHeader::extract()
might cause the function to return before checking the state of an
Error object, which leads to a crash in runtime. The patch fixes the
issue by moving the checks in a safe place.

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

4 years ago[DataExtractor] Improve error message when we run off the end of the buffer
Pavel Labath [Thu, 27 Feb 2020 15:22:12 +0000 (16:22 +0100)]
[DataExtractor] Improve error message when we run off the end of the buffer

Summary: Include the offset at which this happened.

Reviewers: dblaikie, jhenderson

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years agobuild: process the libxml2 library path for embedding
Saleem Abdulrasool [Fri, 28 Feb 2020 03:23:57 +0000 (19:23 -0800)]
build: process the libxml2 library path for embedding

Process the path for libxml2 before embedding that into the command line
that is generated in `llvm-config`.  Each element in the path is being
given a `-l` unconditionally which should not be the case for absolute
paths.  Since the library path may be absolute or not, just apply some
CMake pre-processing when generating the path.

Before:
```
/usr/lib/x86_64-linux-gnu/libz.so -lrt -ldl -ltinfo -lpthread -lm /usr/lib/x86_64-linux-gnu/libxml2.so
```

After:
```
/usr/lib/x86_64-linux-gnu/libz.so -lrt -ldl -ltinfo -lpthread -lm -lxml2
```

Resolves PR44179!

4 years ago[X86] Add FMA commuting test case for D75016
Craig Topper [Sun, 23 Feb 2020 08:21:34 +0000 (00:21 -0800)]
[X86] Add FMA commuting test case for D75016

This test case shows extra moves due to not fully considering all
commuting opportunities.

4 years ago[Coroutines] CoroElide enhancement
Jun Ma [Fri, 28 Feb 2020 02:12:11 +0000 (10:12 +0800)]
[Coroutines] CoroElide enhancement

Fix regression of CoreElide pass when current function is
coroutine.

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

4 years agoRevert "[SimpleLoopUnswitch] Fix introduction of UB when hoisted condition may be...
Juneyoung Lee [Fri, 28 Feb 2020 02:08:14 +0000 (11:08 +0900)]
Revert "[SimpleLoopUnswitch] Fix introduction of UB when hoisted condition may be undef or poison"

.. due to performance regression.

This patch is reverted until infrastructore for CSE/LICM support for freeze is
added.

This reverts commit 181628b

4 years ago[mlir][Tutorial] Fix comment position in SimplifyRedundantTranspose.
Matthias Kramm [Fri, 28 Feb 2020 01:54:22 +0000 (17:54 -0800)]
[mlir][Tutorial] Fix comment position in SimplifyRedundantTranspose.

Summary:
This is a cosmetic change to make the "bingo" comment be in the
right place.

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

4 years ago[mlir] Fix/Clarify parts of MLIR toy tutorial chapter 6+7
Matthias Kramm [Fri, 28 Feb 2020 01:53:03 +0000 (17:53 -0800)]
[mlir] Fix/Clarify parts of MLIR toy tutorial chapter 6+7

Summary:
* add missing comma.
* remove "having to register them here" phrasing, since register it
  is what we're doing, which made the comment a bit confusing.
* remove duplicate code.
* clarify link to chapter 3, since "folder" doesn't appear in that
  chapter.

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

4 years agoFix/Clarify parts of MLIR toy tutorial chapter 5
Matthias Kramm [Fri, 28 Feb 2020 01:52:24 +0000 (17:52 -0800)]
Fix/Clarify parts of MLIR toy tutorial chapter 5

Summary:
* Use bold font (not monospace) for legal/illegal.
* Say a few words about operation<->dialect precedence.
* Omit duplicate code samples.
* Indent items in bullet-point list.

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

4 years ago[mlir] Fix/clarify parts of MLIR toy tutorial chaper 4.
Matthias Kramm [Fri, 28 Feb 2020 01:51:34 +0000 (17:51 -0800)]
[mlir] Fix/clarify parts of MLIR toy tutorial chaper 4.

Summary:
* Let's use "override" when we're just doing standard baseclassing.
  ("Specialization" makes it sound like template specialization, which
   this is not.)
* CallInterfaces.td has an include guard, so #ifdef not needed anymore.
* Omit duplicate code in code samples.
* Clarify which algorithm we're talking about.
* Mention that the ShapeInference code is code a snippet that belongs to
  algorithm discussed in the paragraph above it.
* Add missing definition for createShapeInferencePass.

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

4 years ago[mlir] Fix comma+typo in MLIR toy tutorial chapter 3.
Matthias Kramm [Fri, 28 Feb 2020 01:50:41 +0000 (17:50 -0800)]
[mlir] Fix comma+typo in MLIR toy tutorial chapter 3.

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

4 years ago[mlir] Clarify/Fix parts of MLIR toy tutorial chapter 2
Matthias Kramm [Fri, 28 Feb 2020 01:49:31 +0000 (17:49 -0800)]
[mlir] Clarify/Fix parts of MLIR toy tutorial chapter 2

Summary:
* clarify what "registering" means.
* clarify Op dereferencing
* clarify override/virtual phrasing
* omit duplication in code samples
* fix OpAsmPrinter comment

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

4 years ago[IndVars] Fix sort comparator.
Eli Friedman [Sat, 22 Feb 2020 00:00:04 +0000 (16:00 -0800)]
[IndVars] Fix sort comparator.

std::sort will compare an element to itself in some cases.  We should
not crash if this happens.

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

4 years agoAdd missing cstdint include not found on Windows
Reid Kleckner [Fri, 28 Feb 2020 01:24:50 +0000 (17:24 -0800)]
Add missing cstdint include not found on Windows

4 years ago[Support] Remove byte swapping from MathExtras.h
Reid Kleckner [Fri, 28 Feb 2020 01:06:48 +0000 (17:06 -0800)]
[Support] Remove byte swapping from MathExtras.h

MathExtras.h was just wrapping SwapByteOrder.h functionality, so have
the callers use it directly.  Use the MathExtras.h name (ByteSwap_NN) as
the standard naming, since it appears to be the most popular.

4 years ago[DFSan] Add flag to insert event callbacks.
Matt Morehouse [Fri, 28 Feb 2020 01:13:59 +0000 (17:13 -0800)]
[DFSan] Add flag to insert event callbacks.

Summary:
For now just insert the callback for stores, similar to how MSan tracks
origins.  In the future we may want to add callbacks for loads, memcpy,
function calls, CMPs, etc.

Reviewers: pcc, vitalybuka, kcc, eugenis

Reviewed By: vitalybuka, kcc, eugenis

Subscribers: eugenis, hiraditya, #sanitizers, llvm-commits, kcc

Tags: #sanitizers, #llvm

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

4 years agoChange test to use -S so it works when an external assembler is used that is not...
Douglas Yung [Fri, 28 Feb 2020 00:51:57 +0000 (16:51 -0800)]
Change test to use -S so it works when an external assembler is used that is not present in the testing environment.

4 years ago[DFSan] Remove unused IRBuilder. NFC
Matt Morehouse [Fri, 28 Feb 2020 00:26:21 +0000 (16:26 -0800)]
[DFSan] Remove unused IRBuilder. NFC

Reviewers: pcc, vitalybuka, kcc

Reviewed By: kcc

Subscribers: hiraditya, llvm-commits, kcc

Tags: #llvm

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

4 years agoNeed /bigobj to build SourceCodeTest.cpp with MSVC.
Adrian McCarthy [Thu, 27 Feb 2020 22:33:24 +0000 (14:33 -0800)]
Need /bigobj to build SourceCodeTest.cpp with MSVC.

4 years agoFix DSE miscompile when store is clobbered across loop iterations
Artur Pilipenko [Fri, 21 Feb 2020 22:40:22 +0000 (14:40 -0800)]
Fix DSE miscompile when store is clobbered across loop iterations

DSE would mistakenly remove store (2):

  a = calloc(n+1)
  for (int i = 0; i < n; i++) {
    store 1, a[i+1] // (1)
    store 0, a[i]   // (2)
  }

The fix is to do PHI transaltion while looking for clobbering
instructions between the store and the calloc.

Reviewed By: efriedma, bjope

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

4 years agoAvoid ASTContext.h -> TargetInfo.h dep
Reid Kleckner [Thu, 27 Feb 2020 22:16:47 +0000 (14:16 -0800)]
Avoid ASTContext.h -> TargetInfo.h dep

This has been done before in 2008: ab13857072
But these things regress easily.
Move some things out of line.

Saves 316 includes + transitive stuff:
    316 -    ../clang/include/clang/Basic/TargetOptions.h
    316 -    ../clang/include/clang/Basic/TargetInfo.h
    316 -    ../clang/include/clang/Basic/TargetCXXABI.h
    316 -    ../clang/include/clang/Basic/OpenCLOptions.h
    316 -    ../clang/include/clang/Basic/OpenCLExtensions.def
    302 -    ../llvm/include/llvm/Target/TargetOptions.h
    302 -    ../llvm/include/llvm/Support/CodeGen.h
    302 -    ../llvm/include/llvm/MC/MCTargetOptions.h
    302 -    ../llvm/include/llvm/ADT/FloatingPointMode.h
    302 -    ../clang/include/clang/Basic/XRayInstr.h
    302 -    ../clang/include/clang/Basic/DebugInfoOptions.h
    302 -    ../clang/include/clang/Basic/CodeGenOptions.h
    302 -    ../clang/include/clang/Basic/CodeGenOptions.def
    257 -    ../llvm/include/llvm/Support/Regex.h
     79 -    ../llvm/include/llvm/ADT/SmallSet.h
     68 -    MSVCSTL/include/set
     66 -    ../llvm/include/llvm/ADT/SmallPtrSet.h
     62 -    ../llvm/include/llvm/ADT/StringSwitch.h

4 years ago[llvm-exegesis] Remove unnecessary deletion of an assignment operator of WrappingIter...
Craig Topper [Thu, 27 Feb 2020 22:15:03 +0000 (14:15 -0800)]
[llvm-exegesis] Remove unnecessary deletion of an assignment operator of WrappingIterator that angers some versions of MSVC

The deletion of the const WrappingIterator & should already cover this.

4 years agoAdd some missing header dependencies
Reid Kleckner [Thu, 27 Feb 2020 22:32:10 +0000 (14:32 -0800)]
Add some missing header dependencies

Unit tests are not part of `all` O_O, and I tested on Windows with
-fdelayed-template-parsing.

4 years ago[libc++] Update compiler images and more docker cleanup.
Eric Fiselier [Thu, 27 Feb 2020 22:22:16 +0000 (17:22 -0500)]
[libc++] Update compiler images and more docker cleanup.

4 years agounittest: Convert EXPECT_EQ iterator checks to use EXPECT_TRUE instead
Vedant Kumar [Thu, 27 Feb 2020 22:19:42 +0000 (14:19 -0800)]
unittest: Convert EXPECT_EQ iterator checks to use EXPECT_TRUE instead

Hopefully fixes compile errors on some bots, like:

http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/13383/steps/ninja%20check%201/logs/stdio

/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/unittests/ADT/CoalescingBitVectorTest.cpp:452:3:   required from here
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/utils/unittest/googletest/include/gtest/gtest-printers.h:377:56: error: â€˜const class llvm::CoalescingBitVector<long unsigned int>::const_iterator’ has no member named â€˜begin’
   for (typename C::const_iterator it = container.begin();
                                                        ^
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/utils/unittest/googletest/include/gtest/gtest-printers.h:378:11: error: â€˜const class llvm::CoalescingBitVector<long unsigned int>::const_iterator’ has no member named â€˜end’
        it != container.end(); ++it, ++count) {
           ^

4 years agoUpdate Sanitizer tests for Android R.
Mitch Phillips [Thu, 27 Feb 2020 22:15:09 +0000 (14:15 -0800)]
Update Sanitizer tests for Android R.

Summary:
Sanitizer tests don't entirely pass on an R device. Fix up all the
incompatibilities with the new system.

Reviewers: eugenis, pcc

Reviewed By: eugenis

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years agoAvoid SourceManager.h include in RawCommentList.h, add missing incs
Reid Kleckner [Thu, 27 Feb 2020 19:01:58 +0000 (11:01 -0800)]
Avoid SourceManager.h include in RawCommentList.h, add missing incs

SourceManager.h includes FileManager.h, which is expensive due to
dependencies on LLVM FS headers.

Remove dead BeforeThanCompare specialization.

Sink ASTContext::addComment to cpp file.

This reduces the time to compile a file that does nothing but include
ASTContext.h from ~3.4s to ~2.8s for me.

Saves these includes:
    219 -    ../clang/include/clang/Basic/SourceManager.h
    204 -    ../clang/include/clang/Basic/FileSystemOptions.h
    204 -    ../clang/include/clang/Basic/FileManager.h
    165 -    ../llvm/include/llvm/Support/VirtualFileSystem.h
    164 -    ../llvm/include/llvm/Support/SourceMgr.h
    164 -    ../llvm/include/llvm/Support/SMLoc.h
    161 -    ../llvm/include/llvm/Support/Path.h
    141 -    ../llvm/include/llvm/ADT/BitVector.h
    128 -    ../llvm/include/llvm/Support/MemoryBuffer.h
    124 -    ../llvm/include/llvm/Support/FileSystem.h
    124 -    ../llvm/include/llvm/Support/Chrono.h
    124 -    .../MSVCSTL/include/stack
    122 -    ../llvm/include/llvm-c/Types.h
    122 -    ../llvm/include/llvm/Support/NativeFormatting.h
    122 -    ../llvm/include/llvm/Support/FormatProviders.h
    122 -    ../llvm/include/llvm/Support/CBindingWrapping.h
    122 -    .../MSVCSTL/include/xtimec.h
    122 -    .../MSVCSTL/include/ratio
    122 -    .../MSVCSTL/include/chrono
    121 -    ../llvm/include/llvm/Support/FormatVariadicDetails.h
    118 -    ../llvm/include/llvm/Support/MD5.h
    109 -    .../MSVCSTL/include/deque
    105 -    ../llvm/include/llvm/Support/Host.h
    105 -    ../llvm/include/llvm/Support/Endian.h

Reviewed By: aaron.ballman, hans

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

4 years ago[libc++] Update lld version on buildbots to be LLVM-11.
Eric Fiselier [Thu, 27 Feb 2020 21:27:32 +0000 (16:27 -0500)]
[libc++] Update lld version on buildbots to be LLVM-11.

4 years ago[lldb/CMake] Use PYTHON_HOME as a hint to find Python 3.
Jonas Devlieghere [Thu, 27 Feb 2020 21:17:19 +0000 (13:17 -0800)]
[lldb/CMake] Use PYTHON_HOME as a hint to find Python 3.

http://lists.llvm.org/pipermail/lldb-dev/2020-February/015998.html

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

4 years agounittest: Disable checks to work around compiler errors
Vedant Kumar [Thu, 27 Feb 2020 21:02:42 +0000 (13:02 -0800)]
unittest: Disable checks to work around compiler errors

On some bots, using gtest asserts to compare iterators does not compile,
and I'm not sure why (this certainly compiles with clang). Disable the
checks for now :/.

```
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\utils\unittest\googletest\include\gtest/gtest-printers.h(377): error C2039: 'begin': is not a member of 'llvm::CoalescingBitVector<unsigned int,16>::const_iterator'
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\include\llvm/ADT/CoalescingBitVector.h(243): note: see declaration of 'llvm::CoalescingBitVector<unsigned int,16>::const_iterator'
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\utils\unittest\googletest\include\gtest/gtest-printers.h(478): note: see reference to function template instantiation 'void testing::internal::DefaultPrintTo<T>(testing::internal::IsContainer,testing::internal::false_type,const C &,std::ostream *)' being compiled
        with
        [
            T=T1,
            C=T1
        ]
```

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-win-fast/builds/12006/steps/test-check-llvm-unit/logs/stdio
http://lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/34521/steps/ninja%20check%201/logs/stdio

4 years ago[AMDGPU] Enable runtime unroll for LDS
Stanislav Mekhanoshin [Thu, 27 Feb 2020 20:36:40 +0000 (12:36 -0800)]
[AMDGPU] Enable runtime unroll for LDS

We want to do unroll for LDS even for runtime trip count
to combine LDS operations.

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

4 years ago[gn build] Port b0142cd9867
LLVM GN Syncbot [Thu, 27 Feb 2020 20:40:16 +0000 (20:40 +0000)]
[gn build] Port b0142cd9867

4 years ago[LiveDebugValues] Encode register location within VarLoc IDs [3/3]
Vedant Kumar [Fri, 21 Feb 2020 02:23:01 +0000 (18:23 -0800)]
[LiveDebugValues] Encode register location within VarLoc IDs [3/3]

This is part 3 of a 3-part series to address a compile-time explosion
issue in LiveDebugValues.

---

Start encoding register locations within VarLoc IDs, and take advantage
of this encoding to speed up transferRegisterDef.

There is no fundamental algorithmic change: this patch simply swaps out
SparseBitVector in favor of CoalescingBitVector. That changes iteration
order (hence the test updates), but otherwise this patch is NFCI.

The only interesting change is in transferRegisterDef. Instead of doing:

```
KillSet = {}
for (ID : OpenRanges.getVarLocs())
  if (DeadRegs.count(ID))
    KillSet.add(ID)
```

We now do:

```
KillSet = {}
for (Reg : DeadRegs)
  for (ID : intervalsReservedForReg(Reg, OpenRanges.getVarLocs()))
    KillSet.add(ID)
```

By not visiting each open location every time we visit an instruction,
this eliminates some potentially quadratic behavior. The new
implementation basically does a constant amount of work per instruction
because the interval map lookups are very fast.

For a file in WebKit, this brings the time spent in LiveDebugValues down
from ~2.5 minutes to 4 seconds, reducing compile time spent in that pass
from 28% of the total to just over 1%.

Before:

```
2.49 min   27.8% 0 s LiveDebugValues::process
2.41 min   27.0% 5.40 s LiveDebugValues::transferRegisterDef
1.51 min   16.9% 1.51 min LiveDebugValues::VarLoc::isDescribedByReg() const
32.73 s    6.1% 8.70 s  llvm::SparseBitVector<128u>::SparseBitVectorIterator::operator++()
```

After:

```
4.53 s 1.1% 0 s LiveDebugValues::process
3.00 s 0.7% 107.00 ms LiveDebugValues::transferRegisterCopy
892.00 ms 0.2% 406.00 ms LiveDebugValues::transferSpillOrRestoreInst
404.00 ms 0.1% 32.00 ms LiveDebugValues::transferRegisterDef
110.00 ms 0.0% 2.00 ms   LiveDebugValues::getUsedRegs
57.00 ms 0.0% 1.00 ms   std::__1::vector<>::push_back
40.00 ms 0.0% 1.00 ms   llvm::CoalescingBitVector<>::find(unsigned long long)
```

FWIW, I tried the same approach using SparseBitVector, but got bad
results. To do that, I had to extend SparseBitVector to support 64-bit
indices and expose its lower bound operation. The problem with this is
that the performance is very hard to predict: SparseBitVector's lower
bound operation falls back to O(n) linear scans in a std::list if you're
not /very/ careful about managing iteration order. When I profiled this
the performance looked worse than the baseline.

You can see the full CoalescingBitVector-based implementation here:

  https://github.com/vedantk/llvm-project/commits/try-coalescing

You can see the full SparseBitVector-based implementation here:

  https://github.com/vedantk/llvm-project/commits/try-sparsebitvec-find

Depends on D74984 and D74985.

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

4 years ago[LiveDebugValues] Encode a location in VarLoc IDs, NFC [2/3]
Vedant Kumar [Thu, 20 Feb 2020 17:40:27 +0000 (09:40 -0800)]
[LiveDebugValues] Encode a location in VarLoc IDs, NFC [2/3]

This is part 2 of a 3-part series to address a compile-time explosion
issue in LiveDebugValues.

---

Each VarLoc has a unique ID: this ID is used to look up a VarLoc in the
VarLocMap, and to virtually insert a VarLoc into a VarLocSet. Instead of
inserting the VarLoc /itself/ into the VarLocSet, we insert just the ID,
because this can be represented efficiently with a SparseBitVector.

This change introduces LocIndex, a layer of abstraction on top of VarLoc
IDs. Prior to this change, an ID was just an index into a vector. With
this change, an ID encodes both an index /and/ a register location. The
type-checker ensures that conversions to and from LocIndex are correct.

For the moment the register location is always 0 (undef). We have plenty
of bits left over to encode physregs, stack slots, and other locations
in the future.

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

4 years ago[ADT] Add CoalescingBitVector, implemented using IntervalMap [1/3]
Vedant Kumar [Tue, 18 Feb 2020 13:41:55 +0000 (05:41 -0800)]
[ADT] Add CoalescingBitVector, implemented using IntervalMap [1/3]

Add CoalescingBitVector to ADT. This is part 1 of a 3-part series to
address a compile-time explosion issue in LiveDebugValues.

---

CoalescingBitVector is a bitvector that, under the hood, relies on an
IntervalMap to coalesce elements into intervals.

CoalescingBitVector efficiently represents sets which predominantly
contain contiguous ranges (e.g.  the VarLocSets in LiveDebugValues,
which are very long sequences that look like {1, 2, 3, ...}). OTOH,
CoalescingBitVector isn't good at representing sets with lots of gaps
between elements. The first N coalesced intervals of set bits are stored
in-place (in the initial heap allocation).

Compared to SparseBitVector, CoalescingBitVector offers more predictable
performance for non-sequential find() operations. This provides a
crucial speedup in LiveDebugValues.

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

4 years ago[libc++] Rework docker files for buildbots.
Eric Fiselier [Thu, 27 Feb 2020 20:16:30 +0000 (15:16 -0500)]
[libc++] Rework docker files for buildbots.

I've been sitting on this change for a while and have been using
it to build the bot images, so it should be upstream.

This re-configures the docker build files to use docker-compose
more heavily. This allows for composing large images with multiple
compilers without invalidating the docker caches.

After this commit I'll quickly switch all the current buildbots
over to a new docker image, followed by another update to add new
compilers

4 years ago[x86] use instruction-level fast-math-flags to drive MachineCombiner
Sanjay Patel [Thu, 27 Feb 2020 20:19:37 +0000 (15:19 -0500)]
[x86] use instruction-level fast-math-flags to drive MachineCombiner

The code changes here are hopefully straightforward:

1. Use MachineInstruction flags to decide if FP ops can be reassociated
   (use both "reassoc" and "nsz" to be consistent with IR transforms;
   we probably don't need "nsz", but that's a safer interpretation of
   the FMF).
2. Check that both nodes allow reassociation to change instructions.
   This is a stronger requirement than we've usually implemented in
   IR/DAG, but this is needed to solve the motivating bug (see below),
   and it seems unlikely to impede optimization at this late stage.
3. Intersect/propagate MachineIR flags to enable further reassociation
   in MachineCombiner.

We managed to make MachineCombiner flexible enough that no changes are
needed to that pass itself. So this patch should only affect x86
(assuming no other targets have implemented the hooks using MachineIR
flags yet).

The motivating example in PR43609 is another case of fast-math transforms
interacting badly with special FP ops created during lowering:
https://bugs.llvm.org/show_bug.cgi?id=43609
The special fadd ops used for converting int to FP assume that they will
not be altered, so those are created without FMF.

However, the MachineCombiner pass was being enabled for FP ops using the
global/function-level TargetOption for "UnsafeFPMath". We managed to run
instruction/node-level FMF all the way down to MachineIR sometime in the
last 1-2 years though, so we can do better now.

The test diffs require some explanation:

1. llvm/test/CodeGen/X86/fmf-flags.ll - no target option for unsafe math was
   specified here, so MachineCombiner kicks in where it did not previously;
   to make it behave consistently, we need to specify a CPU schedule model,
   so use the default model, and there are no code diffs.
2. llvm/test/CodeGen/X86/machine-combiner.ll - replace the target option for
   unsafe math with the equivalent IR-level flags, and there are no code diffs;
   we can't remove the NaN/nsz options because those are still used to drive
   x86 fmin/fmax codegen (special SDAG opcodes).
3. llvm/test/CodeGen/X86/pow.ll - similar to #1
4. llvm/test/CodeGen/X86/sqrt-fastmath.ll - similar to #1, but MachineCombiner
   does some reassociation of the estimate sequence ops; presumably these are
   perf wins based on latency/throughput (and we get some reduction of move
   instructions too); I'm not sure how it affects numerical accuracy, but the
   test reflects reality better now because we would expect MachineCombiner to
   be enabled if the IR was generated via something like "-ffast-math" with clang.
5. llvm/test/CodeGen/X86/vec_int_to_fp.ll - this is the test added to model PR43609;
   the fadds are not reassociated now, so we should get the expected results.
6. llvm/test/CodeGen/X86/vector-reduce-fadd-fast.ll - similar to #1
7. llvm/test/CodeGen/X86/vector-reduce-fmul-fast.ll - similar to #1

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

4 years ago[AArch64] add splat shuffle combine test; NFC
Sanjay Patel [Thu, 27 Feb 2020 18:57:06 +0000 (13:57 -0500)]
[AArch64] add splat shuffle combine test; NFC

4 years ago[AArch64] regenerate complete test checks; NFC
Sanjay Patel [Thu, 27 Feb 2020 18:54:02 +0000 (13:54 -0500)]
[AArch64] regenerate complete test checks; NFC

4 years ago[LLDB] Fix AddressSanitizer failure in MemoryCache
Paolo Severini [Thu, 27 Feb 2020 19:17:10 +0000 (11:17 -0800)]
[LLDB] Fix AddressSanitizer failure in MemoryCache

The lldb sanitizer bot is flagging a container-overflow error after we
introduced test TestWasm.py. MemoryCache::Read didn't behave correctly
in case of partial reads that can happen with object files whose size is
smaller that the cache size. It should return the actual number of bytes
read and not try to fill the buffer with random memory.
Module::GetMemoryObjectFile needs to be modified accordingly, to resize
its buffer to only the size that was read.

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

4 years ago[mlir] NFC - Split out RunnerUtils that don't require a C++ runtime
Nicolas Vasilache [Thu, 27 Feb 2020 18:45:43 +0000 (13:45 -0500)]
[mlir] NFC - Split out RunnerUtils that don't require a C++ runtime

Summary:
This revision split out a new CRunnerUtils library that supports
MLIR execution on targets without a C++ runtime.

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

4 years ago[MLIR][Loops] Expose transformations on loop.parallel in header (NFC).
Stephan Herhut [Thu, 27 Feb 2020 09:48:02 +0000 (10:48 +0100)]
[MLIR][Loops] Expose transformations on loop.parallel in header (NFC).

Summary:
This change does not add any functionality but merely exposes existing
static functions to make the associated transformations available
outside of their testing passes.

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

4 years ago[MLIR] add show-dialects option for mlir-opt
Stephen Neuendorffer [Tue, 18 Feb 2020 22:56:45 +0000 (14:56 -0800)]
[MLIR] add show-dialects option for mlir-opt

Display the list of dialects known to mlir-opt.  This is useful
for ensuring that linkage has happened correctly, for instance.

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

4 years ago[clang-tidy] Store all ranges in clang::tooling::Diagnostic
Joe Turner [Tue, 25 Feb 2020 13:56:57 +0000 (14:56 +0100)]
[clang-tidy] Store all ranges in clang::tooling::Diagnostic

Summary: Instead of dropping all the ranges associated with a Diagnostic when
converting them to a ClangTidy error, instead attach them to the ClangTidyError,
so they can be consumed by other APIs.

Patch by Joe Turner <joturner@google.com>.
Differential Revision: https://reviews.llvm.org/D69782

4 years ago[XCOFF] Don't emit non-external labels in the symbol table and handle MCSA_LGlobal
David Tenty [Thu, 27 Feb 2020 15:43:27 +0000 (10:43 -0500)]
[XCOFF] Don't emit non-external labels in the symbol table and handle MCSA_LGlobal

Summary:
We need to handle the  MCSA_LGlobal case in emitSymbolAttribute for functions marked internal in the IR so that the
appropriate storage class is emitted on the function descriptor csect.  As part of this we need to make sure that external
labels are not emitted into the symbol table, so we don't emit the descriptor label in the object writing path.

Reviewers: jasonliu, DiggerLin, hubert.reinterpretcast

Reviewed By: jasonliu

Subscribers: Xiangling_L, wuzish, nemanjai, hiraditya, jsji, llvm-commits

Tags: #llvm

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

4 years ago[libc++] Mark more try_lock tests as possibly flaky.
Eric Fiselier [Wed, 26 Feb 2020 22:25:03 +0000 (17:25 -0500)]
[libc++] Mark more try_lock tests as possibly flaky.

These tests check that an operations happens within a specified
deadline, which causes flaky failures on slow machines or machines
under heavy load.

By adding the // FLAKY_TEST. tag it allows the test suite to
retry or ignore the tests

4 years agoForward declare FileEntry and DirectoryEntry in Module.h
Reid Kleckner [Thu, 27 Feb 2020 00:29:37 +0000 (16:29 -0800)]
Forward declare FileEntry and DirectoryEntry in Module.h

FileManager.h is an expensive header (~350ms for me in isolation), so
try to do without it.

Notably, we need to avoid checking the alignment of FileEntry, which
happens for DenseMap<FileEntry*> and PointerUnion<FileEntry*>. I
adjusted the code to avoid PointerUnion, and moved the DenseMap
insertion to the .cpp file.

Globally, this only saved about ~17 includes of the related headers
because SourceManager.h still includes FileManager.h, and it is more
popular than Module.h.

4 years agoForward declare special case lists
Reid Kleckner [Thu, 27 Feb 2020 01:24:52 +0000 (17:24 -0800)]
Forward declare special case lists

This avoids pulling in unordered_map from TrigramIndex.h:

$ diff -u thedeps-before.txt thedeps-after.txt | \
        grep '^[-+] ' | sort | uniq -c | sort -nr
    976 -    ../llvm/include/llvm/Support/TrigramIndex.h
    976 -    ../llvm/include/llvm/Support/SpecialCaseList.h
    976 -    ../clang/include/clang/Basic/SanitizerSpecialCaseList.h
    502 -    ../../../PROGRA~2/MIB055~1/2019/PROFES~1/VC/Tools/MSVC/14.24.28314/include/unordered_map
    467 -    ../../../PROGRA~2/MIB055~1/2019/PROFES~1/VC/Tools/MSVC/14.24.28314/include/xhash
    467 -    ../../../PROGRA~2/MIB055~1/2019/PROFES~1/VC/Tools/MSVC/14.24.28314/include/xbit_ops.h
    212 -    ../llvm/include/llvm/ADT/StringSet.h

4 years ago[AMDGPU] improve fragile test for divergent branches
Sameer Sahasrabuddhe [Thu, 27 Feb 2020 10:29:25 +0000 (15:59 +0530)]
[AMDGPU] improve fragile test for divergent branches

Summary:
The affected LIT test intends to test the correct use of divergence
analysis to detect a divergent branch with a uniform predicate. The
passes involved are LLVM IR passes, but the test runs llc and tries to
match against generated ISA, which makes it hard to demonstrate that
the intended behavior was really tested. Replaced this with a test
that invokes opt on the required passes and then checks for the
appropriate changes in the LLVM IR.

Reviewed By: arsenm

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

4 years ago[mlir] Hotfix - Rename MLIRRuntimeUtils to mlir_runtime_utils
Nicolas Vasilache [Thu, 27 Feb 2020 17:58:41 +0000 (12:58 -0500)]
[mlir] Hotfix - Rename MLIRRuntimeUtils to mlir_runtime_utils

4 years ago[InstCombine] DCE instructions earlier
Nikita Popov [Thu, 20 Feb 2020 21:42:42 +0000 (22:42 +0100)]
[InstCombine] DCE instructions earlier

When InstCombine initially populates the worklist, it already
performs constant folding and DCE. However, as the instructions
are initially visited in program order, this DCE can pick up only
the last instruction of a dead chain, the rest would only get
picked up in the main InstCombine run.

To avoid this, we instead perform the DCE in separate pass over the
collected instructions in reverse order, which will allow us to
pick up full dead instruction chains. We already need to do this
reverse iteration anyway to populate the worklist, so this
shouldn't add extra cost.

This by itself only fixes a small part of the problem though:
The same basic issue also applies during the main InstCombine loop.
We generally always want DCE to occur as early as possible,
because it will allow one-use folds to happen. Address this by also
performing DCE while adding deferred instructions to the main worklist.

This drops the number of tests that perform more than 2 InstCombine
iterations from ~80 to ~40. There's some spurious test changes due
to operand order / icmp toggling.

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

4 years agoAdd an attribute registry so plugins can add attributes
John Brawn [Fri, 7 Feb 2020 14:21:13 +0000 (14:21 +0000)]
Add an attribute registry so plugins can add attributes

When constructing a ParsedAttr the ParsedAttrInfo gets looked up in the
AttrInfoMap, which is auto-generated using tablegen. If that lookup fails then
we look through the ParsedAttrInfos that plugins have added to the registry and
check if any has a spelling that matches.

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

4 years agoRemove BinaryOperator::CreateFNeg
Simon Moll [Thu, 27 Feb 2020 17:05:54 +0000 (09:05 -0800)]
Remove BinaryOperator::CreateFNeg

Use UnaryOperator::CreateFNeg instead.

Summary:
With the introduction of the native fneg instruction, the
fsub -0.0, %x idiom is obsolete. This patch makes LLVM
emit fneg instead of the idiom in all places.

Reviewed By: cameron.mcinally

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

4 years agoRevert "[SYCL] Driver option to select SYCL version"
Alexey Bader [Thu, 27 Feb 2020 13:23:54 +0000 (16:23 +0300)]
Revert "[SYCL] Driver option to select SYCL version"

This reverts commit bd97704eaaaab5a95ecb048ce343c1a4be5d94e5.

It broke tests on mac: http://45.33.8.238/mac/9011/step_7.txt

4 years ago[Transforms][Debugify] Ignore PHI nodes when checking for DebugLocs
Pierre-vh [Thu, 27 Feb 2020 12:32:51 +0000 (12:32 +0000)]
[Transforms][Debugify] Ignore PHI nodes when checking for DebugLocs

Fix for: https://bugs.llvm.org/show_bug.cgi?id=37964

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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