Commit Graph

50508 Commits

Author SHA1 Message Date
Alexey Bataev c99042ba97 [OPENMP, NVPTX] Improve globalization of the variables captured by value.
If the variable is captured by value and the corresponding parameter in
the outlined function escapes its declaration context, this parameter
must be globalized. To globalize it we need to get the address of the
original parameter, load the value, store it to the global address and
use this global address instead of the original.

Patch improves globalization for parallel|teams regions + functions in
declare target regions.

llvm-svn: 327654
2018-03-15 18:10:54 +00:00
Alexey Bataev 4f4bf7c348 [OPENMP] Codegen for `omp declare target` construct.
Added initial codegen for device side of declarations inside `omp
declare target` construct + codegen for implicit `declare target`
functions, which are used in the target regions.

llvm-svn: 327636
2018-03-15 15:47:20 +00:00
Yaxun Liu 5b330e8d61 Recommit r326946 after reducing CallArgList memory footprint
llvm-svn: 327634
2018-03-15 15:25:19 +00:00
Andrew V. Tischenko 5704dc0c7f More warnings when double truncation to float: compound assignment is supported now.
llvm-svn: 327618
2018-03-15 10:03:35 +00:00
Richard Trieu 09c163bb6b Refactoring code around move/copy initialization. NFC.
Use an enum parameter instead of a bool for more control on how the copy elision
functions work.  Extract the move initialization code from the move or copy
initialization block.

Patch by: Arthur O'Dwyer

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

llvm-svn: 327598
2018-03-15 03:00:55 +00:00
Richard Trieu f4a0e9a78c [CFG] Allow CallExpr's to be looked up in CFG's
r327343 changed the handling for CallExpr in a CFG, which prevented lookups for
CallExpr while other Stmt kinds still worked.  This change carries over the
necessary bits from Stmt function to CallExpr function.

llvm-svn: 327593
2018-03-15 00:09:26 +00:00
Eugene Zelenko 6366efeddc [Tooling] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 327573
2018-03-14 21:05:51 +00:00
Rafael Espindola 3c8a39cfbb Set dso_local for NSConcreteStackBlock.
llvm-svn: 327544
2018-03-14 18:19:26 +00:00
Rafael Espindola 3f727a8f3a Set dso_local on external rtti GVs.
In this particular case it would be possible to just add an else with
CGM.setDSOLocal(GV), but it seems better to have as many callers as
possible just call setGVProperties so that we can centralize the logic
there.

This patch then makes setGVProperties able to handle null Decls.

llvm-svn: 327543
2018-03-14 18:14:46 +00:00
Yaxun Liu d9389827d2 CodeGen: Reduce LValue and CallArgList memory footprint before recommitting r326946
Recent change r326946 (https://reviews.llvm.org/D34367) causes regression in Eigen due to increased
memory footprint of CallArg.

This patch reduces LValue size from 112 to 96 bytes and reduces inline argument count of CallArgList
from 16 to 8.

It has been verified that this will let the added deep AST tree test pass with r326946.

In the long run, CallArg or LValue memory footprint should be further optimized.

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

llvm-svn: 327515
2018-03-14 15:02:28 +00:00
Gheorghe-Teodor Bercea d3dcf2f05d [OpenMP] Add OpenMP data sharing infrastructure using global memory
Summary:
This patch handles the Clang code generation phase for the OpenMP data sharing infrastructure.

TODO: add a more detailed description.

Reviewers: ABataev, carlo.bertolli, caomhin, hfinkel, Hahnfeld

Reviewed By: ABataev

Subscribers: jholewinski, guansong, cfe-commits

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

llvm-svn: 327513
2018-03-14 14:17:45 +00:00
Ilya Biryukov 0ee4a08c00 [Sema] Pop function scope when instantiating a func with skipped body
Summary:
By calling ActOnFinishFunctionBody(). Previously we were only calling
ActOnSkippedFunctionBody, which didn't pop the function scope.
This causes a crash when running on our internal code. No test-case,
though, since I couldn't come up with a small example in reasonable
time.

The bug was introduced in r321174.

Reviewers: bkramer, sammccall, sepavloff, aaron.ballman

Reviewed By: sammccall, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 327504
2018-03-14 13:18:30 +00:00
Pavel Labath 3a17e75be9 StaticAnalyzer: fix compiler warning. NFC
My compiler (clang-3.8) complains that the RCC variable is unused.
That's not really true, as it's checked by the if-declaration, but it's
also kinda true, because we don't need to declaration if we only check
it in the if statement.

In reality, all this means that the dyn_cast<> can be replaced by isa<>,
so that's what I do here.

llvm-svn: 327491
2018-03-14 10:16:40 +00:00
Akira Hatanaka ceb66521ba Check that a field is not annotated with attribute "unavailable" before
setting the NonTrivialToPrimitive* flags of a record.

Union fields that have non-trivial Objective-C ownership qualifications
are normally not legal, but if the union is declared in a system header,
the fields are annotated with attribute "unavailable".

rdar://problem/38431072

llvm-svn: 327464
2018-03-13 23:37:51 +00:00
Gheorghe-Teodor Bercea 0d5aa84ad9 [OpenMP] Add flag for linking runtime bitcode library
Summary: This patch adds an additional flag to the OpenMP device offloading toolchain to link in the runtime library bitcode.

Reviewers: Hahnfeld, ABataev, carlo.bertolli, caomhin, grokos, hfinkel

Reviewed By: ABataev, grokos

Subscribers: jholewinski, guansong, cfe-commits

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

llvm-svn: 327460
2018-03-13 23:19:52 +00:00
Sjoerd Meijer a7463df6e2 [ARM] ACLE FP16 feature test macros
This is a partial recommit of r327189 that was reverted
due to test issues. I.e., this recommits minimal functional
change, the FP16 feature test macros, and adds tests that 
were missing in the original commit.

llvm-svn: 327455
2018-03-13 22:11:06 +00:00
Eugene Zelenko bc32433062 [Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 327453
2018-03-13 21:32:01 +00:00
Gheorghe-Teodor Bercea 0805b80a73 Revert revision 327438.
llvm-svn: 327447
2018-03-13 20:50:12 +00:00
Gheorghe-Teodor Bercea 148046c11b [OpenMP] Add flag for linking runtime bitcode library
Summary: This patch adds an additional flag to the OpenMP device offloading toolchain to link in the runtime library bitcode.

Reviewers: Hahnfeld, ABataev, carlo.bertolli, caomhin, grokos, hfinkel

Reviewed By: ABataev, grokos

Subscribers: jholewinski, guansong, cfe-commits

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

llvm-svn: 327438
2018-03-13 19:39:19 +00:00
Sjoerd Meijer 95da875898 This reverts "r327189 - [ARM] Add ARMv8.2-A FP16 vector intrinsic"
This is causing problems in testing, and PR36683 was raised.
Reverting it until we have sorted out how to pass f16 vectors.

llvm-svn: 327437
2018-03-13 19:38:56 +00:00
Akira Hatanaka 34fb26456b Serialize the NonTrivialToPrimitive* flags I added in r326307.
rdar://problem/38421774

llvm-svn: 327434
2018-03-13 18:58:25 +00:00
George Karpenkov 460675eba4 [analyzer] Fix the matcher for GCDAntipattern to look for "signal" call in all parameters
rdar://38405904

llvm-svn: 327426
2018-03-13 17:27:01 +00:00
Joel E. Denny 8150810556 Reland "[Attr] Fix parameter indexing for several attributes"
Relands r326602 (reverted in r326862) with new test and fix for
PR36620.

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

llvm-svn: 327405
2018-03-13 14:51:22 +00:00
Artem Dergachev 54ed6428b4 [CFG] [analyzer] Don't add construction context to a return-by-reference call.
Call expressions that return objects by an lvalue reference or an rvalue
reference have a value type in the AST but wear an auxiliary flag of being an
lvalue or an xvalue respectively.

Use the helper method for obtaining the actual return type of the function.

Fixes a crash.

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

llvm-svn: 327352
2018-03-12 23:52:36 +00:00
Artem Dergachev 09a7c0c77d [analyzer] Support temporaries conjured by conservatively evaluated functions.
Properly perform destruction and lifetime extension of such temporaries.

C++ object-type return values of conservatively evaluated functions are now
represented as compound values of well-defined temporary object regions. The
function creates a region that represents the temporary object and will later
be used for destruction or materialization, invalidates it, and returns the
invalidated compound value of the object.

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

llvm-svn: 327348
2018-03-12 23:36:12 +00:00
Artem Dergachev 98a24bf76d [analyzer] NFC: Move the code for setting temp object lifetime into method.
Differential Revision: https://reviews.llvm.org/D44129

llvm-svn: 327347
2018-03-12 23:27:52 +00:00
Artem Dergachev e078967879 [analyzer] Destroy and lifetime-extend inlined function return values properly.
This patch uses the newly added CFGCXXRecordTypedCall element at the call site
of the caller to construct the return value within the callee directly into the
caller's stack frame. This way it is also capable of populating the temporary
destructor and lifetime extension maps for the temporary, which allows
temporary destructors and lifetime extension to work correctly.

This patch does not affect temporaries that were returned from conservatively
evaluated functions.

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

llvm-svn: 327345
2018-03-12 23:22:35 +00:00
Artem Dergachev 1527dec139 [CFG] [analyzer] Add construction context to C++ return-by-value call elements.
This patch adds a new CFGStmt sub-class, CFGCXXRecordTypedCall, which replaces
the regular CFGStmt for the respective CallExpr whenever the CFG has additional
information to provide regarding the lifetime of the returned value.

This additional call site information is represented by a ConstructionContext
(which was previously used for CFGConstructor elements) that provides references
to CXXBindTemporaryExpr and MaterializeTemporaryExpr that surround the call.

This corresponds to the common C++ calling convention solution of providing
the target address for constructing the return value as an auxiliary implicit
argument during function call.

One of the use cases for such extra context at the call site would be to perform
any sort of inter-procedural analysis over the CFG that involves functions
returning objects by value. In this case the elidable constructor at the return
site would construct the object explained by the context at the call site, and
its lifetime would also be managed by the caller, not the callee.

The extra context would also be useful for properly handling the return-value
temporary at the call site, even if the callee is not being analyzed
inter-procedurally.

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

llvm-svn: 327343
2018-03-12 23:12:40 +00:00
Reid Kleckner 87a3180343 Re-land "[Sema] Make getCurFunction() return null outside function parsing"
This relands r326965.

There was a null dereference in typo correction that was triggered in
Sema/diagnose_if.c. We are not always in a function scope when doing
typo correction. The fix is to add a null check.

LLVM's optimizer made it hard to find this bug. I wrote it up in a
not-very-well-editted blog post here:
http://qinsb.blogspot.com/2018/03/ub-will-delete-your-null-checks.html

llvm-svn: 327334
2018-03-12 21:43:02 +00:00
Alex Lorenz a44c432be4 [Tooling] Clear the PreambleSrcLocCache when preamble is discarded during reparsing
This ensures that diagnostics are not remapped to incorrect preamble locations after
the second reparse with a remapped header file occurs.

rdar://37502480

llvm-svn: 327322
2018-03-12 19:36:29 +00:00
George Karpenkov 44a3b7c130 [analyzer] Move the GCDAsyncSemaphoreChecker to optin.performance
rdar://38383753

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

llvm-svn: 327309
2018-03-12 18:27:36 +00:00
Akira Hatanaka be7daa3d50 Revert "[ObjC] Allow declaring __weak pointer fields in C structs in
ARC."

This reverts commit r327206 as there were test failures caused by this
patch.

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180312/221427.html

llvm-svn: 327294
2018-03-12 17:05:06 +00:00
Ben Hamilton 788a2227b7 [clang-format] Improve detection of Objective-C block types
Summary:
Previously, clang-format would detect the following as an
Objective-C block type:

  FOO(^);

when it actually must be a C or C++ macro dealing with an XOR
statement or an XOR operator overload.

According to the Clang Block Language Spec:

https://clang.llvm.org/docs/BlockLanguageSpec.html

block types are of the form:

  int (^)(char, float)

and block variables of block type are of the form:

  void (^blockReturningVoidWithVoidArgument)(void);
  int (^blockReturningIntWithIntAndCharArguments)(int, char);
  void (^arrayOfTenBlocksReturningVoidWithIntArgument[10])(int);

This tightens up the detection so we don't unnecessarily detect
C macros which pass in the XOR operator.

Depends On D43904

Test Plan: New tests added. Ran tests with:
  make -j12 FormatTests &&
  ./tools/clang/unittests/Format/FormatTests

Reviewers: krasimir, jolesiak, djasper

Reviewed By: djasper

Subscribers: djasper, cfe-commits, klimek

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

llvm-svn: 327285
2018-03-12 15:42:40 +00:00
Ben Hamilton b060ad870f [clang-format] Don't detect C++11 attribute specifiers as ObjC
Summary:
Previously, clang-format would detect C++11 and C++17 attribute
specifiers like the following as Objective-C method invocations:

  [[noreturn]];
  [[clang::fallthrough]];
  [[noreturn, deprecated("so sorry")]];
  [[using gsl: suppress("type")]];

To fix this, I ported part of the logic from
tools/clang/lib/Parse/ParseTentative.cpp into TokenAnnotator.cpp so we
can explicitly parse and identify C++11 attribute specifiers.

This allows the guessLanguage() and getStyle() APIs to correctly
guess files containing the C++11 attribute specifiers as C++,
not Objective-C.

Test Plan: New tests added. Ran tests with:
  make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: krasimir, jolesiak, djasper

Reviewed By: djasper

Subscribers: aaron.ballman, cfe-commits, klimek

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

llvm-svn: 327284
2018-03-12 15:42:38 +00:00
Maxim Ostapenko debca45e45 [analyzer] Add scope information to CFG
This patch adds two new CFG elements CFGScopeBegin and CFGScopeEnd that indicate
when a local scope begins and ends respectively. We use first VarDecl declared
in a scope to uniquely identify it and add CFGScopeBegin and CFGScopeEnd elements
into corresponding basic blocks.

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

llvm-svn: 327258
2018-03-12 12:26:15 +00:00
Daniel Jasper 9c95dfe658 clang-format: Properly handle implicit string concatenation in text protos
Three issues to fix:
- char_constants weren't properly treated as string literals
- Prevening the break after "label: " does not make sense in concunction
  with AlwaysBreakBeforeMultilineStrings. It leads to situations where
  clang-format just cannot find a viable format (it must break and yet
  it must not break).
- AlwaysBreakBeforeMultilineStrings should not be on for LK_TextProto in
  Google style.

llvm-svn: 327255
2018-03-12 10:32:18 +00:00
Daniel Jasper dd0c4e1d83 Don't re-format raw string literal contents when formatting is disable
Not entirely sure this is the best place to put this check, but it fixes
the immediate issue.

llvm-svn: 327253
2018-03-12 10:11:30 +00:00
Petr Hosek 8b8d6bf62f [Driver] Update the comment about incompatible sanitizers
Differential Revision: https://reviews.llvm.org/D44371

llvm-svn: 327249
2018-03-12 00:23:37 +00:00
George Burgess IV 4deb75d2e8 [CodeGen] Eagerly emit lifetime.end markers for calls
In C, we'll wait until the end of the scope to clean up aggregate
temporaries used for returns from calls. This means in cases like:

{
  // Assuming that `Bar` is large enough to warrant indirect returns
  struct Bar b = {};
  b = foo(&b);
  b = foo(&b);
  b = foo(&b);
  b = foo(&b);
}

...We'll allocate space for 5 Bars on the stack (`b`, and 4
temporaries). This becomes painful in things like large switch
statements.

If cleaning up sooner is trivial, we should do it.

llvm-svn: 327229
2018-03-10 23:06:31 +00:00
Akira Hatanaka c181b127c0 [ObjC] Allow declaring __weak pointer fields in C structs in ARC.
This patch uses the infrastructure added in r326307 for enabling
non-trivial fields to be declared in C structs to allow __weak fields in
C structs in ARC.

rdar://problem/33599681

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

llvm-svn: 327206
2018-03-10 06:36:08 +00:00
Akira Hatanaka 9f9d766037 [Driver] Pass Default=false to hasFlag.
I forgot to do this in r326530.

llvm-svn: 327204
2018-03-10 05:55:21 +00:00
Richard Smith 007cb6df58 Revert r326946. It caused stack overflows by significantly increasing the size of a CallArgList.
llvm-svn: 327195
2018-03-10 01:47:22 +00:00
George Burgess IV 56e5a2e13e [CodeGen] Try to not call a dtor after lifetime.end
If CodeGenFunction::EmitCall is:
- asked to emit a call with an indirectly returned value,
- given an invalid return value slot, and
- told the return value of the function it's calling is unused

then it'll make its own temporary, and add lifetime markers so that the
temporary's lifetime ends immediately after the call.

The early lifetime.end becomes problematic when we need to run a
destructor on the result of the function.

Instead of unconditionally saying that results of all calls are used
here (which would be correct, but would also cause us to never emit
lifetime markers for these temporaries), we just build our own temporary
to pass in when a dtor has to be run.

llvm-svn: 327192
2018-03-10 01:11:17 +00:00
Abderrazek Zaafrani 5bd68cf742 [ARM] Add ARMv8.2-A FP16 vector intrinsic
Add the fp16 neon vector intrinsic for ARM as described in the ARM ACLE document.

Reviews in https://reviews.llvm.org/D43650

llvm-svn: 327189
2018-03-09 23:39:34 +00:00
Evgeniy Stepanov d48c0cd910 Don't use -pie in relocatable link.
Summary:
Android, in particular, got PIE enabled by default in r316606. It resulted in
relocatable links passing both -r and -pie to the linker, which is not allowed.

Reviewers: srhines

Subscribers: cfe-commits

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

llvm-svn: 327165
2018-03-09 19:35:16 +00:00
Alexey Bataev 21dab12453 [OPENMP] Fix the address of the original variable in task reductions.
If initialization of the task reductions requires pointer to original
variable, which is stored in the threadprivate storage, we used the
address of this pointer instead.

llvm-svn: 327136
2018-03-09 15:20:30 +00:00
Ilya Biryukov 1a1dffd275 [SemaOverload] Fixed crash on code completion
Summary:
The relevant failing assertion message is:
../tools/clang/lib/Sema/SemaInit.cpp:8411: PerformCopyInitialization(): Assertion `InitE && "No initialization expression?"' failed.

See the added test case for a repro.

Reviewers: bkramer, sammccall, ioeric, hokein

Reviewed By: sammccall

Subscribers: cfe-commits

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

llvm-svn: 327134
2018-03-09 14:43:29 +00:00
Saleem Abdulrasool 3e70132753 CodeGen: simplify and validate exception personalities
Simplify the dispatching for the personality routines.  This really had
no test coverage previously, so add test coverage for the various cases.
This turns out to be pretty complicated as the various languages and
models interact to change personalities around.

You really should feel bad for the compiler if you are using exceptions.
There is no reason for this type of cruelty.

llvm-svn: 327105
2018-03-09 07:06:42 +00:00
Richard Smith 69cf59ed26 PR36645: Go looking for an appropriate array bound when constant-evaluating a
name of an array object.

llvm-svn: 327099
2018-03-09 02:00:01 +00:00
Artem Dergachev ce5f2d3d42 [analyzer] MmapWriteExecChecker: Add support for mprotect().
mprotect() allows setting memory access flags similarly to mmap(),
causing similar security issues if these flags are needlessly broad.

Patch by David Carlier!

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

llvm-svn: 327098
2018-03-09 01:47:24 +00:00