Commit Graph

246 Commits

Author SHA1 Message Date
Pete Cooper 3b39e88ae0 Revert "Change memcpy/memset/memmove to have dest and source alignments."
This reverts commit r253512.

This likely broke the bots in:
http://lab.llvm.org:8011/builders/clang-ppc64-elf-linux2/builds/20202
http://bb.pgr.jp/builders/clang-3stage-i686-linux/builds/3787

llvm-svn: 253542
2015-11-19 05:55:59 +00:00
John McCall 00b2bbb7bb Don't actually add the __unsafe_unretained qualifier in MRC;
driving a canonical difference between that and an unqualified
type is a really bad idea when both are valid.  Instead, remember
that it was there in a non-canonical way, then look for that in
the one place we really care about it: block captures.  The net
effect closely resembles the behavior of a decl attribute, except
still closely following ARC's standard qualifier parsing rules.

llvm-svn: 253534
2015-11-19 02:28:03 +00:00
Pete Cooper 7bfd5cb7be Change memcpy/memset/memmove to have dest and source alignments.
This is a follow on from a similar LLVM commit: r253511.

Note, this was reviewed (and more details are in) http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html

These intrinsics currently have an explicit alignment argument which is
required to be a constant integer.  It represents the alignment of the
source and dest, and so must be the minimum of those.

This change allows source and dest to each have their own alignments
by using the alignment attribute on their arguments.  The alignment
argument itself is removed.

The only code change to clang is hidden in CGBuilder.h which now passes
both dest and source alignment to IRBuilder, instead of taking the minimum of
dest and source alignments.

Reviewed by Hal Finkel.

llvm-svn: 253512
2015-11-18 22:18:45 +00:00
John McCall 0204e342ca Correctly handle type mismatches in the __weak copy/move-initialization
peephole I added in r250916.

rdar://23559789

llvm-svn: 253255
2015-11-16 22:11:41 +00:00
Peter Collingbourne 0900fe0f1b CodeGen: Update for debug info API change.
Differential Revision: http://reviews.llvm.org/D14266

llvm-svn: 252220
2015-11-05 22:04:14 +00:00
Akira Hatanaka 44a59f8976 [CodeGen] Attach function attributes to Objective-C and OpenMP
functions.

This commit fixes a bug in CGOpenMPRuntime.cpp and CGObjC.cpp where
some of the function attributes are not attached to newly created
functions.

rdar://problem/20828324

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

llvm-svn: 251476
2015-10-28 02:30:47 +00:00
John McCall 3fd13f0665 Fix and stylize the emission of GC/ARC ivar and GC block layout strings.
Specifically, handle under-aligned object references (by explicitly
ignoring them, because this just isn't representable in the format;
yes, this means that GC silently ignores such references), descend
into anonymous structs and unions, stop classifying fields of
pointer-to-strong/weak type as strong/weak in ARC mode, and emit
skips to cover the entirety of block layouts in GC mode.  As a
cleanup, extract this code into a helper class, avoid a number of
unnecessary copies and layout queries, generate skips implicitly
instead of explicitly tracking them, and clarify the bitmap-creation
logic.

llvm-svn: 250919
2015-10-21 18:06:47 +00:00
John McCall f8a9b66f65 In ARC, peephole the initialization of a __weak variable with
a value loaded from a __weak variable into a call to
objc_copyWeak or objc_moveWeak.

llvm-svn: 250916
2015-10-21 18:06:31 +00:00
Douglas Katzman 3459ce2e5e Stop messing with the 'g' group of options in CompilerInvocation.
With this change, most 'g' options are rejected by CompilerInvocation.
They remain only as Driver options. The new way to request debug info
from cc1 is with "-debug-info-kind={line-tables-only|limited|standalone}"
and "-dwarf-version={2|3|4}". In the absence of a command-line option
to specify Dwarf version, the Toolchain decides it, rather than placing
Toolchain-specific logic in CompilerInvocation.

Also fix a bug in the Windows compatibility argument parsing
in which the "rightmost argument wins" principle failed.

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

llvm-svn: 249655
2015-10-08 04:24:12 +00:00
Sanjoy Das a0bc8590fe Change arc-cxx11-init-list.mm to work with upcoming SCEV changes.
Summary:
The store being checked for in arc-cxx11-init-list.mm is a store to an
unescaped alloca.  After an uncoming change to ScalarEvolution, LLVM is
able to elide the store, so adjust the test accordingly.

Reviewers: compnerd

Subscribers: cfe-commits

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

llvm-svn: 248632
2015-09-25 23:07:11 +00:00
John McCall f0f0b7a0eb Fix a nasty bug with the partial destruction of nested arrays;
it escaped notice because it's only used for heterogeneous
initialization.

rdar://21397946

llvm-svn: 247597
2015-09-14 18:57:08 +00:00
John McCall 9c52b28003 When comparing two block captures for layout, don't crash
if they have the same alignment and one was 'this'.

Fixes PR24780.

llvm-svn: 247482
2015-09-11 22:00:51 +00:00
Nico Weber b833fd982d Let selector-expr-lvalue.mm actually test something.
I accidentally introduced a bug locally, and noticed that none of the tests
caught it. No longer!

llvm-svn: 247477
2015-09-11 21:24:40 +00:00
Vedant Kumar 276d5d9fbc [test] Specify exception object type in two tests
Replace:
    'try { throw 0; } catch (...)'
with
    'try { throw 0; } catch (int e)'

in two test cases.

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

llvm-svn: 247437
2015-09-11 17:39:34 +00:00
Vedant Kumar db609471ce [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst
When uses of personality functions were moved from LandingPadInst to
Function, we forgot to update SimplifyPersonality(). This patch corrects
that.

Note: SimplifyPersonality() is an optimization which replaces
personality functions with the default C++ personality when possible.
Without this update, some ObjC++ projects fail to link against C++
libraries (seeing as the exception ABI had effectively changed).

rdar://problem/22155434

llvm-svn: 247421
2015-09-11 15:40:05 +00:00
John McCall 7f416cc426 Compute and preserve alignment more faithfully in IR-generation.
Introduce an Address type to bundle a pointer value with an
alignment.  Introduce APIs on CGBuilderTy to work with Address
values.  Change core APIs on CGF/CGM to traffic in Address where
appropriate.  Require alignments to be non-zero.  Update a ton
of code to compute and propagate alignment information.

As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
helper function to CGF and made use of it in a number of places in
the expression emitter.

The end result is that we should now be significantly more correct
when performing operations on objects that are locally known to
be under-aligned.  Since alignment is not reliably tracked in the
type system, there are inherent limits to this, but at least we
are no longer confused by standard operations like derived-to-base
conversions and array-to-pointer decay.  I've also fixed a large
number of bugs where we were applying the complete-object alignment
to a pointer instead of the non-virtual alignment, although most of
these were hidden by the very conservative approach we took with
member alignment.

Also, because IRGen now reliably asserts on zero alignments, we
should no longer be subject to an absurd but frustrating recurring
bug where an incomplete type would report a zero alignment and then
we'd naively do a alignmentAtOffset on it and emit code using an
alignment equal to the largest power-of-two factor of the offset.

We should also now be emitting much more aggressive alignment
attributes in the presence of over-alignment.  In particular,
field access now uses alignmentAtOffset instead of min.

Several times in this patch, I had to change the existing
code-generation pattern in order to more effectively use
the Address APIs.  For the most part, this seems to be a strict
improvement, like doing pointer arithmetic with GEPs instead of
ptrtoint.  That said, I've tried very hard to not change semantics,
but it is likely that I've failed in a few places, for which I
apologize.

ABIArgInfo now always carries the assumed alignment of indirect and
indirect byval arguments.  In order to cut down on what was already
a dauntingly large patch, I changed the code to never set align
attributes in the IR on non-byval indirect arguments.  That is,
we still generate code which assumes that indirect arguments have
the given alignment, but we don't express this information to the
backend except where it's semantically required (i.e. on byvals).
This is likely a minor regression for those targets that did provide
this information, but it'll be trivial to add it back in a later
patch.

I partially punted on applying this work to CGBuiltin.  Please
do not add more uses of the CreateDefaultAligned{Load,Store}
APIs; they will be going away eventually.

llvm-svn: 246985
2015-09-08 08:05:57 +00:00
John McCall ee04aebbdb When building a pseudo-object assignment, and the RHS is
a contextually-typed expression that semantic analysis will
probably need to invasively rewrite, don't include the
RHS OVE as a separate semantic expression, and check the
operation with the original RHS expression.

There are two contextually-typed expressions that can survive
to here: overloaded function references, which are at least
safe to double-emit, and C++11 initializer list expressions,
which are not at all safe to double-emit and which often
don't update the original syntactic InitListExpr with
implicit conversions to member types, etc.

This means that the original RHS may appear, undecorated by
an OVE, in the semantic expressions.  Fortunately, it will
only ever be used in a single place there, and I don't
believe there are clients that rely on being able to pick
out the original RHS from the semantic expressions.
But this could be problematic if there are clients that do
visit the entire tree and rely on not seeing the same
expression multiple times, once in the syntactic and once
in the semantic expressions.  This is a very fiddly part
of the compiler.

rdar://21801088

llvm-svn: 245771
2015-08-22 00:35:27 +00:00
Argyrios Kyrtzidis 2705819240 [test] Follow-up for r243343, also add a test case using an enum for designated enum.
llvm-svn: 243355
2015-07-28 00:01:13 +00:00
Argyrios Kyrtzidis 4746c2fcdb [sema] Fix infinite loop when using a boolean value as designated initializer.
For designated indices use the max array size type bitwidth, not the bitwidth of the index value itself.
rdar://21942503

llvm-svn: 243343
2015-07-27 23:16:53 +00:00
Douglas Gregor ab209d83be Implement the Objective-C __kindof type qualifier.
The __kindof type qualifier can be applied to Objective-C object
(pointer) types to indicate id-like behavior, which includes implicit
"downcasting" of __kindof types to subclasses and id-like message-send
behavior. __kindof types provide better type bounds for substitutions
into unspecified generic types, which preserves more type information.

llvm-svn: 241548
2015-07-07 03:58:42 +00:00
David Blaikie ea3e51d73f Account for calling convention specifiers in function definitions in IR test cases
Several tests wouldn't pass when executed on an armv7a_pc_linux triple
due to the non-default arm_aapcs calling convention produced on the
function definitions in the IR output. Account for this with the
application of a little regex.

Patch by Ying Yi.

llvm-svn: 240971
2015-06-29 17:29:50 +00:00
David Majnemer fcbdb6ea58 Update clang to take into account the changes to personality fns
llvm-svn: 239941
2015-06-17 20:53:19 +00:00
Philip Reames c758ca3c5c Adjust clang side tests effected by 239795 before reapplying said change
llvm-svn: 239848
2015-06-16 20:24:06 +00:00
Adrian Prantl c6f91a2081 Debug Info: Turn on ODR type uniquing for (the C++ part of) Objective-C++.
rdar://problem/20571359

llvm-svn: 239781
2015-06-15 23:18:16 +00:00
Sunil Srivastava 3acf6275e6 Changed renaming of local symbols by inserting a dot vefore the numeric suffix
details in http://reviews.llvm.org/D9483
goes with llvm checkin r237150

llvm-svn: 237151
2015-05-12 16:48:43 +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
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
David Blaikie d6c88ece21 [opaque pointer types] Explicit non-pointer type for call expressions
(migration for recent LLVM change to textual IR for calls)

llvm-svn: 235147
2015-04-16 23:25:00 +00:00
Nico Weber 1c565c31b1 Revert r234581, it might have caused a few miscompiles in Chromium.
If the revert helps, I'll get a repro this Monday.  Else I'll put the change
back in.

llvm-svn: 234700
2015-04-11 23:51:38 +00:00
Arnaud A. de Grandmaison 047a686d53 Remove threshold for inserting lifetime markers for named temporaries
Now that TailRecursionElimination has been fixed with r222354, the
threshold on size for lifetime marker insertion can be removed. This
only affects named temporary though, as the patch for unnamed temporaries
is still in progress.

My previous commit (r222993) was not handling debuginfo correctly, but
this could only be seen with some asan tests. Basically, lifetime markers
are just instrumentation for the compiler's usage and should not affect
debug information; however, the cleanup infrastructure was assuming it
contained only destructors, i.e. actual code to be executed, and was
setting the breakpoint for the end of the function to the closing '}', and
not the return statement, in order to show some destructors have been
called when leaving the function. This is wrong when the cleanups are only
lifetime markers, and this is now fixed.

llvm-svn: 234581
2015-04-10 10:13:52 +00:00
Ahmed Bougacha 5a4aa42a59 Add a bunch of missing "CHECK" colons in tests. NFC.
llvm-svn: 232237
2015-03-14 01:10:19 +00:00
David Blaikie bdf40a62a7 Test case updates for explicit type parameter to the gep operator
llvm-svn: 232187
2015-03-13 18:21:46 +00:00
Duncan P. N. Exon Smith f04be1fb3a DebugInfo: Move new hierarchy into place (clang)
Update testcases for LLVM change in r231082 to use the new debug info
hierarchy.

llvm-svn: 231083
2015-03-03 17:25:55 +00:00
David Blaikie a953f2825b Update Clang tests to handle explicitly typed load changes in LLVM.
llvm-svn: 230795
2015-02-27 21:19:58 +00:00
David Blaikie 218b783192 Update Clang tests to handle explicitly typed gep changes in LLVM.
llvm-svn: 230783
2015-02-27 19:18:17 +00:00
Adrian Prantl d268046eef Add a testcase that exercises DIBuilder's handling of cyclic debug info nodes.
rdar://problem/19839612

llvm-svn: 229522
2015-02-17 19:17:56 +00:00
David Blaikie e257034bf0 Remove trailing whitespace to make test compatible with typeless pointer migration
llvm-svn: 229273
2015-02-15 04:12:21 +00:00
David Blaikie 3e160d5e8c Remove trailing whitespace getting in the way of near-future getelementptr change updates
llvm-svn: 229197
2015-02-14 00:28:51 +00:00
Adrian Prantl 39428e74a0 Merge ArtificialLocation into ApplyDebugLocation and make a clear
distinction between the different use-cases. With the previous default
behavior we would occasionally emit empty debug locations in situations
where they actually were strictly required (= on invoke insns).
We now have a choice between defaulting to an empty location or an
artificial location.

Specifically, this fixes a bug caused by a missing debug location when
emitting C++ EH cleanup blocks from within an artificial function, such as
an ObjC destroy helper function.

rdar://problem/19670595

llvm-svn: 228003
2015-02-03 18:40:42 +00:00
Rafael Espindola e5df59ff78 Emit DeferredDeclsToEmit in a DFS order.
Currently we emit DeferredDeclsToEmit in reverse order. This patch changes that.

The advantages of the change are that

* The output order is a bit closer to the source order. The change to
test/CodeGenCXX/pod-member-memcpys.cpp is a good example.

* If we decide to deffer more, it will not cause as large changes in the
estcases as it would without this patch.

llvm-svn: 226751
2015-01-22 00:24:57 +00:00
Duncan P. N. Exon Smith 8d3ef611ce IR: Move MDLocation into place (clang testcases)
Update testcases to match LLVM change in r226048.

llvm-svn: 226049
2015-01-14 22:28:03 +00:00
David Blaikie 47d28e07c1 DebugInof: Correct the location of exception cleanups in global ctors/dtors and ObjC methods
Without setting the CurEHLocation these cleanups would be attributed to
whatever the last active debug line location was (the 'fn' call in the
included test cases). By setting CurEHLocation correctly the line
information is improved/corrected.

This quality bug turned into a crasher with r225000 when, instead of
allowing the last location to persist, it would be zero'd out. This
could lead to a function call (such as the dtor) being made without a
debug location - if that call was subsequently inlined (and the caller
and callee had debug info, just not the call instruction) the inliner
would violate important constraints about the debug location chains by
not updating the inlined instructions to chain up to the callee
locations.

So, by fixing this bug, I am addressing the assertion failures
introduced by r225000 and should be able to recommit that patch with
impunity...

llvm-svn: 225955
2015-01-14 07:10:46 +00:00
David Blaikie 1ae04916cc DebugInfo: Correct the location of EH cleanup for blocks
This was previously piggybacking on whatever happened to be the last
location set on CGDebugInfo/DIBuilder, which was wrong (it was often the
current location, such as the 'fn()' call site, not the end of the
block). With my improvements to set/unset the location in a scoped
manner (r225000) this went from a bad quality situation, to a crash.
Fixing this goes part-way to unblocking the recommit of r225000.

It's likely that any call to CodeGenFunction::StartFunction without the
CurEHLocation set represents a similar bug or risk of a bug. Perhaps
there are some callers that know they won't generate EH cleanups, but
I'm not sure.

I considered a generic catch-fix in StartFunction (just fallback to the
GlobalDecl's location) but that seemed like it'd mask bugs where the EH
location shouldn't be the same as the decl's location (& indeed by not
using that stop-gap I found this bug). We'll see how long I can hold out
on the generic catch-all. I might eventually be able to add an assertion
in.

llvm-svn: 225845
2015-01-13 23:06:27 +00:00
Eric Christopher 0e2618857c Have the driver and the target code agree on what the default ABI
is for each machine. Fix up darwin tests that were testing for
aapcs on armv7-ios when the actual ABI is apcs.

Should be no user visible change without -cc1.

llvm-svn: 223429
2014-12-05 01:06:59 +00:00
Arnaud A. de Grandmaison f3470cc979 Revert "Remove threshold for lifetime marker insertion of named temporaries"
Revert r222993 while I investigate some MemorySanitizer failures.

llvm-svn: 222995
2014-12-01 09:30:16 +00:00
Arnaud A. de Grandmaison f2730e2d22 Remove threshold for lifetime marker insertion of named temporaries
Now that TailRecursionElimination has been fixed with r222354, the
threshold on size for lifetime marker insertion can be removed. This
only affects named temporary though, as the patch for unnamed temporaries
is still in progress.

llvm-svn: 222993
2014-12-01 09:13:54 +00:00
David Majnemer eea02eefe7 AST: Consider pseudo-struct builtin types as substitutable
We didn't consider types like ObjCSel as a substitution candidate.

This fixes PR21688.

llvm-svn: 222941
2014-11-28 22:22:46 +00:00
Chandler Carruth cc75b75b9d Update Clang tests that run the LLVM optimizer to reflect the changed
canonicalization in r222748. No interesting functionality changed here.

llvm-svn: 222749
2014-11-25 10:10:37 +00:00
Fariborz Jahanian ef7c578d3c Fixes test.
llvm-svn: 221843
2014-11-13 00:19:30 +00:00
Fariborz Jahanian 800821a3b2 [Objective-C++ IRGen] do not generate .cxx_construct
for class that contains trivially-constructible struct ivar.
rdar://18950072

llvm-svn: 221823
2014-11-12 22:37:43 +00:00