480562 Commits

Author SHA1 Message Date
Shengchen Kan
58bb2d1956
[X86][MC] Support encoding of EGPR for APX (#71909)
#70958 adds registers R16-R31 (EGPR), this patch
1. Introduces a new instruction prefix REX2
2. Supports encoding of EGPR with REX2 for legacy instructions in MAP
0/1
3. Supports encoding of EGPR with EVEX for the existing instructions in
EVEX space

RFC:

https://discourse.llvm.org/t/rfc-design-for-apx-feature-egpr-and-ndd-support/73031/4
2023-11-13 15:27:42 +08:00
Michael Buch
f86770aa07 Reland "[lldb][DWARFASTParserClang] Make MemberAttributes const when parsing member DIEs (#71921)"
Changed the recently added `FindConstantOnVariableDefinition` to
not rely on MemberAttributes being non-const.

Original commit message:
"""
This patch removes the Objective-C accessibility workaround added in
5a477cfd90
(rdar://8492646). This allows us to make the local `MemberAttributes`
variable immutable, which is useful for some other work around this
function I was planning on doing.

We don't need the workaround anymore since compiler-support for giving
debuggers access to private ivars was done couple of years later in
d6cb4a858d
(rdar://10997647).

**Testing**

* Test-suite runs cleanly
"""
2023-11-13 06:38:57 +00:00
Nemanja Ivanovic
563720c3be
[RISCV] Fix lowering of negative zero with Zdinx 32-bit (#71869)
The compiler currently abends with an impossible reg-to-reg copy when
producing a negative zero FP immediate on RV32 with -Zdinx. This is
because we emit a negation that uses FP registers. Emit the right node
to produce correct code.
2023-11-13 07:38:14 +01:00
wenzhi-cui
858453dd71
Adds ":Support" to MLIRBindingsPythonCore deps (#72087)
Adds ":Support" to MLIRBindingsPythonCore deps
2023-11-13 07:34:16 +01:00
Fangrui Song
65f2cf25c3 Revert "[CodeGen] -fsanitize=alignment: add cl::opt sanitize-alignment-builtin to disable memcpy instrumentation (#69240)"
This reverts commit e8fe4de64ffb84924c41e54116a04570046eed74.

memcpy/memmove instrumentation for -fsanitize=alignment has been tested
on a huge code base. There were some cleanups but the number does not
justify a workaround.
2023-11-12 22:26:27 -08:00
Michael Buch
c501bf4334 Revert "[lldb][DWARFASTParserClang] Make MemberAttributes const when parsing member DIEs (#71921)"
This reverts commit 576f7ccfa4c1da241fb697185d03546298bfe2b6.

Causes build bot failure because new code started depending
on the non-constness of the MemberAttributes.
2023-11-13 06:16:32 +00:00
Michael Buch
9d587480dc [lldb][DWARFASTParserClang][NFC] Fix build failure
Caused by a badly resolved merge conflict
2023-11-13 06:14:23 +00:00
Michael Buch
576f7ccfa4
[lldb][DWARFASTParserClang] Make MemberAttributes const when parsing member DIEs (#71921)
This patch removes the Objective-C accessibility workaround added in
5a477cfd90
(rdar://8492646). This allows us to make the local `MemberAttributes`
variable immutable, which is useful for some other work around this
function I was planning on doing.

We don't need the workaround anymore since compiler-support for giving
debuggers access to private ivars was done couple of years later in
d6cb4a858d
(rdar://10997647).

**Testing**

* Test-suite runs cleanly
2023-11-13 06:11:05 +00:00
Michael Buch
15c8085202
Reland "[lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available" (#71800)
This patch relands https://github.com/llvm/llvm-project/pull/71004 which
was reverted because the clang change it depends on was reverted.

In addition to the original patch, this PR includes a change to
`SymbolFileDWARF::ParseVariableDIE` to support CU-level variable
definitions that don't have locations, but represent a constant value.
Previously, when debug-maps were available, we would assume that a
variable with "static lifetime" (which in this case means "has a linkage
name") has a valid address, which isn't the case for non-locationed
constants. We could omit this additional change if we stopped attaching
linkage names to global non-locationed constants.

Original commit message:
"""
https://github.com/llvm/llvm-project/pull/71780 proposes moving the
`DW_AT_const_value` on inline static members from the declaration DIE to
the definition DIE. This patch makes sure the LLDB's expression
evaluator can continue to support static initialisers even if the
declaration doesn't have a `DW_AT_const_value` anymore.

Previously the expression evaluator would find the constant for a
VarDecl from its declaration `DW_TAG_member` DIE. In cases where the
initialiser was specified out-of-class, LLDB could find it during symbol
resolution.

However, neither of those will work for constants, since we don't have a
constant attribute on the declaration anymore and we don't have
constants in the symbol table.
"""

Depends on:
* https://github.com/llvm/llvm-project/pull/71780
2023-11-13 06:09:58 +00:00
Matt Arsenault
d4912e8050 ValueTracking: Add some tests to cover asserts in fcmpImpliesClass
Catch asserts hit after 1adce7d8e47e2438f99f91607760b825e5e3cc37
2023-11-13 15:05:52 +09:00
Michael Buch
638a839361
Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (#71780)
This patch relands https://github.com/llvm/llvm-project/pull/70639

It was reverted because under certain conditions we triggered an
assertion
in `DIBuilder`. Specifically, in the original patch we called
`EmitGlobalVariable`
at the end of `CGDebugInfo::finalize`, after all the temporary `DIType`s
have
been uniqued. With limited debug-info such temporary nodes would be
created
more frequently, leaving us with non-uniqued nodes by the time we got to
`DIBuilder::finalize`; this violated its pre-condition and caused
assertions to trigger.

To fix this, the latest iteration of the patch moves
`EmitGlobalVariable` to the
beginning of `CGDebugInfo::finalize`. Now, when we create a temporary
`DIType` node as a result of emitting a variable definition, it will get
uniqued
in time. A test-case was added for this scenario.

We also now don't emit a linkage name for non-locationed constants since
LLDB doesn't make use of it anyway.

Original commit message:
"""
When an LLDB user asks for the value of a static data member, LLDB
starts
by searching the Names accelerator table for the corresponding variable
definition DIE. For static data members with out-of-class definitions
that
works fine, because those get represented as global variables with a
location
and making them eligible to be added to the Names table. However,
in-class
definitions won’t get indexed because we usually don't emit global
variables
for them. So in DWARF we end up with a single `DW_TAG_member` that
usually holds the constant initializer. But we don't get a corresponding
CU-level `DW_TAG_variable` like we do for out-of-class definitions.

To make it more convenient for debuggers to get to the value of inline
static data
members, this patch makes sure we emit definitions for static variables
with
constant initializers the same way we do for other static variables.
This also aligns
Clang closer to GCC, which produces CU-level definitions for inline
statics and also
emits these into `.debug_pubnames`.

The implementation keeps track of newly created static data members.
Then in `CGDebugInfo::finalize`, we emit a global `DW_TAG_variable` with
a
`DW_AT_const_value` for any of those declarations that didn't end up
with a
definition in the `DeclCache`.

The newly emitted `DW_TAG_variable` will look as follows:
```
0x0000007b:   DW_TAG_structure_type
                DW_AT_calling_convention        (DW_CC_pass_by_value)
                DW_AT_name      ("Foo")
                ...

0x0000008d:     DW_TAG_member
                  DW_AT_name    ("i")
                  DW_AT_type    (0x00000062 "const int")
                  DW_AT_external        (true)
                  DW_AT_declaration     (true)
                  DW_AT_const_value     (4)

Newly added
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

0x0000009a:   DW_TAG_variable
                DW_AT_specification     (0x0000008d "i")
                DW_AT_const_value       (4)
                DW_AT_linkage_name      ("_ZN2t2IiE1iIfEE")
```

This patch also drops the `DW_AT_const_value` off of the declaration
since we
now always have it on the definition. This ensures that the
`DWARFParallelLinker`
can type-merge class with static members where we couldn't attach the
constant
on the declaration in some CUs.
"""

Dependent changes:
* https://github.com/llvm/llvm-project/pull/71800
2023-11-13 06:04:27 +00:00
drazi
9a3d3c7093
generalize pass gpu-kernel-outlining for symbol op (#72074)
This PR generalize gpu-out-lining pass to take care of ops
`SymbolOpInterface` instead of just `func::FuncOp`.

Before this change, gpu-out-lining pass will skip `llvm.func`.
```mlir
module {
  llvm.func @main() {
    %c1 = arith.constant 1 : index
    gpu.launch blocks(%arg0, %arg1, %arg2) in (%arg6 = %c1, %arg7 = %c1, %arg8 = %c1) threads(%arg3, %arg4, %arg5) in (%arg9 = %c1, %arg10 = %c1, %arg11 = %c1) {
      gpu.terminator
    }
    llvm.return
  }
}
```

After this change, gpu-out-lining pass can handle llvm.func as well.
2023-11-12 21:48:49 -08:00
Fangrui Song
abeffc9fd6 [test] Test #pragma GCC visibility interaction with explicit instantiations 2023-11-12 21:29:03 -08:00
Wenju He
fe146e9b59
[InferAddressSpaces] Fix constant replace to avoid modifying other functions (#70611)
A constant value is unique in llvm context. InferAddressSpaces was
replacing its users in other functions as well. This leads to unexpected
behavior in our downstream use case after the pass.

InferAddressSpaces is a function passe, so it shall not modify functions
other than currently processed one.

Co-authored-by: Abhinav Gaba <abhinav.gaba@intel.com>

---------

Co-authored-by: Abhinav Gaba <abhinav.gaba@intel.com>
2023-11-13 13:28:56 +08:00
HaohaiWen
63e13f2b7d
[DebugInfo] Limit jump table test for x86 only (#72082)
32 bit target may generate different SelectionDAG for jump table. 
Temporarily limit this test for 64bit X86 target only.
2023-11-13 13:22:32 +08:00
Fangrui Song
89ecb8001a
MapVector: add C++17-style try_emplace and insert_or_assign (#71969)
Similar to https://wg21.link/n4279

For example, insert_or_assign can be used to simplify
CodeGenModule::AddDeferredUnusedCoverageMapping in
clang/lib/CodeGen/CodeGenModule.cpp
2023-11-12 20:45:37 -08:00
Younan Zhang
868007a03c
[clang][Sema] Avoid non-empty unexpanded pack assertion for FunctionParmPackExpr (#69224)
Closes https://github.com/llvm/llvm-project/issues/61460.

We have FunctionParmPackExpr that serves as the unexpanded expression
but from which the visitor collects none, which may lead to assertion
failure during the template instantiation.
2023-11-13 12:44:17 +08:00
Mehdi Amini
285a229f20 [MLIR] Apply clang-tidy fixes for misc-include-cleaner (NFC) 2023-11-12 20:35:46 -08:00
Craig Topper
44e8bea400
[GISel][AArch64] Notify the Observer when CTTZ lowering changes the opcode to CTPOP. (#72008) 2023-11-12 19:36:24 -08:00
Maksim Panchenko
ec4a03c658
[BOLT] Enhance LowerAnnotations pass. NFCI. (#71847)
After #70147, all primary annotation types are stored directly in the
instruction and hence there's no need for the temporary storage we've
used previously for repopulating preserved annotations.
2023-11-12 19:34:42 -08:00
Carl Ritson
edc38a6cbd
[AMDGPU] Add option to pre-allocate SGPR spill VGPRs (#70626)
SGPR spill VGPRs are WWM registers so allow them to be allocated by
SIPreAllocateWWMRegs pass.
This intentionally prevents spilling of these VGPRs when enabled.
2023-11-13 12:21:18 +09:00
HaohaiWen
6428bdd05d
[DebugInfo] Remove target related attributes for jump-table test (#72075)
This fixes test fails on non-x86 target.
2023-11-13 11:16:39 +08:00
Carl Ritson
52b247b1d3
[PHIElimination] Handle subranges in LiveInterval updates (#69429)
Add subrange tracking and handling for LiveIntervals during PHI
elimination.
This requires extending MachineBasicBlock::SplitCriticalEdge to also
update subrange intervals.
2023-11-13 12:16:26 +09:00
HaohaiWen
18415c8365
[DebugInfo] Add debug info test for jump table (#71018)
Test whether jump table BB has debug info after ISel.
2023-11-13 09:33:23 +08:00
Owen Pan
a533b76468
[clang-format][NFC] Simplify parseBracedList() (#72010) 2023-11-12 15:55:06 -08:00
Craig Topper
e0e0891d74 [RISCV][GISel] Select G_BRCOND and G_ICMP together when possible.
This allows us to fold the G_ICMP operands into the conditional branch.

This reuses the helper function we have for folding a G_ICMP into
G_SELECT.
2023-11-12 15:53:23 -08:00
Mariusz Borsa
c2205ab309
[Sanitizers][Darwin] Pass offset to __asan_set_shadow_xx (#71745)
Normally, when __asan_option_detect_stack_use_after_return option is
set,
the instrumentation passed the adress of the shadow memory bytes to be
set, for detecting problems with local variables.
This can be a problem when the -fsanitize-stable-abi option is in
effect,
since the ABI implementation doesn't have means to communicate the
current shadow memory base address
back to its users.

This change addresses it simply by setting
__asan_shadow_memory_dynamic_address to zero. It means
that __asan_set_shadow_xx will be now called with the offset relative to
the current shadow memory
base, and the ABI implementation needs to adapt accordingly.

The other change here is to set
__asan_option_detect_stack_use_after_return to nonzer by default,
which is needed for instrumentation to take paths using the
__asan_shadow_memory_dynamic_address
and __asan_set_shadow_xx calls.

Co-authored-by: Mariusz Borsa <m_borsa@apple.com>
2023-11-12 14:44:43 -08:00
Craig Topper
4c3206c5d5 [RISCV][GISel] Sink more code into getOperandsForBranch. NFC
Move the m_GICmp match call in and use it to collect the operands.

This code is also needed for G_BRCOND.
2023-11-12 11:52:32 -08:00
Brad Smith
9ba5b52c13
[lldb][test] Implement getting thread ID on OpenBSD (#71129) 2023-11-12 14:38:09 -05:00
JOE1994
c42d006f05 [llvm][InstrProfiling] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
2023-11-12 13:44:06 -05:00
Aleksandr Platonov
f575d792c6
[clangd] Use InitLLVM (#69119)
This patch is similar to a7acba29c19ac67c77ed282ec9432602ae21268d but
for clangd.

It allows to pass non-UTF8 encoded command line arguments (e.g. path
where compile-commands.json file is located) on Windows.
2023-11-12 20:46:47 +03:00
Léonard Oest O'Leary
ff36411b23
[InstCombine] Use zext's nneg flag for icmp folding (#70845)
This PR fixes https://github.com/llvm/llvm-project/issues/55013 : the
max intrinsics is not generated for this simple loop case :
https://godbolt.org/z/hxz1xhMPh. This is caused by a ICMP not being
folded into a select, thus not generating the max intrinsics.

For the story :

Since LLVM 14, SCCP pass got smarter by folding sext into zext for
positive ranges : https://reviews.llvm.org/D81756. After this change,
InstCombine was sometimes unable to fold ICMP correctly as both of the
arguments pointed to mismatched zext/sext. To fix this, @rotateright
implemented this fix : https://reviews.llvm.org/D124419 that tries to
resolve the mismatch by knowing if the argument of a zext is positive
(in which case, it is like a sext) by using ValueTracking, however
ValueTracking is not smart enough to infer that the value is positive in
some cases. Recently, @nikic implemented #67982 which keeps the
information that a zext is non-negative. This PR simply uses this
information to do the folding accordingly.

TLDR : This PR uses the recent nneg tag on zext to fold the icmp
accordingly in instcombine.

This PR also contains test cases for sext/zext folding with InstCombine
as well as a x86 regression tests for the max/min case.
2023-11-13 00:53:53 +08:00
Duo Wang
d05bada592
[libcxx][test] std::array::iterator are not pointers by C++ standard (#70729)
This is to modify a list of libcxx tests written under the assumption
that iterators for std::array, std::string_view, and std::string are
pointers. The motivation for this PR is to make the tests more universal
and potentially being used to test other C++ standard library
implementations, for example
[microsoft/STL](https://github.com/microsoft/STL).

I can confirm that this patch makes a number of tests compatible with
microsoft STL:
`Failed :  204 (2.12%)`  ->  `Failed :  136 (1.42%)`
, and does not break any tests on `libcxx`.

This is not a complete list of such incompatibilities, but I am hoping
this will start a discussion about whether we are open to accepting such
changes.
2023-11-12 17:30:15 +01:00
Aaron Ballman
8569465adf Add a Clang NATVIS visualizer for StringLiteral 2023-11-12 09:22:15 -05:00
Han Shen
ca10e3b2e5
[LLVM][NVPTX] Add BF16 vector instruction and fix lowering rules (#69415)
Add support for bf16x2 instructions such as setp, fneg, fabs, etc;
Fix the instructions that were not differentiated between sm_80 and
sm_90 support, such as fpround etc.
Add more bf16 test cases to ensure the correct behavior.

---------

Co-authored-by: shenhan03 <shenhan03@kuaishou.com>
2023-11-12 21:48:31 +08:00
David Green
a31538d29c [AArch64] Add a test showing inefficient register allocation around loop IVs. NFC 2023-11-12 13:11:03 +00:00
Florian Hahn
34c2dcd5ac
[VPlan] Move initial skeleton construction to createInitialVPlan. (NFC)
This patch moves creating the  middle VPBBs and an initial empty
vector loop region for the top-level loop to createInitialVPlan.

This consolidates code to create the initial VPlan skeleton and enables
adding other bits outside the main region during initial VPlan
construction. In particular, D150398 will add the exit check & branch to
the middle block.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D158333
2023-11-12 13:00:44 +00:00
Owen Pan
40671bbdef
[clang-format] Handle control statements in BreakAfterAttributes (#71995)
This patch doesn't work for do-while loops.

Fixed #64474.
2023-11-12 01:08:27 -08:00
Craig Topper
1ffcac1b07 [RISCV][GISel] Rename ValueMappingsIdx->ValueMappingIdx. NFC
This is consistent with other targets.
2023-11-12 00:09:10 -08:00
Craig Topper
3e60693422 [RISCV][GISel] Rename PartialMappingIdx and ValueMappingsIdx to use register bank name with B suffix. NFC
PartialMappingIdx refers to an entry in the PartMappings table that
includes a RegBank and a size. So I think the PartialMappingIdx should
be named using the name of the register bank concatenated with the size.

So the indices are now PMI_GPRB32, PMI_GPRB64, PMI_FPRB32, PMI_FPRB64.
2023-11-12 00:09:01 -08:00
Craig Topper
8c53cfd351 [RISCV][GISel] Rename register bank tablegen records to include B suffix to match the MIR name. NFC
GPRRegBank -> GPRBRegBank
FPRRegBank -> FPRBRegBank
2023-11-11 23:14:16 -08:00
Nathan Ridge
cee598720f
[clangd] Correctly identify the next token after the completion point (#69153)
The code was previously using Lexer::findNextToken() which does not
handle being passed the completion point as input.

Fixes https://github.com/clangd/clangd/issues/1785
2023-11-12 02:13:22 -05:00
Felix Schneider
d5a0fb39ae
[mlir][vector] Handle empty MaskOp in LowerVectorMask, MaskOpRewritePattern (#72031)
This patch adds handling of an empty `MaskOp` to `MaskOpRewritePattern`
and thereby fixes a crash.
It also pulls the `MaskOp` canonicalization patterns into
`LowerVectorMask` so that empty `MaskOp`s are folded away in the Pass.

Fix https://github.com/llvm/llvm-project/issues/71036
2023-11-12 08:12:28 +01:00
Kazu Hirata
fcb160eabc [llvm] Stop including llvm/ADT/DenseMap.h (NFC)
Identified with clangd.
2023-11-11 22:46:28 -08:00
Kazu Hirata
651c502fc8 [clang] Stop including llvm/ADT/DenseSet.h (NFC)
Identified with clangd.
2023-11-11 22:25:48 -08:00
Stella Laurenzo
0677e54653
[mlir][python] Allow contexts to be created with a custom thread pool. (#72042)
The existing initialization sequence always enables multi-threading at
MLIRContext construction time, making it impractical to provide a
customized thread pool.

Here, this is changed to always create the context with threading
disabled, process all site-specific init hooks (which can set thread
pools) and ultimately enable multi-threading unless if site-configured
to not do so.

This should preserve the existing user-visible initialization behavior
while also letting downstreams ensure that contexts are always created
with a shared thread pool. This was tested with IREE, which has such a
concept. Using site-specific thread tuning produced up to 2x single
compilation job behavior and customization of batch compilation (i.e. as
part of a build system) to utilize half the memory and run the entire
test suite ~2x faster. Given this, I believe that the additional
configurability can well pay for itself for implementations that use it.
We may also want to present user-level Python APIs for controlling
threading configuration in the future.
2023-11-11 21:41:56 -08:00
Kazu Hirata
78a05b92a8 [DependencyScanning] Include DenseMap.h instead of DenseSet.h (NFC)
DependencyScanningFilesystem.h uses DenseMap, not DenseSet.
2023-11-11 21:40:59 -08:00
Timm Bäder
8ff81deeaa [clang][Interp][NFC] Remove some redundant code
The needsRuntimeArgPop() stuff is now handled by the
cleanupAfterFunctionCall() function.
2023-11-12 06:37:51 +01:00
Timm Baeder
190b9179a5
[clang][Interp] Handle SizeOfPackExprs (#71929) 2023-11-12 05:34:16 +01:00
Aiden Grossman
688664fd19 [Github] Make code formatting action checkout SHA rather than ref
Checking out a ref of the branch requires the remote to be the same as
the fork whereas setting it to be the commit SHA allows for us to avoid
changing the remote. This should fix the action not working on PRs made
from forks (essentially all of them).
2023-11-11 20:33:03 -08:00