]> granicus.if.org Git - clang/log
clang
5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 years ago[tsan,msan] Insert module constructors in a module pass
Vitaly Buka [Thu, 10 Oct 2019 23:49:10 +0000 (23:49 +0000)]
[tsan,msan] 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

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

5 years ago[tooling] Fix assertion on MacOSX.
Michael Liao [Thu, 10 Oct 2019 23:45:20 +0000 (23:45 +0000)]
[tooling] Fix assertion on MacOSX.

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

5 years ago[tooling] Teach Tooling to understand compilation with offloading.
Michael Liao [Thu, 10 Oct 2019 23:05:55 +0000 (23:05 +0000)]
[tooling] Teach Tooling to understand compilation with offloading.

Summary:
- So far, we only recognize the host compilation with offloading and
  skip the offloading part.

Reviewers: tra, yaxunl

Subscribers: cfe-commits

Tags: #clang

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

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

5 years agoFix help message for -ffp-contract
Yaxun Liu [Thu, 10 Oct 2019 22:43:00 +0000 (22:43 +0000)]
Fix help message for -ffp-contract

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

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

5 years agoPR43629: Fix crash evaluating constexpr placement new on a subobject of
Richard Smith [Thu, 10 Oct 2019 22:31:17 +0000 (22:31 +0000)]
PR43629: Fix crash evaluating constexpr placement new on a subobject of
an out-of-lifetime object.

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

5 years agoFix some errors in <arm_neon.h> tests that cause them to fail with lax
Richard Smith [Thu, 10 Oct 2019 21:40:56 +0000 (21:40 +0000)]
Fix some errors in <arm_neon.h> tests that cause them to fail with lax
vector conversions disabled.

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

5 years agoRevert 374450 "Fix __builtin_assume_aligned with too large values."
Nico Weber [Thu, 10 Oct 2019 21:34:32 +0000 (21:34 +0000)]
Revert 374450 "Fix __builtin_assume_aligned with too large values."

The test fails on Windows, with

  error: 'warning' diagnostics expected but not seen:
    File builtin-assume-aligned.c Line 62: requested alignment
        must be 268435456 bytes or smaller; assumption ignored
  error: 'warning' diagnostics seen but not expected:
    File builtin-assume-aligned.c Line 62: requested alignment
        must be 8192 bytes or smaller; assumption ignored

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

5 years agoFix __builtin_assume_aligned with too large values.
Erich Keane [Thu, 10 Oct 2019 21:08:28 +0000 (21:08 +0000)]
Fix __builtin_assume_aligned with too large values.

Code to handle __builtin_assume_aligned was allowing larger values, but
would convert this to unsigned along the way. This patch removes the
EmitAssumeAligned overloads that take unsigned to do away with this
problem.

Additionally, it adds a warning that values greater than 1 <<29 are
ignored by LLVM.

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

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

5 years agoAdd -fgnuc-version= to control __GNUC__ and other GCC macros
Reid Kleckner [Thu, 10 Oct 2019 21:04:25 +0000 (21:04 +0000)]
Add -fgnuc-version= to control __GNUC__ and other GCC macros

I noticed that compiling on Windows with -fno-ms-compatibility had the
side effect of defining __GNUC__, along with __GNUG__, __GXX_RTTI__, and
a number of other macros for GCC compatibility. This is undesirable and
causes Chromium to do things like mix __attribute__ and __declspec,
which doesn't work. We should have a positive language option to enable
GCC compatibility features so that we can experiment with
-fno-ms-compatibility on Windows. This change adds -fgnuc-version= to be
that option.

My issue aside, users have, for a long time, reported that __GNUC__
doesn't match their expectations in one way or another. We have
encouraged users to migrate code away from this macro, but new code
continues to be written assuming a GCC-only environment. There's really
nothing we can do to stop that. By adding this flag, we can allow them
to choose their own adventure with __GNUC__.

This overlaps a bit with the "GNUMode" language option from -std=gnu*.
The gnu language mode tends to enable non-conforming behaviors that we'd
rather not enable by default, but the we want to set things like
__GXX_RTTI__ by default, so I've kept these separate.

Helps address PR42817

Reviewed By: hans, nickdesaulniers, MaskRay

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

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

5 years ago[MSVC] Automatically add atlmfc folder to include and libpath.
Zachary Turner [Thu, 10 Oct 2019 20:25:54 +0000 (20:25 +0000)]
[MSVC] Automatically add atlmfc folder to include and libpath.

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

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

5 years ago[ScanDeps] clang-format, 80 cols.
Michael J. Spencer [Thu, 10 Oct 2019 20:19:02 +0000 (20:19 +0000)]
[ScanDeps] clang-format, 80 cols.

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

5 years ago[OPENMP]Update doc for supported constructs, NFC.
Alexey Bataev [Thu, 10 Oct 2019 20:15:54 +0000 (20:15 +0000)]
[OPENMP]Update doc for supported constructs, NFC.

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

5 years ago[OPENMP50]Support for 'master taskloop' directive.
Alexey Bataev [Thu, 10 Oct 2019 20:13:02 +0000 (20:13 +0000)]
[OPENMP50]Support for 'master taskloop' directive.

Added full support for master taskloop directive.

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

5 years ago[ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 2.
Eli Friedman [Thu, 10 Oct 2019 18:45:34 +0000 (18:45 +0000)]
[ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 2.

Just running -fsyntax-only over arm_neon.h doesn't cover some intrinsics
which are defined using macros.  Add more test coverage for that.

arm-neon-header.c wasn't checking the full set of available NEON target
features; change the target architecture of the test to account for
that.

Fix the generator for arm_neon.h to generate casts in more cases where
they are necessary.

Fix VFMLAL_LOW etc. to express their signatures differently, so the
builtins have the expected type. Maybe the TableGen backend should
detect intrinsics that are defined the wrong way, and produce an error.
The rules here are sort of strange.

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

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

5 years agoFix one more clang test which didn't have \5C in it
Reid Kleckner [Thu, 10 Oct 2019 18:42:06 +0000 (18:42 +0000)]
Fix one more clang test which didn't have \5C in it

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

5 years agoUpdate clang tests for new LLVM IR backslash printing in r374415
Reid Kleckner [Thu, 10 Oct 2019 18:36:41 +0000 (18:36 +0000)]
Update clang tests for new LLVM IR backslash printing in r374415

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

5 years agoRe-land "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"
Reid Kleckner [Thu, 10 Oct 2019 18:01:20 +0000 (18:01 +0000)]
Re-land "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"

This reverts r374324 (git commit 62808631acceaa8b78f8ab9b407eb6b943ff5f77)

I changed the test to not rely on finding the sequence "clang, test,
CoverageMapping" in the CWD used to run the test. Instead it makes its
own internal directory hierarchy of foo/bar/baz and looks for that.

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

5 years ago[clang-format] throws an incorrect assertion in consumeToken() formatting the MSVC stl
Paul Hoad [Thu, 10 Oct 2019 17:54:47 +0000 (17:54 +0000)]
[clang-format] throws an incorrect assertion in consumeToken() formatting the MSVC stl

Summary:
An incorrect assertion is thrown when clang-formatting MSVC's STL library

```
Assertion failed: !Line.startsWith(tok::hash), file C:/llvm/llvm-project/clang/lib/Format/TokenAnnotator.cpp, line 847
Stack dump:
0.      Program arguments: C:\llvm\build\bin\clang-format.exe -i -n ./stl/inc/xkeycheck.h
```

```
Enable warning C4005 to find the forbidden define.
```

Reviewers: mitchell-stellar, STL_MSFT, klimek, krasimir

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

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

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

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

5 years ago[OPENMP50]Support for declare variant directive for NVPTX target.
Alexey Bataev [Thu, 10 Oct 2019 17:28:10 +0000 (17:28 +0000)]
[OPENMP50]Support for declare variant directive for NVPTX target.

NVPTX does not support global aliases. Instead, we have to copy the full
body of the variant function for the original function.

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

5 years agoIn openFileForRead don't cache erroneous entries if the error relates to them being...
Kousik Kumar [Thu, 10 Oct 2019 15:29:01 +0000 (15:29 +0000)]
In openFileForRead don't cache erroneous entries if the error relates to them being directories. Add tests.

Summary:
It seems that when the CachingFileSystem is first given a file to open that is actually a directory, it incorrectly
caches that path to be errenous and throws an error when subsequently a directory open call is made for the same
path.
This change makes it so that we do NOT cache a path if it turns out we asked for a file when its a directory.

Reviewers: arphaman

Subscribers: dexonsmith, cfe-commits

Tags: #clang

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

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

5 years ago[OPENMP50]Register vendor name only once in vendor context selector.
Alexey Bataev [Thu, 10 Oct 2019 15:15:26 +0000 (15:15 +0000)]
[OPENMP50]Register vendor name only once in vendor context selector.

No need to store multiple copies of the same vendor names in the context
selector, keep only single copy.

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

5 years agoRevert "[IRBuilder] Update IRBuilder::CreateFNeg(...) to return a UnaryOperator"
Dmitri Gribenko [Thu, 10 Oct 2019 14:13:54 +0000 (14:13 +0000)]
Revert "[IRBuilder] Update IRBuilder::CreateFNeg(...) to return a UnaryOperator"

This reverts commit r374240. It broke OCaml tests:
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/19014

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

5 years ago[AST] ASTReader::ReadSLocEntry(): move computation of FirstDecl into the branch where...
Roman Lebedev [Thu, 10 Oct 2019 12:22:42 +0000 (12:22 +0000)]
[AST] ASTReader::ReadSLocEntry(): move computation of FirstDecl into the branch where it's used

The existing code is not defined, you are not allowed
to produce non-null pointer from null pointer (F->FileSortedDecls here).
That being said, i'm not really confident this is fix-enough, but we'll see.

FAIL: Clang :: Modules/no-module-map.cpp (6879 of 16079)
******************** TEST 'Clang :: Modules/no-module-map.cpp' FAILED ********************
Script:
--
: 'RUN: at line 1';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -fmodules-ts -fmodule-name=ab -x c++-header /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map/a.h /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map/b.h -emit-header-module -o /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm
: 'RUN: at line 2';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -fmodules-ts -fmodule-file=/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp -I/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map -verify
: 'RUN: at line 3';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -fmodules-ts -fmodule-file=/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp -I/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map -verify -DA
: 'RUN: at line 4';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -fmodules-ts -fmodule-file=/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp -I/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map -verify -DB
: 'RUN: at line 5';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -fmodules-ts -fmodule-file=/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp -I/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/Inputs/no-module-map -verify -DA -DB
: 'RUN: at line 7';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -E /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm -o - | /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp
: 'RUN: at line 8';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/10.0.0/include -nostdsysteminc -frewrite-imports -E /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/clang/test/Modules/Output/no-module-map.cpp.tmp.pcm -o - | /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/Modules/no-module-map.cpp
--
Exit Code: 2

Command Output (stderr):
--
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:1526:50: runtime error: applying non-zero offset 8 to null pointer
    #0 0x3a9bd0c in clang::ASTReader::ReadSLocEntry(int) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:1526:50
    #1 0x328b6f8 in clang::SourceManager::loadSLocEntry(unsigned int, bool*) const /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Basic/SourceManager.cpp:461:28
    #2 0x328b351 in clang::SourceManager::initializeForReplay(clang::SourceManager const&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Basic/SourceManager.cpp:399:11
    #3 0x3996c71 in clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:581:27
    #4 0x394f341 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:956:13
    #5 0x3a8a92b in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:290:25
    #6 0xaf8d62 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/tools/driver/cc1_main.cpp:250:15
    #7 0xaf1602 in ExecuteCC1Tool /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/tools/driver/driver.cpp:309:12
    #8 0xaf1602 in main /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/tools/driver/driver.cpp:382:12
    #9 0x7f2c1eecc2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #10 0xad57f9 in _start (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang-10+0xad57f9)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:1526:50 in

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

5 years agoRevert "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"
Kadir Cetinkaya [Thu, 10 Oct 2019 12:20:11 +0000 (12:20 +0000)]
Revert "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"

This reverts commit f6777964bde28c349d3e289ea37ecf5f5eeedbc4.

Because the absolute path check relies on temporary path containing
"clang", "test" and "CoverageMapping" as a subsequence, which is not
necessarily true on all systems(breaks internal integrates). Wanted to
fix it by checking for a leading "/" instead, but then noticed that it
would break windows tests, so leaving it to the author instead.

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

5 years agoRemove rest of time-trace message as it is inconsistent style
Russell Gallop [Thu, 10 Oct 2019 09:33:53 +0000 (09:33 +0000)]
Remove rest of time-trace message as it is inconsistent style

Other options which create output files don't produce output messages.
Improve documentation to help find trace file.

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

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

5 years ago[UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour
Roman Lebedev [Thu, 10 Oct 2019 09:25:02 +0000 (09:25 +0000)]
[UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

Summary:
Quote from http://eel.is/c++draft/expr.add#4:
```
4     When an expression J that has integral type is added to or subtracted
      from an expression P of pointer type, the result has the type of P.
(4.1) If P evaluates to a null pointer value and J evaluates to 0,
      the result is a null pointer value.
(4.2) Otherwise, if P points to an array element i of an array object x with n
      elements ([dcl.array]), the expressions P + J and J + P
      (where J has the value j) point to the (possibly-hypothetical) array
      element i+j of x if 0≤i+j≤n and the expression P - J points to the
      (possibly-hypothetical) array element i−j of x if 0≤i−j≤n.
(4.3) Otherwise, the behavior is undefined.
```

Therefore, as per the standard, applying non-zero offset to `nullptr`
(or making non-`nullptr` a `nullptr`, by subtracting pointer's integral value
from the pointer itself) is undefined behavior. (*if* `nullptr` is not defined,
i.e. e.g. `-fno-delete-null-pointer-checks` was *not* specified.)

To make things more fun, in C (6.5.6p8), applying *any* offset to null pointer
is undefined, although Clang front-end pessimizes the code by not lowering
that info, so this UB is "harmless".

Since rL369789 (D66608 `[InstCombine] icmp eq/ne (gep inbounds P, Idx..), null -> icmp eq/ne P, null`)
LLVM middle-end uses those guarantees for transformations.
If the source contains such UB's, said code may now be miscompiled.
Such miscompilations were already observed:
* https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190826/687838.html
* https://github.com/google/filament/pull/1566

Surprisingly, UBSan does not catch those issues
... until now. This diff teaches UBSan about these UB's.

`getelementpointer inbounds` is a pretty frequent instruction,
so this does have a measurable impact on performance;
I've addressed most of the obvious missing folds (and thus decreased the performance impact by ~5%),
and then re-performed some performance measurements using my [[ https://github.com/darktable-org/rawspeed | RawSpeed ]] benchmark:
(all measurements done with LLVM ToT, the sanitizer never fired.)
* no sanitization vs. existing check: average `+21.62%` slowdown
* existing check vs. check after this patch: average `22.04%` slowdown
* no sanitization vs. this patch: average `48.42%` slowdown

Reviewers: vsk, filcab, rsmith, aaron.ballman, vitalybuka, rjmccall, #sanitizers

Reviewed By: rsmith

Subscribers: kristof.beyls, nickdesaulniers, nikic, ychen, dtzWill, xbolva00, dberris, arphaman, rupprecht, reames, regehr, llvm-commits, cfe-commits

Tags: #clang, #sanitizers, #llvm

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

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

5 years agoRecommit "[Clang] Pragma vectorize_width() implies vectorize(enable)"
Sjoerd Meijer [Thu, 10 Oct 2019 08:27:14 +0000 (08:27 +0000)]
Recommit "[Clang] Pragma vectorize_width() implies vectorize(enable)"

This was further discussed at the llvm dev list:

http://lists.llvm.org/pipermail/llvm-dev/2019-October/135602.html

I think the brief summary of that is that this change is an improvement,
this is the behaviour that we expect and promise in ours docs, and also
as a result there are cases where we now emit diagnostics whereas before
pragmas were silently ignored. Two areas where we can improve: 1) the
diagnostic message itself, and 2) and in some cases (e.g. -Os and -Oz)
the vectoriser is (quite understandably) not triggering.

Original commit message:

Specifying the vectorization width was supposed to implicitly enable
vectorization, except that it wasn't really doing this. It was only
setting the vectorize.width metadata, but not vectorize.enable.

This should fix PR27643.

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

5 years ago[clang] prevent crash for nonnull attribut in constant context (Bug 43601)
Gauthier Harnisch [Thu, 10 Oct 2019 07:13:20 +0000 (07:13 +0000)]
[clang] prevent crash for nonnull attribut in constant context (Bug 43601)

Summary:

bug : https://bugs.llvm.org/show_bug.cgi?id=43601

Reviewers: rnk

Reviewed By: rnk

Subscribers: cfe-commits

Tags: #clang

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

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

5 years ago[ast] Fix indentation. NFC.
Michael Liao [Thu, 10 Oct 2019 04:16:52 +0000 (04:16 +0000)]
[ast] Fix indentation. NFC.

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