Commit Graph

93683 Commits

Author SHA1 Message Date
Nico Weber 50186b63d1 Revert "[GH54588]Fix ItaniumMangler for NTTP unnamed unions w/ unnamed structs"
This reverts commit 4cf98f973a.
The test fails on mac bots, see comments on https://reviews.llvm.org/D122820

Also reverts follow-ups eb92098986 and
861c189d2a.
2022-04-03 17:21:27 -04:00
Iain Sandoe 1f0b8ba47a [C++20][Modules] Fix a testcase warning on Windows [NFC].
As reported, using "-DTDIR=%t" with a path name of 'C:\Users\...' causes
a warning to be emitted about the use of \U without following hex digits.

Since the value is only required for the FileCheck cases resolve this by
omitting the -D from the compile lines.
2022-04-03 11:39:00 +01:00
tyb0807 43d758b142 [Driver][AArch64] Split up aarch64-cpus.c tests further
This is the continuation of https://reviews.llvm.org/D120875. Now
aarch64-cpus-[12].c are further splitted and renamed to better reflect
the tests.

Differential Revision: https://reviews.llvm.org/D121093
2022-04-02 14:51:24 +01:00
tyb0807 9a015ee1f9 [AArch64] Avoid scanning feature list for target parsing
As discussed in https://reviews.llvm.org/D120111, this patch proposes an
alternative implementation to avoid scanning feature list for
architecture version over and over again. The insertion position for
default extensions is also captured during this single scan of the
feature list.

Differential Revision: https://reviews.llvm.org/D120864
2022-04-02 14:51:23 +01:00
tyb0807 b93893e60f [AArch64] Default HBC/MOPS features in clang
This implements minimum support in clang for default HBC/MOPS features
on v8.8-a/v9.3-a or later architectures.

Differential Revision: https://reviews.llvm.org/D120111
2022-04-02 14:51:23 +01:00
Ron Lieberman f1e7ecaa18 Revert "[AMDPU][Sanitizer] Refactor sanitizer options handling for AMDGPU Toolchain"
This reverts commit cc2139524f.

failed a few buildbots
2022-04-02 13:25:50 +00:00
Ron Lieberman cc2139524f [AMDPU][Sanitizer] Refactor sanitizer options handling for AMDGPU Toolchain
authored by amit.pandey@amd.com  ampandey-AMD

Differential Revision: https://reviews.llvm.org/D122781
2022-04-02 11:01:09 +00:00
Brad Smith d369dd1c06 [clang][Sparc] Enable IAS on the remaining OS's 2022-04-02 02:18:30 -04:00
Luo, Yuanke 979d876bb4 [X86][AMX] enable amx cast intrinsics in FE.
We have some discission in D99152 and llvm-dev and finially come up with
a solution to add amx specific cast intrinsics. We've support the
intrinsics in llvm IR. This patch is to replace bitcast with amx cast
intrinsics in code emitting in FE.

Differential Revision: https://reviews.llvm.org/D122567
2022-04-02 14:02:35 +08:00
Owen Pan 492cb7bf91 [clang-format] Fix a crash in qualifier alignment
Related to #54513.
2022-04-01 17:30:59 -07:00
Mitch Phillips 9262d031a4 [NFCI] clang-format SanitizerArgs.cpp 2022-04-01 16:38:15 -07:00
Erich Keane 9ba8c4024b Fix behavior of ifuncs with 'used' extern "C" static functions
We expect that `extern "C"` static functions to be usable in things like
inline assembly, as well as ifuncs:
See the bug report here: https://github.com/llvm/llvm-project/issues/54549

However, we were diagnosing this as 'not defined', because the
ifunc's attempt to look up its resolver would generate a declared IR
function.

Additionally, as background, the way we allow these static extern "C"
functions to work in inline assembly is by making an alias with the C
mangling in MOST situations to the version we emit with
internal-linkage/mangling.

The problem here was multi-fold: First- We generated the alias after the
ifunc was checked, so the function by that name didn't exist yet.
Second, the ifunc's generation caused a symbol to exist under the name
of the alias already (the declared function above), which suppressed the
alias generation.

This patch fixes all of this by moving the checking of ifuncs/CFE aliases
until AFTER we have generated the extern-C alias.  Then, it does a
'fixup' around the GlobalIFunc to make sure we correct the reference.

Differential Revision: https://reviews.llvm.org/D122608
2022-04-01 13:00:59 -07:00
Erich Keane eb92098986 FIX the wildcards to pass an FP diff in mangle-nttp-anon-union.cpp 2022-04-01 12:22:44 -07:00
Erich Keane 861c189d2a Add some wildcards to pass FP difference on one of the buildbots 2022-04-01 12:04:20 -07:00
Erich Keane 4cf98f973a [GH54588]Fix ItaniumMangler for NTTP unnamed unions w/ unnamed structs
As reported in https://github.com/llvm/llvm-project/issues/54588
and discussed in https://github.com/itanium-cxx-abi/cxx-abi/issues/139

We are supposed to do a DFS, pre-order, decl-order search for a name for
the union in this case. Prevoiusly we crashed because the IdentiferInfo
pointer was nullptr, so this makes sure we have a name in the cases
described by the ABI.

I added an llvm-unreachable to cover an unexpected case at the end of
the new function with information/reference to the ABI in case we come
up with some way to get back to here.

Differential Revision: https://reviews.llvm.org/D122820
2022-04-01 11:31:14 -07:00
Yitzhak Mandelbaum 01db10365e [clang][dataflow] Add support for correlation of boolean (tracked) values
This patch extends the join logic for environments to explicitly handle
boolean values. It creates the disjunction of both source values, guarded by the
respective flow conditions from each input environment. This change allows the
framework to reason about boolean correlations across multiple branches (and
subsequent joins).

Differential Revision: https://reviews.llvm.org/D122838
2022-04-01 17:25:49 +00:00
Yitzhak Mandelbaum ef1e1b3106 [clang][dataflow] Add support for (built-in) (in)equality operators
Adds logical interpretation of built-in equality operators, `==` and `!=`.s

Differential Revision: https://reviews.llvm.org/D122830
2022-04-01 17:13:21 +00:00
Yitzhak Mandelbaum 36d4e84427 [clang][dataflow] Fix handling of base-class fields.
Currently, the framework does not track derived class access to base
fields. This patch adds that support and a corresponding test.

Differential Revision: https://reviews.llvm.org/D122273
2022-04-01 15:01:32 +00:00
Aaron Ballman cd55e51516 Add prototypes to functions which need them; NFC 2022-04-01 10:32:46 -04:00
Joseph Huber 69a77771a9 [OpenMP] Make linker wrapper thin-lto default thread count use all
Summary:
Currently there is no option to configure the number of thin-backend
threads to use when performing thin-lto on the device, but we should
default to use all the threads rather than just one. In the future we
should use the same arguments that gold / lld use and parse it here.
2022-04-01 09:44:28 -04:00
Gabor Marton e63b81d10e [analyzer][ctu] Only import const and trivial VarDecls
Do import the definition of objects from a foreign translation unit if that's type is const and trivial.

Differential Revision: https://reviews.llvm.org/D122805
2022-04-01 13:49:39 +02:00
Iain Sandoe c7ed65b4bc [C++20][Modules] Limit ModuleInternalLinkage to modules-ts.
At present, we are generating wrong code for C++20 modules entities which
should have internal linkage.  This is because we are assigning
'ModuleInternalLinkage' unconditionally to such entities.  However this mode
is only applicable to the modules-ts.

This change makes the special linkage mode conditional on fmodules-ts and
adds a unit test to verify that we generate the correct linkage.

Currently, static variables and functions in module purview are emitted into
object files as external. On some platforms, lambdas are emitted as global
weak defintions (on Windows this causes a mangler crash).

Differential Revision: https://reviews.llvm.org/D122413
2022-04-01 09:10:30 +01:00
Chuanqi Xu 3cec39b91c [C++20] [Modules] Don't generate strong function of a partition in importing modules
This solves the multiple defintiion issue
https://github.com/llvm/llvm-project/issues/54269.

I think the cause of the bug might be an oversight. We just forget to
edit this when implementing partitions. And it should be a good fix.

Reviewed By: iains

Differential Revision: https://reviews.llvm.org/D121271
2022-04-01 14:36:04 +08:00
Richard Smith f1b0a4fc54 An expression should only contain an unexpanded parameter pack if it
lexically contains a mention of the pack.

Systematically distinguish between syntactic and semantic references to
packs, especially when propagating dependence from a type into an
expression. We should consult the type-as-written when computing
syntactic dependence and should consult the semantic type when computing
semantic dependence.

Fixes #54402.
2022-03-31 20:02:53 -07:00
Jorge Gorbe Moya fc7573f29c Revert "[misexpect] Re-implement MisExpect Diagnostics"
This reverts commit 46774df307.
2022-03-31 14:54:41 -07:00
Shivam 83bde93cef
resolve typo in the manual. 2022-04-01 03:15:17 +05:30
Artem Belevich fe528e7216 [CUDA] Don't call inferCUDATargetForImplicitSpecialMember too early.
Otherwise we may crash because the special member has not been sufficiently set
up yet. Fixes https://github.com/llvm/llvm-project/issues/54537

Differential Revision: https://reviews.llvm.org/D122846
2022-03-31 13:49:12 -07:00
Aaron Ballman 0e890904ea Use functions with prototypes when appropriate; NFC
A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);
2022-03-31 13:45:39 -04:00
Paul Kirth 46774df307 [misexpect] Re-implement MisExpect Diagnostics
Reimplements MisExpect diagnostics from D66324 to reconstruct its
original checking methodology only using MD_prof branch_weights
metadata.

New checks rely on 2 invariants:

1) For frontend instrumentation, MD_prof branch_weights will always be
   populated before llvm.expect intrinsics are lowered.

2) for IR and sample profiling, llvm.expect intrinsics will always be
   lowered before branch_weights are populated from the IR profiles.

These invariants allow the checking to assume how the existing branch
weights are populated depending on the profiling method used, and emit
the correct diagnostics. If these invariants are ever invalidated, the
MisExpect related checks would need to be updated, potentially by
re-introducing MD_misexpect metadata, and ensuring it always will be
transformed the same way as branch_weights in other optimization passes.

Frontend based profiling is now enabled without using LLVM Args, by
introducing a new CodeGen option, and checking if the -Wmisexpect flag
has been passed on the command line.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D115907
2022-03-31 17:38:21 +00:00
Chris Bieneman 19054163e1 [HLSL] Further improve to numthreads diagnostics
This adds diagnostics for conflicting attributes on the same
declarataion, conflicting attributes on a forward and final
declaration, and defines a more narrowly scoped HLSLEntry attribute
target.

Big shout out to @aaron.ballman for the great feedback and review on
this!
2022-03-31 11:34:01 -05:00
Aaron Ballman 2267549296 Fix the build after cd26190a10
These variables were being used uninitialized and it caused a
significant number of test failures on Windows.
2022-03-31 12:03:53 -04:00
Sven van Haastregt 4dfec37037 [OpenCL] Set MinVersion for sub_group_barrier with memory_scope
The memory_scope enum is not available before OpenCL 2.0, so ensure
the sub_group_barrier overload with a memory_scope argument is
restricted to OpenCL 2.0 and above.  This is already the case in
opencl-c.h.

Fixes the issue revealed by https://reviews.llvm.org/D120254

Reported-by: Harald van Dijk (hvdijk)
2022-03-31 16:41:40 +01:00
Vince Bridgers 4d5b824e3d [analyzer] Avoid checking addrspace pointers in cstring checker
This change fixes an assert that occurs in the SMT layer when refuting a
finding that uses pointers of two different sizes. This was found in a
downstream build that supports two different pointer sizes, The CString
Checker was attempting to compute an overlap for the 'to' and 'from'
pointers, where the pointers were of different sizes.

In the downstream case where this was found, a specialized memcpy
routine patterned after memcpy_special is used. The analyzer core hits
on this builtin because it matches the 'memcpy' portion of that builtin.
This cannot be duplicated in the upstream test since there are no
specialized builtins that match that pattern, but the case does
reproduce in the accompanying LIT test case. The amdgcn target was used
for this reproducer. See the documentation for AMDGPU address spaces here
https://llvm.org/docs/AMDGPUUsage.html#address-spaces.

The assert seen is:

`*Solver->getSort(LHS) == *Solver->getSort(RHS) && "AST's must have the same sort!"'

Ack to steakhal for reviewing the fix, and creating the test case.

Reviewed By: steakhal

Differential Revision: https://reviews.llvm.org/D118050
2022-03-31 17:34:56 +02:00
David Goldman d9739f29cd Serialize PragmaAssumeNonNullLoc to support preambles
Previously, if a `#pragma clang assume_nonnull begin` was at the
end of a premable with a `#pragma clang assume_nonnull end` at the
end of the main file, clang would diagnose an unterminated begin in
the preamble and an unbalanced end in the main file.

With this change, those errors no longer occur and the case above is
now properly handled. I've added a corresponding test to clangd,
which makes use of preambles, in order to verify this works as
expected.

Differential Revision: https://reviews.llvm.org/D122179
2022-03-31 11:08:01 -04:00
Yitzhak Mandelbaum 7f076004e9 [clang][dataflow] Add support for `value_or` in a comparison.
This patch adds limited modeling of the `value_or` method. Specifically, when
used in a particular idiom in a comparison to implicitly check whether the
optional holds a value.

Differential Revision: https://reviews.llvm.org/D122231
2022-03-31 13:21:39 +00:00
Qiu Chaofan e1b85430e9 Revert "[Clang] Add option to set alternative toolchain path"
--overlay-platform-toolchain inserts a whole new toolchain path with
higher priority than system default, which could be achieved by
composing smaller options. We need to figure out alternative solution
and what is missing among these basic options.
2022-03-31 15:58:01 +08:00
Fangrui Song 85bd90cb71 [Driver] Move legacy -f[no-]unit-at-a-time to clang_ignored_gcc_optimization_f_Group
Move to clang_ignored_gcc_optimization_f_Group like other ignored options. This
decreases code size a bit: ~400 bytes on x86-64.
2022-03-30 23:20:49 -07:00
Chuanqi Xu ee572129ae [C++20] [Modules] Use '-' as the separator of partitions when searching
in filesystems

It is simpler to search for module unit by -fprebuilt-module-path
option. However, the separator ':' of partitions is not friendly.
According to the discussion in https://reviews.llvm.org/D118586, I think
we get consensus to use '-' as the separator instead. The '-' is the
choice of GCC too.

Previously I thought it would be better to add an option. But I feel it
is over-engineering now. Another reason here is that there are too many
options for modules (for clang module mainly) now. Given it is not bad
to use '-' when searching, I think it is acceptable to not add an
option.

Reviewed By: iains

Differential Revision: https://reviews.llvm.org/D120874
2022-03-31 11:21:58 +08:00
wangyihan 907d3acefc [Clang][CodeGen]Beautify dump format, add indent for nested struct and struct members
Beautify dump format, add indent for nested struct and struct members, also fix test cases in dump-struct-builtin.c
for example:
struct:
```
  struct A {
    int a;
    struct B {
      int b;
      struct C {
        struct D {
          int d;
          union E {
            int x;
            int y;
          } e;
        } d;
        int c;
      } c;
    } b;
  };
```
Before:
```
struct A {
int a = 0
struct B {
    int b = 0
struct C {
struct D {
            int d = 0
union E {
                int x = 0
                int y = 0
                }
            }
        int c = 0
        }
    }
}
```
After:
```
struct A {
    int a = 0
    struct B {
        int b = 0
        struct C {
            struct D {
                int d = 0
                union E {
                    int x = 0
                    int y = 0
                }
            }
            int c = 0
        }
    }
}
```

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D122704
2022-03-31 07:38:37 +08:00
sstwcw f6740fe483 [clang-format] Indent import statements in JavaScript.
[clang-format] Indent import statements in JavaScript.

Take for example this piece of code found at
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import>.

```
for (const link of document.querySelectorAll("nav > a")) {
  link.addEventListener("click", e => {
    e.preventDefault();

    import('/modules/my-module.js')
        .then(module => {
          module.loadPageInto(main);
        })
        .catch(err => {
          main.textContent = err.message;
        });
  });
}
```

Previously the import line would be unindented, looking like this.

```
for (const link of document.querySelectorAll("nav > a")) {
  link.addEventListener("click", e => {
    e.preventDefault();

import('/modules/my-module.js')
        .then(module => {
          module.loadPageInto(main);
        })
        .catch(err => {
          main.textContent = err.message;
        });
  });
}
```

Actually we were going to fix this along with fixing Verilog import
statements.  But the patch got too big.

Reviewed By: MyDeveloperDay, curdeius

Differential Revision: https://reviews.llvm.org/D121906
2022-03-30 23:17:27 +00:00
Daniel Grumberg 985eaa1a3d [clang][extract-api][NFC] Don't remap the generated input buffer in PPOpts
This was triggering some build failures so removing this change for now.
2022-03-30 20:38:09 +01:00
Chris Bieneman ff6696c842 Expanding HLSL attribute diagnostics
Updating the diagnostics as per the feedback on
https://reviews.llvm.org/D122627.

This change correctly handles missing argument lists, and changes the
subject for the `numthreads` attribute to be global functions.

I did not handle applying the attribute to template functions because
that currently fails parsing in a way that is consisetent with the
current DXC codebase (Microsoft attributes are not supported on
templates).

A future improvement to the diagnostic maybe warranted.
2022-03-30 14:15:01 -05:00
Ben Barham 3fda0edc51 [VFS] RedirectingFileSystem only replace path if not already mapped
If the `ExternalFS` has already remapped a path then the
`RedirectingFileSystem` should not change it to the originally provided
path. This fixes the original path always being used if multiple VFS
overlays were provided and the path wasn't found in the highest (ie.
first in the chain).

This also renames `IsVFSMapped` to `ExposesExternalVFSPath` and only
sets it if `UseExternalName` is true. This flag then represents that the
`Status` has an external path that's different from its virtual path.
Right now the contained path is still the external path, but further PRs
will change this to *always* be the virtual path. Clients that need the
external can then request it specifically.

Note that even though `ExposesExternalVFSPath` isn't set for all
VFS-mapped paths, `IsVFSMapped` was only being used by a hack in
`FileManager` that was specific to module searching. In that case
`UseExternalNames` is always `true` and so that hack still applies.

Resolves rdar://90578880 and llvm-project#53306.

Differential Revision: https://reviews.llvm.org/D122549
2022-03-30 11:52:41 -07:00
Michael Liao 73ab5fd17b [clang] Fix shared build. NFC. 2022-03-30 14:05:14 -04:00
Daniel Grumberg 529a0570f7 [clang][extract-api] Add support for macros
To achieve this we hook into the preprocessor during the
ExtractAPIAction and record definitions for macros that don't get
undefined during preprocessing.
2022-03-30 18:33:10 +01:00
Daniel Grumberg a9909d23e9 [clang][extractapi] Tie API and serialization to the FrontendAction
Make the API records a property of the action instead of the ASTVisitor
so that it can be accessed outside the AST visitation and push back
serialization to the end of the frontend action.

This will allow accessing and modifying the API records outside of the
ASTVisitor, which is a prerequisite for supporting macros.
2022-03-30 18:32:58 +01:00
Corentin Jabot 0550601d18 [Clang] Add a compatibiliy warning for non-literals in constexpr.
Reviewed By: aaron.ballman, hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D122249
2022-03-30 19:18:53 +02:00
Nathan James 61d67c8eec Revert "[ASTMatchers] Output currently matching node on crash"
This reverts commit 6e33e45b94.

Fails to build on 32bit machines due to PointerUnion limitations
2022-03-30 18:10:48 +01:00
Nathan James 6e33e45b94
[ASTMatchers] Output currently matching node on crash
Extend D120185 to also log the node being matched on in case of a crash.
This can help if a matcher is causing a crash or there are not enough interesting nodes bound.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D122529
2022-03-30 17:14:00 +01:00
Nathan Sidwell ae4dce8659 [clang][ABI] New C++20 module mangling scheme
Implement a demangleable strong ownership symbol mangling.

 * The original module symbol mangling scheme turned out to be
undemangleable.

 * The hoped-for C++17 compatibility of weak ownership turns out to be
fragile

* C++20 now has better ways of controlling C++17 compatibility

The issue is captured on the ABI list at:
  https://github.com/itanium-cxx-abi/cxx-abi/issues/134

GCC implements this new mangling.

The old mangling is unceremoniously dropped.  No backwards
compatibility, no deprectated old-mangling flag.  It was always
labelled experimental.  (Old and new manglings cannot be confused.)

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D122256
2022-03-30 08:51:27 -07:00