Commit Graph

93203 Commits

Author SHA1 Message Date
Andrzej Warzynski
38101b4e95 [flang][driver] Add support for -S and implement -c/-emit-obj
This patch adds support for:
  * `-S` in Flang's compiler and frontend drivers,
and implements:
  * `-emit-obj` in Flang's frontend driver and `-c` in Flang's compiler
    driver (this is consistent with Clang).
(these options were already available before, but only as placeholders).
The semantics of these options in Clang and Flang are identical.

The `EmitObjAction` frontend action is renamed as `BackendAction`. This
new name more accurately reflects the fact that this action will
primarily run the code-gen/backend pipeline in LLVM. It also makes more
sense as an action implementing both `-emit-obj` and `-S` (originally,
it was just `-emit-obj`).

`tripleName` from FirContext.cpp is deleted and, when a target triple is
required, `mlir::LLVM::LLVMDialect::getTargetTripleAttrName()` is used
instead. In practice, this means that `fir.triple` is replaced with
`llvm.target_triple`. The former was effectively ignored. The latter is
used when lowering from the LLVM dialect in MLIR to LLVM IR (i.e. it's
embedded in the generated LLVM IR module). The driver can then re-use
it when configuring the backend. With this change, the LLVM IR files
generated by e.g. `tco` will from now on contain the correct target
triple.

The code-gen.f90 test is replaced with code-gen-x86.f90 and
code-gen-aarch64.f90. With 2 seperate files we can verify that
`--target` is correctly taken into account. LIT configuration is updated
to enable e.g.:
```
! REQUIRES: aarch64-registered-target
```

Differential Revision: https://reviews.llvm.org/D120568
2022-03-09 15:48:09 +00:00
Stanislav Gatev
3dd7877b27 Revert "[clang][dataflow] Move dataflow testing support out of unittests"
This reverts commit 26bbde2612.
2022-03-09 15:38:51 +00:00
Stanislav Gatev
26bbde2612 [clang][dataflow] Move dataflow testing support out of unittests
This enables tests out of clang/unittests/Analysis/FlowSensitive to
use the testing support utilities.

Reviewed-by: ymandel, gribozavr2

Differential Revision: https://reviews.llvm.org/D121285
2022-03-09 15:31:02 +00:00
Timm Bäder
e5ccd66801 [clang][sema] Enable first-class bool support for C2x
Implement N2395 for C2x.

This also covers adding "bool", which is part of N2394.

Differential Revision: https://reviews.llvm.org/D120244
2022-03-09 15:04:24 +01:00
Simon Pilgrim
d258196f5f [clang] ScalarExprEmitter::VisitCastExpr - use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointers are always dereferenced, so assert the cast is correct instead of returning nullptr
2022-03-09 11:40:37 +00:00
Simon Pilgrim
a157d839c5 [clang] Environment::createValueUnlessSelfReferential - use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointer is always dereferenced, so assert the cast is correct instead of returning nullptr
2022-03-09 11:40:37 +00:00
Simon Pilgrim
8d0931114f [clang] Sema::ActOnModuleImport - remove superfluous nullptr test
Mod has already been dereferenced
2022-03-09 11:40:36 +00:00
Chuanqi Xu
ae4eb938c0 [NFC] [C++20] [Modules] Add test to show private module fragment is not allowed in partition unit 2022-03-09 19:05:54 +08:00
Stanislav Gatev
e0cc28dfdc Revert "[clang][dataflow] Add analysis that detects unsafe accesses to optionals"
This reverts commit ce205cffdf.
2022-03-09 09:51:03 +00:00
Stanislav Gatev
ce205cffdf [clang][dataflow] Add analysis that detects unsafe accesses to optionals
Adds a dataflow analysis that detects unsafe accesses to values of type
`std::optional`, `absl::optional`, or `base::Optional`.

Reviewed-by: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D121197
2022-03-09 09:42:51 +00:00
Chuanqi Xu
845f0bb5fa Revert "[clang][ABI] New C++20 module mangling scheme"
This reverts commit 21e16ab6b8.

It looks like it would break builds in mac. See
https://reviews.llvm.org/D118352.
2022-03-09 10:15:15 +08:00
Ryan Senanayake
b3dae59b9d [clang] Fix CodeGenAction for LLVM IR MemBuffers
Replaces use of getCurrentFile with getCurrentFileOrBufferName
in CodeGenAction. This avoids an assertion error or an incorrect
name chosen for the output file when assertions are disabled.
This error previously occurred when the FrontendInputFile was a
MemoryBuffer instead of a file.

Reviewed By: jlebar

Differential Revision: https://reviews.llvm.org/D121259
2022-03-09 00:39:48 +00:00
Andrzej Warzynski
8321579b28 [flang][driver] Add support for -debug-dump-pft
This patch adds support for dumping the pre-FIR tree in `flang-new
-fc1`, i.e. Flang's frontend driver. This flag is functionally identical
to `-pft-test` in `bbc` and semantically similar to
`-fdebug-dump-parse-tree` from `flang-new -fc1`.

Differential Revision: https://reviews.llvm.org/D121198
2022-03-08 19:21:58 +00:00
eopXD
550b2eaaa6 [RISCV] Add combination crypto extensions in ISAInfo
The crypto extension have several shorthand extensions that don't consist of any extra instructions.
Take `zk` for example, while the extension would imply `zkn, zkr, zkt`. The 3 extensions should also
combine back into `zk` to maintain the canonical order in isa strings.

This patch addresses the above.

Reviewed By: VincentWu

Differential Revision: https://reviews.llvm.org/D119530
2022-03-08 09:52:38 -08:00
Akira Hatanaka
9bb8c80bea [NFC][Clang][OpaquePtr] Remove calls to Address::deprecated in
CGBuiltin.cpp

Differential Revision: https://reviews.llvm.org/D121153
2022-03-08 09:45:15 -08:00
Aaron Ballman
1c55f05c6a Properly diagnose constant evaluation issues at TU scope
We were not creating an evaluation context for the TU scope, so we
never popped an evaluation context for it. Popping the evaluation
context triggers a number of diagnostics, including warnings about
immediate invocations that we were previously missing.

Note: I think we have an additional issue that we should solve, but not
as part of this patch. I don't think Clang is properly modeling static
initialization as happening before constant expression evaluation. I
think structure members members are zero initialized per
http://eel.is/c++draft/basic.start.static#1,
https://eel.is/c++draft/basic.start.static#2.sentence-2, and
http://eel.is/c++draft/dcl.init#general-6.2 and the new test case
actually should be accepted. However, it's also worth noting that other
compilers behave the way this patch makes Clang behave:
https://godbolt.org/z/T7noqhdPr
2022-03-08 10:19:15 -05:00
Timm Bäder
5b7941ad7c [clang][driver] Fix float128 diagnostics with glibc >= 2.32
Fix checking for an unsupported stdlib++.

Differential Revision: https://reviews.llvm.org/D121209
2022-03-08 15:49:01 +01:00
Nathan Sidwell
21e16ab6b8 [clang][ABI] New C++20 module mangling scheme
The existing module symbol mangling scheme turns out to be
undemangleable.  It is also desirable to switch to the
strong-ownership model as the hoped-for C++17 compatibility turns out
to be fragile, and we also now have a better way of controlling that.

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

A document describing the issues and new mangling is at:
  https://drive.google.com/file/d/1qQjqptzOFT_lfXH8L6-iD9nCRi34wjft/view

This patch is the code-generation part.  I have a demangler too, but
that patch is based on some to-be-landed refactoring of the demangler.

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: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D118352
2022-03-08 06:21:50 -08:00
Marek Kurdej
f537a40916 [clang-format] Correctly detect ! as TT_NonNullAssertion after default.
Fixes https://github.com/llvm/llvm-project/issues/53153.

Depends on D121132.

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D121136
2022-03-08 13:35:26 +01:00
Marek Kurdej
7a54fceb25 [clang-format] Handle C# 9 init accessor specifier.
Before, the code:
```
int Value { get; } = 0;
int Value { init; } = 0;
```
was formatted incoherently:
```
int Value { get; } = 0;
int Value { init; }
= 0;
```
because `init` was not recognised as an accessor specifier.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D121132
2022-03-08 13:33:36 +01:00
Adrian Kuegel
75aca24d2f [clang] Fix reference to file that was moved. 2022-03-08 12:26:02 +01:00
Krystian Kuzniarek
481f681867 [AST] Fix typo in assert messages
Differential Revision: https://reviews.llvm.org/D120221
2022-03-08 11:06:50 +00:00
Argyrios Kyrtzidis
f2b24905bf [Sema] Mark the referenced destructor during transformation of a CXXBindTemporaryExpr
Otherwise we will fail to generate the definition of a defaulted destructor,
if the only reference was in a templated temporary.

rdar://89366678

Differential Revision: https://reviews.llvm.org/D120426
2022-03-08 01:00:07 -08:00
Stanislav Mekhanoshin
9eabea3968 [AMDGPU] Set noclobber metadata on loads instead of cast to constant
A load via pointer cast to constant will return true from
pointsToConstantMemory which is not necessarily so.

Fixes: SWDEV-326463

Differential Revision: https://reviews.llvm.org/D121172
2022-03-07 23:13:02 -08:00
Yuanfang Chen
eddd94c27d Reland "[clang][debug] port clang-cl /JMC flag to ELF"
This relands commit 7313474319.

It failed on Windows/Mac because `-fjmc` is only checked for ELF targets.
Check the flag unconditionally instead and issue a warning for non-ELF targets.
2022-03-07 21:55:41 -08:00
Phoebe Wang
4de9a752d6 [X86] Add helper enum for ternary intrinsics
Reviewed By: RKSimon, LuoYuanke

Differential Revision: https://reviews.llvm.org/D120307
2022-03-08 11:19:05 +08:00
Yitzhak Mandelbaum
18c84e2d32 [clang][dataflow] Fix nullptr dereferencing error.
When pre-initializing fields in the environment, the code assumed that all
fields of a struct would be initialized. However, given limits on value
construction, that assumption is incorrect. This patch changes the code to drop
that assumption and thereby avoid dereferencing a nullptr.

Differential Revision: https://reviews.llvm.org/D121158
2022-03-08 03:01:31 +00:00
Peixin-Qiao
4e159e4c7b [clang] Fix OpenMP critical hint parameter check
The paramemter of hint clause in OpenMP critical hint should be
non-negative. The omp_lock_hint_none is 0 in omp.h.

Reviewed By: Alexey Bataev

Differential Revision: https://reviews.llvm.org/D121101
2022-03-08 09:04:31 +08:00
Sam Clegg
c832edfd3f [WebAssembly] Add new target feature in support of 'extended-const' proposal
We don't yet do anything when this feature is enabled, this change
just lays the ground work by accepting that there is such a feature.

See https://github.com/WebAssembly/extended-const

Differential Revision: https://reviews.llvm.org/D121151
2022-03-07 16:45:42 -08:00
Yuanfang Chen
f46fa4de4a Revert "[clang][debug] port clang-cl /JMC flag to ELF"
This reverts commit 7313474319.

Break bots:
http://45.33.8.238/win/54551/step_7.txt
http://45.33.8.238/macm1/29590/step_7.txt
2022-03-07 12:40:43 -08:00
Stanislav Mekhanoshin
932f628121 [AMDGPU] new gfx940 fp atomics
Differential Revision: https://reviews.llvm.org/D121028
2022-03-07 12:32:02 -08:00
Haojian Wu
2d01ac18df [pseudo] Strip comments for TokenStream.
Add a utility function to strip comments from a "raw" tokenstream. The
derived stream will be fed to the GLR parser (for early testing).

Differential Revision: https://reviews.llvm.org/D121092
2022-03-07 20:24:37 +01:00
Haojian Wu
d5b8ecbd33 [pseudo] empty parameter-declaration should be allowed in lambda declarator.
This was an oversight, as we did a avoild-nullable modication to
parameter-declaration-clause.

Differential Revision: https://reviews.llvm.org/D121089
2022-03-07 20:05:35 +01:00
Nico Weber
e6a8b92b89 [clang-format] Fix namespace end comments in ObjC++ files too
See also d96ae86735.

Differential Revision: https://reviews.llvm.org/D121112
2022-03-07 13:30:25 -05:00
David Blaikie
c0a6433f2b Simplify OpenMP Lambda use
* Use default ref capture for non-escaping lambdas (this makes
  maintenance easier by allowing new uses, removing uses, having
  conditional uses (such as in assertions) not require updates to an
  explicit capture list)
* Simplify addPrivate API not to take a lambda, since it calls it
  unconditionally/immediately anyway - most callers are simply passing
  in a named value or short expression anyway and the lambda syntax just
  adds noise/overhead

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D121077
2022-03-07 18:23:20 +00:00
Yuanfang Chen
7313474319 [clang][debug] port clang-cl /JMC flag to ELF
The motivation is to enable the MSVC-style JMC instrumentation usable by a ELF-based
debugger. Since there is no prior experience implementing JMC feature for ELF-based
debugger, it might be better to just reuse existing MSVC-style JMC instrumentation.
For debuggers that support both ELF&COFF (like lldb), the JMC implementation might
be shared between ELF&COFF. If this is found to inadequate, it is pretty low-cost
switching to alternatives.

Implementation:
- The '-fjmc' is already a driver and cc1 flag. Wire it up for ELF in the driver.
- Refactor the JMC instrumentation pass a little bit.
- The ELF handling is different from MSVC in two places:
  * the flag section name is ".just.my.code" instead of ".msvcjmc"
  * the way default function is provided: MSVC uses /alternatename; ELF uses weak function.

Based on D118428.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D119910
2022-03-07 10:16:24 -08:00
Yi Kong
bc1f8b6b9b Fix the comment for EnableNoundefAttrs, NFC 2022-03-08 01:59:44 +08:00
Stanislav Gatev
1e5715857a [clang][dataflow] Extend flow conditions from block terminators
This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D120984
2022-03-07 17:50:44 +00:00
Sam McCall
54d6b5b67f [pseudo] Rename {Preprocess,PPStructure} -> DirectiveMap. NFC
More precisely describes what this file does.
Per comments on https://reviews.llvm.org/D121092
2022-03-07 17:41:35 +01:00
phyBrackets
90a6e35478 [analyzer][NFC] Merge similar conditional paths
Reviewed By: aaron.ballman, steakhal

Differential Revision: https://reviews.llvm.org/D121045
2022-03-07 22:05:27 +05:30
Marek Kurdej
d03e342803 [clang-format] Fix assertion failure/crash with AllowShortFunctionsOnASingleLine: Inline/InlineOnly.
Fixes https://github.com/llvm/llvm-project/issues/54147.

When handling `AllowShortFunctionsOnASingleLine`, we were searching for the last line with a smaller level than the current line. The search was incorrect when the first line had the same level as the current one. This led to an unsatisfied assumption about the existence of a brace (non-comment token).

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D120902
2022-03-07 16:54:08 +01:00
Kadir Cetinkaya
d65952b9bd
[clang] Adjust LookupTest for UsingTypeLocs
We no longer traverse the underlying RecordTypeLoc directly, but rather
visit the UsingTypeLoc.

Differential Revision: https://reviews.llvm.org/D121103
2022-03-07 16:22:03 +01:00
Sam McCall
68b4e2d703 [pseudo] Add readme
Differential Revision: https://reviews.llvm.org/D121108
2022-03-07 15:54:00 +01:00
Endre Fülöp
bfc40b1a1a [analyzer] Fix buildbot failure for D120369
Fix test case for GenericTaintChecker.
Redefinition of types is a C11 feature, and it broke a buildbot.
Commit amended: 4fd6c6e65a.
2022-03-07 14:56:04 +01:00
Endre Fülöp
4fd6c6e65a [analyzer] Add more propagations to Taint analysis
Add more functions as taint propators to GenericTaintChecker.

Reviewed By: steakhal

Differential Revision: https://reviews.llvm.org/D120369
2022-03-07 13:18:54 +01:00
Jan Svoboda
2d26f163f6 [clang][modules] Fix failing test
This test started failing on Windows after b45888e959 due to path separators not matching up.
2022-03-07 11:21:21 +01:00
Jan Svoboda
b45888e959 [clang][modules] Report module maps affecting no_undeclared_includes modules
Since D106876, PCM files don't report module maps as input files unless they contributed to the compilation.

Reporting only module maps of (transitively) imported modules is not enough, though. For modules marked with `[no_undeclared_includes]`, other module maps affect the compilation by introducing anti-dependencies.

This patch makes sure such module maps are being reported as input files.

Depends on D120463.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D120464
2022-03-07 10:47:46 +01:00
Jan Svoboda
242b24c184 [clang][modules] NFC: Simplify and clarify test
This patch simplifies a test that checks only used module map files are reported as input files in PCM files.

Instead of using opaque `diff`, this patch uses `clang -module-file-info` and `FileCheck` to verify this.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D120463
2022-03-07 10:47:46 +01:00
Timm Bäder
7b969b0bb5 [clang][parser] Stop dragging an EndLoc around when parsing attributes
It's almost always entirely unused and if it is used, the end of the
attribute range can be used instead.

Differential Revision: https://reviews.llvm.org/D120888
2022-03-07 08:16:39 +01:00
Qiu Chaofan
b2497e5435 [PowerPC] Add generic fnmsub intrinsic
Currently in Clang, we have two types of builtins for fnmsub operation:
one for float/double vector, they'll be transformed into IR operations;
one for float/double scalar, they'll generate corresponding intrinsics.

But for the vector version of builtin, the 3 op chain may be recognized
as expensive by some passes (like early cse). We need some way to keep
the fnmsub form until code generation.

This patch introduces ppc.fnmsub.* intrinsic to unify four fnmsub
intrinsics.

Reviewed By: shchenz

Differential Revision: https://reviews.llvm.org/D116015
2022-03-07 13:00:06 +08:00