Commit Graph

6771 Commits

Author SHA1 Message Date
Eli Friedman eecc09a99c Don't use mangleCXXRTTIName in TBAA for C code.
This changes the TBAA code so it doesn't use mangleCXXRTTIName in C,
because it doesn't really make sense there.  Also, as sort of a
defense-in-depth change, fix the mangler so it handles C RecordDecls
correctly.

No tests because I don't know the TBAA code well enough to write a test,
and I don't know how else to trigger mangling a local struct in C.

Fixes a crash with r185450 reported by Joerg Sonnenberger.

llvm-svn: 185721
2013-07-05 20:27:40 +00:00
Craig Topper 5603df45df Use SmallVectorImpl& for function arguments instead of SmallVector.
llvm-svn: 185715
2013-07-05 19:34:19 +00:00
Eli Bendersky 9b64ec18c1 Add target hook CodeGen queries when generating builtin pow*.
Without fmath-errno, Clang currently generates calls to @llvm.pow.* intrinsics
when it sees pow*(). This may not be suitable for all targets (for
example le32/PNaCl), so the attached patch adds a target hook that CodeGen
queries. The target can state its preference for having or not having the
intrinsic generated. Non-PNaCl behavior remains unchanged;
PNaCl-specific test added.

llvm-svn: 185568
2013-07-03 19:19:12 +00:00
Manman Ren 0d441f1853 Debug Info: clean up usage of Verify.
No functionality change. It should suffice to check the type of a debug info
metadata, instead of calling Verify.

llvm-svn: 185463
2013-07-02 19:01:53 +00:00
Eli Friedman c48d31c31c Simplify linkage code for static local vars.
The key insight here is that weak linkage for a static local variable
should always mean linkonce_odr, because every file that needs it will
generate a definition.  We don't actually care about the precise linkage
of the parent context.  I feel a bit silly that I didn't realize this before.

llvm-svn: 185381
2013-07-01 20:53:07 +00:00
Eli Friedman 7e346a8127 Fix mangling for block literals.
Blocks, like lambdas, can be written in contexts which are required to be
treated as the same under ODR.  Unlike lambdas, it isn't possible to actually
take the address of a block, so the mangling of the block itself doesn't
matter. However, objects like static variables inside a block do need to
be mangled in a consistent way.

There are basically three components here. One, block literals need a
consistent numbering.  Two, objects/types inside a block literal need
to be mangled using it.  Three, objects/types inside a block literal need
to have their linkage computed correctly.

llvm-svn: 185372
2013-07-01 20:22:57 +00:00
Stephen Lin 9dc6eef755 Restore r184205 and associated commits (after commit of r185290)
This allows clang to use the backend parameter attribute 'returned' when generating 'this'-returning constructors and destructors in ARM and MSVC C++ ABIs.

llvm-svn: 185291
2013-06-30 20:40:16 +00:00
Eli Friedman ba2778f4ba Remove dead code.
llvm-svn: 185231
2013-06-28 22:13:27 +00:00
Peter Collingbourne 66f82e68c3 [ms-cxxabi] Move CodeGenVTables::needsVTTParameter to ItaniumCXXABI.
This function only makes sense there.  Eventually it should no longer
be part of the CGCXXABI interface, as it is an Itanium-specific detail.

Differential Revision: http://llvm-reviews.chandlerc.com/D821

llvm-svn: 185213
2013-06-28 20:45:28 +00:00
Eli Friedman c7ad5c4e29 Delete dead code.
llvm-svn: 185119
2013-06-28 00:23:34 +00:00
Peter Collingbourne 5c5e6179a0 Use the zero-argument DIBuilder::createNullPtrType in Clang.
Differential Revision: http://llvm-reviews.chandlerc.com/D1051

llvm-svn: 185115
2013-06-27 22:51:01 +00:00
John McCall 611d9b6659 Ensure that debugger calls to signature-less functions default to
passing arguments in the fixed style.

We have an abstraction for deciding this, but it's (1) deep in
IR-generation, (2) necessarily tied to exact argument lists, and
(3) triggered by unprototyped function types, which we can't
legitimately make in C++ mode.  So this solution, wherein Sema
rewrites the function type to an exact prototype but leaves the
variadic bit enabled so as to request x86-64-like platforms to
pass the extra variadic info, is very much a hack, but it's one
that works in practice on the platforms that LLDB will support
in the medium term --- the only place we know of where it's a
problem is instance methods in Windows, where variadic functions
are implicitly cdecl.  We may have a more abstracted base on which
to build a solution by then.

rdar://13731520

llvm-svn: 185112
2013-06-27 22:43:24 +00:00
Eli Friedman 2782dacfbc Rewrite record layout for ms_struct structs.
The old implementation of ms_struct in RecordLayoutBuilder was a
complete mess: it depended on complicated conditionals which didn't
really reflect the underlying logic, and placed a burden on users of
the resulting RecordLayout. This commit rips out almost all of the
old code, and replaces it with simple checks in
RecordLayoutBuilder::LayoutBitField.

This commit also fixes <rdar://problem/14252115>, a bug where class
inheritance would cause us to lay out bitfields incorrectly.

llvm-svn: 185018
2013-06-26 20:50:34 +00:00
Eli Bendersky 099888eccd Remove misplaced comment
llvm-svn: 184862
2013-06-25 17:07:56 +00:00
Nick Lewycky d3f3e4f04c Make -vectorize-... proper cc1 flags instead of abusing -backend-option. Fixes
usage of clang as a library.

llvm-svn: 184812
2013-06-25 01:49:44 +00:00
Reid Kleckner 8a36502a60 [AST] Introduce a new DecayedType sugar node
The goal of this sugar node is to be able to look at an arbitrary
FunctionType and tell if any of the parameters were decayed from an
array or function type.  Ultimately this is necessary to implement
Microsoft's C++ name mangling scheme, which mangles decayed arrays
differently from normal pointers.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1014

llvm-svn: 184763
2013-06-24 17:51:48 +00:00
David Blaikie ce1ae387d6 DebugInfo: ensure negative enumerators are emitted as such
There's still a problem here - since we're not appropriately using the
signedness/range of the enum to chooset the encoding and emission of
enumerators, but GCC has some bugs around this too so I assume that's
not /such/ a high priority though I may get to it soon out of
completeness.

llvm-svn: 184695
2013-06-24 07:13:13 +00:00
David Blaikie 47c1150f50 DebugInfo: Support (using GNU extensions) for template template parameters and parameter packs
llvm-svn: 184644
2013-06-22 18:59:18 +00:00
David Blaikie 18cfbc53ee DebugInfo: Random tidying up/simplification
No functionality change intended.

llvm-svn: 184614
2013-06-22 00:09:36 +00:00
Tim Northover 1711cc930b Teach ARM va_arg to ignore empty structs.
Empty structs are ignored for parameter passing purposes, but va_arg was
incrementing the pointer anyway which could lead to va_list getting out of
sync.

llvm-svn: 184605
2013-06-21 23:05:33 +00:00
Tim Northover 1060eae78e Check for trivial constructibility before emptiness in ARM ABI.
According to the Itanium ABI (3.1.1), types with non-trivial copy constructors
passed by value should be passed indirectly, with the caller creating a
temporary.

We got this mostly correct, but forgot that empty structs can have non-trivial
constructors too and passed them incorrectly. This simply reverses the order of
the check.

llvm-svn: 184603
2013-06-21 22:49:34 +00:00
Nick Lewycky 92a6c74bbf Fix a leak of TargetMachine in clang. We'll continue to leak it on purpose if
given -disable-free. (Reviewed by John McCall over IRC.)

llvm-svn: 184595
2013-06-21 21:15:32 +00:00
David Blaikie 940ca4d462 PR16214: Debug info for types first used via pointers or qualified types & later require definitions
llvm-svn: 184594
2013-06-21 21:03:11 +00:00
Reid Kleckner 23f4c4b64f [ms-cxxabi] Destroy temporary record arguments in the callee
Itanium destroys them in the caller at the end of the full expression,
but MSVC destroys them in the callee.  This is further complicated by
the need to emit EH-only destructor cleanups in the caller.

This should help clang compile MSVC's debug iterators more correctly.
There is still an outstanding issue in PR5064 of a memcpy emitted by the
LLVM backend, which is not correct for C++ records.

Fixes PR16226.

Reviewers: rjmccall

Differential Revision: http://llvm-reviews.chandlerc.com/D929

llvm-svn: 184543
2013-06-21 12:45:15 +00:00
David Blaikie f7bcb0c279 Fix all the silly things I committed in r184509
llvm-svn: 184512
2013-06-21 00:59:44 +00:00
David Blaikie b8f2fbbe97 Alternative fix for r184473.
This just seems a bit tidier/more principled. Based on a patch provided
by Adrian - with the only minor tweak that it needed to use
"getTypeOrNull" rather than "getCompletedTypeOrNull" since we don't
store declarations in the CompletedTypes cache.

No intended functionality change.

llvm-svn: 184509
2013-06-21 00:40:50 +00:00
Michael Gottesman 930ecdb77b [checked-arithmetic builtins] Added builtins to enable users to perform checked-arithmetic in c.
This will enable users in security critical applications to perform
checked-arithmetic in a fast safe manner that is amenable to c.

Tests/an update to Language Extensions is included as well.

rdar://13421498.

llvm-svn: 184497
2013-06-20 23:28:10 +00:00
Richard Smith 2f7aa19026 Fix typo in comment. Patch by Matthew Dempsky!
llvm-svn: 184495
2013-06-20 23:03:35 +00:00
John McCall c84e4e9b1c Call __cxa_begin_catch before std::terminate() in a noexcept trap.
r174939-40 caused us to do this in the canonical terminate lpad,
but when the EH stack has other cleanups on it we use the
terminate handler block, which wasn't doing this.

Fixes the rest of rdar://11904428 given appropriate stdlib support.

llvm-svn: 184475
2013-06-20 21:37:43 +00:00
Adrian Prantl dba725c0be Debug Info: Attempt to resolve forward declarations if we are not emitting
limited debug info.

This is another small addendum to r184252.

rdar://problem/14101097

llvm-svn: 184473
2013-06-20 21:17:24 +00:00
Meador Inge f081d02586 CodeGen: Don't set 'PMBuilder.DisableSimplifyLibCalls'
The simplify-libcalls pass has been removed from LLVM.  Thus
'PMBuilder.DisableSimplifyLibCalls' does not exist anymore.
The disabling/enabling of library call simplifications is
done through the TargetLibraryInfo which is already wired
up in Clang.

llvm-svn: 184458
2013-06-20 19:47:18 +00:00
Stephen Lin 19cee1871e Revert r184205 and associated patches while investigating issue with broken buildbot (possible interaction with LTO)
<rdar://problem/14209661>

llvm-svn: 184384
2013-06-19 23:23:19 +00:00
David Blaikie b9c667d808 Debug Info: PR14763/r183329 - specify that non-trivial pass-by-value parameters are stored indirectly
This is to fix the location information for such parameters to refer to
the object accessible through the pointer rather than to the pointer
parameter itself.

llvm-svn: 184367
2013-06-19 21:53:53 +00:00
Stephen Lin c467c873e6 Corrections to r184205 ('this'-return optimization) due to the wrong version of the patch being committed originally.
1) Removed useless return value of CGCXXABI::EmitConstructorCall and CGCXXABI::EmitVirtualDestructorCall and implementations
2) Corrected last portion of CodeGenCXX/constructor-destructor-return-this to correctly test for non-'this'-return of virtual destructor calls

llvm-svn: 184330
2013-06-19 18:10:35 +00:00
Reid Kleckner d29f1342c2 [CodeGen] Move EHScopeStack into its own header
CGCleanup.h isn't meant to be included by all of CodeGen according to
John.

llvm-svn: 184321
2013-06-19 17:07:50 +00:00
Reid Kleckner 7810af0a43 [ms-cxxabi] Emit and install appropriately mangled vbtables
In Itanium, dynamic classes have one vtable with several different
address points for dynamic base classes that can't share vtables.

In the MS C++ ABI, each vbtable that can't be shared gets its own
symbol, similar to how ctor vtables work in Itanium.  However, instead
of mangling the subobject offset into the symbol, the unique portions of
the inheritance path are mangled into the symbol to make it unique.

This patch implements the MSVC 2012 scheme for forming unique vbtable
symbol names.  MSVC 2010 use the same mangling with a different subset
of the path.  Implementing that mangling and possibly others is TODO.

Each vbtable is an array of i32 offsets from the vbptr that points to it
to another virtual base subobject.  The first entry of a vbtable always
points to the base of the current subobject, implying that it is the
same no matter which parent class contains it.

Reviewers: rjmccall

Differential Revision: http://llvm-reviews.chandlerc.com/D636

llvm-svn: 184309
2013-06-19 15:20:38 +00:00
NAKAMURA Takumi 9157b55c3c Fix a warning. [-Wunused-variable]
llvm-svn: 184284
2013-06-19 06:58:20 +00:00
Manman Ren 9691f7fa35 Debug Info: support for gdwarf-2 gdwarf-3 gdwarf-4
These options will add a module flag with name "Dwarf Version".
The behavior flag is currently set to Warning, so when two values disagree,
a warning will be emitted.

llvm-svn: 184276
2013-06-19 01:46:49 +00:00
Adrian Prantl 1f56b2a4f1 Add some comments to r184252.
rdar://problem/14101097

llvm-svn: 184259
2013-06-18 23:32:21 +00:00
Adrian Prantl c1a3fe7f9b Emit forward decls for structs with declarations only when we are
limiting debug info.

FIXME: There is still work left to do here, the testcase should work even with -flimit-debug-info.

rdar://problem/14101097

llvm-svn: 184252
2013-06-18 23:01:56 +00:00
Michael Gottesman 1534399059 [multiprecision-builtins] Added missing builtin __builtin_{add,sub}cb for {add,sub} with carry for bytes.
I have had several people ask me about why this builtin was not available in
clang (since it seems like a logical conclusion). This patch implements said
builtins.

Relevant tests are included as well. I also updated the Clang language extension reference.

rdar://14192664.

llvm-svn: 184227
2013-06-18 20:40:40 +00:00
Stephen Lin a637fb8ccd CodeGen: Have 'this'-returning constructors and destructors to take advantage of the new backend 'returned' attribute.
The backend will now use the generic 'returned' attribute to form tail calls where possible, as well as avoid save-restores of 'this' in some cases (specifically the cases that matter for the ARM C++ ABI).

This patch also reverts a prior front-end only partial implementation of these optimizations, since it's no longer required.

llvm-svn: 184205
2013-06-18 17:00:49 +00:00
John McCall 1fe2a8c87e Add support for -fpcc-struct-return. Patch by Arthur O'Dwyer!
llvm-svn: 184166
2013-06-18 02:46:29 +00:00
Adrian Prantl de5fde0b05 Remove an ugly hack that was meant to eliminate the breakpoint ambiguity
between a block assignment and the entry of the block function. In reality
this wouldn't work anyway because blocks are predominantly created
on-the-fly inside of an ObjC method invocation.
The proper fix for the ambiguity is to use -gcolumn-info to differentiate
the breakpoints.

This is expected to break some block-related darwin-gdb tests.

rdar://problem/14039866

llvm-svn: 184157
2013-06-18 00:27:36 +00:00
Eli Friedman 40a4becb11 Compute the visibility of static local variables consistently. Fixes PR16208.
llvm-svn: 184137
2013-06-17 21:51:45 +00:00
Rafael Espindola a418418f63 Cleanup linkage computation for static locals.
With this patch we assign VisibleNoLinkage to static locals in inline functions.
This lets us simplify CodeGen a bit.

llvm-svn: 184114
2013-06-17 20:04:51 +00:00
Richard Smith a509f2fdfa Emit initializers for static-storage-duration temporaries as constants where
possible.

llvm-svn: 183967
2013-06-14 03:07:01 +00:00
Eli Friedman d4b6e7a9b7 Fix the linkage of static locals inside a CapturedStmt. (Found in the
process of trying to fix the related issue for block literals.)

llvm-svn: 183951
2013-06-13 21:50:44 +00:00
Richard Smith a1c9d4d932 Simplify: we don't need any special-case lifetime extension when initializing
declarations of reference type; they're handled by the general case handling of
MaterializeTemporaryExpr.

llvm-svn: 183875
2013-06-12 23:38:09 +00:00
Richard Smith cc1b96d356 PR12086, PR15117
Introduce CXXStdInitializerListExpr node, representing the implicit
construction of a std::initializer_list<T> object from its underlying array.
The AST representation of such an expression goes from an InitListExpr with a
flag set, to a CXXStdInitializerListExpr containing a MaterializeTemporaryExpr
containing an InitListExpr (possibly wrapped in a CXXBindTemporaryExpr).

This more detailed representation has several advantages, the most important of
which is that the new MaterializeTemporaryExpr allows us to directly model
lifetime extension of the underlying temporary array. Using that, this patch
*drastically* simplifies the IR generation of this construct, provides IR
generation support for nested global initializer_list objects, fixes several
bugs where the destructors for the underlying array would accidentally not get
invoked, and provides constant expression evaluation support for
std::initializer_list objects.

llvm-svn: 183872
2013-06-12 22:31:48 +00:00