Commit Graph

95665 Commits

Author SHA1 Message Date
Sunho Kim 4191d661c7 [clang-repl] Disable execution unittests on unsupported platforms.
After the intoduction of global destructor support, there is a possiblity to run invalid instructions in the destructor of Interpreter class. Completely disable tests in platforms with failing test cases.

Differential Revision: https://reviews.llvm.org/D130786
2022-07-30 02:28:03 +09:00
Aaron Ballman d8352abd3a Diagnose use of _Noreturn on a struct/union field
C99 6.7.4p2 clarifies that a function specifier can only be used in the
declaration of a function. _Noreturn is a function specifier, so it is
a constraint violation to write it on a structure or union field, but
we missed that case.

Fixes #56800
2022-07-29 13:18:44 -04:00
Corentin Jabot ad16268f13 [Clang] Do not check for underscores in isAllowedInitiallyIDChar
isAllowedInitiallyIDChar is only used with non-ASCII codepoints,
which are handled by isAsciiIdentifierStart.
To make that clearer, remove the check for _ from
isAllowedInitiallyIDChar, and assert on ASCII - to ensure neither
_ or $ are passed to this function.

Reviewed By: tahonermann, aaron.ballman

Differential Revision: https://reviews.llvm.org/D130750
2022-07-29 17:46:38 +02:00
Erich Keane b25902736c [NFCI] Propagate MLTAL through more concepts in prep of deferred inst.
In preperation of the deferred instantation progress, this patch
propagates the multi-level template argument lists further through the
API to reduce the size of that patch.
2022-07-29 05:54:04 -07:00
Florian Hahn fbe022f189
[Libcalls] Add tests with maytrap & non-errno for math libcalls. 2022-07-29 13:45:34 +01:00
Rainer Orth bf3714884a [clang][Driver] Handle SPARC -mcpu=native etc.
To make use of SPARC support in `getHostCPUName` as implemented by D130272
<https://reviews.llvm.org/D130272>, this patch uses it to handle
`-mcpu=native` and `-mtune=native`.  To match GCC, this patch rejects
`-march` instead of silently treating it as a no-op.

Tested on `sparcv9-sun-solaris2.11` and checking that those options are
passed on as `-target-cpu` resp. `-tune-cpu` as expected.

Differential Revision: https://reviews.llvm.org/D130273
2022-07-29 09:27:09 +02:00
Rainer Orth 9b1897bbd0 [Driver] Use libatomic for 32-bit SPARC atomics support on Linux
This is the Linux/sparc64 equivalent to D118021
<https://reviews.llvm.org/D118021>, necessary to provide an external
implementation of atomics on 32-bit SPARC which LLVM cannot inline even
with `-mcpu=v9` or an equivalent default.

Tested on `sparc64-unknown-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D130569
2022-07-29 09:19:38 +02:00
Chuanqi Xu 4d9251bd78 [C++20] [Modules] Merge same concept decls in global module fragment
According to [basic.def.odr]p14, the same redeclarations in different TU
but not attached to a named module are allowed. But we didn't take care
of concept decl for this condition. This patch tries to fix this
problem.

Reviewed By: ilya-biryukov

Differention Revision: https://reviews.llvm.org/D130614
2022-07-29 10:50:27 +08:00
skc7 a35c64ce23 [Clang][Attribute] Introduce maybe_undef attribute for function arguments which accepts undef values
Add the ability to put __attribute__((maybe_undef)) on function arguments.
Clang codegen introduces a freeze instruction on the argument.

Differential Revision: https://reviews.llvm.org/D130224
2022-07-29 02:27:26 +00:00
Chris Bieneman cc47db6737 [HLSL] Add HLSLResource attribute
HLSL Resource objects will have restrictions on use and codegen
requirements. This patch is fairly minimal just adding the attribute
with no spellings since it will only be attached by the
HLSLExternalSemaSource.

Depends on D1300017.

Differential Revision: https://reviews.llvm.org/D130018
2022-07-28 20:54:51 -05:00
sstwcw 60e12068ff [clang-format] Handle Verilog attributes
Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D128709
2022-07-29 00:38:30 +00:00
sstwcw c88719483c [clang-format] Handle Verilog case statements
These statements are like switch statements in C, but without the 'case'
keyword in labels.

How labels are parsed.  In UnwrappedLineParser, the program tries to
parse a statement every time it sees a colon.  In TokenAnnotator, a
colon that isn't part of an expression is annotated as a label.

The token type `TT_GotoLabelColon` is added.  We did not include Verilog
in the name because we thought we would eventually have to fix the
problem that case labels in C can't contain ternary conditional
expressions and we would use that token type.

The style is like below.  Labels are on separate lines and indented by
default.  The linked style guide also has examples where labels and the
corresponding statements are on the same lines.  They are not supported
for now.

https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md

```
case (state_q)
  StIdle:
    state_d = StA;
  StA: begin
    state_d = StB;
  end
endcase
```

Differential Revision: https://reviews.llvm.org/D128714
2022-07-29 00:38:30 +00:00
sstwcw b67ee18e85 [clang-format] Handle Verilog user-defined primitives
Differential Revision: https://reviews.llvm.org/D128713
2022-07-29 00:38:30 +00:00
sstwcw 6db0c18b1a [clang-format] Handle Verilog modules
Now things inside hierarchies like modules and interfaces are
indented.  When the module header spans multiple lines, all except the
first line are indented as continuations.  We added the property
`IsContinuation` to mark lines that should be indented this way.

In order that the colons inside square brackets don't get labeled as
`TT_ObjCMethodExpr`, we added a check to only use this type when the
language is not Verilog.

Differential Revision: https://reviews.llvm.org/D128712
2022-07-29 00:38:30 +00:00
sstwcw 67480b360c [clang-format] Handle Verilog blocks
Now stuff inside begin-end blocks get indented.

Some tests are moved into FormatTestVerilog.Block from
FormatTestVerilog.If because they have nothing to do with if statements.

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D128711
2022-07-29 00:38:30 +00:00
sstwcw f93182a887 [clang-format] Handle Verilog numbers and operators
Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D126845
2022-07-29 00:38:29 +00:00
John Ericson cc56a5022c [clang][lld][cmake] Simplify header dirs
We don't need to recompute the list LLVMConfig.cmake provides us.

When LLVM is being built, the list is two elements long: generated headers and headers from source.

When LLVM is already built,the list is one element long: the installed header directory containing both generated and hand-written sources.

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D130553
2022-07-28 19:36:40 -04:00
Shafik Yaghmour b364535304 [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values
DR2338 clarified that it was undefined behavior to set the value outside the
range of the enumerations values for an enum without a fixed underlying type.

We should diagnose this with a constant expression context.

Differential Revision: https://reviews.llvm.org/D130058
2022-07-28 15:27:50 -07:00
Denis Fatkulin 4977fd2192 [clang-format] Missing space between trailing return type 'auto' and left brace
There's no a space symbol between  trailing return type `auto` and left brace `{`.

The simpliest examles of code to reproduce the issue:

```
[]() -> auto {}
```

and

```
auto foo() -> auto {}
```

Depends on D130299

Reviewed By: HazardyKnusperkeks, curdeius, owenpan

Differential Revision: https://reviews.llvm.org/D130417
2022-07-29 00:30:22 +03:00
Ben Langmuir 0287170140 [clang][deps] Include canonical invocation in ContextHash
The "strict context hash" is insufficient to identify module
dependencies during scanning, leading to different module build commands
being produced for a single module, and non-deterministically choosing
between them. This commit switches to hashing the canonicalized
`CompilerInvocation` of the module. By hashing the invocation we are
converting these from correctness issues to performance issues, and we
can then incrementally improve our ability to canonicalize
command-lines.

This change can cause a regression in the number of modules needed. Of
the 4 projects I tested, 3 had no regression, but 1, which was
clang+llvm itself, had a 66% regression in number of modules (4%
regression in total invocations). This is almost entirely due to
differences between -W options across targets.  Of this, 25% of the
additional modules are system modules, which we could avoid if we
canonicalized -W options when -Wsystem-headers is not present --
unfortunately this is non-trivial due to some warnings being enabled in
system headers by default. The rest of the additional modules are mostly
real differences in potential warnings, reflecting incorrect behaviour
in the current scanner.

There were also a couple of differences due to `-DFOO`
`-fmodule-ignore-macro=FOO`, which I fixed here.

Since the output paths for the module depend on its context hash, we
hash the invocation before filling in outputs, and rely on the build
system to always return the same output paths for a given module.

Note: since the scanner itself uses an implicit modules build, there can
still be non-determinism, but it will now present as different
module+hashes rather than different command-lines for the same
module+hash.

Differential Revision: https://reviews.llvm.org/D129884
2022-07-28 12:24:06 -07:00
Chris Bieneman 66eabeb65d [HLSL] Add RWBuffer default constructor
This fills out the default constructor for RWBuffer to assign the
handle with the result of __builtin_hlsl_create_handle which we can
then treat as a pointer to the resource data through the mid-level of
the compiler.

Depends on D130016

Differential Revision: https://reviews.llvm.org/D130017
2022-07-28 14:07:40 -05:00
Austin Kerbow f5b21680d1 [AMDGPU] Add amdgcn_sched_group_barrier builtin
This builtin allows the creation of custom scheduling pipelines on a per-region
basis. Like the sched_barrier builtin this is intended to be used either for
testing, in situations where the default scheduler heuristics cannot be
improved, or in critical kernels where users are trying to get performance that
is close to handwritten assembly. Obviously using these builtins will require
extra work from the kernel writer to maintain the desired behavior.

The builtin can be used to create groups of instructions called "scheduling
groups" where ordering between the groups is enforced by the scheduler.
__builtin_amdgcn_sched_group_barrier takes three parameters. The first parameter
is a mask that determines the types of instructions that you would like to
synchronize around and add to a scheduling group. These instructions will be
selected from the bottom up starting from the sched_group_barrier's location
during instruction scheduling. The second parameter is the number of matching
instructions that will be associated with this sched_group_barrier. The third
parameter is an identifier which is used to describe what other
sched_group_barriers should be synchronized with. Note that multiple
sched_group_barriers must be added in order for them to be useful since they
only synchronize with other sched_group_barriers. Only "scheduling groups" with
a matching third parameter will have any enforced ordering between them.

As an example, the code below tries to create a pipeline of 1 VMEM_READ
instruction followed by 1 VALU instruction followed by 5 MFMA instructions...
// 1 VMEM_READ
__builtin_amdgcn_sched_group_barrier(32, 1, 0)
// 1 VALU
__builtin_amdgcn_sched_group_barrier(2, 1, 0)
// 5 MFMA
__builtin_amdgcn_sched_group_barrier(8, 5, 0)
// 1 VMEM_READ
__builtin_amdgcn_sched_group_barrier(32, 1, 0)
// 3 VALU
__builtin_amdgcn_sched_group_barrier(2, 3, 0)
// 2 VMEM_WRITE
__builtin_amdgcn_sched_group_barrier(64, 2, 0)

Reviewed By: jrbyrnes

Differential Revision: https://reviews.llvm.org/D128158
2022-07-28 10:43:14 -07:00
Sunho Kim c619d4f840 [clang-repl] Support destructors of global objects.
Supports destructors of global objects by properly calling jitdylib deinitialize which calls the global dtors of ir modules.

This supersedes https://reviews.llvm.org/D127945. There was an issue when calling deinitialize on windows but it got fixed by https://reviews.llvm.org/D128037.

Reviewed By: v.g.vassilev

Differential Revision: https://reviews.llvm.org/D128589
2022-07-29 02:38:40 +09:00
Chris Bieneman fe13002bb3 [HLSL] Add __builtin_hlsl_create_handle
This is pretty straightforward, it just adds a builtin to return a
pointer to a resource handle. This maps to a dx intrinsic.

The shape of this builtin and the underlying intrinsic will likely
shift a bit as this implementation becomes more feature complete, but
this is a good basis to get started.

Depends on D128569.

Differential Revision: https://reviews.llvm.org/D130016
2022-07-28 09:16:11 -05:00
Chris Bieneman 6e56d0dbe3 Start support for HLSL `RWBuffer`
Most of the change here is fleshing out the HLSLExternalSemaSource with
builder implementations to build the builtin types. Eventually, I may
move some of this code into tablegen or a more managable declarative
file but I want to get the AST generation logic ready first.

This code adds two new types into the HLSL AST, `hlsl::Resource` and
`hlsl::RWBuffer`. The `Resource` type is just a wrapper around a handle
identifier, and is largely unused in source. It will morph a bit over
time as I work on getting the source compatability correct, but for now
it is a reasonable stand-in. The `RWBuffer` type is not ready for use.
I'm posting this change for review because it adds a lot of
infrastructure code and is testable.

There is one change to clang code outside the HLSL-specific logic here,
which addresses a behavior change introduced a long time ago in
967d438439. That change resulted in unintentionally breaking
situations where an incomplete template declaration was provided from
an AST source, and needed to be completed later by the external AST.
That situation doesn't happen in the normal AST importer flow, but can
happen when an AST source provides incomplete declarations of
templates. The solution is to annotate template specializations of
incomplete types with the HasExternalLexicalSource bit from the base
template.

Depends on D128012.

Differential Revision: https://reviews.llvm.org/D128569
2022-07-28 08:49:50 -05:00
Sunho Kim bd08f413c0 [clang-repl] Disable exception unittest on AIX.
AIX platform was not supported but it was not explicitly checked in exception test as it was excluded by isPPC() check.
2022-07-28 22:48:51 +09:00
David Green 3b09e532ee [ARM] Remove duplicate fp16 intrinsics
These vdup and vmov float16 intrinsics are being defined in both the
general section and then again in fp16 under a !aarch64 flag. The
vdup_lane intrinsics were being defined in both aarch64 and !aarch64
sections, so have been commoned.  They are defined as macros, so do not
give duplicate warnings, but removing the duplicates shouldn't alter the
available intrinsics.
2022-07-28 14:26:17 +01:00
Sunho Kim 3cc3be8fa4 [clang-repl] Add host exception support check utility flag.
Add host exception support check utility flag. This is needed to not run tests that require exception support in few buildbots that lacks related symbols for some reason.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D129242
2022-07-28 21:14:58 +09:00
Sunho Kim 72ea1a721e [ORC] Fix weak hidden symbols failure on PPC with runtimedyld
Fix "JIT session error: Symbols not found: [ DW.ref.__gxx_personality_v0 ] error" which happens when trying to use exceptions on ppc linux. To do this, it expands AutoClaimSymbols option in RTDyldObjectLinkingLayer to also claim weak symbols before they are tried to be resovled. In ppc linux, DW.ref symbols is emitted as weak hidden symbols in the later stage of MC pipeline. This means when using IRLayer (i.e. LLJIT), IRLayer will not claim responsibility for such symbols and RuntimeDyld will skip defining this symbol even though it couldn't resolve corresponding external symbol.

Reviewed By: sgraenitz

Differential Revision: https://reviews.llvm.org/D129175
2022-07-28 21:12:25 +09:00
Muhammad Usman Shahid 0cc3c184c7 Missing tautological compare warnings due to unary operators
The patch mainly focuses on the lack of warnings for
-Wtautological-compare. It works fine for positive numbers but doesn't
for negative numbers. This is because the warning explicitly checks for
an IntegerLiteral AST node, but -1 is represented by a UnaryOperator
with an IntegerLiteral sub-Expr.

For the below code we have warnings:

if (0 == (5 | x)) {}

but not for

if (0 == (-5 | x)) {}

This patch changes the analysis to not look at the AST node directly to
see if it is an IntegerLiteral, but instead attempts to evaluate the
expression to see if it is an integer constant expression. This handles
unary negation signs, but also handles all the other possible operators
as well.

Fixes #42918
Differential Revision: https://reviews.llvm.org/D130510
2022-07-28 07:45:28 -04:00
Fangrui Song 1dc26b80b8 [Driver][PowerPC] Support -mtune=
Reviewed By: #powerpc, nemanjai

Differential Revision: https://reviews.llvm.org/D130526
2022-07-28 00:34:04 -07:00
Argyrios Kyrtzidis a9ae2f2764 [ASTWriter] Replace `const std::string &OutputFile` with `StringRef OutputFile` in some of `ASTWriter` functions, NFC
This is to make it consistent with LLVM's string parameter passing convention.
2022-07-27 23:02:33 -07:00
Sridhar Gopinath f9a2f6b6ae [clang-format] Fix the return code of git-clang-format
In diff and diffstat modes, the return code is != 0 even when there are no
changes between commits. This issue can be fixed by passing --exit-code to
git-diff command that returns 0 when there are no changes and using that as
the return code for git-clang-format.

Fixes #56736.

Differential Revision: https://reviews.llvm.org/D129311
2022-07-27 21:01:24 -07:00
Chuanqi Xu fe1887da36 [NFC] [C++20] [Modules] Add tests for merging redefinitions in modules
Add tests for detecting redefinitions in C++20 modules. Some of these
may be covered by other tests. But more tests should be always good.
2022-07-28 11:32:47 +08:00
Chris Bieneman 76e951e803 [Docs] Fix column ordering on clang attribute docs
This patch just adjusts the ordering of the headings on the attribute
docs to match the order of the column content.
2022-07-27 21:36:43 -05:00
David Blaikie 4bb192b846 DebugInfo: Test vtable homing overriding ctor homing only on itanium since msvc ABI doesn't home vtables 2022-07-28 00:45:00 +00:00
David Blaikie 4e719e0f16 DebugInfo: Prefer vtable homing over ctor homing.
Vtables will be emitted in fewer places than ctors (every ctor
references the vtable, so at worst it's the same places - but at best
the type has a non-inline key function and the vtable is emitted in one
place)

Pulling this fix out of 517bbc64db which
was reverted in 4821508d4d
2022-07-28 00:07:35 +00:00
Shafik Yaghmour 28cd7f86ed Revert "[Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values"
This reverts commit a3710589f2.
2022-07-27 15:31:41 -07:00
Shafik Yaghmour a3710589f2 [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values
DR2338 clarified that it was undefined behavior to set the value outside the
range of the enumerations values for an enum without a fixed underlying type.

We should diagnose this with a constant expression context.

Differential Revision: https://reviews.llvm.org/D130058
2022-07-27 14:59:35 -07:00
Joseph Huber e27026cce1 [LinkerWrapper] Do not consume `--verbose` from the linker
Summary:
Linkers use `--verbose` to let users investigate search libraries among
other things. The linker wrapper was incorrectly not forwarding this to
the linker job. This patch simply renames this so users can still see
verbose messages from the linker if it was passed.
2022-07-27 16:06:48 -04:00
Denis Fatkulin 17fb879764 [clang-format] FIX: Misannotation 'auto' as trailing return type in lambdas
Lambdas with trailing return type 'auto' are annotated incorrectly. It causes a misformatting. The simpliest code to reproduce is:

```
auto list = {[]() -> auto { return 0; }};
```

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

Reviewed By: HazardyKnusperkeks, owenpan, curdeius

Differential Revision: https://reviews.llvm.org/D130299
2022-07-27 22:20:09 +03:00
Jacob Lambert 0f3f357e26 [clang-offload-bundler] Library-ize ClangOffloadBundler
Lifting the core functionalities of the clang-offload-bundler into a
user-facing library/API. This will allow online and JIT compilers to
bundle and unbundle files without spawning a new process.

This patch lifts the classes and functions used to implement
the clang-offload-bundler into a separate OffloadBundler.cpp,
and defines three top-level API functions in OfflaodBundler.h.
        BundleFiles()
        UnbundleFiles()
        UnbundleArchives()

This patch also introduces a Config class that locally stores the
previously global cl::opt options and arrays to allow users to call
the APIs in a multi-threaded context, and introduces an
OffloadBundler class to encapsulate the top-level API functions.

We also  lift the BundlerExecutable variable, which is specific
to the clang-offload-bundler tool, from the API, and replace
its use with an ObjcopyPath variable. This variable must be set
in order to internally call llvm-objcopy.

Finally, we move the API files from
clang/tools/clang-offload-bundler into clang/lib/Driver and
clang/include/clang/Driver.

Differential Revision: https://reviews.llvm.org/D129873
2022-07-27 11:54:38 -07:00
Eric Li 5e28923e33 [clang][dataflow][NFC] Remove last use of deprecated ctor
Use a delegating constructor to remove the last use of the deprecated
ctor of `TypeErasedDataflowAnalysis`, and then delete it.

Differential Revision: https://reviews.llvm.org/D130653
2022-07-27 14:23:35 -04:00
Quinn Pham b6cc5ddc94 [libLTO] Set data-sections by default in libLTO.
This patch changes legacy LTO to set data-sections by default. The user can
explicitly unset data-sections. The reason for this patch is to match the
behaviour of lld and gold plugin. Both lld and gold plugin have data-sections on
by default.

This patch also fixes the forwarding of the clang options -fno-data-sections and
-fno-function-sections to libLTO. Now, when -fno-data/function-sections are
specified in clang, -data/function-sections=0 will be passed to libLTO to
explicitly unset data/function-sections.

Reviewed By: w2yehia, MaskRay

Differential Revision: https://reviews.llvm.org/D129401
2022-07-27 09:39:39 -05:00
Quinn Pham 70ec8cd024 Revert "[libLTO] Set data-sections by default in libLTO."
This reverts commit f565444b48.
2022-07-27 08:47:00 -05:00
Nicolai Hähnle cd62604d19 Revert "ManagedStatic: remove from ASTMatchersInternal.h"
This reverts commit 7132bcdc42.

It is the likely cause of a clang-tools-extra test regression. Reverting
until I can investigate what's going on.
2022-07-27 15:46:21 +02:00
Quinn Pham f565444b48 [libLTO] Set data-sections by default in libLTO.
This patch changes legacy LTO to set data-sections by default. The user can
explicitly unset data-sections. The reason for this patch is to match the
behaviour of lld and gold plugin. Both lld and gold plugin have data-sections on
by default.

This patch also fixes the forwarding of the clang options -fno-data-sections and
-fno-function-sections to libLTO. Now, when -fno-data/function-sections are
specified in clang, -data/function-sections=0 will be passed to libLTO to
explicitly unset data/function-sections.

Reviewed By: w2yehia, MaskRay

Differential Revision: https://reviews.llvm.org/D129401
2022-07-27 08:34:40 -05:00
Nicolai Hähnle 7132bcdc42 ManagedStatic: remove from ASTMatchersInternal.h
Differential Revision: https://reviews.llvm.org/D130576
2022-07-27 14:57:34 +02:00
Nicolai Hähnle 5a78ac2156 clang: include ManagedStatic.h for llvm_shutdown
The code relied on ManagedStatic.h being included indirectly. This is
about to change as uses of ManagedStatic are removed throughout the
codebase.

Differential Revision: https://reviews.llvm.org/D130575
2022-07-27 14:57:34 +02:00
Nicolai Hähnle 3e874bcf06 ClangLinkerWrapper: explicitly #include <atomic>
This code relied on implicitly having std::atomic available via the
ManagedStatic.h header.

Differential Revision: https://reviews.llvm.org/D130574
2022-07-27 14:57:34 +02:00