Commit Graph

25147 Commits

Author SHA1 Message Date
Adrian Prantl 0d82089233 Revert "Debug Info: Represent local anonymous unions as anonymous unions"
This reverts commit r236059 as it breaks the gdb buildbot.

llvm-svn: 236110
2015-04-29 15:05:50 +00:00
Alexey Bataev 19fa2c3b66 [OPENMP] Fix crash on reductions codegen for short circuit reduction operations.
llvm-svn: 236084
2015-04-29 05:21:03 +00:00
Nico Weber ea721b64df Revert r236052, it caused linker errors when building 32-bit applications.
llvm-svn: 236082
2015-04-29 03:08:32 +00:00
Richard Trieu ac3eca536d Add -Wpessimizing-move and -Wredundant-move warnings.
-Wpessimizing-move warns when a call to std::move would prevent copy elision
if the argument was not wrapped in a call.  This happens when moving a local
variable in a return statement when the variable is the same type as the
return type or using a move to create a new object from a temporary object.

-Wredundant-move warns when an implicit move would already be made, so the
std::move call is not needed, such as when moving a local variable in a return
that is different from the return type.

Differential Revision: http://reviews.llvm.org/D7633

llvm-svn: 236075
2015-04-29 01:52:17 +00:00
Richard Smith 180b92168d PR20625: Instantiate static constexpr member function of a local struct in a function template earlier.
This is necessary in order to allow the use of a constexpr member function, or
a member function with deduced return type, of a local class within a
surrounding instantiated function template specialization.

Patch by Michael Park!

llvm-svn: 236063
2015-04-29 00:07:09 +00:00
Adrian Prantl 0a4ddc180b Debug Info: Represent local anonymous unions as anonymous unions
in the debug info. This patch deletes a hack that emits the members
of local anonymous unions as local variables.

Besides being morally wrong, the existing representation using local
variables breaks internal assumptions about the local variables' storage
size.

Compiling

```
   void fn1() {
     union {
       int i;
       char c;
     };
     i = c;
   }

```

with -g -O3 -verify will cause the verifier to fail after SROA splits
the 32-bit storage for the "local variable" c into two pieces because the
second piece is clearly outside the 8-bit range that is expected for a
variable of type char. Given the choice I'd rather fix the debug
representation than weaken the verifier.

Debuggers generally already know how to deal with anonymous unions when
they are members of C++ record types, but they may have problems finding
the local anonymous struct members in the expression evaluator.

rdar://problem/20730771

llvm-svn: 236059
2015-04-28 23:01:24 +00:00
Reid Kleckner de57c2af61 Fix Sema tests using __try by adding triple
llvm-svn: 236057
2015-04-28 22:58:25 +00:00
Reid Kleckner ddd40964f0 [SEH] Add 32-bit lowering code for __try
This is just the clang-side of 32-bit SEH. LLVM still needs work, and it
will determinstically fail to compile until it's feature complete.

On x86, all outlined handlers have no parameters, but they do implicitly
take the EBP value passed in and use it to address locals of the parent
frame. We model this with llvm.frameaddress(1).

This works (mostly), but __finally block inlining can break it. For now,
we apply the 'noinline' attribute. If we really want to inline __finally
blocks on 32-bit x86, we should teach the inliner how to untangle
frameescape and framerecover.

Promote the error diagnostic from codegen to sema. It now rejects SEH on
non-Windows platforms. LLVM doesn't implement SEH on non-x86 Windows
platforms, but there's nothing preventing it.

llvm-svn: 236052
2015-04-28 22:19:32 +00:00
Steven Wu 2baa53ace9 Fix -fno-gnu-inline-asm doesn't catch file scope asm
Summary:
FileScopeAsm should be treated the same as funcion level inline asm.
-fno-gnu-inline-asm should trigger an error if file scope asm is used.
I missed this case from r226340. This should not affect ms-extension
because it is not allowed in the file scope.

Reviewers: bob.wilson, rnk

Reviewed By: rnk

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D9328

llvm-svn: 236044
2015-04-28 21:49:09 +00:00
Richard Smith 6d69e8c00b Fix assertion failure if a lambda array-capture is followed by a this capture.
llvm-svn: 236043
2015-04-28 21:41:14 +00:00
Artem Belevich a0473a5479 [cuda] Preserve TLS storage class of host variable even if it's a
device-side compilation.

llvm-svn: 236029
2015-04-28 20:31:49 +00:00
Sean Callanan 59721b3d3f Implemented ASTImporter support for Stmts and fixed
some bugs in the ASTImporter that this exposed:

- When importing functions, the body (if any) was
  previously ignored.  This patch ensures that the
  body is imported also.

- When a function-local Decl is imported, the first
  thing the ASTImporter does is import its context
  (via ImportDeclParts()).  This can trigger 
  importing the Decl again as part of the body of
  the function (but only once, since the function's
  Decl has been added to ImportedDecls).  This patch
  fixes that problem by extending ImportDeclParts()
  to return the imported Decl if it was imported as
  part of importing its context, and the patch adds
  ASTImporter::GetAlreadyImportedOrNull() to support
  this query.  All callers of ImportDeclParts return
  the imported version of the Decl if ImportDeclParts()
  returns it.

- When creating functions, InnerLocStart of the source
  function was re-used without importing.  This is a
  straight up bug, and this patch makes ASTImporter
  import the InnerLocStart and use the imported version.

- When importing FileIDs, the ASTImporter previously
  always tried to re-load the file for the corresponding
  CacheEntry from disk.  This doesn't work if the 
  CacheEntry corresponds to a named memory buffer.  This
  patch changes the code so that if the UniqueID for the
  cache entry is invalid (i.e., it is not a disk file)
  the whole entry is treated as if it were invalid, which
  forces an in-memory copy of the buffer.

Also added test cases, using the new support committed in
236011.

llvm-svn: 236012
2015-04-28 18:41:46 +00:00
Jonathan Roelofs 7441136d2a Fix PR22047: ObjC: Method unavailability attribute doesn't work with overloaded methods
http://reviews.llvm.org/D9261

llvm-svn: 236006
2015-04-28 18:04:44 +00:00
Serge Pavlov 907233fd99 Combine instantiation context of field initializer with context of class.
Inclass initializer is instantiated in its own LocalInstantiationScope. It
causes problems when instantiating local classes - when instantiation scope
is searched for DeclContext of the field, the search fails. As a solution,
the instantiation scope of field initializer is combined with its outer
scope.

This patch fixes PR23194.

Differential Revision: http://reviews.llvm.org/D9258

llvm-svn: 236005
2015-04-28 17:58:47 +00:00
Elena Demikhovsky 35dc8c0944 AVX-512: added intrinsics for KNL and SKX
by Asaf Badouh (asaf.badouh@intel.com)

llvm-svn: 235986
2015-04-28 13:28:01 +00:00
Alexey Bataev 6111469a4a [OPENMP] Fix crash on loop control vars explicitly marked as private.
It is allowed to mark loop control vars as private in 'private' or 'lastprivate' clause, so no need to assert here.

llvm-svn: 235985
2015-04-28 13:20:05 +00:00
Bradley Smith ba945626b0 [ARM/AArch64] Enforce alignment for bitfielded structs
When creating a global variable with a type of a struct with bitfields, we must
forcibly set the alignment of the global from the RecordDecl. We must do this so
that the proper bitfield alignment makes its way down to LLVM, since clang will
mangle the bitfields into one large type.

llvm-svn: 235976
2015-04-28 11:24:54 +00:00
Justin Bogner 097f1bf4b2 InstrProf: Match a bit less strictly - some targets may add signext
Notably, this bot didn't like it:

  http://lab.llvm.org:8011/builders/clang-cmake-mips/builds/5117

llvm-svn: 235968
2015-04-28 06:55:23 +00:00
Justin Bogner f959febf7a InstrProf: Mark code regions after throw expressions as unreachable
We weren't setting regions as being unreachable after C++ throw
expressions, leading to incorrect count propagations.

llvm-svn: 235967
2015-04-28 06:31:55 +00:00
Duncan P. N. Exon Smith 374934cb8a DebugInfo: Add a clang test for LLVM fix for PR23332
Add a clang test for LLVM r235955, which added support for up to 2^16
arguments.

llvm-svn: 235956
2015-04-28 01:09:20 +00:00
Alexey Samsonov d60832eade Allow UBSan+MSan and UBSan+TSan combinations (Clang part).
Embed UBSan runtime into TSan and MSan runtimes in the same as we do
in ASan. Extend UBSan test suite to also run tests for these
combinations.

llvm-svn: 235953
2015-04-28 00:56:36 +00:00
John McCall f3e86a7a55 ms_struct does not imply the MS base-layout ABI; separate these
conditions in the IRGen struct layout code.

rdar://20636558

llvm-svn: 235949
2015-04-28 00:17:18 +00:00
Reid Kleckner e0bca755d8 Remove stale FIXMEs from test case
llvm-svn: 235937
2015-04-27 23:14:24 +00:00
Eric Christopher f37ab1ca73 Always add the target-cpu and target-features sets if they're non-null.
This makes sure that the front end is specific about what they're expecting
the backend to produce. Update a FIXME with the idea that the target-features
could be more precise using backend knowledge.

llvm-svn: 235936
2015-04-27 23:11:34 +00:00
Aaron Ballman edc8084751 Check whether the operand to a noexcept expression is valid or not. Fixes PR15842.
llvm-svn: 235931
2015-04-27 22:31:12 +00:00
Alexey Samsonov 381845d54f Introduce tsan_cxx and msan_cxx libraries (Clang part).
For now tsan_cxx and msan_cxx contain only operator new/delete
replacements. In the future, when we add support for running UBSan+TSan
and UBSan+MSan, they will also contain bits ubsan_cxx runtime.

llvm-svn: 235924
2015-04-27 22:07:50 +00:00
Richard Smith c38498f046 PR23334: Perform semantic checking of lambda capture initialization in the right context.
Previously we'd try to perform checks on the captures from the middle of
parsing the lambda's body, at the point where we detected that a variable
needed to be captured. This was wrong in a number of subtle ways. In
PR23334, we couldn't correctly handle the list of potential odr-uses
resulting from the capture, and our attempt to recover from that resulted
in a use-after-free.

We now defer building the initialization expression until we leave the lambda
body and return to the enclosing context, where the initialization does the
right thing. This patch only covers lambda-expressions, but we should apply
the same change to blocks and captured statements too.

llvm-svn: 235921
2015-04-27 21:27:54 +00:00
Artem Belevich c3e2fd7bea Revert "PR21000: pass -I options to assembler" as the test was failing on hexagon.
llvm-svn: 235919
2015-04-27 21:11:08 +00:00
Artem Belevich 8fe8ed56ee PR21000: pass -I options to assembler
Pass -I options to assembly so it can find files included with
.include.

Differential Revision: http://reviews.llvm.org/D7472

llvm-svn: 235915
2015-04-27 20:51:44 +00:00
Paul Robinson d101ca21e6 Simplify depfile quoting test.
With -MG we don't actually need to create the files with funky names.
Also use a more sensible check-prefix for the NMAKE case.

llvm-svn: 235908
2015-04-27 19:40:04 +00:00
Artem Belevich fa62ad4087 [cuda] Ignore "TLS unsupported by target" errors for host variables during device compilation.
During device-side CUDA compilation clang currently complains about
all TLS variables, regardless of whether they are __host__ or
__device__.

This patch suppresses "TLS unsupported" errors for host variables
during device compilation and for device variables during host
compilation.

Differential Revision: http://reviews.llvm.org/D9269

llvm-svn: 235907
2015-04-27 19:37:53 +00:00
Artem Belevich 0488d1e4ba [cuda] treat file scope __asm as __host__ and ignore it during device-side compilation.
Currently clang emits file-scope asm during *both* host and device
compilation modes which is usually a wrong thing to do.

There's no way to attach any attribute to an __asm statement, so
there's no way to differentiate between host-side and device-side
file-scope asm.  This patch makes clang to match nvcc behavior and
emit file-scope-asm only during host-side compilation.

Differential Revision: http://reviews.llvm.org/D9270

llvm-svn: 235905
2015-04-27 18:52:00 +00:00
Paul Robinson d7214a7651 Support generating NMake/Jom-style depfiles.
NMake is a Make-like builder that comes with Microsoft Visual Studio.
Jom (https://wiki.qt.io/Jom) is an NMake-compatible build tool.
Dependency files for NMake/Jom need to use double-quotes to wrap
filespecs containing special characters, instead of the backslash
escapes that GNU Make wants.

Adds the -MV option, which specifies to use double-quotes as needed
instead of backslash escapes when writing the dependency file.

Differential Revision: http://reviews.llvm.org/D9260

llvm-svn: 235903
2015-04-27 18:14:32 +00:00
Reid Kleckner 4cb2dbde5b [MS ABI] Use 'continue' instead of 'return false' where intended
This was a bug in r218285 that prevented us from seeing subsequent
virtual bases in the class hierarchy, leading to crashes later.

Also add some comments to this function, now that we better understand
what it's trying to do.

Fixes PR21062 and PR21064.

llvm-svn: 235899
2015-04-27 17:19:49 +00:00
Alexey Bataev 8b8e202a33 [OPENMP] Codegen for 'taskwait' directive.
Emit the following code for 'taskwait' directive within tied task:
call i32 @__kmpc_omp_taskwait(<loc>, i32 <thread_id>);
Differential Revision: http://reviews.llvm.org/D9245

llvm-svn: 235836
2015-04-27 05:22:09 +00:00
Alexey Bataev a89adf22db [OPENMP] Codegen for 'reduction' clause in 'sections' directive.
Emit a code for reduction clause. Next code should be emitted for reductions:

static kmp_critical_name lock = { 0 };

void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
    *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]);
      ...
        *(Type<n>-1*)lhs[<n>-1] =
          ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1],
            *(Type<n>-1*)rhs[<n>-1]);
}

...
void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]};
switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) {
case 1:
  <LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0]);
  ...
  <LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1]);
  __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>);
  break;
case 2:
  Atomic(<LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0]));
  ...
  Atomic(<LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1]));
  break;
default:;
}
Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation.
If sections directive has only single section, then original shared variables are used instead with barrier at the end of the directive.
Differential Revision: http://reviews.llvm.org/D9242

llvm-svn: 235835
2015-04-27 05:04:13 +00:00
Alexey Bataev 9efc03b6f7 [OPENMP] Codegen for 'lastprivate' clause in 'sections' directive.
#pragma omp sections lastprivate(<var>)
<BODY>;
This construct is translated into something like:

<last_iter> = alloca i32
<init for lastprivates>;
<last_iter> = 0
; No initializer for simple variables or a default constructor is called for objects.
; For arrays perform element by element initialization by the call of the default constructor.
...
OMP_FOR_START(...,<last_iter>, ..); sets <last_iter> to 1 if this is the last iteration.
<BODY>
...
OMP_FOR_END
if (<last_iter> != 0) {
  <final copy for lastprivate>; Update original variable with the lastprivate value.
}
call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race.
If there is only one section, there is no special code generation, original shared variables are used + barrier is emitted at the end of the directive.
Differential Revision: http://reviews.llvm.org/D9240

llvm-svn: 235834
2015-04-27 04:34:03 +00:00
Alexey Bataev 7387083d95 [OPENMP] Codegen for 'private' clause in 'sections' directive.
If there are 2 or more sections in a 'section' directive the following code is generated:

<default init for privates>
@__kmpc_for_static_init_4();
<BODY for sections directive>
@__kmpc_for_static_fini()
If there is only one section, the following code is generated:

if (@__kmpc_single()) {
  <default init for privates>
  @__kmpc_end_single();
}
Differential Revision: http://reviews.llvm.org/D9239

llvm-svn: 235833
2015-04-27 04:12:12 +00:00
Alexey Bataev 59c654aa43 [OPENMP] Codegen for 'private' clause in 'single' directive.
Emit the following code for 'single' directive with 'private' clause:

if (@__kmpc_single()) {
  <default init for privates>
  @__kmpc_end_single();
}
Differential Revision: http://reviews.llvm.org/D9238

llvm-svn: 235832
2015-04-27 03:48:52 +00:00
David Majnemer 9370dc2fda [Sema] Do not permit binding a reference to a compound literal
We could probably make this work if we cared enough.  However, we are
far outside any language rules at this point.

This fixes PR21834.

llvm-svn: 235818
2015-04-26 07:35:03 +00:00
David Majnemer 8702b5215e [Sema] Don't allow unverified bitfields in FieldDecls
VerifyBitField must be called if we are to form a bitfield FieldDecl.
We will not verify the bitfield if the decl is known to be malformed in
other ways; pretend that we don't have a bitfield if this happens.

llvm-svn: 235816
2015-04-26 04:58:18 +00:00
John McCall 9fc700e76d Correctly handle zero-sized but non-empty base classes in IRGen.
Fixes rdar://20621065.

A more elegant fix would preclude this case by defining the
rules such that zero-size classes are always formally empty.
I believe the only extensions which create zero-size classes
right now are flexible arrays and zero-length arrays; it's
not abstractly unreasonable to say that those don't count
as members for the purposes of emptiness, just as zero-width
bitfields don't count.  But that's an ABI-affecting change
and requires further discussion; in the meantime, let's not
assert / miscompile.

llvm-svn: 235815
2015-04-26 04:43:26 +00:00
Davide Italiano 3c613d608d [Sema] Check if a builtin is FunctionPrototype().
Don't assume it's always is. This prevents a crash in Sema while
trying to merge return type for a builtin w/out function prototype.
 
PR:		23086
Differential Revision:	http://reviews.llvm.org/D9235
Reviewed by:	rsmith

llvm-svn: 235806
2015-04-25 20:20:04 +00:00
Justin Bogner e3654ce7ab InstrProf: Fix coverage maps for conditional operators
This fixes a crash when we're emitting coverage and a macro appears
between two binary conditional operators, ie, "foo ?: MACRO ?: bar",
and fixes the interaction of macros and conditional operators in
general.

llvm-svn: 235793
2015-04-24 23:37:57 +00:00
Nico Weber 1f0f165d50 clang-cl: Don't look up absolute paths in %LIB%.
Before this patch, passing a non-existent absolute path to clang-cl would cause
stat'ing of impossible paths. For example, `clang-cl -c d:\adsfasdf.txt` would
cause a stat of
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIBd:\asdfadsf.cc

llvm-svn: 235787
2015-04-24 22:16:53 +00:00
David Blaikie cb6b6f7e20 [opaque pointer type] Update test cases now that the type for an invoke is just a function type, not a pointer-to-function type
llvm-svn: 235756
2015-04-24 19:33:25 +00:00
Alexey Bataev 5521d78532 [OPENMP] Codegen for 'firstprivate' clause in 'single' directive.
Emit the following code for 'single' directive with 'firtstprivate' clause:

if (@__kmpc_single()) {
  <init for firstprivates>
  @__kmpc_end_single();
}
@__kmpc_cancel_barrier(); // To avoid data race in firstprivate init
Differential Revision: http://reviews.llvm.org/D9223

llvm-svn: 235694
2015-04-24 04:21:15 +00:00
Alexey Bataev 8b72566eec [OPENMP] Do not emit implicit barrier for single directive with 'copyprivate' clause(s).
Runtime function for 'copyprivate' directive generates implicit barriers, so no need to emit it.
Differential Revision: http://reviews.llvm.org/D9215

llvm-svn: 235692
2015-04-24 04:00:39 +00:00
Alexey Bataev 2cb9b95adf [OPENMP] Codegen for 'firstprivate' clause in 'sections' directive.
If there are 2 or more sections in a 'section' directive the following code is generated:

<init for firstprivates>
@__kmpc_cancel_barrier();// To avoid data race in firstprivate init
@__kmpc_for_static_init_4();
<BODY for sections directive>
@__kmpc_for_static_fini()
If there is only one section, the following code is generated:

if (@__kmpc_single()) {
  <init for firstprivates>
  @__kmpc_end_single();
}
@__kmpc_cancel_barrier(); // To avoid data race in firstprivate init
Differential Revision: http://reviews.llvm.org/D9214

llvm-svn: 235691
2015-04-24 03:37:03 +00:00
David Majnemer e154456d4a [MS ABI] Fix the preferred alignment of member pointers
Member pointers in the MS ABI have different alignment depending on
whether they were created on the stack or live in a record.

llvm-svn: 235681
2015-04-24 01:25:05 +00:00