Commit Graph

126 Commits

Author SHA1 Message Date
James Y Knight 9871db064d [opaque pointer types] Pass function types for runtime function calls.
Emit{Nounwind,}RuntimeCall{,OrInvoke} have been modified to take a
FunctionCallee as an argument, and CreateRuntimeFunction has been
modified to return a FunctionCallee. All callers have been updated.

Additionally, CreateBuiltinFunction is removed, as it was redundant
with CreateRuntimeFunction after some previous changes.

Differential Revision: https://reviews.llvm.org/D57668

llvm-svn: 353184
2019-02-05 16:42:33 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Akira Hatanaka 2ec36f08a6 [CodeGen] Merge identical block descriptor global variables.
Currently, clang generates a new block descriptor global variable for
each new block literal. This commit merges block descriptors that are
identical inside and across translation units using the same approach
taken in r339438.

To enable merging identical block descriptors, the size and signature of
the block and information about the captures are encoded into the name
of the block descriptor variable. Also, the block descriptor variable is
marked as linkonce_odr and unnamed_addr.

rdar://problem/42640703

Differential Revision: https://reviews.llvm.org/D50783

llvm-svn: 340041
2018-08-17 15:46:07 +00:00
David Chisnall 93ce018f3d Add Windows support for the GNUstep Objective-C ABI V2.
Summary:
Introduces funclet-based unwinding for Objective-C and fixes an issue
where global blocks can't have their isa pointers initialised on
Windows.

After discussion with Dustin, this changes the name mangling of
Objective-C types to prevent a C++ catch statement of type struct X*
from catching an Objective-C object of type X*.

Reviewers: rjmccall, DHowett-MSFT

Reviewed By: rjmccall, DHowett-MSFT

Subscribers: mgrang, mstorsjo, smeenai, cfe-commits

Differential Revision: https://reviews.llvm.org/D50144

llvm-svn: 339428
2018-08-10 12:53:13 +00:00
Fangrui Song 6907ce2f8f Remove trailing space
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h}

llvm-svn: 338291
2018-07-30 19:24:48 +00:00
John McCall dba63a7e5c Clean up CGObjCMac's APIs for deriving class references. NFC.
llvm-svn: 288295
2016-11-30 23:54:50 +00:00
Benjamin Kramer 0772c42385 Reduce the number of implicit StringRef->std::string conversions by threading StringRef through more APIs.
No functionality change intended.

llvm-svn: 260815
2016-02-13 13:42:54 +00:00
Vedant Kumar 2f5bb1150d Reapply "[CodeGen] Fix assignments of inline layouts into the byref structure"
When using blocks, a byref structure is created to represent the
closure. The "byref.layout" field of this structure is an i8*. However,
some 'inline' layouts are represented as i64's, not i8*'s.

Prior to r246985 we cast the i64 'inline' layout to an i8* before
assigning it into the byref structure. This patch brings the cast back
and adds a regression test.

The original version of this patch was too invasive. This version only adds the
cast to BuildByrefLayout.

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

rdar://23713871

llvm-svn: 256190
2015-12-21 20:21:15 +00:00
Vedant Kumar 3ed0df070e Revert "[CodeGen] Fix assignments of inline layouts into the byref structure"
This reverts commit r256185. It breaks CodeGenObjC/fragile-arc.m.

llvm-svn: 256186
2015-12-21 19:43:25 +00:00
Vedant Kumar eb37ec87e4 [CodeGen] Fix assignments of inline layouts into the byref structure
When using blocks, a byref structure is created to represent the
closure. The "byref.layout" field of this structure is an i8*. However,
some 'inline' layouts are represented as i64's, not i8*'s.

Prior to r246985 we cast the i64 'inline' layout to an i8* before
assigning it into the byref structure. This patch brings the cast back
and adds a regression test.

rdar://23713871

llvm-svn: 256185
2015-12-21 19:30:37 +00:00
John McCall 17f0275d4c Initialize @catch variables correctly in fragile-runtime ARC.
llvm-svn: 251677
2015-10-30 00:56:02 +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
Alexander Kornienko ab9db51042 Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
llvm-svn: 240353
2015-06-22 23:07:51 +00:00
Alexander Kornienko 3d9d929e42 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

  $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
      -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
      work/llvm/tools/clang

To reduce churn, not touching namespaces spanning less than 10 lines.

llvm-svn: 240270
2015-06-22 09:47:44 +00:00
Benjamin Kramer 2f5db8b3db Header guard canonicalization, clang part.
Modifications made by clang-tidy with minor tweaks.

llvm-svn: 215557
2014-08-13 16:25:19 +00:00
Craig Topper 8a13c4180e [C++11] Use 'nullptr'. CodeGen edition.
llvm-svn: 209272
2014-05-21 05:09:00 +00:00
Rafael Espindola 554256ca56 Refactor linkage computation in CGObjCMac.cpp.
Before this patch the globals were created with the wrong linkage and patched
afterwards. From the comments it looks like something would complain about
having an internal GV with no initializer. At least in clang the verifier will
only run way after we set the initializer, so that is not a problem.

This patch should be a nop. It just figures out the linkage earlier and
converts the old calls to setLinkage to asserts. The only case where that is
not possible is when we first see a weak import that is then implemented. In
that case we have to change the linkage, but that is the only setLinkage left.

llvm-svn: 202305
2014-02-26 22:25:45 +00:00
John McCall 882987f30c Use the actual ABI-determined C calling convention for runtime
calls and declarations.

LLVM has a default CC determined by the target triple.  This is
not always the actual default CC for the ABI we've been asked to
target, and so we sometimes find ourselves annotating all user
functions with an explicit calling convention.  Since these
calling conventions usually agree for the simple set of argument
types passed to most runtime functions, using the LLVM-default CC
in principle has no effect.  However, the LLVM optimizer goes
into histrionics if it sees this kind of formal CC mismatch,
since it has no concept of CC compatibility.  Therefore, if this
module happens to define the "runtime" function, or got LTO'ed
with such a definition, we can miscompile;  so it's quite
important to get this right.

Defining runtime functions locally is quite common in embedded
applications.

llvm-svn: 176286
2013-02-28 19:01:20 +00:00
Fariborz Jahanian 1eab052a7f objectiveC++: When throwing c++ exception of
an objectiveC object, use objc_exception_throw
to raise the exception. // rdar://12605907

llvm-svn: 172091
2013-01-10 19:02:56 +00:00
David Chisnall 0d75e0600b Reapply r170344, this time without forgetting to commit the header changes.
llvm-svn: 170354
2012-12-17 18:54:24 +00:00
Benjamin Kramer beea120d6e Revert "Added support for new property helpers (GNUstep runtime)."
This reverts commit r170344. Doesn't even compile.

llvm-svn: 170351
2012-12-17 18:02:43 +00:00
David Chisnall e99bc83fa5 Added support for new property helpers (GNUstep runtime).
llvm-svn: 170344
2012-12-17 15:59:29 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Fariborz Jahanian a9d4464baf objective-C blocks: Provide layout map for byref
variables captured in a block. // rdar://12184410

llvm-svn: 167931
2012-11-14 17:15:51 +00:00
Eli Friedman 8593748ed5 Put something sane in the DWARF offset field for bitfield ObjC ivars.
This is useful because unnamed bitfields can have effects on the
offsets which are not otherwise reflected in the DWARF information.

<rdar://problem/12629719>

llvm-svn: 167503
2012-11-06 23:40:48 +00:00
Eli Friedman 8cbca20a59 Back out 167431+167437+167487; I didn't realize how incomplete our test
coverage of this code is.

llvm-svn: 167495
2012-11-06 22:15:52 +00:00
Eli Friedman 5a56bb83cc Propagate CharUnits into ObjC CodeGen. No intended functional change.
llvm-svn: 167431
2012-11-06 01:51:20 +00:00
Fariborz Jahanian 0c58ce9346 objective-C arc/mrr: Patch for the new block variable layout meta-data.
It is currently off (so no tests). This is wip.

llvm-svn: 166892
2012-10-27 21:10:38 +00:00
James Dennett be30245442 Documentation cleanup:
* Escaped Objective-C @keywords in Doxygen comments;
* Documented more accurate \params;
* Exposed some more summaries using \brief.

llvm-svn: 158559
2012-06-15 22:10:14 +00:00
James Dennett 1355bd17c6 Documentation cleanup, fixing Doxygen markup. Mostly this avoids common terms
such as "protocol" and "expression" being implicitly turned into links to
mistakenly-generated Doxygen pages:
- Escaping @ symbols when Doxygen would otherwise incorrectly interpret them;
- Escaping # symbols when they're not intended as explicit Doxygen link 
  requests, such as when discussing preprocessor directives;
- In one odd case, unescaping @ in @__experimental_modules_import, because
  Doxygen wrote '\@' to the output in that case, causing the example in the
  description of ImportDecl to be wrong; and
- Fixing a typo: @breif -> @brief.

llvm-svn: 158299
2012-06-11 06:19:40 +00:00
Ted Kremenek e65b086e07 Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,
NSNumber, and boolean literals.  This includes both Sema and Codegen support.
Included is also support for new Objective-C container subscripting.

My apologies for the large patch.  It was very difficult to break apart.
The patch introduces changes to the driver as well to cause clang to link
in additional runtime support when needed to support the new language features.

Docs are forthcoming to document the implementation and behavior of these features.

llvm-svn: 152137
2012-03-06 20:05:56 +00:00
John McCall a729c62b81 Whether an argument is required (in contrast with being an
optional argument passed through the variadic ellipsis)
potentially affects how we need to lower it.  Propagate
this information down to the various getFunctionInfo(...)
overloads on CodeGenTypes.  Furthermore, rename those
overloads to clarify their distinct purposes, and make
sure we're calling the right one in the right place.
This has a nice side-effect of making it easier to construct
a function type, since the 'variadic' bit is no longer
separable.

This shouldn't really change anything for our existing
platforms, with one minor exception --- we should now call
variadic ObjC methods with the ... in the "right place"
(see the test case), which I guess matters for anyone
running GNUStep on MIPS.  Mostly it's just a substantial
clean-up.

llvm-svn: 150788
2012-02-17 03:33:10 +00:00
David Chisnall 92d436b49a Support @compatibility_alias at run time (GNUstep Runtime)
Patch by Niels Grewe!

llvm-svn: 149401
2012-01-31 18:59:20 +00:00
Fariborz Jahanian 1e1b54926b objc++: some declarations related to atomic
properties of c++ object types with non-trivial
assignment copy. Not used yet. // rdar://6137845

llvm-svn: 147666
2012-01-06 18:07:23 +00:00
David Blaikie 83d382b1ca Switch assert(0/false) llvm_unreachable.
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
Fariborz Jahanian 831f0fc2e0 Support for catching objc pointer objects in c++ catch-statement
in fragile abi mode and some other cleanups. // rdar://8940528

llvm-svn: 133747
2011-06-23 19:00:08 +00:00
Fariborz Jahanian 0a3cfcc87f Alloa catching Objective-C id's being thrown with C++ throw
in Darwin's fragile abi mode.  // rdar://8940528

llvm-svn: 133639
2011-06-22 20:21:51 +00:00
John McCall 31168b077c Automatic Reference Counting.
Language-design credit goes to a lot of people, but I particularly want
to single out Blaine Garst and Patrick Beard for their contributions.

Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself,
in no particular order.

llvm-svn: 133103
2011-06-15 23:02:42 +00:00
David Chisnall 3fe89562e8 Fix some problems where functions must be bitcast but we're expecting a llvm::Function of the right type.
PR9994.

llvm-svn: 131930
2011-05-23 22:33:28 +00:00
Fariborz Jahanian 7bd3d1c49b Patch to fix IR-gen crash generating structure ABI which implements
user specified string class via -fconstant-string-class option.
pr9914.

llvm-svn: 131496
2011-05-17 22:21:16 +00:00
Jay Foad 1a180156b6 Remove unused STL header includes.
llvm-svn: 130068
2011-04-23 19:53:52 +00:00
Chris Lattner 57540c5be0 fix a bunch of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129559
2011-04-15 05:22:18 +00:00
David Chisnall d3858d6b0c Continuing work on ObjC tidyup:
- Moved the CGObjCRuntime functions out of CGObjCMac.cpp into CGObjCRuntime.cpp

- Added generic functions in CGObjCRuntime for emitting @try and @synchronize
  blocks, usable by any runtime that uses DWARF exceptions.

- Made the GNU runtimes use these functions.

It should now be possible to replace the equivalent functions in
CGObjCNonFragileABIMac with simple calls to these two functions, providing the
runtime functions as arguments.  I'll post a diff to the list for review before
making any changes to the Mac runtime stuff.

llvm-svn: 128274
2011-03-25 11:57:33 +00:00
David Chisnall 067f0ed468 Simplify Mac runtime selection - it's the factory function's job to select which class to produce, not CodeGenModule's.
llvm-svn: 128109
2011-03-22 21:21:24 +00:00
John McCall 351762cda2 A few more tweaks to the blocks AST representation:
- BlockDeclRefExprs always store VarDecls
  - BDREs no longer store copy expressions
  - BlockDecls now store a list of captured variables, information about
    how they're captured, and a copy expression if necessary
    
With that in hand, change IR generation to use the captures data in       
blocks instead of walking the block independently.        

Additionally, optimize block layout by emitting fields in descending
alignment order, with a heuristic for filling in words when alignment
of the end of the block header is insufficient for the most aligned
field.

llvm-svn: 125005
2011-02-07 10:33:21 +00:00
David Chisnall 168b80f2c0 Add support for GNU runtime property set / get structure functions. Minor refactoring of Mac runtime (returns the same function for both, as the Mac runtimes currently only provide a single entry point for setting and getting struct properties, although this will presumably be fixed at some point).
llvm-svn: 122569
2010-12-26 22:13:16 +00:00
Fariborz Jahanian 933c6723a4 Fixes an obscure bug in importd block variable layout
information when imported variable is used
more than once. Originally though to be a bug in importing
block varibles. Fixes radar 8417746.

llvm-svn: 113675
2010-09-11 01:27:29 +00:00
Fariborz Jahanian c05349e53a Some early work for providing block layout info.
for objective-c/c++ blocks (NeXt runtime).

llvm-svn: 110213
2010-08-04 16:57:49 +00:00
John McCall 2ca705eb13 Support catching Objective C pointers in C++ under the non-fragile NeXT runtime.
Diagnose attempts to do this under the GNU or fragile NeXT runtimes.

llvm-svn: 109298
2010-07-24 00:37:23 +00:00
Fariborz Jahanian 217af240b5 Adopt objc_assign_threadlocal() for __thread variables of GC types.
Implements radar 8203301.

llvm-svn: 108917
2010-07-20 20:30:03 +00:00