platform/upstream/llvm.git
19 months ago[flang] Lowering and runtime support for F08 transformational intrinsics: BESSEL_JN...
Tarun Prabhu [Mon, 19 Dec 2022 14:51:59 +0000 (07:51 -0700)]
[flang] Lowering and runtime support for F08 transformational intrinsics: BESSEL_JN and BESSEL_YN

The runtime implementation uses the recurrence relations

`J(n-1, x) = (2.0 / x) * n * J(n, x) - J(n+1, x)`
`Y(n+1, x) = (2.0 / x) * n * Y(n, x) - Y(n-1, x)`

(see https://dlmf.nist.gov/10.74.iv and https://dlmf.nist.gov/10.6.E1).

Although the standard requires that `N1` and `N2` in `BESSEL_JN(N1, N2, x)`
and `BESSEL_YN(N1, N2, x)` be non-negative, this is not checked in the
runtime functions. This is in keeping with some other compilers which also
return some results when `N1` and/or `N2` are negative.

The special case for `x == 0` is  handled in different runtime functions
for each of `BESSEL_JN` and `BESSEL_YN`. The lowering code checks for this
case and inserts the checks and the appropriate runtime calls in FIR.

The existing tests for the two intrinsics was modified to keep the style
consistent with the additional lowering tests that were added.

19 months ago[LoopPeel] Expose ValueMap of last peeled iteration. NFC
Anna Thomas [Thu, 17 Nov 2022 18:40:33 +0000 (13:40 -0500)]
[LoopPeel] Expose ValueMap of last peeled iteration. NFC

The value map of last peeled iteration is computed within peelLoop API.
This patch exposes it for callers of peelLoop.
While this is not currently used by upstream passes, we have a usecase
downstream which benefits from this API update. Future users of peelLoop
can also use the ValueMap if needed.

Similar value maps are exposed by other loop utilities such as loop
cloning.

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

19 months agoSupport: Make TypeSize constructors constexpr
Matt Arsenault [Mon, 19 Dec 2022 03:14:00 +0000 (22:14 -0500)]
Support: Make TypeSize constructors constexpr

This is to enable LLT to be constexpr

19 months ago[msan] Convert tests to check 'target=...'
Paul Robinson [Mon, 19 Dec 2022 14:44:27 +0000 (06:44 -0800)]
[msan] Convert tests to check 'target=...'

Part of the project to eliminate special handling for triples in lit
expressions.

19 months agoAMDGPU: Convert a few more special case tests to opaque pointers
Matt Arsenault [Mon, 19 Dec 2022 14:31:17 +0000 (09:31 -0500)]
AMDGPU: Convert a few more special case tests to opaque pointers

lower-kernargs.ll needed a switch to use update_test_checks metadata
matching.

19 months agoAMDGPU: Update some tests to use opaque pointers
Matt Arsenault [Mon, 19 Dec 2022 14:23:45 +0000 (09:23 -0500)]
AMDGPU: Update some tests to use opaque pointers

vectorize-buffer-fat-pointer.ll required a manual check line fix.
vector-alloca-addrspacecast.ll required a manual fixup of a check
line. partial-regcopy-and-spill-missed-at-regalloc.ll required
re-running update_mir_test_checks. The HSA metadata tests required
avoiding the script touching the type name in the metadata.

annotate-noclobber.ll ran into one update script bug. It deleted a
check line with a 0 offset GEP, moving the following -NEXT check
logically up one line.

19 months agoAMDGPU: Convert some amdgpu-codegenprepare tests to opaque pointers
Matt Arsenault [Mon, 5 Dec 2022 18:06:16 +0000 (13:06 -0500)]
AMDGPU: Convert some amdgpu-codegenprepare tests to opaque pointers

amdgpu-late-codegenprepare.ll required running update_test_checks
after converting.

19 months ago[lsan] Convert tests to check 'target=...'
Paul Robinson [Mon, 19 Dec 2022 14:24:50 +0000 (06:24 -0800)]
[lsan] Convert tests to check 'target=...'

Part of the project to eliminate special handling for triples in lit
expressions.

19 months ago[BPFAbstractMemberAccess] Use WeakTrackingVH for Base
Nikita Popov [Mon, 19 Dec 2022 13:47:28 +0000 (14:47 +0100)]
[BPFAbstractMemberAccess] Use WeakTrackingVH for Base

The value will be RAUWd, make sure the reference in CallInfo gets
updated.

It seems like this was not a problem without opaque pointers due
to the bitcast in between.

19 months ago[include-cleaner] Use expansion locations for macros.
Viktoriia Bakalova [Thu, 8 Dec 2022 10:20:14 +0000 (10:20 +0000)]
[include-cleaner] Use expansion locations for macros.

Use expansion locations for target symbol decls when finding headers for macros.
Fix: https://github.com/llvm/llvm-project/issues/59392
Differential Revision: https://reviews.llvm.org/D139716

19 months ago[NFC][llvm-exegesis] Try to fix GCC7 build
Roman Lebedev [Mon, 19 Dec 2022 14:14:55 +0000 (17:14 +0300)]
[NFC][llvm-exegesis] Try to fix GCC7 build

https://lab.llvm.org/staging/#/builders/235/builds/1090

19 months ago[SeparateConstOffsetFromGEP] Remove TypeSize error when collecting constant indices.
Paul Walker [Fri, 16 Dec 2022 17:14:38 +0000 (17:14 +0000)]
[SeparateConstOffsetFromGEP] Remove TypeSize error when collecting constant indices.

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

19 months agoAMDGPU: Convert some tests to opaque pointers
Matt Arsenault [Mon, 19 Dec 2022 13:35:55 +0000 (08:35 -0500)]
AMDGPU: Convert some tests to opaque pointers

These required update_mir_test_checks.

19 months agoFix tests for commit 658ed9547cdd6657895339a6c390c31aa77a5698.
Doru Bercea [Mon, 19 Dec 2022 13:00:05 +0000 (07:00 -0600)]
Fix tests for commit 658ed9547cdd6657895339a6c390c31aa77a5698.

19 months ago[BPF] Restore failing offset-reloc-cast-struct tests (NFC)
Nikita Popov [Mon, 19 Dec 2022 13:30:29 +0000 (14:30 +0100)]
[BPF] Restore failing offset-reloc-cast-struct tests (NFC)

After opaque pointer conversion these tests fail with a use after
free under asan, due to bugs in BPFAbstractMemberAccess. For now,
restore the tests to unbreak build bots.

19 months ago[lit] Script to automate use of %(line-n). Use in CodeComplete tests.
Sam McCall [Fri, 16 Dec 2022 14:59:11 +0000 (15:59 +0100)]
[lit] Script to automate use of %(line-n). Use in CodeComplete tests.

Tests where the RUN-lines/CHECK-ed output refer to line numbers in the test
file are a maintenance burden, as inserting text in the appropriate place
invalidates all the subsequent line numbers.

Lit supports %(line+n) for this, and FileCheck supports [[@LINE+N]].
But many existing tests don't make use of it and still need to be modified.

This commit adds a script that can find line numbers in tests according to a
regex and replace them with the appropriate relative-line reference.
It contains some options to avoid inappropriately rewriting tests where absolute
numbers are appropriate: a "nearby" threshold and a refusal by default to
replace only some matched line numbers.

I've applied it to CodeComplete tests, this proves the concept but also are the
single worst group of tests I've seen in this respect.
These changes are likely to hit merge conflicts, but can be regenerated with:

```
find ../clang/test/CodeCompletion/ -type f | grep -v /Inputs/ | xargs ../llvm/utils/relative_lines.py --verbose --near=20 --pattern='-code-completion-at[ =]%s:(\\d+):' --pattern='requires fix-it: {(\d+):\d+-(\d+):\d+}'
````

As requested in https://reviews.llvm.org/D140044

Fixes https://github.com/llvm/llvm-project/issues/59553

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

19 months ago[SystemZ] Fix test (NFC)
Nikita Popov [Mon, 19 Dec 2022 13:14:00 +0000 (14:14 +0100)]
[SystemZ] Fix test (NFC)

Broken during opaque pointer conversion. I did not notice because
it requires -Drun_long_tests=1 to run.

Run the test through instnamer so updating it works properly.

19 months agoInstCombine: Match pattern that appears in clang's __builtin_isnormal
Matt Arsenault [Sat, 3 Dec 2022 19:13:50 +0000 (14:13 -0500)]
InstCombine: Match pattern that appears in clang's __builtin_isnormal

and (fcmp ord x, 0), (fcmp u* x, inf) -> fcmp o* x, inf
and (fcmp ord x, 0), (fcmp u* fabs(x), inf) -> fcmp o* x, inf

Clang emits this peculiar pattern as an isfinite check in
__builtin_isnormal which can be simplified. We should fix clang to
emit this in the first place, but should also fold it here.

19 months agoInstCombine: Add baseline tests for and (fcmp ord x), (fcmp u* x)
Matt Arsenault [Sat, 3 Dec 2022 15:12:00 +0000 (10:12 -0500)]
InstCombine: Add baseline tests for and (fcmp ord x), (fcmp u* x)

19 months ago[include-cleaner] Handle dependent type members in AST.
Viktoriia Bakalova [Tue, 6 Dec 2022 10:58:25 +0000 (10:58 +0000)]
[include-cleaner] Handle dependent type members in AST.

Handles dependent type members in AST.

Fix: https://github.com/llvm/llvm-project/issues/59354
Differential Revision: https://reviews.llvm.org/D139409

19 months ago[gn build] Port
LLVM GN Syncbot [Mon, 19 Dec 2022 12:30:15 +0000 (12:30 +0000)]
[gn build] Port

19 months agoFix abs labs and llabs to work in C code.
Doru Bercea [Fri, 9 Dec 2022 17:01:04 +0000 (11:01 -0600)]
Fix abs labs and llabs to work in C code.

19 months agoInstCombine: Add baseline test for pattern in clang's isnormal
Matt Arsenault [Sat, 3 Dec 2022 20:47:58 +0000 (15:47 -0500)]
InstCombine: Add baseline test for pattern in clang's isnormal

Clang emits this peculiar pattern as an isfinite check in
__builtin_isnormal which can be simplified. We should fix clang to
emit this in the first place, but should also fold it here.

19 months ago[InstCombine][NFC] Add tests of combining ZExt(B-A) + ZExt(A) to ZExt(B)
luxufan [Mon, 19 Dec 2022 12:10:12 +0000 (20:10 +0800)]
[InstCombine][NFC] Add tests of combining ZExt(B-A) + ZExt(A) to ZExt(B)

19 months agoFix host call to nohost function with host variant.
Doru Bercea [Thu, 15 Dec 2022 20:34:56 +0000 (14:34 -0600)]
Fix host call to nohost function with host variant.

19 months ago[XCore] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 12:12:03 +0000 (13:12 +0100)]
[XCore] Convert some tests to opaque pointers (NFC)

19 months ago[X86] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 12:09:40 +0000 (13:09 +0100)]
[X86] Convert some tests to opaque pointers (NFC)

19 months ago[WinEH] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 12:08:24 +0000 (13:08 +0100)]
[WinEH] Convert some tests to opaque pointers (NFC)

19 months ago[WebAssembly] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 12:07:12 +0000 (13:07 +0100)]
[WebAssembly] Convert some tests to opaque pointers (NFC)

19 months ago[VE] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 12:06:08 +0000 (13:06 +0100)]
[VE] Convert some tests to opaque pointers (NFC)

19 months ago[Thumb] Convert tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 12:04:48 +0000 (13:04 +0100)]
[Thumb] Convert tests to opaque pointers (NFC)

19 months ago[Thumb2] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 12:03:31 +0000 (13:03 +0100)]
[Thumb2] Convert some tests to opaque pointers (NFC)

19 months ago[SystemZ] Convert test to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 12:01:54 +0000 (13:01 +0100)]
[SystemZ] Convert test to opaque pointers (NFC)

19 months ago[RISCV] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 12:00:01 +0000 (13:00 +0100)]
[RISCV] Convert some tests to opaque pointers (NFC)

19 months ago[PowerPC] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 11:58:16 +0000 (12:58 +0100)]
[PowerPC] Convert some tests to opaque pointers (NFC)

19 months ago[NVPTX] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 11:56:42 +0000 (12:56 +0100)]
[NVPTX] Convert some tests to opaque pointers (NFC)

19 months ago[Mips] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 11:55:15 +0000 (12:55 +0100)]
[Mips] Convert some tests to opaque pointers (NFC)

19 months ago[MIR] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 11:54:50 +0000 (12:54 +0100)]
[MIR] Convert some tests to opaque pointers (NFC)

19 months ago[Hexagon] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 11:52:45 +0000 (12:52 +0100)]
[Hexagon] Convert some tests to opaque pointers (NFC)

19 months ago[CodeGen] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 11:48:20 +0000 (12:48 +0100)]
[CodeGen] Convert some tests to opaque pointers (NFC)

19 months ago[analyzer] Fix crash inside RangeConstraintManager.cpp introduced by D112621
Balazs Benics [Mon, 19 Dec 2022 11:49:43 +0000 (12:49 +0100)]
[analyzer] Fix crash inside RangeConstraintManager.cpp introduced by D112621

It seems like `LHS` and `RHS` could be empty range sets.
This caused an assertion failure inside RangeConstraintManager.

I'm hoisting out the check from the function into the call-site.
This way we could assert that we only want to deal with non-empty range
sets.

The relevant part of the trace:
```
 #6 0x00007fe6ff5f81a6 __assert_fail_base (/lib64/libc.so.6+0x2f1a6)
 #7 0x00007fe6ff5f8252 (/lib64/libc.so.6+0x2f252)
 #8 0x00000000049caed2 (anonymous namespace)::SymbolicRangeInferrer::VisitBinaryOperator(clang::ento::RangeSet, clang::BinaryOperatorKind, clang::ento::RangeSet, clang::QualType) RangeConstraintManager.cpp:0:0
 #9 0x00000000049c9867 (anonymous namespace)::SymbolicRangeInferrer::infer(clang::ento::SymExpr const*) RangeConstraintManager.cpp:0:0
#10 0x00000000049bebf5 (anonymous namespace)::RangeConstraintManager::assumeSymNE(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::SymExpr const*, llvm::APSInt const&, llvm::APSInt const&) RangeConstraintManager.cpp:0:0
#11 0x00000000049d368c clang::ento::RangedConstraintManager::assumeSymUnsupported(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::SymExpr const*, bool) (../../main-github/llvm/build-all/bin/clang+0x49d368c)
#12 0x00000000049f0b09 clang::ento::SimpleConstraintManager::assumeAux(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::NonLoc, bool) (../../main-github/llvm/build-all/bin/clang+0x49f0b09)
#13 0x00000000049f096a clang::ento::SimpleConstraintManager::assume(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::NonLoc, bool) (../../main-github/llvm/build-all/bin/clang+0x49f096a)
#14 0x00000000049f086d clang::ento::SimpleConstraintManager::assumeInternal(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::DefinedSVal, bool) (../../main-github/llvm/build-all/bin/clang+0x49f086d)
#15 0x000000000492d3e3 clang::ento::ConstraintManager::assumeDual(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::DefinedSVal) (../../main-github/llvm/build-all/bin/clang+0x492d3e3)
#16 0x0000000004955b6d clang::ento::ExprEngine::evalEagerlyAssumeBinOpBifurcation(clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet&, clang::Expr const*) (../../main-github/llvm/build-all/bin/clang+0x4955b6d)
#17 0x00000000049514b6 clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (../../main-github/llvm/build-all/bin/clang+0x49514b6)
#18 0x000000000494c73e clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*, clang::ento::ExplodedNode*) (../../main-github/llvm/build-all/bin/clang+0x494c73e)
#19 0x000000000494c459 clang::ento::ExprEngine::processCFGElement(clang::CFGElement, clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) (../../main-github/llvm/build-all/bin/clang+0x494c459)
#20 0x000000000492f3d0 clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*, unsigned int, clang::ento::ExplodedNode*) (../../main-github/llvm/build-all/bin/clang+0x492f3d0)
#21 0x000000000492e1f6 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) (../../main-github/llvm/build-all/bin/clang+0x492e1f6)
```

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

19 months ago[ValueTracking] Consider single poison operands in propgatesPoison.
Florian Hahn [Mon, 19 Dec 2022 11:47:51 +0000 (11:47 +0000)]
[ValueTracking] Consider single poison operands in propgatesPoison.

This patch updates propgatesPoison to take a Use as argument and
propagatesPoison now returns true if the passed in operand causes the
user to yield poison if the operand is poison

This allows propagating poison if the condition of a select is poison.
This helps improve results for programUndefinedIfUndefOrPoison.

Reviewed By: nikic

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

19 months ago[BPF] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 11:46:13 +0000 (12:46 +0100)]
[BPF] Convert some tests to opaque pointers (NFC)

19 months ago[ARM] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 11:44:09 +0000 (12:44 +0100)]
[ARM] Convert some tests to opaque pointers (NFC)

19 months ago[AMDGPU] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 11:39:01 +0000 (12:39 +0100)]
[AMDGPU] Convert some tests to opaque pointers (NFC)

19 months ago[AMDGPU][CodeGen] Support raw format TFE buffer loads other than byte, short and...
Ivan Kosarev [Mon, 19 Dec 2022 11:07:41 +0000 (11:07 +0000)]
[AMDGPU][CodeGen] Support raw format TFE buffer loads other than byte, short and d16 ones.

Reviewed By: arsenm

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

19 months ago[AArch64] Convert some tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 11:13:38 +0000 (12:13 +0100)]
[AArch64] Convert some tests to opaque pointers (NFC)

19 months ago[mlir][Bazel] Add ModuleImport sources to FromLLVMIRTranslation target.
Adrian Kuegel [Mon, 19 Dec 2022 11:04:47 +0000 (12:04 +0100)]
[mlir][Bazel] Add ModuleImport sources to FromLLVMIRTranslation target.

19 months ago[X86] Fix SLM uops counts for AES instructions
Simon Pilgrim [Mon, 19 Dec 2022 11:03:41 +0000 (11:03 +0000)]
[X86] Fix SLM uops counts for AES instructions

Based off llvm-exegesis captures, confirmed with uops.info

19 months ago[X86] Add default LoadUOps argument to Intel models WriteResPair macro
Simon Pilgrim [Sat, 17 Dec 2022 22:21:45 +0000 (22:21 +0000)]
[X86] Add default LoadUOps argument to Intel models WriteResPair macro

This will make it easier to override the folded uop count on a class-by-class basis

19 months ago[flang] Fix llvm::Optional warning caused by D140220
Jean Perier [Mon, 19 Dec 2022 10:40:25 +0000 (02:40 -0800)]
[flang] Fix llvm::Optional warning caused by D140220

Using llvm::Optional::value() was just deprecated in LLVM.
Remove the usage that was added by D140220 and replace it by an assert.

https://lab.llvm.org/buildbot/#/builders/160/builds/14222

19 months ago[WebAssembly] Fix crash when selecting 64 bit lane extract operand
Luke Lau [Fri, 16 Dec 2022 12:20:26 +0000 (12:20 +0000)]
[WebAssembly] Fix crash when selecting 64 bit lane extract operand

The tablegen patterns on vector_extract only match i32 constants, but
on wasm64 these come in as i64 constants. In certain situations this
would cause crashes whenever it couldn't select an extract_vector_elt
instruction.
Rather than add duplicate patterns for every instruction, this just
canonicalizes the constant to be i32 when lowering.
Fixes https://github.com/llvm/llvm-project/issues/57577

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

19 months ago[Bitcode] Convert tests to opaque pointers (NFC)
Nikita Popov [Mon, 19 Dec 2022 10:13:37 +0000 (11:13 +0100)]
[Bitcode] Convert tests to opaque pointers (NFC)

19 months ago[mlir][llvm] Move LLVM IR import into separate file (NFC).
Tobias Gysi [Mon, 19 Dec 2022 10:10:49 +0000 (11:10 +0100)]
[mlir][llvm] Move LLVM IR import into separate file (NFC).

The revision renames the Importer to ModuleImport and moves the class
out of the ConvertFromLLVMIR.cpp file into ModuleImport.h and
ModuleImport.cpp. Additionally, it introduces two helper methods
on the ModuleImport class that convert functions and globals, and it
merges the translateLLVMIRToModule function into the
registerFromLLVMIRTranslation function to match the design of
the MLIR to LLVM IR export.

This restructuring is a step towards the file structure of the export
and a preparation for an extensible import
https://discourse.llvm.org/t/rfc-extensible-llvm-ir-import/67256/6 that
uses a dialect interface to import intrinsics and metadata.

Reviewed By: ftynse

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

19 months ago[flang] Lower statement function references in HLFIR
Jean Perier [Mon, 19 Dec 2022 10:11:23 +0000 (11:11 +0100)]
[flang] Lower statement function references in HLFIR

Enable lowering of statement function references in HLFIR.  This follows
the same principle as statement function lowering with the current
lowering:
- Actual arguments are lowered and mapped to the statement function
  dummy symbols.
- "HostAssociated" symbols are mapped to their host values (these are
  the symbols referred to inside the statement function expressions that
  are not statement function dummies. e.g: `x` in `stmt_func(i) =
  x(i)`).
- The statement function expression is evaluated.

evaluate::SetLength has to be lowered to deal with statement functions
returning characters since the front-end is generating one to ensure the
statement function expression value is trimmed/padded to match the statement
function declared type.

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

19 months ago[lldb] Modernize sprintf in FormatEntity.cpp
Pavel Labath [Mon, 19 Dec 2022 09:47:53 +0000 (10:47 +0100)]
[lldb] Modernize sprintf in FormatEntity.cpp

Avoid buffer overflows with large indexes, and spurious nul characters
with small ones.

19 months ago[MLIR][Bufferization] Remove extra trailing spaces (NFC)
Adrian Kuegel [Mon, 19 Dec 2022 09:42:47 +0000 (10:42 +0100)]
[MLIR][Bufferization] Remove extra trailing spaces (NFC)

19 months ago[mlir][vector] Add scalar vector xfer to memref patterns
Matthias Springer [Mon, 19 Dec 2022 09:24:46 +0000 (10:24 +0100)]
[mlir][vector] Add scalar vector xfer to memref patterns

These patterns devectorize scalar transfers such as vector<f32> or vector<1xf32>.

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

19 months ago[mlir][vector] Fix error handling in VectorizationState::initState
Matthias Springer [Mon, 19 Dec 2022 08:59:21 +0000 (09:59 +0100)]
[mlir][vector] Fix error handling in VectorizationState::initState

This function used to create new ops even if the vectorization failed. Those ops were then folded away. This caused a failure of the GreedyPatternRewriter, which no longer terminated (each time the IR is modified => one more iteration).

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

19 months ago[mlir][Bazel] Add missing dependency to TensorDialect.
Adrian Kuegel [Mon, 19 Dec 2022 09:03:44 +0000 (10:03 +0100)]
[mlir][Bazel] Add missing dependency to TensorDialect.

19 months ago[CLANG] XFAIL c-strings.c & volatile-1.c AArch64/Windows
Muhammad Omair Javaid [Mon, 19 Dec 2022 09:00:10 +0000 (14:00 +0500)]
[CLANG] XFAIL c-strings.c & volatile-1.c AArch64/Windows

c-strings.c was marked XFAIL for msvc ABI on AArch64/Windows platform.
But it is failing due to alignment issue on WoA for both msvc and gnu
gnu ABIs. I am going to mark them as XFAIL for both.

19 months ago[mlir] optionally allow repeated handles in transform dialect
Alex Zinenko [Thu, 15 Dec 2022 18:48:09 +0000 (18:48 +0000)]
[mlir] optionally allow repeated handles in transform dialect

Some operations may be able to deal with handles pointing to the same
operation when the handle is consumed. For example, merge handles with
deduplication doesn't actually destroy payload operations and is
specifically intended to remove the situation with duplicates. Add a
method to the transform interface to allow ops to declare they can
support repeated handles.

Reviewed By: springerm

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

19 months agoRevert "[lldb] Remove redundant .c_str() and .get() calls"
Muhammad Omair Javaid [Mon, 19 Dec 2022 08:50:31 +0000 (13:50 +0500)]
Revert "[lldb] Remove redundant .c_str() and .get() calls"

This reverts commit fbaf48be0ff6fb24b9aa8fe9c2284fe88a8798dd.

This has broken all LLDB buildbots:
https://lab.llvm.org/buildbot/#/builders/68/builds/44990
https://lab.llvm.org/buildbot/#/builders/96/builds/33160

19 months ago[mlir] Apply ClangTidy readability finding.
Adrian Kuegel [Mon, 19 Dec 2022 08:50:43 +0000 (09:50 +0100)]
[mlir] Apply ClangTidy readability finding.

Use empty() instead of checking for size 0.

19 months ago[flang] Add hlfir.set_length operation
Jean Perier [Mon, 19 Dec 2022 08:50:13 +0000 (09:50 +0100)]
[flang] Add hlfir.set_length operation

This will implement evaluate::SetLength where the length of
a character entity is changed (with trimming and padding).

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

19 months ago[flang][NFC] move getIntIfConstant into FIROpsSupport.h
Jean Perier [Mon, 19 Dec 2022 08:49:06 +0000 (09:49 +0100)]
[flang][NFC] move getIntIfConstant into FIROpsSupport.h

The motivation is to have it accessible in HLFIROps.cpp to
use it in hlfir.set_length builder to build the result length
type as best as possible.

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

19 months ago[Examples] Fix build (NFC)
Nikita Popov [Mon, 19 Dec 2022 08:38:44 +0000 (09:38 +0100)]
[Examples] Fix build (NFC)

Can't use VLA at file scope.

19 months ago[include-cleaner] Fix a missing review comment.
Haojian Wu [Mon, 19 Dec 2022 08:12:35 +0000 (09:12 +0100)]
[include-cleaner] Fix a missing review comment.

I forgot to add the change to the commit when committing.

19 months ago[MLIR][Bufferization] Introduce `EmptyTensorToAllocTensorOp`
Lorenzo Chelini [Wed, 14 Dec 2022 13:47:01 +0000 (14:47 +0100)]
[MLIR][Bufferization] Introduce `EmptyTensorToAllocTensorOp`

Introduce a new transform operation to replace `tensor.empty` with
`alloc_tensor` operations. The operation is a pass-through if the target
operation is already a `alloc_tensor`; otherwise, it expects a
`tensor.empty` as a target. Currently, it does not return any results.

The operation is expected to run before `one_shot_bufferize` as
`one_shot_bufferize` rejects `tensor.empty`.

Reviewed By: springerm

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

19 months ago[Bazel] Remove define HAVE_LSEEK64 to match cmake config.
Adrian Kuegel [Mon, 19 Dec 2022 08:05:43 +0000 (09:05 +0100)]
[Bazel] Remove define HAVE_LSEEK64 to match cmake config.

19 months ago[include-cleaner] Fix the member-expr-access usage for sugar type.
Haojian Wu [Thu, 15 Dec 2022 13:16:54 +0000 (14:16 +0100)]
[include-cleaner] Fix the member-expr-access usage for sugar type.

Fixes https://github.com/llvm/llvm-project/issues/59533

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

19 months agoFix 'underline too short' failure
Qiu Chaofan [Mon, 19 Dec 2022 07:29:40 +0000 (15:29 +0800)]
Fix 'underline too short' failure

19 months ago[Intrinsic] Rename flt.rounds intrinsic to get.rounding
Qiu Chaofan [Mon, 19 Dec 2022 07:20:45 +0000 (15:20 +0800)]
[Intrinsic] Rename flt.rounds intrinsic to get.rounding

Address the inconsistency between FLT_ROUNDS_ and SET_ROUNDING SDAG
node. Rename FLT_ROUNDS_ to GET_ROUNDING and add llvm.get.rounding
intrinsic to replace flt.rounds.

Reviewed By: nikic

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

19 months ago[mlir][transform] Add PackedOrDynamicIndexList helper
Matthias Springer [Mon, 19 Dec 2022 06:57:46 +0000 (07:57 +0100)]
[mlir][transform] Add PackedOrDynamicIndexList helper

This customer parser/printer is similar to DynamicIndexList, but has special syntax for the case where one handle represents the entire list.

Example:
```
// Regular index list
[10, 20, %val]

// Packed handle (no square parentheses)
%val
```

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

19 months ago[AIX][BigArchive] Treat the archive is empty if the first child member offset is...
Kai Luo [Mon, 19 Dec 2022 05:01:55 +0000 (13:01 +0800)]
[AIX][BigArchive] Treat the archive is empty if the first child member offset is zero

If the archive contains free list and contains no member file, the buffer length doesn't equal to length of the header.

Reviewed By: Esme, DiggerLin, #powerpc

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

19 months ago[mlir][python] llvm::Optional::value => operator*
Fangrui Song [Mon, 19 Dec 2022 04:28:55 +0000 (04:28 +0000)]
[mlir][python] llvm::Optional::value => operator*

And convert it to std::optional while updating.

19 months agoPPC: Implement null target streamer
Matt Arsenault [Sat, 29 Oct 2022 19:17:23 +0000 (12:17 -0700)]
PPC: Implement null target streamer

19 months ago[InstCombine] `sinkNotIntoOtherHandOfLogicalOp()`: don't forget to re-set insert...
Roman Lebedev [Mon, 19 Dec 2022 02:17:03 +0000 (05:17 +0300)]
[InstCombine] `sinkNotIntoOtherHandOfLogicalOp()`: don't forget to re-set insert position

Several bots are unhappy, and this appears to be the reason:
we might be inserting into wrong basic block,
one that does not dominate the I.

19 months ago[InstCombine] `sinkNotIntoOtherHandOfLogicalOp()`: allow extra invertible uses of...
Roman Lebedev [Mon, 19 Dec 2022 01:21:51 +0000 (04:21 +0300)]
[InstCombine] `sinkNotIntoOtherHandOfLogicalOp()`: allow extra invertible uses of hand-to-invert

19 months ago[NFC][InstCombine] Improve test coverage for invertible extra uses of hands of logical op
Roman Lebedev [Mon, 19 Dec 2022 01:21:46 +0000 (04:21 +0300)]
[NFC][InstCombine] Improve test coverage for invertible extra uses of hands of logical op

While there, reduce bitwidth, we really don't care about testing i32 specifically.

19 months ago[InstCombine] Support sinking `not` into logical operand with invertible hands
Roman Lebedev [Sun, 18 Dec 2022 23:50:49 +0000 (02:50 +0300)]
[InstCombine] Support sinking `not` into logical operand with invertible hands

The important bit here is that we gracefully handle other uses,
iff they can be adapted to inversion.

I'll note, the previous logic was actively bad,
it increased instruction count since it didn't actually ensure
that the inversions happened.

19 months ago[NFC][InstCombine] Add tests for sinking `not` into logical ops with hands with extra...
Roman Lebedev [Sun, 18 Dec 2022 23:28:30 +0000 (02:28 +0300)]
[NFC][InstCombine] Add tests for sinking `not` into logical ops with hands with extra (but invertible) uses

19 months ago[CodeGen] Include llvm/CodeGen/DFAPacketizer.h
Kazu Hirata [Sun, 18 Dec 2022 23:35:29 +0000 (15:35 -0800)]
[CodeGen] Include llvm/CodeGen/DFAPacketizer.h

This patch teaches MachinePipeliner.h to include
DFAPacketizer.h so that the header file is self contained.

Without this patch, a C++ source file that only includes
MachinePipeliner.h does not compile because the forward declaration of
DFAPacketizer is not enough for:

  llvm::SmallVector<std::unique_ptr<DFAPacketizer>> DFAResources;

19 months ago[CodeGen] Include MachineInstr.h
Kazu Hirata [Sun, 18 Dec 2022 23:12:30 +0000 (15:12 -0800)]
[CodeGen] Include MachineInstr.h

This patch teaches DbgEntityHistoryCalculator.h to include
MachineInstr.h so that the header file is self contained.

Without this patch, a C++ source file that only includes
DbgEntityHistoryCalculator.h does not compile because:

  PointerIntPair<const MachineInstr *, 1, EntryKind> Instr;

wants to know the alignment of llvm::MachineInstr:

  llvm/include/llvm/Support/PointerLikeTypeTraits.h:61:28: error:
  invalid application of 'alignof' to an incomplete type
  'llvm::MachineInstr'
          detail::ConstantLog2<alignof(T)>::value;
                               ^~~~~~~~~~

19 months ago[InstCombine] Try to sink `not` of one operand of logical operation into another...
Roman Lebedev [Sun, 18 Dec 2022 21:44:26 +0000 (00:44 +0300)]
[InstCombine] Try to sink `not` of one operand of logical operation into another hand

Matches what we do for binary operations, but a special care needs
is needed to preserve operand order, as the logical operations
are not strictly commutative!

19 months ago[NFC][InstCombine] Add tests with invertible hands of logical operators
Roman Lebedev [Sun, 18 Dec 2022 20:06:21 +0000 (23:06 +0300)]
[NFC][InstCombine] Add tests with invertible hands of logical operators

19 months agoRevert "[APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project...
Peter Rong [Sun, 18 Dec 2022 22:01:08 +0000 (14:01 -0800)]
Revert "[APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues/59515"

This reverts commit 7859d6e79ca90df2f3f206192a1dfa89e3cb10f1.

Signed-off-by: Peter Rong <PeterRong96@gmail.com>
19 months ago[gn] try porting 07af0e2d3e84 even more
Nico Weber [Sun, 18 Dec 2022 21:57:20 +0000 (16:57 -0500)]
[gn] try porting 07af0e2d3e84 even more

Possibly fixes tests on Linux. This corresponds to
`export_executable_symbols_for_plugins` calls in CMake.

19 months ago[APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues...
Peter Rong [Wed, 14 Dec 2022 22:42:38 +0000 (14:42 -0800)]
[APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues/59515

Also provide a `tryExtValue()` API like APInt did in D139683

Reviewed By: RKSimon

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

19 months ago[InstCombine] Try to fold `not` into `cmp` iff other users of `cmp` are freely invertible
Roman Lebedev [Sun, 18 Dec 2022 21:10:47 +0000 (00:10 +0300)]
[InstCombine] Try to fold `not` into `cmp` iff other users of `cmp` are freely invertible

There is still some such patterns that require collaboration
of folds to handle,that we don't currently do.

19 months ago[NFC][PatternMatching] Promote `m_LogicalOp` matchers into `PatternMatch.h`
Roman Lebedev [Sun, 18 Dec 2022 19:53:59 +0000 (22:53 +0300)]
[NFC][PatternMatching] Promote `m_LogicalOp` matchers into `PatternMatch.h`

19 months ago[MC] Use `MCRegister` instead of `unsigned` in `MCTargetAsmParser`
Sergei Barannikov [Sun, 18 Dec 2022 20:12:05 +0000 (12:12 -0800)]
[MC] Use `MCRegister` instead of `unsigned` in `MCTargetAsmParser`

Reviewed By: MaskRay

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

19 months ago[CMake] Fix LoongArchTests -DBUILD_SHARED_LIBS=on builds
Fangrui Song [Sun, 18 Dec 2022 20:07:43 +0000 (12:07 -0800)]
[CMake] Fix LoongArchTests -DBUILD_SHARED_LIBS=on builds

Similar to 1b9cd51d55b33cfaf68e21fa5396539ca54e5324

19 months agoRevert "[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional"
Krzysztof Parzyszek [Sun, 18 Dec 2022 19:19:40 +0000 (11:19 -0800)]
Revert "[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional"

This reverts commit 8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d.

The Optional*RefDegradesTo*EntryPtr types want to keep the same size as
the underlying type, which std::optional doesn't guarantee. For use with
llvm::Optional, they define their own storage class, and there is no way
to do that in std::optional.

On top of that, that commit broke builds with older GCCs, where
std::optional was not trivially copyable (static_assert in the clang
sources was failing).

19 months ago[libc++][CI] Fixes build failures.
Mark de Wever [Sun, 18 Dec 2022 17:58:28 +0000 (18:58 +0100)]
[libc++][CI] Fixes build failures.

Some clang diagnostics have changed causing build failures.

Reviewed By: #libc, Mordante

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

19 months ago[PoisonChecking] Add tests with selects.
Florian Hahn [Sun, 18 Dec 2022 18:51:15 +0000 (18:51 +0000)]
[PoisonChecking] Add tests with selects.

This adds test coverage for a suggestion in D111643.

19 months agoAMDGPU/GlobalISel: Use ptrtoint to legalize constant 32-bit addrspacecast
Matt Arsenault [Sun, 18 Dec 2022 18:00:24 +0000 (13:00 -0500)]
AMDGPU/GlobalISel: Use ptrtoint to legalize constant 32-bit addrspacecast

This was trying to merge 2 32-bit pointers into a 64-bit pointer. The
artifact combiner was assuming merges to pointers use scalar sources,
and ended up inserting invalid bitcast from a pointer to a scalar. It
should probably be a verifier error to have pointer merge sources with
a pointer result.

Fixes verifier errors with EXPENSIVE_CHECKS.

19 months agollvm-profgen: Fix use of stats to be under LLVM_ENABLE_STATS
David Blaikie [Sun, 18 Dec 2022 17:46:01 +0000 (17:46 +0000)]
llvm-profgen: Fix use of stats to be under LLVM_ENABLE_STATS

This caused a -Wunused-variable warning in a without-assert+with-stats
build (because the stats were included but their use was not).

Stat use is meant to be gated by LLVM_ENABLE_STATS which can be set
independently of assertions.

19 months ago[llvm-exegesis][X86] Explicitly not support `WRFSBASE` opcode.
Roman Lebedev [Sun, 18 Dec 2022 16:43:31 +0000 (19:43 +0300)]
[llvm-exegesis][X86] Explicitly not support `WRFSBASE` opcode.

We can't serialize if for latency measurements, and when measuring uops,
it crashes so hard even `CrashRecoveryContext` doesn't stop it.

Looks like *this* was the last crasher, now `--opcode-index=-1`
succeeds for all three benchmark modes here.
At least with Duplication repetitor.

19 months ago[NFC][llvm-exegesis] Improve `getOpcodesOrDie()`
Roman Lebedev [Sun, 18 Dec 2022 16:54:42 +0000 (19:54 +0300)]
[NFC][llvm-exegesis] Improve `getOpcodesOrDie()`

We already have opcode name -> opcode index map, use it.
Reserve memory where appropriate.