Commit Graph

92293 Commits

Author SHA1 Message Date
Sander de Smalen 990bab89ff [ScalableVectors] Warn instead of error for invalid size requests.
This was intended to be fixed by D98856, but that only seemed to have
the desired behaviour when compiling to assembly using `-S`, not when
compiling into an object file or executable. Given that this was not
the intention of D98856, this patch fixes the behaviour.
2022-01-20 16:42:08 +00:00
Mubashar Ahmad 3da69fb5a2 [Clang][AArch64][ARM] Unaligned Access Test Fix
Test fixed for the unaligned access warning.
2022-01-20 15:29:53 +00:00
eopXD 14c5fd920b [Clang][RISCV] Change TARGET_BUILTIN to require zve32x for vector instruction
According to v-spec v1.0, `zve-32x` is the new minimum extension to include
to have vector instructions.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D112613
2022-01-20 06:53:48 -08:00
Stanislav Gatev c95cb4de1b [clang][dataflow] Intersect ExprToLoc when joining environments
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: xazax.hun

Differential Revision: https://reviews.llvm.org/D117754
2022-01-20 14:30:17 +00:00
Mubashar Ahmad 35737df4dc [Clang][AArch64][ARM] Unaligned Access Warning Added
Added warning for potential cases of
unaligned access when option
-mno-unaligned-access has been specified

Differential Revision: https://reviews.llvm.org/D116221
2022-01-20 14:12:49 +00:00
Florian Hahn 67aa314bce
[IRGen] Do not overwrite existing attributes in CGCall.
When adding new attributes, existing attributes are dropped. While
this appears to be a longstanding issue, this was highlighted by D105169
which dropped a lot of attributes due to adding the new noundef
attribute.

Ahmed Bougacha (@ab) tracked down the issue and provided the fix in
CGCall.cpp. I bundled it up and updated the tests.
2022-01-20 13:45:19 +00:00
Marek Kurdej 69ecd2484f [clang-format] Indicate source location on test failure. NFC. 2022-01-20 14:10:59 +01:00
Florian Hahn 782c0dd1a1
[IRBuilder] Migrate and-folding to value-based FoldAnd.
Similar to the migration of or-folding to FoldOr, there are a few cases
where the fold in IRBuilder::CreateAnd triggered directly. Those have
been updated.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D117431
2022-01-20 10:22:21 +00: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
Marek Kurdej 794b1eebe7 [clang-format] Add tests for aligning `operator=` with `=delete`. NFC.
Also, add test case from https://github.com/llvm/llvm-project/issues/33044.
This was actually fixed in 480a1fab72, but there were no tests for delete.
2022-01-20 09:39:08 +01:00
Chenbing.Zheng 0be3da1fab [RISCV] Add intrinsic for Zbt extension
RV32: fsl, fsr, fsri
RV64: fsl, fsr, fsri, fslw, fsrw, fsriw

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D117468
2022-01-20 08:27:05 +00:00
Jino Park 560eb2277b [clang-format] Fix bug in parsing `operator<` with template
Fixes https://github.com/llvm/llvm-project/issues/44601.

This patch handles a bug when parsing a below example code :

```
template <class> class S;

template <class T> bool operator<(S<T> const &x, S<T> const &y) {
  return x.i < y.i;
}

template <class T> class S {
  int i = 42;
  friend bool operator< <>(S const &, S const &);
};

int main() { return S<int>{} < S<int>{}; }
```
which parse `< <>` as `<< >`, not `< <>` in terms of tokens as discussed in discord.

1. Add a condition in `tryMergeLessLess()` considering `operator` keyword and `>`
2. Force to leave a whitespace between `tok::less` and a template opener
3. Add unit test

Reviewed By: MyDeveloperDay, curdeius

Differential Revision: https://reviews.llvm.org/D117398
2022-01-20 08:59:04 +01: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
Johannes Doerfert 6f2ee1ca5e [OpenMP][AMDGPU] Optimize the linked in math libraries
Once we linked in math files, potentially even if we link in only other
"system libraries", we want to optimize the code again. This is not only
reasonable but also helps to hide various problems with the missing
attribute annotations in the math libraries.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D116906
2022-01-19 23:36:36 -06:00
Joseph Huber 28d718602a [OpenMP] Expand short verisions of OpenMP offloading triples
The OpenMP offloading libraries are built with fixed triples and linked
in during compile time. This would cause un-helpful errors if the user
passed in the wrong expansion of the triple used for the bitcode
library. because we only support these triples for OpenMP offloading we
can normalize them to the full verion used in the bitcode library.

Reviewed By: jdoerfert, JonChesterfield

Differential Revision: https://reviews.llvm.org/D117634
2022-01-19 20:26:37 -05:00
Alexandre Ganea aba5b91b69 Re-land [CodeView] Add full repro to LF_BUILDINFO record
This patch writes the full -cc1 command into the resulting .OBJ, like MSVC does. This allows for external tools (Recode, Live++) to rebuild a source file without any external dependency but the .OBJ itself (other than the compiler) and without knowledge of the build system.

The LF_BUILDINFO record stores a full path to the compiler, the PWD (CWD at program startup), a relative or absolute path to the source, and the full CC1 command line. The stored command line is self-standing (does not depend on the environment). In the same way, MSVC doesn't exactly store the provided command-line, but an expanded version (a somehow equivalent of CC1) which is also self-standing.

For more information see PR36198 and D43002.

Differential Revision: https://reviews.llvm.org/D80833
2022-01-19 19:44:37 -05:00
Joseph Huber a9935b5db7 [openmp] Unconditionally set march commandline argument
Extracted from D117246. This reflects the march value used by the
compile back into the toolchain arguments, letting downstream processes
such as LTO rely on it being present. Subsequent patches should also be able
to remove the two other calls to checkSystemForAMDGPU.

Reviewed By: jonchesterfield

Differential Revision: https://reviews.llvm.org/D117706
2022-01-19 19:14:47 +00: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
David Blaikie baa9b7c3c8 unique_ptrify the ModuleManager's VisitState linked list 2022-01-19 09:57:46 -08:00
Yaxun (Sam) Liu 85c2bd2a0e Prevent adding module flag amdgpu_hostcall multiple times
HIP program with printf call fails to compile with -fsanitize=address
option, because of appending module flag - amdgpu_hostcall twice, one
for printf and one for sanitize option. This patch fixes that issue.

Patch by: Praveen Velliengiri

Reviewed by: Yaxun Liu, Roman Lebedev

Differential Revision: https://reviews.llvm.org/D116216
2022-01-19 12:52:33 -05:00
Arnamoy Bhattacharyya 9fbd33ad62 [OMPIRBuilder] Add support for simd (loop) directive.
This patch adds OMPIRBuilder support for the simd directive (without any clause).  This will be a first step towards lowering simd directive in LLVM_Flang.  The patch uses existing CanonicalLoop infrastructure of IRBuilder to add the support.  Also adds necessary code to add llvm.access.group and llvm.loop metadata wherever needed.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D114379
2022-01-19 11:32:17 -05:00
Stanislav Gatev 8e53ae3d37 [clang][dataflow] Add a transfer function for conditional operator
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: xazax.hun

Differential Revision: https://reviews.llvm.org/D117667
2022-01-19 16:25:05 +00:00
Masoud Ataei d261660af9 Fix the use of -fno-approx-func along with -Ofast or -ffast-math
Fix how -fapprox-func interact correctly with the other floating point options.
Reported bug Number 52565: https://bugs.llvm.org/show_bug.cgi?id=52565

Differential: https://reviews.llvm.org/D114564
Reviewer: @andrew.w.kaylor
2022-01-19 08:05:08 -08:00
Balazs Benics 881b6a009f [analyzer][NFC] Re-enable skipped SValTests by relaxing expectations
Some tests were skipped in D114454 to resolve test failures on some
platforms, where the pointers have different bitwidth than expected.
This patch re-enables these tests, by relaxing the requirements on the
types of the SVal.

The issue:
There is no way to reconstruct the type of the `SVal` perfectly
accurately, since there could be multiple types having the required
bitwidth and signedness.
Consider platforms where `int` and `long` have the same bitwidth.
Additionally, we need to be careful about casting a pointer to an
integral representation, because we don't know what smallest integral
type can represent that.

To workaround these issues, I propose enforcing a type that has the
same signedness and bitwidth as the expected type, instead of perfect
equality.

In the `GetLocAsIntType` test, in case of pointer-to-integral casts
I'm using the widest standard integral type (long long) to make sure
that the pointer can be represented by the type without losing
precision. This won't affect the test in any meaningful way, since the
type of the `lvalue` remained the same.

In one case, I had to replace `getUIntPtrType()` with `UnsignedLongTy`
because on some platforms `getUIntPtrType()` is different then `long
int`.

In this patch, I also enforce that the tests must compile without
errors, to prevent narrowing conversions in the future.

Reviewed By: stevewan

Differential Revision: https://reviews.llvm.org/D115349
2022-01-19 15:16:18 +01:00
Marek Kurdej 5ea98988c6 [clang-format] [docs] Fix link to avoid redirection. NFC. 2022-01-19 14:23:04 +01:00
Haojian Wu 6c78703e3a [AST] Fix the incorrect auto-keyword loc for constrained auto type loc.
E.g.  `Concept auto Func();`

The nameLoc for the constained auto type loc pointed to the concept name
loc, it should be the auto token loc. This patch fixes it, and remove
a relevant hack in clang-tidy check.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D117009
2022-01-19 14:18:38 +01:00
Ben Shi a2f488c6a5 [clang][AVR] Implement '__flashN' for variables on different flash banks
Reviewed By: aykevl

Differential Revision: https://reviews.llvm.org/D115982
2022-01-19 11:24:01 +00:00
Saiyedul Islam 6ee9654713
[Doc] Fix wrong indentation
Handle Sphinx's warning at line 218.
2022-01-19 11:15:31 +00:00
Saiyedul Islam 0731f6ba4f
[Doc] Add documentation for the clang-offload-wrapper tool (NFC)
Add the missing documentation for this tool.

Reviewed By: sdmitriev

Differential Revision: https://reviews.llvm.org/D117120
2022-01-19 10:45:13 +00:00
Stanislav Gatev acd4b03590 Revert "Revert "[clang][dataflow] Add a test to justify skipping past references in UO_Deref""
This reverts commit a0262043bb.

Add the -fno-delayed-template-parsing arg to fix the failing test on Windows.
2022-01-19 10:00:01 +00:00
Elliott Maguire 480a1fab72 [clang-format] Fix incorrect alignment of operator= overloads.
Fixes https://github.com/llvm/llvm-project/issues/31568.

Added a check for operator keyword tokens.

Reviewed By: MyDeveloperDay, curdeius, owenpan, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D117421
2022-01-19 10:18:47 +01:00
Stanislav Gatev a0262043bb Revert "[clang][dataflow] Add a test to justify skipping past references in UO_Deref"
This reverts commit 68226e572f.
2022-01-19 06:46:37 +00:00
Joseph Huber ca6c9e43ea [OpenMP] Remove hidden visibility for declare target variables
This patch changes the visiblity of variables declared within a declare
target directive. Variable declarations within a declare target
directive need to be externally visible to the plugin for initialization
or reading. Previously this would cause runtime errors where the named
global could not be found because it was not included in the symbol
table.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D117362
2022-01-18 18:19:57 -05:00
Stanislav Gatev 68226e572f [clang][dataflow] Add a test to justify skipping past references in UO_Deref
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: xazax.hun

Differential Revision: https://reviews.llvm.org/D117567
2022-01-18 21:27:43 +00:00
Sam McCall 4777eb2954 [Sema] Add test for new errors due to 09f8315bba
Knowing the type of more dependent expressions means we can diagnose
more errors at template parsing rather than instantiation time.

Such templates are IFNDR, so this is a QoI improvement.
I hadn't anticipated this in the original patch, so had no test.
2022-01-18 22:18:35 +01:00
Joseph Huber 8fc24de93f Revert "[OpenMP] Remove hidden visibility for declare target variables"
Reverting to investigate break on AMDPGU.  This reverts commit
d081bfcd17.
2022-01-18 14:44:11 -05:00
Aaron Ballman 0d459444e5 Mark ATOMIC_VAR_INIT and ATOMIC_FLAG_INIT as deprecated
C17 deprecated ATOMIC_VAR_INIT with the resolution of DR 485. C++
followed suit when adopting P0883R2 for C++20, but additionally chose
to deprecate ATOMIC_FLAG_INIT at the same time despite the macro still
being required in C. This patch marks both macros as deprecated when
appropriate to do so.
2022-01-18 13:41:56 -05:00
Joseph Huber d081bfcd17 [OpenMP] Remove hidden visibility for declare target variables
This patch changes the visiblity of variables declared within a declare
target directive. Variable declarations within a declare target
directive need to be externally visible to the plugin for initialization
or reading. Previously this would cause runtime errors where the named
global could not be found because it was not included in the symbol
table.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D117362
2022-01-18 12:53:20 -05:00
Joseph Huber dcb83b2364 [OpenMP] Mark device RTL variables as hidden
This patch changes the visibility of the `__omp_rtl_debug_kind` variable
to be hidden. These variables are only used by the plugin so they do not
need to be read externally. Previously the default visibility prevented
these variables from being completely eliminated in the module.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D117320
2022-01-18 12:53:17 -05:00
Tres Popp 262cc74e0b Fix pair construction with an implicit constructor inside. 2022-01-18 18:01:52 +01:00
Aaron Ballman fa596fb077 Fix a failed assertion on an invalid typename requirement
The parsing code for a typename requirement currently asserts when
given something which is not a valid type-requirement
(http://eel.is/c++draft/expr.prim.req.type#nt:type-requirement). This
removes the assertion to continue on to the proper diagnostic.

This resolves PR53057.

Note that in that PR, it is using _BitInt(N) as a dependent type name.
This patch does not attempt to support that as it is not clear that is
a valid type requirement (it does not match the grammar production for
one). The workaround in the PR, however, is definitely valid and works
as expected.
2022-01-18 11:59:08 -05:00
Stanislav Gatev d7c19f947e [clang][dataflow] Remove obsolete FIXME
The FIXME is no longer relevant as ControlFlowContext centralizes the
construction of the CFG.

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: xazax.hun

Differential Revision: https://reviews.llvm.org/D117563
2022-01-18 15:16:44 +00:00
Endre Fülöp 17f74240e6 [analyzer][NFC] Refactor GenericTaintChecker to use CallDescriptionMap
GenericTaintChecker now uses CallDescriptionMap to describe the possible
operation in code which trigger the introduction (sources), the removal
(filters), the passing along (propagations) and detection (sinks) of
tainted values.

Reviewed By: steakhal, NoQ

Differential Revision: https://reviews.llvm.org/D116025
2022-01-18 16:04:04 +01:00
Jan Svoboda 105c913156 [clang][lex] NFC: Simplify calls to `LookupFile`
The `{HeaderSearch,Preprocessor}::LookupFile()` functions take an out-parameter `const DirectoryLookup *&`. Most callers end up creating a `const DirectoryLookup *` variable that's otherwise unused.

This patch changes the out-parameter from reference to a pointer, making it possible to simply pass `nullptr` to the function without the ceremony.

Reviewed By: ahoppen

Differential Revision: https://reviews.llvm.org/D117312
2022-01-18 16:02:18 +01:00
Jan Svoboda 8b21e074db [clang] NFC: Remove unused `DirectoryLookup`
This patch removes bitrotten/dead uses of `DirectoryLookup` in `InclusionRewriter.cpp`.

Reviewed By: ahoppen

Differential Revision: https://reviews.llvm.org/D117309
2022-01-18 16:02:18 +01:00
Qichao Gu 67ac3f1fbe [Driver] Pass the flag -dI to cc1 invocation
Hook up the flag -dI in the driver to pass it to cc1 invocation.

Differential Revision: https://reviews.llvm.org/D117292
2022-01-18 06:16:44 -08:00
Denys Petrov d835dd4cf5 [analyzer] Produce SymbolCast symbols for integral types in SValBuilder::evalCast
Summary: Produce SymbolCast for integral types in `evalCast` function. Apply several simplification techniques while producing the symbols. Added a boolean option `handle-integral-cast-for-ranges` under `-analyzer-config` flag. Disabled the feature by default.

Differential Revision: https://reviews.llvm.org/D105340
2022-01-18 16:08:04 +02:00
Stanislav Gatev 59e031ff90 [clang][dataflow] Add transfer function for addrof
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: xazax.hun

Differential Revision: https://reviews.llvm.org/D117496
2022-01-18 11:23:08 +00:00
Kagami Sascha Rosylight 9c195bae31 [clang] Add include path for cppwinrt on Windows SDK 10.0.17134+
This fixes https://github.com/llvm/llvm-project/issues/53112 by adding
cppwinrt to the include path when the SDK version is higher than
10.0.17134.0.

Differential revision: https://reviews.llvm.org/D117407
2022-01-18 09:14:23 +01:00
Stanislav Gatev 782eced561 [clang][dataflow] Replace initValueInStorageLocation with createValue
Since Environment's setValue method already does part of the work that
initValueInStorageLocation does, we can factor out a new createValue
method to reduce the duplication.

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/D117493
2022-01-18 07:09:35 +00:00