Commit Graph

74900 Commits

Author SHA1 Message Date
Heejin Ahn f0fe359bc3 [WebAssembly] Revert type of wake count in atomic.wake to i32
Summary:
We decided to revert this from i64 to i32 in Nov 28 CG meeting. Fixes
PR38632.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, jfb, cfe-commits

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

llvm-svn: 340235
2018-08-20 23:49:34 +00:00
Saleem Abdulrasool f02e4f9074 libclang: add install/distribution targets for python
Add installation support for the python bindings for libclang.  Add an
additional CMake configuration variable to enumerate the python versions for
which the bindings should be installed.  This allows for a LLVM/clang
distribution to distribute the python bindings for libclang as part of the
image.  Because the python versions need to be explicitly stated by the user,
the default image remains unchanged.

llvm-svn: 340228
2018-08-20 22:50:18 +00:00
Raphael Isemann 79d50a04c0 [ASTImporter] Add test for C++'s try/catch statements.
Summary: Also enable exceptions in clang-import-test so that we can parse the test files.

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

llvm-svn: 340220
2018-08-20 22:13:24 +00:00
Richard Smith e43e2b3667 Model type attributes as regular Attrs.
Specifically, AttributedType now tracks a regular attr::Kind rather than
having its own parallel Kind enumeration, and AttributedTypeLoc now
holds an Attr* instead of holding an ad-hoc collection of Attr fields.

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

This reinstates r339623, reverted in r339638, with a fix to not fail
template instantiation if we instantiate a QualType with no associated
type source information and we encounter an AttributedType.

llvm-svn: 340215
2018-08-20 21:47:29 +00:00
David Blaikie 658645241b DebugInfo: Add the ability to disable DWARF name tables entirely
This changes the current default behavior (from emitting pubnames by
default, to not emitting them by default) & moves to matching GCC's
behavior* with one significant difference: -gno(-gnu)-pubnames disables
pubnames even in the presence of -gsplit-dwarf (though -gsplit-dwarf
still by default enables -ggnu-pubnames). This allows users to disable
pubnames (& the new DWARF5 accelerated access tables) when they might
not be worth the size overhead.

* GCC's behavior is that -ggnu-pubnames and -gpubnames override each
other, and that -gno-gnu-pubnames and -gno-pubnames act as synonyms and
disable either kind of pubnames if they come last. (eg: -gpubnames
-gno-gnu-pubnames causes no pubnames (neither gnu or standard) to be
emitted)

llvm-svn: 340206
2018-08-20 20:14:08 +00:00
Fangrui Song 4876977085 [Lex] Make HeaderMaps a unique_ptr vector
Summary: unique_ptr makes the ownership clearer than a raw pointer container.

Reviewers: Eugene.Zelenko, dblaikie

Subscribers: cfe-commits

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

llvm-svn: 340198
2018-08-20 19:15:02 +00:00
Matt Arsenault a13746b7eb Rename -mlink-cuda-bitcode to -mlink-builtin-bitcode
The same semantics work for OpenCL, and probably any offload
language. Keep the old name around as an alias.

llvm-svn: 340193
2018-08-20 18:16:48 +00:00
Alexey Bataev 7f792cab12 [OPENMP] Fix crash on the emission of the weak function declaration.
If the function is actually a weak reference, it should not be marked as
deferred definition as this is only a declaration. Patch adds checks for
the definitions if they must be emitted. Otherwise, only declaration is
emitted.

llvm-svn: 340191
2018-08-20 18:03:40 +00:00
Adrian Prantl 49092d13c2 Close FileEntries of cached files in ModuleManager::addModule().
While investigating why LLDB (which can build hundreds of clang
modules during one debug session) was getting "too many open files"
errors, I found that most of them are .pcm files that are kept open by
ModuleManager. Pretty much all of the open file dscriptors are
FileEntries that are refering to `.pcm` files for which a buffer
already exists in a CompilerInstance's PCMCache.

Before PCMCache was added it was necessary to hold on to open file
descriptors to ensure that all ModuleManagers using the same
FileManager read the a consistent version of a given `.pcm` file on
disk, even when a concurrent clang process overwrites the file halfway
through. The PCMCache makes this practice unnecessary, since it caches
the entire contents of a `.pcm` file, while the FileManager caches all
the stat() information.

This patch adds a call to FileEntry::closeFile() to the path where a
Buffer has already been created. This is necessary because even for a
freshly written `.pcm` file the file is stat()ed once immediately
after writing to generate a FileEntry in the FileManager. Because a
freshly-generated file's contents is stored in the PCMCache, it is
fine to close the file immediately thereafter.  The second change this
patch makes is to set the `ShouldClose` flag to true when reading a
`.pcm` file into the PCMCache for the first time.

[For reference, in 1 Clang instance there is
     - 1 FileManager and
     - n ModuleManagers with
     - n PCMCaches.]

rdar://problem/40906753

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

llvm-svn: 340188
2018-08-20 17:10:27 +00:00
Raphael Isemann c705bb8401 [ASTImporter] Add test for C++ casts and fix broken const_cast importing.
Summary:
The ASTImporter does currently not handle const_casts. This patch adds the
missing const_cast importer code and the test case that discovered this.

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

llvm-svn: 340182
2018-08-20 16:20:01 +00:00
Alexey Bataev 7b1a7bd5ba [OPENMP][BLOCKS]Fix PR38923: reference to a global variable is captured
by a block.

Added checks for capturing of the variable in the block when trying to
emit correct address for the variable with the reference type. This
extra check allows correctly identify the variables that are not
captured in the block context.

llvm-svn: 340181
2018-08-20 16:00:22 +00:00
Raphael Isemann 6ef4fafef8 [ASTImporter] Test for importing condition variable from a ForStmt
Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: cfe-commits, martong

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

llvm-svn: 340180
2018-08-20 15:51:41 +00:00
Andrei Elovikov 7d408ff662 [NFC] Don't define static function in header (UninitializedObject.h)
Summary:
See also http://lists.llvm.org/pipermail/cfe-users/2016-January/000854.html for
the reasons why it's bad.

Reviewers: Szelethus, erichkeane

Reviewed By: Szelethus

Subscribers: cfe-commits

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

llvm-svn: 340174
2018-08-20 13:45:38 +00:00
Fangrui Song d0a07e2185 [Lex] Fix some inconsistent parameter names and duplicate comments. NFC
llvm-svn: 340145
2018-08-19 22:23:42 +00:00
Sanjay Patel b197667eba [CodeGen] add test file that should have been included with r340141
llvm-svn: 340142
2018-08-19 17:32:56 +00:00
Sanjay Patel ad82390d3f [CodeGen] add rotate builtins that map to LLVM funnel shift
This is a partial retry of rL340137 (reverted at rL340138 because of gcc host compiler crashing)
with 1 change:
Remove the changes to make microsoft builtins also use the LLVM intrinsics.
 
This exposes the LLVM funnel shift intrinsics as more familiar bit rotation functions in clang
(when both halves of a funnel shift are the same value, it's a rotate).

We're free to name these as we want because we're not copying gcc, but if there's some other
existing art (eg, the microsoft ops) that we want to replicate, we can change the names.

The funnel shift intrinsics were added here:
https://reviews.llvm.org/D49242

With improved codegen in:
https://reviews.llvm.org/rL337966
https://reviews.llvm.org/rL339359

And basic IR optimization added in:
https://reviews.llvm.org/rL338218
https://reviews.llvm.org/rL340022

...so these are expected to produce asm output that's equal or better to the multi-instruction
alternatives using primitive C/IR ops.

In the motivating loop example from PR37387:
https://bugs.llvm.org/show_bug.cgi?id=37387#c7
...we get the expected 'rolq' x86 instructions if we substitute the rotate builtin into the source.

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

llvm-svn: 340141
2018-08-19 16:50:30 +00:00
Ivan A. Kosarev 1b7851212b [NEON] Define fp16 vld and vst intrinsics conditionally
This patch fixes definitions of vld and vst NEON intrinsics so
that we only define them if half-precision arithmetic is
supported on the target platform, as prescribed in ACLE 2.0.

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

llvm-svn: 340140
2018-08-19 16:30:57 +00:00
Sanjay Patel a09ae4b8a6 revert r340137: [CodeGen] add rotate builtins
At least a couple of bots (gcc host compiler on PPC only?) are showing the compiler dying while trying to compile.

llvm-svn: 340138
2018-08-19 15:31:42 +00:00
Sanjay Patel 446529b0d9 [CodeGen] add/fix rotate builtins that map to LLVM funnel shift (retry)
This is a retry of rL340135 (reverted at rL340136 because of gcc host compiler crashing)
with 2 changes:
1. Move the code into a helper to reduce code duplication (and hopefully work-around the crash).
2. The original commit had a formatting bug in the docs (missing an underscore).

Original commit message:

This exposes the LLVM funnel shift intrinsics as more familiar bit rotation functions in clang
(when both halves of a funnel shift are the same value, it's a rotate).

We're free to name these as we want because we're not copying gcc, but if there's some other
existing art (eg, the microsoft ops that are modified in this patch) that we want to replicate,
we can change the names.

The funnel shift intrinsics were added here:
https://reviews.llvm.org/D49242

With improved codegen in:
https://reviews.llvm.org/rL337966
https://reviews.llvm.org/rL339359

And basic IR optimization added in:
https://reviews.llvm.org/rL338218
https://reviews.llvm.org/rL340022

...so these are expected to produce asm output that's equal or better to the multi-instruction
alternatives using primitive C/IR ops.

In the motivating loop example from PR37387:
https://bugs.llvm.org/show_bug.cgi?id=37387#c7
...we get the expected 'rolq' x86 instructions if we substitute the rotate builtin into the source.

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

llvm-svn: 340137
2018-08-19 14:44:47 +00:00
Sanjay Patel 39b4dd2da7 revert r340135: [CodeGen] add rotate builtins
At least a couple of bots (PPC only?) are showing the compiler dying while trying to compile:
http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/11065/steps/build%20stage%201/logs/stdio
http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/18267/steps/build%20stage%201/logs/stdio

llvm-svn: 340136
2018-08-19 13:48:06 +00:00
Sanjay Patel 9116f0438c [CodeGen] add rotate builtins
This exposes the LLVM funnel shift intrinsics as more familiar bit rotation functions in clang 
(when both halves of a funnel shift are the same value, it's a rotate).

We're free to name these as we want because we're not copying gcc, but if there's some other 
existing art (eg, the microsoft ops that are modified in this patch) that we want to replicate, 
we can change the names.

The funnel shift intrinsics were added here:
D49242

With improved codegen in:
rL337966
rL339359

And basic IR optimization added in:
rL338218
rL340022

...so these are expected to produce asm output that's equal or better to the multi-instruction 
alternatives using primitive C/IR ops.

In the motivating loop example from PR37387:
https://bugs.llvm.org/show_bug.cgi?id=37387#c7
...we get the expected 'rolq' x86 instructions if we substitute the rotate builtin into the source.

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

llvm-svn: 340135
2018-08-19 13:12:40 +00:00
Bruno Cardoso Lopes bb3b7cff96 Revert "[analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker"
This reverts commit a786521fa66c72edd308baff0c08961b6d964fb1.

Bots haven't caught up yet, but broke modules build with:

../tools/clang/include/clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h:18:10:
fatal error: cyclic dependency in module 'Clang_StaticAnalyzer_Core':
Clang_StaticAnalyzer_Core -> Clang_Analysis ->
Clang_StaticAnalyzer_Checkers -> Clang_StaticAnalyzer_Core
         ^

llvm-svn: 340117
2018-08-18 03:22:11 +00:00
George Karpenkov 0ac54fad53 [analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker
ARCMigrator is using code from RetainCountChecker, which is a layering
violation (and it also does it badly, by using a different header, and
then relying on implementation being present in a header file).

This change splits up RetainSummaryManager into a separate library in
lib/Analysis, which can be used independently of a checker.

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

llvm-svn: 340114
2018-08-18 01:45:50 +00:00
George Karpenkov b300eac47b Quickfix for failing tests.
llvm-svn: 340110
2018-08-17 23:54:00 +00:00
Argyrios Kyrtzidis c0cd01764f [index] For an ObjC message call, also record as receivers the protocols if they are present in the ObjC type
llvm-svn: 340109
2018-08-17 23:50:59 +00:00
Alex Lorenz b111da14ad [ObjC] Error out when using forward-declared protocol in a @protocol
expression

Clang emits invalid protocol metadata when a @protocol expression is used with a
forward-declared protocol. The protocol metadata is missing protocol conformance
list of the protocol since we don't have access to the definition of it in the
compiled translation unit. The linker then might end up picking the invalid
metadata when linking which will lead to incorrect runtime protocol conformance
checks.

This commit makes sure that Clang fails to compile code that uses a @protocol
expression with a forward-declared protocol. This ensures that Clang does not
emit invalid protocol metadata. I added an extra assert in CodeGen to ensure
that this kind of issue won't happen in other places.

rdar://32787811

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

llvm-svn: 340102
2018-08-17 22:18:08 +00:00
Reid Kleckner 4c33d197fa Don't warn on returning the address of a label from a statement expression
Summary:
There isn't anything inherently wrong with returning a label from a
statement expression. In practice, the Linux kernel uses this pattern to
materialize PCs.

Fixes PR38569

Reviewers: niravd, rsmith, nickdesaulniers

Subscribers: cfe-commits

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

llvm-svn: 340101
2018-08-17 22:11:31 +00:00
George Karpenkov b1b791b9b1 [analyzer] [NFC] Minor refactoring of ISL-specific code in RetainCountChecker
Differential Revision: https://reviews.llvm.org/D50879

llvm-svn: 340098
2018-08-17 21:43:27 +00:00
George Karpenkov bc0cddf0c8 [analyzer] Re-instate support for MakeCollectable is RetainCountChecker
Differential Revision: https://reviews.llvm.org/D50872

llvm-svn: 340097
2018-08-17 21:42:59 +00:00
George Karpenkov 03011b2d98 [analyzer] [NFC] Move ObjCRetainCount to include/Analysis
Differential Revision: https://reviews.llvm.org/D50869

llvm-svn: 340096
2018-08-17 21:42:32 +00:00
George Karpenkov c4d6b93dc7 [analyzer] [NFC] Move canEval function from RetainCountChecker to RetainCountSummaries
Differential Revision: https://reviews.llvm.org/D50863

llvm-svn: 340094
2018-08-17 21:42:05 +00:00
George Karpenkov cab604e9c7 [analyzer] [NFC] Split up summary generation in RetainCountChecker in two methods
Differential Revision: https://reviews.llvm.org/D50830

llvm-svn: 340093
2018-08-17 21:41:37 +00:00
George Karpenkov 70c2ee30bc [analyzer] [NFC] Split up RetainCountChecker
At some point, staring at 4k+ LOC file becomes a bit hard.

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

llvm-svn: 340092
2018-08-17 21:41:07 +00:00
George Karpenkov 7390ddc968 [analyzer] Drop support for GC mode in RetainCountChecker
A lot of code in RetainCountChecker deals with GC mode.
Given that GC mode is deprecated, Apple does not ship runtime for it,
and modern compiler toolchain does not support it, it makes sense to
remove the code dealing with it in order to aid understanding of
RetainCountChecker.

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

llvm-svn: 340091
2018-08-17 21:40:38 +00:00
Mike Rice 3820f582eb test commit: add a comment
llvm-svn: 340082
2018-08-17 21:16:21 +00:00
Reid Kleckner 59320fc9d7 Update comments in CGDebugInfo to reflect changes in the MS mangler, NFC
I've tried to elaborate on the purpose of these type identifiers and why
and when clang uses them.

llvm-svn: 340080
2018-08-17 20:59:52 +00:00
Reid Kleckner df8dd61f23 [MS] Mangle a hash of the main file path into anonymous namespaces
Summary:
This is needed to avoid conflicts in mangled names for codeview types in
anonymous namespaces. In CodeView, types refer to each other typically
through forward declarations, which contain mangled names. These names
have to be unique, otherwise the debugger will look up the mangled name
and find the wrong definition.

Furthermore, ThinLTO will deduplicate the types, and debug info
verification can fail when the types have the wrong sizes. This is
PR38608.

Fixes PR38609.

Reviewers: majnemer, inglorion, hans

Subscribers: mehdi_amini, aprantl, JDevlieghere, dexonsmith, cfe-commits

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

llvm-svn: 340079
2018-08-17 20:59:27 +00:00
Richard Smith f9a5d5f04a Improve diagnostic for missing comma in template parameter list.
Given 'typename T typename U', we would correctly diagnose the missing
comma, but incorrectly disambiguate the first parameter as being a
non-type parameter and complain that the 'T' is not a qualified-id.

See also gcc.gnu.org/PR86998.

llvm-svn: 340074
2018-08-17 19:43:40 +00:00
Yaxun Liu 94ff57f5b1 [HIP] Make __hip_gpubin_handle hidden to avoid being merged across different shared libraries
Different shared libraries contain different fat binary, which is stored in a global variable
__hip_gpubin_handle. Since different compilation units share the same fat binary, this
variable has linkonce linkage. However, it should not be merged across different shared
libraries.

This patch set the visibility of the global variable to be hidden, which will make it invisible
in the shared library, therefore preventing it from being merged.

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

llvm-svn: 340056
2018-08-17 17:47:31 +00:00
Nico Weber b2c53d3393 Make __shiftleft128 / __shiftright128 real compiler built-ins.
r337619 added __shiftleft128 / __shiftright128 as functions in intrin.h.
Microsoft's STL plans on using these functions, and they're using intrin0.h
which just has declarations of built-ins to not pull in the huge intrin.h
header in the standard library headers. That requires that these functions are
real built-ins.

https://reviews.llvm.org/D50907

llvm-svn: 340048
2018-08-17 17:19:06 +00:00
Akira Hatanaka 2ec36f08a6 [CodeGen] Merge identical block descriptor global variables.
Currently, clang generates a new block descriptor global variable for
each new block literal. This commit merges block descriptors that are
identical inside and across translation units using the same approach
taken in r339438.

To enable merging identical block descriptors, the size and signature of
the block and information about the captures are encoded into the name
of the block descriptor variable. Also, the block descriptor variable is
marked as linkonce_odr and unnamed_addr.

rdar://problem/42640703

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

llvm-svn: 340041
2018-08-17 15:46:07 +00:00
Haojian Wu 70560ba8db [Preamble] Empty preamble is not an error.
Summary:
Empty preamble is valid for source file which doesn't have any
preprocessor and #includes.

This patch makes clang treat an empty preamble as a normal preamble.

Check: ninja check-clang

A testcase is added in https://reviews.llvm.org/D50627.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 340029
2018-08-17 14:25:10 +00:00
Erich Keane eaca388308 Fix for bug 38508 - Don't do PCH processing when only generating preprocessor output
This clang-cl driver change removes the PCH options when we are only generating
preprocessed output. This is similar to the behavior of Y-.

Patch by: mikerice
Differential Revision: https://reviews.llvm.org/D50640

llvm-svn: 340025
2018-08-17 13:43:39 +00:00
Hans Wennborg a8e1fc4eaa clang-cl: Expose -fno-crash-diagnostics (PR38574)
llvm-svn: 340023
2018-08-17 13:37:57 +00:00
Teresa Johnson c9818ebc02 [ThinLTO] Correct documentation on default number of threads
Summary:
The number of threads used for ThinLTO backend parallelism was
dropped to the number of cores in r284618 to avoid oversubscribing
physical cores due to hyperthreading. This updates the documentation
to reflect that change.

Fixes PR38610.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, cfe-commits

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

llvm-svn: 340021
2018-08-17 13:19:36 +00:00
Luke Cheeseman 0ac44c18b7 [AArch64] - return address signing
- Add a command line options -msign-return-address to enable return address
  signing
- Armv8.3a added instructions to sign the return address to help mitigate
  against ROP attacks
- This patch adds command line options to generate function attributes that
  signal to the back whether return address signing instructions should be
  added

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

llvm-svn: 340019
2018-08-17 12:55:05 +00:00
Roman Lebedev 9cb37a2a15 [NFC] Some small test updates for Implicit Conversion sanitizer.
Split off from D50250.

llvm-svn: 339995
2018-08-17 07:33:25 +00:00
Brian Cain d6a76f761f [hexagon] restore -fuse-cxa-atexit by default
"-fno-use-cxa-atexit" was a default provided by the initial
commit offering hexagon support.  This is no longer required.

Reviewers: bcahoon, sidneym

Subscribers: llvm-commits

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

llvm-svn: 339979
2018-08-17 03:53:51 +00:00
David Blaikie 9982bb8739 Disable pubnames in NVPTX debug info using metadata
llvm-svn: 339968
2018-08-16 23:56:32 +00:00
Vedant Kumar 61cdea81e7 Relax a CHECK line to allow for dso_local
Fixes a bot failure:
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/11806

llvm-svn: 339964
2018-08-16 23:19:50 +00:00