Commit Graph

113 Commits

Author SHA1 Message Date
John McCall c8e0170578 Standardize accesses to the TargetInfo in IR-gen.
Patch by Stephen Lin!

llvm-svn: 179638
2013-04-16 22:48:15 +00:00
Richard Smith dbf74baee5 CodeGen support for function-local static thread_local variables with
non-constant constructors or non-trivial destructors. Plus bugfixes for
thread_local references bound to temporaries (the temporaries themselves are
lifetime-extended to become thread_local), and the corresponding case for
std::initializer_list.

llvm-svn: 179496
2013-04-14 23:01:42 +00:00
Richard Smith fd3834f7a1 Annotate flavor of TLS variable (statically or dynamically initialized) onto the AST.
llvm-svn: 179447
2013-04-13 02:43:54 +00:00
John McCall 47fb950871 Change hasAggregateLLVMType, which conflates complex and
aggregate types in a profoundly wrong way that has to be
worked around in every call site, to getEvaluationKind,
which classifies and distinguishes between all of these
cases.

Also, normalize the API for loading and storing complexes.

I'm working on a larger patch and wanted to pull these
changes out, but it would have be annoying to detangle
them from each other.

llvm-svn: 176656
2013-03-07 21:37:08 +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
Kostya Serebryany 4c0fc9931e Unify clang/llvm attributes for asan/tsan/msan (Clang part)
These are two related changes (one in llvm, one in clang).
LLVM: 
- rename address_safety => sanitize_address (the enum value is the same, so we preserve binary compatibility with old bitcode)
- rename thread_safety => sanitize_thread
- rename no_uninitialized_checks -> sanitize_memory

CLANG: 
- add __attribute__((no_sanitize_address)) as a synonym for __attribute__((no_address_safety_analysis))
- add __attribute__((no_sanitize_thread))
- add __attribute__((no_sanitize_memory))

for S in address thread memory
If -fsanitize=S is present and __attribute__((no_sanitize_S)) is not
set llvm attribute sanitize_S

llvm-svn: 176076
2013-02-26 06:58:27 +00:00
Will Dietz f54319c891 [ubsan] Add support for -fsanitize-blacklist
llvm-svn: 172808
2013-01-18 11:30:38 +00:00
Chandler Carruth ffd5551bc7 Rewrite #includes for llvm/Foo.h to llvm/IR/Foo.h as appropriate to
reflect the migration in r171366.

Re-sort the #include lines to reflect the new paths.

llvm-svn: 171369
2013-01-02 11:45:17 +00:00
Bill Wendling 207f05369d Rename llvm::Attributes to llvm::Attribute.
llvm-svn: 170722
2012-12-20 19:27:06 +00:00
Bill Wendling 4442605f18 Revert r170500. It over-zealously converted *ALL* things named Attributes, which is wrong here.
llvm-svn: 170721
2012-12-20 19:22:21 +00:00
Bill Wendling 7967fc14b9 Rename the 'Attributes' class to 'Attribute'. It's going to represent a single attribute in the future.
llvm-svn: 170500
2012-12-19 07:18:12 +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
Anton Korobeynikov abed749203 Implement codegen for init_priority attribute properly - make sure it
works between the modules.
No functionality change on Darwin/Windows.
This fixes PR11480.

llvm-svn: 167496
2012-11-06 22:44:45 +00:00
Richard Smith 43f9d9c6d9 Rename LangOptions members for address sanitizer and thread sanitizer from
*Sanitizer to Sanitize* in preparation for later patches.

llvm-svn: 167405
2012-11-05 21:48:12 +00:00
Richard Smith 9c6890a792 Simplify: replace getContext().getLangOpts() with just getLangOpts().
llvm-svn: 167261
2012-11-01 22:30:59 +00:00
Alexey Samsonov 9b502e512c Initialize debug info for special cases of functions that lack declarations and are generated by Clang (global initializers/destructors, thunks) . Fixes PR13942.
llvm-svn: 166676
2012-10-25 10:18:50 +00:00
Alexey Samsonov 38e2496497 Transform pattern:
if (CGM.getModuleDebugInfo())
    DebugInfo = CGM.getModuleDebugInfo()
into a call:
  maybeInitializeDebugInfo();

This is a simplification for a possible future fix of PR13942.

llvm-svn: 166019
2012-10-16 07:22:28 +00:00
Bill Wendling 73e465e148 Have 'addFnAttr' take the attribute enum value. Then have it build the attribute object and add it appropriately. No functionality change.
llvm-svn: 165596
2012-10-10 03:13:20 +00:00
Nick Lewycky 085970736f Emit debug info for dynamic initializers. Permit __attribute__((nodebug)) on
variables that have static storage duration, it removes debug info on the
emitted initializer function but not all debug info about this variable.

llvm-svn: 160659
2012-07-24 01:40:49 +00:00
Kostya Serebryany bf84b8fa3b [asan] add missing asan instrumentation in generated global init functions
llvm-svn: 159191
2012-06-26 08:56:33 +00:00
John McCall c84ed6a336 Abstract the emission of global destructors into ABI-specific code
and only consider using __cxa_atexit in the Itanium logic.  The
default logic is to use atexit().

Emit "guarded" initializers in Microsoft mode unconditionally.
This is definitely not correct, but it's closer to correct than
just not emitting the initializer.

Based on a patch by Timur Iskhodzhanov!

llvm-svn: 155894
2012-05-01 06:13:13 +00:00
John McCall 32233a7c1a Fix a trivial oversight with apple-kext static local destructors
and add a test case.

llvm-svn: 154653
2012-04-13 02:53:27 +00:00
John McCall 76cc43a2a4 Use atexit when __cxa_atexit isn't available instead of adding a
global destructor entry.  For some reason this isn't enabled for
apple-kexts;  it'd be good to have documentation for that.

Based on a patch by Nakamura Takumi!

llvm-svn: 154191
2012-04-06 18:21:06 +00:00
John McCall ee08c53478 Rename GenerateCXXGlobalDtorFunc to GenerateCXXGlobalDtorsFunc.
llvm-svn: 154190
2012-04-06 18:21:03 +00:00
Chandler Carruth 8453795255 Revert r153723, and its follow-ups r153728 and r153733.
These patches cause us to miscompile and/or reject code with static
function-local variables in an extern-C context. Previously, we were
papering over this as long as the variables are within the same
translation unit, and had not seen any failures in the wild. We still
need a proper fix, which involves mangling static locals inside of an
extern-C block (as GCC already does), but this patch causes pretty
widespread regressions. Firefox, and many other applications no longer
build.

Lots of test cases have been posted to the list in response to this
commit, so there should be no problem reproducing the issues.

llvm-svn: 153768
2012-03-30 19:44:53 +00:00
John McCall 87590e60c0 Do the static-locals thing properly in the face of unions and
other things which might mess with the variable's type.

llvm-svn: 153733
2012-03-30 07:09:50 +00:00
Chad Rosier 615ed1a3a6 Revert r153613 as it's causing large compile-time regressions on the nightly testers.
llvm-svn: 153660
2012-03-29 17:37:10 +00:00
John McCall 1a0877f99d When we can't prove that the target of an aggregate copy is
a complete object, the memcpy needs to use the data size of
the structure instead of its sizeof() value.  Fixes PR12204.

llvm-svn: 153613
2012-03-28 23:30:44 +00:00
NAKAMURA Takumi 9c7f1242f1 CodeGen/CGDeclCXX.cpp: Twine-ize CreateGlobalInitOrDestructFunction().
llvm-svn: 153578
2012-03-28 16:24:29 +00:00
David Blaikie bbafb8a745 Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
The member variable is always "LangOpts" and the member function is always "getLangOpts".

Reviewed by Chris Lattner

llvm-svn: 152536
2012-03-11 07:00:24 +00:00
Nick Lewycky 4506204640 Emit the exact size for the invariant intrinsics.
llvm-svn: 151010
2012-02-21 00:26:58 +00:00
Richard Smith 132bea96ad Don't emit optimization-specific intrinsic at -O0.
llvm-svn: 150838
2012-02-17 20:12:52 +00:00
Richard Smith 08a5144621 The clang half of r150794: after the construction of a global or static const
variable ends, if the variable has a trivial destructor and no mutable
subobjects then emit an llvm.invariant.start call for it. globalopt knows to
make the variable const when evaluating this.

llvm-svn: 150798
2012-02-17 07:31:37 +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
Richard Smith 6331c408b5 Deal with a horrible C++11 special case. If a non-literal type has a constexpr
constructor, and that constructor is used to initialize an object of static
storage duration such that all members and bases are initialized by constant
expressions, constant initialization is performed. In this case, the object
can still have a non-trivial destructor, and if it does, we must emit a dynamic
initializer which performs no initialization and instead simply registers that
destructor.

llvm-svn: 150419
2012-02-13 22:16:19 +00:00
Chris Lattner ece0409a1a simplify a bunch of code to use the well-known LLVM IR types computed by CodeGenModule.
llvm-svn: 149943
2012-02-07 00:39:47 +00:00
Peter Collingbourne 1425b4556a Use function pointers, rather than references, to pass Destroyers
around, in the process cleaning up the various gcc/msvc compiler
workarounds.

llvm-svn: 149036
2012-01-26 03:33:36 +00:00
Eli Friedman a0544d6fdf Switch LValue so that it exposes alignment in CharUnits. (No functional change.)
llvm-svn: 145753
2011-12-03 04:14:32 +00:00
Douglas Gregor e8bbc12152 Extend the ASTContext constructor to delay the initialization of
builtin types (When requested). This is another step toward making
ASTUnit build the ASTContext as needed when loading an AST file,
rather than doing so after the fact. No actual functionality change (yet).

llvm-svn: 138985
2011-09-02 00:18:52 +00:00
John McCall a5efa7386a Track whether an AggValueSlot is potentially aliased, and do not
emit call results into potentially aliased slots.  This allows us
to properly mark indirect return slots as noalias, at the cost
of requiring an extra memcpy when assigning an aggregate call
result into a l-value.  It also brings us into compliance with
the x86-64 ABI.

llvm-svn: 138599
2011-08-25 23:04:34 +00:00
John McCall 8d6fc9583d Use stronger typing for the flags on AggValueSlot and require
creators to tell us whether something needs GC barriers.
No functionality change.

llvm-svn: 138581
2011-08-25 20:40:09 +00:00
Jay Foad 5709f7c5f7 Remove some unnecessary single element array temporaries.
llvm-svn: 136461
2011-07-29 13:56:53 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
Chris Lattner 2192fe50da de-constify llvm::Type, patch by David Blaikie!
llvm-svn: 135370
2011-07-18 04:24:23 +00:00
Jay Foad 5bd375a6cc Convert CallInst and InvokeInst APIs to use ArrayRef.
llvm-svn: 135265
2011-07-15 08:37:34 +00:00
John McCall 98de3d74d2 Generalize the routine for destroying an object with static
storage duration, then explicitly exempt ownership-qualified
types from it.

llvm-svn: 135028
2011-07-13 03:01:35 +00:00
Chris Lattner a5f58b05e8 clang side to match the LLVM IR type system rewrite patch.
llvm-svn: 134831
2011-07-09 17:41:47 +00:00
Douglas Gregor fa918f69f6 Emit guard variables for any weak global that has a run-time
initializer. Previously, we only used guard variables for weak static
data members. Fixes <rdar://problem/9692249>.

llvm-svn: 134266
2011-07-01 21:54:36 +00:00
John McCall 1553b19067 Restore correct use of GC barriers.
llvm-svn: 133144
2011-06-16 04:16:24 +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