Aaron Puchert [Wed, 26 Jun 2019 21:36:35 +0000 (21:36 +0000)]
[Clang] Remove unused -split-dwarf and obsolete -enable-split-dwarf
Summary:
The changes in D59673 made the choice redundant, since we can achieve
single-file split DWARF just by not setting an output file name.
Like llc we can also derive whether to enable Split DWARF from whether
-split-dwarf-file is set, so we don't need the flag at all anymore.
The test CodeGen/split-debug-filename.c distinguished between having set
or not set -enable-split-dwarf with -split-dwarf-file, but we can
probably just always emit the metadata into the IR.
Alex Lorenz [Wed, 26 Jun 2019 21:11:51 +0000 (21:11 +0000)]
[clang-scan-deps] Introduce the DependencyScanning library with the
thread worker code and better error handling
This commit extracts out the code that will powers the fast scanning
worker into a new file in a new DependencyScanning library. The error
and output handling is improved so that the clients can gather
errors/results from the worker directly.
JF Bastien [Wed, 26 Jun 2019 19:50:12 +0000 (19:50 +0000)]
BitStream reader: propagate errors
The bitstream reader handles errors poorly. This has two effects:
* Bugs in file handling (especially modules) manifest as an "unexpected end of
file" crash
* Users of clang as a library end up aborting because the code unconditionally
calls `report_fatal_error`
The bitstream reader should be more resilient and return Expected / Error as
soon as an error is encountered, not way late like it does now. This patch
starts doing so and adopting the error handling where I think it makes sense.
There's plenty more to do: this patch propagates errors to be minimally useful,
and follow-ups will propagate them further and improve diagnostics.
Xing Xue [Wed, 26 Jun 2019 19:27:16 +0000 (19:27 +0000)]
Print NULL as "(null)" in diagnostic message
Summary:
Passing a null pointer to the printf family for a %s format specifier leads to undefined behaviour. The tests currently expect (null). Explicitly test for a null pointer and provide the expected string.
Without an explicit declaration for placement new, clang would reject
uses of placement new with "'default new' is not supported in OpenCL
C++". This may mislead users into thinking that placement new is not
supported, see e.g. PR42060.
Clarify that placement new requires an explicit declaration.
Kadir Cetinkaya [Wed, 26 Jun 2019 07:39:03 +0000 (07:39 +0000)]
[clang][Tooling] Infer target and mode from argv[0] when using JSONCompilationDatabase
Summary:
Wraps JSON compilation database with a target and mode adding database
wrapper. So that driver can correctly figure out which toolchain to use.
Note that clients that wants to make use of this target discovery mechanism
needs to link in TargetsInfos and initialize them at startup.
Yaxun Liu [Wed, 26 Jun 2019 03:47:37 +0000 (03:47 +0000)]
[HIP] Support attribute hip_pinned_shadow
This patch introduces support of hip_pinned_shadow variable for HIP.
A hip_pinned_shadow variable is a global variable with attribute hip_pinned_shadow.
It has external linkage on device side and has no initializer. It has internal
linkage on host side and has initializer or static constructor. It can be accessed
in both device code and host code.
This allows HIP runtime to implement support of HIP texture reference.
The android target assumes that for the x86_64 target, the CPU supports SSE4.2
and popcnt. This implies that the CPU is Nehalem or newer. This should be
sufficiently new to provide the double word compare and exchange instruction.
This allows us to directly lower `__sync_val_compare_and_swap_16` to a `cmpxchg16b`.
It appears that the libatomic in android's NDK does not provide the
implementation for lowering calls to the library function.
Simon Tatham [Tue, 25 Jun 2019 16:49:32 +0000 (16:49 +0000)]
[ARM] Support inline assembler constraints for MVE.
"To" selects an odd-numbered GPR, and "Te" an even one. There are some
8.1-M instructions that have one too few bits in their register fields
and require registers of particular parity, without necessarily using
a consecutive even/odd pair.
Also, the constraint letter "t" should select an MVE q-register, when
MVE is present. This didn't need any source changes, but some extra
tests have been added.
Haojian Wu [Tue, 25 Jun 2019 08:43:17 +0000 (08:43 +0000)]
[clangd] Narrow rename to local symbols.
Summary:
Previously, we performed rename for all kinds of symbols (local, global).
This patch narrows the scope by only renaming symbols not being used
outside of the main file (with index asisitance). Renaming global
symbols is not supported at the moment (return an error).
Gabor Marton [Tue, 25 Jun 2019 08:00:51 +0000 (08:00 +0000)]
[ASTImporter] Store import errors for Decls
Summary:
We add a new member which is a mapping from the already-imported
declarations in the "from" context to the error status of the import of
that declaration. This map contains only the declarations that were not
correctly imported. The same declaration may or may not be included in
ImportedDecls. This map is updated continuously during imports and never
cleared (like ImportedDecls). In Import(Decl*) we use this mapping, so
if there was a previous failed import we return with the existing error.
We add/remove from the Lookuptable in consistency with ImportedFromDecls.
When we map a decl in the 'to' context to something in the 'from'
context then and only then we add it to the lookup table. When we
remove a mapping then and only then we remove it from the lookup table.
This patch is the first in a series of patches whose aim is to further
strengthen the error handling in ASTImporter.
Artem Dergachev [Tue, 25 Jun 2019 02:16:53 +0000 (02:16 +0000)]
[analyzer] exploded-graph-rewriter: Add support for range constraints.
Diff support included.
A cheap solution is implemented that treats range constraints as
"some sort of key-value map", so it's going to be trivial
to add support for other such maps later, such as dynamic type info.
Artem Dergachev [Tue, 25 Jun 2019 02:16:47 +0000 (02:16 +0000)]
[analyzer] Add more timers for performance profiling.
The -analyzer-stats flag now allows you to find out how much time was spent
on AST-based analysis and on path-sensitive analysis and, separately,
on bug visitors, as they're occasionally a performance problem on their own.
The total timer wasn't useful because there's anyway a total time printed out.
Remove it.
Aaron Ballman [Mon, 24 Jun 2019 20:07:11 +0000 (20:07 +0000)]
Augment location information when dumping the AST to JSON.
Rather than create JSON objects for source locations and ranges, we instead stream them out directly. This allows us to elide duplicate information (without JSON field reordering causing an issue) like file names and line numbers, similar to the text dump. This also adds token length information when dumping the source location.
Leonard Chan [Mon, 24 Jun 2019 16:49:18 +0000 (16:49 +0000)]
[clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM
For CodeGenOpenCL/convergent.cl, the new PM produced a slightly different for
loop, but this still checks for no loop unrolling as intended. This is
committed separately from D63174.
Richard Smith [Sat, 22 Jun 2019 21:30:43 +0000 (21:30 +0000)]
Fix TBAA representation for zero-sized fields and unnamed bit-fields.
Unnamed bit-fields should not be represented in the TBAA metadata
because they do not represent storage fields (they only affect layout).
Zero-sized fields should not be represented in the TBAA metadata
because by definition they have no associated storage (so we will never
emit a load or store through them), and they might not appear in
declaration order within the struct layout.
Fixes a verifier failure when emitting a TBAA-enabled load through a
class type containing a zero-sized field.
This is reduced from MSVC's MSVCPRT 14.21.27702 atomic header. Because
Windows is a LLP64 environment, `long`, `long int`, and `int` are all
synonymous. Change the signature for `__iso_volatile_load32` and
`__iso_volatile_store32` to accept a `long int` instead. This allows
an implicit cast of `int` to `long int` while also permitting `long`
to be accepted.
Craig Topper [Sat, 22 Jun 2019 07:21:48 +0000 (07:21 +0000)]
[X86] Don't use _MM_FROUND_CUR_DIRECTION in the intrinsics tests.
_MM_FROUND_CUR_DIRECTION is the behavior of the intrinsics that
don't take a rounding mode argument. So a better test
is using _MM_FROUND_NO_EXC with the SAE only intrinsics and
an explicit rounding mode with the intrinsics that support
embedded rounding mode.
Richard Trieu [Sat, 22 Jun 2019 00:32:19 +0000 (00:32 +0000)]
[ODRHash] Skip some typedef types.
In some cases, a typedef only strips aways a keyword for a type, keeping the
same name as the root record type. This causes some confusion when the type
is defined in one modules but only forward declared in another. Skipping the
typedef and going straight to the record will avoid this issue.
typedef struct S {} S;
S* s; // S is TypedefType here
Erich Keane [Fri, 21 Jun 2019 22:29:32 +0000 (22:29 +0000)]
Ensure Target Features always_inline error happens in C++ cases.
A handful of C++ cases as reported in PR42352 didn't actually give an
error when always_inlining with a different target feature list. This
resulted in broken IR.
Richard Smith [Fri, 21 Jun 2019 20:46:22 +0000 (20:46 +0000)]
PR42301: Abort cleanly if we encounter a huge source file rather than
crashing.
Ideally we wouldn't care about the size of a file so long as it fits in
memory, but in practice we have lots of hardocded assumptions that
unsigned can be used to index files, string literals, and so on.
Alexey Bataev [Fri, 21 Jun 2019 17:28:41 +0000 (17:28 +0000)]
[OPENMP]Fix PR42068: Vla type is not captured.
If the variably modified type is declared outside of the captured region
and then used in the cast expression along with array subscript
expression, the type is not captured and it leads to the compiler crash.
Leonard Chan [Fri, 21 Jun 2019 16:03:06 +0000 (16:03 +0000)]
[clang][NewPM] Add -fno-experimental-new-pass-manager to tests
As per the discussion on D58375, we disable test that have optimizations under
the new PM. This patch adds -fno-experimental-new-pass-manager to RUNS that:
- Already run with optimizations (-O1 or higher) that were missed in D58375.
- Explicitly test new PM behavior along side some new PM RUNS, but are missing
this flag if new PM is enabled by default.
- Specify -O without the number. Based on getOptimizationLevel(), it seems the
default is 2, and the IR appears to be the same when changed to -O2, so
update the test to explicitly say -O2 and provide -fno-experimental-new-pass-manager`.
Aaron Ballman [Fri, 21 Jun 2019 14:37:39 +0000 (14:37 +0000)]
Add an automated note to files produced by gen_ast_dump_json_test.py.
This also details what filters, if any, were used to generate the test output. Updates all the current JSON testing files to include the automated note.
[cmake] Add llvm-dwarfdump to clang test dependencies
Commit r363496 ("[Clang] Harmonize Split DWARF options with llc",
2019-06-15) introduced the use of llvm-dwarfdump in the clang tests,
so ensure the clang tests are dependent on llvm-dwarfdump.
Sam Elliott [Fri, 21 Jun 2019 10:03:31 +0000 (10:03 +0000)]
[RISC-V] Add -msave-restore and -mno-save-restore to clang driver
Summary:
The GCC RISC-V toolchain accepts `-msave-restore` and `-mno-save-restore`
to control whether libcalls are used for saving and restoring the stack within
prologues and epilogues.
Clang currently errors if someone passes -msave-restore or -mno-save-restore.
This means that people need to change build configurations to use clang. This
patch adds these flags, so that clang invocations can now match gcc.
As the RISC-V backend does not currently have a `save-restore` target feature,
we emit a warning if someone requests `-msave-restore`. LLVM does not error if
we pass the (unimplemented) target features `+save-restore` or `-save-restore`.
[clang] Small improvments after Adding APValue to ConstantExpr
Summary:
this patch has multiple small improvements related to the APValue in ConstantExpr.
changes:
- APValue in ConstantExpr are now cleaned up using ASTContext::addDestruction instead of there own system.
- ConstantExprBits Stores the ValueKind of the result beaing stored.
- VerifyIntegerConstantExpression now stores the evaluated value in ConstantExpr.
- the Constant Evaluator uses the stored value of ConstantExpr when available.
Jordan Rupprecht [Thu, 20 Jun 2019 22:35:52 +0000 (22:35 +0000)]
[CodeGen][test] Use FileCheck variable matchers for better test support
Summary: Depending on how clang is built, it may discard the IR names and use names like `%2` instead of `%result.ptr`, causing tests that rely on the IR name to fail. Using FileCheck matchers makes the test work regardless of how clang is built.
This test passes with both `-fno-discard-value-names` and `-fdiscard-value-names` to make sure it passes regardless of the build mode.
Clang :: Driver/cl-response-file.c currently FAILs on Solaris:
Command Output (stderr):
--
/vol/llvm/src/clang/dist/test/Driver/cl-response-file.c:10:11: error: CHECK: expected string not found in input
// CHECK: "-I" "{{.*}}\\Inputs\\cl-response-file\\" "-D" "FOO=2"
^
Looking at the generated response file reveals that this is no surprise:
/I/vol/llvm/src/clang/dist/test/Driver\Inputs
with no newline at the end. The echo command used to create it boils down to
echo 'a\cb'
However, one cannot expect \c to be emitted literally: e.g. bash's builtin
echo has
\c suppress further output
I've tried various combinations of builtin echo, /usr/bin/echo, GNU echo if
different, the same for printf, and the backslash unescaped and quoted
(a\cb and a\\cb). The only combination that worked reliably on Solaris,
Linux, and macOS was
printf 'a\\cb'
so this is what this patch uses. Tested on amd64-pc-solaris2.11 and
x86_64-pc-linux-gnu.
Richard Smith [Thu, 20 Jun 2019 19:49:13 +0000 (19:49 +0000)]
Fix crash and rejects-valid when a later template parameter or default
template argument contains a backreference to a dependently-typed
earlier parameter.
In a case like:
template<typename T, T A, decltype(A) = A> struct X {};
template<typename U> auto Y = X<U, 0>();
we previously treated both references to `A` in the third parameter as
being of type `int` when checking the template-id in `Y`. That`s wrong;
the type of `A` in these contexts is the dependent type `U`.
When we encounter a non-type template argument that we can't convert to
the parameter type because of type-dependence, we now insert a dependent
conversion node so that the SubstNonTypeTemplateParmExpr for the
template argument will have the parameter's type rather than whatever
type the argument had.
Leonard Chan [Thu, 20 Jun 2019 19:44:51 +0000 (19:44 +0000)]
[clang][NewPM] Do not eliminate available_externally durng `-O2 -flto` runs
This fixes CodeGen/available-externally-suppress.c when the new pass manager is
turned on by default. available_externally was not emitted during -O2 -flto
runs when it should still be retained for link time inlining purposes. This can
be fixed by checking that we aren't LTOPrelinking when adding the
EliminateAvailableExternallyPass.
Leonard Chan [Thu, 20 Jun 2019 19:35:25 +0000 (19:35 +0000)]
[clang][NewPM] Move EntryExitInstrumenterPass to the start of the pipeline
This fixes CodeGen/x86_64-instrument-functions.c when running under the new
pass manager. The pass should go before any other pass to prevent
`__cyg_profile_func_enter/exit()` from not being emitted by inlined functions.