]> granicus.if.org Git - clang/log
clang
4 years agoInclude leading attributes in DeclStmt's SourceRange
Stephan Bergmann [Thu, 17 Oct 2019 11:20:21 +0000 (11:20 +0000)]
Include leading attributes in DeclStmt's SourceRange

Differential Revision: https://reviews.llvm.org/D68581

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375104 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoSemaExprCXX - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Thu, 17 Oct 2019 11:12:31 +0000 (11:12 +0000)]
SemaExprCXX - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375101 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoSemaDeclObjC - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Thu, 17 Oct 2019 10:35:29 +0000 (10:35 +0000)]
SemaDeclObjC - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375097 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoReland: Dead Virtual Function Elimination
Oliver Stannard [Thu, 17 Oct 2019 09:58:57 +0000 (09:58 +0000)]
Reland: Dead Virtual Function Elimination

Remove dead virtual functions from vtables with
replaceNonMetadataUsesWith, so that CGProfile metadata gets cleaned up
correctly.

Original commit message:

Currently, it is hard for the compiler to remove unused C++ virtual
functions, because they are all referenced from vtables, which are referenced
by constructors. This means that if the constructor is called from any live
code, then we keep every virtual function in the final link, even if there
are no call sites which can use it.

This patch allows unused virtual functions to be removed during LTO (and
regular compilation in limited circumstances) by using type metadata to match
virtual function call sites to the vtable slots they might load from. This
information can then be used in the global dead code elimination pass instead
of the references from vtables to virtual functions, to more accurately
determine which functions are reachable.

To make this transformation safe, I have changed clang's code-generation to
always load virtual function pointers using the llvm.type.checked.load
intrinsic, instead of regular load instructions. I originally tried writing
this using clang's existing code-generation, which uses the llvm.type.test
and llvm.assume intrinsics after doing a normal load. However, it is possible
for optimisations to obscure the relationship between the GEP, load and
llvm.type.test, causing GlobalDCE to fail to find virtual function call
sites.

The existing linkage and visibility types don't accurately describe the scope
in which a virtual call could be made which uses a given vtable. This is
wider than the visibility of the type itself, because a virtual function call
could be made using a more-visible base class. I've added a new
!vcall_visibility metadata type to represent this, described in
TypeMetadata.rst. The internalization pass and libLTO have been updated to
change this metadata when linking is performed.

This doesn't currently work with ThinLTO, because it needs to see every call
to llvm.type.checked.load in the linkage unit. It might be possible to
extend this optimisation to be able to use the ThinLTO summary, as was done
for devirtualization, but until then that combination is rejected in the
clang driver.

To test this, I've written a fuzzer which generates random C++ programs with
complex class inheritance graphs, and virtual functions called through object
and function pointers of different types. The programs are spread across
multiple translation units and DSOs to test the different visibility
restrictions.

I've also tried doing bootstrap builds of LLVM to test this. This isn't
ideal, because only classes in anonymous namespaces can be optimised with
-fvisibility=default, and some parts of LLVM (plugins and bugpoint) do not
work correctly with -fvisibility=hidden. However, there are only 12 test
failures when building with -fvisibility=hidden (and an unmodified compiler),
and this change does not cause any new failures for either value of
-fvisibility.

On the 7 C++ sub-benchmarks of SPEC2006, this gives a geomean code-size
reduction of ~6%, over a baseline compiled with "-O2 -flto
-fvisibility=hidden -fwhole-program-vtables". The best cases are reductions
of ~14% in 450.soplex and 483.xalancbmk, and there are no code size
increases.

I've also run this on a set of 8 mbed-os examples compiled for Armv7M, which
show a geomean size reduction of ~3%, again with no size increases.

I had hoped that this would have no effect on performance, which would allow
it to awlays be enabled (when using -fwhole-program-vtables). However, the
changes in clang to use the llvm.type.checked.load intrinsic are causing ~1%
performance regression in the C++ parts of SPEC2006. It should be possible to
recover some of this perf loss by teaching optimisations about the
llvm.type.checked.load intrinsic, which would make it worth turning this on
by default (though it's still dependent on -fwhole-program-vtables).

Differential revision: https://reviews.llvm.org/D63932

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375094 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoRevert "Include sanitize blacklist and other extra deps as part of scan-deps output"
Kousik Kumar [Thu, 17 Oct 2019 04:50:12 +0000 (04:50 +0000)]
Revert "Include sanitize blacklist and other extra deps as part of scan-deps output"

This test is failing on Windows bots, revert for now (will check the right fix and retry the patch).

Summary: This reverts commit 962ca076e51c25a7a08f4e0d329c65328a635bdb.

Reviewers: Bigcheese, jkorous, arphaman

Subscribers: dexonsmith, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69079

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375079 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoInclude sanitize blacklist and other extra deps as part of scan-deps output
Kousik Kumar [Thu, 17 Oct 2019 02:14:44 +0000 (02:14 +0000)]
Include sanitize blacklist and other extra deps as part of scan-deps output

Summary:
Clang's -M mode includes these extra dependencies in its output and clang-scan-deps
should have equivalent behavior, so adding these extradeps to output just like
how its being done for ".d" file generation mode.

Reviewers: arphaman, dexonsmith, Bigcheese, jkorous

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69017

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375074 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoRevert Tag CFI-generated data structures with "#pragma clang section" attributes.
Dmitry Mikulin [Thu, 17 Oct 2019 00:55:38 +0000 (00:55 +0000)]
Revert Tag CFI-generated data structures with "#pragma clang section" attributes.

This reverts r375022 (git commit e2692b3bc0327606748b6d291b9009d2c845ced5)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375069 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Concepts] ConceptSpecializationExprs mangling
Saar Raz [Thu, 17 Oct 2019 00:16:01 +0000 (00:16 +0000)]
[Concepts] ConceptSpecializationExprs mangling

Implement mangling for CSEs to match regular template-ids.
Reviewed as part of D41569 <https://reviews.llvm.org/D41569>.

Re-commit fixing failing test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375063 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoReplace platform-dependent `stat` with `llvm::sys::fs::status`. NFC intended.
Volodymyr Sapsai [Wed, 16 Oct 2019 19:12:34 +0000 (19:12 +0000)]
Replace platform-dependent `stat` with `llvm::sys::fs::status`. NFC intended.

Reviewers: bruno, sammccall

Reviewed By: sammccall

Subscribers: jkorous, dexonsmith, arphaman, ributzka, cfe-commits

Differential Revision: https://reviews.llvm.org/D69011

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375031 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoFix darwin-ld-lto test for some speical path
Steven Wu [Wed, 16 Oct 2019 18:12:41 +0000 (18:12 +0000)]
Fix darwin-ld-lto test for some speical path

Fix the test by not assuming the prefix path of the temp directory can
be matched by a regex.

rdar://problem/56259195

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375027 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[OPENMP]Allow priority clause in combined task-based directives.
Alexey Bataev [Wed, 16 Oct 2019 18:09:37 +0000 (18:09 +0000)]
[OPENMP]Allow priority clause in combined task-based directives.

The expression of the priority clause must be captured in the combined
task-based directives, like 'parallel master taskloop' directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375026 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoTag CFI-generated data structures with "#pragma clang section" attributes.
Dmitry Mikulin [Wed, 16 Oct 2019 17:51:40 +0000 (17:51 +0000)]
Tag CFI-generated data structures with "#pragma clang section" attributes.

Differential Revision: https://reviews.llvm.org/D68808

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375022 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[OPENMP]Use different addresses for zeroed thread_id/bound_id.
Alexey Bataev [Wed, 16 Oct 2019 16:59:01 +0000 (16:59 +0000)]
[OPENMP]Use different addresses for zeroed thread_id/bound_id.

When the parallel region is called directly in the sequential region,
the zeroed tid/bound id are used. But they must point to the different
memory locations as the parameters are marked as noalias.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375017 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[DWARF5] Added support for DW_AT_noreturn attribute to be emitted for
Adrian Prantl [Wed, 16 Oct 2019 16:30:38 +0000 (16:30 +0000)]
[DWARF5] Added support for DW_AT_noreturn attribute to be emitted for
C++ class member functions.

Patch by Sourabh Singh Tomar!

Differential Revision: https://reviews.llvm.org/D68697

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375012 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[libTooling] Fix r374962: add more Transformer forwarding decls.
Yitzhak Mandelbaum [Wed, 16 Oct 2019 14:26:20 +0000 (14:26 +0000)]
[libTooling] Fix r374962: add more Transformer forwarding decls.

Summary:
The move to a new, single namespace in r374962 left out some type definitions
from the old namespace and resulted in one naming conflict (`text`).  This
revision adds aliases for those definitions and removes one of the `text`
functions from the new namespace.

Reviewers: alexfh

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69036

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375003 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Driver,ARM] Make -mfloat-abi=soft turn off MVE.
Simon Tatham [Wed, 16 Oct 2019 13:23:39 +0000 (13:23 +0000)]
[Driver,ARM] Make -mfloat-abi=soft turn off MVE.

Since `-mfloat-abi=soft` is taken to mean turning off all uses of the
FP registers, it should turn off the MVE vector instructions as well
as NEON and scalar FP. But it wasn't doing so.

So the options `-march=armv8.1-m.main+mve.fp+fp.dp -mfloat-abi=soft`
would cause the underlying LLVM to //not// support MVE (because it
knows the real target feature relationships and turned off MVE when
the `fpregs` feature was removed), but the clang layer still thought
it //was// supported, and would misleadingly define the feature macro
`__ARM_FEATURE_MVE`.

The ARM driver code already has a long list of feature names to turn
off when `-mfloat-abi=soft` is selected. The fix is to add the missing
entries `mve` and `mve.fp` to that list.

Reviewers: dmgreen

Subscribers: kristof.beyls, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69025

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375001 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoRewriteModernObjC - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Wed, 16 Oct 2019 10:50:06 +0000 (10:50 +0000)]
RewriteModernObjC - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374991 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoCGDebugInfo - silence static analyzer dyn_cast<> null dereference warnings. NFCI.
Simon Pilgrim [Wed, 16 Oct 2019 10:38:49 +0000 (10:38 +0000)]
CGDebugInfo - silence static analyzer dyn_cast<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use cast<> directly and if not assert will fire for us.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374989 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoCGExprConstant - silence static analyzer getAs<> null dereference warning. NFCI.
Simon Pilgrim [Wed, 16 Oct 2019 10:38:40 +0000 (10:38 +0000)]
CGExprConstant - silence static analyzer getAs<> null dereference warning. NFCI.

The static analyzer is warning about a potential null dereference, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374988 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoCGBuiltin - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Wed, 16 Oct 2019 10:38:32 +0000 (10:38 +0000)]
CGBuiltin - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374987 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoRevert 374967 "[Concepts] ConceptSpecializationExprs mangling"
Nico Weber [Wed, 16 Oct 2019 10:23:53 +0000 (10:23 +0000)]
Revert 374967 "[Concepts] ConceptSpecializationExprs mangling"

This reverts commit 5e34ad109ced8dbdea9500ee28180315b2aeba3d.

The mangling test fails on Windows:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/15944

It also fails on ppc64le:
http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/21092

Also revert follow-up  374971 "Fix failing mangle-concept.cpp test."
(it did not help on Win/ppc64le).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374985 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoFix failing mangle-concept.cpp test.
Saar Raz [Wed, 16 Oct 2019 02:56:40 +0000 (02:56 +0000)]
Fix failing mangle-concept.cpp test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374971 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Concepts] ConceptSpecializationExprs mangling
Saar Raz [Wed, 16 Oct 2019 02:33:41 +0000 (02:33 +0000)]
[Concepts] ConceptSpecializationExprs mangling

Implement mangling for CSEs to match regular template-ids.
Reviewed as part of D41569.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374967 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[libTooling] Put all Transformer declarations in a single namespace.
Yitzhak Mandelbaum [Wed, 16 Oct 2019 01:06:46 +0000 (01:06 +0000)]
[libTooling] Put all Transformer declarations in a single namespace.

Summary:
This revision introduces a new namespace, `clang::transformer`, to hold
the declarations for the Transformer library.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68876

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374962 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoPR43674: fix incorrect constant evaluation of 'switch' where no case
Richard Smith [Tue, 15 Oct 2019 22:23:11 +0000 (22:23 +0000)]
PR43674: fix incorrect constant evaluation of 'switch' where no case
label corresponds to the condition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374954 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoRemove unnecessary and inappropriate forward-declaration of Sema from
Richard Smith [Tue, 15 Oct 2019 21:50:24 +0000 (21:50 +0000)]
Remove unnecessary and inappropriate forward-declaration of Sema from
AST.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374952 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[OPENMP]Fix comments/params, NFC.
Alexey Bataev [Tue, 15 Oct 2019 19:51:30 +0000 (19:51 +0000)]
[OPENMP]Fix comments/params, NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374943 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[OPENMP]Allow final clause in combined task-based directives.
Alexey Bataev [Tue, 15 Oct 2019 19:37:05 +0000 (19:37 +0000)]
[OPENMP]Allow final clause in combined task-based directives.
The condition of the final clause must be captured in the combined
task-based directives, like 'parallel master taskloop' directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374942 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Concept] Associated Constraints Infrastructure
Saar Raz [Tue, 15 Oct 2019 18:44:06 +0000 (18:44 +0000)]
[Concept] Associated Constraints Infrastructure

Add code to correctly calculate the associated constraints of a template (no enforcement yet).
D41284 on Phabricator.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374938 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Clang][OpenMP Offload] Move offload registration code to the wrapper
Sergey Dmitriev [Tue, 15 Oct 2019 18:42:47 +0000 (18:42 +0000)]
[Clang][OpenMP Offload] Move offload registration code to the wrapper

The final list of OpenMP offload targets becomes known only at the link time and since offload registration code depends on the targets list it makes sense to delay offload registration code generation to the link time instead of adding it to the host part of every fat object. This patch moves offload registration code generation from clang to the offload wrapper tool.

This is the last part of the OpenMP linker script elimination patch https://reviews.llvm.org/D64943

Differential Revision: https://reviews.llvm.org/D68746

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374937 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoFix as-w-option.c on Windows where no assembler exists
Reid Kleckner [Tue, 15 Oct 2019 18:39:41 +0000 (18:39 +0000)]
Fix as-w-option.c on Windows where no assembler exists

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374936 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoAdded support for "#pragma clang section relro=<name>"
Dmitry Mikulin [Tue, 15 Oct 2019 18:31:10 +0000 (18:31 +0000)]
Added support for "#pragma clang section relro=<name>"

Differential Revision: https://reviews.llvm.org/D68806

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374934 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[clang] refactor -Wa,-W test cases.
Jian Cai [Tue, 15 Oct 2019 18:17:08 +0000 (18:17 +0000)]
[clang] refactor -Wa,-W test cases.

Remove REQUIRES and only keep the clang driver tests, since the
assembler are already tested with -Wa,--no-warn. This way we could run
the test on non-linux platforms and catch breaks on them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374932 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoFix Driver/working-directory.c test
Jan Korous [Tue, 15 Oct 2019 18:04:18 +0000 (18:04 +0000)]
Fix Driver/working-directory.c test

Accidentally committed debug print.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374929 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoReland [Driver] Fix -working-directory issues
Jan Korous [Tue, 15 Oct 2019 17:51:59 +0000 (17:51 +0000)]
Reland [Driver] Fix -working-directory issues

Don't change the default VFS in Driver, update tests & reland.

This reverts commit 999f8a7416f8edc54ef92e715fd23c532bcc74d4.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374926 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoAdd more information to JSON AST dumping of source locations.
Aaron Ballman [Tue, 15 Oct 2019 17:30:19 +0000 (17:30 +0000)]
Add more information to JSON AST dumping of source locations.

This adds information about the offset within the source file to the given source location as well as information about the include file a location is from. These pieces of information allow for more efficient post-processing of JSON AST dumps.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374921 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoCFI: wrong type passed to llvm.type.test with multiple inheritance devirtualization.
Dmitry Mikulin [Tue, 15 Oct 2019 16:32:50 +0000 (16:32 +0000)]
CFI: wrong type passed to llvm.type.test with multiple inheritance devirtualization.

Differential Revision: https://reviews.llvm.org/D67985

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374909 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Concepts] Remove unused and illegal Sema includes from ExprCXX.cpp
Saar Raz [Tue, 15 Oct 2019 15:49:29 +0000 (15:49 +0000)]
[Concepts] Remove unused and illegal Sema includes from ExprCXX.cpp

Fixing accidental includes introduced in 374903

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374907 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Concepts] Concept Specialization Expressions
Saar Raz [Tue, 15 Oct 2019 15:24:26 +0000 (15:24 +0000)]
[Concepts] Concept Specialization Expressions

Part of C++20 Concepts implementation effort. Added Concept Specialization Expressions that are created when a concept is refe$

D41217 on Phabricator.

(recommit after fixing failing Parser test on windows)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374903 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoRevert 374882 "[Concepts] Concept Specialization Expressions"
Nico Weber [Tue, 15 Oct 2019 14:46:39 +0000 (14:46 +0000)]
Revert 374882 "[Concepts] Concept Specialization Expressions"

This reverts commit ec87b003823d63f3342cf648f55a134c1522e612.
The test fails on Windows, see e.g.
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11533/steps/stage%201%20check/logs/stdio

Also revert follow-up r374893.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374899 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoReapply: [Modules][PCH] Hash input files content
Bruno Cardoso Lopes [Tue, 15 Oct 2019 14:23:55 +0000 (14:23 +0000)]
Reapply: [Modules][PCH] Hash input files content

Summary:
When files often get touched during builds, the mtime based validation
leads to different problems in implicit modules builds, even when the
content doesn't actually change:

- Modules only: module invalidation due to out of date files. Usually causing rebuild traffic.
- Modules + PCH: build failures because clang cannot rebuild a module if it comes from building a PCH.
- PCH: build failures because clang cannot rebuild a PCH in case one of the input headers has different mtime.

This patch proposes hashing the content of input files (headers and
module maps), which is performed during serialization time. When looking
at input files for validation, clang only computes the hash in case
there's a mtime mismatch.

I've tested a couple of different hash algorithms availble in LLVM in
face of building modules+pch for `#import <Cocoa/Cocoa.h>`:
- `hash_code`: performace diff within the noise, total module cache increased by 0.07%.
- `SHA1`: 5% slowdown. Haven't done real size measurements, but it'd be BLOCK_ID+20 bytes per input file, instead of BLOCK_ID+8 bytes from `hash_code`.
- `MD5`: 3% slowdown. Like above, but BLOCK_ID+16 bytes per input file.

Given the numbers above, the patch uses `hash_code`. The patch also
improves invalidation error msgs to point out which type of problem the
user is facing: "mtime", "size" or "content".

rdar://problem/29320105

Reviewers: dexonsmith, arphaman, rsmith, aprantl

Subscribers: jkorous, cfe-commits, ributzka

Tags: #clang

Differential Revision: https://reviews.llvm.org/D67249

llvm-svn: 374841

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374895 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[AST] Remove unused Sema includes to fix a cyclic dependency from Sema to AST
Benjamin Kramer [Tue, 15 Oct 2019 14:23:05 +0000 (14:23 +0000)]
[AST] Remove unused Sema includes to fix a cyclic dependency from Sema to AST

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374893 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Alignment] Migrate Attribute::getWith(Stack)Alignment
Guillaume Chatelet [Tue, 15 Oct 2019 12:56:24 +0000 (12:56 +0000)]
[Alignment] Migrate Attribute::getWith(Stack)Alignment

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet, jdoerfert

Reviewed By: courbet

Subscribers: arsenm, jvesely, nhaehnle, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D68792

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374884 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Concepts] Concept Specialization Expressions
Saar Raz [Tue, 15 Oct 2019 11:48:58 +0000 (11:48 +0000)]
[Concepts] Concept Specialization Expressions

Part of C++20 Concepts implementation effort. Added Concept Specialization Expressions that are created when a concept is referenced with arguments, and tests thereof.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374882 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoFix uninitialized variable warnings. NFCI.
Simon Pilgrim [Tue, 15 Oct 2019 10:23:05 +0000 (10:23 +0000)]
Fix uninitialized variable warnings. NFCI.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374876 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Format] Add machine-readable SPDX license ID to clang-format.el
Sam McCall [Tue, 15 Oct 2019 07:25:18 +0000 (07:25 +0000)]
[Format] Add machine-readable SPDX license ID to clang-format.el

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374864 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[WebAssembly] Trapping fptoint builtins and intrinsics
Thomas Lively [Tue, 15 Oct 2019 01:11:51 +0000 (01:11 +0000)]
[WebAssembly] Trapping fptoint builtins and intrinsics

Summary:
The WebAssembly backend lowers fptoint instructions to a code sequence
that checks for overflow to avoid traps because fptoint is supposed to
be speculatable. These new builtins and intrinsics give users a way to
depend on the trapping semantics of the underlying instructions and
avoid the extra code generated normally.

Patch by coffee and tlively.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D68902

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374856 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoRevert "Dead Virtual Function Elimination"
Jorge Gorbe Moya [Mon, 14 Oct 2019 23:25:25 +0000 (23:25 +0000)]
Revert "Dead Virtual Function Elimination"

This reverts commit 9f6a873268e1ad9855873d9d8007086c0d01cf4f.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374844 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoTemporarily Revert [Modules][PCH] Hash input files content
Eric Christopher [Mon, 14 Oct 2019 23:14:24 +0000 (23:14 +0000)]
Temporarily Revert [Modules][PCH] Hash input files content
as it's breaking a few bots.

This reverts r374841 (git commit 2a1386c81de504b5bda44fbecf3f7b4cdfd748fc)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374842 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Modules][PCH] Hash input files content
Bruno Cardoso Lopes [Mon, 14 Oct 2019 23:02:03 +0000 (23:02 +0000)]
[Modules][PCH] Hash input files content

Summary:
When files often get touched during builds, the mtime based validation
leads to different problems in implicit modules builds, even when the
content doesn't actually change:

- Modules only: module invalidation due to out of date files. Usually causing rebuild traffic.
- Modules + PCH: build failures because clang cannot rebuild a module if it comes from building a PCH.
- PCH: build failures because clang cannot rebuild a PCH in case one of the input headers has different mtime.

This patch proposes hashing the content of input files (headers and
module maps), which is performed during serialization time. When looking
at input files for validation, clang only computes the hash in case
there's a mtime mismatch.

I've tested a couple of different hash algorithms availble in LLVM in
face of building modules+pch for `#import <Cocoa/Cocoa.h>`:
- `hash_code`: performace diff within the noise, total module cache increased by 0.07%.
- `SHA1`: 5% slowdown. Haven't done real size measurements, but it'd be BLOCK_ID+20 bytes per input file, instead of BLOCK_ID+8 bytes from `hash_code`.
- `MD5`: 3% slowdown. Like above, but BLOCK_ID+16 bytes per input file.

Given the numbers above, the patch uses `hash_code`. The patch also
improves invalidation error msgs to point out which type of problem the
user is facing: "mtime", "size" or "content".

rdar://problem/29320105

Reviewers: dexonsmith, arphaman, rsmith, aprantl

Subscribers: jkorous, cfe-commits, ributzka

Tags: #clang

Differential Revision: https://reviews.llvm.org/D67249

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374841 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoAdd -fno-experimental-pass-manager to make clear which pass manager
Eric Christopher [Mon, 14 Oct 2019 23:01:48 +0000 (23:01 +0000)]
Add -fno-experimental-pass-manager to make clear which pass manager
we're running and to make flipping the default not regress testing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374840 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoIn the new pass manager use PTO.LoopUnrolling to determine when and how
Eric Christopher [Mon, 14 Oct 2019 22:56:07 +0000 (22:56 +0000)]
In the new pass manager use PTO.LoopUnrolling to determine when and how
we will unroll loops. Also comment a few occasions where we need to
know whether or not we're forcing the unwinder or not.

The default before and after this patch is for LoopUnroll to be enabled,
and for it to use a cost model to determine whether to unroll the loop
(`OnlyWhenForced = false`). Before this patch, disabling loop unroll
would not run the LoopUnroll pass. After this patch, the LoopUnroll pass
is being run, but it restricts unrolling to only the loops marked by a
pragma (`OnlyWhenForced = true`).

In addition, this patch disables the UnrollAndJam pass when disabling unrolling.

Testcase is in clang because it's controlling how the loop optimizer
is being set up and there's no other way to trigger the behavior.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374838 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[clang] add requirements to -Wa,-W test cases.
Jian Cai [Mon, 14 Oct 2019 22:51:12 +0000 (22:51 +0000)]
[clang] add requirements to -Wa,-W test cases.

Include linux as a test requirement.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374837 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[test] Fix test failure
Eli Friedman [Mon, 14 Oct 2019 22:44:42 +0000 (22:44 +0000)]
[test] Fix test failure

The version mismatch symbol is version 9 on 32 bit android. Since
this test isn't actually testing any android specific functionality,
we force the target triple to x86_64-unknown-unknown in order to have
a consistent version number. It seems the test was already trying to
do this, just not doing it right

Patch by Christopher Tetrault

Differential Revision: https://reviews.llvm.org/D68882

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374836 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoAdd support to -Wa,-W in clang
Jian Cai [Mon, 14 Oct 2019 22:28:03 +0000 (22:28 +0000)]
Add support to -Wa,-W in clang

Summary:
Currently clang does not support -Wa,-W, which suppresses warning
messages in GNU assembler. Add this option for gcc compatibility.
https://bugs.llvm.org/show_bug.cgi?id=43651. Reland with differential
information.

Reviewers: bcain

Reviewed By: bcain

Subscribers: george.burgess.iv, gbiv, llozano, manojgupta, nickdesaulniers, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68884

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374834 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoRevert "Add support to -Wa,-W in clang"
Jian Cai [Mon, 14 Oct 2019 22:28:01 +0000 (22:28 +0000)]
Revert "Add support to -Wa,-W in clang"

This reverts commit e72eeca43b9577be2aae55f7603febbf223a6ab3.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374833 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoPR43080: Do not build context-sensitive expressions during name classification.
Richard Smith [Mon, 14 Oct 2019 21:53:03 +0000 (21:53 +0000)]
PR43080: Do not build context-sensitive expressions during name classification.

Summary:
We don't know what context to use until the classification result is
consumed by the parser, which could happen in a different semantic
context. So don't build the expression that results from name
classification until we get to that point and can handle it properly.

This covers everything except C++ implicit class member access, which
is a little awkward to handle properly in the face of the protected
member access check. But it at least fixes all the currently-filed
instances of PR43080.

Reviewers: efriedma

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68896

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374826 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoAdd support to -Wa,-W in clang
Jian Cai [Mon, 14 Oct 2019 21:21:39 +0000 (21:21 +0000)]
Add support to -Wa,-W in clang

Currently clang does not support -Wa,-W, which suppresses warning
messages in GNU assembler. Add this option for gcc compatibility.
https://bugs.llvm.org/show_bug.cgi?id=43651

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374822 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[NFC] Fix ClangScanDeps/static-analyzer.c test on Windows
Jan Korous [Mon, 14 Oct 2019 21:06:11 +0000 (21:06 +0000)]
[NFC] Fix ClangScanDeps/static-analyzer.c test on Windows

Follow-up to c5d14b5c6fa

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374821 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[OPNEMP]Allow num_tasks clause in combined task-based directives.
Alexey Bataev [Mon, 14 Oct 2019 20:44:34 +0000 (20:44 +0000)]
[OPNEMP]Allow num_tasks clause in combined task-based directives.

The expression of the num_tasks clause must be captured in the combined
task-based directives, like 'parallel master taskloop' directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374819 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[clang-scan-deps] Support for clang --analyze in clang-scan-deps
Jan Korous [Mon, 14 Oct 2019 20:15:01 +0000 (20:15 +0000)]
[clang-scan-deps] Support for clang --analyze in clang-scan-deps

The goal is to have 100% fidelity in clang-scan-deps behavior when
--analyze is present in compilation command.

At the same time I don't want to break clang-tidy which expects
__static_analyzer__ macro defined as built-in.

I introduce new cc1 options (-setup-static-analyzer) that controls
the macro definition and is conditionally set in driver.

Differential Revision: https://reviews.llvm.org/D68093

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374815 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[OPNEMP]Allow grainsize clause in combined task-based directives.
Alexey Bataev [Mon, 14 Oct 2019 19:29:52 +0000 (19:29 +0000)]
[OPNEMP]Allow grainsize clause in combined task-based directives.

The expression of the grainsize clause must be captured in the combined
task-based directives, like 'parallel master taskloop' directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374810 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[clang][IFS][test] Fixing lit test breakages on macOS due to r374798
Puyan Lotfi [Mon, 14 Oct 2019 18:57:29 +0000 (18:57 +0000)]
[clang][IFS][test] Fixing lit test breakages on macOS due to r374798

Adding the quotes breaks tests because on Darwin the name mangling is prefixed
with an underscore.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374805 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[clang][IFS] Escape mangled names so MS ABI doesn't break YAML parsing.
Puyan Lotfi [Mon, 14 Oct 2019 18:03:03 +0000 (18:03 +0000)]
[clang][IFS] Escape mangled names so  MS ABI doesn't break YAML parsing.

Microsoft's ABI mangles names differently than Itanium and this breaks the LLVM
yaml parser unless the name is escaped in quotes. Quotes are being added to the
mangled names of the IFS file generation so that llvm-ifs doesn't break when
Windows triples are passed to the driver.

Differential Revision: https://reviews.llvm.org/D68915

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374798 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[OPENMP50]Add support for 'parallel master taskloop' construct.
Alexey Bataev [Mon, 14 Oct 2019 17:17:41 +0000 (17:17 +0000)]
[OPENMP50]Add support for 'parallel master taskloop' construct.

Added parsing/sema/codegen support for 'parallel master taskloop'
constructs. Some of the clauses, like 'grainsize', 'num_tasks', 'final'
and 'priority' are not supported in full, only constant expressions can
be used currently in these clauses.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374791 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[OPENMP]Fix codegen for private variably length vars in combined
Alexey Bataev [Mon, 14 Oct 2019 16:44:01 +0000 (16:44 +0000)]
[OPENMP]Fix codegen for private variably length vars in combined
constructs.

If OpenMP construct includes several capturing regions and the variable
is declared as private, the length of the inner variable length array is
not captured in outer captured regions, only in the innermost region.
Patch fixes this bug.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374787 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[ARM] Preserve fpu behaviour for '-crypto'
Diogo N. Sampaio [Mon, 14 Oct 2019 16:29:26 +0000 (16:29 +0000)]
[ARM] Preserve fpu behaviour for '-crypto'

Summary:
This patch restores the behaviour that -fpu overwrites the
architecture obtained from -march or -mcpu flags, not enforcing to
disable 'crypto' if march=armv7 and mfpu=neon-fp-armv8.
However, it does warn that 'crypto' is ignored when passing
mfpu=crypto-neon-fp-armv8.

Reviewers: peter.smith, labrinea

Reviewed By: peter.smith

Subscribers: nickdesaulniers, kristof.beyls, dmgreen, cfe-commits, krisb

Tags: #clang

Differential Revision: https://reviews.llvm.org/D67608

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374785 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[IRBuilder] Update IRBuilder::CreateFNeg(...) to return a UnaryOperator
Cameron McInally [Mon, 14 Oct 2019 15:35:01 +0000 (15:35 +0000)]
[IRBuilder] Update IRBuilder::CreateFNeg(...) to return a UnaryOperator

Reapply r374240 with fix for Ocaml test, namely Bindings/OCaml/core.ml.

Differential Revision: https://reviews.llvm.org/D61675

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374782 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[RISCV] enable LTO support, pass some options to linker.
Sam Elliott [Mon, 14 Oct 2019 14:00:13 +0000 (14:00 +0000)]
[RISCV] enable LTO support, pass some options to linker.

Summary:
1. enable LTO need to pass target feature and abi to LTO code generation
   RISCV backend need the target feature to decide which extension used in
   code generation.
2. move getTargetFeatures to CommonArgs.h and add ForLTOPlugin flag
3. add general tools::getTargetABI in CommonArgs.h because different target uses different
   way to get the target ABI.

Patch by Kuan Hsu Chen (khchen)

Reviewers: lenary, lewis-revill, asb, MaskRay

Reviewed By: lenary

Subscribers: hiraditya, dschuff, aheejin, fedor.sergeev, mehdi_amini, inglorion, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, steven_wu, rogfer01, MartinMosbeck, brucehoult, the_o, dexonsmith, rkruppe, PkmX, jocewei, psnobl, benna, Jim, lenary, s.egerton, pzheng, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D67409

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374774 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[docs] loop pragmas: options implying transformations
Sjoerd Meijer [Mon, 14 Oct 2019 07:40:36 +0000 (07:40 +0000)]
[docs] loop pragmas: options implying transformations

Following our discussion on the cfe dev list:
http://lists.llvm.org/pipermail/cfe-dev/2019-August/063054.html,
I have added a paragraph that is explicit about loop pragmas, and
transformation options implying the corresponding transformation.

Differential Revision: https://reviews.llvm.org/D66199

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374756 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[clang] [clang-offload-bundler] Fix finding installed llvm-objcopy
Michal Gorny [Mon, 14 Oct 2019 05:33:23 +0000 (05:33 +0000)]
[clang] [clang-offload-bundler] Fix finding installed llvm-objcopy

Allow finding installed llvm-objcopy in PATH if it's not present
in the directory containing clang-offload-bundler.  This is the case
if clang is being built stand-alone, and llvm-objcopy is already
installed while the c-o-b tool is still present in build directory.

This is consistent with how e.g. llvm-symbolizer is found in LLVM.
However, most of similar searches in LLVM and Clang are performed
without special-casing the program directory.

Fixes r369955.

Differential Revision: https://reviews.llvm.org/D68931

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374754 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoPrefer 'env not' over 'not env' in tests.
Nico Weber [Mon, 14 Oct 2019 01:41:56 +0000 (01:41 +0000)]
Prefer 'env not' over 'not env' in tests.

That way, lit's builtin 'env' command can be used for the 'env' bit.

Also it's clearer that way that the 'not' shouldn't cover 'env'
failures.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374749 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoImprove __builtin_constant_p lowering
Joerg Sonnenberger [Sun, 13 Oct 2019 22:33:46 +0000 (22:33 +0000)]
Improve __builtin_constant_p lowering

__builtin_constant_p used to be short-cut evaluated to false when
building with -O0. This is undesirable as it means that constant folding
in the front-end can give different results than folding in the back-end.
It can also create conditional branches on constant conditions that don't
get folded away. With the pending improvements to the llvm.is.constant
handling on the LLVM side, the short-cut is no longer useful.

Adjust various codegen tests to not depend on the short-cut or the
backend optimisations.

Differential Revision: https://reviews.llvm.org/D67638

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374742 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[clang-format] Proposal for clang-format to give compiler style warnings
Paul Hoad [Sun, 13 Oct 2019 14:51:45 +0000 (14:51 +0000)]
[clang-format] Proposal for clang-format to give compiler style warnings

relanding {D68554} with fixed lit tests, checked on Windows and MacOS

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374720 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoBlockInCriticalSectionChecker - silence static analyzer dyn_cast null dereference...
Simon Pilgrim [Sun, 13 Oct 2019 11:30:06 +0000 (11:30 +0000)]
BlockInCriticalSectionChecker - silence static analyzer dyn_cast null dereference warning. NFCI.

The static analyzer is warning about a potential null dereference, but we should be able to use cast<> directly and if not assert will fire for us.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374717 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoRevert r374663 "[clang-format] Proposal for clang-format to give compiler style warnings"
Nico Weber [Sat, 12 Oct 2019 22:58:34 +0000 (22:58 +0000)]
Revert r374663 "[clang-format] Proposal for clang-format to give compiler style warnings"

The test fails on macOS and looks a bit wrong, see comments on the review.

Also revert follow-up r374686.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374688 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[clang-format] Proposal for clang-format to give compiler style warnings
Paul Hoad [Sat, 12 Oct 2019 15:36:05 +0000 (15:36 +0000)]
[clang-format] Proposal for clang-format to give compiler style warnings

Summary:
Related somewhat to {D29039}

On seeing a quote on twitter by @invalidop

> If it's not formatted with clang-format it's a build error.

This made me want to change the way I use clang-format into a tool that could optionally show me where my source code violates clang-format syle.

When I'm making a change to clang-format itself, one thing I like to do to test the change is to ensure I didn't cause a huge wave of changes, what I want to do is simply run this on a known formatted directory and see if any new differences arrive in a manner I'm used to.

This started me thinking that we should allow build systems to run clang-format on a whole tree and emit compiler style warnings about files that fail clang-format in a form that would make them as a warning in most build systems and because those build systems range in their construction I don't think its unreasonable to NOT expect them to have to do the directory searching or parsing the output replacements themselves, but simply transform that into an error code when there are changes required.

I am starting this by suggesing adding a -n or -dry-run command line argument which would emit a warning/error of the form

Support for various common compiler command line argumuments like '-Werror' and '-ferror-limit' could make this very flexible to be integrated into build systems and CI systems.

```
> $ /usr/bin/clang-format --dry-run ClangFormat.cpp -ferror-limit=3 -fcolor-diagnostics
> ClangFormat.cpp:54:29: warning: code should be clang-formatted [-Wclang-format-violations]
> static cl::list<std::string>
>                             ^
> ClangFormat.cpp:55:20: warning: code should be clang-formatted [-Wclang-format-violations]
> LineRanges("lines", cl::desc("<start line>:<end line> - format a range of\n"
>                    ^
> ClangFormat.cpp:55:77: warning: code should be clang-formatted [-Wclang-format-violations]
> LineRanges("lines", cl::desc("<start line>:<end line> - format a range of\n"
>                                                                             ^
```

Reviewers: mitchell-stellar, klimek, owenpan

Reviewed By: klimek

Subscribers: mgorny, cfe-commits

Tags: #clang-format, #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D68554

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374663 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoremove an useless allocation found by scan-build - the new Dead nested assignment...
Sylvestre Ledru [Sat, 12 Oct 2019 15:24:00 +0000 (15:24 +0000)]
remove an useless allocation found by scan-build - the new Dead nested assignment check

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374659 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[clang][IFS] Fixing spelling errors in interface-stubs OPT flag (NFC).
Puyan Lotfi [Sat, 12 Oct 2019 06:25:07 +0000 (06:25 +0000)]
[clang][IFS] Fixing spelling errors in interface-stubs OPT flag (NFC).

This is just a long standing spelling error that was found recently.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374638 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[clang][IFS] Updating tests to pass on -fvisibility=hidden builds (NFCi).
Puyan Lotfi [Sat, 12 Oct 2019 02:46:57 +0000 (02:46 +0000)]
[clang][IFS] Updating tests to pass on -fvisibility=hidden builds (NFCi).

Special thanks to JamesNagurne who got to the bottom of this; landing this on
his behalf.

Differential Revision: https://reviews.llvm.org/D68897

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374632 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoSlightly relax restriction on exact order arguments must appear.
Douglas Yung [Sat, 12 Oct 2019 02:22:36 +0000 (02:22 +0000)]
Slightly relax restriction on exact order arguments must appear.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374627 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[ObjC] Remove default parameter no caller was providing. NFC intended.
Volodymyr Sapsai [Fri, 11 Oct 2019 21:21:02 +0000 (21:21 +0000)]
[ObjC] Remove default parameter no caller was providing. NFC intended.

Currently there is no need to make ObjCTypeParamType have a canonical type
different from the one in corresponding ObjCTypeParamDecl. So remove the
corresponding unused API.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374596 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoRelease notes: Add the option WarnForDeadNestedAssignments
Sylvestre Ledru [Fri, 11 Oct 2019 20:33:43 +0000 (20:33 +0000)]
Release notes: Add the option WarnForDeadNestedAssignments
https://reviews.llvm.org/D66733

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374593 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[Stats] Convert some ad-hoc header search stats to ALWAYS_ENABLED_STATISTIC.
Volodymyr Sapsai [Fri, 11 Oct 2019 18:22:34 +0000 (18:22 +0000)]
[Stats] Convert some ad-hoc header search stats to ALWAYS_ENABLED_STATISTIC.

rdar://problem/55715134

Reviewers: dsanders, bogner, rtereshin

Reviewed By: dsanders

Subscribers: hiraditya, jkorous, dexonsmith, ributzka, cfe-commits, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D68252

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374581 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoSuppress false-positive -Wdeprecated-volatile warning from __is_*_assignable(volatile...
Richard Smith [Fri, 11 Oct 2019 17:59:09 +0000 (17:59 +0000)]
Suppress false-positive -Wdeprecated-volatile warning from __is_*_assignable(volatile T&, U).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374580 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[clang][IFS] Fixing assert in clang interface stubs for enums, records, typedefs
Puyan Lotfi [Fri, 11 Oct 2019 17:24:11 +0000 (17:24 +0000)]
[clang][IFS] Fixing assert in clang interface stubs for enums, records, typedefs

The clang IFS ASTConsumer was asserting on enums, records (struct definitions in
C), and typedefs. All it needs to do is skip them because the stub just needs to
expose global object instances and functions.

Differential Revision: https://reviews.llvm.org/D68859

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374573 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoUpdate clang module map for new excluded .def file.
Richard Smith [Fri, 11 Oct 2019 17:00:34 +0000 (17:00 +0000)]
Update clang module map for new excluded .def file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374571 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoFix test failure with 374562 on Hexagon
Erich Keane [Fri, 11 Oct 2019 16:30:45 +0000 (16:30 +0000)]
Fix test failure with 374562 on Hexagon

__builtin_assume_aligned takes a size_t which is a 32 bit int on
hexagon.  Thus, the constant gets converted to a 32 bit value, resulting
in 0 not being a power of 2.  This patch changes the constant being
passed to 2**30 so that it fails, but doesnt exceed 30 bits.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374569 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoReland r374450 with Richard Smith's comments and test fixed.
Erich Keane [Fri, 11 Oct 2019 14:59:44 +0000 (14:59 +0000)]
Reland r374450 with Richard Smith's comments and test fixed.

The behavior from the original patch has changed, since we're no longer
allowing LLVM to just ignore the alignment.  Instead, we're just
assuming the maximum possible alignment.

Differential Revision: https://reviews.llvm.org/D68824

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374562 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[libTooling] Move `RewriteRule` abstraction into its own header and impl.
Yitzhak Mandelbaum [Fri, 11 Oct 2019 14:43:46 +0000 (14:43 +0000)]
[libTooling] Move `RewriteRule` abstraction into its own header and impl.

Summary: Move the `RewriteRule` class and related declarations into its own set
of files (header, implementation). Only the `Transformer` class is left in the
Transformer-named files. This change clarifies the distinction between the
`RewriteRule` class, which is essential to the Transformer library, and the
`Transformer` class, which is only one possible `RewriteRule` interpreter
(compare to `TransformerClangTidyCheck`, a clang-tidy based interpreter).

Reviewers: gribozavr

Subscribers: jfb, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68795

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374558 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[libTooling] Change Stencil equality to use `toString()`
Yitzhak Mandelbaum [Fri, 11 Oct 2019 14:02:03 +0000 (14:02 +0000)]
[libTooling] Change Stencil equality to use `toString()`

Summary:
Removes the `isEqual` method from StencilPartInterface and modifies equality to
use the string representation returned by the `toString` method for comparison.

This means the `run` and `selection` stencils return true by default, and
clients should be cautious in relying on equality operator for comparison of
stencils containing parts generated by these functions.

It also means we no longer need the custom RTTI support (typeId() and
down_cast()), so it has been removed.

Patch by Harshal T. Lehri.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68825

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374552 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[MS ABI]: Fix mangling function arguments for template types to be compatible with...
Nico Weber [Fri, 11 Oct 2019 12:27:51 +0000 (12:27 +0000)]
[MS ABI]: Fix mangling function arguments for template types to be compatible with MSVC

MS name mangling supports cache for first 10 distinct function
arguments.  The error was when non cached template type occurred twice
(e.g. 11th and 12th).  For such case in code there is another cache
table TemplateArgStrings (for performance reasons).  Then one '@'
character at the end of the mangled name taken from this table was
missing.  For other cases the missing '@' character was added in
the call to mangleSourceName(TemplateMangling) in the cache miss code,
but the cache hit code didn't add it.

This fixes a regression from r362560.

Patch by Adam Folwarczny <adamf88@gmail.com>!

Differential Revision: https://reviews.llvm.org/D68099

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374543 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoDead Virtual Function Elimination
Oliver Stannard [Fri, 11 Oct 2019 11:59:55 +0000 (11:59 +0000)]
Dead Virtual Function Elimination

Currently, it is hard for the compiler to remove unused C++ virtual
functions, because they are all referenced from vtables, which are referenced
by constructors. This means that if the constructor is called from any live
code, then we keep every virtual function in the final link, even if there
are no call sites which can use it.

This patch allows unused virtual functions to be removed during LTO (and
regular compilation in limited circumstances) by using type metadata to match
virtual function call sites to the vtable slots they might load from. This
information can then be used in the global dead code elimination pass instead
of the references from vtables to virtual functions, to more accurately
determine which functions are reachable.

To make this transformation safe, I have changed clang's code-generation to
always load virtual function pointers using the llvm.type.checked.load
intrinsic, instead of regular load instructions. I originally tried writing
this using clang's existing code-generation, which uses the llvm.type.test
and llvm.assume intrinsics after doing a normal load. However, it is possible
for optimisations to obscure the relationship between the GEP, load and
llvm.type.test, causing GlobalDCE to fail to find virtual function call
sites.

The existing linkage and visibility types don't accurately describe the scope
in which a virtual call could be made which uses a given vtable. This is
wider than the visibility of the type itself, because a virtual function call
could be made using a more-visible base class. I've added a new
!vcall_visibility metadata type to represent this, described in
TypeMetadata.rst. The internalization pass and libLTO have been updated to
change this metadata when linking is performed.

This doesn't currently work with ThinLTO, because it needs to see every call
to llvm.type.checked.load in the linkage unit. It might be possible to
extend this optimisation to be able to use the ThinLTO summary, as was done
for devirtualization, but until then that combination is rejected in the
clang driver.

To test this, I've written a fuzzer which generates random C++ programs with
complex class inheritance graphs, and virtual functions called through object
and function pointers of different types. The programs are spread across
multiple translation units and DSOs to test the different visibility
restrictions.

I've also tried doing bootstrap builds of LLVM to test this. This isn't
ideal, because only classes in anonymous namespaces can be optimised with
-fvisibility=default, and some parts of LLVM (plugins and bugpoint) do not
work correctly with -fvisibility=hidden. However, there are only 12 test
failures when building with -fvisibility=hidden (and an unmodified compiler),
and this change does not cause any new failures for either value of
-fvisibility.

On the 7 C++ sub-benchmarks of SPEC2006, this gives a geomean code-size
reduction of ~6%, over a baseline compiled with "-O2 -flto
-fvisibility=hidden -fwhole-program-vtables". The best cases are reductions
of ~14% in 450.soplex and 483.xalancbmk, and there are no code size
increases.

I've also run this on a set of 8 mbed-os examples compiled for Armv7M, which
show a geomean size reduction of ~3%, again with no size increases.

I had hoped that this would have no effect on performance, which would allow
it to awlays be enabled (when using -fwhole-program-vtables). However, the
changes in clang to use the llvm.type.checked.load intrinsic are causing ~1%
performance regression in the C++ parts of SPEC2006. It should be possible to
recover some of this perf loss by teaching optimisations about the
llvm.type.checked.load intrinsic, which would make it worth turning this on
by default (though it's still dependent on -fwhole-program-vtables).

Differential revision: https://reviews.llvm.org/D63932

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374539 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoInsert module constructors in a module pass
Vitaly Buka [Fri, 11 Oct 2019 08:47:03 +0000 (08:47 +0000)]
Insert module constructors in a module pass

Summary:
If we insert them from function pass some analysis may be missing or invalid.
Fixes PR42877.

Reviewers: eugenis, leonardchan

Reviewed By: leonardchan

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D68832

llvm-svn: 374481
Signed-off-by: Vitaly Buka <vitalybuka@google.com>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374527 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[X86] Always define the tzcnt intrinsics even when _MSC_VER is defined.
Craig Topper [Fri, 11 Oct 2019 06:07:53 +0000 (06:07 +0000)]
[X86] Always define the tzcnt intrinsics even when _MSC_VER is defined.

These intrinsics use llvm.cttz intrinsics so are always available
even without the bmi feature. We already don't check for the bmi
feature on the intrinsics themselves. But we were blocking the
include of the header file with _MSC_VER unless BMI was enabled
on the command line.

Fixes PR30506.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374516 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoRevert 374481 "[tsan,msan] Insert module constructors in a module pass"
Nico Weber [Fri, 11 Oct 2019 02:44:20 +0000 (02:44 +0000)]
Revert 374481 "[tsan,msan] Insert module constructors in a module pass"

CodeGen/sanitizer-module-constructor.c fails on mac and windows, see e.g.
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11424

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374503 91177308-0d34-0410-b5e6-96231b3b80d8

4 years ago[CUDA][HIP} Add a test for constexpr default ctor
Yaxun Liu [Fri, 11 Oct 2019 02:43:28 +0000 (02:43 +0000)]
[CUDA][HIP} Add a test for constexpr default ctor

Differential Revision: https://reviews.llvm.org/D68753

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374502 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoFix assertion failure for a cv-qualified array as a non-type template
Richard Smith [Fri, 11 Oct 2019 01:29:53 +0000 (01:29 +0000)]
Fix assertion failure for a cv-qualified array as a non-type template
parameter type.

We were both failing to decay the array type to a pointer and failing to
remove the top-level cv-qualifications. Fix this by decaying array
parameters even if the parameter type is dependent.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374496 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoInclude whether the destructor is constexpr in -ast-dump output for a
Richard Smith [Fri, 11 Oct 2019 00:40:08 +0000 (00:40 +0000)]
Include whether the destructor is constexpr in -ast-dump output for a
clss.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374488 91177308-0d34-0410-b5e6-96231b3b80d8

4 years agoMove most CXXRecordDecl::DefinitionData bit-fields out into a separate
Richard Smith [Fri, 11 Oct 2019 00:29:04 +0000 (00:29 +0000)]
Move most CXXRecordDecl::DefinitionData bit-fields out into a separate
file.

Reduces duplication and thereby reduces the risk that someone will
forget to update one of these places, as I did when adding
DefaultedDestructorIsConstexpr (though I've been unable to produce
a testcase for which that matters so far).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374484 91177308-0d34-0410-b5e6-96231b3b80d8