platform/upstream/llvm.git
2 years ago[llvm-reduce] Add pass that reduces DebugInfo metadata
Matthew Voss [Thu, 6 Oct 2022 21:20:13 +0000 (14:20 -0700)]
[llvm-reduce] Add pass that reduces DebugInfo metadata

This new pass for llvm-reduce attempts to reduce DebugInfo metadata.
The process used is:
  1. Scan every MD node, keeping track of nodes already visited.
  2. Look for DebugInfo nodes, then record any operands that are lists.
  3. Bisect though all the elements of the collected lists.

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

2 years ago[mlir][sparse] remove llvm dependence from sparse bazel
Aart Bik [Thu, 6 Oct 2022 21:10:36 +0000 (14:10 -0700)]
[mlir][sparse] remove llvm dependence from sparse bazel

Reviewed By: wrengr, Peiming

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

2 years ago[ConstraintElimination] Add tests where unsigned system can be queried.
Florian Hahn [Thu, 6 Oct 2022 21:11:51 +0000 (22:11 +0100)]
[ConstraintElimination] Add tests where unsigned system can be queried.

Add tests with a mix of signed and unsigned predicates. In some cases,
the unsigned system can be queried for signed predicates to improve
results.

2 years ago[flang] Improve syntax error messages by fixing withMessage() parser combinator
Peter Klausler [Tue, 4 Oct 2022 20:14:49 +0000 (13:14 -0700)]
[flang] Improve syntax error messages by fixing withMessage() parser combinator

The parser combinator withMessage("error message"_err_en_US, PARSER) is meant
to run the parser PARSER and, if it fails, override its error messages if
it failed silently or it was unable to recognize any tokens at all.  This
gives the parser a way to avoid emitting some confusing or missing error
messages.  Unfortunately, the implementation could sometimes lose track of
whether any tokens had been recognized, leading to problems with outer usage
of withMessage() and also -- more seriously -- with ParseState::CombineFailedParses().
That's a utility that determines which error messages to retain when two
or more parsers have been attempted at the same starting point and none
of them succceed.  Its policy is to retain the state from the parser that
consumed the most input text before failing, so long as it had recognized at
least one token.

So anyway, fix up withMessage(), adjust the tests, and add a test of the
original motivating confusing error situation, in which a syntax error in
a COMMON statement was being diagnosed as a problem with a statement function
definition because withMessage() had lost the fact that the parse of the
COMMON statement had recognized some tokens, and the last attempted parse
later was a failed attempt to parse a statement function.

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

2 years ago[mlir][sparse] minor header ordering cleanup
Aart Bik [Thu, 6 Oct 2022 17:53:33 +0000 (10:53 -0700)]
[mlir][sparse] minor header ordering cleanup

Order of methods was getting a bit out of sync with headers

Reviewed By: Peiming

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

2 years ago[mlir][sparse] Favors synthetic tensor over other undefined tensors
Peiming Liu [Thu, 6 Oct 2022 17:41:48 +0000 (17:41 +0000)]
[mlir][sparse] Favors synthetic tensor over other undefined tensors

Reviewed By: aartbik

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

2 years ago[flang] Add missing source location to a semantic error message
Peter Klausler [Tue, 4 Oct 2022 19:41:48 +0000 (12:41 -0700)]
[flang] Add missing source location to a semantic error message

Ensure that the semantic error "An allocatable or pointer component
reference must be applied to a scalar base" is emitted with a source
code location.

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

2 years agoRevert "[llvm-reduce] Remove debug metadata elements"
Ellis Hoag [Thu, 6 Oct 2022 20:11:35 +0000 (13:11 -0700)]
Revert "[llvm-reduce] Remove debug metadata elements"

This reverts commit 69549de865550e54983ed8d00009920184de47ff.

The change in D135237 can lead to verification failures like `scope must have two or three operands`.
The ongoing work in D132077 does something similar without these failures, so lets wait for that to land and revert this patch.

Reviewed By: aeubanks

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

2 years ago[lldb] Skip check for conflicting filter/synth when adding a new regex.
Jorge Gorbe Moya [Fri, 23 Sep 2022 22:09:08 +0000 (15:09 -0700)]
[lldb] Skip check for conflicting filter/synth when adding a new regex.

When adding a new synthetic child provider, we check for an existing
conflicting filter in the same category (and vice versa). This is done
by trying to match the new type name against registered formatters.

However, the new type name we're registered can also be a regex
(`type synth add -x`), and in this case the conflict check is just
wrong: it will try to match the new regex as if it was a type name,
against previously registered regexes.

See https://github.com/llvm/llvm-project/issues/57947 for a longer
explanation with concrete examples of incorrect behavior.

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

2 years ago[DAG] Extract helper for (neg x) [nfc]
Philip Reames [Thu, 6 Oct 2022 20:10:58 +0000 (13:10 -0700)]
[DAG] Extract helper for (neg x) [nfc]

This is a frequently reoccurring pattern, let's factor it out.

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

2 years ago[OpenMP][DeviceRTL] Fix build issue
Shilei Tian [Thu, 6 Oct 2022 20:21:51 +0000 (16:21 -0400)]
[OpenMP][DeviceRTL] Fix build issue

2 years agoThread safety analysis: Support copy-elided production of scoped capabilities through...
Aaron Puchert [Wed, 13 Jul 2022 23:47:52 +0000 (01:47 +0200)]
Thread safety analysis: Support copy-elided production of scoped capabilities through arbitrary calls

When support for copy elision was initially added in e97654b2f2807, it
was taking attributes from a constructor call, although that constructor
call is actually not involved. It seems more natural to use attributes
on the function returning the scoped capability, which is where it's
actually coming from. This would also support a number of interesting
use cases, like producing different scope kinds without the need for tag
types, or producing scopes from a private mutex.

Changing the behavior was surprisingly difficult: we were not handling
CXXConstructorExpr calls like regular calls but instead handled them
through the DeclStmt they're contained in. This was based on the
assumption that constructors are basically only called in variable
declarations (not true because of temporaries), and that variable
declarations necessitate constructors (not true with C++17 anymore).

Untangling this required separating construction from assigning a
variable name. When a call produces an object, we use a placeholder
til::LiteralPtr for `this`, and we collect the call expression and
placeholder in a map. Later when going through a DeclStmt, we look up
the call expression and set the placeholder to the new VarDecl.

The change has a couple of nice side effects:
* We don't miss constructor calls not contained in DeclStmts anymore,
  allowing patterns like
    MutexLock{&mu}, requiresMutex();
  The scoped lock temporary will be destructed at the end of the full
  statement, so it protects the following call without the need for a
  scope, but with the ability to unlock in case of an exception.
* We support lifetime extension of temporaries. While unusual, one can
  now write
    const MutexLock &scope = MutexLock(&mu);
  and have it behave as expected.
* Destructors used to be handled in a weird way: since there is no
  expression in the AST for implicit destructor calls, we instead
  provided a made-up DeclRefExpr to the variable being destructed, and
  passed that instead of a CallExpr. Then later in translateAttrExpr
  there was special code that knew that destructor expressions worked a
  bit different.
* We were producing dummy DeclRefExprs in a number of places, this has
  been eliminated. We now use til::SExprs instead.

Technically this could break existing code, but the current handling
seems unexpected enough to justify this change.

Reviewed By: aaron.ballman

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

2 years agoThread safety analysis: Handle additional cast in scoped capability construction
Aaron Puchert [Thu, 14 Jul 2022 11:39:04 +0000 (13:39 +0200)]
Thread safety analysis: Handle additional cast in scoped capability construction

We might have a CK_NoOp cast and a further CK_ConstructorConversion.
As an optimization, drop some IgnoreParens calls: inside of the
CK_{Constructor,UserDefined}Conversion should be no more parentheses,
and inside the CXXBindTemporaryExpr should also be none.

Lastly, we factor out the unpacking so that we can reuse it for
MaterializeTemporaryExprs later on.

Reviewed By: aaron.ballman

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

2 years ago[OpenMP][DeviceRTL] Fix an issue that thread array might be corrupted
Shilei Tian [Thu, 6 Oct 2022 20:13:22 +0000 (16:13 -0400)]
[OpenMP][DeviceRTL] Fix an issue that thread array might be corrupted

The shared memory stack in the device runtime assumes no intervined uses.
D135037 breaks the assumption, potentially causing the shared stack corruption.
This patch moves the thread array to heap memory. Since it is already the slow
path, it doesn't matter that much anyway.

Reviewed By: jhuber6

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

2 years agoRevert "Reapply [InstCombine] Switch foldOpIntoPhi() to use InstSimplify"
Alina Sbirlea [Thu, 6 Oct 2022 20:10:41 +0000 (13:10 -0700)]
Revert "Reapply [InstCombine] Switch foldOpIntoPhi() to use InstSimplify"

This reverts commit e94619b955104841cc2a4a6febe4025ee140194e.

2 years ago[flang][NFC] Document Fortran aliasing rules
Peter Klausler [Thu, 29 Sep 2022 20:47:38 +0000 (13:47 -0700)]
[flang][NFC] Document Fortran aliasing rules

Summarize current understanding of Fortran's guarantees to a compiler
(or in other words, restrictions on programs and programmers)
about aliasing.

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

2 years ago[flang] Clarify edge case of host association and generic interfaces
Peter Klausler [Tue, 4 Oct 2022 19:11:20 +0000 (12:11 -0700)]
[flang] Clarify edge case of host association and generic interfaces

Name resolution was mishandling cases of generic interfaces and specific procedures
(sometimes complicatd by use of the same name for each) when the specific procedure
was accessed by means of host association; only the scope of the generic interface
definition was searched for the specific procedure.  Also search enclosing scopes
in the usual way.

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

2 years ago[tosa] Add legalization for conv3d
TatWai Chong [Thu, 6 Oct 2022 19:50:12 +0000 (12:50 -0700)]
[tosa] Add legalization for conv3d

Update the existing implementation to match TOSA spec.

Reviewed By: rsuderman

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

2 years ago[libc] Add POSIX execv and execve functions.
Siva Chandra Reddy [Thu, 6 Oct 2022 05:24:18 +0000 (05:24 +0000)]
[libc] Add POSIX execv and execve functions.

The POSIX global variable environ has also been added.

Reviewed By: michaelrj

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

2 years ago[flang] Use assembly format for fir.dispatch
Valentin Clement [Thu, 6 Oct 2022 19:40:50 +0000 (21:40 +0200)]
[flang] Use assembly format for fir.dispatch

Remove custom parser/printer and make use of the assembly format
for the fir.dispatch operation.

Depends on D135358

Reviewed By: PeteSteinfeld, jeanPerier

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

2 years ago[Sanitizer] Fix compile errors in rtl-old/tsan_rtl.cpp
Julian Lettner [Wed, 21 Sep 2022 21:05:28 +0000 (14:05 -0700)]
[Sanitizer] Fix compile errors in rtl-old/tsan_rtl.cpp

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

2 years ago[PowerPC] Fix types for vcipher builtins.
Stefan Pintilie [Thu, 6 Oct 2022 18:34:09 +0000 (13:34 -0500)]
[PowerPC] Fix types for vcipher builtins.

The documentation specifies that the parameters for the vcipher builtins are
```
vector unsigned char
```
The code used
```
vector unsigned long long
```

This patch fixes the types for the vcipher builtins.

Reviewed By: amyk

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

2 years ago[NFCI] Simplify TypeCategoryImpl for-each callbacks.
Jorge Gorbe Moya [Fri, 16 Sep 2022 22:58:19 +0000 (15:58 -0700)]
[NFCI] Simplify TypeCategoryImpl for-each callbacks.

The callback system to iterate over every formatter of a given kind in
a TypeCategoryImpl is only used in one place (the implementation of
`type {formatter_kind} list`), and it's too convoluted for the sake of
unused flexibility.

This change changes it so that only one callback is passed to `ForEach`
(instead of a callback for exact matches and another one for regex
matches), and moves the iteration logic to `TieredFormatterContainer`
to avoid duplication.

If in the future we need different logic in the callback depending on
exact/regex match, the callback can get the type of formatter matching
used from the TypeMatcher argument anyway.

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

2 years ago[SLP]Improve/fix CSE analysis of the blocks/instructions.
Alexey Bataev [Wed, 5 Oct 2022 15:43:39 +0000 (08:43 -0700)]
[SLP]Improve/fix CSE analysis of the blocks/instructions.

Added analysis for invariant extractelement instructions and improved
detection of the CSE blocks for generated extractelement instructions.

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

2 years ago[Sanitizers][Darwin] Fix invalid gap found by FindAvailableMemoryRange
Mariusz Borsa [Tue, 20 Sep 2022 22:23:58 +0000 (15:23 -0700)]
[Sanitizers][Darwin] Fix invalid gap found by FindAvailableMemoryRange

An application running with ASAN can fail during shadow memory allocation, with an error
indicating a failure to map shadow memory region due to negative size parameter passed to mmap.

It turns out that the mach_vm_region_recurse() call can return an address of a module
which is beyond the range of the VM address space available to the iOS process,
i.e. greater than the value returned by GetMaxVirtualAddress(). It leads the FindAvailableMemoryRange function
to the an incorrect conclusion that it has found a suitable gap where the shadow memory can fit in,
 while the shadow memory cannot be really allocated in this case.

The fix just takes the maximum VM address into account, causing the function to return 0,
meaning that the VM gap to fit the requested size could not be found.

rdar://66530705

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

2 years ago[lldb] Fix hard-coded argument to set_target_properties
Jonas Devlieghere [Thu, 6 Oct 2022 18:01:49 +0000 (11:01 -0700)]
[lldb] Fix hard-coded argument to set_target_properties

The call to `set_target_properties` should use the target passed to
`add_lldb_library` instead of a hard-coded value. Upstream `liblldb` is
the only target for which this matters, but downstream we have
LLDBRPC.framework which needs this as well.

2 years ago[GlobalISel] Add a m_SpecificReg matcher
Jessica Paquette [Thu, 6 Oct 2022 17:30:10 +0000 (10:30 -0700)]
[GlobalISel] Add a m_SpecificReg matcher

Similar to the specific matchers for constants.

The intention here is to make it easier to write combines which check if a
specific register is used more than once.

e.g. matching patterns like:

```
(X + Y) == Y
```

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

2 years ago[flang][runtime] When NAMELIST input hits EOF, signal END, not an error
Peter Klausler [Tue, 4 Oct 2022 18:40:38 +0000 (11:40 -0700)]
[flang][runtime] When NAMELIST input hits EOF, signal END, not an error

NAMELIST input processing in the runtime support library treats an
end-of-file found while searching for the initial '&' character
as an error condition, but it really should be distinguishable.
Call SignalEnd() rather than SignalError().

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

2 years ago[flang] Selectors whose expressions are pointers returned from functions are valid...
Peter Klausler [Tue, 4 Oct 2022 18:10:59 +0000 (11:10 -0700)]
[flang] Selectors whose expressions are pointers returned from functions are valid targets

An ASSOCIATE or SELECT TYPE statement's selector whose "right-hand side" is the result
of a reference to a function that returns a pointer must be usable as a valid target
(but not as a pointer).

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

2 years ago[flang] Delay parse tree rewriting for I/O UNIT=func()
Peter Klausler [Tue, 4 Oct 2022 17:42:42 +0000 (10:42 -0700)]
[flang] Delay parse tree rewriting for I/O UNIT=func()

When an I/O statement's UNIT= specifier is a variable that is a
function reference, parse tree rewriting may determine the wrong type
of the result because generic resolution has not yet been performed.
So move this bit of parse tree rewriting into I/O semantic
checking so that the right handling (integer -> external file unit
number, character pointer -> internal I/O) applies.

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

2 years ago[flang] Ignore errors on declarations in interfaces that "have no effect"
Peter Klausler [Tue, 4 Oct 2022 17:37:36 +0000 (10:37 -0700)]
[flang] Ignore errors on declarations in interfaces that "have no effect"

Fortran strangely allows declarations to appear in procedure interface
definitions when those declarations do not contribute anything to the
characteristics of the procedure; in particular, one may declare local
variables that are neither dummy variables nor function results.
Such declarations "have no effect" on the semantics of the program,
and that should include semantic error checking for things like
special restrictions on PURE procedures.

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

2 years ago[PGO] Make emitted symbols hidden
Alex Brachet [Thu, 6 Oct 2022 18:27:34 +0000 (18:27 +0000)]
[PGO] Make emitted symbols hidden

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

2 years ago[flang] Ensure USE associations of shadowed procedures are emitted to module files
Peter Klausler [Mon, 26 Sep 2022 23:24:32 +0000 (16:24 -0700)]
[flang] Ensure USE associations of shadowed procedures are emitted to module files

When a generic interface in a module shadows a procedure of the same name that
has been brought into scope via USE association, ensure that that USE association is
not lost when the module file is written.

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

2 years ago[flang] Error message situation should be a warning
Peter Klausler [Tue, 4 Oct 2022 17:24:29 +0000 (10:24 -0700)]
[flang] Error message situation should be a warning

f18 emits an error message when the same name is used in a scope
for both a procedure and a generic interface, and the procedure is
not a specific procedure of the generic interface.  It may be
questionable usage, and not portable, but it does not appear to
be non-conforming by a strict reading of the standard, and many
popular Fortran compilers accept it.

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

2 years ago[flang] Don't force SET_EXPONENT(I=...) argument to integer(4)
Peter Klausler [Tue, 4 Oct 2022 17:17:04 +0000 (10:17 -0700)]
[flang] Don't force SET_EXPONENT(I=...) argument to integer(4)

The implementation of the folding code for SET_EXPONENT() was written
in such a fashion as to convert the I= actual argument value to a 32-bit
integer.  Which is usually not a problem, but it's not always correct
and a test case ran into trouble with it.  Fix to allow any kind of
INTEGER without conversion.

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

2 years ago[X86] Do not emit JCC to __x86_indirect_thunk
Joao Moreira [Tue, 4 Oct 2022 21:02:18 +0000 (14:02 -0700)]
[X86] Do not emit JCC to __x86_indirect_thunk

Clang may optimize conditional tailcall blocks with the following layout:

cmp <condition>
je  tailcall_target
ret

When retpoline is in place, indirect calls are converted into direct calls to a retpoline thunk. When these indirect calls are tail calls, they may be subject to the above described optimization (there is no indirect JCC, but since now the jump is direct it can be made conditional). The above layout is non-ideal for the Linux kernel scenario because the branches into thunks may be patched back into indirect branches during runtime depending on the underlying CPU features, what would not be feasible if the binary is emitted with the optimized layout above.

Thus, prevent clang from emitting this it if CodeModel is Kernel.

Feature request from the respective kernel mailing list: https://lore.kernel.org/llvm/Yv3uI%2FMoJVctmBCh@worktop.programming.kicks-ass.net/

Reviewed By: nickdesaulniers, pengfei

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

2 years ago[RISCV] Use fixed vector types in fixed-vectors-vfnmsac-vp.ll. NFC
Craig Topper [Thu, 6 Oct 2022 18:02:08 +0000 (11:02 -0700)]
[RISCV] Use fixed vector types in fixed-vectors-vfnmsac-vp.ll. NFC

2 years ago[clang][NFC] Remove extraneous normalized value
Bill Wendling [Thu, 6 Oct 2022 18:00:41 +0000 (11:00 -0700)]
[clang][NFC] Remove extraneous normalized value

2 years ago[SimplifyLibCalls] Adjust code comment in optimizeStringLength. NFC
Bjorn Pettersson [Tue, 4 Oct 2022 18:57:29 +0000 (20:57 +0200)]
[SimplifyLibCalls] Adjust code comment in optimizeStringLength. NFC

The limitation in LibCallSimplifier::optimizeStringLength to only
optimize when the string is an i8 array was changed already in
commit 50ec0b5dceff1f3fe93 back in 2017.

We still only simplify when 's' points at an array of 'CharSize', so
the comment is still valid in the sense that we do not support
arbitrary array types.

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

2 years ago[RISCV] Cleanup some vector tests. NFC
Craig Topper [Thu, 6 Oct 2022 17:20:37 +0000 (10:20 -0700)]
[RISCV] Cleanup some vector tests. NFC

Some tests had scalable vector intrinsic names with fixed vector types.
Some had types in the wrong order.

Remove scalable vector test from fixed vector files.

Also replace insert+shuffle constexprs with fixed constant vectors.

2 years ago[LLVM][Support] Support for `llvm::cl::list`'s default values
Son Tuan Vu [Wed, 5 Oct 2022 20:04:47 +0000 (20:04 +0000)]
[LLVM][Support] Support for `llvm::cl::list`'s default values

This patch introduces support for default values of list of CL options.
It fixes the issue in https://github.com/llvm/llvm-project/issues/52667

Reviewed By: bkramer

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

2 years ago[clang][NFC] Use enum for -fstrict-flex-arrays
Bill Wendling [Mon, 3 Oct 2022 19:53:15 +0000 (12:53 -0700)]
[clang][NFC] Use enum for -fstrict-flex-arrays

Use enums for the strict flex arrays flag so that it's more readable.

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

2 years agoRevert "[DSE] Eliminate noop store even through has clobbering between LoadI and...
Arthur Eubanks [Thu, 6 Oct 2022 17:29:46 +0000 (10:29 -0700)]
Revert "[DSE] Eliminate noop store even through has clobbering between LoadI and StoreI"

This reverts commit cd8f3e75813995c1d2da35370ffcf5af3aff9c2f.

Causes miscompiles, see D132657

2 years agoSilence a signed/unsigned mismatch warning; NFC
Aaron Ballman [Thu, 6 Oct 2022 17:30:15 +0000 (13:30 -0400)]
Silence a signed/unsigned mismatch warning; NFC

2 years ago[ConstraintElimination] Remove fixme addressed in 8e3e96298f5a20.
Florian Hahn [Thu, 6 Oct 2022 17:24:15 +0000 (18:24 +0100)]
[ConstraintElimination] Remove fixme addressed in 8e3e96298f5a20.

2 years ago[InstCombine] fold sdiv with hidden common factor
Sanjay Patel [Thu, 6 Oct 2022 16:31:42 +0000 (12:31 -0400)]
[InstCombine] fold sdiv with hidden common factor

(X * Y) s/ (X << Z) --> Y s/ (1 << Z)

https://alive2.llvm.org/ce/z/yRSddG

issue #58137

2 years ago[PhaseOrdering] add test for mul + sdiv; NFC
Sanjay Patel [Thu, 6 Oct 2022 16:25:22 +0000 (12:25 -0400)]
[PhaseOrdering] add test for mul + sdiv; NFC

issue #58137

2 years ago[clang][test] Make headers unique to avoid linking issues
Ben Langmuir [Thu, 6 Oct 2022 16:11:51 +0000 (09:11 -0700)]
[clang][test] Make headers unique to avoid linking issues

Make the empty headers used by cl-pch-showincludes.cpp unique so that
filesystems that link these files together by contents will not see
different behaviour in this test, which is not testing linked files
specifically.

This was uncovered by 5ea78c4113f8 which made us stop mutating the name
of the presumed loc for the file in ContentCache, but that just surfaced
an underlying issue that the filename of multiple includes of linked
files are not separately tracked.

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

2 years ago[ConstraintElimination] Update tests to use opaque pointers.
Florian Hahn [Thu, 6 Oct 2022 17:07:25 +0000 (18:07 +0100)]
[ConstraintElimination] Update tests to use opaque pointers.

2 years ago[InstrProf] Add version into llvm-profdata
Gulfem Savrun Yeniceri [Wed, 5 Oct 2022 01:54:04 +0000 (01:54 +0000)]
[InstrProf] Add version into llvm-profdata

This patch adds support of printing profile version
into llvm-profdata which was proposed in:
https://discourse.llvm.org/t/llvm-profdata-failure-guarantees-for-code-coverage/64924

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

2 years ago[mlir][sparse] Implement insertion sort for the stable sort operator.
bixia1 [Thu, 6 Oct 2022 15:51:46 +0000 (08:51 -0700)]
[mlir][sparse] Implement insertion sort for the stable sort operator.

Reviewed By: aartbik

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

2 years ago[NFC] Replace use of !isTranslationUnit && !isNamespace with !isFileContext
Erich Keane [Thu, 6 Oct 2022 15:52:29 +0000 (08:52 -0700)]
[NFC] Replace use of !isTranslationUnit && !isNamespace with !isFileContext

isFileContext is exactly equal to these two, so simplify the function.

2 years ago[RISCV] Optimization for using compressed beqz and bnez PR#56391
Ivan Tetyushkin [Thu, 6 Oct 2022 16:22:13 +0000 (09:22 -0700)]
[RISCV] Optimization for using compressed beqz and bnez PR#56391

Optimization for using compressed beqz and bnez

If there is pattern
```
br_cc val1 constval eq/neq place
select_cc val1 constval eq/neq trueval falseval
```
and constval does not fit in compressed imm format(6 bit), but fit in
imm format(12 bit), we can replace by non compress sub and compress
c.beqz/c.bneqz:

```
addi val val -constval
c.beqz val place
```

Reviewed By: craig.topper

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

2 years agoRevert "Remove the dependency between lib/DebugInfoDWARF and MC."
Shubham Sandeep Rastogi [Thu, 6 Oct 2022 16:30:18 +0000 (09:30 -0700)]
Revert "Remove the dependency between lib/DebugInfoDWARF and MC."

This reverts commit 0008990479a2daf587c2a4f274384b2fb87247fb.

2 years ago[llvm-reduce] Remove debug metadata elements
Ellis Hoag [Wed, 5 Oct 2022 04:27:25 +0000 (21:27 -0700)]
[llvm-reduce] Remove debug metadata elements

There can be lots of `MDTuple` debug metadata nodes. For example, `globals: !{!1, !2}` in `!DICompileUnit()`. Search through all debug info to find `MDTuple`'s and remove some of their elements.

For D135114 I was able to get a reproducer with 364 lines without manually deleting elements. After this patch I got it down to 67 lines.

Reviewed By: dblaikie

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

2 years agoRemove the dependency between lib/DebugInfoDWARF and MC.
Shubham Sandeep Rastogi [Tue, 27 Sep 2022 20:08:29 +0000 (13:08 -0700)]
Remove the dependency between lib/DebugInfoDWARF and MC.

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

2 years ago[ConstraintElimination] Generalize AND matching.
Florian Hahn [Thu, 6 Oct 2022 16:17:37 +0000 (17:17 +0100)]
[ConstraintElimination] Generalize AND matching.

Extend more general matching used for chains of ORs to also support
chains of ANDs.

2 years ago[flang] Update fir.dispatch operation
Valentin Clement [Thu, 6 Oct 2022 16:10:33 +0000 (18:10 +0200)]
[flang] Update fir.dispatch operation

Update the `fir.dispatch` operation to prepare
the lowering part. `nopass` and `pass_arg_pos` attributes
are added in the arguments list so accessors are generated
by MLIR tablegen. A verifier is added as well as some tests.

This patch is part of the implementation of the poltymorphic
entities.
https://github.com/llvm/llvm-project/blob/main/flang/docs/PolymorphicEntities.md

Reviewed By: jeanPerier, PeteSteinfeld

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

2 years ago[CMake] Provide Findzstd module
Petr Hosek [Fri, 30 Sep 2022 20:33:13 +0000 (20:33 +0000)]
[CMake] Provide Findzstd module

This module is used to find the system zstd library. The imported
targets intentionally use the same name as the generate zstd config
CMake file so these can be used interchangeably.

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

2 years ago[gn build] Port 79df8e19beb9
LLVM GN Syncbot [Thu, 6 Oct 2022 16:02:20 +0000 (16:02 +0000)]
[gn build] Port 79df8e19beb9

2 years ago[Format] Drop speculative test added in previous patch, it hits asserts?
Sam McCall [Thu, 6 Oct 2022 15:57:58 +0000 (17:57 +0200)]
[Format] Drop speculative test added in previous patch, it hits asserts?

2 years ago[ADT] Add support for more formats in APFixedPoint
Tyker [Wed, 14 Sep 2022 01:55:32 +0000 (18:55 -0700)]
[ADT] Add support for more formats in APFixedPoint

Prior to this patch FixedPointSemantics and APFixedPoint only support semantics where
the Scale larger or equal to zero and the Width is larger or equal to the Scale.
This patch removes both those requirements while staying API compatible.

2 years ago[flang] Add a "not yet implemented" message for large, constant arrays
Peter Steinfeld [Wed, 5 Oct 2022 21:02:59 +0000 (14:02 -0700)]
[flang] Add a "not yet implemented" message for large, constant arrays

Rather than crashing in llvm code, nip things in the bud.

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

2 years ago[mlir][sparse] Add rewrite rules for sparse-to-sparse reshape operators.
bixia1 [Wed, 5 Oct 2022 21:33:53 +0000 (14:33 -0700)]
[mlir][sparse] Add rewrite rules for sparse-to-sparse reshape operators.

Reviewed By: aartbik

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

2 years ago[InstCombine] fold udiv with hidden common factor
Sanjay Patel [Thu, 6 Oct 2022 15:33:19 +0000 (11:33 -0400)]
[InstCombine] fold udiv with hidden common factor

(X * Y) u/ (X << Z) --> Y u>> Z

https://alive2.llvm.org/ce/z/4G9D_W

2 years ago[InstCombine] add tests for div with common factor; NFC
Sanjay Patel [Thu, 6 Oct 2022 13:42:18 +0000 (09:42 -0400)]
[InstCombine] add tests for div with common factor; NFC

2 years ago[lldb] Move breakpoint hit reset code to Target::CleanupProcess
Pavel Labath [Thu, 29 Sep 2022 14:47:52 +0000 (16:47 +0200)]
[lldb] Move breakpoint hit reset code to Target::CleanupProcess

This ensures it is run regardless of the method we use to initiate the
session (previous version did not handle connects), and it is the same
place that is used for resetting watchpoints.

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

2 years ago[lldb/gdb-server] Better reporting of launch errors
Pavel Labath [Tue, 27 Sep 2022 18:04:10 +0000 (20:04 +0200)]
[lldb/gdb-server] Better reporting of launch errors

Use our "rich error" facility to propagate error reported by the stub to
the user. lldb-server reports rich launch errors as of D133352.

To make this easier to implement, and reduce code duplication, I have
moved the vRun/A/qLaunchSuccess handling into a single
GDBRemoteCommunicationClient function.

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

2 years ago[clangd] Optimize Dex::generateProximityURIs().
Sam McCall [Tue, 4 Oct 2022 23:33:36 +0000 (01:33 +0200)]
[clangd] Optimize Dex::generateProximityURIs().

Production profiles show that generateProximityURIs is roughly 3.8% of
buildPreamble. Of this, the majority (3% of buildPreamble) is parsing
and reserializing URIs.

We can do this with ugly string manipulation instead.

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

2 years ago[Format] Fix crash when hitting eof while lexing JS template string
Sam McCall [Thu, 6 Oct 2022 11:10:19 +0000 (13:10 +0200)]
[Format] Fix crash when hitting eof while lexing JS template string

Different loop termination conditions resulted in confusion of whether
*Offset was intended to be inside or outside the token.
This ultimately led to constructing an out-of-range SourceLocation.

Fix by making Offset consistently point *after* the token.

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

2 years ago[RISCV][InsertVSETVLI] Default to MA not MU
Philip Reames [Thu, 6 Oct 2022 14:46:09 +0000 (07:46 -0700)]
[RISCV][InsertVSETVLI] Default to MA not MU

This changes the default value used for mask policy from mask undisturbed to mask agnostic. In hardware, there may be a minor preference for ta/ma, but since this is only going to apply to instructions which don't use the mask policy bit, this is functionally mostly a nop. The main value is to make future changes to using MA when legal for masked instructions easier to review by reducing test churn.

The prior code was motivated by a desire to minimize state transitions between masked and unmasked code. This patch achieves the same effect using the demanded field logic (landed in afb45ff), and there are no regressions I spotted in the test diffs. (Given the size, I have only been able to skim.) I do want to call out that regressions are possible here; the demanded analysis only works on a block local scope right now, so e.g. a tight loop mixing masked and unmasked computation might see an extra vsetvli or two.

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

2 years ago[libc++] Implement P0591R4 (Utility functions to implement uses-allocator construction)
Nikolas Klauser [Tue, 4 Oct 2022 15:55:42 +0000 (17:55 +0200)]
[libc++] Implement P0591R4 (Utility functions to implement uses-allocator construction)

Reviewed By: ldionne, #libc, huixie90

Spies: huixie90, libcxx-commits, mgorny

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

2 years ago[ConstraintElimination] Order cmps for signed <-> unsigned transfer first.
Florian Hahn [Thu, 6 Oct 2022 14:56:24 +0000 (15:56 +0100)]
[ConstraintElimination] Order cmps for signed <-> unsigned transfer first.

Make sure conditions with constant operands come before conditions
without constant operands. This increases the effectiveness of the
current signed <-> unsigned fact transfer logic.

2 years ago[test][InstCombine] Use opaque pointers in wcslen test cases. NFC
Bjorn Pettersson [Thu, 6 Oct 2022 14:42:04 +0000 (16:42 +0200)]
[test][InstCombine] Use opaque pointers in wcslen test cases. NFC

2 years ago[Clang] Fix using LTO with the new driver in RDC-mode
Joseph Huber [Wed, 5 Oct 2022 19:35:48 +0000 (14:35 -0500)]
[Clang] Fix using LTO with the new driver in RDC-mode

The new driver supports LTO for RDC-mode compilations. However, this was
not correctly handled for non-LTO compilations. HIP can handle this as
it is fed to `lld` which will perform the LTO itself. CUDA however would
require every work which is wholly useless in non-RDC mode so it should
report an error.

Reviewed By: yaxunl

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

2 years ago[mlir][llvmir] Simpler error handling in ConvertFromLLVMIR (nfc).
Tobias Gysi [Thu, 6 Oct 2022 14:11:58 +0000 (17:11 +0300)]
[mlir][llvmir] Simpler error handling in ConvertFromLLVMIR (nfc).

The revision renames some methods of the Importer and changes
the error handling to be closer the ModuleTranslation. In particular,
processValue -> lookupValue and processType -> convertType
now fail if the translation fails (instead of returning an error),
which simplifies the error handling.

The revision prepares a follow up commit that will import
LLVMIR intrinsics using tablegen.

Reviewed By: ftynse

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

2 years ago[ASTMatchers][NFC] Fix wrong code ending command in documentation comments
oToToT [Thu, 6 Oct 2022 14:25:45 +0000 (22:25 +0800)]
[ASTMatchers][NFC] Fix wrong code ending command in documentation comments

2 years ago[RISCV][InsertVSETVLI] Treat mask policy as undemanded if usesMaskPolicy is false
Philip Reames [Thu, 6 Oct 2022 14:18:55 +0000 (07:18 -0700)]
[RISCV][InsertVSETVLI] Treat mask policy as undemanded if usesMaskPolicy is false

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

2 years ago[llvm] [test] Add missing canonicalization of LLVM_ENABLE_ZSTD
Michał Górny [Thu, 6 Oct 2022 12:41:52 +0000 (14:41 +0200)]
[llvm] [test] Add missing canonicalization of LLVM_ENABLE_ZSTD

Add LLVM_ENABLE_ZSTD to llvm_canonicalize_cmake_booleans().  This is
needed to ensure that the substitutions in lit.site.cfg.py resolve
to correct Python booleans.

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

2 years agoSilence a duplicate diagnostic about K&R C function definitions
Aaron Ballman [Thu, 6 Oct 2022 14:07:16 +0000 (10:07 -0400)]
Silence a duplicate diagnostic about K&R C function definitions

We would issue the same diagnostic twice in the case that the K&R C
function definition is preceded by a static declaration of the function
with a prototype.

Fixes #58181

2 years ago[clang][C++20] Note github issue in the FIXME matching requires clause.
Utkarsh Saxena [Thu, 6 Oct 2022 11:51:17 +0000 (13:51 +0200)]
[clang][C++20] Note github issue in the FIXME matching requires clause.

2 years ago[ConstraintElimination] Add tests with logical ANDs.
Florian Hahn [Thu, 6 Oct 2022 13:50:12 +0000 (14:50 +0100)]
[ConstraintElimination] Add tests with logical ANDs.

2 years ago[VectorCombine] remove unused test prefixes; NFC
Sanjay Patel [Thu, 6 Oct 2022 13:39:14 +0000 (09:39 -0400)]
[VectorCombine] remove unused test prefixes; NFC

These would change with D135278, but for now everything is the same.

2 years ago[gn build] port d1f13c54f1728 (Inclusions/Stdlib)
Nico Weber [Thu, 6 Oct 2022 13:38:23 +0000 (09:38 -0400)]
[gn build] port d1f13c54f1728 (Inclusions/Stdlib)

2 years ago[VectorCombine] add tests for scalar fneg with insert/extract; NFC
Sanjay Patel [Wed, 5 Oct 2022 12:55:22 +0000 (08:55 -0400)]
[VectorCombine] add tests for scalar fneg with insert/extract; NFC

2 years ago[gn build] port d785a8eaa25d
Nico Weber [Thu, 6 Oct 2022 11:31:06 +0000 (07:31 -0400)]
[gn build] port d785a8eaa25d

2 years ago[C++20][Clang] P2468R2 The Equality Operator You Are Looking For
Utkarsh Saxena [Fri, 23 Sep 2022 13:02:28 +0000 (15:02 +0200)]
[C++20][Clang] P2468R2 The Equality Operator You Are Looking For

Implement
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2468r2.html.

Primarily we now accept
```
template<typename T> struct CRTPBase {
  bool operator==(const T&) const;
  bool operator!=(const T&) const;
};
struct CRTP : CRTPBase<CRTP> {};
bool cmp_crtp = CRTP() == CRTP();
bool cmp_crtp2 = CRTP() != CRTP();
```

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

2 years ago[CodeGenCXX] Remove typed pointer check lines from test (NFC)
Nikita Popov [Thu, 6 Oct 2022 11:05:13 +0000 (13:05 +0200)]
[CodeGenCXX] Remove typed pointer check lines from test (NFC)

This test already has check lines for opaque pointers, remove the
unnecessary typed pointer check lines.

2 years ago[ConstraintElimination] Generalize OR matching.
Florian Hahn [Thu, 6 Oct 2022 10:56:21 +0000 (11:56 +0100)]
[ConstraintElimination] Generalize OR matching.

Extend OR handling to traverse chains of ORs.

2 years ago[RelativeVTablesABI] Convert tests to opaque pointers (NFC)
Nikita Popov [Thu, 6 Oct 2022 10:36:10 +0000 (12:36 +0200)]
[RelativeVTablesABI] Convert tests to opaque pointers (NFC)

Converted using https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34
with manual fixup, primarily to drop check lines for types that
no longer appear with opaque pointers.

2 years ago[Test] Add test showing missed branch elimination due to loop predication transform
Dmitry Makogon [Thu, 6 Oct 2022 09:30:25 +0000 (16:30 +0700)]
[Test] Add test showing missed branch elimination due to loop predication transform

2 years ago[mlir] Add bar.warp.sync to NVVM
Guray Ozen [Wed, 5 Oct 2022 10:23:32 +0000 (12:23 +0200)]
[mlir] Add bar.warp.sync to NVVM

It adds the missing `bar.warp.sync` to the nvvm dialect. It is a barrier to synchronize for threads in a warp.

Reviewed By: ftynse

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

2 years ago[CodeGenCXX] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 6 Oct 2022 10:12:57 +0000 (12:12 +0200)]
[CodeGenCXX] Convert some tests to opaque pointers (NFC)

Conversion done using the script at
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34.

These are tests where the conversion worked out of the box and no
manual fixup was performed.

2 years agoRevert "[CMake] Provide Findzstd module"
Nikita Popov [Thu, 6 Oct 2022 10:02:13 +0000 (12:02 +0200)]
Revert "[CMake] Provide Findzstd module"

This reverts commit 849059861c63f5d89a6956191ecb8da8acf16bdb.

This breaks running llvm tests:

llvm-lit: /home/npopov/repos/llvm-project/llvm/utils/lit/lit/TestingConfig.py:138: fatal: unable to parse config file '/home/npopov/repos/llvm-project/build/test/lit.site.cfg.py', traceback: Traceback (most recent call last):
  File "/home/npopov/repos/llvm-project/llvm/utils/lit/lit/TestingConfig.py", line 127, in load_from_path
    exec(compile(data, path, 'exec'), cfg_globals, None)
  File "/home/npopov/repos/llvm-project/build/test/lit.site.cfg.py", line 48, in <module>
    config.have_zstd = FALSE
NameError: name 'FALSE' is not defined

2 years agoRevert "Revert "[clang][Lex] Fix a crash on malformed string literals""
Kadir Cetinkaya [Thu, 6 Oct 2022 09:39:43 +0000 (11:39 +0200)]
Revert "Revert "[clang][Lex] Fix a crash on malformed string literals""

This reverts commit feea7ef23cb1bef92d363cc613052f8f3a878fc2.
Drops the test case, see https://reviews.llvm.org/D135161#3839510

2 years ago[clangd] Avoid scanning up to end of file on each comment!
Sam McCall [Wed, 5 Oct 2022 20:23:10 +0000 (22:23 +0200)]
[clangd] Avoid scanning up to end of file on each comment!

Assigning char* (pointing at comment start) to StringRef was causing us
to scan the rest of the source file looking for the null terminator.

This seems to be eating about 8% of our *total* CPU!

While fixing this, factor out the common bits from the two places we're
parsing IWYU pragmas.

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

2 years ago[clang] Add Create method for CXXBoolLiteralExpr
David Spickett [Wed, 5 Oct 2022 11:22:54 +0000 (11:22 +0000)]
[clang] Add Create method for CXXBoolLiteralExpr

Reviewed By: shafik

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

2 years ago[Local] Fix unused variable warnings (NFC)
Nikita Popov [Thu, 6 Oct 2022 08:30:59 +0000 (10:30 +0200)]
[Local] Fix unused variable warnings (NFC)

2 years ago[AA] Update unit test missed in previous commit (NFC)
Nikita Popov [Thu, 6 Oct 2022 08:26:24 +0000 (10:26 +0200)]
[AA] Update unit test missed in previous commit (NFC)

Missed this unit test use in 3d0b5f019e85eab5e7153516d3f6e9e4f2b9135b.

2 years ago[CMake] Provide Findzstd module
Petr Hosek [Fri, 30 Sep 2022 20:33:13 +0000 (20:33 +0000)]
[CMake] Provide Findzstd module

This module is used to find the system zstd library. The imported
targets intentionally use the same name as the generate zstd config
CMake file so these can be used interchangeably.

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