platform/upstream/llvm.git
12 months ago[BOLT] Fix jump table issue for split functions
Maksim Panchenko [Sat, 22 Jul 2023 02:14:26 +0000 (19:14 -0700)]
[BOLT] Fix jump table issue for split functions

A jump table in a split function may contain an entry matching a start
address of another fragment of the function. While converting addresses
to labels, we used to ignore such entries resulting in underpopulated
jump table. Change that, so we always create one label per address.

Reviewed By: Amir

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

12 months ago[LSR] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sun, 23 Jul 2023 14:57:21 +0000 (15:57 +0100)]
[LSR] Use poison instead of undef as placeholder [NFC]
This value is patcher afterwards, and only used temporarily during dbg info construction

12 months ago[X86] getIntImmCostInst - avoid repeating getNumOperands() in for-loop (style). NFC.
Simon Pilgrim [Sun, 23 Jul 2023 14:49:22 +0000 (15:49 +0100)]
[X86] getIntImmCostInst - avoid repeating getNumOperands() in for-loop (style). NFC.

12 months ago[X86] getIntImmCostInst - silence static analyzer overflow warning. NFCI.
Simon Pilgrim [Sun, 23 Jul 2023 14:45:10 +0000 (15:45 +0100)]
[X86] getIntImmCostInst - silence static analyzer overflow warning. NFCI.

Use the divideCeil uint64_t return type directly

12 months ago[Scalarizer] Fold -1 mask in shufflevector to poison instead of undef
Nuno Lopes [Sun, 23 Jul 2023 14:02:23 +0000 (15:02 +0100)]
[Scalarizer] Fold -1 mask in shufflevector to poison instead of undef
Per latest LangRef

12 months ago[clang-tidy][clang-tidy-diff.py] Change shebang from python to python3
Shivam Gupta [Sun, 23 Jul 2023 13:53:32 +0000 (19:23 +0530)]
[clang-tidy][clang-tidy-diff.py] Change shebang from python to python3

12 months ago[X86][FP16] Split v32f16 shuffle when feature BWI is off
Phoebe Wang [Sun, 23 Jul 2023 12:29:54 +0000 (20:29 +0800)]
[X86][FP16] Split v32f16 shuffle when feature BWI is off

Found this problem when investigating #63017

Reviewed By: RKSimon

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

12 months ago[clang-tidy][NFC] Fix links to fuchsia codding standard
Piotr Zegar [Sun, 23 Jul 2023 12:29:18 +0000 (12:29 +0000)]
[clang-tidy][NFC] Fix links to fuchsia codding standard

Correct links to fuchsia codding standard in
documentation for fuchsia-* checks.

Partially fixes: #62334

12 months ago[X86] lowerRegToMasks - rename masklen -> MaskLenVT. NFC.
Simon Pilgrim [Sun, 23 Jul 2023 11:21:39 +0000 (12:21 +0100)]
[X86] lowerRegToMasks - rename masklen -> MaskLenVT. NFC.

Fixes style warning

12 months ago[InstCombine] Regenerate test checks (NFC)
Antonio Frighetto [Sun, 23 Jul 2023 11:25:14 +0000 (11:25 +0000)]
[InstCombine] Regenerate test checks (NFC)

12 months ago[InstCombine] Do not assume scalar types in `select`/`zext`
Antonio Frighetto [Sun, 23 Jul 2023 10:52:47 +0000 (10:52 +0000)]
[InstCombine] Do not assume scalar types in `select`/`zext`

Do not assume scalar types when folding binops of `select`
operations and `zext`/`sext` of their condition.

Reported-by: Benjins, dyung
Proofs: https://alive2.llvm.org/ce/z/GmDLns

12 months ago[X86] X86ISelLowering.cpp - fix some mixed case SDLoc variable names. NFC.
Simon Pilgrim [Sun, 23 Jul 2023 10:53:35 +0000 (11:53 +0100)]
[X86] X86ISelLowering.cpp - fix some mixed case SDLoc variable names. NFC.

Consistently use SDLoc DL

12 months agoAdd missing 'namespace X86' closing comment to appease static analyser. NFC.
Simon Pilgrim [Sun, 23 Jul 2023 10:11:57 +0000 (11:11 +0100)]
Add missing 'namespace X86' closing comment to appease static analyser. NFC.

12 months ago[X86] LowerFunnelShift - manually expand funnel shifts by splat constant patterns.
Simon Pilgrim [Sat, 22 Jul 2023 21:12:49 +0000 (22:12 +0100)]
[X86] LowerFunnelShift - manually expand funnel shifts by splat constant patterns.

Followup to af32e51a43fb4343f - where the undef funnel shift amounts (during widening from v2i32 -> v4i32) were being constant folded to 0 when the shift amounts are created during expansion, losing the splat'd shift amounts.

12 months ago[X86] Add basic test coverage for funnels shifts of sub-128-bit vector types
Simon Pilgrim [Sat, 22 Jul 2023 17:47:11 +0000 (18:47 +0100)]
[X86] Add basic test coverage for funnels shifts of sub-128-bit vector types

12 months ago[Clang][NFC] Restore changelog entry incorrectly removed by 02bb2beeef
Corentin Jabot [Sun, 23 Jul 2023 09:09:43 +0000 (11:09 +0200)]
[Clang][NFC] Restore changelog entry incorrectly removed by 02bb2beeef

12 months ago[clang] Fix diagnostics for defaulted, implicitly deleted 'operator=='.
Amirreza Ashouri [Sun, 23 Jul 2023 08:40:48 +0000 (10:40 +0200)]
[clang] Fix diagnostics for defaulted, implicitly deleted 'operator=='.

https://godbolt.org/z/cMKE3o1aG

According to the issue https://github.com/llvm/llvm-project/issues/63960 , compiler falsely complains that no viable `operator<=>` was found while we are actually looking for a `operator==`.
This bug has been fixed through adding a check of the `OverloadedOperatorKind` type's object, `OO`, to see if it is `OO_EqualEqual` in addition to `OO_ExclaimEqual`.

Reviewed By: #clang-language-wg, cor3ntin

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

12 months ago[clang][Interp][NFC] Fix two small code style problems
Timm Bäder [Sat, 22 Jul 2023 11:29:54 +0000 (13:29 +0200)]
[clang][Interp][NFC] Fix two small code style problems

12 months ago[clang][Interp][NFC] Fix InterpStack::dump() for empty stacks
Timm Bäder [Sat, 22 Jul 2023 11:08:55 +0000 (13:08 +0200)]
[clang][Interp][NFC] Fix InterpStack::dump() for empty stacks

12 months ago[clang][Interp][NFC] Clean up getOrCreateDummy()
Timm Bäder [Sun, 23 Jul 2023 05:21:37 +0000 (07:21 +0200)]
[clang][Interp][NFC] Clean up getOrCreateDummy()

12 months ago[clang][Interp][NFC] Use existing local variable
Timm Bäder [Sun, 23 Jul 2023 05:20:19 +0000 (07:20 +0200)]
[clang][Interp][NFC] Use existing local variable

Instead of calling getSubExpr() again.

12 months ago[PowerPC/SPE] powerpcspe load and store instruction has
Kishan Parmar [Sun, 23 Jul 2023 07:54:35 +0000 (13:24 +0530)]
[PowerPC/SPE] powerpcspe load and store instruction has
8-bit offset instead of 16-bit unlike other load/store instructions.
so if stack grows any further than 8-bit, create one emergency slot
for spilling.

12 months ago[unittest] Fix HighlighterTest.cpp after D151683
Fangrui Song [Sun, 23 Jul 2023 01:30:02 +0000 (18:30 -0700)]
[unittest] Fix HighlighterTest.cpp after D151683

:: is now parsed as tok::coloncolon even in C mode.

12 months ago[PowerPC] Reorder setMaxAtomicSizeInBitsSupported(). NFC
Brad Smith [Sun, 23 Jul 2023 00:01:27 +0000 (20:01 -0400)]
[PowerPC] Reorder setMaxAtomicSizeInBitsSupported(). NFC

Reorder setMaxAtomicSizeInBitsSupported() in numerical and more logical order.

Reviewed By: MaskRay

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

12 months ago[Support] Change StringMap hash function from xxHash64 to xxh3_64bits
Fangrui Song [Sat, 22 Jul 2023 23:50:47 +0000 (16:50 -0700)]
[Support] Change StringMap hash function from xxHash64 to xxh3_64bits

Similar to D142862.

xxh3 is significantly faster than xxh64. Switch to xxh3, as we did for
for lld and llvm-dwarfutil to increase performance (D154813 D155675).
While I think StringMap is not a bottleneck for most applications, it
seems good to eliminate the slower xxh64.
In addition, according to Erik Desjardins, an artificial benchmark of
Rust with very large constant strings improves by ~3% locally.

I have fixed all found issues (~20) separately, but one is remaining:

* ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s has a
  failure due to StringMap iteration order. It now passes
  with LLVM_ENABLE_REVERSE_ITERATION=on while failing with
  LLVM_ENABLE_REVERSE_ITERATION=off.

Reviewed By: erikdesjardins

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

12 months ago[gdb-remote] Sort entries in QEnvironment*
Fangrui Song [Sat, 22 Jul 2023 23:45:32 +0000 (16:45 -0700)]
[gdb-remote] Sort entries in QEnvironment*

Similar to ae316ac66ffff430997e342772fc4629c1acece0 for
QEMU_(UN)SET_ENV.
The iteration order of StringMap is not guaranteed to be deterministic.
Sort the entries to give deterministic packets for the tests added by
D108018.

12 months ago[test] Fix compiler_version.f90 for -DLLVM_APPEND_VC_REV=OFF builds after D152572
Fangrui Song [Sat, 22 Jul 2023 23:06:29 +0000 (16:06 -0700)]
[test] Fix compiler_version.f90 for -DLLVM_APPEND_VC_REV=OFF builds after D152572

Checking the patch version is too strict. Just check major and minor
versions as in clang/test/Driver/immediate-options.c.

12 months ago[Frontend] Sort featuresVec for AMDGPU target features
Fangrui Song [Sat, 22 Jul 2023 22:57:41 +0000 (15:57 -0700)]
[Frontend] Sort featuresVec for AMDGPU target features

D145579 leverages the iteration order of StringSet, which is not
guaranteed to be deterministic.

12 months ago[DAG] Improve carry reconstruction in combineCarryDiamond.
Amaury Séchet [Wed, 5 Jul 2023 17:45:01 +0000 (17:45 +0000)]
[DAG] Improve carry reconstruction in combineCarryDiamond.

The gain is usually suffiscient to go the extra mile and reconstruct a carry in some cases.

Reviewed By: RKSimon

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

12 months ago[InstrProf] Stabilize --show-prof-sym-list dump order
Fangrui Song [Sat, 22 Jul 2023 22:47:44 +0000 (15:47 -0700)]
[InstrProf] Stabilize --show-prof-sym-list dump order

D118181 leverages the iteration order of StringSet, which is not
guaranteed to be deterministic.

12 months ago[CodeGen] Stabilize C2/D2 to C1/D1 replacement order
Fangrui Song [Sat, 22 Jul 2023 22:29:37 +0000 (15:29 -0700)]
[CodeGen] Stabilize C2/D2 to C1/D1 replacement order

The conversion iterates over CodeGenModule::Replacements (a StringMap)
and replaces C2/D2 and moves C1/D1 (
commit 0196a1d98f8a206259a4b5ce93c21807243af92f in 2013, to make the
output look nicer). The iteration order is not guaranteed to be
deterministic, and may cause destructors.cpp to exhibit different
function orders. Use a MapVector instead.

While here, fix an IWYU issue by adding an explicit include, though
MapVector is already used in CodeGenModule.h.

12 months ago[builtins][Mips] Un-break FreeBSD build of __clear_cache
Jessica Clarke [Sat, 22 Jul 2023 22:01:21 +0000 (23:01 +0100)]
[builtins][Mips] Un-break FreeBSD build of __clear_cache

Commit 674a17e9bbe8 ("MIPS/compiler_rt: use synci to flush icache on
r6") completely removed the OS-specific guards under the guise of "For
pre-r6, we can use cacheflush libc function, which is same on Linux and
FreeBSD." However, the code in question had guards for Linux and
OpenBSD, not Linux and FreeBSD, and FreeBSD does not have a cacheflush
libc function as claimed, so this was neither the statement they
intended to make nor was it sufficient justification for making the code
completely unconditional. Whilst the upcoming FreeBSD 14 release has
dropped support for MIPS, FreeBSD 13 has support for it.

Fix this by only calling cacheflush on the OSes where it was previously
called, and not on other OSes where it either definitely isn't available
(FreeBSD) or is unknown (any other OS than the three mentioned in this
commit).

12 months ago[ObjCARC] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 21:41:24 +0000 (22:41 +0100)]
[ObjCARC] Use poison instead of undef as placeholder [NFC]
It's used to specify UB (as ptr argument to store) and to RAUW values when UB occurs.

12 months ago[UnifyLoopExits] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 21:38:10 +0000 (22:38 +0100)]
[UnifyLoopExits] Use poison instead of undef as placeholder [NFC]
This pass creates phi nodes where only one of the incoming values is used.
The remaining ones can be poison.

12 months ago[RewriteStatepointsForGC] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 21:25:41 +0000 (22:25 +0100)]
[RewriteStatepointsForGC] Use poison instead of undef as placeholder [NFC]
This is used in shufflevectors where the placeholder arg is unused.
It's also used when deleting invariant_start

12 months ago[clang-tidy] Support concepts in `bugprone-forwarding-reference-overload`
Evgeny Shulgin [Sat, 22 Jul 2023 19:46:31 +0000 (19:46 +0000)]
[clang-tidy] Support concepts in `bugprone-forwarding-reference-overload`

Ignore constrained perfect forwarding constructors.

Fixes: #58230

Reviewed By: PiotrZSL

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

12 months ago[clang-tidy] Fix checks filter with warnings-as-errors
Piotr Zegar [Sat, 22 Jul 2023 19:28:25 +0000 (19:28 +0000)]
[clang-tidy] Fix checks filter with warnings-as-errors

Since commit 5d12b13b0b26bc58b02ee23c369da8b83240cceb, warnings are
internally classified as errors which skip the check filters.

One use-case is particularly affected: you cannot selectively disable
clang-analyzer-core checks, they are force-enabled because required by others.
So enabling warning as errors will show new (and unwanted) errors !

Co-authored-by: kiwixz <kiwixz@outlook.com>
Fixes: #61969

Reviewed By: carlosgalvezp

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

12 months ago[clang-tidy] Ignore implcit casts in cppcoreguidelines-owning-memory
Piotr Zegar [Sat, 22 Jul 2023 19:24:53 +0000 (19:24 +0000)]
[clang-tidy] Ignore implcit casts in cppcoreguidelines-owning-memory

Add getCheckTraversalKind to the check in order
to ignore some implicit casts when matching
expresions.

Fixes: #63994

Reviewed By: carlosgalvezp

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

12 months ago[clang-tidy][NFC] Fix links in cppcoreguidelines module
Piotr Zegar [Sat, 22 Jul 2023 19:22:21 +0000 (19:22 +0000)]
[clang-tidy][NFC] Fix links in cppcoreguidelines module

Change links in cppcoreguidelines module from github
repository to isocpp.github.io. Unify format.

12 months ago[RISCV] Simplify setOperationAction for f64 ceil/floor/round/trunc/etc. NFC
Craig Topper [Sat, 22 Jul 2023 19:11:13 +0000 (12:11 -0700)]
[RISCV] Simplify setOperationAction for f64 ceil/floor/round/trunc/etc. NFC

We were setting the operations as Legal for Zfa in two places. Use
an else to avoid this.

12 months agoFix test failure on linaro-clang-armv8-quick with
Shubham Sandeep Rastogi [Sat, 22 Jul 2023 18:20:29 +0000 (11:20 -0700)]
Fix test failure on linaro-clang-armv8-quick with
c5a45b2515e6d2c3d29e86ad41c9be5a88f172d4

12 months ago[X86] Fix typo in comment. NFC
Craig Topper [Sat, 22 Jul 2023 18:12:02 +0000 (11:12 -0700)]
[X86] Fix typo in comment. NFC

12 months ago[LegalizeTypes] Use report_fatal_error instead of llvm_unreachable in the default...
Craig Topper [Sat, 22 Jul 2023 18:04:25 +0000 (11:04 -0700)]
[LegalizeTypes] Use report_fatal_error instead of llvm_unreachable in the default case of some type legalization handlers.

These can be triggered by in various ways when intrinsics are used wrong or a target doesn't correctly
not support something. Using a fatal error prevents strange behavior
like infinite loops.

We already do this for some of the vector type legalization handles.

12 months ago[RISCV] Remove unnecessary opcode argument to FPUnaryOp_imm template. NFC
Craig Topper [Sat, 22 Jul 2023 17:46:23 +0000 (10:46 -0700)]
[RISCV] Remove unnecessary opcode argument to FPUnaryOp_imm template. NFC

Instead of always passing OPC_OP_FP just hardcode it inside.

12 months agoChange DW_LLE_baseaddr to DW_LLE_baseaddrx in .debug_loclist section
Shubham Sandeep Rastogi [Thu, 20 Jul 2023 18:27:16 +0000 (11:27 -0700)]
Change DW_LLE_baseaddr to DW_LLE_baseaddrx in .debug_loclist section

With https://reviews.llvm.org/D154638, the ability to emit a .debug_addr
section has been added to dsymutil. With this, instead of emitting a
DW_LLE_baseaddr in the .debug_loclist section, a DW_LLE_baseaddrx can be
emitted instead, which will allow for more indirection.

Differetial Revision: https://reviews.llvm.org/D155724

12 months agoDo not emit a .debug_addr section if the DW_AT_addr_base is not set.
Shubham Sandeep Rastogi [Wed, 19 Jul 2023 01:36:30 +0000 (18:36 -0700)]
Do not emit a .debug_addr section if the DW_AT_addr_base is not set.

If the DW_AT_addr_base is not set, dsymutil should not copy any addrx
attributes into the cloned DIE, which will result in no .debug_addr
section being emitted.

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

12 months agoEmit a .debug_addr section with dsymutil
Shubham Sandeep Rastogi [Wed, 28 Jun 2023 22:19:35 +0000 (15:19 -0700)]
Emit a .debug_addr section with dsymutil

DWARF5 has support for DW_FORM_addrx, which can be useful for space
savings, but it needs a .debug_addr section to be used. dsymutil does
not have the ability to emit a debug_addr section currently. This patch
adds support for that.

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

12 months ago[X86] LowerRotate - manually expand rotate by splat constant patterns.
Simon Pilgrim [Sat, 22 Jul 2023 16:54:48 +0000 (17:54 +0100)]
[X86] LowerRotate - manually expand rotate by splat constant patterns.

Fixes issue identified on #63980 where the undef rotate amounts (during widening from v2i32 -> v4i32) were being constant folded to 0 when the shift amounts are created during expansion, losing the splat'd shift amounts.

12 months ago[ORC] Stabilize output stream order
Fangrui Song [Sat, 22 Jul 2023 16:52:14 +0000 (09:52 -0700)]
[ORC] Stabilize output stream order

It currently depends on the StringMap iteration order, which is not
guaranteed to be deterministic. Use MapVector to stabilize the order.

12 months ago[WebAssembly] Stabilize custom section order
Fangrui Song [Sat, 22 Jul 2023 16:37:22 +0000 (09:37 -0700)]
[WebAssembly] Stabilize custom section order

It currently depends on the StringMap iteration order, which is not
guaranteed to be deterministic. Use MapVector to stabilize the order.

12 months ago[clang] Enable C++11-style attributes in all language modes
Nikolas Klauser [Sat, 22 Jul 2023 16:33:55 +0000 (09:33 -0700)]
[clang] Enable C++11-style attributes in all language modes

This also ignores and deprecates the `-fdouble-square-bracket-attributes` command line flag, which seems to not be used anywhere. At least a code search exclusively found mentions of it in documentation: https://sourcegraph.com/search?q=context:global+-fdouble-square-bracket-attributes+-file:clang/*+-file:test/Sema/*+-file:test/Parser/*+-file:test/AST/*+-file:test/Preprocessor/*+-file:test/Misc/*+archived:yes&patternType=standard&sm=0&groupBy=repo

RFC: https://discourse.llvm.org/t/rfc-enable-c-11-c2x-attributes-in-all-standard-modes-as-an-extension-and-remove-fdouble-square-bracket-attributes

This enables `[[]]` attributes in all C and C++ language modes without warning by default. `-Wc++-extensions` does warn. GCC has enabled this extension in all C modes since GCC 10.

Reviewed By: aaron.ballman, MaskRay

Spies: #clang-vendors, beanz, JDevlieghere, Michael137, MaskRay, sstefan1, jplehr, cfe-commits, lldb-commits, dmgreen, jdoerfert, wenlei, wlei

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

12 months ago[clang-tidy][NFC] Fix list.rst generation when adding check
Piotr Zegar [Sat, 22 Jul 2023 15:48:18 +0000 (15:48 +0000)]
[clang-tidy][NFC] Fix list.rst generation when adding check

add_new_check.py does not work properly for checks that
generate fixes in base class. Adding some comments to those
checks in order to fix list.rst generation.

12 months ago[MemCpyOpt] add noalias metadata on lifetime intrinsic test case for stack-move optim...
khei4 [Sat, 22 Jul 2023 14:54:33 +0000 (23:54 +0900)]
[MemCpyOpt] add noalias metadata on lifetime intrinsic test case for stack-move optimization(NFC)

12 months ago[X86] Enable ISD::TRUNCATE support from v2i64 and v4i64 nodes
Simon Pilgrim [Sat, 22 Jul 2023 15:03:50 +0000 (16:03 +0100)]
[X86] Enable ISD::TRUNCATE support from v2i64 and v4i64 nodes

Addresses the last comment from D154592 - ensure we only truncate with PACKSS/PACKUS when it can be cheaply done (and use shuffles otherwise).

12 months ago[NFC][clang] Fixes whitespace.
Mark de Wever [Sat, 22 Jul 2023 14:50:58 +0000 (16:50 +0200)]
[NFC][clang] Fixes whitespace.

These changes cause the Buildkite CI to fail.

12 months ago[libc++][doc] Uses the proper paper number.
Mark de Wever [Sat, 22 Jul 2023 14:44:59 +0000 (16:44 +0200)]
[libc++][doc] Uses the proper paper number.

This was brought to my attention in
https://github.com/llvm/llvm-project/commit/88622aabf10764cc32d546f448076d25b13e94cd#r122279717

12 months ago[gn build] Port 57bd882343f8
LLVM GN Syncbot [Sat, 22 Jul 2023 14:23:37 +0000 (14:23 +0000)]
[gn build] Port 57bd882343f8

12 months ago[gn] port 822c31a0fe827a6 (HAVE_BUILTIN_THREAD_POINTER)
Nico Weber [Sat, 22 Jul 2023 14:22:32 +0000 (10:22 -0400)]
[gn] port 822c31a0fe827a6 (HAVE_BUILTIN_THREAD_POINTER)

Should maybe be 1 on linux, at least if is_clang. But just disabling
it everywhere is good enough for now.

12 months ago[gn] port b0bb68fd3cb7bfba (LLVM_ENABLE_REVERSE_ITERATION in clang/test)
Nico Weber [Sat, 22 Jul 2023 14:14:09 +0000 (10:14 -0400)]
[gn] port b0bb68fd3cb7bfba (LLVM_ENABLE_REVERSE_ITERATION in clang/test)

12 months ago[gn] port 9996e71f2d (LLVM_ENABLE_REVERSE_ITERATION in llvm/test)
Nico Weber [Sat, 22 Jul 2023 14:12:01 +0000 (10:12 -0400)]
[gn] port 9996e71f2d (LLVM_ENABLE_REVERSE_ITERATION in llvm/test)

12 months ago[mlir][LLVM] Introduce reduction intrinsics for minimum/maximum
Daniil Dudkin [Sat, 22 Jul 2023 13:25:26 +0000 (16:25 +0300)]
[mlir][LLVM] Introduce reduction intrinsics for minimum/maximum

This patch adds supports for the reduction intrinsic
for floating point minimum and maximum that have
been added to LLVM by https://reviews.llvm.org/D152370.

Related to: #63969

Reviewed By: dcaballe

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

12 months ago[Inline] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 12:23:32 +0000 (13:23 +0100)]
[Inline] Use poison instead of undef as placeholder [NFC]

12 months ago[StructurizeCFG] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 12:19:42 +0000 (13:19 +0100)]
[StructurizeCFG] Use poison instead of undef as placeholder [NFC]
These are used to create branch instructions. The condition is patched later

12 months ago[X86][BF16] Customize INSERT_VECTOR_ELT for bf16 when feature BF16 is on
Phoebe Wang [Sat, 22 Jul 2023 12:25:44 +0000 (20:25 +0800)]
[X86][BF16] Customize INSERT_VECTOR_ELT for bf16 when feature BF16 is on

Fixes root cause of #63017.
The reason is similar to BUILD_VECTOR. We have legal vector type but
still soft promote for scalar type. So we need to customize these scalar
to vector nodes.

Reviewed By: RKSimon

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

12 months agoPartially revert "clang/HIP: Remove __llvm_amdgcn_* wrapper hacks"
Matt Arsenault [Fri, 21 Jul 2023 16:33:35 +0000 (12:33 -0400)]
Partially revert "clang/HIP: Remove __llvm_amdgcn_* wrapper hacks"

Revert part of f407a7399575a6821940973c54754d42e72dd9ce.

Some of the HIP headers were using the f16 rcp inline, such that it
breaks compiling code against non-top-of-tree headers. Need to wait
for a few HIP releases to expire to fully remove these.

Fixes #63981

12 months agoAMDGPU: Silence a gcc warning
Matt Arsenault [Sat, 22 Jul 2023 11:45:18 +0000 (07:45 -0400)]
AMDGPU: Silence a gcc warning

12 months agoConstantFolding: Fix canonicalize folding for dynamic mode denormal inputs
Matt Arsenault [Sat, 22 Jul 2023 11:35:04 +0000 (07:35 -0400)]
ConstantFolding: Fix canonicalize folding for dynamic mode denormal inputs

We have to assume the input could be positive-zero. Makes alive2
happy.

12 months ago[CoroSplit] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 11:56:03 +0000 (12:56 +0100)]
[CoroSplit] Use poison instead of undef as placeholder [NFC]
Used to construct full structs/vectors
also, covert freeze undef -> freeze poison (same semantics)

12 months ago[SimplifyCFG] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 11:44:03 +0000 (12:44 +0100)]
[SimplifyCFG] Use poison instead of undef as placeholder [NFC]
This is used in a phi node that is created for which only 1 value is accessed (the non-poison)

12 months ago[mlir][rocdl] Change the translation of `GridDim*Op` to `__ockl_get_num_groups`
Fabian Mora [Sat, 22 Jul 2023 11:32:42 +0000 (11:32 +0000)]
[mlir][rocdl] Change the translation of `GridDim*Op` to `__ockl_get_num_groups`

Currently, `ROCDL::GridDim*Op` is being translated to `__ockl_get_global_size`, however
to match the meaning of `gpu.grid_dim` it should instead be translated to
`__ockl_get_num_groups`. This change would also make it agree with the meaning
of `gridDimx.*` in HIP, see:
https://github.com/ROCm-Developer-Tools/hipamd/blob/develop/include/hip/amd_detail/amd_hip_runtime.h#L257

Difference between the functions:
```
__ockl_get_global_size =  blockDim * numBlocks
__ockl_get_num_groups = numBlocks
```

Reviewed By: krzysz00

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

12 months ago[bazel] Add missing dependency for b2d76a063dd7fb681c98a10d8e7f54fd6d25dd27
Benjamin Kramer [Sat, 22 Jul 2023 11:21:51 +0000 (13:21 +0200)]
[bazel] Add missing dependency for b2d76a063dd7fb681c98a10d8e7f54fd6d25dd27

12 months ago[X86][BF16] Do not scalarize masked load for BF16 when we have AVX512BF16
Phoebe Wang [Sat, 22 Jul 2023 10:13:58 +0000 (18:13 +0800)]
[X86][BF16] Do not scalarize masked load for BF16 when we have AVX512BF16

Fixes #63017

Reviewed By: RKSimon

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

12 months ago[libc++][print] Adds stdout functions.
Mark de Wever [Wed, 12 Jul 2023 06:20:26 +0000 (08:20 +0200)]
[libc++][print] Adds stdout functions.

Implements parts of
- P2093R14 Formatted output
- P2539R4  Should the output of std::print to a terminal be
           synchronized with the underlying stream?

Depends on D150044

Reviewed By: #libc, ldionne

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

12 months ago[VirtualFileSystem] Use std::map::emplace
Fangrui Song [Sat, 22 Jul 2023 07:00:57 +0000 (00:00 -0700)]
[VirtualFileSystem] Use std::map::emplace

12 months ago[mlir][Transforms] GreedyPatternRewriteDriver: Fix `changed` parameter
Matthias Springer [Sat, 22 Jul 2023 06:30:40 +0000 (08:30 +0200)]
[mlir][Transforms] GreedyPatternRewriteDriver: Fix `changed` parameter

`changed` was not updated correctly when it was already set to "true" before calling `applyPatternsAndFoldGreedily`.

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

12 months ago[mlir][transform] Add `transform.apply_dce` op
Matthias Springer [Sat, 22 Jul 2023 06:23:48 +0000 (08:23 +0200)]
[mlir][transform] Add `transform.apply_dce` op

Add a transform that eliminates dead operations. This is useful after certain transforms (such as fusion) that create/clone new IR but leave the original IR in place.

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

12 months ago[VirtualFileSystem] Make gcc<7.5 happy after 75d71800aa384ee58663d892c325572f5588df2a
Fangrui Song [Sat, 22 Jul 2023 06:23:32 +0000 (23:23 -0700)]
[VirtualFileSystem] Make gcc<7.5 happy after 75d71800aa384ee58663d892c325572f5588df2a

There is a libstdc++ stl_map.h bug that is only back ported to 7.5.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78595#c13

```
/tmp/opt/gcc-7.3.0/include/c++/7.3.0/bits/stl_tree.h:2091:28: error: no matching function for call to ‘std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::unique_ptr<llvm::vfs::detail::InMemoryNode> >, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::unique_ptr<llvm::vfs::detail::InMemoryNode> > >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::unique_ptr<llvm::vfs::detail::InMemoryNode> > > >::_M_get_insert_unique_pos(std::pair<llvm::StringRef, std::unique_ptr<llvm::vfs::detail::InMemoryNode> >::first_type&)’
  = _M_get_insert_unique_pos(_KeyOfValue()(__v));
    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
```

Just construct a std::string from StringRef to work around it.

12 months agoFix crash in ODS backend for Type/Attr when an incorrect construct is used for Type...
Mehdi Amini [Sat, 22 Jul 2023 04:47:33 +0000 (21:47 -0700)]
Fix crash in ODS backend for Type/Attr when an incorrect construct is used for Type/Attr

Instead of crashing, try to print a useful error message.

12 months ago[flang][openacc] Fix hasDynamicShape logic
Valentin Clement [Sat, 22 Jul 2023 04:46:20 +0000 (21:46 -0700)]
[flang][openacc] Fix hasDynamicShape logic

Reviewed By: razvanlupusoru

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

12 months agoRevert "Reapply: [MemCpyOpt] implement single BB stack-move optimization which unify...
khei4 [Sat, 22 Jul 2023 04:08:12 +0000 (13:08 +0900)]
Revert "Reapply: [MemCpyOpt] implement single BB stack-move optimization which unify the static unescaped allocas"
revert because crash on chrome windows https://reviews.llvm.org/D153453#4524256

This reverts commit 569769b64858fd38f41267db41b461d3163aa754.

12 months ago[clang] Add serialization support for the DynamicAllocLValue variant of APValue:...
Nathan Ridge [Fri, 21 Jul 2023 08:05:14 +0000 (04:05 -0400)]
[clang] Add serialization support for the DynamicAllocLValue variant of APValue::LValueBase::Ptr

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

12 months ago[CodeGen] Support bitcode input containing multiple modules
Fangrui Song [Sat, 22 Jul 2023 03:05:35 +0000 (20:05 -0700)]
[CodeGen] Support bitcode input containing multiple modules

When using -fsplit-lto-unit (explicitly specified or due to using
-fsanitize=cfi/-fwhole-program-vtables), the emitted LLVM IR contains a module
flag metadata `"EnableSplitLTOUnit"`. If a module contains both type metadata
and `"EnableSplitLTOUnit"`, `ThinLTOBitcodeWriter.cpp` will write two modules
into the bitcode file. Compiling the bitcode (not ThinLTO backend compilation)
will lead to an error due to `parseIR` requiring a single module.

```
% clang -flto=thin a.cc -c -o a.bc
% clang -c a.bc
% clang -fsplit-lto-unit -flto=thin a.cc -c -o a.bc
% clang -c a.bc
error: Expected a single module
1 error generated.
```

There are multiple ways to have just one module in a bitcode file
output: `-Xclang -fno-lto-unit`, not using features like `-fsanitize=cfi`,
using `-fsanitize=cfi` with `-fno-split-lto-unit`. I think whether a
bitcode input file contains 2 modules (internal implementation strategy)
should not be a criterion to require an additional driver option when
the user seek for a non-LTO compile action.

Let's place the extra module (if present) into CodeGenOptions::LinkBitcodeFiles
(originally for -cc1 -mlink-bitcode-file). Linker::linkModules will link the two
modules together. This patch makes the following commands work:

```
clang -S -emit-llvm a.bc
clang -S a.bc
clang -c a.bc
```

Reviewed By: ormris

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

12 months agoOptimize emission of `dynamic_cast` to final classes.
Richard Smith [Sat, 22 Jul 2023 00:37:55 +0000 (17:37 -0700)]
Optimize emission of `dynamic_cast` to final classes.

- When the destination is a final class type that does not derive from
  the source type, the cast always fails and is now emitted as a null
  pointer or call to __cxa_bad_cast.

- When the destination is a final class type that does derive from the
  source type, emit a direct comparison against the corresponding base
  class vptr value(s). There may be more than one such value in the case
  of multiple inheritance; check them all.

For now, this is supported only for the Itanium ABI. I expect the same thing is
possible for the MS ABI too, but I don't know what guarantees are made about
vfptr uniqueness.

Reviewed By: rjmccall

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

12 months ago[lldb] Convert script native types to StructuredData counterpart
Med Ismail Bennani [Fri, 21 Jul 2023 23:43:24 +0000 (16:43 -0700)]
[lldb] Convert script native types to StructuredData counterpart

This patch adds the ability to pass native types from the script
interpreter to methods that use a {SB,}StructuredData argument.

To do so, this patch changes the `ScriptedObject` struture that holds
the pointer to the script object as well as the originating script
interpreter language. It also exposes that to the SB API via a new class
called `SBScriptObject`.

This structure allows the debugger to parse the script object and
convert it to a StructuredData object. If the type is not compatible
with the StructuredData types, we will store its pointer in a
`StructuredData::Generic` object.

This patch also adds some SWIG typemaps that checks the input argument to
ensure it's either an SBStructuredData object, in which case it just
passes it throught, or a python object that is NOT another SB type, to
provide some guardrails for the user.

rdar://111467140

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
12 months agoSet default C++ level for PlayStation(r) to C++17.
Sunil Srivastava [Sat, 22 Jul 2023 01:18:21 +0000 (18:18 -0700)]
Set default C++ level for PlayStation(r) to C++17.

12 months ago[include-cleaner] allow spelling strategies to customize verbatim/system headers
Sam McCall [Wed, 19 Jul 2023 02:49:54 +0000 (04:49 +0200)]
[include-cleaner] allow spelling strategies to customize verbatim/system headers

Our use case is wanting to apply a spelling strategy to rewrite the spellings
written in IWYU pragma private directives.

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

12 months ago[lldb] Consider OP_addrx in DWARFExpression::Update_DW_OP_addr
Felipe de Azevedo Piovezan [Fri, 21 Jul 2023 23:39:31 +0000 (16:39 -0700)]
[lldb] Consider OP_addrx in DWARFExpression::Update_DW_OP_addr

This rewrites DW_OP_addrx inside DWARFExpression as an DW_OP_addr so
that we can update addresses that are originally located in the
debug_addr section.

The full discussion behind this can be found in
https://discourse.llvm.org/t/dwarfexpression-and-dw-op-addrx/71627/12, but a
summary follows.

When SymbolFileDWARF::ParseVariableDIE creates DWARFExpressions for
variables whose location is an OP_addr, it knows how to remap
addresses appropriately in the DebugMap case. It then calls
DWARFExpression::Update_DW_OP_addr, which updates the value associated
with OP_addr.

However, when we have an OP_addrx, the update function does
nothing. This makes sense, as the DWARFExpression does not have a
mutable view of the debug_addr section. In non-DebugMap flows this is
not an issue, as the debug_addr contains the correct addresses of
variables. In DebugMap flows, this is problematic because the work
done by RelinkOSOAddress is lost. By updating the OP to OP_addr, we
can also update the address as required,

We also explored the alternative of relinking the debug_addr section
when we are initializing OSOs (InitOSO). However, this creates an
inconsistent story for users of
DWARFExpression::GetLocation_DW_OP_addr. This function returns an
address without telling callers whether that address came from an
OP_addr or an OP_addrx. If we preemptively relink OP_addrx results
without doing the same for OP_addr results, then callers can’t know
whether the address they got was an executable address or an object
file address. In other words, they can’t know whether they need to
call LinkOSOFileAddress on those results or not.

This patch addresses the majority of test failures when enabling DWARF
5 for MachO (over 200 test failures).

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

12 months ago[mlir][tosa][fix] Add proper type checking trait for tosa mul
TatWai Chong [Fri, 21 Jul 2023 23:28:45 +0000 (16:28 -0700)]
[mlir][tosa][fix] Add proper type checking trait for tosa mul

when operating integer type tensors, tosa elementwise multiplication
requires the element type of result to be a 32-bit integer rather
than the same type as inputs.

Change-Id: Ifd3d7ebd879be5c6b2c8e23aa6d7ef41f39c6d41

Reviewed By: mgehre-amd

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

12 months ago[NFC] Remove extra semicolons in clang/lib/APINotes/APINotesFormat.h
Evan Wilde [Fri, 21 Jul 2023 23:17:16 +0000 (16:17 -0700)]
[NFC] Remove extra semicolons in clang/lib/APINotes/APINotesFormat.h

There are some trailing semicolons on namespaces in
clang/lib/APINotes/APINotesFormat.h. These result in warnings while
building and don't need to be there.

Reviewed By: compnerd

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

12 months ago[AMDGPU] Fix an unused variable warning
Kazu Hirata [Fri, 21 Jul 2023 23:14:41 +0000 (16:14 -0700)]
[AMDGPU] Fix an unused variable warning

This patch fixes:

  llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp:1006:9: error:
  unused variable 'Ty' [-Werror,-Wunused-variable]

12 months agoEnable compact unwind in all darwin simulators
Jon Roelofs [Fri, 21 Jul 2023 19:51:39 +0000 (12:51 -0700)]
Enable compact unwind in all darwin simulators

... since they've always supported it.

rdar://104359594

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

12 months agoRevert "[RISCV] Add test which shows alignment of constant pools and the functions...
Philip Reames [Fri, 21 Jul 2023 23:02:33 +0000 (16:02 -0700)]
Revert "[RISCV] Add test which shows alignment of constant pools and the functions which followed"

This reverts commit cbf2a6ce197e8176c01316fe25400aae0b7390c4.  This was a precommited test for a change which is being abandoned.

12 months agoRevert "Reapply [IR] Mark and constant expressions as undesirable"
Nathan Chancellor [Fri, 21 Jul 2023 22:23:08 +0000 (15:23 -0700)]
Revert "Reapply [IR] Mark and constant expressions as undesirable"

This reverts commit 086ee99564afbb11449c08ea2e094f7f49fadde5.

This patch causes an infinite loop when building arch/mips/mm/c-r4k.c in
the Linux kernel. See the comment in Phabricator for a reduced
reproducer: https://reviews.llvm.org/rG086ee99564afbb11449c08ea2e094f7f49fadde5

12 months agoAMDGPU: Fix variables only used in asserts
Matt Arsenault [Fri, 21 Jul 2023 22:52:50 +0000 (18:52 -0400)]
AMDGPU: Fix variables only used in asserts

12 months agoAMDGPU: Implement new 2ulp fdiv lowering
Matt Arsenault [Sun, 16 Jul 2023 12:32:08 +0000 (08:32 -0400)]
AMDGPU: Implement new 2ulp fdiv lowering

Extends the new frexp scaled reciprocal to the general case. The
reciprocal case is just the same thing when frexp of 1 is constant
folded. Could probably clean up the code to rely on that constant
folding.

Improves results for the IEEE path for the default OpenCL division. We
used to only emit the fdiv.fast intrinsic with a 2.5 ulp accuracy
threshold with DAZ, which uses explicit range checks. This gives us a
better fast option with the default IEEE behavior.

12 months agoAMDGPU: Refactor AMDGPUCodeGenPrepare fdiv handling
Matt Arsenault [Wed, 19 Jul 2023 14:11:53 +0000 (10:11 -0400)]
AMDGPU: Refactor AMDGPUCodeGenPrepare fdiv handling

NFC-ish. Does trigger some reordering of the fdiv scalarization. Also
skips scalarizing in more cases where nothing was going to happen. We
can still scalarize in some no-op edge cases.

https://reviews.llvm.org/D155740

12 months agoTrack the RequestingModule in the HeaderSearch LookupFile cache.
Richard Smith [Fri, 21 Jul 2023 21:53:36 +0000 (14:53 -0700)]
Track the RequestingModule in the HeaderSearch LookupFile cache.

Different requesting modules can have different lookup results, so don't
cache results across modules.

Fixes a regression introduced in reviews.llvm.org/D132779.

Test case based on one provided by Jan Svoboda.

Reviewed By: jansvoboda11

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

12 months ago[flang] Fix portability warning that was incorrectly an "else if"
Peter Klausler [Thu, 20 Jul 2023 19:37:25 +0000 (12:37 -0700)]
[flang] Fix portability warning that was incorrectly an "else if"

A semantics check for an assumed-length dummy procedure pointer was
inappropriately part of an "else" clause for a preceding check,
causing it to not be applied in all situations.

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

12 months ago[mlir][arith] Add canon pattern for chained `arith.muli`
Jakub Kuderski [Fri, 21 Jul 2023 22:17:39 +0000 (18:17 -0400)]
[mlir][arith] Add canon pattern for chained `arith.muli`

@benvanik reported this as missing.

Reviewed By: Mogball

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

12 months ago[HWASAN][LSAN] Replace cstdint with stdint.h
Kirill Stoimenov [Fri, 21 Jul 2023 21:17:50 +0000 (21:17 +0000)]
[HWASAN][LSAN] Replace cstdint with stdint.h

Reviewed By: brooksmoses, MaskRay

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