Commit Graph

2847 Commits

Author SHA1 Message Date
David Blaikie 1a83db4f5e PR21312: Fix a regression in non-type template parameters of function type that are static member functions.
llvm-svn: 220221
2014-10-20 18:56:54 +00:00
David Majnemer 8e133965c8 CodeGen: ConstStructBuilder must verify packed constraints after padding
This reverts commit r220169 which reverted r220153.  However, it also
contains additional changes:
- We may need to add padding *after* we've packed the struct.  This
  occurs when the aligned next field offset is greater than the new
  field's offset.  When this occurs, we make the struct packed.
  *However*, once packed the next field offset might be less than the
  new feild's offset.  It is in this case that we might further pad the
  struct.
- We would pad structs which were perfectly sized!  This behavior is
  immensely old.  This behavior came from blindly subtracting
  NextFieldOffsetInChars from RecordSize.  This doesn't take into
  account the fact that the struct might have a greater overall
  alignment than the last field.

llvm-svn: 220175
2014-10-19 23:40:06 +00:00
David Blaikie b5c7e6a71d PR21305: Typedefs in non-type template parameters in member data pointers.
Patch by Stephen Crane!

llvm-svn: 220122
2014-10-18 02:21:26 +00:00
Hans Wennborg 0b603cc4e9 Move test/CodeGen/sections.c to CodeGenCXX/sections.cpp
The test was running with -xc++. Seems it wants to be a C++ file.

llvm-svn: 220069
2014-10-17 18:13:21 +00:00
David Blaikie d70f3c20b8 DebugInfo: Follow up to r219736, also test/demonstrate that we emit the constant value in this case as well.
llvm-svn: 219943
2014-10-16 18:38:36 +00:00
David Blaikie 0f62c8d8f8 PR21246: DebugInfo: Emit the appropriate type (cv qualifiers, reference-ness, etc) for non-type template parameters
Plumb through the full QualType of the TemplateArgument::Declaration, as
it's insufficient to only know whether the type is a reference or
pointer (that was necessary for mangling, but insufficient for debug
info). This shouldn't increase the size of TemplateArgument as
TemplateArgument::Integer is still longer by another 32 bits.

Several bits of code were testing that the reference-ness of the
parameters matched, but this seemed to be insufficient (various other
features of the type could've mismatched and wouldn't've been caught)
and unnecessary, at least insofar as removing those tests didn't cause
anything to fail.

(Richard - perchaps you can hypothesize why any of these checks might
need to test reference-ness of the parameters (& explain why
reference-ness is part of the mangling - I would've figured that for the
reference-ness to be different, a prior template argument would have to
be different). I'd be happy to add them in/beef them up and add test
cases if there's a reason for them)

llvm-svn: 219900
2014-10-16 04:21:25 +00:00
David Blaikie d59bbd1e91 DebugInfo: Cleanup testing of non-type template parameters.
Separate out the non-nullable parameters from the nullable ones
(currently only the template template parameter) and demonstrate that
cv-qualifiers aren't preserved for non-null parameters (but are
preserved for null parameters) by adding 'const' to an int* non-type
template parameter.

llvm-svn: 219883
2014-10-16 00:41:40 +00:00
Reid Kleckner 72d03bee64 Don't use a global_ctors comdat for globals that aren't externally visible
In particular, if you have two identical templates in different TUs in
anonymous namespaces, we would use the same global_ctors comdat key for
both. As a result, only one would be run.

llvm-svn: 219806
2014-10-15 16:38:00 +00:00
David Majnemer b00ddf31b2 CodeGen: Use the initing member's type for a union's storage type more often
Unions are initialized with the default initialization of their first
named member.  If that member is not zero initialized, then we should
prefer that member's type.  Otherwise, we might try to make an otherwise
unsuitable type (like an array) which we cannot easily initialize with a
pointer to member.

llvm-svn: 219781
2014-10-15 07:57:41 +00:00
David Majnemer 1573d73367 MS ABI: Use the correct this arg when generating implicit array copy ctor
We assumed the last argument of the copy constructor was the this
pointer.  However, this is not the case under the MS ABI.

llvm-svn: 219775
2014-10-15 04:54:54 +00:00
David Blaikie 8e707bb476 DebugInfo: Lazily built static member variable declarations should use the canonical declaration for line/file information.
When lazily constructing static member variable declarations (when
the vtable optimization fires and the definition of the type is omitted
(or built later, lazily), but the out of line definition of the static
member is provided and must be described in debug info) ensure we use
the canonical declaration when computing the file, line, etc for that
declaration (rather than the definition, which is also a declaration,
but not the canonical one).

llvm-svn: 219736
2014-10-14 22:22:17 +00:00
Alexey Samsonov eb47d8a2c8 Sanitize upcasts and conversion to virtual base.
This change adds UBSan check to upcasts. Namely, when we
perform derived-to-base conversion, we:
1) check that the pointer-to-derived has suitable alignment
   and underlying storage, if this pointer is non-null.
2) if vptr-sanitizer is enabled, and we perform conversion to
   virtual base, we check that pointer-to-derived has a matching vptr.

llvm-svn: 219642
2014-10-13 23:59:00 +00:00
Alexey Bataev 4dcead4bc3 PredefinedExpr deserialization test in dependent context.
For commit r219561 - Fix deserialization of PredefinedExpr in dependent context.

llvm-svn: 219594
2014-10-13 03:27:35 +00:00
David Majnemer 571162af6b CodeGen: Strip qualifiers from qualified array types in catches
While we ran getUnqualifiedType over the catch type,
it isn't enough for array types.  Use getUnqualifiedArrayType instead.

This fixes PR21252.

llvm-svn: 219582
2014-10-12 06:58:22 +00:00
David Majnemer d824405011 Make test more robust to appease build bots
llvm-svn: 219526
2014-10-10 19:23:49 +00:00
Alexey Bataev 769562a382 Bugfix for predefined expressions in dependent context.
This bug break compilation with precompiled headers and predefined expressions in dependent context.

llvm-svn: 219525
2014-10-10 18:58:13 +00:00
David Majnemer a586eb2c70 CodeGen: FieldMemcpyizer didn't handle copies starting inside bitfields
It's possible to construct cases where the first field we are trying to
copy is in the middle of an IR field.  In some complicated cases, we
would fail to use an appropriate offset inside the object.  Earlier
builds of clang seemed to miscompile the code by copying an insufficient
number of bytes.  Up until now, we would assert: the copying offset was
insufficiently aligned.

This fixes PR21232.

llvm-svn: 219524
2014-10-10 18:57:10 +00:00
Nick Lewycky 5d1159ebe9 Revert r218865 because it introduced PR21236, a crash in codegen emitting the try block.
llvm-svn: 219470
2014-10-10 04:05:00 +00:00
Alexey Bataev ec4747802a Fix for bug http://llvm.org/PR17427.
Assertion failed: "Computed __func__ length differs from type!"
Reworked PredefinedExpr representation with internal StringLiteral field for function declaration.
Differential Revision: http://reviews.llvm.org/D5365

llvm-svn: 219393
2014-10-09 08:45:04 +00:00
Arnaud A. de Grandmaison e69ec55cda Revert "Remove threshold on object size for inserting lifetime begin / end"
Revert this patch while I investigate some sanitizer failures off-line.

llvm-svn: 219307
2014-10-08 14:04:26 +00:00
Arnaud A. de Grandmaison 1b175e4098 Remove threshold on object size for inserting lifetime begin / end
Boostrapping LLVM+Clang+LLDB without threshold on object size for
lifetime markers insertion has shown there was no significant change
in compile time, so let the stack slot colorizer do its optimization
for all slots.

llvm-svn: 219303
2014-10-08 12:49:16 +00:00
Reid Kleckner 026e874a97 Fix test case in no asserts build
llvm-svn: 219266
2014-10-08 01:13:51 +00:00
Reid Kleckner 453e056467 Fix IRGen for referencing a static local before emitting its decl
Summary:
Previously CodeGen assumed that static locals were emitted before they
could be accessed, which is true for automatic storage duration locals.
However, it is possible to have CodeGen emit a nested function that uses
a static local before emitting the function that defines the static
local, breaking that assumption.

Fix it by creating the static local upon access and ensuring that the
deferred function body gets emitted. We may not be able to emit the
initializer properly from outside the function body, so don't try.

Fixes PR18020.  See also previous attempts to fix static locals in
PR6769 and PR7101.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 219265
2014-10-08 01:07:54 +00:00
Rafael Espindola e04a17da81 Allow dllexport alias to base destructors.
We used to avoid these, but it looks like we did so just because we were
not handling dllexport alias correctly.

Dario Domizioli fixed that, so allow these aliases.

Based on a patch by Dario Domizioli!

llvm-svn: 219206
2014-10-07 13:34:42 +00:00
David Blaikie fd58072675 DebugInfo: Don't include implicit special members in the list of class members
By leaving these members out of the member list, we avoid them being
emitted into type unit definitions - while still allowing the
definition/declaration to be injected into the compile unit as expected.

llvm-svn: 219101
2014-10-06 05:18:55 +00:00
David Blaikie 56cfbe841f DebugInfo: Don't include member function template specializations in the list of class members
By leaving these members out of the member list, we avoid them being
emitted into type unit definitions - while still allowing the
definition/declaration to be injected into the compile unit as expected.

llvm-svn: 219100
2014-10-06 05:06:54 +00:00
David Majnemer 040fa34bec MS ABI: Use '1' (instead of '0') relative scope discriminators
This changes the scope discriminator's behavior to start at '1' instead
of '0'.  Symbol table diffing, for ABI compatibility testing, kept
finding these as false positives.

llvm-svn: 219075
2014-10-05 06:44:53 +00:00
David Majnemer b3341ea453 MS ABI: Implement thread_local for global variables
Summary:
This add support for the C++11 feature, thread_local global variables.
The ABI Clang implements is an improvement of the MSVC ABI.  Sadly,
further improvements could be made but not without sacrificing ABI
compatibility.

The feature is implemented as follows:
- All thread_local initialization routines are pointed to from the
  .CRT$XDU section.
- All non-weak thread_local variables have their initialization routines
  call from a single function instead of getting their own .CRT$XDU
  section entry.  This is done to open up optimization opportunities to
  the compiler.
- All weak thread_local variables have their own .CRT$XDU section entry.
  This entry is in a COMDAT with the global variable it is initializing;
  this ensures that we will initialize the global exactly once.
- Destructors are registered in the initialization function using
  __tlregdtor.

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

llvm-svn: 219074
2014-10-05 05:05:40 +00:00
Duncan P. N. Exon Smith 3c51fa6aae Revert "Revert "DI: LLVM schema change: fold constants into string""
This reverts commit r218917, effectively reapplying r218913.  Original
commit message follows.

--

Update debug info testcases for an LLVM metadata schema change to fold
metadata constant operands into a single `MDString`.

Part of PR17891.

llvm-svn: 219011
2014-10-03 20:01:52 +00:00
David Majnemer 749b68630b MS ABI: Move test from virtual-inheritance to single-inheritance
The test didn't actually use virtual inheritance.

llvm-svn: 218966
2014-10-03 08:03:23 +00:00
David Majnemer 312c8049f2 MS ABI: Add a vftable test for pure virtual methods
llvm-svn: 218965
2014-10-03 07:54:12 +00:00
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
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
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
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
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
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
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
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
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
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
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
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
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
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