platform/upstream/llvm.git
17 months agoMake optimize llvm common to both gpu-to-hsaco/cubin
Vinayaka Bandishti [Mon, 5 Jun 2023 05:02:51 +0000 (10:32 +0530)]
Make optimize llvm common to both gpu-to-hsaco/cubin

Before serializing, optimizations on llvm were only called on path to
hsaco, and not cubin. Define opt-level for `gpu-to-cubin` pass as well,
and move call to optimize llvm to a common place.

Reviewed By: bondhugula

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

17 months ago[clang][CodeGen] Account for VTT address space
Alex Voicu [Mon, 5 Jun 2023 02:06:25 +0000 (03:06 +0100)]
[clang][CodeGen] Account for VTT address space

Correctly account for the fact that certain targets do not use the generic address space for the implicit VTT argument. This entails adjusting `ItaniumCXXABI::buildStructorSignature`, `ItaniumCXXABI::addImplicitStructorParams` and `ItaniumCXXABI::getImplicitConstructorArgs` to use the target's global variable address space. The associated test is temporarily marked `XFAIL` as additional fixes are needed.

Reviewed By: rjmccall

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

17 months ago[NFC][COFF] Use COFFSection.MCSection when writeSection
Haohai Wen [Mon, 5 Jun 2023 01:33:45 +0000 (09:33 +0800)]
[NFC][COFF] Use COFFSection.MCSection when writeSection

Each COFFSection bind MCSection when created. No need to iterate
throught MCAssembler when writeSection.

Reviewed By: skan

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

17 months ago[AIX] use system assembler for assembly files
Chen Zheng [Mon, 5 Jun 2023 01:36:58 +0000 (21:36 -0400)]
[AIX] use system assembler for assembly files
Change to system assembler to compile assembly files even
-fintegrated-as is specified. We don't have a good Clang as
for now for assembly files on AIX.

Reviewed By: qiucf

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

17 months ago[mlir][bytecodegen] Add list helper methods.
Jacques Pienaar [Sun, 4 Jun 2023 22:52:37 +0000 (15:52 -0700)]
[mlir][bytecodegen] Add list helper methods.

Previously the SignedVarInt was incorrectly defined. Follow up work
needed for improving Array printing/parsing, but correcting the
definitions for now.

17 months agoFix test bot breakage from 36f351098cd50809658493d9b2e22a795874bab0
Alexey Lapshin [Sun, 4 Jun 2023 22:04:30 +0000 (00:04 +0200)]
Fix test bot breakage from 36f351098cd50809658493d9b2e22a795874bab0

This addresses the issue found by: https://lab.llvm.org/buildbot/#/builders/192/builds/2309

17 months ago[mlir][bytecodegen] Add ReservedOrDead marker.
Jacques Pienaar [Sun, 4 Jun 2023 21:59:50 +0000 (14:59 -0700)]
[mlir][bytecodegen] Add ReservedOrDead marker.

Enables reserving or marking dead in enum list, resulting in skipping in dispatches.

17 months ago[mlir][bytecodegen] Remove comments (NFC).
Jacques Pienaar [Sun, 4 Jun 2023 21:19:40 +0000 (14:19 -0700)]
[mlir][bytecodegen] Remove comments (NFC).

Fix missed review comment from https://reviews.llvm.org/D144820

17 months ago[Docs][llvm-mc] Fix location of statement
Aiden Grossman [Sun, 4 Jun 2023 20:40:37 +0000 (20:40 +0000)]
[Docs][llvm-mc] Fix location of statement

The comment moved is referring to the --output-asm-syntax flag rather
than the --print-imm-hex flag, but seems to have mistakenly been put
under the definition of that flag due to some misplaced line numbers on
phabricator.

17 months ago[bazel] Port 36f351098cd5
Benjamin Kramer [Sun, 4 Jun 2023 19:39:52 +0000 (21:39 +0200)]
[bazel] Port 36f351098cd5

17 months ago[LV] Check if value was already not uniform for previous VF.
Florian Hahn [Sun, 4 Jun 2023 19:31:00 +0000 (20:31 +0100)]
[LV] Check if value was already not uniform for previous VF.

If the value was already known to not be uniform for the previous
(smaller VF), it cannot be uniform for the larger VF.

This slightly reduces compile-time, once uniformity checks are becoming
a bit more expensive due to using SCEV rewriting (D148841).

Reviewed By: Ayal

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

17 months agomake sanitizer happy for 36f351098cd50809658493d9b2e22a795874bab0.
Alexey Lapshin [Sun, 4 Jun 2023 18:46:55 +0000 (20:46 +0200)]
make sanitizer happy for 36f351098cd50809658493d9b2e22a795874bab0.

17 months ago[gn build] Port 36f351098cd5
LLVM GN Syncbot [Sun, 4 Jun 2023 18:33:22 +0000 (18:33 +0000)]
[gn build] Port 36f351098cd5

17 months ago[DWARFLinkerParallel][Reland] Add interface files, create a skeleton implementation.
Alexey Lapshin [Fri, 31 Mar 2023 22:12:29 +0000 (00:12 +0200)]
[DWARFLinkerParallel][Reland] Add interface files, create a skeleton implementation.

This patch creates skeleton implementation for the DWARFLinkerParallel.
It also integrates DWARFLinkerParallel into dsymutil and llvm-dwarfutil,
so that empty DWARFLinker::link() can be called. To do this new command
line option is added "--linker apple/llvm". Additionally it changes
existing DWARFLinker interfaces/implementations to be compatible:
use Error for error reporting for the DWARFStreamer, make DWARFFile to
owner of referenced resources, other small refactorings.

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

17 months ago[gn build] Port 7e1ee1e10dc0
LLVM GN Syncbot [Sun, 4 Jun 2023 17:27:50 +0000 (17:27 +0000)]
[gn build] Port 7e1ee1e10dc0

17 months ago[libcxx] Add strict weak ordering checks to sorting algorithms
Danila Kutenin [Sun, 4 Jun 2023 17:24:24 +0000 (19:24 +0200)]
[libcxx] Add strict weak ordering checks to sorting algorithms

This is the implementation of the first proposal of strict weak ordering checks described in https://discourse.llvm.org/t/rfc-strict-weak-ordering-checks-in-the-debug-libc/70217

This targets the most vulnerable algorithms like std::sort

Reviewed By: philnik, #libc

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

17 months ago[NFC][CLANG] [NFC][CLANG] Fix nullptr dereference issue in ConvertQualTypeToKind()
Manna, Soumi [Sun, 4 Jun 2023 16:35:29 +0000 (09:35 -0700)]
[NFC][CLANG] [NFC][CLANG] Fix nullptr dereference issue in ConvertQualTypeToKind()

This patch uses castAs instead of getAs which will assert if the type doesn't match in ConvertQualTypeToKind(clang::ASTContext const &, clang::QualType).

Reviewed By: erichkeane

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

17 months ago[NFC][CLANG] Fix Static Code Analyzer Concerns
Manna, Soumi [Sun, 4 Jun 2023 16:04:49 +0000 (09:04 -0700)]
[NFC][CLANG] Fix Static Code Analyzer Concerns

This patch uses castAs instead of getAs which will assert if the type doesn't match to resolve dereference issue with nullptr FPT when calling getThisType() in clang::CodeGen::CGDebugInfo::CreateType(clang::MemberPointerType const *, llvm::DIFile *).

Reviewed By: erichkeane

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

17 months ago[GlobalIsel][X86] Move G_ICMP legalization before legacy handling and merge 32-bit...
Simon Pilgrim [Sun, 4 Jun 2023 15:59:23 +0000 (16:59 +0100)]
[GlobalIsel][X86] Move G_ICMP legalization before legacy handling and merge 32-bit/64-bit handling

I've kept the legalForCartesianProduct call, but this requires us to maintain 32-bit/64-bit integer lists - we might want to just use legalIf and perform the type pair set matching manually.

17 months ago[AVR][NFC][test] Suppement a test of the pseudo instruction RORBRd
Ben Shi [Sun, 4 Jun 2023 03:22:10 +0000 (11:22 +0800)]
[AVR][NFC][test] Suppement a test of the pseudo instruction RORBRd

Reviewed By: aykevl, Patryk27

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

17 months ago[MC] Remove unused mc_difflist_iterator constructor (NFC)
Sergei Barannikov [Sun, 4 Jun 2023 14:06:53 +0000 (17:06 +0300)]
[MC] Remove unused mc_difflist_iterator constructor (NFC)

The constructor hasn't been used since its introduction.

17 months ago[GlobalIsel][X86] Move G_PTRTOINT/G_INTTOPTR legalization before legacy handling...
Simon Pilgrim [Sun, 4 Jun 2023 14:21:42 +0000 (15:21 +0100)]
[GlobalIsel][X86] Move G_PTRTOINT/G_INTTOPTR legalization before legacy handling and merge 32-bit/64-bit handling

I've kept the legalForCartesianProduct call, but this requires us to maintain 32-bit/64-bit integer lists - we might want to just use legalIf and perform the type pair set matching manually.

17 months ago[gn build] Port 66e5678fece3
LLVM GN Syncbot [Sun, 4 Jun 2023 11:36:45 +0000 (11:36 +0000)]
[gn build] Port 66e5678fece3

17 months ago[clang][CodeGen] Break up TargetInfo.cpp [6/8]
Sergei Barannikov [Tue, 9 May 2023 07:16:20 +0000 (10:16 +0300)]
[clang][CodeGen] Break up TargetInfo.cpp [6/8]

Make `qualifyWindowsLibrary` and `addStackProbeTargetAttributes`
protected members of `TargetCodeGenInfo`.
These are helper functions used by `getDependentLibraryOption` and
`setTargetAttributes` methods when targeting Windows. The change will
allow these functions to be reused after splitting `TargetInfo.cpp`.

Reviewed By: MaskRay

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

17 months ago[GlobalIsel][X86] Remove some unused setLegalizerInfo* methods. NFC.
Simon Pilgrim [Sun, 4 Jun 2023 11:34:05 +0000 (12:34 +0100)]
[GlobalIsel][X86] Remove some unused setLegalizerInfo* methods. NFC.

We're moving away from using per-ISA legalization controls and using LegalIf etc. to handle specific ISAs instead.

17 months agoRevert "[DWARFLinkerParallel] Add interface files, create a skeleton implementation."
Alexey Lapshin [Sun, 4 Jun 2023 11:28:54 +0000 (13:28 +0200)]
Revert "[DWARFLinkerParallel] Add interface files, create a skeleton implementation."

This reverts commit e0ba9b2ace7ffc20bf8fe2eb533d638f27619b10.

17 months ago[gn build] Port e0ba9b2ace7f
LLVM GN Syncbot [Sun, 4 Jun 2023 11:09:26 +0000 (11:09 +0000)]
[gn build] Port e0ba9b2ace7f

17 months ago[DWARFLinkerParallel] Add interface files, create a skeleton implementation.
Alexey Lapshin [Fri, 31 Mar 2023 22:12:29 +0000 (00:12 +0200)]
[DWARFLinkerParallel] Add interface files, create a skeleton implementation.

This patch creates skeleton implementation for the DWARFLinkerParallel.
It also integrates DWARFLinkerParallel into dsymutil and llvm-dwarfutil,
so that empty DWARFLinker::link() can be called. To do this new command
line option is added "--linker apple/llvm". Additionally it changes
existing DWARFLinker interfaces/implementations to be compatible:
use Error for error reporting for the DWARFStreamer, make DWARFFile to
owner of referenced resources, other small refactorings.

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

17 months ago[CodeGen] Fix incorrect usage of MCPhysReg for diff list elements
Sergei Barannikov [Sat, 20 May 2023 18:30:02 +0000 (21:30 +0300)]
[CodeGen] Fix incorrect usage of MCPhysReg for diff list elements

The lists contain differences between register numbers, not the register
numbers themselves. Since a difference can also be negative, this also
changes its type to signed.

Changing the type to signed exposed a "bug". For AMDGPU, which has many
registers, the first element of a sequence could be as big as ~45k.
The value does not fit into int16_t, but fits into uint16_t. The bug
didn't show up because of unsigned wrapping and truncation of the Val
field in the advance() method.

To fix the issue, I changed the way regunit difflists are encoded. The
4-bit 'scale' field of MCRegisterDesc::RegUnit was replaced by 12-bit
number of the first regunit, and the first element of each of the lists
was removed. The higher 20 bits of RegUnit field contain the initial
offset into DiffLists array.
AMDGPU has 1'409 regunits (2^12 = 4'096), and the biggest offset is
80'041 (2^20 = 1'048'576). That is, there is enough room.

Changing the encoding method also resulted in a smaller array size, the
numbers are below (I omitted targets with less than 100 elements).

```
AMDGPU   | 80052 | 78741 |  -1,6%
RISCV    |  6498 |  6297 |  -3,1%
ARM      |  4181 |  3966 |  -5,1%
AArch64  |  2770 |  2592 |  -6,4%
PPC      |  1578 |  1441 |  -8,7%
Hexagon  |   994 |   740 | -25,6%
R600     |   508 |   398 | -21,7%
VE       |   471 |   459 |  -2,5%
Sparc    |   381 |   363 |  -4,7%
X86      |   326 |   208 | -36,2%
Mips     |   253 |   200 | -20,9%
SystemZ  |   186 |   162 | -12,9%
```

Reviewed By: foad, arsenm

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

17 months ago[GlobalIsel][X86] Update legalization of G_AND/G_OR/G_XOR
Simon Pilgrim [Sun, 4 Jun 2023 10:44:19 +0000 (11:44 +0100)]
[GlobalIsel][X86] Update legalization of G_AND/G_OR/G_XOR

Replace the legacy G_AND/G_OR/G_XOR legalizer, this handles all scalar promotion and vector clamping (allows AVX1 to handle 256-bit logic ops).

17 months ago[Hexagon] Check if register is non-null before calling subregs_inclusive
Sergei Barannikov [Thu, 25 May 2023 04:50:54 +0000 (07:50 +0300)]
[Hexagon] Check if register is non-null before calling subregs_inclusive

D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.

Reviewed By: kparzysz

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

17 months ago[GlobalISel] Fix DIVREM combine from inserting a divrem before its operands' defs.
Amara Emerson [Sun, 4 Jun 2023 07:23:47 +0000 (00:23 -0700)]
[GlobalISel] Fix DIVREM combine from inserting a divrem before its operands' defs.

In some rare corner cases where in between the div/rem pair there's a def of
the second instruction's source (but a different vreg due to the combine's
eqivalence checks), it will place the DIVREM at the first instruction's point,
causing a use-before-def. There wasn't an obvious fix that stood out to me
without doing more involved analysis than a combine should really be doing.

Fixes issue #60516

I'm open to new suggestions on how to approach this, as I'm not too happy
at bailing out here. It's not the first time we run into issues with value liveness
that the DAG world isn't affected by.

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

17 months ago[MemCpyOpt] Remove unnecessary bitcast and reuse some variables for ByValOptimization...
khei4 [Sat, 3 Jun 2023 09:06:43 +0000 (18:06 +0900)]
[MemCpyOpt] Remove unnecessary bitcast and reuse some variables for ByValOptimization (NFC)
Differential Revision: https://reviews.llvm.org/D152056

17 months ago[MC] Modernize InlineAsmIdentifier (NFC)
Kazu Hirata [Sun, 4 Jun 2023 06:36:54 +0000 (23:36 -0700)]
[MC] Modernize InlineAsmIdentifier (NFC)

17 months ago[IR] Remove unused declaration removeParamUndefImplyingAttrs
Kazu Hirata [Sun, 4 Jun 2023 06:36:53 +0000 (23:36 -0700)]
[IR] Remove unused declaration removeParamUndefImplyingAttrs

The corresponding function definition was removed by:

  commit 087a8eea359a4d8ef22c42fddca3b09833928c6a
  Author: Nikita Popov <nikita.ppv@gmail.com>
  Date:   Sun Jul 25 18:21:13 2021 +0200

17 months ago[DWARFLinker] Remove unused declaration keepDIEAndDependencies
Kazu Hirata [Sun, 4 Jun 2023 06:36:51 +0000 (23:36 -0700)]
[DWARFLinker] Remove unused declaration keepDIEAndDependencies

The corresponding function definition was removed by:

  commit 95a8e8a2557e487be6133475966255661a9f6567
  Author: Jonas Devlieghere <jonas@devlieghere.com>
  Date:   Tue Dec 3 11:10:04 2019 -0800

17 months ago[AST] Remove unused declaration makeDeclVisibleInContextInternal
Kazu Hirata [Sun, 4 Jun 2023 06:36:50 +0000 (23:36 -0700)]
[AST] Remove unused declaration makeDeclVisibleInContextInternal

The corresponding function definition was removed by:

  commit f634c9006977fcbed5f55eaee831852e453fdf76
  Author: Richard Smith <richard-llvm@metafoo.co.uk>
  Date:   Fri Mar 16 06:12:59 2012 +0000

17 months ago[clang][NFC] Reformat expandTabs
Timm Bäder [Sun, 4 Jun 2023 05:49:43 +0000 (07:49 +0200)]
[clang][NFC] Reformat expandTabs

Use the proper capitalization here as well as a init capture for better
identifiers.

17 months ago[AVR] Fix incorrect operands of pseudo instruction 'ROLBRd'
Patryk Wychowaniec [Sun, 4 Jun 2023 03:08:54 +0000 (11:08 +0800)]
[AVR] Fix incorrect operands of pseudo instruction 'ROLBRd'

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

Reviewed by: benshi001

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

17 months agoAttributor: Fix comment typos
Matt Arsenault [Sat, 3 Jun 2023 19:30:45 +0000 (15:30 -0400)]
Attributor: Fix comment typos

17 months ago[libc][CMake] Place archives in build/lib/<target-triple>
Aiden Grossman [Sat, 3 Jun 2023 22:37:21 +0000 (22:37 +0000)]
[libc][CMake] Place archives in build/lib/<target-triple>

This patch moves the location of libllvmlibc.a within the build tree to
within ./lib/<target triple>. This more closely matches the behavior of
other runtime builds and allows for clang in the same build tree to
automatically be able to link against llvmlibc since this path is by
default included by the driver.

Also removes the LIBC_BINARY_DIR CMake flag since it isn't used anywhere
in the tree (based on a quick grep).

Reviewed By: phosek

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

17 months ago[CMake][Fuchsia] Add LLVM_ENABLE_HTTPLIB to Stage 2 build
Aiden Grossman [Sat, 3 Jun 2023 22:30:05 +0000 (22:30 +0000)]
[CMake][Fuchsia] Add LLVM_ENABLE_HTTPLIB to Stage 2 build

This patch sets the LLVM_ENABLE_HTTPLIB flag to ON in the stage 2 build
similar to how many of the other dependency flags are already specified.
This is necessary to configure the stage 2 build by itself, otherwise
the CMake configuration crashes.

This is currently causing the MLGO demo to fail since we're only using
stage 2 to avoid having to build stage 1 to save some compile time.

Reviewed By: phosek

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

17 months ago[Docs][CMake] Add LLVM_ENABLE_HTTPLIB to CMake options list
Aiden Grossman [Sat, 3 Jun 2023 22:26:33 +0000 (22:26 +0000)]
[Docs][CMake] Add LLVM_ENABLE_HTTPLIB to CMake options list

This patch adds LLVM_ENABLE_HTTPLIB to the list of CMake options to make
it more clear exactly what it does and also provide clarity on which
specific project it is referring to/installation.

Reviewed By: phosek

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

17 months ago[clang-tools-extra] Fix linking when built with CLANG_LINK_CLANG_DYLIB=ON
Martin Storsjö [Sat, 3 Jun 2023 20:15:51 +0000 (23:15 +0300)]
[clang-tools-extra] Fix linking when built with CLANG_LINK_CLANG_DYLIB=ON

clangIncludeCleaner isn't part of libclang-cpp, so link it with
target_link_libraries instead of clang_target_link_libraries.

This fixes a regression from
c28506ba4b6961950849f8fdecd0cf7e503a14f9.

Fix suggested by Michal Gorny.

17 months ago[libcxx] Fix using std::wcout/wcin on Windows with streams configured in wide mode
Martin Storsjö [Wed, 15 Mar 2023 10:11:28 +0000 (12:11 +0200)]
[libcxx] Fix using std::wcout/wcin on Windows with streams configured in wide mode

On Windows, the underlying file descriptors for stdout/stdin/stderr
can be reconfigured to wide mode. In the default (narrow) mode, the
charset usually isn't utf8 (as libcxx assumes), but normally a locale
specific codepage (where each codepage only can represent a small
subset of unicode characters).

By configuring the stdout file descriptor to wide mode, the user can
output wchar_t based strings without convesion to the narrow charset.
Within libcxx, don't try to use codecvt to convert this to a narrow
character encoding, but output these strings as such with fputwc.

In wide mode, such strings could be output directly with fwrite too,
but if the file descriptor hasn't been configured in wide mode, that
breaks the output (which currently works reasonably). By always
outputting one character at a time with fputwc, it works regardless
of mode of the stdout file descriptor.

For the narrow output stream, std::cout, outputting (via fwrite)
does fail when the file descriptor is set to wide mode. This matches
how it behaves with both MS STL and GNU libstdc++ too, so this is
probably acceptable.

This fixes https://github.com/llvm/llvm-project/issues/46646, and
the downstream bugs https://github.com/mstorsjo/llvm-mingw/issues/145
and https://github.com/mstorsjo/llvm-mingw/issues/222.

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

17 months ago[clang-format] Fix overlapping replacements before PPDirectives
Owen Pan [Fri, 2 Jun 2023 00:39:39 +0000 (17:39 -0700)]
[clang-format] Fix overlapping replacements before PPDirectives

If the first token of an annotated line is finalized, reuse its
NewlinesBefore value to avoid potential overlapping whitespace
replacements before preprocessor branching directives.

Fixes #62892.

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

17 months ago[MCA] Modernize Stage (NFC)
Kazu Hirata [Sat, 3 Jun 2023 18:01:18 +0000 (11:01 -0700)]
[MCA] Modernize Stage (NFC)

17 months ago[MCA] Modernize RAWHazard (NFC)
Kazu Hirata [Sat, 3 Jun 2023 18:01:17 +0000 (11:01 -0700)]
[MCA] Modernize RAWHazard (NFC)

17 months ago[MCA] Modernize MemoryGroup (NFC)
Kazu Hirata [Sat, 3 Jun 2023 18:01:15 +0000 (11:01 -0700)]
[MCA] Modernize MemoryGroup (NFC)

17 months ago[MCA] Modernize StallInfo (NFC)
Kazu Hirata [Sat, 3 Jun 2023 17:38:55 +0000 (10:38 -0700)]
[MCA] Modernize StallInfo (NFC)

17 months ago[llvm-mca] Modernize MCACommentConsumer (NFC)
Kazu Hirata [Sat, 3 Jun 2023 17:38:53 +0000 (10:38 -0700)]
[llvm-mca] Modernize MCACommentConsumer (NFC)

17 months ago[MCA] Modernize IncrementalSourceMgr (NFC)
Kazu Hirata [Sat, 3 Jun 2023 17:38:51 +0000 (10:38 -0700)]
[MCA] Modernize IncrementalSourceMgr (NFC)

17 months ago[GlobalIsel][X86] Update legalization of G_MUL
Simon Pilgrim [Sat, 3 Jun 2023 17:19:46 +0000 (18:19 +0100)]
[GlobalIsel][X86] Update legalization of G_MUL

Replace the legacy G_MUL legalizer, this handles all scalar promotion and vector clamping, however we still need to add custom legalization for many vector multiplies.

17 months ago[Clang][RISCV] Avoid generating MaskedPrototype if the intrinsic does not have a...
eopXD [Sat, 3 Jun 2023 17:07:02 +0000 (10:07 -0700)]
[Clang][RISCV] Avoid generating MaskedPrototype if the intrinsic does not have a masked version. NFC

The function should not be called if an intrinsic does not have a masked version.

Signed-off by: eop Chen <eop.chen@sifive.com>

17 months ago[MCA] Modernize Pipeline (NFC)
Kazu Hirata [Sat, 3 Jun 2023 16:37:39 +0000 (09:37 -0700)]
[MCA] Modernize Pipeline (NFC)

17 months ago[Serialization] Remove unused function getKnownModules
Kazu Hirata [Sat, 3 Jun 2023 16:37:37 +0000 (09:37 -0700)]
[Serialization] Remove unused function getKnownModules

The last use was removed by:

  commit 603cd869f7cdb0da7a545e86a1786f3175f72475
  Author: Douglas Gregor <dgregor@apple.com>
  Date:   Fri Mar 22 18:50:14 2013 +0000

17 months ago[AST] Use DenseMapBase::lookup (NFC)
Kazu Hirata [Sat, 3 Jun 2023 16:37:36 +0000 (09:37 -0700)]
[AST] Use DenseMapBase::lookup (NFC)

17 months ago[Clang] Fix status of P0960
Corentin Jabot [Mon, 8 May 2023 15:24:42 +0000 (17:24 +0200)]
[Clang] Fix status of P0960

P0960R3 and P1975R0 were marked not implemented because
of #61145,

This issue has been fixed and backported to LLVM 16,
the status page should reflect that.

Reviewed By: #clang-language-wg, ayzhao, erichkeane

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

17 months ago[IndVars] Add check of loop invariant for indirect use
zhongyunde [Sat, 3 Jun 2023 14:28:55 +0000 (22:28 +0800)]
[IndVars] Add check of loop invariant for indirect use

We usually only check direct use instruction of IV, while the
bitcast of 'ptrtoint ptr to i64' doesn't affect the result, so go
a step further.
Fix https://github.com/llvm/llvm-project/issues/59633.

Reviewed By: markoshorro
Differential Revision: https://reviews.llvm.org/D151877

17 months ago[flang] Fix for 541f5c4a6db35870091dd15dfa09dde751229a17 (D140524) breaking out-of...
Hussain Kadhem [Sat, 3 Jun 2023 13:13:09 +0000 (15:13 +0200)]
[flang] Fix for 541f5c4a6db35870091dd15dfa09dde751229a17 (D140524) breaking out-of-tree flang build.

17 months ago[CMake] Ensure `CLANG_RESOURCE_DIR` is respected.
paperchalice [Sat, 3 Jun 2023 06:29:44 +0000 (23:29 -0700)]
[CMake] Ensure `CLANG_RESOURCE_DIR` is respected.

re-commit of 39aa0f5c434b463520ac39a8dbe933ee8c4c5ea7 with missing file:
cmake/Modules/GetClangResourceDir.cmake.

17 months ago[m68k] Add TLS Support
Sheng [Sat, 3 Jun 2023 10:05:42 +0000 (18:05 +0800)]
[m68k] Add TLS Support

This patch introduces TLS (Thread-Local Storage) support to the LLVM m68k backend.

Reviewed By: glaubitz

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

17 months ago[m68k] Implement absolution long addressing mode for ADDA instruction
Sheng [Sat, 3 Jun 2023 10:05:41 +0000 (18:05 +0800)]
[m68k] Implement absolution long addressing mode for ADDA instruction

Reviewed By: myhsu

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

17 months ago[m68k] Implement BSR Instruction
Sheng [Sat, 3 Jun 2023 10:05:34 +0000 (18:05 +0800)]
[m68k] Implement BSR Instruction

Reviewed By: myhsu

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

17 months agocoach UpdateTestChecks to filter out certain symbol aliases for m68k
Sheng [Sat, 3 Jun 2023 10:05:23 +0000 (18:05 +0800)]
coach UpdateTestChecks to filter out certain symbol aliases for m68k

This patch coaches UpdateTestChecks to filter out these symbol aliases in llc test for m68k
- .L<function name>$local:
- .type .L<function name>$local,@function

Reviewed By: myhsu

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

17 months ago[GlobalIsel][X86] Regenerate G_MUL scalar legalization tests
Simon Pilgrim [Fri, 2 Jun 2023 19:12:52 +0000 (20:12 +0100)]
[GlobalIsel][X86] Regenerate G_MUL scalar legalization tests

Add i8 test coverage

17 months agoRevert "[CMake] Ensure `CLANG_RESOURCE_DIR` is respected."
Martin Storsjö [Sat, 3 Jun 2023 08:44:06 +0000 (11:44 +0300)]
Revert "[CMake] Ensure `CLANG_RESOURCE_DIR` is respected."

This reverts commit 39aa0f5c434b463520ac39a8dbe933ee8c4c5ea7.

This is missing the new GetClangResourceDir.cmake that is being included,
so all clang builds are broken.

17 months ago[llvm] Strip stabs symbols in Mach-O when stripping debug info
Mike Hommey [Sat, 3 Jun 2023 07:31:42 +0000 (09:31 +0200)]
[llvm] Strip stabs symbols in Mach-O when stripping debug info

17 months ago[InstSimplify] Simplify select i1 ConstExpr, i1 true, i1 false to ConstExpr
luxufan [Thu, 1 Jun 2023 05:54:16 +0000 (13:54 +0800)]
[InstSimplify] Simplify select i1 ConstExpr, i1 true, i1 false to ConstExpr

`select i1 non-const, i1 true, i1 false` has been optimized to
`non-const`. There is no reason that we can not optimize `select i1
ConstExpr, i1 true, i1 false` to `ConstExpr`.

Reviewed By: nikic

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

17 months ago[CMake] Ensure `CLANG_RESOURCE_DIR` is respected.
paperchalice [Sat, 3 Jun 2023 06:29:44 +0000 (23:29 -0700)]
[CMake] Ensure `CLANG_RESOURCE_DIR` is respected.

17 months ago[TableGen][GlobalISel] Account for HwMode in RegisterBank register sizes
Nitin John Raj [Sat, 3 Jun 2023 05:08:05 +0000 (22:08 -0700)]
[TableGen][GlobalISel] Account for HwMode in RegisterBank register sizes

This patch adds logic for determining RegisterBank size to RegisterBankInfo, which allows accounting for the HwMode of the target. Individual RegisterBanks cannot be constructed with HwMode information as construction is generated by TableGen, but a RegisterBankInfo subclass can provide the HwMode as a constructor argument. The HwMode is used to select the appropriate RegisterBank size from an array relating sizes to RegisterBanks.

Targets simply need to provide the HwMode argument to the <target>GenRegisterBankInfo constructor. The RISC-V RegisterBankInfo constructor has been updated accordingly (plus an unused argument removed).

Reviewed By: simoncook, craig.topper

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

17 months ago[AMDGPU] Don't flush vmcnt for loops with use/def pairs
Austin Kerbow [Mon, 22 May 2023 17:32:09 +0000 (10:32 -0700)]
[AMDGPU] Don't flush vmcnt for loops with use/def pairs

Conditions for hoisting vmcnt with flat instructions should be similar to VMEM.
If there are use/def pairs in a loop body we cannot guarantee that hosting the
waitcnt will be profitable. Better heuristics are needed to analyse whether
gains from avoiding waitcnt in loop bodys outweighs waiting for loads in the
preheader.

Reviewed By: foad

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

17 months ago[CodeGen] Use DenseMapBase::lookup (NFC)
Kazu Hirata [Sat, 3 Jun 2023 04:05:13 +0000 (21:05 -0700)]
[CodeGen] Use DenseMapBase::lookup (NFC)

Note that DenseMapBase::lookup and Reg2MIMap::get do exactly the same
thing.

17 months ago[RISCV] Avoid illegal DAG combination for strict-fp nodes.
Yeting Kuo [Fri, 2 Jun 2023 12:38:03 +0000 (20:38 +0800)]
[RISCV] Avoid illegal DAG combination for strict-fp nodes.

Those combines may change the exception behavior and rounding behavior.

Reviewed By: craig.topper

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

17 months ago[mlir][sparse] fix crash when using sparse_tensor::UnaryOp and ReduceOp.
Peiming Liu [Sat, 3 Jun 2023 00:49:37 +0000 (00:49 +0000)]
[mlir][sparse] fix crash when using sparse_tensor::UnaryOp and ReduceOp.

Reviewed By: aartbik

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

17 months ago[libc][NFC] Add LIBC_INLINE and attribute.h header includes to targets' FMA.h.
Tue Ly [Fri, 2 Jun 2023 20:13:19 +0000 (16:13 -0400)]
[libc][NFC] Add LIBC_INLINE and attribute.h header includes to targets' FMA.h.

Targets' FMA.h headers are missing LIBC_INLINE and attributes.h header.

Reviewed By: brooksmoses

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

17 months ago[mlir][sparse] fixed bug with unary op, dense output
Aart Bik [Fri, 2 Jun 2023 23:41:49 +0000 (16:41 -0700)]
[mlir][sparse] fixed bug with unary op, dense output

Note that by sparse compiler convention, dense output
is zerod out when not set, so complement results in
zeros where elements were present.

Reviewed By: wrengr

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

17 months ago[scudo] Add 'inline' to static secondary.h function
Caslyn Tonelli [Fri, 2 Jun 2023 22:13:50 +0000 (22:13 +0000)]
[scudo] Add 'inline' to static secondary.h function

This patches an error flaged by Fuchsia builds e.g.
https://ci.chromium.org/ui/p/turquoise/builders/global.try/core.x64-asan/b8779376650819379137/overview)

```
build failed:

[87176/332302](525) CXX user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o
FAILED: user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o
../../prebuilt/third_party/python3/linux-x64/bin/python3.8 -S ../../build/rbe/cxx_remote_wrapper.py --exec_strategy=remote_local_fallback --  ../../prebuilt/third_party/clang/linux-x64/bin/clang++ -MD -MF user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o.d -o user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o -D_LIBCPP...
In file included from ../../zircon/system/ulib/c/scudo/gwp_asan_info.cc:7:
In file included from ../../third_party/scudo/src/allocator_config.h:12:
In file included from ../../third_party/scudo/src/combined.h:22:
../../third_party/scudo/src/secondary.h:67:13: error: 'static' function 'unmap' declared in header file should be declared 'static inline' [-Werror,-Wunneeded-internal-declaration]
static void unmap(LargeBlock::Header *H) {
            ^
1 error generated.
```

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

17 months ago[gn] port 6b3ae49d3243
Nico Weber [Fri, 2 Jun 2023 23:37:10 +0000 (19:37 -0400)]
[gn] port 6b3ae49d3243

17 months ago[InlineCost] Check for conflicting target attributes early
Kazu Hirata [Fri, 2 Jun 2023 23:00:47 +0000 (16:00 -0700)]
[InlineCost] Check for conflicting target attributes early

When we inline a callee into a caller, the compiler needs to make sure
that the caller supports a superset of instruction sets that the
callee is allowed to use.  Normally, we check for the compatibility of
target features via functionsHaveCompatibleAttributes, but that
happens after we decide to honor call site attribute
Attribute::AlwaysInline.  If the caller contains a call marked with
Attribute::AlwaysInline, which can happen with
__attribute__((flatten)) placed on the caller, the caller could end up
with code that cannot be lowered to assembly code.

This patch fixes the problem by checking the target feature
compatibility before we honor Attribute::AlwaysInline.

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

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

17 months agoclang: Update tests after InstSimplify change
Matt Arsenault [Fri, 2 Jun 2023 22:44:18 +0000 (18:44 -0400)]
clang: Update tests after InstSimplify change

Update tests after 1536e299e63d7788f38117b0212ca50eb76d7a3b

17 months ago[ThinLTO] Fix internalization decisions for weak/linkonce ODR
Teresa Johnson [Thu, 1 Jun 2023 18:07:05 +0000 (11:07 -0700)]
[ThinLTO] Fix internalization decisions for weak/linkonce ODR

This fixes a runtime error that occurred due to incorrect
internalization of linkonce_odr functions where function pointer
equality was broken. This was hit because the prevailing copy was in a
native object, so the IR copies were not exported, and the existing code
internalized all of the IR copies. It could be fixed by guarding this
internalization on whether the defs are (local_)unnamed_addr, meaning
that their address is not significant (which we have in the summary
currently for linkonce_odr via the CanAutoHide flag). Or we can
propagate reference attributes as we do when determining whether a
global variable is read or write-only (reference edges are annotated
with whether they are read-only, write-only, or neither, and taking the
address of a function would result in a reference edge to the function
that is not read or write-only).

However, this exposed a larger issue with the internalization handling.
Looking at test cases, it appears the intent is to internalize when
there is a single definition of a linkonce/weak ODR symbol (that isn't
exported). This makes sense in the case of functions, because the
inliner can apply its last call to static heuristic when appropriate. In
the case where there is no prevailing copy in IR, internalizing all of
the IR copies of a linkonce_odr, even if legal, just increases binary
size. In that case it is better to fall back to the normal handling of
converting all non-prevailing copies to available_externally so that
they are eliminated after inlining.

In the case of variables, the existing code was attempting to
internalize the non-exported linkonce/weak ODR variables if they were
read or write-only. While this is legal (we propagate reference
attributes to determine this information), we don't even need to
internalize these here as there is later separate handling that
internalizes read and write-only variables when we process the module at
the start of the ThinLTO backend (processGlobalForThinLTO). Instead, we
can also internalize any non-exported variable when there is only one
(IR) definition, which is prevailing. And in that case, we don't need to
require that it is read or write-only, since we are guaranteed that all
uses must use that single definition.

In the new LTO API, if there are multiple defs of a linkonce or weak ODR
it will be marked exported, but it isn't clear that this will always be
true for the legacy LTO API. Therefore, require that there is only a
single (non-local) def, and that it is prevailing.

The test cases changes are both to reflect the change in the handling of
linkonce_odr IR copies where the prevailing def is not in IR (the main
correctness bug fix here), and to reflect the more aggressive
internalization of variables when there is only a single def, it is in
IR, and not exported.

I've also added some additional testing via the new LTO API.

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

17 months agoProperly restore SP tag on exceptions
Florian Mayer [Fri, 2 Jun 2023 21:11:38 +0000 (14:11 -0700)]
Properly restore SP tag on exceptions

Reviewed By: vitalybuka

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

17 months ago[Damangle] convert dlangDemangle to use std::string_view
Nick Desaulniers [Fri, 2 Jun 2023 22:16:10 +0000 (15:16 -0700)]
[Damangle] convert dlangDemangle to use std::string_view

I was doing this API conversion to use std::string_view top-down in
D149104, but this exposed issues in individual demanglers that needed to
get fixed first. There's no issue with the conversion for the D language
demangler, so convert it.

I have a more aggressive refactoring of the entire D language demangler
to use std::string_view more extensively, but the interface with
llvm::nonMicrosoftDemangle is the more interesting one.

Reviewed By: MaskRay

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

17 months agoInstSimplify: Remove null parent checks
Matt Arsenault [Wed, 24 May 2023 10:42:28 +0000 (11:42 +0100)]
InstSimplify: Remove null parent checks

The feature to operate on incomplete IR was barely used
an poorly tested.

17 months agoInstSimplify: Require instruction be parented
Matt Arsenault [Tue, 23 May 2023 09:28:57 +0000 (10:28 +0100)]
InstSimplify: Require instruction be parented

Unlike every other analysis and transform, simplifyInstruction
permitted operating on instructions which are not inserted
into a function. This created an edge case no other code needs
to really worry about, and limited transforms in cases that
can make use of the context function. Only the inliner and a handful
of other utilities were making use of this, so just fix up these
edge cases. Results in some IR ordering differences since
cloned blocks are inserted eagerly now. Plus some additional
simplifications trigger (e.g. some add 0s now folded out that
previously didn't).

17 months ago[Damangle] convert rustDemangle to use std::string_view
Nick Desaulniers [Fri, 2 Jun 2023 22:08:14 +0000 (15:08 -0700)]
[Damangle] convert rustDemangle to use std::string_view

I was doing this API conversion to use std::string_view top-down in
D149104, but this exposed issues in individual demanglers that needed to
get fixed first. There's no issue with the conversion for the Rust
demangler, so convert it first.

Reviewed By: MaskRay

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

17 months ago[Demangle] convert itaniumDemangle and nonMicrosoftDemangle to use std::string_view
Nick Desaulniers [Fri, 2 Jun 2023 21:53:46 +0000 (14:53 -0700)]
[Demangle] convert itaniumDemangle and nonMicrosoftDemangle to use std::string_view

D149104 converted llvm::demangle to use std::string_view. Enabling
"expensive checks" (via -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON) causes
lld/test/wasm/why-extract.s to fail. The reason for this is obscure:

Reason #10007 why std::string_view is dangerous:
Consider the following pattern:

  std::string_view s = ...;
  const char *c = s.data();
  std::strlen(c);

Is c a NUL-terminated C style string? It depends; but if it's not then
it's not safe to call std::strlen on the std::string_view::data().
std::string_view::length() should be used instead.

Fixing this fixes the one lone test that caught this.

microsoftDemangle, rustDemangle, and dlangDemangle should get this same
treatment, too. I will do that next.

Reviewed By: MaskRay, efriedma

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

17 months ago[mlir][sparse][gpu] make computeType mandatory
Kun Wu [Fri, 2 Jun 2023 18:29:49 +0000 (18:29 +0000)]
[mlir][sparse][gpu] make computeType mandatory

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

17 months ago[flang][hlfir] Added allocatable/pointer support in hlfir::convertToValue.
Slava Zakharin [Fri, 2 Jun 2023 21:20:21 +0000 (14:20 -0700)]
[flang][hlfir] Added allocatable/pointer support in hlfir::convertToValue.

The code is used, for example, when passing arguments to IO or intrinsic
calls as value. The allocatable/pointer boxes must be dereferenced,
and trivial values have to be loaded. Character and derived values
have to stay boxed.
I am not sure what to do for the array cases, and I have not seen
any test triggering it, so I leave it as a TODO.

Reviewed By: tblah, clementval

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

17 months ago[NFC][lsan] Use hash table to track root regions
Vitaly Buka [Wed, 31 May 2023 07:08:02 +0000 (00:08 -0700)]
[NFC][lsan] Use hash table to track root regions

This avoid O(N) in __lsan_unregister_root_region.

Reviewed By: MaskRay

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

17 months ago[NFC][sanitizer] Avoid O(N^2) algorithm
Vitaly Buka [Wed, 31 May 2023 05:58:23 +0000 (22:58 -0700)]
[NFC][sanitizer] Avoid O(N^2) algorithm

Usually root_regions size is small so unlikey
this change will provide a noticable difference.

However it's easy to make sure that even with
large number of root_regions it works reasonably
fast.

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

17 months ago[NFC][sanitizer] Delegate ArrayRef constructors
Vitaly Buka [Fri, 2 Jun 2023 21:25:11 +0000 (14:25 -0700)]
[NFC][sanitizer] Delegate ArrayRef constructors

17 months ago[CUDA] Update Kepler(sm_3*) support info.
Artem Belevich [Fri, 2 Jun 2023 20:30:47 +0000 (13:30 -0700)]
[CUDA] Update Kepler(sm_3*) support info.

sm_30 and sm_32 were removed in cuda-11.0
sm_35 and sm_37 were removed in cuda-12.0

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

17 months agoFully qualify MLIR type in TableGen emitter
Mehdi Amini [Fri, 2 Jun 2023 21:07:56 +0000 (14:07 -0700)]
Fully qualify MLIR type in TableGen emitter

This is important for users that don't enclose their dialect within the MLIR
namespace.

17 months ago[libc] Disable the string_to_float test on NVPTX
Joseph Huber [Fri, 2 Jun 2023 20:56:00 +0000 (15:56 -0500)]
[libc] Disable the string_to_float test on NVPTX

This test began failing after recent changes. Disable it for now.

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

17 months ago[sanitizer] Calculate Range sets intersection
Vitaly Buka [Wed, 31 May 2023 05:47:33 +0000 (22:47 -0700)]
[sanitizer] Calculate Range sets intersection

Will be used to handle Root Regions in LSAN D151781.

Reviewed By: MaskRay

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

17 months ago[TableGen] Allow bit fields in SearchableTables.
Stanislav Mekhanoshin [Tue, 30 May 2023 21:41:29 +0000 (14:41 -0700)]
[TableGen] Allow bit fields in SearchableTables.

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

17 months ago[NFC][CLANG] Fix Static Code Analyzer Concerns with dereference null return value...
Manna, Soumi [Fri, 2 Jun 2023 20:34:32 +0000 (13:34 -0700)]
[NFC][CLANG] Fix Static Code Analyzer Concerns with dereference null return value in applyObjCTypeArgs()

This patch uses castAs instead of getAs to resolve dereference issue with nullptr boundObjC when calling
canAssignObjCInterfaces() or isObjCIdType() in applyObjCTypeArgs() since getAs returns nullptr.

Reviewed By: erichkeane

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

17 months ago[NFC][CLANG] Fix bug with dereference null return value in GetFunctionTypeForVTable()
Manna, Soumi [Fri, 2 Jun 2023 20:23:51 +0000 (13:23 -0700)]
[NFC][CLANG] Fix bug with dereference null return value in GetFunctionTypeForVTable()

This patch uses castAs instead of getAs which will assert if the type doesn't match in clang::CodeGen::CodeGenTypes::GetFunctionTypeForVTable(clang::GlobalDecl).

Reviewed By: erichkeane

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