Commit Graph

6029 Commits

Author SHA1 Message Date
Danila Malyutin ff33b6f90a [Support][AArch64] Detect a few more host CPU features on AArch64
Add detecton for lse, sve and sve2 on linux

Differential Revision: https://reviews.llvm.org/D119435
2022-03-03 09:30:02 +03:00
Aakanksha 840695814a [AMDGPU] Add gfx1036 target
Differential Revision: https://reviews.llvm.org/D120846
2022-03-02 23:26:38 +00:00
Stanislav Mekhanoshin 2e2e64df4a [AMDGPU] Add gfx940 target
This is target definition only.

Differential Revision: https://reviews.llvm.org/D120688
2022-03-02 13:54:48 -08:00
Shao-Ce SUN 0e38b29543 [RISCV] add the MC layer support of Zfinx extension
This patch added the MC layer support of Zfinx extension.

Authored-by: StephenFan
Co-Authored-by: Shao-Ce Sun

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D93298
2022-03-02 14:25:19 +08:00
Jonas Devlieghere 4429cf146e
[Support] Allow the ability to change WithColor's auto detection function
WithColor has an "auto detection mode" which looks whether the
corresponding whether the corresponding cl::opt is enabled or not. While
this is great when opting into cl::opt, it's not so great for downstream
users of this utility, which might have their own competing options to
enable or disable colors. The WithColor constructor takes a color mode,
but the big benefit of the class are its static error and warning
helpers and default error handlers.

In order to allow users of this utility to enable or disable colors
globally, this patch adds the ability to specify a global auto detection
function. By default, the auto detection function behaves the way that
it does today. The benefit of this patch lies in that it can be
overwritten. In addition to a ability to change the auto detection
function, I've also made it possible to get your hands on the default
auto detection function, so you swap it back if if you so desire.

This patch allow downstream users (like LLDB) to globally disable colors
with its own command line flag.

Differential revision: https://reviews.llvm.org/D120593
2022-02-28 20:30:06 -08:00
Jonas Devlieghere 3a167c4a90
Revert "[Support] Allow the ability to change WithColor's auto detection function"
This reverts commit a83cf7a846 because it
breaks a bunch of build bots.
2022-02-28 15:32:15 -08:00
Jonas Devlieghere a83cf7a846
[Support] Allow the ability to change WithColor's auto detection function
WithColor has an "auto detection mode" which looks whether the
corresponding whether the corresponding cl::opt is enabled or not. While
this is great when opting into cl::opt, it's not so great for downstream
users of this utility, which might have their own competing options to
enable or disable colors. The WithColor constructor takes a color mode,
but the big benefit of the class are its static error and warning
helpers and default error handlers.

In order to allow users of this utility to enable or disable colors
globally, this patch adds the ability to specify a global auto detection
function. By default, the auto detection function behaves the way that
it does today. The benefit of this patch lies in that it can be
overwritten. In addition to a ability to change the auto detection
function, I've also made it possible to get your hands on the default
auto detection function, so you swap it back if if you so desire.

This patch allow downstream users (like LLDB) to globally disable colors
with its own command line flag.

Differential revision: https://reviews.llvm.org/D120593
2022-02-28 15:03:04 -08:00
Scott Linder f3487c7be9 [YAMLParser] Add multi-line literal folding support
Last year I was working at Swift to add support for [Localization of Compiler Diagnostic Messages](https://forums.swift.org/t/localization-of-compiler-diagnostic-messages/36412/41). We are currently using YAML as the new diagnostic format. The LLVM::YAMLParser didn't have a support for multiline string literal folding and it's crucial to have that for the diagnostic message to help us keep up with the 80 columns rule. Therefore, I decided to add a multiline string literal folding support to the YAML parser.

Patch By: @HassanElDesouky (Hassan ElDesouky)

Differential Revision: https://reviews.llvm.org/D102590
2022-02-28 21:03:36 +00:00
Zi Xuan Wu 21bce9007a [Support] Add CSKY target parser and attributes parser
Construct LLVM Support module about CSKY target parser and attribute parser.
It refers CSKY ABIv2 and implementation of GNU binutils and GCC.

https://github.com/c-sky/csky-doc/blob/master/C-SKY_V2_CPU_Applications_Binary_Interface_Standards_Manual.pdf

Now we only support CSKY 800 series cpus and newer cpus in the future undering CSKYv2 ABI specification.
There are 11 archs including ck801, ck802, ck803, ck803s, ck804, ck805, ck807, ck810, ck810v, ck860, ck860v.

Every arch has base extensions, the cpus of that arch family have more extended extensions than base extensions.
We need specify extended extensions for every cpu. Every extension has its enum value, name and related llvm feature string with +/-.
Every enum value represents a bit of uint64_t integer.

Differential Revision: https://reviews.llvm.org/D119917
2022-02-28 11:35:07 +08:00
Nikita Popov c7fe6f9c92 Revert "[RISCV] add the MC layer support of Zfinx extension"
This reverts commit 7798ecca9c.

As reported in https://reviews.llvm.org/D93298#3331641 and
following, this causes assertion failures with inline assembly.
2022-02-24 12:14:31 +01:00
Ben Barham ed4f0cb878 [VFS] Use generic_category for errors generated from the VFS
Errors are generally checked in clients by comparing to the portable
error condition in `std::errc`, which will have the `generic_category`
(eg. `std::errc::no_such_file_or_directory`). While in practice these
are usually equivalent for the standard errno's, they are not in *all*
implementations. One such example is CentOS 7.

Differential Revision: https://reviews.llvm.org/D120299
2022-02-22 15:05:58 -08:00
Egor Zhdan 3a1cb36237 Add DriverKit support
This patch is the first in a series of patches to upstream the support for Apple's DriverKit. Once complete, it will allow targeting DriverKit platform with Clang similarly to AppleClang.

This code was originally authored by JF Bastien.

Differential Revision: https://reviews.llvm.org/D118046
2022-02-22 13:42:53 +00:00
Shao-Ce SUN 7798ecca9c [RISCV] add the MC layer support of Zfinx extension
This patch added the MC layer support of Zfinx extension.

Authored-by: StephenFan
Co-Authored-by: Shao-Ce Sun

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D93298
2022-02-17 21:54:13 +08:00
Nikita Popov b66b3247f5 [Support] Use posix_madvise() if available
This is a followup to D119695 using the suggestion by joerg. Rather
than manually declaring madvise() on __sun__, this uses
posix_madvise() if available, which does get declared properly on
Illumos.

Differential Revision: https://reviews.llvm.org/D119856
2022-02-16 09:36:41 +01:00
Nikita Popov 8f55cd0178 [Support] Fix build on illumos
D116366 added a call to madvise() in Path.inc. Unfortunately,
Illumos does not declare this function if _XOPEN_SOURCE is defined
(which it is by default) and we need to provide the declaration
manually. This is the same workaround used in sanitizers:
ee423d93ea/compiler-rt/lib/sanitizer_common/sanitizer_solaris.cpp (L77-L85)

Differential Revision: https://reviews.llvm.org/D119695
2022-02-15 09:42:40 +01:00
jacquesguan bfb4c0c370 [RISCV] Recover the implication between Zve* extensions and the V extension.
This revision recover the implication between Zve* extensions and the V extension.

Differential Revision: https://reviews.llvm.org/D119210
2022-02-14 15:52:07 +08:00
Adrian Prantl baac665adf Revert "[lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:"
This reverts commit b3b2538df1,
it introduced a cycklic module depenency that broke the -DLLVM_ENABLE_MODULES=1 build.
2022-02-11 13:07:23 -08:00
Peter Kasting b3b2538df1 [lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:
Makes lld-link work in a non-MSVC shell by autodetecting MSVC toolchain. Also
adds support for /winsysroot and a few other switches.

All this is done by refactoring to share code with clang-cl's existing support
for the same.

Differential Revision: https://reviews.llvm.org/D118070
2022-02-11 13:55:18 -05:00
Lu Weining 42fd2bfc90 [LoongArch 1/6] Add triples loongarch{32,64} for the upcoming LoongArch target
This is the first patch to incrementally add an MC layer for LoongArch to LLVM.
This patch also adds unit testcases for these new triples.

RFC for adding this new backend:
https://lists.llvm.org/pipermail/llvm-dev/2021-December/154371.html

Differential revision: https://reviews.llvm.org/D115857
2022-02-10 10:23:34 +00:00
Zakk Chen cfe7f69036 [RISCV][NFC] Refactor RISCVISAInfo.
1. Remove computeDefaultABIFromArch and add computeDefaultABI in
RISCVISAInfo.
2. Add parseFeatureBits which may used in D118333.

Differential Revision: https://reviews.llvm.org/D119250
2022-02-08 18:37:43 -08:00
Andy Yankovsky 3df88ec335 [Support] Don't print stacktrace if DbgHelp.dll hasn't been loaded yet
On Windows certain function from `Signals.h` require that `DbgHelp.dll` is loaded. This typically happens when the main program calls `llvm::InitLLVM`, however in some cases main program doesn't do that (e.g. when the application is using LLDB via `liblldb.dll`). This patch adds a safe guard to prevent crashes. More discussion in
https://reviews.llvm.org/D119009.

Reviewed By: aganea

Differential Revision: https://reviews.llvm.org/D119181
2022-02-08 16:37:36 +00:00
Nathan Sidwell 704b21cb4f [demangler] Remove StdQualifiedName
The StdQualifiedName node class is used for names exactly in the std
namespace.  It is not used for nested names that descend further --
those use a NestedName with NameType("std") as the scope.
Representing the compression scheme in the node graph is layer
breaking.  We can use the same structure for those exactly in std too,
and reduce code size a bit.

Reviewed By: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D118249
2022-02-07 07:49:30 -08:00
Kazu Hirata 3a3cb929ab [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
Simon Pilgrim 94453952fc [KnownBits] Add support for X*X self-multiplication (update)
Rename the SelfMultiply argument to make it clearer that the argument must not be undef

Differential Revision: https://reviews.llvm.org/D108992
2022-02-06 19:40:08 +00:00
Simon Pilgrim 1b27940a11 Revert rG7275de7fb2f087871611d037d1b529b226dd0521 "[AArch64] translateLocChar - silence dead code warning"
Seems to cause some buildbot misbehaviour (+ there's a dumb copy+paste typo in the commit message....)
2022-02-06 17:19:23 +00:00
Simon Pilgrim 7275de7fb2 [AArch64] translateLocChar - silence dead code warning
Remove default case from switch and return None after the switch()
2022-02-06 16:32:16 +00:00
Simon Pilgrim 20e212197a [Support] Use llvm_unreachable instead of LLVM_BUILTIN_UNREACHABLE internal define 2022-02-06 16:26:00 +00:00
Dawid Jurczak 39ceea26c5 [NFC] Move FoldingSetNodeIDRef::ComputeHash and FoldingSetNodeID::ComputeHash definitions to header
Lack of ComputeHash inlining slows down slightly FoldingSetBase::FindNodeOrInsertPos calls.
Inlining makes it faster which matters in particular for FoldingSet users in ASTContext.

Extracted from: https://reviews.llvm.org/D118385

Differential Revision: https://reviews.llvm.org/D118612
2022-02-04 18:03:42 +01:00
Miod Vallat 877c84acd4 [Support] unsafe pointer arithmetic in llvm_regcomp()
regcomp.c uses the "start + count < end" idiom to check that there are
"count" bytes available in an array of char "start" and "end" both point
to.

This is fine, unless "start + count" goes beyond the last element of the
array. In this case, pedantic interpretation of the C standard makes
the comparison of such a pointer against "end" undefined, and optimizers
from hell will happily remove as much code as possible because of this.

An example of this occurs in regcomp.c's bothcases(), which defines
bracket[3], sets "next" to "bracket" and "end" to "bracket + 2". Then it
invokes p_bracket(), which starts with "if (p->next + 5 < p->end)"...

Because bothcases() and p_bracket() are static functions in regcomp.c,
there is a real risk of miscompilation if aggressive inlining happens.

The following diff rewrites the "start + count < end" constructs into
"end - start > count". Assuming "end" and "start" are always pointing in
the array (such as "bracket[3]" above), "end - start" is well-defined
and can be compared without trouble.

As a bonus, MORE2() implies MORE() therefore SEETWO() can be simplified
a bit.

Bug report: https://github.com/llvm/llvm-project/issues/47993

Reviewed By: MaskRay, vitalybuka

Differential Revision: https://reviews.llvm.org/D97129
2022-02-03 19:59:27 -05:00
Ben Barham a5cff6af1d [VFS] Add back setFallthrough for downstream users
This fixes lldb's build. We can remove this in the future if we want but
for now this will be nicer to existing consumers.
2022-02-03 13:46:18 -08:00
Ben Barham 502f14d6f2 [VFS] Add a "redirecting-with" field to overlays
Extend "fallthrough" to allow a third option: "fallback". Fallthrough
allows the original path to used if the redirected (or mapped) path
fails. Fallback is the reverse of this, ie. use the original path and
fallback to the mapped path otherwise.

While this result *can* be achieved today using multiple overlays, this
adds a much more intuitive option. As an example, take two directories
"A" and "B". We would like files from "A" to be used, unless they don't
exist, in which case the VFS should fallback to those in "B".

With the current fallthrough option this is possible by adding two
overlays: one mapping from A -> B and another mapping from B -> A. Since
the frontend *nests* the two RedirectingFileSystems, the result will
be that "A" is mapped to "B" and back to "A", unless it isn't in "A" in
which case it fallsthrough to "B" (or fails if it exists in neither).

Using "fallback" semantics allows a single overlay instead: one mapping
from "A" to "B" but only using that mapping if the operation in "A"
fails first.

"redirect-only" is used to represent the current "fallthrough: false"
case.

Differential Revision: https://reviews.llvm.org/D117937
2022-02-03 13:10:23 -08:00
Dawid Jurczak f5e1ace9b0 [NFC] Move FoldingSetNodeID::AddInteger and FoldingSetNodeID::AddPointer definitions to header
Lack of AddInteger/AddPointer inlining slows down NodeEquals/Profile/:operator== calls.
Inlining makes FunctionProtoTypes/PointerTypes/ElaboratedTypes/ParenTypes Profile functions faster
but since NodeEquals is still called indirectly through function pointer from FindNodeOrInsertPos
there is room for further inlining improvements.

Extracted from: https://reviews.llvm.org/D118385

Differential Revision: https://reviews.llvm.org/D118610
2022-02-03 15:34:49 +01:00
Shao-Ce SUN 005fd8aa70 [RISCV] Add support for Zihintpause extention
Add support for the 'pause' hint instruction as an alias for
'fence w, 0'. To do this allow the 'fence' operands pred and succ
to be set to 0 (the empty set). This will also allow future hints
to be encoded as 'fence 0, <x>' and 'fence <x>, 0'.

This patch revised from @mundaym's D93019.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D117789
2022-02-03 20:55:47 +08:00
Simon Pilgrim 6440197ba5 TrigramIndex.h - move unnecessary StringRef include down to TrigramIndex.cpp 2022-02-02 16:29:47 +00:00
Simon Pilgrim aedea002b4 Signposts.h - move unnecessary StringRef include down to Signposts.cpp 2022-02-02 15:36:00 +00:00
Craig Topper 2f023b9455 [RISCV] Don't make it an error have Zve* and V at the same time.
This should not be an error. V is a valid implementation of Zve.

Spec clarified here
9a877e8553

Differential Revision: https://reviews.llvm.org/D118679
2022-02-01 07:16:20 -08:00
Shao-Ce SUN a2a7fc7ea5 [RISCV] Adjust some comments. 2022-02-01 22:53:54 +08:00
Adrian Prantl 2afc8be2fa Work around a Clang modules build issue.
See:
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/40636/consoleFull#-39956214149ba4694-19c4-4d7e-bec5-911270d8a58c

```
llvm/lib/Support/Valgrind.cpp:37:63: error: missing '#include <stddef.h>'; 'size_t' must be declared before it is used
void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) {
                                                              ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/include/stddef.h:46:23: note: declaration here is not visible
typedef __SIZE_TYPE__ size_t;
                      ^
1 error generated.
```

rdar://88049280
2022-01-31 12:03:00 -08:00
Chris Bieneman 9f4f729207 [NFC] Fix build when LLVM_DEFAULT_TARGET_TRIPLE=""
We do support building with a default target unspecified. This fixes
two small build issues that prevented LLVM's unit tests from building
and libSupport from building on Windows.
2022-01-31 13:31:55 -06:00
Craig Topper aae947e860 [RISCV] Separate the Zfhmin and Zfh extensions.
The spec doesn't seem to be written as if Zfh implies Zfhmin. They
seem to be separate extensions.

This patch moves the instructions from Zfhmin to be enabled with
either the Zfh or Zfhmin extensions.

Reviewed By: achieveartificialintelligence

Differential Revision: https://reviews.llvm.org/D118581
2022-01-31 09:06:43 -08:00
Craig Topper 20875fe8a5 [RISCV] Make Zfhmin in march imply F.
Zfhmin should imply F just like Zfh.

Reviewed By: achieveartificialintelligence

Differential Revision: https://reviews.llvm.org/D118578
2022-01-31 09:06:43 -08:00
Ties Stuij 6b1e844b69 [ARM] Add Cortex-X1C Support for Clang and LLVM
This patch upstreams support for the Arm-v8 Cortex-X1C processor for AArch64 and
ARM.

For more information, see:
- https://community.arm.com/arm-community-blogs/b/announcements/posts/arm-cortex-x1c
- https://developer.arm.com/documentation/101968/0002/Functional-description/Technical-overview/Components

The following people contributed to this patch:
- Simon Tatham
- Ties Stuij

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D117202
2022-01-31 14:23:35 +00:00
eopXD 5f856c5b30 [NFC][RISCV] Bundle up ISAInfo updates and checks
Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D118334
2022-01-28 07:13:24 -08:00
serge-sans-paille 5b3b008cf0 Move llvm::array_lenghtof to llvm/ADT/STLArrayExtras.h
This moves the dependency of several files on include/llvm/ADT/STLExtras.h to
the much shorter llvm/ADT/STLArrayExtras.h

Differential Revision: https://reviews.llvm.org/D118342
2022-01-28 11:50:49 +01:00
Craig Topper 39057240f5 [RISCV] Use std::map::count != 0 instead of std::map::count == 1. NFC
Maps always return 0 or 1 for count. Comparing to 0 can create
simpler compiled code.

Someday we'll get to use std::map::contains.
2022-01-27 12:16:42 -08:00
Craig Topper 886dd11795 [RISCV] Use const reference when looping over Exts in RISCVISAInfo.
Exts is a map of keyed by std::string with a extension info as
a value. Making copies of this wouldn't be cheap.

We had a mix of references and copies. This makes everything
consistently use a const reference to make it clear we aren't
modifying it.

Differential Revision: https://reviews.llvm.org/D118326
2022-01-27 09:24:24 -08:00
Shezan Baig 659bf6d08c [Support] [Windows] Don't cancel delete if we failed to set delete
Following up on commit 177176f75c, if we
failed to setDeleteDisposition(true) during TempFile creation, then
don't try to setDeleteDisposition(false) during TempFile::keep, since it
will likely fail as well.

Instead of letting TempFile::keep just fail, we should let it go ahead
and try renaming the file.

This fixes an issue we are seeing when running clang-cl.exe through the
Incredibuild distributed build system.  We're seeing that renaming
temporary object files would fail here:
5c1f7b296a/clang/lib/Frontend/CompilerInstance.cpp (L789)

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D118212
2022-01-27 13:58:25 +02:00
Craig Topper 7e73fd95a0 [RISCV] Minor code cleanups in RISCVISAInfo. NFCI
Pass StringRef by value instead of const reference.

Replace if () llvm_unreachable with an assert.

Replace size() == 0 with empty()
2022-01-26 13:35:40 -08:00
Benjamin Kramer f15014ff54 Revert "Rename llvm::array_lengthof into llvm::size to match std::size from C++17"
This reverts commit ef82063207.

- It conflicts with the existing llvm::size in STLExtras, which will now
  never be called.
- Calling it without llvm:: breaks C++17 compat
2022-01-26 16:55:53 +01:00
serge-sans-paille ef82063207 Rename llvm::array_lengthof into llvm::size to match std::size from C++17
As a conquence move llvm::array_lengthof from STLExtras.h to
STLForwardCompat.h (which is included by STLExtras.h so no build
breakage expected).
2022-01-26 16:17:45 +01:00
Abhina Sreeskantharajan 360af60e17 [SystemZ][z/OS] Add AutoConvert.h header to MemoryBuffer.cpp
This commit 75e164f61d removed the AutoConvert.h header causing a build break on z/OS. This patch adds it back to fix it.

Reviewed By: zibi

Differential Revision: https://reviews.llvm.org/D118129
2022-01-26 09:02:29 -05:00
serge-sans-paille 0984aa70da Fix conditional include in ThreadPool
Should fix  https://lab.llvm.org/buildbot#builders/37/builds/10259
2022-01-26 14:16:01 +01:00
Jan Svoboda aa33688cad [llvm][support] Replace `std::vector<bool>` use in YAMLTraits
LLVM Programmer’s Manual strongly discourages the use of `std::vector<bool>` and suggests `llvm::BitVector` as a possible replacement.

This patch replaces the use of `std::vector` with `llvm::BitVector` in LLVM's YAML traits and replaces the call to `Vec.insert(Vec.begin(), N, false)` on empty `Vec` with `Vec.resize(N)`, which has the same semantics but avoids using `insert` and iterators, which `llvm::BitVector` doesn't possess.

Reviewed By: dexonsmith, dblaikie

Differential Revision: https://reviews.llvm.org/D118111
2022-01-26 11:20:18 +01:00
serge-sans-paille 66c602be25 [NFC] Additional header dependency cleanup LLVMSupport
A few more forward-declarations, a few less headers. the impact on number of
preprocessed lines for LLVMSupport is negligible (-3K lines) but it's always
good to remove dependencies.

Related discourse thread: https://llvm.discourse.group/t/include-what-you-use-include-cleanup
2022-01-26 11:16:15 +01:00
serge-sans-paille 7c02776567 Fix edb02d8c5df36bb375df7171b4ba61635564dfb4 2022-01-26 11:08:42 +01:00
serge-sans-paille c1b653bfa1 [NFC] Use an llvm::DenseMap instead of std::map in CategorizedHelpPrinter::printOptions
It's a recommit of 6427f4c52c (patch included)
2022-01-26 10:32:57 +01:00
Nico Weber a676bdb5d6 Revert "[NFC] Use an llvm::DenseMap instead of std::map in CategorizedHelpPrinter::printOptions"
This reverts commit 6427f4c52c.
Breaks a bunch of tests, see e.g. http://45.33.8.238/linux/66340/step_7.txt
or https://lab.llvm.org/buildbot/#/builders/139/builds/16807
2022-01-25 16:36:38 -05:00
Nico Weber 1c82fdb3d1 Revert "Fix build issue in assert mode introduced by 6427f4c52c31cc36004"
This reverts commit d65a3b3265.
Breaks build everywhere, see e.g. http://45.33.8.238/linux/66344/step_4.txt
or https://lab.llvm.org/buildbot/#/builders/139/builds/16811
2022-01-25 16:35:33 -05:00
serge-sans-paille d65a3b3265 Fix build issue in assert mode introduced by 6427f4c52c
After 6427f4c52c, one should use SortedCategories to check category
validity.
2022-01-25 22:27:26 +01:00
serge-sans-paille 6427f4c52c [NFC] Use an llvm::DenseMap instead of std::map in CategorizedHelpPrinter::printOptions 2022-01-25 21:51:13 +01:00
Benjamin Kramer ce5b04cc04 [Support] #include <new> for std::align_val_t
This is only used when aligned new is enabled.
2022-01-25 19:40:00 +01:00
serge-sans-paille 5f290c090a Move STLFunctionalExtras out of STLExtras
Only using that change in StringRef already decreases the number of
preoprocessed lines from 7837621 to 7776151 for LLVMSupport

Perhaps more interestingly, it shows that many files were relying on the
inclusion of StringRef.h to have the declaration from STLExtras.h. This
patch tries hard to patch relevant part of llvm-project impacted by this
hidden dependency removal.

Potential impact:
- "llvm/ADT/StringRef.h" no longer includes <memory>,
  "llvm/ADT/Optional.h" nor "llvm/ADT/STLExtras.h"

Related Discourse thread:
https://llvm.discourse.group/t/include-what-you-use-include-cleanup/5831
2022-01-24 14:13:21 +01:00
SForeKeeper 70f83f3084 [RISCV] add support for zbkx subextension in MC layer.
This patch adds support for zbkx extension from K extension(v1.0.0) in MC layer.
Instructions with same functionality and same encoding is defined in the bitmanip extension.
It defines {Xperm8, Xperm4} as instruction aliases for xperm.* in Zbp extension. When Zbkx is enabled while Zbp is not, xperm.h will not be available. When Zbkx and Zbp are both enabled, the instructions will be decoded in Zbp format.

[[ https://reviews.llvm.org/D94999 | D94999 ]] this is the patch that introduces xperm.* instructions.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D117889
2022-01-24 20:38:46 +08:00
jacquesguan ba16e3c31f [RISCV] Decouple Zve* extensions and the V extension.
According to the spec, there are some difference between V and Zve64d. For example, the vmulh integer multiply variants that return the high word of the product (vmulh.vv, vmulh.vx, vmulhu.vv, vmulhu.vx, vmulhsu.vv, vmulhsu.vx) are not included for EEW=64 in Zve64*, but V extension does support these instructions. So we should decouple Zve* extensions and the V extension.

Differential Revision: https://reviews.llvm.org/D117854
2022-01-24 14:55:21 +08:00
Wu Xinlong e29d8fb169 [RISCV] Initially support the K-extension instructions on the LLVM MC layer
This commit is currently implementing supports for scalar cryptography extension for LLVM according to version v1.0.0 of [K Ext specification](https://github.com/riscv/riscv-crypto/releases)(scala crypto has been ratified already). Currently, we are implementing the MC (Machine Code) layer of his extension and the majority of work is done under `llvm/lib/Target/RISCV` directory. There are also some test files in `llvm/test/MC/RISCV` directory.

Remove the subfeature of Zbk* which conflict with b extensions to reduce the size of the patch.
(Zbk* will be resubmit after this patch has been merged)

**Co-author:**@ksyx & @VincentWu & @lihongliang & @achieveartificialintelligence

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D98136
2022-01-24 14:45:35 +08:00
Fangrui Song 8e382ae91b [Support] Simplify parallelForEach{,N}
* Merge parallel_for_each into parallelForEach (this removes 1 `Fn(...)` call)
* Change parallelForEach to use parallelForEachN
* Move parallelForEachN into Parallel.cpp

My x86-64 `lld` executable is 100KiB smaller.
No noticeable difference in performance.

Reviewed By: lattner

Differential Revision: https://reviews.llvm.org/D117510
2022-01-23 10:35:44 -08:00
eopXD 3cf15af2da [RISCV] Remove experimental prefix from rvv-related extensions.
Extensions affected: +v, +zve*, +zvl*

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D117860
2022-01-22 20:18:40 -08:00
Alex Fan e796eaf2af [RISCV][RFC] add MC support for zbkc subextension
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D117874
2022-01-22 10:23:01 +08:00
Mitch Phillips 1613f8b8d7 NFC (build fix): Add header for llvm::errs().
Looks like e9211e0393 unfortunately broke the sanitizer build bots,
because those bots compile the symbolizer with DLLVM_ENABLE_THREADS=Off.
Likely, before the patch, this header was transitively included.
2022-01-21 16:22:29 -08:00
serge-sans-paille e9211e0393 Remove dependency from raw_ostream on <chrono>
The tryLockFor method from raw_fd_sotreamis the sole user of that
header, and it's not referenced in the mono repo. I still chose to keep
it (may be useful for downstream user) but added a transient type that's
forward declared to hold the duration parameter.

Notable changes:

- "llvm/Support/Duration.h" must be included in order to use tryLockFor.
- "llvm/Support/raw_ostream.h" no longer includes <chrono>

This sole change has an interesting impact on the number of processed
line, as measured by:

clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/Support/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l

before: 7917500
after:  7835142

Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup/5831
2022-01-21 15:17:39 +01:00
serge-sans-paille 7e3bcae506 Add apple-specific missing header in Support/GraphWriter.cpp 2022-01-21 14:59:30 +01:00
serge-sans-paille 2a9e33db4f Add ms-specific missing header in Support/InitLLVM.cpp 2022-01-21 14:28:47 +01:00
serge-sans-paille 51c53a0791 Add apple-specific missing include 2022-01-21 14:18:29 +01:00
serge-sans-paille 75e164f61d [llvm] Cleanup header dependencies in ADT and Support
The cleanup was manual, but assisted by "include-what-you-use". It consists in

1. Removing unused forward declaration. No impact expected.
2. Removing unused headers in .cpp files. No impact expected.
3. Removing unused headers in .h files. This removes implicit dependencies and
   is generally considered a good thing, but this may break downstream builds.
   I've updated llvm, clang, lld, lldb and mlir deps, and included a list of the
   modification in the second part of the commit.
4. Replacing header inclusion by forward declaration. This has the same impact
   as 3.

Notable changes:

- llvm/Support/TargetParser.h no longer includes llvm/Support/AArch64TargetParser.h nor llvm/Support/ARMTargetParser.h
- llvm/Support/TypeSize.h no longer includes llvm/Support/WithColor.h
- llvm/Support/YAMLTraits.h no longer includes llvm/Support/Regex.h
- llvm/ADT/SmallVector.h no longer includes llvm/Support/MemAlloc.h nor llvm/Support/ErrorHandling.h

You may need to add some of these headers in your compilation units, if needs be.

As an hint to the impact of the cleanup, running

clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/Support/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l

before: 8000919 lines
after:  7917500 lines

Reduced dependencies also helps incremental rebuilds and is more ccache
friendly, something not shown by the above metric :-)

Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup/5831
2022-01-21 13:54:49 +01:00
eopXD e6de53b4de [RISCV] Bump rvv-related extensions from 0.10 to 1.0
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D112987
2022-01-20 23:22:20 -08:00
Wu Xinlong 7ee1c162cc [RISCV][RFC] add inst support of zbkb
This commit add instructions supports of `zbkb` which defined in scalar cryptography extension version v1.0.0 (has been ratified already).

Most of the zbkb directives reuse parts of the zbp and zbb directives, so this patch just modified some of the inst aliases and predicates.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D117640
2022-01-21 11:49:36 +08:00
Craig Topper 7a275dc354 [RISCV] Remove Zvlsseg extension.
This string no longer appears in the Vector Extension specification.
The segment load/store instructions are just part of the vector
instruction set.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D117724
2022-01-20 12:40:07 -08:00
Daniel Thornburgh 6b92bb4790 [Support] [DebugInfo] Lazily create cache dir.
This change defers creating Support/Caching.cpp's cache directory until
it actually writes to the cache.

This allows using Caching library in a read-only fashion. If read-only,
the cache is guaranteed not to write to disk. This keeps tools using
DebugInfod (currently llvm-symbolizer) hermetic when not configured to
perform remote lookups.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D117589
2022-01-20 19:27:15 +00:00
Jan Svoboda 9011903e36 [llvm][vfs] Abstract in-memory node creation
The creation of in-memory VFS nodes happens in a single function that deduces what kind of node to create from the arguments. This leads to complicated if-then-else logic that's difficult to cleanly extend.

This patch abstracts away in-memory node creation via a type-erased factory function that's passed instead.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D117648
2022-01-20 15:48:02 +01:00
Jan Svoboda 9e24d14ac8 [llvm][vfs] NFC: Virtualize in-memory `getStatus`
This patch virtualizes the `getStatus` function on `InMemoryNode` in LLVM VFS. Currently, this is implemented via top-level function `getNodeStatus` that tries to cast `InMemoryNode *` into each subtype. Virtual functions seem to be the simpler solution here.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D117649
2022-01-20 15:48:02 +01:00
eopXD 60b6e73769 [RISCV] Imply extensions in RISCVTargetInfo::initFeatureMap
Under ASTContext, clang only copies the features from the options with
Target->initFeatureMap, and no implications is done there. This makes
clang_cc1 fail to imply into `zve32x` for the vector extension, and test
cases will have to add ` -target-feature +experimental-zve32x` in order
to work.

This patch fixes it.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D113336
2022-01-20 01:47:10 -08:00
eopXD 8eae99dfe5 [RISCV] Add the zve extension according to the v1.0 spec
`zve` is the new standard vector extension to specify varying degrees of
vector support for embedding processors. The `zve` extension is related
to the `zvl` extension and other updates that are added in v1.0.

According to https://github.com/riscv-non-isa/riscv-c-api-doc/pull/21,
Clang defines macro `__riscv_v_max_elen`,  `__riscv_v_max_elen_fp` for
`zve` and it can be used by applications that uses the vector extension.

Authored by: Zakk Chen <zakk.chen@sifive.com> @khchen
Co-Authored by: Eop Chen <eop.chen@sifive.com> @eopXD

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D112408
2022-01-19 23:48:28 -08:00
Richard Howell 4f61749e16 [clang] support relative roots to vfs overlays
This diff adds support for relative roots to VFS overlays. The directory root
will be made absolute from the current working directory and will be used to
determine the path style to use. This supports the use of VFS overlays with
remote build systems that might use a different working directory for each
compilation.

Reviewed By: benlangmuir

Differential Revision: https://reviews.llvm.org/D116174
2022-01-19 10:13:06 -08:00
Fangrui Song e5c944b47c [Support] Fix -Wreturn-type in LLVM_ENABLE_THREADS=OFF build after D116846 2022-01-17 12:04:30 -08:00
Mubashar Ahmad 61d547e824 [Clang][AArch64][ARM] PMUv3 Option Added
An option has been added to Clang to enable or disable
the PMU v3 architecture extension.

Differential Revision: https://reviews.llvm.org/D116748
2022-01-17 14:33:03 +00:00
Lucas Prates c84b8be516 [AArch64] clang support for Armv8.8/9.3 MOPS
This introduces clang command line support for the new Armv8.8-A and
Armv9.3-A instructions for standardising memcpy, memset and memmove
operations, which was previously introduced into LLVM in
https://reviews.llvm.org/D116157.

Patch by Lucas Prates, Tomas Matheson and Son Tuan Vu.

Differential Revision: https://reviews.llvm.org/D117271
2022-01-15 19:52:30 +00:00
eopXD 26bb1b1dab [RISCV] Add the zvl extension according to the v1.0 spec
`zvl` is the new standard vector extension that specifies the minimum vector length of the vector extension.
The `zvl` extension is related to the `zve` extension and other updates that are added in v1.0.

According to https://github.com/riscv-non-isa/riscv-c-api-doc/pull/21,
Clang defines macro `__riscv_v_min_vlen` for `zvl` and it can be used for applications that uses the vector extension.
LLVM checks whether the option `riscv-v-vector-bits-min` (if specified) matches the `zvl*` extension specified.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D108694
2022-01-14 23:01:48 -08:00
Shao-Ce SUN a0a76fee0c [RISCV] update zfh and zfhmin extention to v1.0
`zfh` and `zfhmin` have been ratified, with version 1.0.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D117098
2022-01-15 09:21:24 +08:00
Craig Topper 1e04923d21 [MachineValueType] Don't allow MVT::getVectorNumElements() to be called for scalable vectors.
Migrate the one caller that failed lit tests to use
MVT::getVectorMinNumElements directly.
2022-01-13 09:16:25 -08:00
Sander de Smalen b92102a6d7 [AArch64] Add native CPU detection for Neoverse-V1.
Map Main ID part number 0xd40 to neoverse-v1, as described in the
Neoverse-V1 Technical Reference Manual:

https://developer.arm.com/documentation/101427/0101/Register-descriptions/AArch64-system-registers/MIDR-EL1--Main-ID-Register--EL1

Differential Revision: https://reviews.llvm.org/D117207
2022-01-13 12:58:54 +00:00
Tomas Matheson 2db4cf5962 clang support for Armv8.8/9.3 HBC
This introduces clang command line support for new Armv8.8-A and
Armv9.3-A Hinted Conditional Branches feature, previously introduced
into LLVM in https://reviews.llvm.org/D116156.

Patch by Tomas Matheson and Son Tuan Vu.

Differential Revision: https://reviews.llvm.org/D116939
2022-01-12 22:07:35 +00:00
Alex Bradbury 33d008b169 [RISCV] Update recently ratified Zb{a,b,c,s} extensions to no longer be experimental
Agreed policy is that RISC-V extensions that have not yet been ratified
should be marked as experimental, and enabling them requires the use of
the -menable-experimental-extensions flag when using clang alongside the
version number. These extensions have now been ratified, so this is no
longer necessary, and the target feature names can be renamed to no
longer be prefixed with "experimental-".

Differential Revision: https://reviews.llvm.org/D117131
2022-01-12 19:33:44 +00:00
Duncan P. N. Exon Smith 345223a7be Support: Extract sys::fs::readNativeFileToEOF() from MemoryBuffer
Extract the `readNativeFile()` loop from
`MemoryBuffer::getMemoryBufferForStream()` into `readNativeFileToEOF()`
to allow reuse. The chunk size is configurable; the default of `4*4096`
is exposed as `sys::fs::DefaultReadChunkSize` to allow sizing of
SmallVectors.

There's somewhere I'd like to read a usually-small file without overhead
of a MemoryBuffer; extracting existing logic rather than duplicating it.

Differential Revision: https://reviews.llvm.org/D115397
2022-01-11 18:03:58 -08:00
Duncan P. N. Exon Smith b0492d92ad Support: Avoid SmallVector::set_size() in Unix code
Replace a `reserve()`/`set_size()` pair with `resize_for_overwrite()`
and `truncate()`. The out parameter also needs a `clear()` call on the
error path.

Differential Revision: https://reviews.llvm.org/D115389
2022-01-11 17:57:23 -08:00
Duncan P. N. Exon Smith 4d4439470e Support: Avoid SmallVector::set_size() in Windows code
Replace a few `reserve()` / `set_size()` pairs with
`resize_for_overwrite()` / `truncate()` in the platform-specific
code for Windows.

Differential Revision: https://reviews.llvm.org/D115390
2022-01-11 17:52:41 -08:00
David Green 0c7f515f88 Revert "[Clang][AArch64][ARM] PMUv3.4 Option Added"
It turns out this is conflating a few different PMU extensions. And on
Arm ended up breaking M-Profile code generation. Reverting for the
moment whilst we sort out the details.

This reverts commit d17fb46e89.
2022-01-11 12:33:53 +00:00
Hans Wennborg 0b48d0fe12 [ADT] Add an in-place version of toHex()
and use that to simplify MD5's hex string code which was previously
using a string stream, as well as Clang's
CGDebugInfo::computeChecksum().

Differential revision: https://reviews.llvm.org/D116960
2022-01-11 11:51:04 +01:00
Mubashar Ahmad d17fb46e89 [Clang][AArch64][ARM] PMUv3.4 Option Added
An option has been added to Clang to enable or disable
the PMU v3.4 architecture extension.

Differential Revision: https://reviews.llvm.org/D116748
2022-01-10 11:28:19 +00:00
Kazu Hirata 435a5a3652 [llvm] Fix bugprone argument comments (NFC)
Identified with bugprone-argument-comment.
2022-01-08 11:56:38 -08:00
John Demme d9547f410f [MLIR] Fix compilation with LLVM_ENABLE_THREADS=OFF
Currently, compiles with LLVM_ENABLE_THREADS=OFF fail due to this symbol missing. Add it but assert as calling code is (and should be) checking that threading is enabled.

Differential Revision: https://reviews.llvm.org/D116846
2022-01-08 02:21:03 +00:00
Vitaly Buka ee43259cbc Initialize output parameters
If the function returns true, it should
set all output paremeters, similar to Output::preflightElement, or we
have UB on code like:

```
void *SaveInfo;
if (io.preflightFlowElement(i, SaveInfo))
  io.postflightFlowElement(SaveInfo);
```

It's going to be detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1

Differential Revision: https://reviews.llvm.org/D116826
2022-01-07 15:21:21 -08:00
Logan Smith 7d1cd8e026 [Support] No longer require flushing raw_string_ostream
Since 65b13610a5, raw_string_ostream
has been unbuffered by default, making .flush() a no-op. This diff
formalizes this by no longer .flush()ing in the .str() method or
the destructor. .str() has been marked as "consider removing", since
its primary use case used to be making .flush()+access a one-liner,
and it also has issues such as preventing NRVO/implicit move when used
in return statements.

Differential Revision: https://reviews.llvm.org/D115421
2022-01-07 09:25:22 -08:00
Kazu Hirata 2aed08131d [llvm] Use true/false instead of 1/0 (NFC)
Identified with modernize-use-bool-literals.
2022-01-07 00:39:14 -08:00
Kevin Athey 4d06565bd8 Initialize SaveInfo in methods Output::preflightKey and Output::preflightElement.
When enabling MSAN eager mode with noundef analysis these variables were found to not be initialized in unit tests.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D116428
2022-01-05 13:13:48 -08:00
David Tenty b2f34d6af1 [AIX][z/OS][Support] Provide alternate no-op mapped_file_region::dontNeedImpl implementation
mapped_file_region::dontNeedImpl added in D116366 calls madvise, which
causes problems for z/OS and AIX.

For z/OS, we don't have either madvise, so treat this as a no-op, same
as Windows does.

For AIX, it doesn't have any effect, doesn't have a standardized
signature, and it needs certain feature test macros (i.e. _ALL_SOURCE)
we don't set by default for LLVM on AIX, so just make it a no-op too.

Differential Revision: https://reviews.llvm.org/D116603
2022-01-05 10:21:01 -05:00
Xu Mingjie b5149f4e66 [LTO] Fix assertion failed when flushing bitcode incrementally for LTO output.
In https://reviews.llvm.org/D86905, we introduce an optimization, when lld emits LLVM bitcode,
we allow bitcode writer flush data to disk early when buffered data size is above some threshold.

But when `--plugin-opt=emit-llvm` and `-o /dev/null` are used,
lld will trigger assertion `BytesRead >= 0 && static_cast<size_t>(BytesRead) == BytesFromDisk`.
When we write output to /dev/null, BytesRead is zero, but at this program point BytesFromDisk is always non-zero.

Reviewed By: stephan.yichao.zhao, MaskRay

Differential Revision: https://reviews.llvm.org/D112297
2022-01-04 21:40:23 -08:00
Kazu Hirata e5947760c2 Revert "[llvm] Remove redundant member initialization (NFC)"
This reverts commit fd4808887e.

This patch causes gcc to issue a lot of warnings like:

  warning: base class ‘class llvm::MCParsedAsmOperand’ should be
  explicitly initialized in the copy constructor [-Wextra]
2022-01-03 11:28:47 -08:00
Lucas Prates cd7f621a0a [ARM][AArch64] Introduce Armv9.3-A
This patch introduces support for targetting the Armv9.3-A architecture,
which should map to the existing Armv8.8-A extensions.

Differential Revision: https://reviews.llvm.org/D116158
2022-01-03 12:40:43 +00:00
Kazu Hirata fd4808887e [llvm] Remove redundant member initialization (NFC)
Identified with readability-redundant-member-init.
2022-01-01 16:18:18 -08:00
Simon Tatham d50072f74e [ARM] Introduce an empty "armv8.8-a" architecture.
This is the first commit in a series that implements support for
"armv8.8-a" architecture. This should contain all the necessary
boilerplate to make the 8.8-A architecture exist from LLVM and Clang's
point of view: it adds the new arch as a subtarget feature, a definition
in TargetParser, a name on the command line, an appropriate set of
predefined macros, and adds appropriate tests. The new architecture name
is supported in both AArch32 and AArch64.

However, in this commit, no actual _functionality_ is added as part of
the new architecture. If you specify -march=armv8.8a, the compiler
will accept it and set the right predefines, but generate no code any
differently.

Differential Revision: https://reviews.llvm.org/D115694
2021-12-31 16:43:53 +00:00
Jack Andersen 9d37d0ea34 [Support] Expand `<CFGDIR>` as the base directory in configuration files.
Extends response file expansion to recognize `<CFGDIR>` and expand to the
current file's directory. This makes it much easier to author clang config
files rooted in portable, potentially not-installed SDK directories.

A typical use case may be something like the following:

```
# sample_sdk.cfg
--target=sample
-isystem <CFGDIR>/include
-L <CFGDIR>/lib
-T <CFGDIR>/ldscripts/link.ld
```

Reviewed By: sepavloff

Differential Revision: https://reviews.llvm.org/D115604
2021-12-30 13:43:47 -05:00
Fangrui Song 890e8c8f7e [Support] Add MemoryBuffer::dontNeedIfMmap
On *NIX systems, this API calls madvise(MADV_DONTNEED) on read-only file mappings.
It should not be used on a writable buffer.
The API is used to implement ld.lld LTO memory saving trick (D116367).

Note: on read-only file mappings, Linux's MADV_DONTNEED semantics match POSIX
POSIX_MADV_DONTNEED and BSD systems' MADV_DONTNEED.

On Windows, VirtualAllocEx MEM_COMMIT/MEM_RESET have similar semantics
but are unfortunately not drop-in replacements. dontNeedIfMmap is currently a no-op.

Reviewed By: aganea

Differential Revision: https://reviews.llvm.org/D116366
2021-12-30 10:42:28 -08:00
Kazu Hirata 5a667c0e74 [llvm] Use nullptr instead of 0 (NFC)
Identified with modernize-use-nullptr.
2021-12-28 08:52:25 -08:00
Kazu Hirata 3cfe375ae4 Use StringRef::contains (NFC) 2021-12-24 22:05:34 -08:00
Alexandre Ganea a282ea4898 Reland - [CodeView] Emit S_OBJNAME record
Reland integrates build fixes & further review suggestions.

Thanks to @zturner for the initial S_OBJNAME patch!

Differential Revision: https://reviews.llvm.org/D43002
2021-12-21 19:02:14 -05:00
Alexandre Ganea 5bb5142e80 Revert [CodeView] Emit S_OBJNAME record
Also revert all subsequent fixes:
- abd1cbf5e5 [Clang] Disable debug-info-objname.cpp test on Unix until I sort out the issue.
- 00ec441253 [Clang] debug-info-objname.cpp test: explictly encode a x86 target when using %clang_cl to avoid falling back to a native CPU triple.
- cd407f6e52 [Clang] Fix build by restricting debug-info-objname.cpp test to x86.
2021-12-21 19:02:14 -05:00
Alexandre Ganea f44e3fbadd [CodeView] Emit S_OBJNAME record
Thanks to @zturner for the initial patch!

Differential Revision: https://reviews.llvm.org/D43002
2021-12-21 09:26:36 -05:00
Fangrui Song 98e0b2cf70 [Support] Revert posix_fallocate in resize_file
This reverts 3816c53f04 and removes follow-up
fixups.

The original intention was to show error earlier (posix_fallocate time) than
later for ld.lld but it appears to cause some problems which make it not free.

* FreeBSD ZFS: EINVAL, not too bad.
* FreeBSD UFS: according to khng "devastatingly slow on freebsd because UFS on freebsd does not have preallocation support like illumos. It zero-fills."
* NetBSD: maybe EOPNOTSUPP
* Linux tmpfs: unless tmpfs is set up to use huge pages (requires CONFIG_TRANSPARENT_HUGE_PAGECACHE=y), I can consistently demonstrate ~300ms delay for a 1.4GiB output.
* Linux ext4: I don't measure any benefit, either backed by a hard disk or by a file in tmpfs.
* The current code organization of `defined(HAVE_POSIX_FALLOCATE)` costs us a macro dispatch for AIX.

I think we should just remove it. I think if posix_fallocate ever finds demonstrable benefit,
it is likely Linux specific and will not need HAVE_POSIX_FALLOCATE, and possibly opt-in by some specific programs.

In a filesystem with CoW and compression, the ENOSPC benefit may be lost as well.

Reviewed By: khng300

Differential Revision: https://reviews.llvm.org/D115957
2021-12-20 11:16:03 -08:00
Sanjay Patel 892c731681 [Support] improve known bits analysis for leading zeros of multiply
Instead of summing leading zeros on the input operands, multiply the
max possible values of those inputs and count the leading zeros of
the result. This can give us an extra zero bit (typically in cases
where one of the operands is a known constant).

This allows folding away the remaining 'add' ops in the motivating
bug (modeled in the PhaseOrdering IR test):
https://github.com/llvm/llvm-project/issues/48399

Fixes #48399

Differential Revision: https://reviews.llvm.org/D115969
2021-12-20 09:10:50 -05:00
Shao-Ce SUN 68bc6d7cae [RISCV] Remove Zvamo Extention
Based on D111692. Zvamo is not part of the 1.0 V spec. Remove it.

Reviewed By: arcbbb

Differential Revision: https://reviews.llvm.org/D115709
2021-12-20 10:28:39 +08:00
Jan Svoboda f66803457e [clang][deps] Squash caches for original and minimized files
The minimizing and caching filesystem used by the dependency scanner keeps minimized and original files in separate caches.

This setup is not well suited for dealing with files that are sometimes minimized and sometimes not. Such files are being stat-ed and read twice, which is wasteful and also means the two versions of the file can get "out of sync".

This patch squashes the two caches together. When a file is stat-ed or read, its original contents are populated. If a file needs to be minimized, we give the minimizer the already loaded contents instead of reading the file again.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D115346
2021-12-16 09:57:21 +01:00
Logan Chien 9eb71608ee Print the sign of negative infinity
Differential Revision: https://reviews.llvm.org/D111917
2021-12-14 22:38:42 -08:00
Craig Topper 4cd6dc5adb [RISCV] Add more curly braces to constexpr array initialization to hopefully appease gcc 5.
Build bot failure found after D115668.
2021-12-14 21:44:50 -08:00
Craig Topper df44aaa50e [RISCV] Add a table for extension implications.
This a proof of concept for a suggestion I proposed in D108694.

Reviewed By: eopXD

Differential Revision: https://reviews.llvm.org/D115668
2021-12-14 09:30:13 -08:00
Kazu Hirata d2377f24e1 Ensure newlines at the end of files (NFC) 2021-12-12 11:04:44 -08:00
Kazu Hirata d395befa65 [llvm] Use range-based for loops (NFC) 2021-12-11 11:29:12 -08:00
Jayson Yan 928d17254b [llvm] Add JSONScopedPrinter class
This change adds a JSONScopedPrinter as a subclass to ScopedPrinter.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D114224
2021-12-10 18:57:33 +00:00
Zakk Chen 57b5f4b2ec [RISCV][Clang] Compute the default target-abi if it's empty.
Every generated IR has a corresponding target-abi value, so
encoding a non-empty value would improve the robustness and
correctness.

Reviewed By: asb, jrtc27, arichardson

Differential Revision: https://reviews.llvm.org/D105555
2021-12-10 08:54:23 -08:00
Kazu Hirata 3dbcccab30 [Support] Use range-based for loops (NFC) 2021-12-10 08:53:14 -08:00
eopXD a4bf1b449d [RISCV] Unify depedency check and extension implication parsing logics
Originially there are two places that does parsing - `parseArchString` and
`parseFeatures`, each with its code on dependency check and implication.
This patch extracts common parts of the two  as functions of `RISCVISAInfo`
and let them 2 use it.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D112359
2021-12-09 21:16:04 -08:00
eopXD e308b8e0c7 [RISCV] Fix arch string parsing for multi-character extensions
Current implementation can't parse extension names that contains digits
correctly (e.g. `zvl128b`). This patch fixes it.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D109215
2021-12-09 21:13:44 -08:00
Duncan P. N. Exon Smith 1131738698 Support: Avoid using SmallVector::set_size() in MemoryBuffer
Update getMemoryBufferForStream() to use `resize_for_overwrite()` and
`truncate()` instead of `reserve()` and `set_size()`.

Differential Revision: https://reviews.llvm.org/D115384
2021-12-09 18:44:40 -08:00
Duncan P. N. Exon Smith cd7bc0e010 Support: Avoid using SmallVector::set_size() in zlib
Stop using `SmallVector::set_size()` in zlib. Replace pairs of
`reserve()` / `set_size()` with `resize_for_overwrite()` and
`truncate()`.

Differential Revision: https://reviews.llvm.org/D115391
2021-12-08 16:22:37 -08:00
Duncan P. N. Exon Smith 7df1855779 Support: Avoid using SmallVector::set_size() in sys::path
Stop using `SmallVector::set_size()` in sys::path APIs. In both cases,
use `truncate()` instead.

Differential Revision: https://reviews.llvm.org/D115391
2021-12-08 16:22:37 -08:00
Sanjay Patel e9179a6a02 [Support] improve known bits analysis for multiply by power-of-2 (1 set bit)
This can be viewed as recognizing that multiply-by-power-of-2 doesn't
have a carry into the top bit of an M-bit * N-bit number.

Enhancing canonicalization of mul -> select might also handle some of
these if we were ok with increasing instruction count with casts in
some cases.

This doesn't help https://llvm.org/PR49055 , but it's a simpler
pattern that we miss.
Note: "-sccp" already gets these examples using a constant
range analysis.

Differential Revision: https://reviews.llvm.org/D114962
2021-12-08 11:50:05 -05:00
James Farrell 219672b8dd Revert "Revert "Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible.""
This reverts commit 63a6348cad.

Differential Revision: https://reviews.llvm.org/D115254
2021-12-07 23:15:21 +00:00
Noah Shutty d9941f7454 [Support] [Debuginfod] Move HTTPClient to Debuginfod library.
Following the discussion in D112753, this moves the HTTPClient from Support to Debuginfod library so that tools depending on Support do not automatically depend on Curl as well. This also removes `HTTPClient::initialize()` and `HTTPClient::cleanup()` from `InitLLVM` so these steps should be implemented by user tools instead.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D115131
2021-12-07 01:19:21 +00:00
James Farrell 63a6348cad Revert "Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible."
This reverts commit 5032467034.
2021-12-06 17:35:26 +00:00
James Farrell 5032467034 Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible.
This reverts commit 40d5eeac6c.

Differential Revision: https://reviews.llvm.org/D114885
2021-12-06 14:57:47 +00:00
Jack Andersen b66339575a [CMake] Installable find modules for terminfo and libffi
Improves cross-distro portability of LLVM cmake package by resolving paths for
terminfo and libffi via import targets.

When LLVMExports.cmake is generated for installation, it contains absolute
library paths which are likely to be a common cause of portability issues. To
mitigate this, the discovery logic for these dependencies is refactored into
find modules which get installed alongside LLVMConfig.cmake. The result is
cleaner, cmake-friendly management of these dependencies that respect the
environment of the LLVM package importer.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D114327
2021-12-05 14:46:23 -05:00
Leonard Grey 134275d994 [Support] Use final filename for Caching buffer identifier
Mach-O LLD uses the buffer identifier of the memory buffer backing an object
file to generate stabs which are used by `dsymutil` to find the object file for
dSYM generation.

When using thinLTO, these buffers are provided by the cache which initially
saves them to disk as temporary files beginning with "Thin-" but renames them
to persistent files beginning with "llvmcache-" before the buffer is provided
to the cache user.

However, the buffer is created before the file is renamed and is given the temp
file's name as an identifier. This causes the generated stabs to point to
nonexistent files.

This change names the buffer with the eventual persistent filename. I think
this is safe because failing to rename the temp file is a fatal error.

Differential Revision: https://reviews.llvm.org/D115055
2021-12-04 22:25:49 -05:00
Mehdi Amini e846971811 Split the locking of the queue and the threads vector in the ThreadPool implementation
This allows to release the QueueLock early and create Thread
independently of the queue processing.

Differential Revision: https://reviews.llvm.org/D115078
2021-12-04 04:10:24 +00:00
Mehdi Amini b28f317c81 Fix build for ThreadPool when using -DLLVM_ENABLE_THREADS=OFF
Differential Revision: https://reviews.llvm.org/D115019
2021-12-04 02:23:20 +00:00
Benoit Jacob 728b982bb2 ThreadPool: grow the pool only as needed
On my 96-core cloudtop 'machine', it seems unnecessary to always start
96 threads upfront... particularly as the ThreadPool is created even
with -mlir-disable-threading. Things like the resuling spew in GDB and
the obfuscated output of `(gdb) info threads` are my motivation here,
but it probably also doesn't hurt for at least some efficiency metrics to
avoid creating many threads upfront.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D115019
2021-12-03 21:40:36 +00:00
Noah Shutty e0b259f22c [llvm] [Support] Add CURL HTTP Client.
Provides an implementation of `HTTPClient` that wraps libcurl.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D112753
2021-12-02 20:30:59 +00:00
Kazu Hirata 262dd1e42d [llvm] Use range-based for loops (NFC) 2021-12-02 09:27:47 -08:00
Noah Shutty 170783f991 [llvm] [Support] Add HTTP Client Support library.
This patch implements a small HTTP client library consisting primarily of the `HTTPRequest`, `HTTPResponseHandler`, and `BufferedHTTPResponseHandler` classes. Unit tests of the `HTTPResponseHandler` and `BufferedHTTPResponseHandler` are included.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D112751
2021-12-01 23:54:38 +00:00
Sanjay Patel aea6b9dcee [Support] replace check with assert in known bits of mul calculation; NFC 2021-12-01 13:41:12 -05:00
Ties Stuij b430782be3 [ARM] emit PACBTI-M build attributes
This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Victor Campos
- Ties Stuij

Reviewed By: ostannard

Differential Revision: https://reviews.llvm.org/D112425
2021-12-01 11:05:29 +00:00
Ties Stuij e3b2f0226b [clang][ARM] PACBTI-M frontend support
Handle branch protection option on the commandline as well as a function
attribute. One patch for both mechanisms, as they use the same underlying
parsing mechanism.

These are recorded in a set of LLVM IR module-level attributes like we do for
AArch64 PAC/BTI (see https://reviews.llvm.org/D85649):

- command-line options are "translated" to module-level LLVM IR
  attributes (metadata).

- functions have PAC/BTI specific attributes iff the
  __attribute__((target("branch-protection=...))) was used in the function
  declaration.

- command-line option -mbranch-protection to armclang targeting Arm,
following this grammar:

branch-protection ::= "-mbranch-protection=" <protection>
protection ::=  "none" | "standard" | "bti" [ "+" <pac-ret-clause> ]
                | <pac-ret-clause> [ "+" "bti"]
pac-ret-clause ::= "pac-ret" [ "+" <pac-ret-option> ]
pac-ret-option ::= "leaf" ["+" "b-key"] | "b-key" ["+" "leaf"]

b-key is simply a placeholder to make it consistent with AArch64's
version. In Arm, however, it triggers a warning informing that b-key is
unsupported and a-key will be selected instead.

- Handle _attribute_((target(("branch-protection=..."))) for AArch32 with the
same grammer as the commandline options.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Momchil Velikov
- Victor Campos
- Ties Stuij

Reviewed By: vhscampos

Differential Revision: https://reviews.llvm.org/D112421
2021-12-01 10:37:16 +00:00