Commit Graph

58032 Commits

Author SHA1 Message Date
Richard Smith 2c9608b3b3 Fix use of uninitialized variable, found by ubsan selfhost.
llvm-svn: 236191
2015-04-30 00:57:08 +00:00
Sean Callanan 25d34af88a Use a more reliable method to determine whether
a FileID corresponds to a real file or to a
memory buffer.  The old method didn't work when
Clang was built Release, which meant it wasn't
a very good method at all.

llvm-svn: 236188
2015-04-30 00:44:21 +00:00
NAKAMURA Takumi 83a758a19a Update clang/test/CodeGenCXX/copy-constructor-synthesis-2.cpp to pass for targeting i686.
r236155 missed the suffix in "@llvm.memcpy.p0i8.p0i8.i32".

llvm-svn: 236184
2015-04-29 23:55:46 +00:00
Richard Smith f5ec2acca9 Add an assert to get information on buildbot failure.
llvm-svn: 236181
2015-04-29 23:40:48 +00:00
Eric Christopher fb481a4054 Propagate a terrible hack to the sparc target feature handling code
by erasing the soft-float target feature if the rest of the front
end added it because of defaults or the soft float option.

Add some testing for some of the targets that implement this hack.

llvm-svn: 236179
2015-04-29 23:32:17 +00:00
Richard Smith 3d5925b0e4 Fix unused variable warning.
llvm-svn: 236178
2015-04-29 23:26:13 +00:00
Richard Smith 20e883e59b [modules] Stop trying to fake up a linear MacroDirective history.
Modules builds fundamentally have a non-linear macro history. In the interest
of better source fidelity, represent the macro definition information
faithfully: we have a linear macro directive history within each module, and at
any point we have a unique "latest" local macro directive and a collection of
visible imported directives. This also removes the attendent complexity of
attempting to create a correct MacroDirective history (which we got wrong
in the general case).

No functionality change intended.

llvm-svn: 236176
2015-04-29 23:20:19 +00:00
Rick Foos 2688a49981 XFAIL Hexagon until more codegen in place.
Summary:
Hexagon is being updated, but there is not enough to pass these tests.
These sections are now on top of Colin's list.

Test Plan: Ran changes on hexagon-build-03.

Reviewers: colinl, rfoos

Reviewed By: rfoos

Subscribers: cfe-commits

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

llvm-svn: 236173
2015-04-29 22:54:40 +00:00
Reid Kleckner be9843ce54 Revert r236128, LLVM isn't falling back in the right way
llvm-svn: 236167
2015-04-29 21:55:21 +00:00
David Blaikie 881b23402e [opaque pointer type] update for LLVM API change
llvm-svn: 236161
2015-04-29 21:22:47 +00:00
Nico Weber 6e0ebaea1f Revert r236060, it caused PR23375.
llvm-svn: 236159
2015-04-29 21:16:40 +00:00
Richard Smith 0ae6b2b839 Stop assuming a 64-bit target here.
llvm-svn: 236155
2015-04-29 20:49:22 +00:00
Richard Smith 419bd09415 PR23373: A defaulted union copy constructor that is not trivial must still be
emitted as a memcpy.

llvm-svn: 236142
2015-04-29 19:26:57 +00:00
Richard Smith 6282b215cc Revert r236063 due to regression with -fdelayed-template-parsing.
llvm-svn: 236134
2015-04-29 17:48:08 +00:00
Reid Kleckner 0bb12a8981 Re-land r236052, the linker errors were fixed by LLVM r236123
Basic __finally blocks don't cause linker errors anymore (although they
are miscompiled).

llvm-svn: 236128
2015-04-29 17:17:17 +00:00
Adrian Prantl 00820abf02 Debug Info: Represent local anonymous unions as anonymous unions
and as artificial local variables in the debug info.

This is a follow-up to r236059. We can't get rid of the local variables
entirely because the gdb buildbot depends on them, but we can mark them
as artificial while still emitting the correct debug info. As I learned
from review comments other compilers also follow this model.

A paired commit in LLVM temporarily relaxes the debug info verifier to
not check the integrity of DW_OP_bit_pieces of artificial variables.

rdar://problem/20730771

llvm-svn: 236125
2015-04-29 16:52:31 +00:00
Duncan P. N. Exon Smith 9dd4e4e63a DebugInfo: Metadata constructs now start with DI*
LLVM r236120 renamed debug info IR constructs to use a `DI` prefix, now
that the `DIDescriptor` hierarchy has been gone for about a week.  This
commit was generated using the rename-md-di-nodes.sh upgrade script
attached to PR23080, followed by running clang-format-diff.py on the
`lib/` portion of the patch.

llvm-svn: 236121
2015-04-29 16:40:08 +00:00
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
Bradley Smith dfddebcfb9 Revert code changes made under r235976.
This issue was fixed elsewhere in r235396 in a more general way, hence these
changes no longer do anything. Keep the testcase however, to ensure that we
don't regress this for ARM.

llvm-svn: 236104
2015-04-29 14:32:06 +00:00
Daniel Jasper a4499133b1 clang-format: Add ability to align assignment operators.
In Objective-C some style guides use a style where assignment operators are
aligned, in an effort to increase code readability. This patch adds an option
to the format library which allows this functionality. It is disabled by
default for all the included styles, so it must be explicitly enabled.

The option will change code such as:
  - (void)method {
      NSNumber *one = @1;
      NSNumber *twentyFive = @25;
  }

to:
  - (void)method {
      NSNumber *one        = @1;
      NSNumber *twentyFive = @25;
  }

Patch by Matt Oakes. Thank you!

Accidentally reformatted all the tests...

llvm-svn: 236100
2015-04-29 13:06:49 +00:00
Daniel Jasper eb45cb7cf9 clang-format: Fix selective indentaiton in nested blocks.
Buggy case:
  someFunction(
      [] {
        // comment
        int i; // invoke formatting here.
      },       // force line break
      aaa);

llvm-svn: 236091
2015-04-29 08:29:26 +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
Eric Christopher 52fa24172f Stop emitting the soft-float and soft-float-abi target features
for ARM while the backend will only ignore them. No functional
change intended.

llvm-svn: 236060
2015-04-28 23:18:33 +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 b49febeaee Fix the typo in r236044. NFC.
llvm-svn: 236051
2015-04-28 22:07:05 +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
Sean Callanan 9a89d6a185 Attempt to fix the MSVC build by making ExprIterator
inherit correctly.

llvm-svn: 236035
2015-04-28 21:18:01 +00:00
Richard Smith 9a99aa75d7 Work around a suspected MSVC miscompile to try to bring the MSVC2013 buildbot back.
llvm-svn: 236034
2015-04-28 21:09:27 +00:00
Richard Smith 1e1728536a Refactor to make MacroState ownership and lifetime clearer.
llvm-svn: 236032
2015-04-28 21:05:07 +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
Sean Callanan 61ea0571ac Implemented support for testing the ASTImporter's
ability to generate code that CodeGen likes.  Test
cases can use this functionality by calling

// RUN: %clang_cc1 -emit-obj -o /dev/null -ast-merge %t.1.ast -ast-merge %t.2.ast %s

llvm-svn: 236011
2015-04-28 18:24:12 +00:00
Nico Weber 20b0ce3abd Fix typo in comment.
llvm-svn: 236010
2015-04-28 18:19:18 +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
Aaron Ballman e918faadd2 Silencing a -Wuninitialized warning in a different way. This replaces r235981, but is still NFC.
llvm-svn: 236002
2015-04-28 17:34:38 +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
Aaron Ballman d1c6916327 Silencing a spurious -Wuninitialized warning with this local; NFC.
llvm-svn: 235981
2015-04-28 12:36:54 +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
Richard Smith 66f5ab26e3 Fix memory leak found by asan buildbot.
llvm-svn: 235957
2015-04-28 01:11:23 +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
Richard Smith cc2236f777 Refactor: put these function declarations somewhere more appropriate.
llvm-svn: 235946
2015-04-27 23:52:41 +00:00
Richard Smith 753e007091 [modules] Incrementally compute the list of overridden module macros based on
the active module macros at the point of definition, rather than reconstructing
it from the macro history. No functionality change intended.

llvm-svn: 235941
2015-04-27 23:21:38 +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 c925aa3ab8 [OPENMP] Simplified iteration over clauses, NFC.
llvm-svn: 235838
2015-04-27 08:00:32 +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 bdc1fedf1c [MS ABI] Rephrase the mangling of array types in parameters
Make the canonicalization of array types more consistent.

llvm-svn: 235831
2015-04-27 03:07:47 +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
Lang Hames 51ad8f1e4d Revert r235749 - Accidentally commited cruft from the wrong path.
llvm-svn: 235750
2015-04-24 19:08:30 +00:00
Lang Hames ef789b6a90 [CodeGen] Make AsmPrinter's OutStreamer member a unique_ptr.
AsmPrinter owns the OutStreamer, so an owning pointer makes sense here. Using a
reference for this is crufty.

llvm-svn: 235749
2015-04-24 19:04:55 +00:00
Daniel Jasper 775954be1e clang-format: Don't wrap after short first segments of builder calls.
Before:
  a()
      .aaaaa()
      .aaaaa()
      .aaaaa();

After:
  a().aaaaa()
      .aaaaa()
      .aaaaa();

llvm-svn: 235707
2015-04-24 10:08:09 +00:00
Daniel Jasper de0d1f3c26 clang-format: More selectively detect QT's "signals".
llvm-svn: 235702
2015-04-24 07:50:34 +00:00
Craig Topper bccb773ebc [TableGen] Clang changes for r235697 to stop leaking Expanders and Operators in SetTheory.
llvm-svn: 235698
2015-04-24 06:53:50 +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
David Majnemer b9ac794f57 Remove unused variable to silence GCC warning
llvm-svn: 235693
2015-04-24 04:14:25 +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 5fd33e0d1a Replace getPointeeType()->isFunctionType with isMemberDataPointerType
llvm-svn: 235682
2015-04-24 01:25:08 +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
David Majnemer 37ea57862f Cleanup some MS-ABI specific code
No functional change intended.

llvm-svn: 235680
2015-04-24 01:24:59 +00:00
Richard Smith 6b77f549cb [modules] Partial revert of r235669: don't create ModuleMacros for imported local macros.
The surrounding infrastructure isn't quite ready for this yet.

llvm-svn: 235677
2015-04-24 00:41:09 +00:00
Richard Smith 50474bf5d2 [modules] Refactor creation of ModuleMacros and create them when importing from local submodules.
llvm-svn: 235669
2015-04-23 23:29:05 +00:00
Justin Bogner 66242d6c5e InstrProf: Stop using RegionCounter outside of CodeGenPGO (NFC)
The RegionCounter type does a lot of legwork, but most of it is only
meaningful within the implementation of CodeGenPGO. The uses elsewhere
in CodeGen generally just want to increment or read counters, so do
that directly.

llvm-svn: 235664
2015-04-23 23:06:47 +00:00
Richard Smith 2a553089c3 [modules] Properly attribute macros to modules if they're in a file textually included into a file in the module.
llvm-svn: 235661
2015-04-23 22:58:06 +00:00
Sergey Matveev 33e322455f Fix clang docs build.
llvm-svn: 235650
2015-04-23 21:29:37 +00:00
Richard Smith de71142dce [modules] Remove the now-redundant import of all pending macros at the end of building a module.
Since we now track module macros separately from their visibility state, this
is no longer necessary.

llvm-svn: 235648
2015-04-23 21:20:19 +00:00
Richard Smith 713369b057 [modules] Store a ModuleMacro* on an imported macro directive rather than duplicating the info within it.
llvm-svn: 235644
2015-04-23 20:40:50 +00:00
Sergey Matveev 07e2d283a3 Add clang/docs/SanitizerCoverage.rst
Moved from https://code.google.com/p/address-sanitizer/wiki/AsanCoverage

llvm-svn: 235643
2015-04-23 20:40:04 +00:00
Richard Smith b8b2ed6529 [modules] Determine the set of macros exported by a submodule at the end of that submodule.
Previously we'd defer this determination until writing the AST, which doesn't
allow us to use this information when building other submodules of the same
module. This change also allows us to use a uniform mechanism for writing
module macro records, independent of whether they are local or imported.

llvm-svn: 235614
2015-04-23 18:18:26 +00:00
Reid Kleckner 1ef49218b3 Don't emit lifetime markers when msan is enabled
In r235553, Clang started emitting lifetime markers more often. This
caused false negative in MSan, because MSan only poisons all allocas
once at function entry. Eventually, MSan should poison allocas at
lifetime start and probably also lifetime end, but until then, let's not
emit markers that aren't going to be useful.

llvm-svn: 235613
2015-04-23 18:07:13 +00:00
Aaron Ballman b673c65cb2 Extend format specifier checking to include field function pointers in addition to variable function pointers. Addresses PR21082.
llvm-svn: 235606
2015-04-23 16:14:19 +00:00
Aaron Ballman 1710cc994e Diagnose variadic main() as an extension; addresses PR17905.
llvm-svn: 235605
2015-04-23 16:12:42 +00:00
Daniel Jasper 0faa9136fa clang-format: Properly detect variable declarations with ObjC.
Before:
  LoooooooooooooooooooooooooooooooooooooooongType
  LoooooooooooooooooooooooooooooooooooooongVariable([A a]);

After:
  LoooooooooooooooooooooooooooooooooooooooongType
      LoooooooooooooooooooooooooooooooooooooongVariable([A a]);

llvm-svn: 235599
2015-04-23 13:58:40 +00:00
Daniel Jasper caf84fe21e clang-format: Allow splitting "= default" and "= delete".
Otherwise, this can violate the column limit.

llvm-svn: 235592
2015-04-23 12:59:09 +00:00
Daniel Jasper 532a031422 clang-format: Don't add unwanted space when creating new arrays.
Before:
  char** newargv = new char* [argc];

After:
  char** newargv = new char*[argc];

llvm-svn: 235583
2015-04-23 10:23:53 +00:00
Daniel Jasper 1b998815a0 clang-format: [Proto] Don't linewrap top-level options.
They are very similar to import statements.

llvm-svn: 235582
2015-04-23 09:54:10 +00:00
Daniel Jasper 289afc071e clang-format: Support nested block formatting with ColumnLimit=0.
llvm-svn: 235580
2015-04-23 09:23:17 +00:00
Alexey Bataev 112a7bf961 [OPENMP] Fix for failed tests for 'omp atomic write' construct.
llvm-svn: 235576
2015-04-23 07:56:25 +00:00
David Majnemer 9595b7da1a [MS ABI] Add support for mangling VLA types
Treat a VLA type like an incomplete array type.

llvm-svn: 235575
2015-04-23 07:42:08 +00:00
Alexey Bataev 5e018f9e29 [OPENMP] Codegen for 'atomic capture'.
Adds codegen for 'atomic capture' constructs with the following forms of expressions/statements:

v = x binop= expr;
v = x++;
v = ++x;
v = x--;
v = --x;
v = x = x binop expr;
v = x = expr binop x;
{v = x; x = binop= expr;}
{v = x; x++;}
{v = x; ++x;}
{v = x; x--;}
{v = x; --x;}
{x = x binop expr; v = x;}
{x binop= expr; v = x;}
{x++; v = x;}
{++x; v = x;}
{x--; v = x;}
{--x; v = x;}
{x = x binop expr; v = x;}
{x = expr binop x; v = x;}
{v = x; x = expr;}
If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted.
Otherwise compare-and-swap sequence is emitted.
Update of 'v' is not required to be be atomic with respect to the read or write of the 'x'.

bb:
...
atomic load <x>
cont:
<expected> = phi [ <x>, label %bb ], [ <new_failed>, %cont ]
<desired> = <expected> binop <expr>
<res> = cmpxchg atomic &<x>, desired, expected
<new_failed> = <res>.field1;
br <res>field2, label %exit, label %cont
exit:
atomic store <old/new x>, <v>
...
Differential Revision: http://reviews.llvm.org/D9049

llvm-svn: 235573
2015-04-23 06:35:10 +00:00
David Majnemer 96183f6b06 [MS ABI] Treat ConstantArrayType like IncompleteArrayType in args
Type backreferences for arguments use the DecayedType's original type.
Because of this, arguments with the same canonical type with the same
mangling would not backreference each other if one was a
ConstantArrayType while the other was an IncompleteArrayType.  Solve
this by canonicalizing the ConstantArrayType to a suitable
IncompleteArrayType.

This fixes PR23325.

llvm-svn: 235572
2015-04-23 05:21:20 +00:00
Richard Smith 447ed43cc1 [modules] Actually allocate the extra space we use for the tail-allocated array
in this class.

llvm-svn: 235570
2015-04-23 04:13:52 +00:00
Alexey Samsonov f624650354 Unify the way we report overflow in increment/decrement operator.
Summary:
Make sure signed overflow in "x--" is checked with
llvm.ssub.with.overflow intrinsic and is reported as:
  "-2147483648 - 1 cannot be represented in type 'int'"
instead of:
  "-2147483648 + -1 cannot be represented in type 'int'"
, like we do for unsigned overflow.

Test Plan: clang + compiler-rt regression test suite

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 235568
2015-04-23 01:50:45 +00:00
Justin Bogner 60d852ba5b InstrProf: Fix a shadowing error that would break length of profile names
We try to use the member variable "FuncName" here, but we've also used
that name as a parameter. This ends with us getting the length of the
function name wrong when we generate the coverage data.

llvm-svn: 235565
2015-04-23 00:31:16 +00:00
Reid Kleckner 7d4bc9c0fb [WinEH] Don't emit an exceptional cleanup for llvm.eh.endcatch
These extra endcatch markers aren't helping identify regions to outline,
so let's get rid of them.  LLVM outlines (more or less) from begincatch
to endcatch.  Any unwind edge from an enclosed invoke is a transition to
a new exception handler, which has it's own outlining markers.

llvm-svn: 235562
2015-04-22 23:39:15 +00:00
Reid Kleckner fca03389bd Fix another test broken by r235537
llvm-svn: 235555
2015-04-22 21:39:55 +00:00
David Majnemer dc012fa266 Revert "Revert r234581, it might have caused a few miscompiles in Chromium."
This reverts commit r234700.  It turns out that the lifetime markers
were not the cause of Chromium failing but a bug which was uncovered by
optimizations exposed by the markers.

llvm-svn: 235553
2015-04-22 21:38:15 +00:00
Reid Kleckner 4b24f17c27 Fix test failure caused by r235537. It does not run on Windows due to REQUIRES: shell
llvm-svn: 235551
2015-04-22 21:14:25 +00:00
Reid Kleckner 787dc438c9 Set normal LLVM function attributes on global initializer functions
Otherwise -fno-omit-frame-pointer and other flags like it aren't
applied.

Basic idea taken from Gao's patch, thanks!

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

llvm-svn: 235537
2015-04-22 19:37:32 +00:00
Aaron Ballman c75a192f23 Silencing a -Wunused-variable warning; NFC.
llvm-svn: 235512
2015-04-22 15:25:05 +00:00
Alexey Bataev 1d67713b44 [OPENMP] Codegen for 'if' clause in 'task' directive.
If condition evaluates to true, the code executes task by calling @__kmpc_omp_task() runtime function.
If condition evaluates to false, the code executes serial version of the code by executing the following code:

call void @__kmpc_omp_task_begin_if0(<loc>, <threadid>, <task_t_ptr, returned by @__kmpc_omp_task_alloc()>);
proxy_task_entry(<gtid>, <task_t_ptr, returned by @__kmpc_omp_task_alloc()>);
call void @__kmpc_omp_task_complete_if0(<loc>, <threadid>, <task_t_ptr, returned by @__kmpc_omp_task_alloc()>);
Also it checks if the condition is constant and if it is constant it evaluates its value and then generates either parallel version of the code (if the condition evaluates to true), or the serial version of the code (if the condition evaluates to false).
Differential Revision: http://reviews.llvm.org/D9143

llvm-svn: 235507
2015-04-22 13:57:31 +00:00
Alexey Bataev 7ebe5fddac [OPENMP] Codegen for 'reduction' clause in 'for' 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.
Differential Revision: http://reviews.llvm.org/D9139

llvm-svn: 235506
2015-04-22 13:43:03 +00:00
Alexey Bataev 50a6458870 [OPENMP] Codegen for 'private' clause in 'for' directive.
This patch generates helper variables which used as a private copies of the corresponding original variables inside an OpenMP 'for' directive. These generated variables are initialized by default (with the default constructor, if any). In OpenMP region references to original variables are replaced by the references to these private helper variables.
Differential Revision: http://reviews.llvm.org/D9106

llvm-svn: 235503
2015-04-22 12:24:45 +00:00
Alexey Bataev 9e4b820484 [OPENMP] Fixed test incompatibility for simd codegen.
llvm-svn: 235501
2015-04-22 12:20:41 +00:00
Alexey Bataev 62dbb979c0 [OPENMP] Fix use of unsigned counters in loops with zero trip count.
Patch fixes bugs in codegen for loops with unsigned counters and zero trip count. Previously preconditions for all loops were built using logic (Upper - Lower) > 0. But if the loop is a loop with zero trip count, then Upper - Lower is < 0 only for signed integer, for unsigned we're running into an underflow situation.
In this patch we're using original Lower<Upper condition to check that loop body can be executed at least once. Also this allows to skip code generation for loops, if it is known that preconditions for the loop are always false.
Differential Revision: http://reviews.llvm.org/D9103

llvm-svn: 235500
2015-04-22 11:59:37 +00:00
Alexey Bataev 98eb6e3d41 [OPENMP] Codegen for 'ordered' directive.
Add codegen for 'ordered' directive:

__kmpc_ordered(ident_t *, gtid);
<associated statement>;
__kmpc_end_ordered(ident_t *, gtid);
Also for 'for' directives with the dynamic scheduling and an 'ordered' clause added a call to '__kmpc_dispatch_fini_(4|8)[u]()' function after increment expression for loop control variable:

while(__kmpc_dispatch_next(&LB, &UB)) {
  idx = LB;
  while (idx <= UB) { BODY; ++idx;
    __kmpc_dispatch_fini_(4|8)[u](); // For ordered loops only.
  } // inner loop
}
Differential Revision: http://reviews.llvm.org/D9070

llvm-svn: 235496
2015-04-22 11:15:40 +00:00
Daniel Jasper ee4a8a140a clang-format: Fix for #pragma option formatting.
Adapted patch from Sergey Razmetov. Thank you.

llvm-svn: 235492
2015-04-22 09:45:42 +00:00
Hans Wennborg 287231cb7a Don't dllimport/export class members with internal linkage (PR23308)
For example, a function taking a parameter with internal linkage will
itself have internal linkage since it cannot be called outside the
translation unit.

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

llvm-svn: 235471
2015-04-22 04:05:17 +00:00
Nico Weber 38267349ee Wrap to 80 columns, fix typo in comment. No behavior change.
llvm-svn: 235470
2015-04-22 03:44:51 +00:00
Richard Smith 5dbef92932 [modules] Cope with partial module macro information, fix memory leak found by buildbot.
llvm-svn: 235464
2015-04-22 02:09:43 +00:00
Richard Smith e56c8bc30e [modules] Build a DAG of module macros for each identifier.
This graph will be used to determine the current set of active macros. This is
foundation work for getting macro visibility correct across submodules of the
current module. No functionality change for now.

llvm-svn: 235461
2015-04-22 00:26:11 +00:00
Hans Wennborg 0260ee1205 Expose -fdiagnostics-parseable-fixits to clang-cl
Patch by Daniel Cheng!

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

llvm-svn: 235456
2015-04-21 23:12:03 +00:00
Artem Belevich 7093e40641 [cuda] Allow using integral non-type template parameters as launch_bounds attribute arguments.
- Changed CUDALaunchBounds arguments from integers to Expr* so they can
   be saved in AST for instantiation.
 - Added support for template instantiation of launch_bounds attrubute.
 - Moved evaluation of launch_bounds arguments to NVPTXTargetCodeGenInfo::
   SetTargetAttributes() where it can be done after template instantiation.
 - Added a warning on negative launch_bounds arguments.
 - Amended test cases.

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

llvm-svn: 235452
2015-04-21 22:55:54 +00:00
Artem Belevich 4e192df778 [cuda] Added support for CUDA built-in variables.
Added cuda_builtin_vars.h which implements built-in CUDA variables
using __declattr(property).

Fields of built-in variables (except for warpSize) are implemented
using __declattr(property) which replaces read/write of a member field
with a call to a getter/setter member function, in this case with
appropriate NVPTX builtin.

Added a test case to check diagnostics on attempt to construct or
improperly access a built-in variable.

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

llvm-svn: 235448
2015-04-21 22:14:13 +00:00
Richard Smith d732939592 [modules] Move list of exported module macros from IdentifierInfo lookup table to separate storage, adjacent to the macro directive history.
This is substantially simpler, provides better space usage accounting in bcanalyzer,
and gives a more compact representation. No functionality change intended.

llvm-svn: 235420
2015-04-21 21:46:32 +00:00
Duncan P. N. Exon Smith 8e47da4f5b DebugInfo: Prepare for removal of DIArray and DITypeArray typedefs
An upcoming LLVM commit will remove the `DIArray` and `DITypeArray`
typedefs that shadow `DebugNodeArray` and `MDTypeRefArray`,
respectively.  Use those types directly.

llvm-svn: 235412
2015-04-21 20:07:29 +00:00
Duncan P. N. Exon Smith dadc2b627d DebugInfo: Prepare for deletion of DIDescriptor subclasses
An upcoming LLVM commit will delete all the remaining subclasses of (the
already deleted) `DIDescriptor`.  Stop using them.

llvm-svn: 235403
2015-04-21 18:43:54 +00:00
Alexey Samsonov ec0bff9262 Recommend to use CMake on the Clang Getting Started page.
llvm-svn: 235402
2015-04-21 18:38:31 +00:00
Artem Belevich a050112bba Revert r235398 "[cuda] Added support for CUDA built-in variables."
r235398 was causing buildbot break due to missing Makefile changes.

llvm-svn: 235401
2015-04-21 18:36:42 +00:00
Artem Belevich d0a2ae054f [cuda] Added support for CUDA built-in variables.
Added cuda_builtin_vars.h which implements built-in CUDA variables
using __declattr(property).

Fields of built-in variables (except for warpSize) are implemented
using __declattr(property) which replaces read/write of a member field
with a call to a getter/setter member function, in this case with
appropriate NVPTX builtin.

Added a test case to check diagnostics on attempt to construct or
improperly access a built-in variable.

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

llvm-svn: 235398
2015-04-21 17:39:06 +00:00
Ulrich Weigand ca3cb7f35c Implement target-specific __attribute__((aligned)) value
The GCC construct __attribute__((aligned)) is defined to set alignment
to "the default alignment for the target architecture" according to
the GCC documentation:

  The default alignment is sufficient for all scalar types, but may not be
  enough for all vector types on a target that supports vector operations.
  The default alignment is fixed for a particular target ABI.

clang currently hard-coded an alignment of 16 bytes for that construct,
which is correct on some platforms (including X86), but wrong on others
(including SystemZ).  Since this value is ABI-relevant, it is important
to get correct for compatibility purposes.

This patch adds a new TargetInfo member "DefaultAlignForAttributeAligned"
that targets can set to the appropriate default __attribute__((aligned))
value.

Note that I'm deliberately *not* using the existing "SuitableAlign"
value, which is used to set the pre-defined macro __BIGGEST_ALIGNMENT__,
since those two values may not be the same on all platforms.  In fact,
on X86, __attribute__((aligned)) always uses 16-byte alignment, while
__BIGGEST_ALIGNMENT__ may be larger if AVX-2 or AVX-512 are supported.
(This is actually not yet correctly implemented in clang either.)

The patch provides a value for DefaultAlignForAttributeAligned only for
SystemZ, and leaves the default for all other targets at 16, which means
no visible change in behavior on all other targets.  (The value is still
wrong for some other targets, but I'd prefer to leave it to the target
maintainers for those platforms to fix.)

llvm-svn: 235397
2015-04-21 17:29:35 +00:00
Ulrich Weigand 4608438386 Provide alignment info on LLVM external symbols
Code in CodeGenModule::GetOrCreateLLVMGlobal that sets up GlobalValue
object for LLVM external symbols has this comment:

    // FIXME: This code is overly simple and should be merged with other global
    // handling.

One part does seems to be "overly simple" currently is that this code
never sets any alignment info on the GlobalValue, so that the emitted
IR does not have any align attribute on external globals.  This can
lead to unnecessarily inefficient code generation.

This patch adds a GV->setAlignment call to set alignment info.

llvm-svn: 235396
2015-04-21 17:27:59 +00:00
Ulrich Weigand b63f779be4 Fix __alignof__ of global variables on SystemZ
SystemZ prefers to align all global variables to two bytes, which is
implemented by setting the TargetInfo member MinGlobalAlign.

However, for compatibility with existing compilers this should *not*
change the ABI alignment value as retrieved via __alignof__, which
it currently does.

This patch fixes the issue by having ASTContext::getDeclAlign ignore
the MinGlobalAlign setting in the ForAlignof case.

Since SystemZ is the only platform setting MinGlobalAlign, this should
cause no change for any other target.

llvm-svn: 235395
2015-04-21 17:26:18 +00:00
Duncan P. N. Exon Smith a7fbcbfe00 DebugInfo: Prepare for deletion of subclasses of DIScope
Prepare for the deletion in LLVM of the subclasses of (the already
deleted) `DIScope` by using the raw pointers they were wrapping
directly.

llvm-svn: 235355
2015-04-20 22:09:57 +00:00
Duncan P. N. Exon Smith c09c548bf9 DebugInfo: Prepare for deletion of subclasses of DIType
Subclasses of (the already deleted) `DIType` will be deleted by an
upcoming LLVM commit.  Remove references.

While `DICompositeType` wraps `MDCompositeTypeBase` and `DIDerivedType`
wraps `MDDerivedTypeBase`, most uses of each really meant the more
specific `MDCompositeType` and `MDDerivedType`.  I updated accordingly.

llvm-svn: 235350
2015-04-20 21:17:26 +00:00
Samuel Benzaquen 025f6b1981 Add conversionDecl matcher for node CXXConversionDecl.
llvm-svn: 235348
2015-04-20 20:58:50 +00:00
Reid Kleckner b9ece24dfc Put statement expression decls in the enclosing code DeclContext
We already check that statement expressions are in a function or block,
but we didn't do anything with that information. Now we use that
DeclContext for the duration of the statement expression. Otherwise,
we'd treat statement expression locals as static data members and go
into the weeds.

llvm-svn: 235335
2015-04-20 20:00:49 +00:00
Duncan P. N. Exon Smith 0b6c369697 DebugInfo: Prepare for deletion of DIType
`DIType` is going to be deleted by an upcoming LLVM commit, so replace
uses with `MDType*`.

llvm-svn: 235330
2015-04-20 18:51:48 +00:00