platform/upstream/llvm.git
3 years ago[yaml2obj,obj2yaml] - Make Symbol::Section field optional.
Georgii Rymar [Thu, 3 Dec 2020 11:40:06 +0000 (14:40 +0300)]
[yaml2obj,obj2yaml] - Make Symbol::Section field optional.

This is similar to what we did earlier for fields of the Section class.

When a field is optional we can use the =<none> syntax in macros.

This was splitted from D92478.

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

3 years ago[lldb] Remove LLDB session dir and just store test traces in the respective test...
Raphael Isemann [Fri, 4 Dec 2020 10:42:36 +0000 (11:42 +0100)]
[lldb] Remove LLDB session dir and just store test traces in the respective test build directory

Test runs log some of their output to files inside the LLDB session dir. This
session dir is shared between all tests, so all the tests have to make sure they
choose a unique file name inside that directory. We currently choose by default
`<test-class-name>-<test-method-name>` as the log file name. However, that means
that if not every test class in the test suite has a unique class name, then we
end up with a race condition as two tests will try to write to the same log
file.

I already tried in D83767 changing the format to use the test file basename
instead (which we already require to be unique for some other functionality),
but it seems the code for getting the basename didn't work on Windows.

This patch instead just changes that dotest stores the log files in the build
directory for the current test. We know that directory is unique for this test,
so no need to generate some unique file name now. Also removes all the
environment vars and parameters related to the now unused session dir.

The new log paths now look like this for a failure in 'TestCppOperators`:
```
./lldb-test-build.noindex/lang/cpp/operators/TestCppOperators.test_dwarf/Failure.log
./lldb-test-build.noindex/lang/cpp/operators/TestCppOperators.test_dsym/Failure.log
./lldb-test-build.noindex/lang/cpp/operators/TestCppOperators.test_gmodules/Failure.log
```

Reviewed By: labath

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

3 years ago[llvm-readobj] - Report unique warnings in printProgramHeaders.
Georgii Rymar [Thu, 3 Dec 2020 12:07:28 +0000 (15:07 +0300)]
[llvm-readobj] - Report unique warnings in printProgramHeaders.

This converts `reportWarning` -> `reportUniqueWarning`

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

3 years ago[lldb][NFC] Rename TypeSystemClang::GetScratch to ScratchTypeSystemClang::GetForTarget
Raphael Isemann [Fri, 4 Dec 2020 09:26:03 +0000 (10:26 +0100)]
[lldb][NFC] Rename TypeSystemClang::GetScratch to ScratchTypeSystemClang::GetForTarget

Also add some documentation while I'm at it.

3 years ago[PowerPC] Fix the regression caused by commit 9c588f53fc42
QingShan Zhang [Fri, 4 Dec 2020 10:22:13 +0000 (10:22 +0000)]
[PowerPC] Fix the regression caused by commit 9c588f53fc42

Add a TypeLegal check for MVT::i1 and add the test.

3 years ago[DAGCombiner] Use const APInt& for getConstantOperandAPInt results. NFCI.
Simon Pilgrim [Thu, 3 Dec 2020 11:55:59 +0000 (11:55 +0000)]
[DAGCombiner] Use const APInt& for getConstantOperandAPInt results. NFCI.

Avoid unnecessary instantiation.

Noticed while removing unnecessary autos

3 years ago[X86] Remove unnecessary bitcast. NFC.
Simon Pilgrim [Thu, 3 Dec 2020 11:53:34 +0000 (11:53 +0000)]
[X86] Remove unnecessary bitcast. NFC.

The X86ISD::SUBV_BROADCAST node is already VT

3 years ago[X86] Regenerate midpoint-int.ll tests
Simon Pilgrim [Thu, 3 Dec 2020 11:52:27 +0000 (11:52 +0000)]
[X86] Regenerate midpoint-int.ll tests

Replace X32 check prefixes with X86 - X32 is generally used for gnux triple tests

3 years ago[libcxx] [test] Add a test for conversions between wchar_t, utf8, char16_t, char32_t...
Martin Storsjö [Sat, 24 Oct 2020 21:48:12 +0000 (00:48 +0300)]
[libcxx] [test] Add a test for conversions between wchar_t, utf8, char16_t, char32_t and windows native narrow code pages

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

3 years ago[libcxx] Implement c++2a char8_t input/output of std::filesystem::path
Martin Storsjö [Mon, 26 Oct 2020 11:18:46 +0000 (13:18 +0200)]
[libcxx] Implement c++2a char8_t input/output of std::filesystem::path

This implements the std::filesystem parts of P0482 (which is already
marked as in progress), and applies the actions that are suggested
in P1423.

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

3 years ago[clang] [Headers] Use the corresponding _aligned_free or __mingw_aligned_free in...
Martin Storsjö [Thu, 3 Dec 2020 11:58:04 +0000 (13:58 +0200)]
[clang] [Headers] Use the corresponding _aligned_free or __mingw_aligned_free in _mm_free

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

3 years ago[NFC][NARY-REASSOCIATE] Restructure code to aviod isPotentiallyReassociatable
Evgeniy Brevnov [Fri, 25 Sep 2020 04:46:20 +0000 (11:46 +0700)]
[NFC][NARY-REASSOCIATE] Restructure code to aviod isPotentiallyReassociatable

Currently we have to duplicate the same checks in isPotentiallyReassociatable and tryReassociate. With simple pattern like add/mul this may be not a big deal. But the situation gets much worse when I try to add support for min/max. Min/Max may be represented by several instructions and can take different forms. In order reduce complexity for upcoming min/max support we need to restructure the code a bit to avoid mentioned code duplication.

Reviewed By: mkazantsev

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

3 years ago[NARY-REASSOCIATE] Simplify traversal logic by post deleting dead instructions
Evgeniy Brevnov [Fri, 25 Sep 2020 04:37:19 +0000 (11:37 +0700)]
[NARY-REASSOCIATE] Simplify traversal logic by post deleting dead instructions

Currently we delete optimized instructions as we go. That has several negative consequences. First it complicates traversal logic itself. Second if newly generated instruction has been deleted the traversal is repeated from scratch.

But real motivation for the change is upcoming change with support for min/max reassociation. Here we employ SCEV expander to generate code. As a result newly generated instructions may be inserted not right before original instruction (because SCEV may do hoisting) and there is no way to know 'next' instruction.

Reviewed By: mkazantsev

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

3 years ago[lldb][NFC] Rename TypeSystemClangForExpressions to ScratchTypeSystemClang
Raphael Isemann [Fri, 4 Dec 2020 08:17:51 +0000 (09:17 +0100)]
[lldb][NFC] Rename TypeSystemClangForExpressions to ScratchTypeSystemClang

We keep referring to the single object created by this class as
'scratch AST/Context/TypeSystem' so at this point we might as well rename the
class. It's also not involved at all in expression evaluation, so the
'ForExpressions' prefix is a bit misleading.

3 years ago[clang] Add a C++17 deduction guide testcase.
Haojian Wu [Fri, 4 Dec 2020 08:02:04 +0000 (09:02 +0100)]
[clang] Add a C++17 deduction guide testcase.

From https://bugs.llvm.org/show_bug.cgi?id=47219.

It was crashing before the commit 1e14588d0f68.

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

3 years ago[JumpThreading] Call eraseBlock when folding a conditional branch
Kazu Hirata [Fri, 4 Dec 2020 07:50:17 +0000 (23:50 -0800)]
[JumpThreading] Call eraseBlock when folding a conditional branch

This patch teaches the jump threading pass to call BPI->eraseBlock
when it folds a conditional branch.

Without this patch, BranchProbabilityInfo could end up with stale edge
probabilities for the basic block containing the conditional branch --
one edge probability with less than 1.0 and the other for a removed
edge.

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

3 years ago[mlir][Linalg] Handle fusion on tensors for projected permutation.
Hanhan Wang [Fri, 4 Dec 2020 07:10:20 +0000 (23:10 -0800)]
[mlir][Linalg] Handle fusion on tensors for projected permutation.

In the past, the reshape op can be folded only if the indexing map is
permutation in consumer's usage. We can relax to condition to be projected
permutation.

This patch still limits the fusion for scalar cases. Scalar case is a corner
case, because we need to decide where to put extra dims.

Reviewed By: mravishankar

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

3 years ago[PowerPC] Pre-commit neg abs test for vector. NFC.
Kai Luo [Fri, 4 Dec 2020 06:42:30 +0000 (06:42 +0000)]
[PowerPC] Pre-commit neg abs test for vector. NFC.

3 years agoReturn "[IndVars] ICmpInst should not prevent IV widening"
Max Kazantsev [Fri, 4 Dec 2020 04:59:07 +0000 (11:59 +0700)]
Return "[IndVars] ICmpInst should not prevent IV widening"

This reverts commit 4bd35cdc3ae1874c6d070c5d410b3f591de54ee6.

The patch was reverted during the investigation. The investigation
shown that the patch did not cause any trouble, but just exposed
the existing problem that is addressed by the previous patch
"[IndVars] Quick fix LHS/RHS bug". Returning without changes.

3 years ago[IndVars] Quick fix LHS/RHS bug
Max Kazantsev [Fri, 4 Dec 2020 04:57:39 +0000 (11:57 +0700)]
[IndVars] Quick fix LHS/RHS bug

The code relies on fact that LHS is the NarrowDef but never
really checks it. Adding the conservative restrictive check,
will follow-up with handling of case where RHS is a NarrowDef.

3 years agoFix -allow-deprecated-dag-overlap in test/CodeGen/dso-local-executable.c
Fangrui Song [Fri, 4 Dec 2020 05:24:38 +0000 (21:24 -0800)]
Fix -allow-deprecated-dag-overlap in test/CodeGen/dso-local-executable.c

3 years agoPR48383: Disallow decltype(auto) in pseudodestructor calls
David Blaikie [Fri, 4 Dec 2020 04:40:37 +0000 (20:40 -0800)]
PR48383: Disallow decltype(auto) in pseudodestructor calls

3 years ago[tools] Update update_test_prefix.py to handle %s after prefixes
Mircea Trofin [Thu, 3 Dec 2020 05:32:28 +0000 (21:32 -0800)]
[tools] Update update_test_prefix.py to handle %s after prefixes

Sometimes the check-prefixes is followed by %s, and we want to keep a
white space before it.

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

3 years ago[NFC] [Clang] Fix ppc64le vaarg OpenMP test in CodeGen
Qiu Chaofan [Fri, 4 Dec 2020 03:28:18 +0000 (11:28 +0800)]
[NFC] [Clang] Fix ppc64le vaarg OpenMP test in CodeGen

Reviewed By: MaskRay

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

3 years ago[dfsan] Support passing non-i16 shadow values in TLS mode
Jianzhou Zhao [Wed, 2 Dec 2020 01:14:31 +0000 (01:14 +0000)]
[dfsan] Support passing non-i16 shadow values in TLS mode

This is a child diff of D92261.

It extended TLS arg/ret to work with aggregate types.

For a function
  t foo(t1 a1, t2 a2, ... tn an)
Its arguments shadow are saved in TLS args like
  a1_s, a2_s, ..., an_s
TLS ret simply includes r_s. By calculating the type size of each shadow
value, we can get their offset.

This is similar to what MSan does. See __msan_retval_tls and __msan_param_tls
from llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp.

Note that this change does not add test cases for overflowed TLS
arg/ret because this is hard to test w/o supporting aggregate shdow
types. We will be adding them after supporting that.

Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/D92440

3 years agoIntrusiveRefCntPtr: Ensure RefCount is initialized during ThreadSafeRefCountedBase...
David Blaikie [Fri, 4 Dec 2020 02:23:13 +0000 (18:23 -0800)]
IntrusiveRefCntPtr: Ensure RefCount is initialized during ThreadSafeRefCountedBase copy construction

Post commit feedback on 2e83ccc2ee33 from Nathan James!

3 years agoUse isIgnored instead of checking pass name
Arthur Eubanks [Fri, 4 Dec 2020 01:38:00 +0000 (17:38 -0800)]
Use isIgnored instead of checking pass name

In preparation for https://reviews.llvm.org/D92616 which will remove
angle brackets from pass manager/adaptor names.

Reviewed By: dexonsmith, thakis

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

3 years ago[mac/lld] Run tests with -fatal_warnings by default
Nico Weber [Thu, 3 Dec 2020 14:35:25 +0000 (09:35 -0500)]
[mac/lld] Run tests with -fatal_warnings by default

This helps us catch cases where we add support for a flag but forget to
remove HelpHidden from Options.td.

More explicit alternative to D92455

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

3 years ago[lld][WebAssembly] Set memory limits correctly for PIC + shared memory
Sam Clegg [Thu, 3 Dec 2020 01:14:57 +0000 (17:14 -0800)]
[lld][WebAssembly] Set memory limits correctly for PIC + shared memory

Don't early return from layoutMemory in PIC mode before we have set the
memory limits.

This matters in particular with shared-memory + PIC because shared
memories require maximum size.

Secondly, when we need a maximum, but the user does not supply one,
default to MAX_INT rather than 0 (defaulting to zero is completely
useless and means that building with -shared didn't previously work at
all without --maximum-memory, because zero is never big enough).

This is part of an ongoing effort to enable dynamic linking with
threads in emscripten.

See https://github.com/emscripten-core/emscripten/issues/3494

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

3 years agoSupport: Change InMemoryFileSystem::addFileNoOwn to take a MemoryBufferRef, NFC
Duncan P. N. Exon Smith [Thu, 5 Nov 2020 23:23:19 +0000 (18:23 -0500)]
Support: Change InMemoryFileSystem::addFileNoOwn to take a MemoryBufferRef, NFC

Found this by chance when looking at the InMemoryFileSystem API, seems
like an easy cleanup.

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

3 years ago[mlir][Attributes][NFC] Move all builtin Attribute classes to BuiltinAttributes.h
River Riddle [Fri, 4 Dec 2020 01:22:57 +0000 (17:22 -0800)]
[mlir][Attributes][NFC] Move all builtin Attribute classes to BuiltinAttributes.h

This mirrors the file structure of Types.

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

3 years ago[mlir][Types][NFC] Move all of the builtin Type classes to BuiltinTypes.h
River Riddle [Fri, 4 Dec 2020 01:22:29 +0000 (17:22 -0800)]
[mlir][Types][NFC] Move all of the builtin Type classes to BuiltinTypes.h

This is part of a larger refactoring the better congregates the builtin structures under the BuiltinDialect. This also removes the problematic "standard" naming that clashes with the "standard" dialect, which is not defined within IR/. A temporary forward is placed in StandardTypes.h to allow time for downstream users to replaced references.

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

3 years ago[mlir][NFC] Remove Function.h and Module.h in favor of BuiltinOps.h
River Riddle [Fri, 4 Dec 2020 01:21:32 +0000 (17:21 -0800)]
[mlir][NFC] Remove Function.h and Module.h in favor of BuiltinOps.h

The definitions of ModuleOp and FuncOp are now within BuiltinOps.h, making the individual files obsolete.

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

3 years ago[X86] Unbind the ebx with GOT address in regcall calling convention
Xiang1 Zhang [Thu, 19 Nov 2020 07:16:06 +0000 (15:16 +0800)]
[X86] Unbind the ebx with GOT address in regcall calling convention

No register can be allocated for indirect call when it use regcall calling
convention and passed 5/5+ args.
For example:
call vreg (ag1, ag2, ag3, ag4, ag5, ...) --> 5 regs (EAX, ECX, EDX, ESI, EDI)
used for pass args, 1 reg (EBX )used for hold GOT point, so no regs can be
allocated to vreg.

The Intel386 architecture provides 8 general purpose 32-bit registers. RA
mostly use 6 of them (EAX, EBX, ECX, EDX, ESI, EDI). 5 of this regs can be
used to pass function arguments (EAX, ECX, EDX, ESI, EDI).
EBX used to hold the GOT pointer when making function calls via the PLT.
ESP and EBP usually be "reserved" in register allocation.

Reviewed By: LuoYuanke

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

3 years agoADT: Support copying of IntrusiveRefCntPtr objects
David Blaikie [Thu, 3 Dec 2020 23:28:40 +0000 (15:28 -0800)]
ADT: Support copying of IntrusiveRefCntPtr objects

This was partially supported but untested for RefCountedBase (the
implicit copy assignment would've been problematic - so delete that) and
unsupported (would not have compiled, because std::atomic is
non-copyable) for ThreadSafeRefCountedBase (implement similar support
to RefCountedBase)

Fix the test that had a copy ctor for the derived object but called
RefCountBase's default ctor from that copy ctor - which meant it wasn't
actually testing RefCountBase's copy semantics.

3 years ago[mlir][vector][avx512] move avx512 lowering pass into general vector lowering
Aart Bik [Fri, 4 Dec 2020 00:18:58 +0000 (16:18 -0800)]
[mlir][vector][avx512] move avx512 lowering pass into general vector lowering

A separate AVX512 lowering pass does not compose well with the regular
vector lowering pass. As such, it is at risk of code duplication and
lowering inconsistencies. This change removes the separate AVX512 lowering
pass and makes it an "option" in the regular vector lowering pass
(viz. vector dialect "augmented" with AVX512 dialect).

Reviewed By: rriddle

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

3 years ago[SmallVector] Allow SmallVector<T>
Sean Silva [Thu, 3 Dec 2020 18:38:37 +0000 (10:38 -0800)]
[SmallVector] Allow SmallVector<T>

This patch adds a capability to SmallVector to decide a number of
inlined elements automatically. The policy is:

- A minimum of 1 inlined elements, with more as long as
sizeof(SmallVector<T>) <= 64.
- If sizeof(T) is "too big", then trigger a static_assert: this dodges
the more pathological cases

This is expected to systematically improve SmallVector use in the
LLVM codebase, which has historically been plagued by semi-arbitrary /
cargo culted N parameters, often leading to bad outcomes due to
excessive sizeof(SmallVector<T, N>). This default also makes
programming more convenient by avoiding edit/rebuild cycles due to
forgetting to type the N parameter.

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

3 years ago[NewPM] Support --print-before/after in NPM
Arthur Eubanks [Thu, 3 Dec 2020 18:59:10 +0000 (10:59 -0800)]
[NewPM] Support --print-before/after in NPM

This changes --print-before/after to be a list of strings rather than
legacy passes. (this also has the effect of not showing the entire list
of passes in --help-hidden after --print-before/after, which IMO is
great for making it less verbose).

Currently PrintIRInstrumentation passes the class name rather than pass
name to llvm::shouldPrintBeforePass(), meaning
llvm::shouldPrintBeforePass() never functions as intended in the NPM.
There is no easy way of converting class names to pass names outside of
within an instance of PassBuilder.

This adds a map of pass class names to their short names in
PassRegistry.def within PassInstrumentationCallbacks. It is populated
inside the constructor of PassBuilder, which takes a
PassInstrumentationCallbacks.

Add a pointer to PassInstrumentationCallbacks inside
PrintIRInstrumentation and use the newly created map.

This is a bit hacky, but I can't think of a better way since the short
id to class name only exists within PassRegistry.def. This also doesn't
handle passes not in PassRegistry.def but rather added via
PassBuilder::registerPipelineParsingCallback().

llvm/test/CodeGen/Generic/print-after.ll doesn't seem very useful now
with this change.

Reviewed By: ychen, jamieschmeiser

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

3 years ago[mlir][IR] Add explicit default constructor to OwningModuleRef to appease MSVC
River Riddle [Fri, 4 Dec 2020 00:31:21 +0000 (16:31 -0800)]
[mlir][IR] Add explicit default constructor to OwningModuleRef to appease MSVC

3 years ago[WebAssembly] Fixed Writer::createInitMemoryFunction to work for wasm64
Wouter van Oortmerssen [Mon, 30 Nov 2020 22:00:34 +0000 (14:00 -0800)]
[WebAssembly] Fixed Writer::createInitMemoryFunction to work for wasm64

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

3 years agoUse MlirStringRef in StandardAttributes.h
George [Fri, 4 Dec 2020 00:01:32 +0000 (16:01 -0800)]
Use MlirStringRef in StandardAttributes.h

3 years agoFrontend: Remove redundant call to CompilerInstance::setFileManager, NFC
Duncan P. N. Exon Smith [Wed, 4 Nov 2020 23:31:40 +0000 (18:31 -0500)]
Frontend: Remove redundant call to CompilerInstance::setFileManager, NFC

`ASTUnit::Parse` sets up the `FileManager` earlier in the same function,
ensuring `ASTUnit::getFileManager()` matches `Clang->getFileManager()`.
Remove the later call to `setFileManager(getFileManager())` since it
does nothing.

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

3 years ago[RISCV] Rename FPCCToExtend->FPOpToExpand and FPOpToExtend->FPOpToExpand. NFC
Craig Topper [Thu, 3 Dec 2020 23:58:59 +0000 (15:58 -0800)]
[RISCV] Rename FPCCToExtend->FPOpToExpand and FPOpToExtend->FPOpToExpand. NFC

These are used to call setOperationAction/setCondCodeAction with
the Expand action so it seems that Expand is a better name than
Extend.

3 years agoP0857R0: Parse a requires-clause after an explicit
Richard Smith [Thu, 3 Dec 2020 23:51:56 +0000 (15:51 -0800)]
P0857R0: Parse a requires-clause after an explicit
template-parameter-list in a lambda.

This implements one of the missing parts of P0857R0. Mark it as not done
on the cxx_status page given that it's still incomplete.

3 years ago[mlir][Parser] Don't hardcode the use of ModuleOp in the parser
River Riddle [Thu, 3 Dec 2020 23:46:41 +0000 (15:46 -0800)]
[mlir][Parser] Don't hardcode the use of ModuleOp in the parser

This was important when ModuleOp was the only top level operation, but that isn't necessarily the case anymore. This is one of the last remaining aspects of the infrastructure that is hardcoded to ModuleOp.

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

3 years ago[mlir][Pass] Remove the restriction that PassManager can only run on ModuleOp
River Riddle [Thu, 3 Dec 2020 23:46:32 +0000 (15:46 -0800)]
[mlir][Pass] Remove the restriction that PassManager can only run on ModuleOp

This was a somewhat important restriction in the past when ModuleOp was distinctly the top-level container operation, as well as before the pass manager had support for running nested pass managers natively. With these two issues fading away, there isn't really a good reason to enforce that a ModuleOp is the thing running within a pass manager. As such, this revision removes the restriction and allows for users to pass in the name of the operation that the pass manager will be scheduled on.

The only remaining dependency on BuiltinOps from Pass after this revision is due to FunctionPass, which will be resolved in a followup revision.

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

3 years ago[mlir][IR] Remove references to BuiltinOps from IR/
River Riddle [Thu, 3 Dec 2020 23:46:23 +0000 (15:46 -0800)]
[mlir][IR] Remove references to BuiltinOps from IR/

There isn't a good reason for anything within IR to specifically reference any of the builtin operations. The only place that had a good reason in the past was AsmPrinter, but the behavior there doesn't need to hardcode ModuleOp anymore.

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

3 years ago[mlir][linalg] Add vectorization for element-wise linalg ops
Thomas Raoux [Thu, 3 Dec 2020 04:45:26 +0000 (20:45 -0800)]
[mlir][linalg] Add vectorization for element-wise linalg ops

Add support for vectorization for linalg.generic representing element-wise ops.
Those are converted to transfer_read + vector ops + transfer_write.
Also re-organize the vectorization tests to be together.

Implementation derived from the work of @burmako, @agrue and
@fedelebron.

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

3 years agoPR45699: Fix crash if an unexpanded parameter pack appears in a
Richard Smith [Thu, 3 Dec 2020 23:25:21 +0000 (15:25 -0800)]
PR45699: Fix crash if an unexpanded parameter pack appears in a
requires-clause.

3 years ago[lldb] Use the cpu subtype enum values from llvm::MachO in ArchSpec (NFC)
Jonas Devlieghere [Thu, 3 Dec 2020 23:06:31 +0000 (15:06 -0800)]
[lldb] Use the cpu subtype enum values from llvm::MachO in ArchSpec (NFC)

Use the cpu subtype enum values from llvm::MachO in the ArchSpec MachO
table. As I'm already cluttering the history, restore the table's
formatting to its original glory.

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

3 years agotry more to fix t.s on Windows after 7cb0a373d1
Nico Weber [Thu, 3 Dec 2020 23:06:34 +0000 (18:06 -0500)]
try more to fix t.s on Windows after 7cb0a373d1

3 years agoUse deref facts derived from minimum object size of allocations
Philip Reames [Thu, 3 Dec 2020 22:58:30 +0000 (14:58 -0800)]
Use deref facts derived from minimum object size of allocations

This change should be fairly straight forward. If we've reached a call, check to see if we can tell the result is dereferenceable from information about the minimum object size returned by the call.

To control compile time impact, I'm only adding the call for base facts in the routine. getObjectSize can also do recursive reasoning, and we don't want that general capability here.

As a follow up patch (without separate review), I will plumb through the missing TLI parameter. That will have the effect of extending this to known libcalls - malloc, new, and the like - whereas currently this only covers calls with the explicit allocsize attribute.

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

3 years ago[HIP] cmath demote long double args to double
Aaron En Ye Shi [Wed, 25 Nov 2020 21:08:12 +0000 (21:08 +0000)]
[HIP] cmath demote long double args to double

Since there is no ROCm Device Library support for
long double, demote them to double, and use the fp64
math functions.

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

3 years ago[LoopVec] Support non-instructions as argument to uniform mem ops
Philip Reames [Thu, 3 Dec 2020 22:49:30 +0000 (14:49 -0800)]
[LoopVec] Support non-instructions as argument to uniform mem ops

The initial step of the uniform-after-vectorization (lane-0 demanded only) analysis was very awkwardly written. It would revisit use list of each pointer operand of a widened load/store. As a result, it was in the worst case O(N^2) where N was the number of instructions in a loop, and had restricted operand Value types to reduce the size of use lists.

This patch replaces the original algorithm with one which is at most O(2N) in the number of instructions in the loop. (The key observation is that each use of a potentially interesting pointer is visited at most twice, once on first scan, once in the use list of *it's* operand. Only instructions within the loop have their uses scanned.)

In the process, we remove a restriction which required the operand of the uniform mem op to itself be an instruction.  This allows detection of uniform mem ops involving global addresses.

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

3 years ago[BasicAA] Move newline to dump from printer
Philip Reames [Thu, 3 Dec 2020 22:35:37 +0000 (14:35 -0800)]
[BasicAA] Move newline to dump from printer

3 years ago[lldb] Refactor the Symbolicator initializer
Jonas Devlieghere [Thu, 3 Dec 2020 22:31:37 +0000 (14:31 -0800)]
[lldb] Refactor the Symbolicator initializer

We found out that we have clients relying on the old signature of the
Symbolicator initializer. Make the signature compatible again and
provide a factory method to initialize the class correctly based on
whether you have a target or want the symbolicator to create one for
you.

Differential revision: D92601

3 years agoRevert D90844 "[TableGen][SchedModels] Fix read/write variant substitution"
Fangrui Song [Thu, 3 Dec 2020 22:24:29 +0000 (14:24 -0800)]
Revert D90844 "[TableGen][SchedModels] Fix read/write variant substitution"

This reverts commit 112b3cb6ba49aacd821440d0913f15b32131480e.

D90844 made lib/Target/AArch64/AArch64GenSubtargetInfo.inc non-deterministic.

3 years agoRevert "[test] Add a triple to an x86 test"
Justin Bogner [Thu, 3 Dec 2020 22:21:37 +0000 (14:21 -0800)]
Revert "[test] Add a triple to an x86 test"

This fails on some of the bots. Reverting to investigate.

This reverts commit d5268ebe19252c86549a3c8a9c6b3fa714dbf17c.

3 years ago[test] Add a triple to an x86 test
Justin Bogner [Thu, 3 Dec 2020 22:05:51 +0000 (14:05 -0800)]
[test] Add a triple to an x86 test

This already "REQUIRE"d an x86 target, but it was also implicitly
depending on a default triple being set.

3 years ago[libc][NFC] Remove dependence on xmmintrin.h to read/write MXCSR.
Siva Chandra Reddy [Thu, 3 Dec 2020 21:41:10 +0000 (13:41 -0800)]
[libc][NFC] Remove dependence on xmmintrin.h to read/write MXCSR.

The version of clang on the bots is unhappy with using xmmintrin.h.
So, this change removes dependence on xmmintrin by using inline
assembly.

3 years agotry to fix t.s on Windows after 7cb0a373d1
Nico Weber [Thu, 3 Dec 2020 21:42:08 +0000 (16:42 -0500)]
try to fix t.s on Windows after 7cb0a373d1

3 years ago[lldb] Recognize MachO cpu sub-type 2 as arm64
Jonas Devlieghere [Thu, 3 Dec 2020 21:21:03 +0000 (13:21 -0800)]
[lldb] Recognize MachO cpu sub-type 2 as arm64

Make sure we recognize cpu sub-type 2 as arm64. In reality it's arm64e,
but we don't have the triple for that. Without this patch, we fall back
to unknown-apple-macosx- for the default architecture, which breaks
things like running expressions without a target.

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

3 years ago[mlir] Use long rather than int to address pointer-to-int narrowing warning
David Blaikie [Thu, 3 Dec 2020 21:08:57 +0000 (13:08 -0800)]
[mlir] Use long rather than int to address pointer-to-int narrowing warning

3 years ago[mlir] Make conversion functions inline instead of static to avoid -Wunused-function
David Blaikie [Thu, 3 Dec 2020 21:08:22 +0000 (13:08 -0800)]
[mlir] Make conversion functions inline instead of static to avoid -Wunused-function

3 years ago[BasicAA] Minor formatting improvements for printers
Philip Reames [Thu, 3 Dec 2020 21:08:20 +0000 (13:08 -0800)]
[BasicAA] Minor formatting improvements for printers

3 years ago[mac/lld] Implement -t
Nico Weber [Wed, 2 Dec 2020 23:57:30 +0000 (18:57 -0500)]
[mac/lld] Implement -t

Goes well with `-why_load` to get an idea of load order.

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

3 years ago[libc] Add simple x86_64 floating point exception and rounding mode support.
Siva Chandra Reddy [Tue, 1 Dec 2020 19:39:48 +0000 (11:39 -0800)]
[libc] Add simple x86_64 floating point exception and rounding mode support.

Reviewed By: lntue

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

3 years ago[BasicAA] Add print routines to DecomposedGEP for ease of debugging
Philip Reames [Thu, 3 Dec 2020 20:43:26 +0000 (12:43 -0800)]
[BasicAA] Add print routines to DecomposedGEP for ease of debugging

3 years ago[flang] Fix bogus message on interface procedure argument names
Peter Steinfeld [Wed, 2 Dec 2020 20:31:56 +0000 (12:31 -0800)]
[flang] Fix bogus message on interface procedure argument names

We were keeping the state of parsed equivalence sets in the class
DeclarationVisitor.  A problem happened when  analyzing the the specification
part of a declaration that contained an EQUIVALENCE statement followed by an
interface block.  The same DeclarationVisitor object that was created for the
outer declaration was being used to analyze the specification part
of a procedure body in the interface block.  When analyzing the specification
part of the procedure in the interface block, the names in the outer
declaration's EQUIVALENCE statement were erroneously compared with the names in
the arguments of the interface procedure.  This resulted in a bogus error
message.

I fixed this by not checking equivalence sets when we're in an interface
block.  I also added a test that will produce an error message without
this change.

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

3 years ago[libc++] Update and normalize the "all the headers" tests.
Arthur O'Dwyer [Wed, 2 Dec 2020 23:55:01 +0000 (18:55 -0500)]
[libc++] Update and normalize the "all the headers" tests.

Some C++20 headers weren't added properly to all three of these
test files. Add them, and take the time to normalize the formatting
so that

    diff <(grep '#include' foo.cpp) <(grep '#include' bar.cpp)

shows no diffs (except that `no_assert_include` deliberately
excludes `<cassert>`).

- Add macro guards to <{barrier,latch,semaphore}>.
- Add macro guards to <experimental/simd>.
- Remove an include of <cassert> from <semaphore>.
- Instead, include <cassert> in the semaphore tests.

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

3 years agoRevert "Include Region.h in OperationSupport.h instead of forward declaring it (NFC)"
Mehdi Amini [Thu, 3 Dec 2020 19:59:20 +0000 (19:59 +0000)]
Revert "Include Region.h in OperationSupport.h instead of forward declaring it (NFC)"

This reverts commit e312b388ebadcd074d559454aca1fd6e75e8e7a5.

The original breaking change has been reverted

3 years agoRevert "Switch to std::is_trivially_move_constructible and std::is_trivially_copy_con...
Mehdi Amini [Thu, 3 Dec 2020 19:57:34 +0000 (19:57 +0000)]
Revert "Switch to std::is_trivially_move_constructible and std::is_trivially_copy_constructible"

This reverts commit c8d406c93c5bb01599990201f78d8428dd29d289.

Builds are broken with some versions of GCC.

3 years ago[AMDGPU] Extend and reorganize memory legalizer tests
Scott Linder [Mon, 30 Nov 2020 16:59:09 +0000 (16:59 +0000)]
[AMDGPU] Extend and reorganize memory legalizer tests

* Rename some tests to try to make a convention (where all components
  are optional) of:

    <addrspace>_<syncscope>_<memory-orders>_<operation>

* Split up at a level of granularity appropriate for the different RUN
  lines (i.e. split on addrspace so GFX6 can avoid FLAT) and that makes
  running a specific test reasonable in terms of wall time taken. This
  also means when run as part of the test suite the testing is not one
  serial bottleneck.

* Auto-generate check lines with `update_llc_test_checks.py` to make
  future maintenance more tractable.

Reviewed By: rampitec, t-tye

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

3 years ago[clangd] AddUsing: Fix a crash on ElaboratedTypes without NestedNameSpecfiiers.
Adam Czachorowski [Thu, 3 Dec 2020 17:09:36 +0000 (18:09 +0100)]
[clangd] AddUsing: Fix a crash on ElaboratedTypes without NestedNameSpecfiiers.

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

3 years ago[RISCV] Merge FMV_H_X_RV32/FMV_H_X_RV64 into a single opcode. Same with FMV_X_ANYEXTH...
Craig Topper [Thu, 3 Dec 2020 18:29:10 +0000 (10:29 -0800)]
[RISCV] Merge FMV_H_X_RV32/FMV_H_X_RV64 into a single opcode. Same with FMV_X_ANYEXTH_RV32/RV64

Rather than having a different opcode for RV32 and RV64. Let's just say the integer type is XLenVT and use a single opcode for both modes.

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

3 years agoSpeedup some unicode rendering
serge-sans-paille [Thu, 26 Nov 2020 14:22:20 +0000 (15:22 +0100)]
Speedup some unicode rendering

Use a fast path for column width computation for ascii characters. Especially
relevant for llvm-objdump.

before:

    % time ./bin/llvm-objdump -D  -j .text /lib/libc.so.6 >/dev/null
    ./bin/llvm-objdump -D -j .text /lib/libc.so.6 > /dev/null  0.75s user 0.01s system 99% cpu 0.757 total

after:

    % time ./bin/llvm-objdump -D  -j .text /lib/libc.so.6 >/dev/null
    ./bin/llvm-objdump -D -j .text /lib/libc.so.6 > /dev/null  0.37s user 0.01s system 99% cpu 0.378 total

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

3 years ago[compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if...
Adhemerval Zanella [Thu, 3 Dec 2020 18:29:45 +0000 (15:29 -0300)]
[compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if available

On AArch64 it allows use the native FP16 ABI (although libcalls are
not emitted for fptrunc/fpext lowering), while on other architectures
the expected current semantic is preserved (arm for instance).

For testing the _Float16 usage is enabled by architecture base,
currently only for arm, aarch64, and arm64.

This re-enabled revert done by https://reviews.llvm.org/rGb534beabeed3ba1777cd0ff9ce552d077e496726

Reviewed By: MaskRay

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

3 years ago[lld][WebAssembly] Fix malformed output with -pie + --shared-memory
Sam Clegg [Wed, 2 Dec 2020 23:55:25 +0000 (15:55 -0800)]
[lld][WebAssembly] Fix malformed output with -pie + --shared-memory

The conditional guarding createInitMemoryFunction was incorrect and
didn't match that guarding the creation of the associated symbol.

Rather that reproduce the same conditions in multiple places we can
simply use the presence of the associated symbol.

Also, add an assertion that would have caught this bug.

Also, add a new test for this flag combination.

This is part of an ongoing effort to enable dynamic linking with
threads in emscripten.

See https://github.com/emscripten-core/emscripten/issues/3494

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

3 years ago[ScalarizeMaskedMemIntrin] NFC: Pass args by reference
Anna Thomas [Thu, 3 Dec 2020 19:02:47 +0000 (14:02 -0500)]
[ScalarizeMaskedMemIntrin] NFC: Pass args by reference

3 years ago[Metadata] Fix layer violation in D91576
Fangrui Song [Thu, 3 Dec 2020 18:58:46 +0000 (10:58 -0800)]
[Metadata] Fix layer violation in D91576

There is a library layering issue. LLVMAnalysis provides llvm/Analysis/ScopedNoAliasAA.h and depends on LLVMCore.

LLVMCore provides llvm/IR/Metadata.cpp and it should not include a header file in LLVMAnalysis

3 years agoInclude Region.h in OperationSupport.h instead of forward declaring it (NFC)
Mehdi Amini [Thu, 3 Dec 2020 18:45:58 +0000 (18:45 +0000)]
Include Region.h in OperationSupport.h instead of forward declaring it (NFC)

This fixes the build on gcc5 toolchain where sizeof is required for
types used in SmallVector now.
This is a consequence of using std::is_trivially_copy_constructible
instead of the LLVM variant: https://reviews.llvm.org/D92543

3 years ago[gn build] Port
LLVM GN Syncbot [Thu, 3 Dec 2020 18:47:31 +0000 (18:47 +0000)]
[gn build] Port

3 years agoUse the generic form when printing from the python bindings and the verifier fails
Mehdi Amini [Thu, 3 Dec 2020 17:45:28 +0000 (17:45 +0000)]
Use the generic form when printing from the python bindings and the verifier fails

This reduces the chances of segfault. While it is a good practice to ensure
robust custom printers, it is unfortunately common to have them crash on
invalid input.

Reviewed By: stellaraccident

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

3 years ago[gn build] (semi-manually) port cc8df90b037
Nico Weber [Thu, 3 Dec 2020 18:43:12 +0000 (13:43 -0500)]
[gn build] (semi-manually) port cc8df90b037

3 years ago[gn build] (manually) port 65049d16100af
Nico Weber [Thu, 3 Dec 2020 18:42:52 +0000 (13:42 -0500)]
[gn build] (manually) port 65049d16100af

3 years ago[compiler-rt] Fix a bug in the cmakelists file when CMAKE_CXX_FLAGS are empty
Stella Stamenova [Thu, 3 Dec 2020 18:25:52 +0000 (10:25 -0800)]
[compiler-rt] Fix a bug in the cmakelists file when CMAKE_CXX_FLAGS are empty

Right now, the regex expression will fail if the flags were not set. Instead, we should follow the pattern of other llvm projects and quote the expression, so that it can work even when the flags are not set.

Reviewed By: phosek

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

3 years agoBump MSVC required version to 19.14
Reid Kleckner [Wed, 2 Dec 2020 23:21:04 +0000 (15:21 -0800)]
Bump MSVC required version to 19.14

LLVM passes overaligned objects by value, which MSVC 19.1 didn't support on
x86_32. MSVC added this support somewhere between 19.1 and 19.14, but godbolt
doesn't have 19.11, 19.12, or 19.13 so I can't test before 19.14:
https://gcc.godbolt.org/z/75YoEz

Even if users are using the Visual Studio 2017 series of Visual C++ toolchains,
they should've already updated to 19.14 or newer at this point, or they
wouldn't be able to build LLVM. This just raises the CMake required minimum
version so the build fails earlier.

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

3 years ago[RISCV] Remove RISCVMergeBaseOffsetOpt from the -O0 pass pipeline.
Craig Topper [Thu, 3 Dec 2020 17:30:33 +0000 (09:30 -0800)]
[RISCV] Remove RISCVMergeBaseOffsetOpt from the -O0 pass pipeline.

Internally the pass skips any function with the optnone attribute. But that still requires checking each function. If the opt level is set to None we might as well just skip putting in the pipeline at all. This what is already done for many of the passes added by TargetPassConfig.

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

3 years ago[MLIR] Fix vector::TransferWriteOp builder losing permutation map
Max Kudryavtsev [Thu, 3 Dec 2020 17:51:47 +0000 (09:51 -0800)]
[MLIR] Fix vector::TransferWriteOp builder losing permutation map

Supervectorizer pass uses this builder and loses the permutation map.

Reviewed By: nicolasvasilache

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

3 years ago[MemCpyOpt] Correctly merge alias scopes during call slot optimization
modimo [Thu, 3 Dec 2020 17:23:37 +0000 (09:23 -0800)]
[MemCpyOpt] Correctly merge alias scopes during call slot optimization

When MemCpyOpt performs call slot optimization it will concatenate the `alias.scope` metadata between the function call and the memcpy. However, scoped AA relies on the domains in metadata to be maintained in a caller-callee relationship. Naive concatenation breaks this assumption leading to bad AA results.

The fix is to take the intersection of domains then union the scopes within those domains.

The original bug came from a case of rust bad codegen which uses this bad aliasing to perform additional memcpy optimizations. As show in the added test case `%src` got forwarded past its lifetime leading to a dereference of garbage data.

Testing
ninja check-llvm

Reviewed By: jeroen.dobbelaere

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

3 years agoSwitch to std::is_trivially_move_constructible and std::is_trivially_copy_constructible
Fangrui Song [Thu, 3 Dec 2020 17:15:40 +0000 (09:15 -0800)]
Switch to std::is_trivially_move_constructible and std::is_trivially_copy_constructible

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

3 years ago[X86] Remove DecodeVPERMVMask and DecodeVPERMV3Mask
Kazu Hirata [Thu, 3 Dec 2020 17:12:02 +0000 (09:12 -0800)]
[X86] Remove DecodeVPERMVMask and DecodeVPERMV3Mask

This patch removes the variants of DecodeVPERMVMask and
DecodeVPERMV3Mask that take "const Constant *C" as they are not used
anymore.

They were introduced on Sep 8, 2015 in commit
e88038f23517ffc741acfd307ff92e2b1af136d8.

The last use of DecodeVPERMVMask(const Constant *C, ...)  was removed
on Feb 7, 2016 in commit 73fc26b44a8591b15f13eaffef17e67161c69388.

The last use of DecodeVPERMV3Mask(const Constant *C, ...) was removed
on May 28, 2018 in commit dcfcfdb0d166fff8388bdd2edc5a2948054c9da1.

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

3 years agorepair cygwin build
Jameson Nash [Thu, 3 Dec 2020 15:37:18 +0000 (10:37 -0500)]
repair cygwin build

This is needed for cross-compiling LLVM from Cygwin, but it had gotten
deleted in rG2724d9e12960cc1d93eeabbfc9aa1bffffa041cc

Reviewed By: compnerd

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

3 years ago[ScalarizeMaskedMemIntrin] NFC: Convert member functions to static
Anna Thomas [Thu, 3 Dec 2020 16:43:30 +0000 (11:43 -0500)]
[ScalarizeMaskedMemIntrin] NFC: Convert member functions to static

This will make it easier to add new PM support once the pass is moved
into transforms (D92407).

3 years ago[LLVMFrontend][openacc] Add basic unit tests for functions in LLVMFrontendOpenACC
Valentin Clement [Thu, 3 Dec 2020 16:26:46 +0000 (11:26 -0500)]
[LLVMFrontend][openacc] Add basic unit tests for functions in LLVMFrontendOpenACC

Add unit tests for functions in LLVMFrontendOpenACC. As notice in D91470 these functions were not tested
as well as the ones for OpenMP (D91643). This patch add tests for the OpenACC part.

Reviewed By: Meinersbur

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

3 years ago[libc] Add implementation of hypot.
Tue Ly [Fri, 18 Sep 2020 03:22:18 +0000 (23:22 -0400)]
[libc] Add implementation of hypot.

Refactor src/math/hypotf.cpp and test/src/math/hypotf_test.cpp and reuse them for hypot and hypot_test

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

3 years agoTry to fix tests on Windows after 0cbf61be8be
Nico Weber [Thu, 3 Dec 2020 15:54:52 +0000 (10:54 -0500)]
Try to fix tests on Windows after 0cbf61be8be

3 years ago[Triple][MachO] Define "arm64e", an AArch64 subarch for Pointer Auth.
Ahmed Bougacha [Thu, 3 Sep 2020 15:43:21 +0000 (08:43 -0700)]
[Triple][MachO] Define "arm64e", an AArch64 subarch for Pointer Auth.

This also teaches MachO writers/readers about the MachO cpu subtype,
beyond the minimal subtype reader support present at the moment.

This also defines a preprocessor macro to allow users to distinguish
__arm64__ from __arm64e__.

arm64e defaults to an "apple-a12" CPU, which supports v8.3a, allowing
pointer-authentication codegen.
It also currently defaults to ios14 and macos11.

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

3 years ago[PowerPC] Fix for excessive ACC copies due to PHI nodes
Baptiste Saleil [Thu, 3 Dec 2020 15:49:38 +0000 (09:49 -0600)]
[PowerPC] Fix for excessive ACC copies due to PHI nodes

When using accumulators in loops, they are passed around in PHI nodes of unprimed
accumulators, causing the generation of additional prime/unprime instructions.
This patch detects these cases and changes these PHI nodes to primed accumulator
PHI nodes. We also add IR and MIR test cases for several PHI node cases.

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

3 years ago[ASTMatchers][NFC] Made variadic operator funcs static
Nathan James [Thu, 3 Dec 2020 15:47:54 +0000 (15:47 +0000)]
[ASTMatchers][NFC] Made variadic operator funcs static

Fix naming style while were here too.