Commit Graph

23403 Commits

Author SHA1 Message Date
David Majnemer 22718651af MS ABI: Clean up test to not use dllexport, check vftable entries
llvm-svn: 218964
2014-10-03 07:48:27 +00:00
David Majnemer ba7f49a23d MS ABI: Add an additional test for empty structs in C
Empty structs in C differ from those in C++.
- C++ requires that empty types have size 1; alignment requirements may
  increase the size of the struct.
- The C implementation doesn't let empty structs have a size under 4
  bytes.  Again, alignment requirements may increase the struct's size.

Add a test to stress these differences.

llvm-svn: 218963
2014-10-03 07:41:09 +00:00
Hal Finkel 189c699cad Make test/CodeGen/atomic-ops.c free-standing
This test includes stdint.h (via stdatomic.h), which might include system
headers (and that might not work, depending on the system configuration).
Attempting to fix llvm-clang-lld-x86_64-debian-fast.

llvm-svn: 218960
2014-10-03 05:04:49 +00:00
Hal Finkel 16c54d7186 Make test/Sema/atomic-ops.c free-standing
This test includes stdint.h, which might include system headers (and that might
not work, depending on the system configuration). Attempting to fix
llvm-clang-lld-x86_64-debian-fast.

llvm-svn: 218959
2014-10-03 04:46:48 +00:00
Hal Finkel 6970ac8b0a Add an implementation of C11's stdatomic.h
Adds a Clang-specific implementation of C11's stdatomic.h header. On systems,
such as FreeBSD, where a stdatomic.h header is already provided, we defer to
that header instead (using our __has_include_next technology). Otherwise, we
provide an implementation in terms of our __c11_atomic_* intrinsics (that were
created for this purpose).

C11 7.1.4p1 requires function declarations for atomic_thread_fence,
atomic_signal_fence, atomic_flag_test_and_set,
atomic_flag_test_and_set_explicit, and atomic_flag_clear, and requires that
they have external linkage. Accordingly, we provide these declarations, but if
a user elides the shadowing macros and uses them, then they must have a libc
(or similar) that actually provides definitions.

atomic_flag is implemented using _Bool as the underlying type. This is
consistent with the implementation provided by FreeBSD and also GCC 4.9 (at
least when __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1).

Patch by Richard Smith (rebased and slightly edited by me -- Richard said I
should drive at this point).

llvm-svn: 218957
2014-10-03 04:29:40 +00:00
Richard Smith ef99e4d88a Fix interaction of max_align_t and modules.
When building with modules enabled, we were defining max_align_t as a typedef
for a different anonymous struct type each time it was included, resulting in
an error if <stddef.h> is not covered by a module map and is included more than
once in the same modules-enabled compilation of C11 or C++11 code.

llvm-svn: 218931
2014-10-03 00:31:35 +00:00
Fariborz Jahanian b91c5d6a79 Patch to warn if 'override' is missing
for an overriding method if class has at least one
'override' specified on one of its methods.
Reviewed by Doug Gregor. rdar://18295240
(I have already checked in all llvm files with missing 'override'
 methods and Bob Wilson has fixed a TableGen of FastISel so
 no warnings are expected from build of llvm after this patch.
 I have already verified this). 

llvm-svn: 218925
2014-10-02 23:13:51 +00:00
Duncan P. N. Exon Smith 834c265e85 Revert "DI: LLVM schema change: fold constants into string"
This reverts commit r218913 while I investigate some bots.

llvm-svn: 218917
2014-10-02 22:15:09 +00:00
Duncan P. N. Exon Smith 02b418a875 DI: LLVM schema change: fold constants into string
Update debug info testcases for an LLVM metadata schema change to fold
metadata constant operands into a single `MDString`.

Part of PR17891.

llvm-svn: 218913
2014-10-02 21:56:07 +00:00
Hal Finkel 1b0d24e03a Initial support for the align_value attribute
This adds support for the align_value attribute. This attribute is supported by
Intel's compiler (versions 14.0+), and several of my HPC users have requested
support in Clang. It specifies an alignment assumption on the values to which a
pointer points, and is used by numerical libraries to encourage efficient
generation of vector code.

Of course, we already have an aligned attribute that can specify enhanced
alignment for a type, so why is this additional attribute important? The
problem is that if you want to specify that an input array of T is, say,
64-byte aligned, you could try this:

  typedef double aligned_double attribute((aligned(64)));
  void foo(aligned_double *P) {
    double x = P[0]; // This is fine.
    double y = P[1]; // What alignment did those doubles have again?
  }

the access here to P[1] causes problems. P was specified as a pointer to type
aligned_double, and any object of type aligned_double must be 64-byte aligned.
But if P[0] is 64-byte aligned, then P[1] cannot be, and this access causes
undefined behavior. Getting round this problem requires a lot of awkward
casting and hand-unrolling of loops, all of which is bad.

With the align_value attribute, we can accomplish what we'd like in a well
defined way:

  typedef double *aligned_double_ptr attribute((align_value(64)));
  void foo(aligned_double_ptr P) {
    double x = P[0]; // This is fine.
    double y = P[1]; // This is fine too.
  }

This attribute does not create a new type (and so it not part of the type
system), and so will only "propagate" through templates, auto, etc. by
optimizer deduction after inlining. This seems consistent with Intel's
implementation (thanks to Alexey for confirming the various Intel-compiler
behaviors).

As a final note, I would have chosen to call this aligned_value, not
align_value, for better naming consistency with the aligned attribute, but I
think it would be more useful to users to adopt Intel's name.

llvm-svn: 218910
2014-10-02 21:21:25 +00:00
Hal Finkel d2208b59cf Add __sync_fetch_and_nand (again)
Prior to GCC 4.4, __sync_fetch_and_nand was implemented as:

  { tmp = *ptr; *ptr = ~tmp & value; return tmp; }

but this was changed in GCC 4.4 to be:

  { tmp = *ptr; *ptr = ~(tmp & value); return tmp; }

in response to this change, support for sync_fetch_and_nand (and
sync_nand_and_fetch) was removed in r99522 in order to avoid miscompiling code
depending on the old semantics. However, at this point:

  1. Many years have passed, and the amount of code relying on the old
     semantics is likely smaller.

  2. Through the work of many contributors, all LLVM backends have been updated
     such that "atomicrmw nand" provides the newer GCC 4.4+ semantics (this process
     was complete July of 2014 (added to the release notes in r212635).

  3. The lack of this intrinsic is now a needless impediment to porting codes
     from GCC to Clang (I've now seen several examples of this).

It is true, however, that we still set GNUC_MINOR to 2 (corresponding to GCC
4.2). To compensate for this, and to address the original concern regarding
code relying on the old semantics, I've added a warning that specifically
details the fact that the semantics have changed and that we provide the newer
semantics.

Fixes PR8842.

llvm-svn: 218905
2014-10-02 20:53:50 +00:00
Fariborz Jahanian ce72e63d11 Diagnose mixed use of '_' and '.' as version
separators in my previous patch. 

llvm-svn: 218895
2014-10-02 17:57:26 +00:00
Jan Wen Voung 01c21e8f45 [x32/NaCl] Check if method pointers straddle an eightbyte to classify Hi
Summary:
Currently, with struct my_struct { int x; method_ptr y; };
a call to foo(my_struct s) may end up dropping the last 4 bytes
of the method pointer for x86_64 NaCl and x32.

When checking Has64BitPointers, also check if the method pointer
straddles an eightbyte boundary and classify Hi as well as Lo if needed.

Test Plan: test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp

Reviewers: dschuff, pavel.v.chupin

Subscribers: jfb

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

llvm-svn: 218889
2014-10-02 16:56:57 +00:00
Fariborz Jahanian dbc956d3f6 Patch to accept '_' in addition to '.' as version
number separator in "availability" attribute.
rdar://18490958

llvm-svn: 218884
2014-10-02 16:39:45 +00:00
Arnaud A. de Grandmaison 42d314d1ba Emit lifetime.start / lifetime.end markers for unnamed temporary objects.
This will give more information to the optimizers so that they can reuse stack slots
and reduce stack usage.

llvm-svn: 218865
2014-10-02 12:19:51 +00:00
Asiri Rathnayake 4ae7f2e839 Fix a broken test case.
Summary: Commit r218863 broke this test case. This patch fixes it
by updating the expected output line. Should've been updated with
the original patch but for some reason it didn't fail during my
local make check.

Change-Id: I89ed28b37f67c34d1a5d28a3e47ae33d9a82a98f
llvm-svn: 218864
2014-10-02 10:45:58 +00:00
Asiri Rathnayake fcd41ce5ae [ARM] Handle conflicts between -mfpu and -mfloat-abi options.
Summary: This patch implements warnings/downgradable errors for
invalid -mfpu, -mfloat-abi option combinations (e.g. -mfpu=none
-mfloat-abi=hard).

Change-Id: I94fa664e1bc0b5855ad835abd7a50a3e0395632d
llvm-svn: 218863
2014-10-02 09:56:07 +00:00
David Blaikie e50bd2b21c Reduce the PR20399 test case.
I couldn't get something /really/ obvious, and I imagine Richard Smith
might be able to provide some text explaining the sequence of steps
that's demonstrated by these files - but at least it's a bit simpler
now.

llvm-svn: 218840
2014-10-01 23:16:30 +00:00
Fariborz Jahanian 56b11ca8a5 Test case for my r218780 patch.
Suggested by Richard Smith.
rdar://18508589.

llvm-svn: 218830
2014-10-01 21:33:22 +00:00
Fariborz Jahanian 77a835bf56 Objective-C Modernizer. Patch to remove dangling space
before the semicolon wahen modernizing to use 
NS_ENUM/NS_OPTIONS macros. rdar://18498539

llvm-svn: 218809
2014-10-01 20:46:32 +00:00
Adrian Prantl 2706eb031d Update CGDebugInfo to the updated API in LLVM.
Complex address expressions are no longer part of DIVariable, but
rather an extra argument to the debug intrinsics.

http://reviews.llvm.org/D4919
rdar://problem/17994491

llvm-svn: 218788
2014-10-01 18:55:34 +00:00
Adrian Prantl af11fdba0a Reverting r218777 while investigating buildbot breakage.
"Update CGDebugInfo to the updated API in LLVM."

llvm-svn: 218781
2014-10-01 18:10:14 +00:00
Adrian Prantl 1400aaf8c8 Update CGDebugInfo to the updated API in LLVM.
Complex address expressions are no longer part of DIVariable, but
rather an extra argument to the debug intrinsics.

http://reviews.llvm.org/D4919
rdar://problem/17994491

llvm-svn: 218777
2014-10-01 17:55:09 +00:00
Oliver Stannard bfd3ea32b7 [ARM] Add support for Cortex-M7, FPv5-SP and FPv5-DP
The Cortex-M7 has 3 options for its FPU: none, FPv5-SP-D16 and
FPv5-DP-D16. FPv5 has the same instructions as FP-ARMv8, so it can be
modeled using the same target feature, and all double-precision
operations are already disabled by the fp-only-sp target features.

llvm-svn: 218748
2014-10-01 09:03:02 +00:00
Alexander Musman a5f070aec0 [OPENMP] Loop collapsing and codegen for 'omp simd' directive.
This patch implements collapsing of the loops (in particular, in
presense of clause 'collapse'). It calculates number of iterations N
and expressions nesessary to calculate the nested loops counters
values based on new iteration variable (that goes from 0 to N-1)
in Sema. It also adds Codegen for 'omp simd', which uses
(and tests) this feature.

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

llvm-svn: 218743
2014-10-01 06:03:56 +00:00
Richard Trieu 2d779b984c Improve -Wuninitialized warnings for fields that are record types.
Get the record handling code from SelfReferenceChecker into
UninitializedFieldVisitor as well as copying the testcases.

llvm-svn: 218740
2014-10-01 03:44:58 +00:00
Justin Bogner f59329b083 InstrProf: Avoid repeated linear searches in a hot path
When generating coverage regions, we were doing a linear search
through the existing regions in order to try to merge related ones.
Most of the time this would find what it was looking for in a small
number of steps and it wasn't a big deal, but in cases with many
regions and few mergeable ones this leads to an absurd compile time
regression.

This changes the coverage mapping logic to do a single sort and then
merge as we go, which is a bit simpler and about 100 times faster.
I've also added FIXMEs on a couple of behaviours that seem a little
suspect, while keeping them behaving as they were - I'll look into
these soon.

The test changes here are mostly tedious reorganization, because the
ordering of regions we output has become slightly (but not completely)
more consistent from the almost completely arbitrary ordering we got
before.

llvm-svn: 218738
2014-10-01 03:33:52 +00:00
Richard Trieu 438903d1b2 Update uninitialized tests to ensure that field initialization has the
same coverage as the global checker.

llvm-svn: 218720
2014-09-30 23:46:05 +00:00
Richard Smith ffb650856d Enable both C and C++ modules with -fmodules, by switching -fcxx-modules to
being on by default. -fno-cxx-modules can still be used to enable C modules but
not C++ modules, but C++ modules is not significantly less stable than C
modules any more.

Also remove some of the scare words from the modules documentation. We're
certainly not going to remove modules support (though we might change the
interface), and it works well enough to bootstrap and build lots of
non-trivial code.

Note that this does not represent a commitment to the current interface nor
implementation, and we still intend to follow whatever direction the C and C++
committees take regarding modules support.

llvm-svn: 218717
2014-09-30 23:10:19 +00:00
Richard Trieu 9f8509f70d Update -Wuninitialized to be stricter on CK_NoOp casts.
llvm-svn: 218715
2014-09-30 23:04:37 +00:00
Ben Langmuir c28ce3aba6 Avoid a crash after loading an #undef'd macro in code completion
In code-completion, don't assume there is a MacroInfo for everything,
since we aren't serializing the def corresponding to a later #undef in
the same module.  Also setup the HadMacro bit correctly for undefs to
avoid an assertion failure.

rdar://18416901

llvm-svn: 218694
2014-09-30 20:00:18 +00:00
Eli Bendersky f2787a0dc0 CUDA: mark the target of implicit intrinsics properly
r218624 implemented target inference for implicit special members. However,
other entities can be implicit - for example intrinsics. These can not have
inference running on them, so they should be marked host device as before. This
is the safest and most flexible setting, since by construction these functions
don't invoke anything, and we'd like them to be invokable from both host and
device code. LLVM's intrinsics definitions (where these intrinsics come from in
the case of CUDA/NVPTX) have no notion of target, so both host and device
intrinsics can be supported this way.

llvm-svn: 218688
2014-09-30 17:38:34 +00:00
Job Noorman ac95cd5c22 Make sure aggregates are properly alligned on MSP430.
llvm-svn: 218666
2014-09-30 11:19:13 +00:00
David Majnemer 00a061dccc MS ABI: Correct layout for empty records
Empty records do not always have size equivalent to their alignment.
They only do so when their alignment is at least as large as the minimum
empty struct size: 1 byte in C++ and 4 bytes in C.

llvm-svn: 218661
2014-09-30 06:45:43 +00:00
Alexander Musman 09184fedc0 [OPENMP] Codegen of the ‘aligned’ clause for the ‘omp simd’ directive.
Differential Revision: http://reviews.llvm.org/D5499

llvm-svn: 218660
2014-09-30 05:29:28 +00:00
Richard Smith e9a8bc3b69 PR20399: Do not assert when adding an implicit member coming from a module at
writing time.

Patch by Vassil Vassilev!

llvm-svn: 218651
2014-09-30 00:45:29 +00:00
NAKAMURA Takumi 8c27a52eb8 clang/test/CodeGenCXX/vararg-non-pod-ms-compat.cpp: Appease -Asserts to skip 1st alloca.
llvm-svn: 218647
2014-09-29 23:55:58 +00:00
Hans Wennborg e4c1892ece Try to fix non-asserts CodeGenCXX/vararg-non-pod-ms-compat.cpp
There are two GEP's in the function, and it seems the X64 CHECK
was matching the wrong one.

llvm-svn: 218645
2014-09-29 23:45:00 +00:00
Hans Wennborg d9dd4d29b7 Don't trap when passing non-POD arguments to variadic functions in MS-compatibility mode
Clang warns (treated as error by default, but still ignored in system headers)
when passing non-POD arguments to variadic functions, and generates a trap
instruction to crash the program if that code is ever run.

Unfortunately, MSVC happily generates code for such calls without a warning,
and there is code in system headers that use it.

This makes Clang not insert the trap instruction when in -fms-compatibility
mode, while still generating the warning/error message.

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

llvm-svn: 218640
2014-09-29 23:06:57 +00:00
Eli Bendersky 9a220fca4a CUDA: Fix incorrect target inference for implicit members.
As PR20495 demonstrates, Clang currenlty infers the CUDA target (host/device,
etc) for implicit members (constructors, etc.) incorrectly. This causes errors
and even assertions in Clang when compiling code (assertions in C++11 mode where
implicit move constructors are added into the mix).

Fix the problem by inferring the target from the methods the implicit member
should call (depending on its base classes and fields).

llvm-svn: 218624
2014-09-29 20:38:29 +00:00
Fariborz Jahanian b417b8f71f Objective-C [qoi] - provide group name for
warn_property_types_are_incompatible. rdar://18487506

llvm-svn: 218621
2014-09-29 20:17:04 +00:00
Alexey Bataev 5bd6879439 Fix bug 20116 - http://llvm.org/bugs/show_bug.cgi?id=20116
Fixes incorrect codegen when devirtualization is aborted due to covariant return types.

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

llvm-svn: 218602
2014-09-29 10:32:21 +00:00
Richard Smith 31563ef090 Tests for DR600-640.
llvm-svn: 218591
2014-09-29 06:03:56 +00:00
Richard Smith 04b35e9beb Fix "unsupported friend" diagnostic to also appear for friend functions with dependent scopes.
llvm-svn: 218590
2014-09-29 05:57:29 +00:00
Nikola Smiljanic 2f32527b36 Add the tests for __super that I forgot to commit in as part of r218484.
llvm-svn: 218587
2014-09-29 01:11:55 +00:00
Richard Smith 09c0778059 Run DR tests in C++17 mode too.
llvm-svn: 218580
2014-09-28 21:56:04 +00:00
David Majnemer bb51300970 CodeGen: Don't crash when initializing pointer-to-member fields in bases
Clang uses two types to talk about a C++ class, the
NonVirtualBaseLLVMType and the LLVMType.  Previously, we would allow one
of these to be packed and the other not.

This is problematic.  If both don't agree on a common subset of fields,
then routines like getLLVMFieldNo will point to the wrong field.  Solve
this by copying the 'packed'-ness of the complete type to the
non-virtual subobject.  For this to work, we need to take into account
the non-virtual subobject's size and alignment when we are computing the
layout of the complete object.

This fixes PR21089.

llvm-svn: 218577
2014-09-28 06:39:30 +00:00
Richard Trieu 779c6f2573 Add back checking for condition of conditional operator for -Wuninitialized
llvm-svn: 218556
2014-09-26 23:48:30 +00:00
Alexey Samsonov 58ae9ae23a Don't link in sanitizer runtimes if -nostdlib/-nodefaultlibs is provided.
It makes no sense to link in sanitizer runtimes in this case: the user
probably doesn't want to see any system/toolchain libs in his link if he
provides these flags, and the link will most likely fail anyway - as sanitizer
runtimes depend on libpthread, libdl, libc etc.

Also, see discussion in https://code.google.com/p/address-sanitizer/issues/detail?id=344

llvm-svn: 218541
2014-09-26 21:22:08 +00:00
Ben Langmuir 11eab6120d Fix an assertion failure trying to emit a trivial destructor in ObjC++
If a base class declares a destructor, we will add the implicit
destructor for the subclass in
ActOnFields -> AddImplicitlyDeclaredMembersToClass

But in Objective C++, we did not compute whether we have a trivial
destructor until after that in
CXXRecordDecl::completeDefinition()

This was leading to a mismatch between the class, which thought it had
no trivial destructor, and the CXXDestructorDecl, which considered
itself trivial. It turns out the reason we delayed setting this until
completeDefinition() was for a warning that has since been removed as
part of -Warc-abi, so we just do it eagerly now.

llvm-svn: 218520
2014-09-26 15:27:29 +00:00
NAKAMURA Takumi 6ed6ef7ac2 clang/test/CodeGen/builtin-assume-aligned.c: Fix for -Asserts.
llvm-svn: 218507
2014-09-26 09:37:15 +00:00
Alexander Musman f94c318ea0 Small fix for bug 18635.
(clang crashed in CodeGen in llvm::Module::getNamedValue on
 thread_local std::unique_ptr<int>).
Differential Revision: http://reviews.llvm.org/D5353

llvm-svn: 218503
2014-09-26 06:28:25 +00:00
Hal Finkel ee90a223ea Support the assume_aligned function attribute
In addition to __builtin_assume_aligned, GCC also supports an assume_aligned
attribute which specifies the alignment (and optional offset) of a function's
return value. Here we implement support for the assume_aligned attribute by making
use of the @llvm.assume intrinsic.

llvm-svn: 218500
2014-09-26 05:04:30 +00:00
Jan Vesely b4379f9c2c CGBuiltin: Use frem instruction rather than libcall to implement fmod
AFAICT the semantics of frem match libm's fmod.

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 218488
2014-09-26 01:19:41 +00:00
Eli Bendersky 291a57e2c2 Fix PR20886 - enforce CUDA target match in method calls
http://reviews.llvm.org/D5298

llvm-svn: 218482
2014-09-25 23:59:08 +00:00
Ismail Pazarbasi 129c44c753 Suggest fix-it for missing '{' after base-clause
llvm-svn: 218468
2014-09-25 21:13:02 +00:00
Ben Langmuir 2f8e6b87ef Move calls to ResolveExceptionSpec out of SetDeclDefaulted and into DefineImplicit*
This fixes an assertion failure in CodeGen where we were not resolving
an exception specification.

llvm-svn: 218466
2014-09-25 20:55:00 +00:00
Richard Trieu 52b8b60d4c Add increment/decrement operators and compound assignment operators to the
uninitialized checkers that did not have them before.

llvm-svn: 218435
2014-09-25 01:15:40 +00:00
Richard Smith 5b57167285 Fix handling of preincrement on bit-fields. This gives a bit-field in C++, but
we were failing to find that bit-field when performing integer promotions. This
brings us closer to following the standard, and closer to GCC.

In C, this change is technically a regression: we get bit-field promotions
completely wrong in C, promoting cases that are categorically not bit-field
designators. This change makes us do so slightly more consistently, though.

llvm-svn: 218428
2014-09-24 23:55:00 +00:00
Scott Douglass df914d55eb pass environment when invoking llvm-config and clang from lit.cfg
Use the same environment when invoking llvm-config from lit.cfg as
will be used when running tests, so that ASAN_OPTIONS, INCLUDE, etc.
are present.

llvm-svn: 218404
2014-09-24 18:37:52 +00:00
Nico Weber 8f63ae1d4c Simplify tests.
This reverts bits of r218166 that are no longer necessary now that r218394 made
-Wmissing-prototype-for-cc a regular warning.

llvm-svn: 218400
2014-09-24 18:25:54 +00:00
Reid Kleckner 2e0717e129 Downgrade error about stdcall decls with no prototype to a warning
Fixes PR21027.  The MIDL compiler produces code that does this.

If we wanted to improve the warning, I think we could do this:
  void __stdcall f(); // Don't warn without -Wstrict-prototypes.
  void g() {
    f(); // Might warn, the user probably meant for f to take no args.
    f(1, 2, 3); // Warn, we have no idea what args f takes.
    f(1); // Error, this is insane, one of these calls is broken.
  }

Reviewers: thakis

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

llvm-svn: 218394
2014-09-24 17:49:24 +00:00
Fariborz Jahanian 945a08d7cd Patch to allow mangling of microsoft’s __uuidof expression for the Itanium ABI
when under -fms-extensions. Reviewed by John McCall.
//rdar://17784718

llvm-svn: 218384
2014-09-24 16:28:40 +00:00
David Majnemer ac0b30e6cb Sema: Inherit the flexible array property from struct fields
A record which contains a flexible array member is itself a flexible
array member.  A struct which contains such a record should also
consider itself to be a flexible array member.

llvm-svn: 218378
2014-09-24 11:04:09 +00:00
Robert Khasanov ea13042cf2 [x86] Fixed argument types in intrinsics:
_addcarryx_u64
_addcarry_u64
_subborrow_u64

Thanks Pasi Parviainen for notice.

llvm-svn: 218376
2014-09-24 06:45:23 +00:00
Steven Wu 566c14eccd Fix the argument index error of __builtin___memccpy_chk
memccpy_check should have source and dest size at arg 3 and 4
rdar://18431336

llvm-svn: 218367
2014-09-24 04:37:33 +00:00
Richard Trieu 78dd725cde Fix an edge case with BinaryOperator's in -Wuninitialized. Add testcases for
the other visitors as well.

llvm-svn: 218366
2014-09-24 03:53:56 +00:00
Nico Weber b10c92001c Follow-up to r218292: Add more REVERTIBLE_TYPE_TRAITs.
r218292 reverted r197496 because it broke things. In addition to breaking
things, r197496 also made all traits starting with __is_ revertible.
Reinstantiate that part of r197496 because code out there (e.g. libc++) depends
on this behavior. Fixes PR21045.

llvm-svn: 218365
2014-09-24 03:28:54 +00:00
David Majnemer c2e6753958 MS ABI: Pure virtual functions don't contribute to vtordisps
Usually, overriding a virtual function defined in a virtual base
required emission of a vtordisp slot in the record.  However no vtordisp
is needed if the overriding function is pure; it should be impossible to
observe the pure virtual method.

This fixes PR21046.

llvm-svn: 218340
2014-09-23 22:58:15 +00:00
Richard Trieu e396ba6bb0 Improve -Wuninitialized to take into account field ordering with initializer
lists.  Since the fields are inititalized one at a time, using a field with
lower index to initialize a higher indexed field should not be warned on.

llvm-svn: 218339
2014-09-23 22:52:42 +00:00
Richard Smith bdf54a21b5 PR18793: If we try to EnterTokenStream when our current lexer is a caching
lexer, add the token buffer underneath the caching lexer where possible and
push the tokens directly into the caching lexer otherwise. We previously
put the lexer into a corrupted state where we could not guarantee to provide
the tokens in the right order and would sometimes assert.

llvm-svn: 218333
2014-09-23 21:05:52 +00:00
Richard Smith 0daabd7ebe Don't perform ADL when looking up operator=; there is no non-member form of
that function, and apart from being slow, this is unnecessary: ADL can trigger
instantiations that are not permitted here. The standard isn't *completely*
clear here, but this seems like the intent, and in any case this approach is
permitted by [temp.inst]p7.

llvm-svn: 218330
2014-09-23 20:31:39 +00:00
Reid Kleckner 739aa12b79 Revert "Don't use comdats for initializers on platforms that don't support it"
On further investigation, COMDATs should work with .ctors, and the issue
I was hitting probably reproduces with .init_array.

This reverts commit r218287.

llvm-svn: 218313
2014-09-23 16:20:01 +00:00
Alexander Musman e4e893bb36 [OPENMP] Parsing/Sema of directive omp parallel for simd
llvm-svn: 218299
2014-09-23 09:33:00 +00:00
Daniel Sanders caf534ef96 [mips] Fix r218248's testcase to use -O1 instead of -O3.
llvm-svn: 218298
2014-09-23 08:58:04 +00:00
David Majnemer 9c775c7fe3 AST: Mangle cast expression encoding more accurately
Don't mangle all casts in expressions as "cv", use the appropriate
encoding which corresponds to a specific cast.

This fixes PR21034.

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

llvm-svn: 218293
2014-09-23 04:27:55 +00:00
Nico Weber 7c3c5bec07 Revert r197496, as it broke REVERTIBLE_TYPE_TRAITs from PCH files.
Also add a test to make sure that this doesn't break again. Fixes PR21036.

llvm-svn: 218292
2014-09-23 04:09:56 +00:00
Hans Wennborg 38277f79bb Attempt to fix Sema/builtin-object-size.c after r218258
The type of size_t varies between targets.

llvm-svn: 218288
2014-09-23 00:02:36 +00:00
Reid Kleckner 6c03130542 Don't use comdats for initializers on platforms that don't support it
In particular, pre-.init_array ELF uses the .ctors section mechanism.
MinGW COFF also uses .ctors, now that I think about it. Therefore,
restrict this optimization to the two platforms that are currently known
to work: ELF with .init_array and COFF with .CRT$XCU.

llvm-svn: 218287
2014-09-23 00:00:14 +00:00
Reid Kleckner 15fdcf19ba Fix a vftable mangling bug
We need to walk the class hierarchy twice: once in depth-first base
specifier order for mangling and again in depth-first layout order for
vftable layout.

Vftable layout seems to depend on the full path from the most derived
class to the base containing the vfptr.

Fixes PR21031.

llvm-svn: 218285
2014-09-22 23:14:46 +00:00
Ehsan Akhgari 3e2db26efc ms-inline-asm: Add a test case for the usage of labels in bracket expressions
Summary: This is a test for this patch: http://reviews.llvm.org/D5445.

Reviewers: rnk

Subscribers: cfe-commits

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

llvm-svn: 218271
2014-09-22 20:41:39 +00:00
Kaelyn Takata a1e18cc5b9 Fix test/CodeGen/mips-varargs.c to use %clang_cc1
Only tests under test/Driver should use %clang, and test/CodeGen in
particular must always use %clang_cc1.

llvm-svn: 218260
2014-09-22 18:06:01 +00:00
Fariborz Jahanian a3d8879be7 Fix evatuated value of __builtin_object_size according to its
'type'  argument when it cannot be determined which objects ptr 
points to at compile time. rdar://18334276

llvm-svn: 218258
2014-09-22 17:11:59 +00:00
NAKAMURA Takumi 22a0fd416c clang/test/CodeGen/mips-varargs.c: Fixup for -Asserts.
llvm-svn: 218256
2014-09-22 16:40:05 +00:00
Daniel Sanders 8d36a61f52 [mips] Correct alignment of vectors passed in varargs for the O32 ABI.
Summary:
Vectors are normally 16-byte aligned, however the O32 ABI enforces a
maximum alignment of 8-bytes since the base of the stack is 8-byte aligned.
Previously, this was enforced on the caller side, but not on the callee side.

This fixes the output of OpenCL's printf when given vectors.

Reviewers: atanasyan

Reviewed By: atanasyan

Subscribers: llvm-commits, pekka.jaaskelainen

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

llvm-svn: 218248
2014-09-22 13:27:06 +00:00
Alexey Bataev 3a3bf0bbe3 [OPENMP] Codegen for 'omp critical' directive.
This patch adds codegen for constructs:
#pragma omp critical [name]
<body>

It generates global variable ".gomp_critical_user_[name].var" of type int32[8]. Then it generates library call "kmpc_critical(loc, gtid, .gomp_critical_user_[name].var)", code for <body> statement and final call "kmpc_end_critical(loc, gtid, .gomp_critical_user_[name].var)".
Differential Revision: http://reviews.llvm.org/D5202

llvm-svn: 218239
2014-09-22 10:01:53 +00:00
Ehsan Akhgari 31097581aa ms-inline-asm: Scope inline asm labels to functions
Summary:
This fixes PR20023.  In order to implement this scoping rule, we piggy
back on the existing LabelDecl machinery, by creating LabelDecl's that
will carry the "internal" name of the inline assembly label, which we
will rewrite the asm label to.

Reviewers: rnk

Subscribers: cfe-commits

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

llvm-svn: 218230
2014-09-22 02:21:54 +00:00
Akira Hatanaka 416efb5f90 Fix bugs in cpuid.h.
This commit makes two changes:

- Remove the push and pop instructions that were saving and restoring %ebx
  before and after cpuid in 32-bit pic mode. We were doing this to ensure we
  don't lose the GOT address in pic register %ebx, but this isn't necessary
  because the GOT address is kept in a virtual register.

- In 64-bit mode, preserve base register %rbx around cpuid.

This fixes PR20311 and rdar://problem/17686779.

llvm-svn: 218173
2014-09-20 01:31:09 +00:00
Nico Weber d191063c6c Follow-up to r214408: Warn on other callee-cleanup functions without prototype too.
According to lore, we used to verifier-fail on:

  void __thiscall f();
  int main() { f(1); }

So that's fixed now. System headers use prototype-less __stdcall functions,
so make that a warning that's DefaultError -- then it fires on regular code
but is suppressed in system headers.

Since it's used in system headers, we have codegen tests for this; massage
them slightly so that they still compile.

llvm-svn: 218166
2014-09-19 23:07:12 +00:00
Dario Domizioli c4fb8ca7aa Fix ctor/dtor aliases losing 'dllexport' (for Itanium ABI)
This patch makes sure that the dllexport attribute is transferred to the alias when such alias is created. It only affects the Itanium ABI because for the MSVC ABI a workaround is in place to not generate aliases of dllexport ctors/dtors.
A new CodeGenModule function is provided, CodeGenModule::setAliasAttributes, to factor the code for transferring attributes to aliases.

llvm-svn: 218159
2014-09-19 22:06:24 +00:00
Rafael Espindola 2ae4b631fc In the Itanium ABI, move stuff to the comdat of variables with static init.
Clang can already handle

-------------------------------------------
struct S {
  static const int x;
};
template<typename T> struct U {
  static const int k;
};
template<typename T> const int U<T>::k = T::x;

const int S::x = 42;
extern const int *f();
const int *g() { return &U<S>::k; }
int main() {
  return *f() + U<S>::k;
}

const int *f() { return &U<S>::k; }
-------------------------------------------

since r217264 which puts the .inint_array section in the same COMDAT
as the variable.

This patch allows the linker to more easily delete some dead code and data by
putting the guard variable and init function in the same COMDAT.

This is a fixed version of r218089.

llvm-svn: 218141
2014-09-19 19:43:18 +00:00
Robert Khasanov 2c589bcc5e [x86] Add _addcarry_u{32|64} and _subborrow_u{32|64}.
They are added to adxintrin.h but outside __ADX__ block.
These intrinics generates adc and sbb correspondingly that were available before ADX
            

llvm-svn: 218118
2014-09-19 10:29:22 +00:00
Robert Khasanov 83c419b349 [x86] Added _addcarryx_u32, _addcarryx_u64 intrinsics
llvm-svn: 218117
2014-09-19 10:17:06 +00:00
Robert Khasanov 50e6f58b4f [x86] Enable broadwell target in clang.
Added -madx option

llvm-svn: 218116
2014-09-19 09:53:48 +00:00
Alexey Bataev 0bd520b767 [OPENMP] Initial parsing/sema analysis of 'target' directive.
llvm-svn: 218110
2014-09-19 08:19:49 +00:00
Rafael Espindola 9f834735cd Don't use the third field of llvm.global_ctors for MachO.
The field is defined as:

If the third field is present, non-null, and points to a global variable or function, the initializer function will only run if the associated data from the current module is not discarded.

And without COMDATs we can't implement that.

llvm-svn: 218097
2014-09-19 01:54:22 +00:00
Rafael Espindola 5b6fa2f85a Revert "Put more stuff in the comdat used for variables with static init."
This reverts commit r218089.
It looks like it was causing issues on COFF.

llvm-svn: 218094
2014-09-19 01:28:16 +00:00
Rafael Espindola c0ce9eca0b Put more stuff in the comdat used for variables with static init.
Clang can already handle

-------------------------------------------
struct S {
  static const int x;
};
template<typename T> struct U {
  static const int k;
};
template<typename T> const int U<T>::k = T::x;

const int S::x = 42;
extern const int *f();
const int *g() { return &U<S>::k; }
int main() {
  return *f() + U<S>::k;
}

const int *f() { return &U<S>::k; }
-------------------------------------------

since r217264 which puts the .inint_array section in the same COMDAT
as the variable.

This patch allows the linker to more easily delete some dead code and data by
putting the guard variable and init function in the same COMDAT.

llvm-svn: 218089
2014-09-18 23:41:44 +00:00
DeLesley Hutchins c60dc2cfb9 Thread Safety Analysis: add new warning flag, -Wthread-safety-reference, which
warns when a guarded variable is passed by reference as a function argument.
This is released as a separate warning flag, because it could potentially
break existing code that uses thread safety analysis.

llvm-svn: 218087
2014-09-18 23:02:26 +00:00
David Majnemer 9928106536 MS ABI: Don't ICE for pointers to pointers to members of incomplete classes
CodeGen would try to come up with an LLVM IR type for a pointer to
member type on the way to forming an LLVM IR type for a pointer to
pointer to member type.

However, if the pointer to member representation has not been locked in yet,
we would not be able to come up with a pointer to member IR type.

In these cases, make the pointer to member type an incomplete type.
This will make the pointer to pointer to member type a pointer to an
incomplete type.  If the class eventually obtains an inheritance model,
we will make the pointer to member type represent the actual inheritance
model.

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

llvm-svn: 218084
2014-09-18 22:05:54 +00:00