platform/upstream/llvm.git
2 years ago[NFC][IndVars] Add test that caused D108043 to be reverted
Roman Lebedev [Mon, 30 Aug 2021 09:00:08 +0000 (12:00 +0300)]
[NFC][IndVars] Add test that caused D108043 to be reverted

We currently don't simplify anything here, but we can.

2 years ago[lldb] [gdb-remote client] Support minimal fork/vfork handling
Michał Górny [Fri, 9 Apr 2021 14:18:50 +0000 (16:18 +0200)]
[lldb] [gdb-remote client] Support minimal fork/vfork handling

Add a support for handling fork/vfork stops in LLGS client.  At this
point, it only sends a detach packet for the newly forked child
(and implicitly resumes the parent).

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

2 years ago[DebugInfo] Emit DW_TAG_namelist and DW_TAG_namelist_item
“bhkumarn” [Mon, 23 Aug 2021 12:43:11 +0000 (18:13 +0530)]
[DebugInfo] Emit DW_TAG_namelist and DW_TAG_namelist_item

This patch emits DW_TAG_namelist and DW_TAG_namelist_item for fortran
namelist variables. DICompositeType is extended to support this fortran
feature.

Reviewed By: aprantl

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

2 years ago[flang] Add runtime interface for GET_COMMAND_ARGUMENT
Diana Picus [Wed, 25 Aug 2021 05:57:25 +0000 (05:57 +0000)]
[flang] Add runtime interface for GET_COMMAND_ARGUMENT

GET_COMMAND_ARGUMENT takes a lot of optional arguments: VALUE, LENGTH,
STATUS and ERRMSG. This patch breaks up the interface into 2 different
functions:

* One for getting the LENGTH of an argument.

* One for getting the VALUE and the ERRMSG of an argument. This returns
the STATUS, which can be easily ignored by lowering if it is missing in
the invocation.

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

2 years ago[flang] Add runtime interface for COMMAND_ARGUMENT_COUNT
Diana Picus [Wed, 25 Aug 2021 03:16:30 +0000 (03:16 +0000)]
[flang] Add runtime interface for COMMAND_ARGUMENT_COUNT

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

2 years ago[VPlan] Introduce code to limit querying VPValues using IR references.
Florian Hahn [Mon, 30 Aug 2021 06:50:17 +0000 (08:50 +0200)]
[VPlan] Introduce code to limit querying VPValues using IR references.

After applying VPlan-to-VPlan transformations, using IR references to
query VPlan values may be incorrect, as the IR is not in sync with the
VPlan any longer.

To better detect such mis-matches, this patch introduces a new flag to
VPlans to indicate whether it is safe to query VPValues using IR values.

getVPValue is updated to assert if it is called when the flag indicates
it is not safe any longer.

There is an escape hatch via an extra argument, because there are 3
places that need to be fixed first. Those are

1. truncateToMinimalBitwidths
2. clearReductionWrapFlags
3. fixLCSSAPHIs

As a first step, this flag will help preventing new code from violating
this property.

Any suggestions with respect to naming very welcome!

Reviewed By: Ayal

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

2 years ago[docs] Add a new tutorial that talk about how to make a change to llvm
Shivam Gupta [Mon, 30 Aug 2021 06:55:29 +0000 (06:55 +0000)]
[docs] Add a new tutorial that talk about how to make a change to llvm

This tutorial will guide you through the process of making a change to LLVM, and contributing it back to the LLVM project.
We'll be making a change to Clang, but the steps for other parts of LLVM are the same. Even though the change we'll be making is simple,
we're going to cover steps like building LLVM, running the tests, and code review. This is good practice, and you'll be prepared for making larger changes.

Authors: @meikeb , @gribozavr
Commit: Zhiqian Xia

PS - This is a duplicate revision of https://reviews.llvm.org/D100714 which was actually used for patch review.

Reviewed By: kuhnel

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

2 years ago[flang] Apply double precision KindCode in specific proc interface
Jean Perier [Mon, 30 Aug 2021 06:58:53 +0000 (08:58 +0200)]
[flang] Apply double precision KindCode in specific proc interface

The double precision KindCode was ignored when building the interface
of specific intrinsic procedures leading to bad semantics checks.

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

2 years ago[X86] AVX512FP16 instructions enabling 6/6
Wang, Pengfei [Mon, 30 Aug 2021 04:07:18 +0000 (12:07 +0800)]
[X86] AVX512FP16 instructions enabling 6/6

Enable FP16 complex FMA instructions.

Ref.: https://software.intel.com/content/www/us/en/develop/download/intel-avx512-fp16-architecture-specification.html

Reviewed By: LuoYuanke

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

2 years ago[SymbolRefAttr] Revise SymbolRefAttr to hold a StringAttr.
Chris Lattner [Sun, 29 Aug 2021 21:22:24 +0000 (14:22 -0700)]
[SymbolRefAttr] Revise SymbolRefAttr to hold a StringAttr.

SymbolRefAttr is fundamentally a base string plus a sequence
of nested references.  Instead of storing the string data as
a copies StringRef, store it as an already-uniqued StringAttr.

This makes a lot of things simpler and more efficient because:
1) references to the symbol are already stored as StringAttr's:
   there is no need to copy the string data into MLIRContext
   multiple times.
2) This allows pointer comparisons instead of string
   comparisons (or redundant uniquing) within SymbolTable.cpp.
3) This allows SymbolTable to hold a DenseMap instead of a
   StringMap (which again copies the string data and slows
   lookup).

This is a moderately invasive patch, so I kept a lot of
compatibility APIs around.  It would be nice to explore changing
getName() to return a StringAttr for example (right now you have
to use getNameAttr()), and eliminate things like the StringRef
version of getSymbol.

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

2 years ago[libc] Ensure the result of the clone syscall is not on stack in thrd_create.
Siva Chandra Reddy [Mon, 30 Aug 2021 04:31:30 +0000 (04:31 +0000)]
[libc] Ensure the result of the clone syscall is not on stack in thrd_create.

Also, added a call to munmap on error in thrd_create.

2 years ago[PowerPC] Set branch/call instructions as no hasSideEffects
Qiu Chaofan [Mon, 30 Aug 2021 04:18:57 +0000 (12:18 +0800)]
[PowerPC] Set branch/call instructions as no hasSideEffects

PowerPC can model these instructions, so we don't need this flag set.

Reviewed By: shchenz, jsji

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

2 years ago[libc][NFC] Add a check to catch mismatch in internal and public mutex types.
Siva Chandra Reddy [Mon, 30 Aug 2021 04:08:35 +0000 (04:08 +0000)]
[libc][NFC] Add a check to catch mismatch in internal and public mutex types.

2 years ago[X86] Support __SSC_MARK(const int id)
Xiang1 Zhang [Mon, 30 Aug 2021 01:55:19 +0000 (09:55 +0800)]
[X86] Support __SSC_MARK(const int id)

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

2 years agoRevert "[X86] Support __SSC_MARK(const int id)"
Xiang1 Zhang [Mon, 30 Aug 2021 01:50:00 +0000 (09:50 +0800)]
Revert "[X86] Support __SSC_MARK(const int id)"

This reverts commit 78fbde57794e50f5629979f5d69592caf64067e3.

2 years ago[mlir][SCF] Canonicalize dim(x) where x is an iter_arg
Matthias Springer [Mon, 30 Aug 2021 01:12:14 +0000 (01:12 +0000)]
[mlir][SCF] Canonicalize dim(x) where x is an iter_arg

* Add `DimOfIterArgFolder`.
* Move existing cross-dialect canonicalization patterns to `LoopCanonicalization.cpp`.
* Rename `SCFAffineOpCanonicalization` pass to `SCFForLoopCanonicalization`.
* Expand documentaton of scf.for: The type of loop-carried variables may not change with iterations. (Not even the dynamic type.)

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

2 years ago[AIX] "aligned" attribute does not decrease alignment
Steven Wan [Mon, 30 Aug 2021 01:32:54 +0000 (21:32 -0400)]
[AIX] "aligned" attribute does not decrease alignment

The "aligned" attribute can only increase the alignment of a struct, or struct member, unless it's used together with the "packed" attribute, or used as a part of a typedef, in which case, the "aligned" attribute can both increase and decrease alignment.

That said, we expect:
1. "aligned" attribute alone: does not interfere with the alignment upgrade instrumented by the AIX "power" alignment rule,
2. "aligned" attribute + typedef: overrides any computed alignment,
3. "aligned" attribute + "packed" attribute: overrides any computed alignment.
The old implementation achieved 2 and 3, but didn't get 1 right, in that any field marked attribute "aligned" would not go through the alignment upgrade.

Reviewed By: rjmccall

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

2 years ago[X86] Support __SSC_MARK(const int id)
Xiang1 Zhang [Mon, 30 Aug 2021 01:21:14 +0000 (09:21 +0800)]
[X86] Support __SSC_MARK(const int id)

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

2 years agoRevert "[X86] Support __SSC_MARK(const int id)"
Xiang1 Zhang [Mon, 30 Aug 2021 01:17:42 +0000 (09:17 +0800)]
Revert "[X86] Support __SSC_MARK(const int id)"

This reverts commit 83e82ff767530158fd5590ffea617f50a07534b5.

2 years ago[mlir][Analysis] Add batched version of FlatAffineConstraints::addId
Matthias Springer [Mon, 30 Aug 2021 00:31:07 +0000 (00:31 +0000)]
[mlir][Analysis] Add batched version of FlatAffineConstraints::addId

* Add batched version of all `addId` variants, so that multiple IDs can be added at a time.
* Rename `addId` and variants to `insertId` and `appendId`. Most external users call `appendId`. Splitting `addId` into two functions also makes it possible to provide batched version for both. (Otherwise, the overloads are ambigious when calling `addId`.)

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

2 years ago[X86] Support __SSC_MARK(const int id)
Xiang1 Zhang [Wed, 25 Aug 2021 01:55:54 +0000 (09:55 +0800)]
[X86] Support __SSC_MARK(const int id)

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

2 years ago[InstCombine] Remove invariant group intrinsincs when comparing against null
Arthur Eubanks [Wed, 25 Aug 2021 18:31:22 +0000 (11:31 -0700)]
[InstCombine] Remove invariant group intrinsincs when comparing against null

We cannot leak any equivalency information by comparing against null
since null never has virtual metadata associated with it (when null is
not a valid dereferenceable pointer).

Instcombine seems to make sure that a null will be on the RHS, so we
don't have to check both operands.

This fixes a missed optimization in llvm-test-suite's MultiSource lambda
benchmark under -fstrict-vtable-pointers.

Reviewed By: Prazek

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

2 years ago[clang-format] Add PackConstructorInitializers backward compat test
owenca [Sat, 28 Aug 2021 22:21:23 +0000 (15:21 -0700)]
[clang-format] Add PackConstructorInitializers backward compat test

Add backward compatibility tests for mapping the deprecated
ConstructorInitializerAllOnOneLineOrOnePerLine and
AllowAllConstructorInitializersOnNextLine to
PackConstructorInitializers.

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

2 years ago[ELF] Simplify addGotEntry. NFC
Fangrui Song [Sun, 29 Aug 2021 20:40:08 +0000 (13:40 -0700)]
[ELF] Simplify addGotEntry. NFC

2 years ago[ELF] Untangle TLS IE and regular GOT from addGotEntry for non-mips. NFC
Fangrui Song [Sun, 29 Aug 2021 20:21:06 +0000 (13:21 -0700)]
[ELF] Untangle TLS IE and regular GOT from addGotEntry for non-mips. NFC

2 years ago[ELF] Move handleTlsRelocations. NFC
Fangrui Song [Sun, 29 Aug 2021 20:11:35 +0000 (13:11 -0700)]
[ELF] Move handleTlsRelocations. NFC

Prepare for addGotEntry simplification.

2 years ago[SCEVExpander] Reuse removePointerBase() for canonical addrecs
Nikita Popov [Sun, 29 Aug 2021 19:07:13 +0000 (21:07 +0200)]
[SCEVExpander] Reuse removePointerBase() for canonical addrecs

ExposePointerBase() in SCEVExpander implements basically the same
functionality as removePointerBase() in SCEV, so reuse it.

The SCEVExpander code assumes that the pointer operand on adds is
the last one -- I'm not sure that always holds. As such this might
not be strictly NFC.

2 years ago[ELF] Remove unused processRelocAux argument. NFC
Fangrui Song [Sun, 29 Aug 2021 19:07:56 +0000 (12:07 -0700)]
[ELF] Remove unused processRelocAux argument. NFC

2 years ago[SCEVExpander] Remove unnecessary mul/udiv check (NFC)
Nikita Popov [Sun, 29 Aug 2021 18:46:24 +0000 (20:46 +0200)]
[SCEVExpander] Remove unnecessary mul/udiv check (NFC)

Pointer-typed SCEV expressions can no longer be mul or udiv, so
we do not need to specially handle them here.

2 years ago[SCEVExpander] Assert single pointer op in add (NFC)
Nikita Popov [Sun, 29 Aug 2021 18:29:04 +0000 (20:29 +0200)]
[SCEVExpander] Assert single pointer op in add (NFC)

There can only be one pointer operand in an add expression, and
we have sorted operands to guarantee that it is the first. As
such, the pointer check for other operands is dead code.

2 years ago[SCEV] Assert unique pointer base (NFC)
Nikita Popov [Sun, 29 Aug 2021 17:58:56 +0000 (19:58 +0200)]
[SCEV] Assert unique pointer base (NFC)

Add expressions can contain at most one pointer operand nowadays,
assert that in getPointerBase() and removePointerBase().

2 years ago[X86] Remove X86LowerAMXType::getRowFromCol from X86LowerAMXType.cpp
Vince Bridgers [Fri, 27 Aug 2021 22:57:44 +0000 (17:57 -0500)]
[X86] Remove X86LowerAMXType::getRowFromCol from X86LowerAMXType.cpp

Remove method X86LowerAMXType::getRowFromCol since it's not used, and
it's causing a warning.

Reviewed By: LuoYuanke

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

2 years ago[Support] Remove redundant calls to str() and c_str() (NFC)
Kazu Hirata [Sun, 29 Aug 2021 16:14:47 +0000 (09:14 -0700)]
[Support] Remove redundant calls to str() and c_str() (NFC)

Identified with readability-redundant-string-cstr.

2 years ago[mlir][spirv] Use type dyn_cast when scanning spv.GlobalVariable
Lei Zhang [Sun, 29 Aug 2021 16:01:19 +0000 (12:01 -0400)]
[mlir][spirv] Use type dyn_cast when scanning spv.GlobalVariable

This avoids crashes when there are spv.GlobalVariable without
pointer type.

2 years agotest-release.sh: remove an unused reference to the old svn repo
Sylvestre Ledru [Sun, 29 Aug 2021 15:44:58 +0000 (17:44 +0200)]
test-release.sh: remove an unused reference to the old svn repo

2 years ago[lldb] Allow to register frame recognizers applied beyond the first instruction
Roman Podoliaka [Sun, 29 Aug 2021 15:26:15 +0000 (17:26 +0200)]
[lldb] Allow to register frame recognizers applied beyond the first instruction

It is currently possible to register a frame recognizer, but it will be applied if and only if the frame's PC points to the very first instruction of the specified function, which limits usability of this feature.

The implementation already supports changing this behaviour by passing an additional flag, but it's not possible to set it via the command interface. Fix that.

Reviewed By: jingham

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

2 years ago[NewPM] Add missing LTO ArgPromotion pass
Nikita Popov [Sat, 28 Aug 2021 10:25:58 +0000 (12:25 +0200)]
[NewPM] Add missing LTO ArgPromotion pass

This is a followup to D96780 to add one more pass missing from the
NewPM LTO pipeline. The missing ArgPromotion run is inserted at
the same position as in the LegacyPM, resolving the already
present FIXME:
https://github.com/llvm/llvm-project/blob/16086d47c0d0cd08ffae8e69a69c88653e654d01/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp#L1096-L1098

The compile-time impact is minimal with ~0.1% geomean regression
on CTMark.

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

2 years ago[BPF] support btf_tag attribute in .BTF section
Yonghong Song [Tue, 20 Jul 2021 17:59:19 +0000 (10:59 -0700)]
[BPF] support btf_tag attribute in .BTF section

A new kind BTF_KIND_TAG is added to .BTF to encode
btf_tag attributes. The format looks like
   CommonType.name : attribute string
   CommonType.type : attached to a struct/union/func/var.
   CommonType.info : encoding BTF_KIND_TAG
                     kflag == 1 to indicate the attribute is
                     for CommonType.type, or kflag == 0
                     for struct/union member or func argument.
   one uint32_t    : to encode which member/argument starting from 0.

If one particular type or member/argument has more than one attribute,
multiple BTF_KIND_TAG will be generated.

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

2 years ago[Polly][test] Add dependency to count.
Michael Kruse [Sun, 29 Aug 2021 03:50:07 +0000 (22:50 -0500)]
[Polly][test] Add dependency to count.

Polly does not use the count program itself, but somewhere in lit it is
expected to exists. Otherwise, the following error occurs:

    llvm-lit: llvm-project/llvm/utils/lit/lit/llvm/subst.py:133: fatal: Did not find count in ./bin

2 years ago[Polly] Fix dumpfunction.ll test.
Michael Kruse [Sun, 29 Aug 2021 03:38:52 +0000 (22:38 -0500)]
[Polly] Fix dumpfunction.ll test.

2 years agoTypeInfo records more information about align requirement
Steven Wan [Sat, 28 Aug 2021 23:47:31 +0000 (19:47 -0400)]
TypeInfo records more information about align requirement

Extend the information preserved in `TypeInfo` by replacing the `AlignIsRequired` bool flag with a three-valued enum, the enum also indicates where the alignment attribute come from, which could be helpful in determining whether the attribute should overrule.

Reviewed By: rjmccall

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

2 years ago[OpenMP][NVPTX] Fixed missing variables for CUDA free compilation in NVPTX plugin
Shilei Tian [Sat, 28 Aug 2021 22:08:03 +0000 (18:08 -0400)]
[OpenMP][NVPTX] Fixed missing variables for CUDA free compilation in NVPTX plugin

`CU_EVENT_DEFAULT` is defined in CUDA header. It should be added to
`openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.h` for CUDA free build.

Reviewed By: ronlieb

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

2 years ago[Polly] Don't prune non-external function itself from dump.
Michael Kruse [Sat, 28 Aug 2021 21:48:28 +0000 (16:48 -0500)]
[Polly] Don't prune non-external function itself from dump.

2 years ago[Sanitizers] PGO implements enable/disable SIGKILL on callers on FreeBSD.
David Carlier [Sat, 28 Aug 2021 21:53:16 +0000 (22:53 +0100)]
[Sanitizers] PGO implements enable/disable SIGKILL on callers on FreeBSD.

Reviewed By: phosek

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

2 years ago[Linker] Replace comdat based bool LinkFromSrc with enum class LinkFrom and improve...
Fangrui Song [Sat, 28 Aug 2021 20:56:31 +0000 (13:56 -0700)]
[Linker] Replace comdat based bool LinkFromSrc with enum class LinkFrom and improve nodeduplicate tests. NFC

This is different from symbol resolution based LinkFromSrc.  Rename to be
clearer.

In the future we may support a new enum member 'Both' for nodeduplicate. This is
feasible (by renaming to a private linkage GlobalValue), but we need to be
careful not to break InstrProfiling.cpp's expectation of parallel profd/profc.

The challenge is that current LTO symbol resolution only allows to mark one
profc as prevailing: the other profc in another comdat nodeduplicate may be
discarded while its associated profd isn't.

2 years ago[llc] Initialize context for parsing options
Nikita Popov [Sat, 28 Aug 2021 20:36:37 +0000 (22:36 +0200)]
[llc] Initialize context for parsing options

This will allow using -force-opaque-pointers in codegen tests.

2 years ago[OpenMP][Offloading] Add support for event related interfaces
Shilei Tian [Sat, 28 Aug 2021 20:24:06 +0000 (16:24 -0400)]
[OpenMP][Offloading] Add support for event related interfaces

This patch adds the support form event related interfaces, which will be used
later to fix data race. See D104418 for more details.

Reviewed By: jdoerfert, ye-luo

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

2 years ago[test] Reorganize test/Linker/comdat*.ll
Fangrui Song [Sat, 28 Aug 2021 17:11:08 +0000 (10:11 -0700)]
[test] Reorganize test/Linker/comdat*.ll

2 years ago[mlir] add missing include, fix broken build
Aart Bik [Sat, 28 Aug 2021 16:22:15 +0000 (09:22 -0700)]
[mlir] add missing include, fix broken build

Reviewed By: mehdi_amini

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

2 years ago[libomptarget][NFC] Fixed tests which checked for obsolete string "getOrAllocTgtPtr"
George Rokos [Sat, 28 Aug 2021 14:35:42 +0000 (07:35 -0700)]
[libomptarget][NFC] Fixed tests which checked for obsolete string "getOrAllocTgtPtr"

2 years ago[mlir][NFC] Fully qualify default value of Attributes `getStorageType()` in files...
Markus Böck [Sat, 28 Aug 2021 13:34:34 +0000 (15:34 +0200)]
[mlir][NFC] Fully qualify default value of Attributes `getStorageType()` in files generated by mlir-tblgen

2 years ago[llvm] Fix typos in documentation (NFC)
Kazu Hirata [Sat, 28 Aug 2021 13:37:03 +0000 (06:37 -0700)]
[llvm] Fix typos in documentation (NFC)

2 years ago[Analysis] Fix a "set but not used" warning
Kazu Hirata [Sat, 28 Aug 2021 13:37:01 +0000 (06:37 -0700)]
[Analysis] Fix a "set but not used" warning

2 years ago[WebAssembly] Fix FastISel of condition in different block (PR51651)
Nikita Popov [Fri, 27 Aug 2021 20:18:07 +0000 (22:18 +0200)]
[WebAssembly] Fix FastISel of condition in different block (PR51651)

If the icmp is in a different block, then the register for the icmp
operand may not be initialized, as it nominally does not have
cross-block uses. Add a check that the icmp is in the same block
as the branch, which should be the common case.

This matches what X86 FastISel does:
https://github.com/llvm/llvm-project/blob/5b6b090cf2129228f05d7d0f504676b67f7524cf/llvm/lib/Target/X86/X86FastISel.cpp#L1648

The "not" transform that could have a similar issue is dropped
entirely, because it is currently dead: The incoming value is
a branch or select condition of type i1, but this code requires
an i32 to trigger.

Fixes https://bugs.llvm.org/show_bug.cgi?id=51651.

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

2 years ago[MLIR][GPU] Drop mgpuMemHostRegisterMemRef's dependence on LLVM Support
Uday Bondhugula [Fri, 20 Aug 2021 11:46:25 +0000 (17:16 +0530)]
[MLIR][GPU] Drop mgpuMemHostRegisterMemRef's dependence on LLVM Support

Drop mgpuMemHostRegisterMemRef's dependence on LLVM Support. This
method is the only one in CUDA runtime wrappers library that creates
a dependence on libLLVMSupport due to its use of SmallVector and
ArrayRef. The code can be as easily/compactly written without those ADT.
The dependence on LLVMSupport adds a significant amount of additional
complexity for external things that want to link this library in (both
statically or as a shared object) since libLLVMSupport includes numerous
other objects that are sensitive to C++ compiler version and ABI.

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

2 years ago[JITLink][RISCV] Support GOT/PLT relocations
luxufan [Fri, 27 Aug 2021 14:17:06 +0000 (22:17 +0800)]
[JITLink][RISCV] Support GOT/PLT relocations

This patch add the R_RISCV_GOT_HI20 and R_RISCV_CALL_PLT relocation support. And the basic got/plt was implemented. Because of riscv32 and riscv64 has different pointer size, the got entry size and instructions of plt entry is different. This patch is the basic support, the optimization pass at preFixup stage has not been implemented.

Reviewed By: lhames

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

2 years ago[lld/mac] Don't assert on -dead_strip + arm64 range extension thunks
Nico Weber [Fri, 27 Aug 2021 23:20:29 +0000 (19:20 -0400)]
[lld/mac] Don't assert on -dead_strip + arm64 range extension thunks

The assert is harmless and thinks worked fine in builds with asserts enabled,
but it's still nice to fix the assert.

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

2 years ago[Modules] Change result of reading AST block to llvm::Error instead
Ben Barham [Sat, 28 Aug 2021 02:38:46 +0000 (19:38 -0700)]
[Modules] Change result of reading AST block to llvm::Error instead

Reading the AST block can never fail with a recoverable error as modules
cannot be removed during this phase. Change the return type of these
functions to return an llvm::Error instead, ie. either success or
failure.

NFC other than the wording of some of the errors.

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

2 years agoRemove `const` from `const T &&` in debugString() helper to make it a universal refer...
Mehdi Amini [Sat, 28 Aug 2021 01:09:00 +0000 (01:09 +0000)]
Remove `const` from `const T &&` in debugString() helper to make it a universal reference (NFC)

It broke lvalue arguments otherwise:

2 years agoUse a universal reference (&& instead of const &) for `debugString()` helper (NFC)
Mehdi Amini [Sat, 28 Aug 2021 00:40:28 +0000 (00:40 +0000)]
Use a universal reference (&& instead of const &) for `debugString()` helper (NFC)

Some classes like mlir::Operation have a non-const print() method.

2 years agoTypePrinter:printTo remove redundant parameter (IsPack/SkipBrackets)
David Blaikie [Sat, 28 Aug 2021 00:12:42 +0000 (17:12 -0700)]
TypePrinter:printTo remove redundant parameter (IsPack/SkipBrackets)

2 years agoSpecify argument to be `const` for `debugString()` helper (NFC)
Mehdi Amini [Sat, 28 Aug 2021 00:09:27 +0000 (00:09 +0000)]
Specify argument to be `const` for `debugString()` helper (NFC)

This allows using this helper with rvalues.

2 years ago[Sanitizers] wordexp interceptor build fix on FreeBSD.
David Carlier [Fri, 27 Aug 2021 22:58:06 +0000 (23:58 +0100)]
[Sanitizers] wordexp interceptor build fix on FreeBSD.

Reviewers: vitalybuka

Reviewed-By: vitalybuka
Differential Revision: https://reviews.llvm.org/D108838

2 years ago[compiler-rt][obvious] fix typo, delete paren
Michael Jones [Fri, 27 Aug 2021 22:54:02 +0000 (22:54 +0000)]
[compiler-rt][obvious] fix typo, delete paren

I should've deleted a parenthesis on line 4222 in
https://reviews.llvm.org/D108843 and this patch fixes it.

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

2 years ago[compiler-rt] fix real strlens that were missed
Michael Jones [Fri, 27 Aug 2021 20:54:44 +0000 (20:54 +0000)]
[compiler-rt] fix real strlens that were missed

In reviews.llvm.org/D108316 I missed a few instances of REAL(strlen) and
this change fixes that, as well as restoring one that seems like it
shouldn't have been changed.

Reviewed By: hctim, vitalybuka

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

2 years ago[MipsISelLowering] avoid emitting libcalls to __mulodi4()
Nick Desaulniers [Fri, 27 Aug 2021 22:15:32 +0000 (15:15 -0700)]
[MipsISelLowering] avoid emitting libcalls to __mulodi4()

__has_builtin(__builtin_mul_overflow) returns true for 32b MIPS targets,
but Clang is deferring to compiler RT when encountering `long long`
types. This breaks sanitizer builds of the Linux kernel that are using
__builtin_mul_overflow with these types for these targets.

If the semantics of __has_builtin mean "the compiler resolves these,
always" then we shouldn't conditionally emit a libcall.

This will still need to be worked around in the Linux kernel in order to
continue to support malta_defconfig builds of the Linux kernel for this
target with older releases of clang.

Link: https://bugs.llvm.org/show_bug.cgi?id=28629
Link: https://github.com/ClangBuiltLinux/linux/issues/1438
Reviewed By: rengolin

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

2 years ago[ARMISelLowering] avoid emitting libcalls to __mulodi4()
Nick Desaulniers [Fri, 27 Aug 2021 22:06:08 +0000 (15:06 -0700)]
[ARMISelLowering] avoid emitting libcalls to __mulodi4()

__has_builtin(__builtin_mul_overflow) returns true for 32b ARM targets,
but Clang is deferring to compiler RT when encountering `long long`
types. This breaks sanitizer builds of the Linux kernel that are using
__builtin_mul_overflow with these types for these targets.

If the semantics of __has_builtin mean "the compiler resolves these,
always" then we shouldn't conditionally emit a libcall.

This will still need to be worked around in the Linux kernel in order to
continue to support allmodconfig builds of the Linux kernel for this
target with older releases of clang.

Link: https://bugs.llvm.org/show_bug.cgi?id=28629
Link: https://github.com/ClangBuiltLinux/linux/issues/1438
Reviewed By: rengolin

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

2 years ago[mlir][sparse] fully implement sparse tensor to sparse tensor conversions
Aart Bik [Thu, 26 Aug 2021 05:23:46 +0000 (22:23 -0700)]
[mlir][sparse] fully implement sparse tensor to sparse tensor conversions

with rigorous integration test

Reviewed By: bixia

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

2 years ago[IRSim][IROutliner] Canonicalizing commutative value numbering between similarity...
Andrew Litteken [Fri, 27 Aug 2021 21:01:43 +0000 (14:01 -0700)]
[IRSim][IROutliner] Canonicalizing commutative value numbering between similarity sections.

When the initial relationship between two pairs of values between
similar sections is ambiguous to commutativity, arguments to the
outlined functions can be passed in such that the order is incorrect,
causing miscompilations.  This adds a canonical mapping to each
similarity section, so that we can maintain the relationship of global
value numbering from one section to another.

Added Tests:
Transforms/IROutliner/outlining-commutative-operands-opposite-order.ll
unittests/Analysis/IRSimilarityIdentifierTest.cpp - IRSimilarityCandidate:CanonicalNumbering

Reviewers: jroelofs, jpaquette, yroux

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

2 years ago[clang-format] Fix AllowAllConstructorInitializersOnNextLine value
owenca [Fri, 27 Aug 2021 21:32:30 +0000 (14:32 -0700)]
[clang-format] Fix AllowAllConstructorInitializersOnNextLine value

The default value of the now deprecated
AllowAllConstructorInitializersOnNextLine was always true
regardless of the value of BasedOnStyle. This patch fixes the typo
in the code that handles the related backward compatibility.

2 years ago[Attributor][NFC] Silence unused variable warning
Johannes Doerfert [Fri, 27 Aug 2021 21:37:51 +0000 (16:37 -0500)]
[Attributor][NFC] Silence unused variable warning

2 years ago[MergeICmps] Ignore clobbering instructions before the loads
Nikita Popov [Thu, 26 Aug 2021 19:23:58 +0000 (21:23 +0200)]
[MergeICmps] Ignore clobbering instructions before the loads

This is another followup to D106591. Even if there is an
instruction that clobbers one of the loads, this doesn't matter if
it happens before the loads. Those instructions aren't affected by
the transform at all.

The gep-references-bb.ll is modified to preserve the spirit of the
test, as the store to @g no longer impacts the transform.

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

2 years ago[clang-format] [NFC] Fix the coding style of unit tests header file
owenca [Fri, 27 Aug 2021 21:12:01 +0000 (14:12 -0700)]
[clang-format] [NFC] Fix the coding style of unit tests header file

2 years ago[LoopDeletion] Use max trip count to break backedge in addition to exact one
Philip Reames [Fri, 27 Aug 2021 21:18:38 +0000 (14:18 -0700)]
[LoopDeletion] Use max trip count to break backedge in addition to exact one

We'd added support a while back from breaking the backedge if SCEV can prove the trip count is zero. However, we used the exact trip count which requires *all* exits be analyzeable. I noticed while writing test cases for another patch that this disallows cases where one exit is provably taken paired with another which is unknown. This patch adds the upper bound case.

We could use a symbolic max trip count here instead, but we use an isKnownNonZero filter (presumably for compile time?) for the first-iteration reasoning. I decided this was a more obvious incremental step, and we could go back and untangle the schemes separately.

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

2 years ago[lld/test/ELF] Test fetch from archive to resolve undefined symbols in shared libs
Pirama Arumuga Nainar [Wed, 18 Aug 2021 20:52:14 +0000 (13:52 -0700)]
[lld/test/ELF] Test fetch from archive to resolve undefined symbols in shared libs

Add missing test coverage uncovered in review of D108006.

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

2 years ago[libc][NFC] Fix onre more -Wconversion warning in strtoul test code.
Roland McGrath [Fri, 27 Aug 2021 21:11:31 +0000 (14:11 -0700)]
[libc][NFC] Fix onre more -Wconversion warning in strtoul test code.

The last change missed one spot.

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

2 years ago[libc] Fix various -Wconversion warnings in strto*l test code.
Roland McGrath [Fri, 27 Aug 2021 18:04:19 +0000 (11:04 -0700)]
[libc] Fix various -Wconversion warnings in strto*l test code.

The Fuchsia build compiles the libc and test code with lots
of warnings enabled, including all the integer conversion warnings.
There was some sloppy type usage here that triggered some of those.

Reviewed By: michaelrj

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

2 years agoSupport LLVM_ENABLE_PER_TARGET_RUNTIME_DIR in the sanitizer symbolizer build.
Evgenii Stepanov [Fri, 27 Aug 2021 20:36:38 +0000 (13:36 -0700)]
Support LLVM_ENABLE_PER_TARGET_RUNTIME_DIR in the sanitizer symbolizer build.

In this mode libc++ headers end up in two directories:
* include/<triple>/c++/v1 for the site config header
* include/c++/v1 for everything else

Also switch from -I to -isystem.

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

2 years ago[test] Precommit test for D108837
Arthur Eubanks [Fri, 27 Aug 2021 20:39:43 +0000 (13:39 -0700)]
[test] Precommit test for D108837

2 years ago[MergeICmps] Don't merge icmps derived from pointers with addressspaces
Valentin Churavy [Fri, 27 Aug 2021 15:20:14 +0000 (17:20 +0200)]
[MergeICmps] Don't merge icmps derived from pointers with addressspaces

IIUC we can't emit `memcmp` between pointers in addressspaces,
doing so will trigger an assertion since the signature of the memcmp
will not match it's arguments (https://bugs.llvm.org/show_bug.cgi?id=48661).

This PR disables the attempt to merge icmps,
when the pointer is in an addressspace.

Reviewed By: #julialang, vtjnash

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

2 years ago[Profile] Support __llvm_profile_set_file_object in continuous mode.
Zequan Wu [Tue, 17 Aug 2021 21:18:52 +0000 (14:18 -0700)]
[Profile] Support __llvm_profile_set_file_object in continuous mode.

Replace D107203, because __llvm_profile_set_file_object is usually used when the
process doesn't have permission to open/create file. That patch trying to copy
from old profile to new profile contradicts with the usage.

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

2 years agoUse std::less instead of operator < in less_first and less_second
Akira Hatanaka [Wed, 25 Aug 2021 20:11:19 +0000 (13:11 -0700)]
Use std::less instead of operator < in less_first and less_second

According to the standard, if p1 and p2 are both pointers, p1 < p2 and
p2 < p1 can both be false in theory in some cases:

https://eel.is/c++draft/expr.rel#4.3

std::less<void> yields a implementation-defined strict total order over
pointers:

https://eel.is/c++draft/comparisons.general

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

2 years ago[RISCV] Use ~0ULL instead of ~0U when checking for invalid ErrorInfo.
Craig Topper [Fri, 27 Aug 2021 19:30:31 +0000 (12:30 -0700)]
[RISCV] Use ~0ULL instead of ~0U when checking for invalid ErrorInfo.

ErrorInfo is a uint64_t and is initialized to all 1s.

Not sure how to test this. Noticed while working on .insn support.

2 years ago[llvm] [lit] Support forcing lexical test order
Michał Górny [Sat, 7 Aug 2021 14:40:09 +0000 (16:40 +0200)]
[llvm] [lit] Support forcing lexical test order

Add a new --order option to choose between available test orders:
the default "smart" order, predictable "lexical" order or "random"
order.  Default to using lexical order and one job in the lit test
suite.

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

2 years ago[test] More test precommits for D108734
Arthur Eubanks [Fri, 27 Aug 2021 18:16:47 +0000 (11:16 -0700)]
[test] More test precommits for D108734

2 years ago[ifs] Add option to hide undefined symbols
Haowei Wu [Fri, 20 Aug 2021 00:39:36 +0000 (17:39 -0700)]
[ifs] Add option to hide undefined symbols

This change add an option to llvm-ifs to hide undefined symbols from
its output.

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

2 years ago[clang-format] [PR51640] - New AfterEnum brace wrapping changes have cause C# behavio...
mydeveloperday [Fri, 27 Aug 2021 18:10:45 +0000 (19:10 +0100)]
[clang-format] [PR51640] - New AfterEnum brace wrapping changes have cause C# behaviour to change

LLVM 13.0.0-rc2 shows change of behaviour in enum and interface BraceWrapping (likely before we simply didn't wrap)  but may be related to {D99840}

Logged as https://bugs.llvm.org/show_bug.cgi?id=51640

This change ensure AfterEnum works for

`internal|public|protected|private enum A {`  in the same way as it works for `enum A {` in C++

A similar issue was also observed with `interface` in C#

Reviewed By: krasimir, owenpan

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

2 years ago[OpenMP][FIX] Allow declare variant to work with reference types
Johannes Doerfert [Thu, 26 Aug 2021 18:04:29 +0000 (13:04 -0500)]
[OpenMP][FIX] Allow declare variant to work with reference types

Reference types in the return or parameter position did cause the OpenMP
declare variant overload reasoning to give up. We should allow them as
we allow any other type.

This should fix the bug reported on the mailing list:
https://lists.llvm.org/pipermail/openmp-dev/2021-August/004094.html

Reviewed By: ABataev, pdhaliwal

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

2 years ago[Attributor][FIX] Recursion via memory needs to be tracked explicitly
Johannes Doerfert [Tue, 17 Aug 2021 06:37:29 +0000 (01:37 -0500)]
[Attributor][FIX] Recursion via memory needs to be tracked explicitly

Recursion can happen when we see a PHI use the second time or when we
look at a store value operand use again. We already visited the
potential copies and doing so again will just cause endless looping.

Reviewed By: kuter

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

2 years ago[Attributor][FIX] Do not treat byval args as local memory (for now)
Johannes Doerfert [Mon, 16 Aug 2021 16:04:09 +0000 (11:04 -0500)]
[Attributor][FIX] Do not treat byval args as local memory (for now)

For now we do should not treat byval arguments as local copies performed
on the call edge, though, in general we should. To make that happen we
need to teach various passes, e.g., DSE, about the copy effect of a
byval. That would also allow us to mark functions only accessing byval
arguments as readnone again, atguably their acceses have no effect
outside of the function, like accesses to allocas.

Reviewed By: kuter

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

2 years agoFix assertion when passing function into inline asm's input operand
Jason Liu [Fri, 27 Aug 2021 17:37:34 +0000 (13:37 -0400)]
Fix assertion when passing function into inline asm's input operand

This seem to be a regression caused by this change:
https://reviews.llvm.org/D60943.
Since we delayed report the error, we would run into some invalid
state in clang and llvm.

Without this fix, clang would assert when passing function into
inline asm's input operand.

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

2 years ago[gn build] Port 54e8cae56529
LLVM GN Syncbot [Fri, 27 Aug 2021 17:29:43 +0000 (17:29 +0000)]
[gn build] Port 54e8cae56529

2 years agoSpecial case common branch patterns in breakLoopBackedge (try 2)
Philip Reames [Fri, 27 Aug 2021 17:12:15 +0000 (10:12 -0700)]
Special case common branch patterns in breakLoopBackedge (try 2)

Changes since aec08e:
* Adjust placement of a closing brace so that the general case actually runs.  Turns out we had *no* coverage of the switch case.  I added one in eae90fd.
* Drop .llvm.loop.* metadata from the new branch as there is no longer a loop to annotate.

Original commit message:

This special cases an unconditional latch and a conditional branch latch exit to improve codegen and test readability. I am hoping to reuse this function in the runtime unroll code, but without this change, the test diffs are far too complex to assess.

2 years ago[Codegen][X86] EltsFromConsecutiveLoads(): if only have AVX1, ensure that the "load...
Roman Lebedev [Fri, 27 Aug 2021 17:15:45 +0000 (20:15 +0300)]
[Codegen][X86] EltsFromConsecutiveLoads(): if only have AVX1, ensure that the "load" is actually foldable (PR51615)

This fixes another reproducer from https://bugs.llvm.org/show_bug.cgi?id=51615
And again, the fix lies not in the code added in D105390

In this case, we completely don't check that the "broadcast-from-mem" we create
can actually fold the load. In this case, it's operand was not a load at all:
```
Combining: t16: v8i32 = vector_shuffle<0,u,u,u,0,u,u,u> t14, undef:v8i32
Creating new node: t29: i32 = undef
RepeatLoad:
t8: i32 = truncate t7
  t7: i64 = extract_vector_elt t5, Constant:i64<0>
    t5: v2i64,ch = load<(load (s128) from %ir.arg)> t0, t2, undef:i64
      t2: i64,ch = CopyFromReg t0, Register:i64 %0
        t1: i64 = Register %0
      t4: i64 = undef
    t3: i64 = Constant<0>
Combining: t15: v8i32 = undef

```

Reviewed By: RKSimon

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

2 years ago[MC][RISCV] Add RISCV MCObjectFileInfo
Philipp Krones [Fri, 27 Aug 2021 16:55:52 +0000 (17:55 +0100)]
[MC][RISCV] Add RISCV MCObjectFileInfo

This makes sure, that the text section will have a 2-byte alignment, if
the +c extension is enabled.

Reviewed By: MaskRay, luismarques

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

2 years ago[RISCV] Add -riscv-v-fixed-length-vector-elen-max to limit the ELEN used for fixed...
Craig Topper [Fri, 27 Aug 2021 16:51:05 +0000 (09:51 -0700)]
[RISCV] Add -riscv-v-fixed-length-vector-elen-max to limit the ELEN used for fixed length vectorization.

This adds an ELEN limit for fixed length vectors. This will scalarize
any elements larger than this. It will also disable some fractional
LMULs. For example, if ELEN=32 then mf8 becomes illegal, i32/f32
vectors can't use any fractional LMULs, i16/f16 can only use mf2,
and i8 can use mf2 and mf4.

We may also need something for the scalable vectors, but that has
interactions with the intrinsics and we can't scalarize a scalable
vector.

Longer term this should come from one of the Zve* features

2 years ago[libcxx] Use GetSystemTimePreciseAsFileTime() if available
Sizhe Zhao [Thu, 26 Aug 2021 20:11:54 +0000 (23:11 +0300)]
[libcxx] Use GetSystemTimePreciseAsFileTime() if available

We will try to use GetSystemTimePreciseAsFileTime if possible.
Reference: https://sourceforge.net/p/mingw-w64/mingw-w64/ci/59195b2d7fe26549f70969b0dd487293819f023e/.

Reviewed By: compnerd, #libc, mstorsjo, ldionne

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

2 years ago[test] exercise breakLoopBackedge with a switch latch cond
Philip Reames [Fri, 27 Aug 2021 17:09:51 +0000 (10:09 -0700)]
[test] exercise breakLoopBackedge with a switch latch cond

This was reduced from a test case which triggered a revert to my recent change to same function.  It turns out we didn't have *any* coverage of the non-branch latch and my patch was blatantly broken.

2 years ago[gn build] Port c8b14c03ec74
LLVM GN Syncbot [Fri, 27 Aug 2021 16:46:52 +0000 (16:46 +0000)]
[gn build] Port c8b14c03ec74

2 years ago[libc++][NFC] Fix include guard for decay_copy.h and remove underscores from the...
Louis Dionne [Fri, 27 Aug 2021 14:36:04 +0000 (10:36 -0400)]
[libc++][NFC] Fix include guard for decay_copy.h and remove underscores from the header

We don't use double underscores for private header names when they are
in a subdirectory with double underscores already.

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