Mark de Wever [Thu, 20 Apr 2023 18:39:00 +0000 (20:39 +0200)]
[libc++][format] Removes vector dependency.
During the review of D140653 it was suggested to use vector in
__retarget_buffer instead of manually managing the memory. Due to the
requirements of the Standard it turns out format needs to include vector
leading to a cycle. Therefore switching back to manual memory
management.
This is a preparation to fix https://llvm.org/PR61314
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D148826
Florian Hahn [Sun, 30 Apr 2023 10:41:22 +0000 (11:41 +0100)]
[LV] Sink collect* calls to LVP::plan() (NFC).
Move calls of collect* helpers closer to where the cost-model is used.
Should help simplifying D142669 & D142670.
Differential Revision: https://reviews.llvm.org/D142674
Nuno Lopes [Sun, 30 Apr 2023 08:56:34 +0000 (09:56 +0100)]
Revert "[InstCombine] Generate better code for std::bit_floor from libstdc++"
This reverts commit
d775fc390d3c78cc81872e276c4b1314f19af577.
The patch is wrong wrt undef and the author didn't fix it after 2 weeks.
Mehdi Amini [Thu, 23 Feb 2023 05:43:45 +0000 (22:43 -0700)]
Add an action for each iteration of the GreedyPatternRewriteDriver
Differential Revision: https://reviews.llvm.org/D149101
Craig Topper [Sun, 30 Apr 2023 05:55:41 +0000 (22:55 -0700)]
[LegalizeVectorOps][RISCV] Support condition code legalization for ISD::STRICT_FSETCC/FSETCCS during LegalizeVectorOps.
Switch RISC-V to legalize during LegalizeVectorOps instead of
LegalizeDAG. LegalizeDAG uses the OpVT for legalize action while
LegalizeVectorOps uses the result VT. We really should fix that.
Craig Topper [Sun, 30 Apr 2023 04:42:45 +0000 (21:42 -0700)]
[RISCV] Prevent lowerVectorStrictFSetcc from creatin an ISD::AND with identical operands.
This AND immediately gets legalized to RISCVISD::VMAND_VL and we don't
yet have DAG combine to optimize that away. So this is a quick fix to
improve generated code.
Joshua Cao [Sat, 15 Apr 2023 23:04:58 +0000 (16:04 -0700)]
[SimpleLoopUnswitch] unswitch selects
The old LoopUnswitch pass unswitched selects, but the changes were never
ported to the new SimpleLoopUnswitch.
We unswitch by turning:
```
S = select %cond, %a, %b
```
into:
```
head:
br %cond, label %then, label %tail
then:
br label %tail
tail:
S = phi [ %a, %then ], [ %b, %head ]
```
Unswitch selects are always nontrivial, since the successors do not exit
the loop and the loop body always needs to be cloned.
Differential Revision: https://reviews.llvm.org/D138526
Co-authored-by: Sergey Kachkov <sergey.kachkov@syntacore.com>
Joshua Cao [Mon, 17 Apr 2023 00:25:05 +0000 (17:25 -0700)]
[SimpleLoopUnswitch] Add unswitch select tests
Sergei Barannikov [Sun, 30 Apr 2023 04:00:20 +0000 (07:00 +0300)]
[TableGen] Forward declare CodeGenRegister et al. (NFC)
LLVM GN Syncbot [Sun, 30 Apr 2023 03:41:51 +0000 (03:41 +0000)]
[gn build] Port
ebc05b93a11b
LLVM GN Syncbot [Sun, 30 Apr 2023 03:41:50 +0000 (03:41 +0000)]
[gn build] Port
8af259e8d90b
Nikolas Klauser [Sat, 14 Jan 2023 01:08:27 +0000 (02:08 +0100)]
[libc++][PSTL] Implement std::{any, all, none}_of
Reviewed By: ldionne, #libc
Spies: arichardson, libcxx-commits, miyuki
Differential Revision: https://reviews.llvm.org/D143161
Nikolas Klauser [Fri, 13 Jan 2023 21:48:23 +0000 (22:48 +0100)]
[libc++][PSTL] Implement <execution> contents
Reviewed By: ldionne, #libc
Spies: libcxx-commits, arichardson
Differential Revision: https://reviews.llvm.org/D141888
Vitaly Buka [Sun, 30 Apr 2023 02:20:41 +0000 (19:20 -0700)]
Revert "[NFC][LLD] Disambiguate RISCV and llvm::RISCV"
This reverts commit
176cc70abe8d85df9aae223e0b35ce65238c4333.
Vitaly Buka [Sun, 30 Apr 2023 02:06:18 +0000 (19:06 -0700)]
[NFC][LLD] Disambiguate RISCV and llvm::RISCV
Build is broken after
ee9cbe35.
Craig Topper [Sun, 30 Apr 2023 01:05:56 +0000 (18:05 -0700)]
Revert "[RISCV] Move RISCV::RVVBitsPerBlock from TargetParser to Support/RISCVISAInfo.h."
This reverts commit
ee9cbe3548cded885c6409d6dd8a616b515a06d3.
I've been told this cauess a namespace clash in lld.
Craig Topper [Sun, 30 Apr 2023 01:05:10 +0000 (18:05 -0700)]
[RISCV] Use TokenFactor instead of MERGE_VALUES to combine chains.
Vitaly Buka [Sun, 30 Apr 2023 00:40:33 +0000 (17:40 -0700)]
[NFC][HWASAN] Use pointercast instead of bitcast
Vitaly Buka [Sun, 30 Apr 2023 00:22:45 +0000 (17:22 -0700)]
[NFC][HWASAN] Add cont to parameter
Vitaly Buka [Sun, 30 Apr 2023 00:22:12 +0000 (17:22 -0700)]
[NFC][HWASAN] Fix comment
Vitaly Buka [Sun, 30 Apr 2023 00:14:39 +0000 (17:14 -0700)]
[NFC][HWASAN] Remove unused parameter
Ian Douglas Scott [Sat, 29 Apr 2023 23:26:17 +0000 (16:26 -0700)]
[M68k] Add instruction selection support for zext with PCD addressing
Instruction selection was failing when trying to zero extend a value
loaded from a PC-relative address. This adds support for zero extension
using the "program counter indirect with displacement" addressing mode.
It also adds a test with code that was previously failing to compile.
This fixes a compile error in Rust's libcore.
Differential Revision: https://reviews.llvm.org/D149034
Craig Topper [Sat, 29 Apr 2023 22:38:31 +0000 (15:38 -0700)]
[X86] Update some stale comments. NFC
Jakub Kuderski [Sat, 29 Apr 2023 22:34:33 +0000 (18:34 -0400)]
[mlir][vector][NFC] Update `vector.flat_transpose` description
Change the example to match how this op is actually printed. Do not use
'smart quotes' in the description.
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D149535
Craig Topper [Sat, 29 Apr 2023 22:10:29 +0000 (15:10 -0700)]
[TargetLowering] Stop passing an ISD::CondCode to isOperationLegalOrCustom.
ISD::CondCode is a separate num space from opcodes. isOperationLegalOrCustom
should take an opcode.
Reviewed By: barannikov88
Differential Revision: https://reviews.llvm.org/D149528
Craig Topper [Sat, 29 Apr 2023 22:04:52 +0000 (15:04 -0700)]
[RISCV] Move RISCV::RVVBitsPerBlock from TargetParser to Support/RISCVISAInfo.h.
RISCVTargetParser.h has a dependency on a tablegen generated file.
Using RISCVISAInfo.h instead avoids this dependency.
We just need this constant somewhere visible to the frontend and
backend and I'm trying to avoid adding a header just for it.
Craig Topper [Sat, 29 Apr 2023 20:33:02 +0000 (13:33 -0700)]
[RISCV][Sema] Add a build dependency on RISCVTargetParserTableGen after D145088.
Need to find a better home for RISCV::RVVBitsPerBlock to remove
this dependency. This just a quick fix to fix the build.
Florian Hahn [Sat, 29 Apr 2023 20:33:06 +0000 (21:33 +0100)]
[SCEV] Use object size for globals to sharpen ranges.
The highest address the object can start is ObjSize bytes before the
end (unsigned max value). If this value is not a multiple of the
alignment, the last possible start value is the next lowest multiple
of the alignment. Note: The computations cannot overflow,
because if they would there's no possible start address for the
object.
At the moment, this is limited to GlobalVariables, because I could not
find a API similar to getObjectSize to also get the alignment of the
object. With such an API, this can be generalized to general addresses.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D149483
Matt Arsenault [Sat, 29 Apr 2023 19:56:15 +0000 (15:56 -0400)]
GlobalOpt: Add some test coverage for addrspacecast treatment
David Green [Sat, 29 Apr 2023 19:32:54 +0000 (20:32 +0100)]
[ARM] Add predicated shift patterns
This uses the patterns defined in MVE_TwoOpPattern to add predicated patterns
for vshls/u instructions.
Differnetial Revision: https://reviews.llvm.org/D149366
Matt Arsenault [Sat, 29 Apr 2023 16:27:22 +0000 (12:27 -0400)]
AMDGPU: Don't need pointer bitcast in AMDGPULowerKernelArguments
Sergei Barannikov [Sat, 29 Apr 2023 18:07:04 +0000 (21:07 +0300)]
[SelectionDAG] Rename ADDCARRY/SUBCARRY to UADDO_CARRY/USUBO_CARRY (NFC)
This will make them consistent with other overflow-aware nodes.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D148196
Noah Goldstein [Sat, 29 Apr 2023 18:49:14 +0000 (13:49 -0500)]
[emacs] Highlight 'ptr' keyword as a type
Seems natural to highlight 'ptr' same as 'void', 'i1', etc...
Reviewed By: artagnon, nikic
Differential Revision: https://reviews.llvm.org/D149519
Noah Goldstein [Sat, 29 Apr 2023 16:26:33 +0000 (11:26 -0500)]
[InstCombine] Fold `(cmp eq/ne (umax X, Y),0)` -> `(cmp eq/ne (or X, Y),0)`
`or` is almost always preferable.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D149426
Noah Goldstein [Fri, 28 Apr 2023 04:52:12 +0000 (23:52 -0500)]
[InstCombine] Don't fold `uadd.sat` to `or` if it increase instruction count
In the `(cmp eq/ne (uadd.sat X, Y),0)` case, we where missing a
`hasOneUse` check.
Differential Revision: https://reviews.llvm.org/D149425
Noah Goldstein [Fri, 28 Apr 2023 04:09:05 +0000 (23:09 -0500)]
[InstCombine] Add tests `(cmp eq/ne (umax/uadd.sat X, Y), 0)`; NFC
Differential Revision: https://reviews.llvm.org/D149424
Craig Topper [Sat, 29 Apr 2023 17:06:22 +0000 (10:06 -0700)]
[TargetLowering] Don't use ISD::SELECT_CC in expandFP_TO_INT_SAT.
This function gets called for vectors and ISD::SELECT_CC was never
intended to support vectors. Some updates were made to support
it when this function started getting used for vectors.
Overall, using separate ISD::SETCC and ISD::SELECT looks like an
improvement even for scalar.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D149481
Stefan Gränitz [Sat, 29 Apr 2023 15:29:28 +0000 (17:29 +0200)]
[lldb][ObjectFileELF] Support AArch32 in ApplyRelocations
Allow the ObjectFileELF plugin to resolve R_ARM_ABS32 relocations from AArch32 object files. This fixes https://github.com/llvm/llvm-project/issues/61948
The existing architectures work with RELA-type relocation records that read addend from the relocation entry. REL-type relocations in AArch32 store addend in-place.
The new function doesn't re-use ELFRelocation::RelocAddend32(), because the interface doesn't match: in addition to the relocation entry we need the actual target section memory.
Reviewed By: labath
Differential Revision: https://reviews.llvm.org/D147642
Matt Arsenault [Sat, 29 Apr 2023 14:18:34 +0000 (10:18 -0400)]
AMDGPU: Don't need pointer bitcasts in AMDGPURewriteOutArguments
Matt Arsenault [Sat, 29 Apr 2023 14:14:30 +0000 (10:14 -0400)]
AMDGPU: Remove code to create pointer bitcasts in atomicrmw expansion
Matt Arsenault [Sat, 29 Apr 2023 14:12:11 +0000 (10:12 -0400)]
AMDGPU: Use getTypeStoreSizeInBits
Matt Arsenault [Sat, 29 Apr 2023 14:11:21 +0000 (10:11 -0400)]
AMDGPU: Don't create a pointer bitcast in AMDGPULateCodeGenPrepare
Matt Arsenault [Sat, 29 Apr 2023 14:04:06 +0000 (10:04 -0400)]
AMDGPU: Don't try to create pointer bitcasts in kernarg lowering
Matt Arsenault [Sat, 29 Apr 2023 14:01:37 +0000 (10:01 -0400)]
AMDGPU: Don't try to create pointer bitcasts in load widening
Matt Arsenault [Wed, 26 Apr 2023 19:27:54 +0000 (15:27 -0400)]
GlobalOpt: Drop code to handle typed pointers
Fixes assert with pointers with different address spaces. We
could keep looking through addrspacecast, but it would require
checking for null handling of the access address space.
Fixes #62384
Joseph Huber [Thu, 27 Apr 2023 23:29:10 +0000 (18:29 -0500)]
[libc] Add support for global ctors / dtors for AMDGPU
This patch makes the necessary changes to support calling global
constructors and destructors on the GPU. The patch in D149340 allows the
`lld` linker to create the symbols pointing us to these globals. These
should be executed by a single thread, which is more difficult on the
GPU because all threads are active. I chose to use an atomic counter to
sync every thread on the GPU. This is very slow if you use more than a
few thousand threads, but for testing purposes it should be sufficient.
Depends on D149340 D149363
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D149398
Joseph Huber [Thu, 27 Apr 2023 13:00:01 +0000 (08:00 -0500)]
[AMDGPU] Place global constructors in .init_array and .fini_array
For the GPU, we emit external kernels that call the initializers and
constructors, however if we had a persistent kernel like in the `_start`
kernel for the `libc` project, we could initialize the standard way of
calling constructors. This patch adds new global variables containing
pointers to the constructors to be called. If these are placed in the
`.init_array` and `.fini_array` sections, then the backend will handle
them specially. The linker will then provide the `__init_array_` and
`__fini_array_` sections to traverse them. An implementation would look
like this.
```
extern uintptr_t __init_array_start[];
extern uintptr_t __init_array_end[];
extern uintptr_t __fini_array_start[];
extern uintptr_t __fini_array_end[];
using InitCallback = void(int, char **, char **);
using FiniCallback = void(void);
extern "C" [[gnu::visibility("protected"), clang::amdgpu_kernel]] void
_start(int argc, char **argv, char **envp) {
uint64_t init_array_size = __init_array_end - __init_array_start;
for (uint64_t i = 0; i < init_array_size; ++i)
reinterpret_cast<InitCallback *>(__init_array_start[i])(argc, argv, env);
uint64_t fini_array_size = __fini_array_end - __fini_array_start;
for (uint64_t i = 0; i < fini_array_size; ++i)
reinterpret_cast<FiniCallback *>(__fini_array_start[i])();
}
```
Reviewed By: yaxunl
Differential Revision: https://reviews.llvm.org/D149340
Matt Arsenault [Tue, 6 Dec 2022 14:25:33 +0000 (09:25 -0500)]
LangRef: Add "dynamic" option to "denormal-fp-math"
This is stricter than the default "ieee", and should probably be the
default. This patch leaves the default alone. I can change this in a
future patch.
There are non-reversible transforms I would like to perform which are
legal under IEEE denormal handling, but illegal with flushing zero
behavior. Namely, conversions between llvm.is.fpclass and fcmp with
zeroes.
Under "ieee" handling, it is legal to translate between
llvm.is.fpclass(x, fcZero) and fcmp x, 0.
Under "preserve-sign" handling, it is legal to translate between
llvm.is.fpclass(x, fcSubnormal|fcZero) and fcmp x, 0.
I would like to compile and distribute some math library functions in
a mode where it's callable from code with and without denormals
enabled, which requires not changing the compares with denormals or
zeroes.
If an IEEE function transforms an llvm.is.fpclass call into an fcmp 0,
it is no longer possible to call the function from code with denormals
enabled, or write an optimization to move the function into a denormal
flushing mode. For the original function, if x was a denormal, the
class would evaluate to false. If the function compiled with denormal
handling was converted to or called from a preserve-sign function, the
fcmp now evaluates to true.
This could also be of use for strictfp handling, where code may be
changing the denormal mode.
Alternative name could be "unknown".
Replaces the old AMDGPU custom inlining logic with more conservative
logic which tries to permit inlining for callees with dynamic handling
and avoids inlining other mismatched modes.
Jacques Pienaar [Sat, 29 Apr 2023 12:35:53 +0000 (05:35 -0700)]
[mlir][bytecode] Allow client to specify a desired version.
Add method to set a desired bytecode file format to generate. Change
write method to be able to return status including the minimum bytecode
version needed by reader. This enables generating an older version of
the bytecode (not dialect ops, attributes or types). But this does not
guarantee that an older version can always be generated, e.g., if a
dialect uses a new encoding only available at later bytecode version.
This clamps setting to at most current version.
Differential Revision: https://reviews.llvm.org/D146555
Tom Praschan [Sat, 8 Apr 2023 12:57:34 +0000 (14:57 +0200)]
[clangd] Hover: Add CalleeArgInfo for constructor expressions
Differential Revision: https://reviews.llvm.org/D147847
NAKAMURA Takumi [Mon, 24 Apr 2023 13:59:56 +0000 (22:59 +0900)]
[CMake] Serialize `build_native_tool`
To prevent race in `NATIVE`, let each action depend on preceding action.
At the moment, this is restricted only for "Visual Studio".
For example,
- `llvm-tblgen-host` depends on the target's `llvm-tblgen`.
- `clang-tblgen-host` depends on the target's `clang-tblgen` and `llvm-tblgen-host`.
This is rework for D54153.
`build_native_tool` has been introduced since D60024.
Differential Revision: https://reviews.llvm.org/D149072
Jon Phillips [Sat, 29 Apr 2023 07:22:22 +0000 (00:22 -0700)]
[clang-format] Add BracedInitializerIndentWidth option
The option allows users to specify how many columns to use to indent
the contents of initializer lists.
Closes #51070.
Differential Revision: https://reviews.llvm.org/D146101
Luo, Yuanke [Sat, 29 Apr 2023 05:14:54 +0000 (13:14 +0800)]
[X86] Fix the vnni machine combine issue.
The previous patch (D148980) didn't set the InstrIdxForVirtReg correctly
in genAlternativeDpCodeSequence(). It causes vnni lit test failure when
LLVM_ENABLE_EXPENSIVE_CHECKS is on.
Hans Wennborg [Sat, 29 Apr 2023 05:06:16 +0000 (07:06 +0200)]
Revert "Reland D147337 "[tsan] Add debugging interfaces into interface header.""
This broke the lit tests on Mac, see comment on the code review.
> This change the types to match the ones used in:
> Darwin/debug_external.cpp
> debugging.cpp
>
> Reviewed By: vitalybuka
>
> Differential Revision: https://reviews.llvm.org/D148214
This reverts commit
ea7d6e658e37363c61d2f9ce64de0b223a39be50.
Yeting Kuo [Thu, 27 Apr 2023 07:37:39 +0000 (15:37 +0800)]
[RISCV] Disable strict node mutation and use correct lowering action of strict_fsetcc(s).
The patch disables strict node mutation by setting IsStrictFPEnabled to true.
It also fixes wrong lowering action of strict_fsetcc(s).
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D149320
NAKAMURA Takumi [Sat, 29 Apr 2023 02:31:27 +0000 (11:31 +0900)]
GOFFObjectFile.cpp: Suppress a warning in -Asserts (D98437)
Joseph Huber [Fri, 28 Apr 2023 22:44:17 +0000 (17:44 -0500)]
[libc] Fix printing on the GPU when given a `cpp::string_ref`
The implementation of the test printing currently expects a null
terminated C-string. However, the `write_to_stderr` interface uses a
string view, which doesn't need to be null terminated. This patch
changes the printing interface to directly use `fwrite` instead rather
than relying on a null terminator.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D149493
Manna, Soumi [Sat, 29 Apr 2023 01:38:07 +0000 (18:38 -0700)]
[NFC][clang] Fix static analyzer concerns about AUTO_CAUSES_COPY
Reported by Coverity:
AUTO_CAUSES_COPY
Unnecessary object copies can affect performance
1. Inside "ODRHash.cpp" file, in clang::ODRHash::AddCXXRecordDecl(clang::CXXRecordDecl const *): Using the auto keyword without an & causes the copy of an object of type CXXBaseSpecifier.
2. Inside "Tokens.cpp" file, in clang::syntax::TokenBuffer::dumpForTests[abi:cxx11](): Using the auto keyword without an & causes the copy of an object of type DenseMapPair.
3. Inside "TargetID.cpp" file, in clang::getCanonicalTargetID[abi:cxx11](llvm::StringRef, llvm::StringMap<bool, llvm::MallocAllocator> const &): Using the auto keyword without an & causes the copy of an object of type pair.
Reviewed By: tahonermann, aaron.ballman
Differential Revision: https://reviews.llvm.org/D148639
Uday Bondhugula [Sat, 29 Apr 2023 01:35:56 +0000 (07:05 +0530)]
Simplify affine bound min or max with operands
Add canonicalization for affine.for bounds to use operand info (when
operands are outer loop affine.for IVs) to simplify bounds: redundant
bound expressions are eliminated in specific cases that are easy to
check and well-suited for op canonicaliation. If the lowest or the
highest value the affine expression can take is already covered by other
constant bounds, the expression can be removed.
Eg:
`min (d0) -> (32 * d0 + 32, 32)(%i) where 0 <= %i < 2`
The first expression can't be less than 32 and can be simplified away
with a lightweight local rewrite.
This simplification being part of canonicalization only handles simple
expressions, specifically, a sum of products of operands with constants.
This is a very common and a dominant case where such simplification is
desired. These can be flattened without any local variables.
Reviewed By: dcaballe, springerm
Differential Revision: https://reviews.llvm.org/D149007
Vitaly Buka [Sat, 29 Apr 2023 01:18:31 +0000 (18:18 -0700)]
[HWASAN] Support short granules in __hwasan_test_shadow
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D149430
Vitaly Buka [Sat, 29 Apr 2023 01:31:03 +0000 (18:31 -0700)]
Revert "[HWASAN] Support short granules in __hwasan_test_shadow"
Acidentally relanded without the fix.
This reverts commit
008c3934ab6b3a6dfcbb81f6258b9e03e9b61c1c.
Vitaly Buka [Sat, 29 Apr 2023 01:18:31 +0000 (18:18 -0700)]
[HWASAN] Support short granules in __hwasan_test_shadow
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D149430
Jason Molenda [Sat, 29 Apr 2023 01:20:40 +0000 (18:20 -0700)]
Refactor and generalize AArch64 watchpoint support in debugserver
Refactor the debugserver watchpiont support in anticipating of
adding support for AArch64 MASK hardware watchpoints to watch
larger regions of memory. debugserver already had support for
handling a request to watch an unaligned region of memory up
to 8 bytes using Byte Address Select watchpoints - it would split
an unaligned watch request into two aligned doublewords that
could be watched with two hardware watchpoints using the BAS
specification.
This patch generalizes that code for properly aligning, and
possibly splitting, a watchpoint request into two hardware watchpoints
to handle any size request. And separates out the specifics
about BAS watchpoints into its own method, so a sibling method
for MASK watchpoints can be dropped in next.
Differential Revision: https://reviews.llvm.org/D149040
rdar://
108233371
Jason Molenda [Sat, 29 Apr 2023 01:18:43 +0000 (18:18 -0700)]
Remove i386 and armv7 native support in debugserver
i386 and armv7 macOS/iOS cannot be built with current Xcode
any longer; we cannot build or test the support code for running
debugserver on these targets. Remove the code.
Differential Revision: https://reviews.llvm.org/D149503
Jonas Devlieghere [Fri, 28 Apr 2023 20:36:00 +0000 (13:36 -0700)]
[lldb] Refactor host::OpenFileInExternalEditor
This patch refactors the macOS implementation of
OpenFileInExternalEditor. It fixes an AppleEvent memory leak, the
caching of LLDB_EXTERNAL_EDITOR and speculatively fixes a crash when
CFURL is NULL (rdar://
108633464). The new code also improves error
handling, readability and documents calls to the CoreFoundation Launch
Services APIs.
A bunch of the Launch Services APIs have been deprecated
(LSFindApplicationForInfo, LSOpenURLsWithRole). The preferred API is
LSOpenCFURLRef but it doesn't specifying the "location" Apple Event
which is used to highlight the current line and switching over would
regress the existing behavior.
rdar://
108633464
Differential revision: https://reviews.llvm.org/D149482
Vitaly Buka [Sat, 29 Apr 2023 00:38:11 +0000 (17:38 -0700)]
Revert "[HWASAN] Support short granules in __hwasan_test_shadow"
Break internal tests, but it supposed to be almost NFC.
This reverts commit
bf12b746372a25c5a15fa9bd452bd469cc047b47.
Craig Topper [Fri, 28 Apr 2023 23:52:55 +0000 (16:52 -0700)]
[RISCV] Add a DAG combine to fold (add (xor (setcc X, Y), 1) -1)->(neg (setcc X, Y)).
Mahesh Ravishankar [Fri, 28 Apr 2023 23:45:02 +0000 (23:45 +0000)]
[mlir][Tensor] Dont drop attributes during tiling.
Reviewed By: hanchung
Differential Revision: https://reviews.llvm.org/D149120
LLVM GN Syncbot [Fri, 28 Apr 2023 23:32:00 +0000 (23:32 +0000)]
[gn build] Port
2fa6bcf02f15
Jie Fu [Fri, 28 Apr 2023 23:30:35 +0000 (07:30 +0800)]
Fix use of undeclared identifier 'EC' (NFC)
/Users/jiefu/llvm-project/llvm/lib/Object/GOFFObjectFile.cpp:199:3: error: use of undeclared identifier 'EC'
EC = ConverterEBCDIC::convertToUTF8(SymbolName, SymbolNameConverted);
^
1 error generated.
Vitaly Buka [Fri, 28 Apr 2023 22:13:52 +0000 (15:13 -0700)]
[msan] Improve handling of Intrinsic::is_fpclass after c55fffe
c55fffe replaced fcmp with fpclass.
```
declare i1 @llvm.is.fpclass(<fptype> <op>, i32 <test>)
declare <N x i1> @llvm.is.fpclass(<vector-fptype> <op>, i32 <test>)
```
Perfect fix will require checking bits of <op> corresponding to <test>
argument. For now just propagate shadow without reporting before
intrinsic. Still existing handling of fcmp is also simple OR, so it's
not making it worse.
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D149491
Vitaly Buka [Fri, 28 Apr 2023 21:52:27 +0000 (14:52 -0700)]
[msan] Precommit test for regression from c55fffe
Msan uses strict approach for unknown intrinsics like fpclass. So any
uninitialized bits in the value trigger msan report.
Yusra Syeda [Fri, 28 Apr 2023 23:08:00 +0000 (19:08 -0400)]
[SystemZ][z/OS] Add GOFFObjectFile class support for HDR, ESD and END records
This patch details the GOFF file format and implements the GOFFObjectfile class
with support for only the HDR, ESD and END GOFF records.
Reviewed By: jhenderson, kpn
Differential Revision: https://reviews.llvm.org/D98437
Neumann Hon [Fri, 28 Apr 2023 23:06:17 +0000 (19:06 -0400)]
Revert "[SystemZ][z/OS] Add GOFFObjectFile class support for HDR, ESD and END records"
This reverts commit
5b2423183cb35703723ec91ce5b93b99cec36fb2.
Neumann Hon [Fri, 28 Apr 2023 23:00:45 +0000 (19:00 -0400)]
[SystemZ][z/OS] Add GOFFObjectFile class support for HDR, ESD and END records
This patch details the GOFF file format and implements the GOFFObjectfile class
with support for only the HDR, ESD and END GOFF records.
Reviewed By: jhenderson, kpn
Differential Revision: https://reviews.llvm.org/D98437
wlei [Fri, 28 Apr 2023 22:53:47 +0000 (15:53 -0700)]
fix a use-after-free failure
Slava Zakharin [Fri, 28 Apr 2023 22:44:59 +0000 (15:44 -0700)]
[flang] Fixed branch-to-default generation for select_type.
When the default case requires block arguments, they have to be passed
through the cf.br - this piece was missing.
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D149484
Michael Jones [Fri, 28 Apr 2023 21:43:04 +0000 (14:43 -0700)]
[libc][NFC] Start cleanup of time functions
The time functions have not yet been updated to match our new coding
patterns. This patch removes some unnecessary includes, adjusts the
names of the test targets, and adds several TODO comments. It is my
intention to follow this patch up with additional cleanup.
Reviewed By: sivachandra, rtenneti
Differential Revision: https://reviews.llvm.org/D149487
Craig Topper [Fri, 28 Apr 2023 22:41:17 +0000 (15:41 -0700)]
[RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.
This allows the user to set the size of the scalable vector so they
can be used in structs and as the type of global variables. This works
by representing the type as a fixed vector instead of a scalable vector
in IR. Conversions to and from scalable vectors are made where necessary
like function arguments/returns and intrinsics.
This features has been requested here
https://github.com/riscv-non-isa/rvv-intrinsic-doc/issues/176
I know arm_sve_vector_bits is used by the Eigen library so this
could be used to port Eigen to RVV.
This patch adds a new preprocessor define `__riscv_v_fixed_vlen` that
is set when -mrvv_vector_bits is passed on the command line.
The code is largely based on the AArch64 code. A lot of code was
copy/pasted and then modiied to RVV. There may be some opportunities
for sharing.
This first patch only supports the LMUL=1 types. Additional changes
will be needed to support other LMULs. I have also not supported
mask vectors.
Differential Revision: https://reviews.llvm.org/D145088
AdityaK [Fri, 28 Apr 2023 22:29:41 +0000 (15:29 -0700)]
[NFC] check for UnreachableInst first as it is cheaper compared to getTerminatingDeoptimizeCall
Reviewers: craig.topper, aeubanks, Peter
Differential Revision: https://reviews.llvm.org/D134490
Craig Topper [Fri, 28 Apr 2023 22:08:19 +0000 (15:08 -0700)]
[RISCV] Fix spelling consition -> condition. NFC
Arthur Eubanks [Fri, 28 Apr 2023 21:32:45 +0000 (14:32 -0700)]
[gn build] Add gn flag to force enable stats
Florian Hahn [Fri, 28 Apr 2023 21:15:23 +0000 (22:15 +0100)]
[LV] Rename Preheader -> VecPreheader (NFC).
Clarify variable name as suggested in D147964 to reduce diff.
Arthur Eubanks [Fri, 28 Apr 2023 20:57:23 +0000 (13:57 -0700)]
[gn build] Remove scudo sources that no longer exist
Michael Jones [Thu, 27 Apr 2023 17:43:10 +0000 (10:43 -0700)]
[libc] add exception to atof differential fuzz
The differential fuzzer for atof found a bug in glibc's handling of
hexadecimal rounding. Since we can't easily update glibc and we want to
avoid false positives when running the fuzzer, I've added an exception
to skip all hexadecimal subnormal cases.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D149359
Vitaly Buka [Fri, 28 Apr 2023 07:31:29 +0000 (00:31 -0700)]
[HWASAN] Support short granules in __hwasan_test_shadow
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D149430
Teresa Johnson [Fri, 28 Apr 2023 16:37:32 +0000 (09:37 -0700)]
[MemProf] Use updated version of hot/cold operator new
Switch to the just updated versions of the API in tcmalloc that change
the name of the hot cold paramter to a reserved identifier __hot_cold_t.
This was based on feedback from Richard Smith, as I also need to add
some follow-on handling to clang so they are annotated properly.
Differential Revision: https://reviews.llvm.org/D149475
Jakub Kuderski [Fri, 28 Apr 2023 20:17:43 +0000 (16:17 -0400)]
[mlir][arith] Add narrowing pattern to commute extension over insertion
This enabled more optimization opportunities by moving
zero/sign-extension closer to the use.
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D149282
wlei [Thu, 6 Apr 2023 04:21:59 +0000 (21:21 -0700)]
[SamplePGO] Stale profile matching(part 2)
Part 2 of https://reviews.llvm.org/D147456
Use callee name on IR as an anchor to match the call target/inlinee name in the profile. The advantages of this in particular:
- Different from the traditional way of encoding hash signatures to every block that would affect binary/profile size and build speed, it doesn't require any additional information for this, all the data is already in the IR and profiles.
- Effective for current nested profile layout in which once a callsite is mismatched all the inlinee's profiles are dropped.
**The input of the algorithm:**
- IR locations: the anchor is the callee name of direct callsite.
- Profile locations: the anchor is the call target name for `BodySample`s or inlinee's profile name for `CallsiteSamples`.
The two lists are populated by parsing the IR and profile and both can be generalized as a sequence of locations with an optional anchor.
For example: say location `1.2(foo)` refers to a callsite at `1.2` with callee name `foo` and `1.3` refers to a non-directcall location `1.3`.
```
// The current build source code:
int main() {
1. ...
2. foo();
3. ...
4 ...
5. ...
6. bar();
7. ...
}
```
IR locations are populated and simplified as: `[1, 2(foo), 3, 5, 6(bar), 7]`.
```
; The "stale" profile:
main:350:1
1: 1
2: 3
3: 100 foo:100
4: 2
7: 2
8: 200 bar:200
9: 30
```
Profile locations are populated and simplified as `[1, 2, 3(foo), 4, 7, 8(bar), 9]`
**Matching heuristic:**
- Match all the anchors in lexical order first.
- Match non-anchors evenly between two anchors: Split the non-anchor range, the first half is matched based on the start anchor, the second half is matched based on the end anchor.
So the example above is matched like:
```
[1, 2(foo), 3, 5, 6(bar), 7]
| | | | | |
[1, 2, 3(foo), 4, 7, 8(bar), 9]
```
3 -> 4 matching is based on anchor `foo`, 5 -> 7 matching is based on anchor `bar`.
The output mapping of matching is [2->3, 3->4, 5->7, 6->8, 7->9].
For the implementation, the anchors are saved in a map for fast look-up. The result mapping is saved into `IRToProfileLocationMap`(see https://reviews.llvm.org/D147456) and distributed to all FunctionSamples(`distributeIRToProfileLocationMap`)
**Clang-self build benchmark: **
Current build version: clang-10
The profiled version: clang-9
Results compared to a refresh profile(collected profile on clang-10) and to be fair, we invalidated new functions' profiles(both refresh and stale profile use the same profile list).
1) Regression to using refresh profile with this off : -3.93%
2) Regression to using refresh profile with this on : -1.1%
So this algorithm can recover ~72% of the regression.
**Internal(Meta) large-scale services.**
we saw one real instance of a 3 week stale profile., it delivered a ~1.8% win.
**Notes or future work:**
- Classic AutoFDO support: the current version only supports pseudo-probe, but I believe it's not hard to extend to classic line-number based AutoFDO since pseudo-probe and line-number are shared the LineLocation structure.
- The fuzzy matching is an open-ended area and there could be more heuristics to try out, but since the current version already recovers a reasonable percentage of regression(with some pseudo probe order change, it can recover close to 90%), I'm submitting the patch for review and we will try more heuristics in future.
- Profile call target name are only available when the call is hit by samples, the missing anchor might mislead the matching, this can be mitigated in llvm-profgen to generate the call target for the zero samples.
- This doesn't handle function name mismatch, we plan to solve it in future.
Reviewed By: hoy, wenlei
Differential Revision: https://reviews.llvm.org/D147545
wlei [Mon, 27 Mar 2023 18:21:24 +0000 (11:21 -0700)]
[SamplePGO] Stale profile matching(part 1)
AutoFDO/CSSPGO often has to deal with stale profiles collected on binaries built from several revisions behind release. It’s likely to get incorrect profile annotations using the stale profile, which results in unstable or low performing binaries. Currently for source location based profile, once a code change causes a profile mismatch, all the locations afterward are mismatched, the affected samples or inlining info are lost. If we can provide a matching framework to reuse parts of the mismatched profile - aka incremental PGO, it will make PGO more stable, also increase the optimization coverage and boost the performance of binary.
This patch is the part 1 of stale profile matching, summary of the implementation:
- Added a structure for the matching result:`LocToLocMap`, which is a location to location map meaning the location of current build is matched to the location of the previous build(to be used to query the “stale” profile).
- In order to use the matching results for sample query, we need to pass them to all the location queries. For code cleanliness, we added a new pointer field(`IRToProfileLocationMap`) to `FunctionSamples`.
- Added a wrapper(`mapIRLocToProfileLoc`) for the query to the location, the location from input IR will be remapped to the matched profile location.
- Added a new switch `--salvage-stale-profile`.
- Some refactoring for the staleness detection.
Test case is in part 2 with the matching algorithm.
Reviewed By: wenlei
Differential Revision: https://reviews.llvm.org/D147456
Med Ismail Bennani [Fri, 28 Apr 2023 19:50:02 +0000 (12:50 -0700)]
[lldb/crashlog] Fix JSON ObjectFile module loading issue
In
27f27d15f6c9, we added a new way to use textual (JSON) object files
and symbol files with the interactive crashlog command, using the
inlined symbols from the crash report.
However, there was a missing piece after successfully adding the textual
module to the target, we didn't mark it as available causing the module
loading to exit early.
This patch addresses that issue by marking the module as available when
added successfully to the target.
Differential Revision: https://reviews.llvm.org/D149477
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Florian Hahn [Fri, 28 Apr 2023 19:41:09 +0000 (20:41 +0100)]
[IndVars] Add test for simplifying a induction cmp against global.
Vasileios Porpodas [Thu, 27 Apr 2023 21:54:34 +0000 (14:54 -0700)]
[NFC][SLP] Cleanup: Replace Value* operand with Instruction* in `vectorizeRootInstruction()` and `vectorizeHorReduction()`
This makes it explicit that these functions work with instructions, and avoids
calling them if the operand is not an instruction.
Differential Revision: https://reviews.llvm.org/D149465
Louis Dionne [Thu, 27 Apr 2023 17:54:09 +0000 (13:54 -0400)]
[libc++] Fix __verbose_abort in C++11
__use() can't be marked as constexpr in C++11 because it returns void,
which is not a literal type. But it turns out that we just don't need
to define it at all, since it's never called outside of decltype.
Differential Revision: https://reviews.llvm.org/D149360
Manna, Soumi [Fri, 28 Apr 2023 18:53:43 +0000 (11:53 -0700)]
[NFC][CLANG] Fix coverity remarks about large copy by values
Reported By Static Analyzer Tool, Coverity:
Big parameter passed by value
Copying large values is inefficient, consider passing by reference; Low, medium, and high size thresholds for detection can be adjusted.
1. Inside "CodeGenModule.cpp" file, in clang::CodeGen::CodeGenModule::EmitBackendOptionsMetadata(clang::CodeGenOptions): A very large function call parameter exceeding the high threshold is passed by value.
pass_by_value: Passing parameter CodeGenOpts of type clang::CodeGenOptions const (size 2168 bytes) by value, which exceeds the high threshold of 512 bytes.
2. Inside "SemaType.cpp" file, in IsNoDerefableChunk(clang::DeclaratorChunk): A large function call parameter exceeding the low threshold is passed by value.
pass_by_value: Passing parameter Chunk of type clang::DeclaratorChunk (size 176 bytes) by value, which exceeds the low threshold of 128 bytes.
3. Inside "CGNonTrivialStruct.cpp" file, in <unnamed>::getParamAddrs<1ull, <0ull...>>(std::integer_sequence<unsigned long long, T2...>, std::array<clang::CharUnits, T1>, clang::CodeGen::FunctionArgList, clang::CodeGen::CodeGenFunction *): A large function call parameter exceeding the low threshold is passed by value.
.i. pass_by_value: Passing parameter Args of type clang::CodeGen::FunctionArgList (size 144 bytes) by value, which exceeds the low threshold of 128 bytes.
4. Inside "CGGPUBuiltin.cpp" file, in <unnamed>::containsNonScalarVarargs(clang::CodeGen::CodeGenFunction *, clang::CodeGen::CallArgList): A very large function call parameter exceeding the high threshold is passed by value.
i. pass_by_value: Passing parameter Args of type clang::CodeGen::CallArgList (size 1176 bytes) by value, which exceeds the high threshold of 512 bytes.
Reviewed By: tahonermann
Differential Revision: https://reviews.llvm.org/D149163
Louis Dionne [Tue, 7 Feb 2023 23:21:08 +0000 (15:21 -0800)]
[libc++] Clean up pair's constructors and assignment operators
This patch makes std::pair's constructors and assignment operators
closer to conforming in C++23. The only missing bit I am aware of
now is `reference_constructs_from_temporary_v` checks, which we
don't have the tools for yet.
This patch also refactors a long-standing non-standard extension where
we'd provide constructors for tuple-like types in all standard modes. The
criteria for being a tuple-like type are different from pair-like types
as introduced recently in the standard, leading to a lot of complexity
when trying to implement recent papers that touch the pair constructors.
After this patch, the pre-C++23 extension is provided in a self-contained
block so that we can easily deprecate and eventually remove the extension
in future releases.
Differential Revision: https://reviews.llvm.org/D143914
Valentin Clement [Fri, 28 Apr 2023 18:50:47 +0000 (11:50 -0700)]
[flang][openacc][NFC] Cleanup enter data lowering
Remove copyinOperands, createOperands, createZeroOperands, attachOperands
SmallVectors as they are not used anymore.
The op itself cannot be cleanup yet because
`mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp`
still depends on it. The final clean up on the op will be down once
the translation uses the new data operand operations.
Reviewed By: vzakhari
Differential Revision: https://reviews.llvm.org/D149467
Kiran Chandramohan [Fri, 28 Apr 2023 18:37:52 +0000 (18:37 +0000)]
[Flang] Add a missing case for bfloat
A case was missed for the bfloat type in the getRealType function
in FIRBuilder. This can cause a crash in some situations like in
the provided test. The patch adds the missing case.
Reviewed By: vzakhari
Differential Revision: https://reviews.llvm.org/D149469
Shivam Gupta [Fri, 28 Apr 2023 17:59:52 +0000 (23:29 +0530)]
[Clang][Doc] Added an open project for improving command line docs
There seems to be a lot of documentation is missing
for different command line flags uses.
This create confusion with same looking options, better to
document clearly their uses.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D149405
Jakub Kuderski [Fri, 28 Apr 2023 17:48:48 +0000 (13:48 -0400)]
[mlir][arith] Add patterns to commute extension over vector extraction
This moves zero/sign-extension ops closer to their use and exposes more
narrowing optimization opportunities.
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D149233