Commit Graph

665 Commits

Author SHA1 Message Date
Richard Smith f0480fc988 Simplify. No functionality change.
llvm-svn: 170100
2012-12-13 05:41:48 +00:00
John McCall c818bbb8b2 Fix the required args count for variadic blocks.
We were emitting calls to blocks as if all arguments were
required --- i.e. with signature (A,B,C,D,...) rather than
(A,B,...).  This patch fixes that and accounts for the
implicit block-context argument as a required argument.
In addition, this patch changes the function type under which
we call unprototyped functions on platforms like x86-64 that
guarantee compatibility of variadic functions with unprototyped
function types;  previously we would always call such functions
under the LLVM type T (...)*, but now we will call them under
the type T (A,B,C,D,...)*.  This last change should have no
material effect except for making the type conventions more
explicit;  it was a side-effect of the most convenient implementation.

llvm-svn: 169588
2012-12-07 07:03:17 +00:00
Chandler Carruth ff0e3a1e1c Rework the bitfield access IR generation to address PR13619 and
generally support the C++11 memory model requirements for bitfield
accesses by relying more heavily on LLVM's memory model.

The primary change this introduces is to move from a manually aligned
and strided access pattern across the bits of the bitfield to a much
simpler lump access of all bits in the bitfield followed by math to
extract the bits relevant for the particular field.

This simplifies the code significantly, but relies on LLVM to
intelligently lowering these integers.

I have tested LLVM's lowering both synthetically and in benchmarks. The
lowering appears to be functional, and there are no really significant
performance regressions. Different code patterns accessing bitfields
will vary in how this impacts them. The only real regressions I'm seeing
are a few patterns where the LLVM code generation for loads that feed
directly into a mask operation don't take advantage of the x86 ability
to do a smaller load and a cheap zero-extension. This doesn't regress
any benchmark in the nightly test suite on my box past the noise
threshold, but my box is quite noisy. I'll be watching the LNT numbers,
and will look into further improvements to the LLVM lowering as needed.

llvm-svn: 169489
2012-12-06 11:14:44 +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
Richard Smith 78f6b03edc Fix test failure when building Clang with g++4.7 -- don't use a Twine temporary
after its lifetime has ended!

llvm-svn: 169170
2012-12-03 22:39:14 +00:00
Will Dietz 88e0233ff4 [ubsan] Add flag to enable recovery from checks when possible.
llvm-svn: 169114
2012-12-02 19:50:33 +00:00
Aaron Ballman f505d55472 Fixing a precedence issue with my previous commit.
llvm-svn: 169041
2012-11-30 21:44:01 +00:00
Aaron Ballman 56b226a8da Fixing an MSVC warning about an unsafe mixture of Boolean and unsigned types in a logical operator.
llvm-svn: 169037
2012-11-30 21:15:20 +00:00
Fariborz Jahanian fbd19749a3 objective-C arc: load of a __weak object happens via call to
objc_loadWeak. This retains and autorelease the weakly-refereced
object. This hidden autorelease sometimes makes __weak variable alive even
after the weak reference is erased, because the object is still referenced
by an autorelease pool. This patch overcomes this behavior by loading a 
weak object via call to objc_loadWeakRetained(), followng it by objc_release
at appropriate place, thereby removing the hidden autorelease. // rdar://10849570

llvm-svn: 168740
2012-11-27 23:02:53 +00:00
Benjamin Kramer 37196de31e Enable inlining of 4 byte atomic ops on ppc32, 8 byte atomic ops on ppc64.
Also fixes a bit/byte mismatch when checking if a target supports atomic ops of a certain size.

llvm-svn: 168260
2012-11-17 17:30:55 +00:00
Eli Friedman b369f44924 Fix IR generation for bool on PPC (and any other target where bool is not 8 bits in memory).
PR11777.

llvm-svn: 167802
2012-11-13 02:05:15 +00:00
Richard Smith b1b0ab41e7 Use the individual -fsanitize=<...> arguments to control which of the UBSan
checks to enable. Remove frontend support for -fcatch-undefined-behavior,
-faddress-sanitizer and -fthread-sanitizer now that they don't do anything.

llvm-svn: 167413
2012-11-05 22:21:05 +00:00
Richard Smith 9c6890a792 Simplify: replace getContext().getLangOpts() with just getLangOpts().
llvm-svn: 167261
2012-11-01 22:30:59 +00:00
Richard Smith de67068fc1 Split emission of -ftrapv checks and -fcatch-undefined-behavior checks into
separate functions, since they share essentially no code.

llvm-svn: 167259
2012-11-01 22:15:34 +00:00
Richard Smith 2d8b294b3c -fcatch-undefined-behavior: Start checking loads and stores for null pointers.
We want the diagnostic, and if the load is optimized away, we still want to
trap it. Stop checking non-default address spaces; that doesn't work in
general.

llvm-svn: 167219
2012-11-01 07:22:08 +00:00
Eli Friedman fb9c49e250 Don't crash on bad atomic operations. PR14176.
llvm-svn: 166992
2012-10-30 01:15:28 +00:00
Rafael Espindola 9c006de3d3 Move two helper functions to AST so that sema can use them.
llvm-svn: 166853
2012-10-27 01:03:43 +00:00
Rafael Espindola b9d75ca84b Refactor some code into a new findMaterializedTemporary function.
llvm-svn: 166849
2012-10-27 00:43:14 +00:00
Rafael Espindola b413676cd7 Refactor some code into a new skipRValueSubobjectAdjustments function.
llvm-svn: 166848
2012-10-27 00:40:06 +00:00
Rafael Espindola e7b11f5241 Delay codegen to after collecting all SubobjectAdjustment so that the collection
can be refactored and used in Sema.

llvm-svn: 166847
2012-10-27 00:36:38 +00:00
Richard Smith 4d3110af06 -fcatch-undefined-behavior checking for appropriate vptr value: Clang CodeGen side.
llvm-svn: 166661
2012-10-25 02:14:12 +00:00
Richard Smith 5a1104bd3a DR1472: A reference isn't odr-used if it has preceding initialization,
initialized by a reference constant expression.

Our odr-use modeling still needs work here: we don't yet implement the 'set of
potential results of an expression' DR.

llvm-svn: 166361
2012-10-20 01:38:33 +00:00
Bill Wendling a514ebc1db Move the Attributes::Builder outside of the Attributes class and into its own class named AttrBuilder. No functionality change.
llvm-svn: 165961
2012-10-15 20:36:26 +00:00
Bill Wendling 311c832fda Attributes Rewrite
Convert the uses of the Attributes class over to the new format. The
Attributes::get method call now takes an LLVM context so that the attributes
object can be uniquified and stored.

llvm-svn: 165918
2012-10-15 04:47:45 +00:00
Nico Weber cf4ff586e8 Add codegen support for __uuidof().
llvm-svn: 165710
2012-10-11 10:13:44 +00:00
Bill Wendling a7912f8894 Remove the final bits of Attributes being declared in the Attribute
namespace. Use the attribute's enum value instead. No functionality change
intended.

llvm-svn: 165611
2012-10-10 07:36:56 +00:00
Richard Smith 683398a3b6 -fcatch-undefined-behavior: store the type name directly at the end of a type descriptor. 5% binary size reduction due to fewer relocations.
llvm-svn: 165572
2012-10-09 23:55:19 +00:00
Richard Smith e30752c93b -fcatch-undefined-behavior: emit calls to the runtime library whenever one of the checks fails.
llvm-svn: 165536
2012-10-09 19:52:38 +00:00
Micah Villmow dd31ca10ef Move TargetData to DataLayout.
llvm-svn: 165395
2012-10-08 16:25:52 +00:00
Richard Smith 639b8d05dd When a bad UTF-8 encoding or bogus escape sequence is encountered in a
string literal, produce a diagnostic pointing at the erroneous character
range, not at the start of the literal.

llvm-svn: 163459
2012-09-08 07:16:20 +00:00
Richard Smith 4d1458ed38 -fcatch-undefined-behavior: Factor emission of the creation of, and branch to,
the trap BB out of the individual checks and into a common function, to prepare
for making this code call into a runtime library. Rename the existing EmitCheck
to EmitTypeCheck to clarify it and to move it out of the way of the new
EmitCheck.

llvm-svn: 163451
2012-09-08 02:08:36 +00:00
Eli Friedman 34866c7719 Change the representation of builtin functions in the AST
(__builtin_* etc.) so that it isn't possible to take their address.
Specifically, introduce a new type to represent a reference to a builtin
function, and a new cast kind to convert it to a function pointer in the
operand of a call.  Fixes PR13195.

llvm-svn: 162962
2012-08-31 00:14:07 +00:00
Richard Smith 69d0d2626a New -fcatch-undefined-behavior features:
* when checking that a pointer or reference refers to appropriate storage for a type, also check the alignment and perform a null check
 * check that references are bound to appropriate storage
 * check that 'this' has appropriate storage in member accesses and member function calls

llvm-svn: 162523
2012-08-24 00:54:33 +00:00
Tanya Lattner a9dd49fe5b Convert loads and stores of vec3 to vec4 to achieve better code generation. Add test case.
llvm-svn: 162002
2012-08-16 00:10:13 +00:00
Eli Friedman f6d2184c83 Fix an assertion failure with a C++ constructor initializing a
member of reference type in an anonymous struct.  PR13154.

llvm-svn: 161473
2012-08-08 03:51:37 +00:00
Chandler Carruth cc8f2a6ab5 Update Clang to reflect the move of MDBuilder in r160237.
llvm-svn: 160238
2012-07-15 23:28:01 +00:00
John McCall 8dda7b27ee Distinguish more carefully between free functions and C++ instance methods
in the ABI arrangement, and leave a hook behind so that we can easily
tweak CCs on platforms that use different CCs by default for C++
instance methods.

llvm-svn: 159894
2012-07-07 06:41:13 +00:00
Matt Beaumont-Gay 36af16affd Silence warning in -Asserts build
llvm-svn: 159635
2012-07-03 03:55:58 +00:00
Nico Weber 4b18c3ff40 Share ConvertUTF8toWide() between Lex and CodeGen.
llvm-svn: 159634
2012-07-03 02:24:52 +00:00
John McCall 4e8ca4fa14 Significantly simplify CGExprAgg's logic about ignored results:
if we want to ignore a result, the Dest will be null.  Otherwise,
we must copy into it.  This means we need to ensure a slot when
loading from a volatile l-value.

With all that in place, fix a bug with chained assignments into
__block variables of aggregate type where we were losing insight into
the actual source of the value during the second assignment.

llvm-svn: 159630
2012-07-02 23:58:38 +00:00
Eli Friedman c24e2fb1fb Propagate lvalue alignment into bitfields. Per report on cfe-dev.
llvm-svn: 159295
2012-06-27 21:19:48 +00:00
Nico Weber 3a691a367c Support L__FUNCTION__ in microsoft mode, PR11789
Heavily based on a patch from
Aaron Wishnick <aaron.s.wishnick@gmail.com>.

I'll clean up the duplicated function in CodeGen as
a follow-up, later today or tomorrow.

llvm-svn: 159060
2012-06-23 02:07:59 +00:00
Eli Friedman 13ffdd86b9 Make the ".*" operator work correctly when the base is a prvalue and the field has a non-trivial copy constructor. PR13097.
llvm-svn: 158578
2012-06-15 23:51:06 +00:00
Fariborz Jahanian 5d53fcda7c User better API for vla in compund literals.
// rdar://11485774

llvm-svn: 158157
2012-06-07 18:15:55 +00:00
Fariborz Jahanian bbc5bbf4f1 When emitting compund literal of vla pointer elements, make
sure to emit vla size to prevent an irgen crash.
// rdar://11485774

llvm-svn: 158153
2012-06-07 17:07:15 +00:00
Nuno Lopes a425589fea wire -fbounds-checking to the new LLVM bounds checking pass
llvm-svn: 157262
2012-05-22 17:19:45 +00:00
Nuno Lopes 2b1ff46ed1 revert the usage of the objectsize intrinsic with 3 parameters (to match LLVM r157255)
llvm-svn: 157256
2012-05-22 15:26:48 +00:00
Richard Smith bb653bd5f9 Implement IRGen for C++11's "T{1, 2, 3}", where T is an aggregate and the
expression is treated as an lvalue.

llvm-svn: 156781
2012-05-14 21:57:21 +00:00
Nuno Lopes ddcce0bb90 update calls to objectsize intrinsic to match LLVM r156473
add a test for -fbounds-checking code generation

llvm-svn: 156474
2012-05-09 15:53:34 +00:00
Nuno Lopes 3d6311d5f7 add -fbounds-checking option.
When enabled, clang generates bounds checks for array and pointers dereferences. Work to follow in LLVM's backend.

OK'ed by Chad; thanks for the review.

llvm-svn: 156431
2012-05-08 22:10:46 +00:00