platform/upstream/llvm.git
19 months ago[C++20] [Coroutines] Handle function-try-block in SemaCoroutine
Chuanqi Xu [Thu, 6 Apr 2023 07:10:24 +0000 (15:10 +0800)]
[C++20] [Coroutines] Handle function-try-block in SemaCoroutine

In https://reviews.llvm.org/D146758, we handled the rare case that the
coroutine has a function-try-block. But it will be better to handle it
in the Sema part. This patch handles the preprocess.

19 months ago[InstCombine] Remove visitGEPOfBitcast() fold (NFC)
Nikita Popov [Wed, 5 Apr 2023 14:40:50 +0000 (16:40 +0200)]
[InstCombine] Remove visitGEPOfBitcast() fold (NFC)

This does not apply to opaque pointers, and as such is no longer
necessary.

19 months ago[clang][dataflow] Eliminate code duplication in Environment::createValueUnlessSelfRef...
Martin Braenne [Wed, 5 Apr 2023 11:20:33 +0000 (11:20 +0000)]
[clang][dataflow] Eliminate code duplication in Environment::createValueUnlessSelfReferential().

Reviewed By: sammccall

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

19 months ago[X86] Add InstFixup for masked `unpck{l|h}pd` -> masked `shufpd`
Noah Goldstein [Thu, 6 Apr 2023 06:11:30 +0000 (01:11 -0500)]
[X86] Add InstFixup for masked `unpck{l|h}pd` -> masked `shufpd`

This is a follow up D147507 which removed the prior transformation to
`shufps` which was incorrect as the mask was for 64-bit double
elements, not 32-bit float elements. Using `shufpd` for the
replacement, however, preserves the mask semantics and has the same
benefits as `shufps`.

Reviewed By: pengfei, RKSimon

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

19 months ago[gn build] Port 8d7c865c2e22
LLVM GN Syncbot [Thu, 6 Apr 2023 06:23:53 +0000 (06:23 +0000)]
[gn build] Port 8d7c865c2e22

19 months ago[runtimes] Fix typo from e787ef86634553131f8e47bd8eaaede987cf20e2
Shoaib Meenai [Thu, 6 Apr 2023 06:22:28 +0000 (23:22 -0700)]
[runtimes] Fix typo from e787ef86634553131f8e47bd8eaaede987cf20e2

The variable name was incorrect, which was breaking runtimes builds.

19 months ago[docs] Also mention Discord on Contributing.rst page
Kristof Beyls [Tue, 7 Mar 2023 09:56:20 +0000 (10:56 +0100)]
[docs] Also mention Discord on Contributing.rst page

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

19 months ago[RISCV] Support __builtin_nontemporal_load/store by MachineMemOperand
Piyou Chen [Mon, 6 Feb 2023 03:37:13 +0000 (19:37 -0800)]
[RISCV] Support __builtin_nontemporal_load/store by MachineMemOperand

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

19 months ago[X86][InstCombine] Avoid -Wparentheses warnings introduced in D145220, NFCI
Shengchen Kan [Thu, 6 Apr 2023 05:49:15 +0000 (13:49 +0800)]
[X86][InstCombine] Avoid -Wparentheses warnings introduced in D145220, NFCI

19 months ago[AMDGPU][GISel] Add inverse ballot intrinsic
Jessica Del [Thu, 16 Mar 2023 16:17:20 +0000 (17:17 +0100)]
[AMDGPU][GISel] Add inverse ballot intrinsic

The inverse ballot intrinsic takes in a boolean mask for all lanes and
returns the boolean for the current lane. See SPIR-V's
`subgroupInverseBallot()` in the [[ https://github.com/KhronosGroup/GLSL/blob/master/extensions/khr/GL_KHR_shader_subgroup.txt | GL_KHR_shader_subgroup extension ]].
This allows decision making via branch and select instructions with a manually
manipulated mask.

Implemented in GlobalISel and SelectionDAG, since currently both are supported.
The SelectionDAG required pseudo instructions to use the custom inserter.

The boolean mask needs to be uniform for all lanes.
Therefore we expect SGPR input. In case the source is in a
VGPR, we insert one or more `v_readfirstlane` instructions.

Reviewed By: nhaehnle

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

19 months ago[X86][mem-fold] Refine the code in X86FoldTablesEmitter.cpp, NFCI
Shengchen Kan [Thu, 6 Apr 2023 05:32:42 +0000 (13:32 +0800)]
[X86][mem-fold] Refine the code in X86FoldTablesEmitter.cpp, NFCI

1. Construct RecognizableInstrBase for Mem Inst only once in IsMatch
2. Correct the comments
3. Use std::make_tuple to simplify the compare

19 months ago[CodeGen] Speedup stack slot sharing during stack coloring (interval overlapping...
Valery Pykhtin [Tue, 14 Mar 2023 15:30:46 +0000 (16:30 +0100)]
[CodeGen] Speedup stack slot sharing during stack coloring (interval overlapping test).

AMDGPU code with enabled address sanitizer generates tons of stack objects (> 200000 in my testcase) and
takes forever to compile due to the time spent on stack slot sharing.

While LiveRange::overlaps method has logarithmic complexity on the number of segments in the involved
liveranges the problem is that when a new interval is assigned to a used color it's tested against
overlapping every other assigned interval for that color.

Instead I decided to join all assigned intervals for a color into a single interval and this allows to
have logarithmic complexity on the number of segments for the joined interval.

This patch reduced time spent on stack slot coloring pass from 628 to 3 seconds on my testcase.

Reviewed By: arsenm

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

19 months ago[mlir][bufferization] Add bufferization.eliminate_empty_tensors transform op
Matthias Springer [Thu, 6 Apr 2023 05:17:54 +0000 (14:17 +0900)]
[mlir][bufferization] Add bufferization.eliminate_empty_tensors transform op

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

19 months ago[X86] Add AMX_COMPLEX to Graniterapids
Freddy Ye [Thu, 6 Apr 2023 02:15:11 +0000 (10:15 +0800)]
[X86] Add AMX_COMPLEX to Graniterapids

This patch also rename __AMXCOMPLEX__ to __AMX_COMPLEX__

Reviewed By: skan, xiangzhangllvm

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

19 months ago[mlir] Use BaseMemRefType for ranked/unranked memrefs
Matthias Springer [Thu, 6 Apr 2023 04:21:00 +0000 (13:21 +0900)]
[mlir] Use BaseMemRefType for ranked/unranked memrefs

This makes `RankedOrUnrankedMemRefOf` consistent with `TensorOf`.

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

19 months ago[mlir] Use RankedTensorType when rank is required
Matthias Springer [Thu, 6 Apr 2023 04:20:41 +0000 (13:20 +0900)]
[mlir] Use RankedTensorType when rank is required

`RankedTensorOf` and `TensorRankOf` (in Tablegen files) now generate code that uses `RankedTensorType` instead of `TensorType`. This gives us more accurate type information (e.g., when calling `op.getType()`).

Also use restrict tensor.expand_shape/tensor.collapse_shape/tensor.pad to ranked tensors. Only cast ops should deal with unranked tensors.

Also improves a few places in the code base (e.g., Toy tutorial) where a ranked tensor is assumed (e.g., because `getRank` is called) but a `TensorType` is currently used: cast to `RankedTensorType` directly, so that the assertion is triggered directly at the cast.

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

19 months ago[X86][mem-fold] Refine the code in X86FoldTablesEmitter.cpp, NFCI
Shengchen Kan [Thu, 6 Apr 2023 04:04:50 +0000 (12:04 +0800)]
[X86][mem-fold] Refine the code in X86FoldTablesEmitter.cpp, NFCI

1. Avoid vulnerable assumption: the enum of reg/memory format are continous
2. Remove redundant inline keyword
3. Replace getValueFromBitsInit with byteFromBitsInit b/c both Form and
   Opcode can be represented in 1 byte

19 months ago[mlir][bufferize] Simplify one_shot_bufferize transform op
Matthias Springer [Thu, 6 Apr 2023 03:58:46 +0000 (12:58 +0900)]
[mlir][bufferize] Simplify one_shot_bufferize transform op

Restrict the op to functions and modules. Such ops are modified in-place. The transform now consumes the handle and produces a new handle. The `target_is_module` attribute is no longer needed because a result handle is produced in either case.

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

19 months ago[mlir][linalg] Use TrackingListener for VectorizeOp
Matthias Springer [Thu, 6 Apr 2023 02:51:03 +0000 (11:51 +0900)]
[mlir][linalg] Use TrackingListener for VectorizeOp

This is needed so that the transform dialect interpreter is notified about deleted payload ops.

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

19 months ago[LAA] Group implementation of stride speculation into one file [nfc]
Philip Reames [Thu, 6 Apr 2023 01:12:47 +0000 (18:12 -0700)]
[LAA] Group implementation of stride speculation into one file [nfc]

These utilities are only used in one place, so move them there and make them static.

19 months agoRecommit [C++20] [Modules] Don't load declaration eagerly for named modules
Chuanqi Xu [Thu, 6 Apr 2023 03:01:58 +0000 (11:01 +0800)]
Recommit [C++20] [Modules] Don't load declaration eagerly for named modules

Close https://github.com/llvm/llvm-project/issues/61064.

The root cause of the issue is that we will deserilize some declarations
eagerly when reading the BMI. However, many declarations in the BMI are
not necessary for the importer. So it wastes a lot of time.

The new commit handles the MSVC's extension #pragma comment and #pragma
detect_mismatch to follow MSVC's behavior. See pr61783 for details.

19 months agoRevert "[ADT][ConcurrentHashTable] Change thread_local to LLVM_THREAD_LOCAL inside...
Alexey Lapshin [Thu, 6 Apr 2023 02:55:26 +0000 (04:55 +0200)]
Revert "[ADT][ConcurrentHashTable] Change thread_local to LLVM_THREAD_LOCAL inside unit test."

This reverts commit 9ef701318b4590e1fa8bb61906d5957d7b1f6a2f.

19 months ago[RISCV] Add vector load/store intrinsics to getTgtMemIntrinsic.
Craig Topper [Thu, 6 Apr 2023 02:28:05 +0000 (19:28 -0700)]
[RISCV] Add vector load/store intrinsics to getTgtMemIntrinsic.

This constructs a proper memory operand for these intrinsics.

Segment load/store will be added in a separate patch.

Reviewed By: kito-cheng

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

19 months ago[PowerPC] Update pr61315.ll to address D146632 failure
Maryam Moghadas [Thu, 6 Apr 2023 01:56:19 +0000 (20:56 -0500)]
[PowerPC] Update pr61315.ll to address D146632 failure

This patch is to update pr61315.ll what was needed as part of
D146632 and caused build failures.

Reviewed By: stefanp

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

19 months ago[RISCV] Support vector type strict_[su]int_to_fp and strict_fp_to_[su]int.
Yeting Kuo [Tue, 28 Mar 2023 13:57:36 +0000 (21:57 +0800)]
[RISCV] Support vector type strict_[su]int_to_fp and strict_fp_to_[su]int.

Also the patch loose the fixed vector contraint in llvm/lib/IR/Verifier.cpp.

Reviewed By: craig.topper

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

19 months ago[mlir][arith] Add ValueBoundsOpInterface impls
Matthias Springer [Thu, 6 Apr 2023 01:46:48 +0000 (10:46 +0900)]
[mlir][arith] Add ValueBoundsOpInterface impls

These ops are useful for unit testing. (They do not fold/canonicalize with affine.apply etc.)

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

19 months ago[SelectionDAG] Expand VP SDNodes by default.
Craig Topper [Thu, 6 Apr 2023 01:52:28 +0000 (18:52 -0700)]
[SelectionDAG] Expand VP SDNodes by default.

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

19 months ago[mlir][memref] Add ValueBoundsOpInterface impls
Matthias Springer [Thu, 6 Apr 2023 01:35:12 +0000 (10:35 +0900)]
[mlir][memref] Add ValueBoundsOpInterface impls

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

19 months ago[mlir][linalg] ValueBoundsOpInterface: Add affine.apply op
Matthias Springer [Thu, 6 Apr 2023 01:15:11 +0000 (10:15 +0900)]
[mlir][linalg] ValueBoundsOpInterface: Add affine.apply op

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

19 months ago[PowerPC] Fix the xxperm swap requirements
Maryam Moghadas [Wed, 22 Mar 2023 14:14:00 +0000 (09:14 -0500)]
[PowerPC] Fix the xxperm swap requirements

This patch is to fix the xxperm vector operand swap condition so that the
single-use operand is in V2 to prevent copying, it also fixes the subtarget
condition to exploit the xpperm.

Reviewed By: stefanp

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

19 months ago[mlir][Interfaces] Add ValueBoundsOpInterface
Matthias Springer [Thu, 6 Apr 2023 00:41:15 +0000 (02:41 +0200)]
[mlir][Interfaces] Add ValueBoundsOpInterface

Ops can implement this interface to specify lower/upper bounds for their result values and block arguments. Bounds can be specified for:
* Index-type values
* Dimension sizes of shapes values

The bounds are added to a constraint set. Users can query this constraint set to compute bounds wrt. to a user-specified set of values. Only EQ bounds are supported at the moment.

This revision also contains interface implementations for various tensor dialect ops, which illustrates how to implement this interface.

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

19 months ago[RISCV][CostModel] Add tests for first class aggregate loads and stores
Philip Reames [Thu, 6 Apr 2023 00:41:05 +0000 (17:41 -0700)]
[RISCV][CostModel] Add tests for first class aggregate loads and stores

This adds coverage for the code change in 27b6ddbf6.

19 months ago[RISCV] Speculative fix for issue reported against D147470 post commit
Philip Reames [Thu, 6 Apr 2023 00:25:12 +0000 (17:25 -0700)]
[RISCV] Speculative fix for issue reported against D147470 post commit

19 months ago[Driver] Fix rpath for compiler-rt
Yaxun (Sam) Liu [Wed, 5 Apr 2023 23:38:37 +0000 (19:38 -0400)]
[Driver] Fix rpath for compiler-rt

The compiler-rt library path can be either {resource_dir}/lib/{triple}
or {resource_dir}/lib/{OS}/{arch} depending on whether
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default is ON or OFF.
Currently, the rpath added by -rtlib-add-rpath only adds
the latter. This patch checks both and adds the one that exists.

Reviewed by: Fangrui Song

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

19 months agoFix the check in StopInfoBreakpoint for "are we currently running an expression"
Jim Ingham [Thu, 6 Apr 2023 00:10:42 +0000 (17:10 -0700)]
Fix the check in StopInfoBreakpoint for "are we currently running an expression"

We were checking "WasTheLastResumeForUserExpression" but that returns true even
if that expression was completed, provided we haven't run again.  This uses a
better check.

This is actually fairly hard to trigger.  It happens the first time you hit an
objc_exception_throw breakpoint and invoke that frame recognizer for that.  But
I couldn't trigger it using a Python based frame recognizer.  So I wrote a test
for the objc_exception_throw_breakpoint recognizer which should have been there
anyway...  It fails (the target auto-continues) w/o this patch and succeeds with
it.

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

19 months ago[gn] port 405ceaa09de0
Nico Weber [Thu, 6 Apr 2023 00:13:57 +0000 (20:13 -0400)]
[gn] port 405ceaa09de0

19 months agoRevert "[scudo] Switch to use MemMap in tests"
Chia-hung Duan [Thu, 6 Apr 2023 00:06:34 +0000 (00:06 +0000)]
Revert "[scudo] Switch to use MemMap in tests"

This reverts commit 4151477021170d8937f8fc820187d5934eb93c7d.

19 months ago[scudo] Fix __require_constant_initialization__ on Android
Chia-hung Duan [Wed, 5 Apr 2023 22:38:32 +0000 (22:38 +0000)]
[scudo] Fix __require_constant_initialization__ on Android

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

19 months ago[lsan] Rename IgnoreObjectLocked into IgnoreObject
Vitaly Buka [Wed, 5 Apr 2023 23:16:49 +0000 (16:16 -0700)]
[lsan] Rename IgnoreObjectLocked into IgnoreObject

We don't lock allocator for this call.

19 months ago[hwasan] Use GetBlockBegin instead of GetBlockBeginFastLocked
Vitaly Buka [Wed, 5 Apr 2023 23:12:04 +0000 (16:12 -0700)]
[hwasan] Use GetBlockBegin instead of GetBlockBeginFastLocked

Asan and lsan use non-locked version as well.
IgnoreObjectLocked name is missleading.

19 months ago[mlir][sparse][gpu] end-to-end example with sparse GPU pipeline
Aart Bik [Tue, 4 Apr 2023 22:14:32 +0000 (15:14 -0700)]
[mlir][sparse][gpu] end-to-end example with sparse GPU pipeline

Reviewed By: Peiming

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

19 months ago[MSP430] Add CFI instructions for MSP430.
Ilia Kuklin [Wed, 5 Apr 2023 22:49:53 +0000 (15:49 -0700)]
[MSP430] Add CFI instructions for MSP430.

Implement emission of DWARF CFI instructions for MSP430. This includes descriptions of stack frame layout and location of callee-saved registers that could be used for backtracing.

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

19 months ago[Tests] More InlineCost tests with attributes only on callsites
Dávid Bolvanský [Wed, 5 Apr 2023 22:49:55 +0000 (00:49 +0200)]
[Tests] More InlineCost tests with attributes only on callsites

19 months ago[Clang][NFC] Refactor "Designators" to be more similar
Bill Wendling [Tue, 4 Apr 2023 23:17:52 +0000 (16:17 -0700)]
[Clang][NFC] Refactor "Designators" to be more similar

This makes the two interfaces for designators more similar so that it's
easier to merge them together in a future refactoring.

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

19 months agoLazily deserialize default member initializers.
Richard Smith [Wed, 5 Apr 2023 21:28:57 +0000 (14:28 -0700)]
Lazily deserialize default member initializers.

This is important to break deserialization cycles, where a lambda in a
default member initializer can refer to the field as its context
declaration, and the initializer of the field can refer back to the
lambda.

This is a follow-up to bc73ef0031b5, which applied the same fix to
variable declarations for the same reason.

19 months agoRegAllocFast: Fix dropping subreg indexes on unassigned subreg defs
Matt Arsenault [Fri, 3 Mar 2023 17:11:58 +0000 (13:11 -0400)]
RegAllocFast: Fix dropping subreg indexes on unassigned subreg defs

This was assuming all register operands were assigned to physical registers.
This should ignore the operands which weren't assigned in this run.

Fixes #61134

19 months ago[mlir][sparse][gpu] sparse GPU code generator pipeline setup
Aart Bik [Wed, 5 Apr 2023 19:57:23 +0000 (12:57 -0700)]
[mlir][sparse][gpu] sparse GPU code generator pipeline setup

Reviewed By: Peiming

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

19 months ago[isel] Pre-commit test for pr61964 fix
Han Zhu [Wed, 5 Apr 2023 22:01:04 +0000 (15:01 -0700)]
[isel] Pre-commit test for pr61964 fix

19 months ago[Tests] Added InlineCost test when arg is known as dereferenceable
Dávid Bolvanský [Wed, 5 Apr 2023 21:58:06 +0000 (23:58 +0200)]
[Tests] Added InlineCost test when arg is known as dereferenceable

19 months ago[AMDGPU] Add Lower Bound to PipelineSolver
Jeff Byrnes [Thu, 23 Mar 2023 16:59:31 +0000 (09:59 -0700)]
[AMDGPU] Add Lower Bound to PipelineSolver

19 months agoReland "[-Wunsafe-buffer-usage] Fix-Its transforming `&DRE[any]` to `&DRE.data()...
Ziqing Luo [Wed, 5 Apr 2023 21:52:49 +0000 (14:52 -0700)]
Reland "[-Wunsafe-buffer-usage] Fix-Its transforming `&DRE[any]` to `&DRE.data()[any]`"

This commit relands 87b5807d3802b932c06d83c4287014872aa2caab, where a
test fails on a few specific targets.  Now hard-code a target
for the test.

19 months ago[flang] Nonconformant assigned gotos
V Donaldson [Wed, 5 Apr 2023 18:13:36 +0000 (11:13 -0700)]
[flang] Nonconformant assigned gotos

Modify code generation for assigned gotos to generate a runtime error
for most cases that violate F90 Clause 8.2.4, rather than treating a
nonconformant GOTO as a nop. For example, generate a runtime error for
a GOTO that attempts to branch to a label for a FORMAT statement.
Relax the requirement that an assigned GOTO with a label list must
branch to a label in the list, and instead allow a branch to any valid
assigned GOTO target in scope.

19 months ago[clang-format] Fix bugs with "LambdaBodyIndentation: OuterScope"
Jon Phillips [Wed, 5 Apr 2023 21:28:56 +0000 (14:28 -0700)]
[clang-format] Fix bugs with "LambdaBodyIndentation: OuterScope"

The previous implementation of the option corrupted the parenthesis
state stack. (See https://reviews.llvm.org/D102706.)

Fixes #55708.
Fixes #53212.
Fixes #52846.
Fixes #59954.

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

19 months ago[scudo] Switch to use MemMap in tests
Chia-hung Duan [Wed, 5 Apr 2023 21:19:11 +0000 (21:19 +0000)]
[scudo] Switch to use MemMap in tests

Reviewed By: cferris

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

19 months ago[scudo] Manage pages with MemMap in Secondary Allocator
Chia-hung Duan [Tue, 4 Apr 2023 21:32:22 +0000 (21:32 +0000)]
[scudo] Manage pages with MemMap in Secondary Allocator

Replace the uses of raw map()/unmap(), .etc calls with MemMap. Also
remove the direct use of MapPlatformData in the secondary allocator.

Also add setMemoryPermission() in MemMap.

Reviewed By: cryptoad

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

19 months ago[scudo] Manage pages with MemMap in SizeClassAllocator64
Chia-hung Duan [Tue, 4 Apr 2023 20:13:13 +0000 (20:13 +0000)]
[scudo] Manage pages with MemMap in SizeClassAllocator64

Introduce a new data structure to manage the allocated pages from the
system. This is meant to deprecate certain memory system call wrappers
in Scudo, e.g., map()/unmap(). Besides, we would like to make
MapPlatformData to be appeared in platform specific data structure only.
Given that there are several allocators in Scudo and each of them has
different way of page management. The deprecation will be done in
several CLs. In this commit, we start from SizeClassAllocator64.

Reviewed By: cferris

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

19 months ago[amdgpu][nfc] Remove dead code associated with LDS lowering
Jon Chesterfield [Wed, 5 Apr 2023 21:24:21 +0000 (22:24 +0100)]
[amdgpu][nfc] Remove dead code associated with LDS lowering

Pass disabled since approximately D104962 for miscompiling openmp

The functions under ReplaceConstant miscompile phis as noted in D112717 and
have no users in tree other than the disabled pass. It seems likely it has no
users out of tree.

Deletes the test cases associated with the disabled pass as well.

Reviewed By: rampitec

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

19 months agoMark threadIdx.x and friends as noundef.
Justin Lebar [Wed, 5 Apr 2023 06:36:06 +0000 (23:36 -0700)]
Mark threadIdx.x and friends as noundef.

threadIdx.x and similar functions never return undef.

Simple enough to say, but why does it matter?

Consider the following IR that reads threadIdx.x and blockIdx.x.

  %a = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x(), !range !138
  %b = call i32 @llvm.nvvm.read.ptx.sreg.tid.x(), !range !139
  %c = shl nuw nsw i32 %a, 6
  %linear_index = or i32 %c, %b
  %linear_index.fr = freeze i32 %linear_index

If %a or %b may be undef, then computeKnownBits will not recurse through
the freeze instruction.  Therefore we will not know anything about the
known bits of linear_index.fr, even though we have range metadata!  Bad
Things fall out of this.

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

19 months ago[flang] Keep the extended value for assumed-type optional
Valentin Clement [Wed, 5 Apr 2023 20:34:23 +0000 (13:34 -0700)]
[flang] Keep the extended value for assumed-type optional

Keep the extended value when lowering optional assumed type
dummy argument. The extended value is needed to lower correctly the
rest of the code.

Reviewed By: PeteSteinfeld, jeanPerier

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

19 months ago[libc] Only add extra runtime dependencies if the target exists
Joseph Huber [Wed, 5 Apr 2023 20:30:48 +0000 (15:30 -0500)]
[libc] Only add extra runtime dependencies if the target exists

Summary:
If the target for these tools doesn't exist we should simply assume that
they will be provided externally. This allows building `libc` standalone
with an external installation of `clang`.

19 months agoUpdate clang :: Driver/debug-options.c to fix the buildbots
Matthew Voss [Wed, 5 Apr 2023 20:25:04 +0000 (13:25 -0700)]
Update clang :: Driver/debug-options.c to fix the buildbots

The format of the LTO debug options generated for orbis-ld changed,
breaking this test.

https://lab.llvm.org/buildbot/#/builders/230/builds/11367

19 months ago[ADT][ConcurrentHashTable] Change thread_local to LLVM_THREAD_LOCAL inside unit test.
Alexey Lapshin [Wed, 5 Apr 2023 18:45:00 +0000 (20:45 +0200)]
[ADT][ConcurrentHashTable] Change thread_local to LLVM_THREAD_LOCAL inside unit test.

Not all platform support C++11 thread_local. Use portable
LLVM_THREAD_LOCAL macro instead.

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

19 months ago[OpenMP] Add tool dependencies in runtimes mode
Joseph Huber [Wed, 5 Apr 2023 19:24:34 +0000 (14:24 -0500)]
[OpenMP] Add tool dependencies in runtimes mode

The OpenMP offloading device runtime depends on multiple tools. We
should ensure that these tools are build before invoking the OpenMP
build.

Reviewed By: tra

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

19 months ago[libc] Search for the CUDA patch explicitly when testing
Joseph Huber [Wed, 5 Apr 2023 19:16:53 +0000 (14:16 -0500)]
[libc] Search for the CUDA patch explicitly when testing

The packaged version of the `libc` library does not depend on the CUDA
installation because it only uses `clang` and emits LLVM-IR. However,
for testing we directly need the CUDA toolkit to emit and execute the
files. This patch explicitly passes `--cuda-path` to the relevant
compilations for NVPTX testing.

Reviewed By: tra

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

19 months ago[CMake] Support runtimes targets without specifying triple
Petr Hosek [Wed, 30 Jun 2021 06:34:18 +0000 (23:34 -0700)]
[CMake] Support runtimes targets without specifying triple

Currently, for BUILTIN_TARGETS and RUNTIME_TARGETS you can either use
the special "default" value, or a target triple.

For the "default" value, we don't set any target triple and passthrough
a subset of CMake variables into the subbuild. This is typically used
on Darwin where we build universal binaries and a single target triple
therefore isn't sufficient.

For the target triple value, you can set arbitrary CMake variables
through RUNTIMES_<target>_<variable>, but we always set target triple
to <target>. This gives more flexibility, because we can precisely
control what variables are set in the subbuild, but is unsuitable for
platforms like Darwin.

To address this, we would like to introduce a third option which is
similar to the second option, except we won't set target triple in
the subbuild (you can always do so yourself by setting the appropriate
CMake variable, e.g. RUNTIMES_<name>_CMAKE_C_COMPILER_TARGET=<triple>).

This change is a first step in that direction, by eliminating the support
of target triples from builtin_register_target and runtime_register_target
helper functions.

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

19 months ago[NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy
Manna, Soumi [Wed, 5 Apr 2023 19:41:54 +0000 (15:41 -0400)]
[NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

    Reported by Coverity:

    AUTO_CAUSES_COPY
    Unnecessary object copies can affect performance

    Inside FrontendActions.cpp file,
    In clang::DumpModuleInfoAction::ExecuteAction(): Using the auto keyword without an & causes the copy of an object of type pair.

    Inside ComputeDependence.cpp file,
    In clang::computeDependence(clang::OverloadExpr *, bool, bool, bool): Using the auto keyword without an & causes the copy of an object of type TemplateArgumentLoc.

    Reviewed By: erichkeane, aaron.ballman

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

19 months ago[PS4][clang] Fix the format of the LTO debug options passed to orbis-ld
Matthew Voss [Wed, 5 Apr 2023 19:57:21 +0000 (12:57 -0700)]
[PS4][clang] Fix the format of the LTO debug options passed to orbis-ld

Currently, we pass multiple LTO debug options to orbis-ld like this:

orbis-ld --lto=thin --lto-thin-debug-options=<arg1> --lto-thin-debug-options=<arg2> ...

When it should be like this:

orbis-ld --lto=thin "--lto-thin-debug-options= <arg1> <arg2>" ...

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

19 months ago[clang][deps] NFC: Make PCH test more debuggable
Jan Svoboda [Wed, 5 Apr 2023 19:27:07 +0000 (12:27 -0700)]
[clang][deps] NFC: Make PCH test more debuggable

Overwriting CDB files made it difficult to debug earlier clang-scan-deps invocations. This commit creates separate files for each.

19 months ago[clang][deps] NFC: Don't collect PCH input files
Jan Svoboda [Wed, 5 Apr 2023 19:25:10 +0000 (12:25 -0700)]
[clang][deps] NFC: Don't collect PCH input files

Since b4c83a13, PCH input files are no longer necessary.

19 months agoRemove unintended __sanitizer_get_allocation_bounds declaration
Thurston Dang [Mon, 3 Apr 2023 23:44:29 +0000 (23:44 +0000)]
Remove unintended __sanitizer_get_allocation_bounds declaration

This removes an unintentional function declaration, that was accidentally
added in D147005 (from an incomplete refactoring of __sanitizer_get_allocation_bounds).

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

19 months agoRevert "[clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR."
Francesco Petrogalli [Wed, 5 Apr 2023 18:53:20 +0000 (20:53 +0200)]
Revert "[clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR."

This reverts commit 029212617ca8bdedd949d17bf2d33750605ea607.

Reverting because of failures when setting
`CLANG_CRASH_DIAGNOSTICS_DIR` before invoking `ninja check-clang`.

19 months ago[libc][NFC] Rework generic memory operations
Guillaume Chatelet [Wed, 5 Apr 2023 18:47:39 +0000 (18:47 +0000)]
[libc][NFC] Rework generic memory operations

19 months agoAdd release note for D147569.
Zequan Wu [Wed, 5 Apr 2023 18:43:52 +0000 (14:43 -0400)]
Add release note for D147569.

19 months ago[Coverage] Fix crash when visiting PseudoObjectExpr.
Zequan Wu [Tue, 4 Apr 2023 20:40:11 +0000 (16:40 -0400)]
[Coverage] Fix crash when visiting PseudoObjectExpr.

This is a split of D147073.

Fixes #45481

Reviewed By: aaron.ballman

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

19 months ago[mlir][sparse][gpu] a first prototype sparse GPU code generator
Aart Bik [Mon, 3 Apr 2023 22:46:23 +0000 (15:46 -0700)]
[mlir][sparse][gpu] a first prototype sparse GPU code generator

This implements a proof-of-concept GPU code generator
to the sparse compiler pipeline, currently only capable
of generating CUDA threads for outermost parallel loops.

The objective, obviously, is to grow this concept
to a full blown GPU code generator, capable of the
right combinaton of code generation as well as exploiting
idiomatic kernels or vector specific libraries (think cuSparse).

Reviewed By: ThomasRaoux

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

19 months ago[Object] Refactor build ID parsing into Object lib.
Daniel Thornburgh [Mon, 3 Apr 2023 18:15:31 +0000 (11:15 -0700)]
[Object] Refactor build ID parsing into Object lib.

This makes parsing for build IDs in the markup filter slightly more
permissive, in line with fromHex.

It also removes the distinction between missing build ID and empty build
ID; empty build IDs aren't a useful concept, since their purpose is to
uniquely identify a binary. This removes a layer of indirection wherever
build IDs are obtained.

Reviewed By: jhenderson

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

19 months ago[lldb] Remove unused functions from RegisterContextLinux_x86
Pavel Labath [Wed, 5 Apr 2023 18:10:31 +0000 (20:10 +0200)]
[lldb] Remove unused functions from RegisterContextLinux_x86

These should be overridden by individual subclasses, they ended up here
because of copy-pasta.

19 months ago[dsymutil] Remove empty reproducer directory on exit
Keith Smiley [Tue, 4 Apr 2023 04:43:36 +0000 (21:43 -0700)]
[dsymutil] Remove empty reproducer directory on exit

In the case the reproducer isn't generated, we don't want to leave
around an empty temporary directory.

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

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

19 months ago[OpenMP][MLIR][Flang][bbc][Driver] Add OpenMP RTL Flags to Flang and generate omp...
Andrew Gozillon [Wed, 5 Apr 2023 17:34:57 +0000 (12:34 -0500)]
[OpenMP][MLIR][Flang][bbc][Driver] Add OpenMP RTL Flags to Flang and generate omp.FlagsAttr from them

This patch ports OpenMP RTL flags from the shared Clang compiler
options to Flang. As well as adding a limited subset to bbc.

This patch enables the flags below (and any equals or inverse variants)
for Flang that exist in Clang:

-fopenmp-target-debug
-fopenmp-assume-threads-oversubscription
-fopenmp-assume-teams-oversubscription
-fopenmp-assume-no-nested-parallelism
-fopenmp-assume-no-thread-state

For the bbc tool it only utilises the primary variants to minimize
additional complexity in the tool.

The patch also provides FlagAttr generation from these flags. Which
will be lowered to LLVM-IR in a subsequent patch.

Reviewers: kiranchandramohan, awarzynski

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

19 months ago[MSVC] Allow declaration of multi-dim 'property' array fields
Mike Rice [Wed, 5 Apr 2023 15:10:57 +0000 (08:10 -0700)]
[MSVC] Allow declaration of multi-dim 'property' array fields

MSVC allows declaration of multi-dim arrays like this:

__declspec(property(get=GetX, put=PutX)) int x[][][];

This syntax can appear in generated typelib headers.

Currently clang errors on declarators like this since it forms an array
type of incomplete array. Rather than try to handle such a type, ignore
adjacent empty chunks so this is treated as if there was only one empty
array chunk (i.e. int x[]).

The functionality to handle multi-dim subscripts of property fields
already works, but only if declared as a single-dim array.

19 months agoFix LLVM sphinx build
Aaron Ballman [Wed, 5 Apr 2023 17:25:07 +0000 (13:25 -0400)]
Fix LLVM sphinx build

This addresses issues found by:
https://lab.llvm.org/buildbot/#/builders/30/builds/33698

19 months agoAdd some additional comments to this test; NFC
Aaron Ballman [Wed, 5 Apr 2023 17:13:42 +0000 (13:13 -0400)]
Add some additional comments to this test; NFC

It isn't immediately obvious why that code should be accepted given the
wording of C2x 6.7.10p4, so this adds a comment explaining that there
is an existing extension to support zero-sized arrays in C, and that
empty initialization of an unbounded array in C++ deduces the array
extent as zero, so C is exposing the same extension as in C++.

19 months ago[flang][runtime] Support L editing of Logical
Shao-Ce SUN [Tue, 28 Mar 2023 16:38:18 +0000 (00:38 +0800)]
[flang][runtime] Support L editing of Logical

I tested gfortran and flang(old). https://godbolt.org/z/c89foro4G

Reviewed By: klausler

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

19 months ago[sanitizers] Simplify Explainer about dyld and weak overrides on Darwin. (NFC)
Roy Sundahl [Tue, 4 Apr 2023 13:09:58 +0000 (06:09 -0700)]
[sanitizers] Simplify Explainer about dyld and weak overrides on Darwin. (NFC)

Presenting more than one way to satisfy the single-weak-ref requirement leads to
confusing messaging for the end user. Use the introduction of a single unused
weak variable as the preferred solution. This differential modifies D146745.

rdar://103453678

Reviewed By: yln, thetruestblue

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

19 months ago[libc] fix strtofloat on large exponents
Michael Jones [Mon, 3 Apr 2023 21:00:43 +0000 (14:00 -0700)]
[libc] fix strtofloat on large exponents

Previously if you specified an exponent of more than 10000 in string to
float (e.g. "1e10001") it would treat it as 10000. A bug was discovered
where by having more than 10000 zeroes after a decimal point and an
exponent of more than 10000 this would cause the code to return the
incorrect value.

Reviewed By: lntue

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

19 months ago[RISCV][TTI] Cost model for SK_ExtractSubvector
Philip Reames [Wed, 5 Apr 2023 16:33:10 +0000 (09:33 -0700)]
[RISCV][TTI] Cost model for SK_ExtractSubvector

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

19 months ago[LV] Cleanup and reformatting for some debug messages. NFC
David Green [Wed, 5 Apr 2023 16:50:01 +0000 (17:50 +0100)]
[LV] Cleanup and reformatting for some debug messages. NFC

This is just some cleanup of various debug messages, pulled out of another
patch to simplify it a little.

19 months ago[SLP]Find reused scalars in buildvector sequences, if any.
Alexey Bataev [Mon, 20 Mar 2023 14:26:33 +0000 (07:26 -0700)]
[SLP]Find reused scalars in buildvector sequences, if any.

Patch generalizes analysis of scalars. The main part is outlined into
lambda, which can be used to find reused inserted scalars and emit
shuffle for them instead of multiple insertelement instructions, if the
permutation is found alreadyi. I.e. some scalars are transformed by the
permutation of previously vectorized nodes, and some are inserted
directly.

Reworked part of D110978

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

19 months ago[IVDescriptors] Add pointer InductionDescriptors with non-constant strides (try 2)
Philip Reames [Wed, 5 Apr 2023 16:26:17 +0000 (09:26 -0700)]
[IVDescriptors] Add pointer InductionDescriptors with non-constant strides (try 2)

(JFYI - This has been heavily reframed since original attempt at landing.)

This change updates the InductionDescriptor logic to allow matching a pointer IV with a non-constant stride, but also updates the LoopVectorizer to bailout on such descriptors by default. This preserves the default vectorizer behavior.

In review, it was pointed out that there's multiple unfortunate performance implications which need to be addressed before this can be enabled. Having a flag allows us to exercise the behavior, and write test cases for logic which is otherwise unreachable (or hard to reach).

This will also enable non-constant stride pointer recurrences for other consumers. I've audited said code, and don't see any obvious issues.

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

19 months ago[libunwind] Fix a case of inconsistent indentation. NFC.
Martin Storsjö [Sat, 1 Apr 2023 22:02:37 +0000 (01:02 +0300)]
[libunwind] Fix a case of inconsistent indentation. NFC.

19 months ago[JITLink][AArch32] Implement ELF::R_ARM_ABS32 after we stopped skipping debug info...
Stefan Gränitz [Tue, 4 Apr 2023 17:06:10 +0000 (19:06 +0200)]
[JITLink][AArch32] Implement ELF::R_ARM_ABS32 after we stopped skipping debug info sections

We create LinkGraph sections with NoAlloc lifetime now since f05ac803ffe76c7f4299a4e1288cc6bb8b098410
This means we do process debug info sections now with all their relocations. That's ok for the moment.

19 months agoSkip tests under asan
Adrian Prantl [Wed, 5 Apr 2023 16:00:46 +0000 (09:00 -0700)]
Skip tests under asan

19 months ago [X86][mem-fold] Simplify code by using StringRef::drop_back, NFCI
Shengchen Kan [Wed, 5 Apr 2023 15:39:32 +0000 (23:39 +0800)]
 [X86][mem-fold] Simplify code by using StringRef::drop_back, NFCI

19 months ago[DebugInfo] Update test to use opaque ptrs
OCHyams [Wed, 5 Apr 2023 15:23:02 +0000 (16:23 +0100)]
[DebugInfo] Update test to use opaque ptrs

The test was added in D99169.

19 months ago[X86][mem-fold] Remove the logic for FoldGenData, NFCI
Shengchen Kan [Wed, 5 Apr 2023 15:22:18 +0000 (23:22 +0800)]
[X86][mem-fold] Remove the logic for FoldGenData, NFCI

19 months agoRevert "[SimplifyCFG][LICM] Preserve nonnull, range and align metadata when speculating"
Nikita Popov [Wed, 5 Apr 2023 15:03:20 +0000 (17:03 +0200)]
Revert "[SimplifyCFG][LICM] Preserve nonnull, range and align metadata when speculating"

This reverts commit 78b1fbc63f78660ef10e3ccf0e527c667a563bc8.

This causes or exposes miscompiles in Rust, revert until they
have been investigated.

19 months ago[Flang] Fix usage of uninitialized resolution variable
Paul Scoropan [Wed, 5 Apr 2023 14:31:16 +0000 (14:31 +0000)]
[Flang] Fix usage of uninitialized resolution variable

Recent Flang PowerPC intrinsics patch used resolution variable without checking if it exists first, causing segmentation faults in some scenarios. This patch checks that the resolution variable exists first before usage.

Reviewed By: DanielCChen

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

19 months ago[Coroutines] Convert test to opaque pointers (NFC)
Nikita Popov [Wed, 5 Apr 2023 14:59:04 +0000 (16:59 +0200)]
[Coroutines] Convert test to opaque pointers (NFC)

19 months ago[RISCV] Account for LMUL in memory op costs
Philip Reames [Wed, 5 Apr 2023 14:47:24 +0000 (07:47 -0700)]
[RISCV] Account for LMUL in memory op costs

Generally, the cost of a memory op will scale with the number of vector registers accessed. Machines might exist which have a narrow memory access than vector register width, but machines with a wider memory access width than vector register width seem unlikely.

I noticed this because we were preferring wide loads + deinterleaves on examples where the cost of a short gather (actually a strided load) would be better. Touching 8 vector registers instead of doing a 4 element gather is not a good tradeoff.

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

19 months ago[AggressiveInstCombine] Enable also for -O2
Dávid Bolvanský [Wed, 5 Apr 2023 10:52:30 +0000 (12:52 +0200)]
[AggressiveInstCombine] Enable also for -O2

Next step after https://reviews.llvm.org/D113179

Recently a set of patches by @anton-afanasyev improved many cases (better and cleaner vectorized code) thanks to improvements to AIC's TruncInstCombine (IC cannot handle it) motivated by real examples in bug reports. There was a discussion that -O2 could benefit from AIC as well, but discussion then stalled, so I would like restart it, with new numbers from LLVM compile time tracker.

As -O2 pipeline is not tracked by LLVM compile time tracker, I disabled AIC for -O3 to get an idea how expensive is it. Without AIC, I observed that geomean was cca -0.10%. Given that it seems like AIC is quite cheap, heavily tested by -O3 pipeline, I am proposing to enable it also with -O2 and similar to improve quality to vectorized code.

https://llvm-compile-time-tracker.com/compare.php?from=a1df5abef5f27646c809c7b85cf6170eb68f7735&to=e1ba6068f58c6ca862b920b8750faccb42a5843c&stat=instructions:u

Differential Revision: https://reviews.llvm.org/D147604
Reviewed-By: nikic