David Blaikie [Thu, 2 Apr 2015 18:55:21 +0000 (18:55 +0000)]
[opaque pointer type] Update for GEP API changes in LLVM
Now the GEP constant utility functions require the type to be explicitly
passed (since eventually the pointer type will be opaque and not convey
the required type information). For now callers can still pass nullptr
(though none were needed here in Clang, which is nice) if
convenienc/necessary, but eventually that will be disallowed as well.
Benjamin Kramer [Thu, 2 Apr 2015 16:19:54 +0000 (16:19 +0000)]
Lower the default alignment on ASTContext's operator new.
It was documented as 8 and operator new[] defaults to 8, but the normal
operator new was never updated and happily wasted bytes on every other
allocation.
We still have to allocate all Types with 16 byte alignment, update the
allocation calls for Types that were missing explicit alignment.
Benjamin Kramer [Thu, 2 Apr 2015 15:29:07 +0000 (15:29 +0000)]
[ast] Put the Stmt hierarchy on a diet for 64 bit targets.
Previously we would waste 32 bits on alignment, use LLVM_ALIGNAS to
free that space for derived classes an place. Sadly still have to #ifdef
out MSVC 2013 because it can't align based on a sizeof expr.
No intended functionality change. New byte counts:
sizeof(before) | sizeof(after)
This is a tool for checking consistency of code generation with different
compiler options (such as -g or outputting to .s). This tool has found a number
of code generation issues. The script acts as a wrapper to clang or clang++
performing 2 (or more) compiles then comparing the object files. Instructions
for use are in check_cfc.py including how to use with LNT.
[UBSan] Embed UBSan into ASan runtime (Clang part).
Summary:
Change the way we use ASan and UBSan together. Instead of keeping two
separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan
into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on
a platform, all UBSan sources are just compiled into dummy empty object
files. UBSan initialization code (e.g. flag parsing) is directly called
from ASan initialization, so we are able to enforce correct
initialization order.
This mirrors the approach we already use for ASan+LSan. This change doesn't
modify the way we use standalone UBSan.
Richard Smith [Wed, 1 Apr 2015 19:31:06 +0000 (19:31 +0000)]
Minor simplification: do typo-correction before handling inheriting
constructors, instead of having the typo-correction code also dispatch to the
inheriting constructor special case.
Fix data layout mismatch between LLVM and Clang for i686-pc-windows-msvc-elf
Do the same thing as win64. If we're not using COFF, use the ELF
manglings. Maybe if we are targetting *-windows-msvc-macho, we should
use darwin manglings, but I don't need to stir that pot today.
Mark instantiated function decls as inline specified if any pattern is
A function template pattern can be declared without the 'inline'
specifier and defined later with the 'inline' specifier. However, during
instantiation, we were only looking at the canonical decl to see if we
should mark the instantiated decl as inline specified. Since the
instantiated decl actually represents many pattern declarations, put the
inline specifier on the instantiation decl if any of the pattern decls
have it.
[SystemZ] Add header files to Makefile / module.modulemap
This should fix build-bot failures after r233804.
The patch also adds a "systemz" feature, and renames the
"transactional-execution" feature to "htm", since it turns
out "-" is not a legal character in module feature names.
[SystemZ] Support transactional execution on zEC12
The zEC12 provides the transactional-execution facility. This is exposed
to users via a set of builtin routines on other compilers. This patch
adds clang support to enable those builtins. In partciular, the patch:
- enables the transactional-execution feature by default on zEC12
- allows to override presence of that feature via the -mhtm/-mno-htm options
- adds a predefined macro __HTM__ if the feature is enabled
- adds support for the transactional-execution GCC builtins
- adds Sema checking to verify the __builtin_tabort abort code
- adds the s390intrin.h header file (for GCC compatibility)
- adds s390 sections to the htmintrin.h and htmxlintrin.h header files
Since this is first use of target-specific intrinsics on the platform,
the patch creates the include/clang/Basic/BuiltinsSystemZ.def file and
hooks it up in TargetBuiltins.h and lib/Basic/Targets.cpp.
An associated LLVM patch adds the required LLVM IR intrinsics.
For reference, the transactional-execution instructions are documented
in the z/Architecture Principles of Operation for the zEC12:
http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/download/DZ9ZR009.pdf
The associated builtins are documented in the GCC manual:
http://gcc.gnu.org/onlinedocs/gcc/S_002f390-System-z-Built-in-Functions.html
The htmxlintrin.h intrinsics provided for compatibility with the IBM XL
compiler are documented in the "z/OS XL C/C++ Programming Guide".
MSVC treats all non-empty exception specifications the same way: all
exceptions are permitted. The .xdata tables provide a way to
efficiently lower exception specifications *but* this probably has to be
implemented as a catch-all/rethrow mechanism instead of the Itanium way.
[OPENMP] Sema analysis for 'atomic capture' construct.
Added sema checks for forms of expressions/statements allowed under control of 'atomic capture' directive + generation of helper objects for future codegen.
Craig Topper [Tue, 31 Mar 2015 05:45:00 +0000 (05:45 +0000)]
[X86] Use getHostCPUFeatures when 'native' is specified for cpu.
This is necessary because not aall Sandybridge, Ivybrige, Haswell, and Broadwell CPUs support AVX. Currently we modify the CPU name back to Nehalem for this case, but that turns off additional features for these CPUs.
Derek Schuff [Mon, 30 Mar 2015 20:31:33 +0000 (20:31 +0000)]
Add driver support for Native Client SDK
Add Tool and ToolChain support for clang to target the NaCl OS using the NaCl
SDK for x86-32, x86-64 and ARM.
Includes nacltools::Assemble and Link which are derived from gnutools. They
are similar to Linux but different enought that they warrant their own class.
Also includes a NaCl_TC in ToolChains derived from Generic_ELF with library
and include paths suitable for an SDK and independent of the system tools.
Jordan Rose [Mon, 30 Mar 2015 20:18:00 +0000 (20:18 +0000)]
[analyzer] Disable all retain count diagnostics on values that come from ivars.
This is imitating a pre-r228174 state where ivars are not considered tracked by
default, but with the addition that even ivars /with/ retain count information
(e.g. "[_ivar retain]; [ivar _release];") are not being tracked as well. This is
to ensure that we don't regress on values accessed through both properties and
ivars, which is what r228174 was trying to fix.
In this case, the call to -addSubview: may change the value of self->_contentView,
and so the analyzer can't be sure that we didn't leak the original _contentView.
This is a correct conservative view of the world, but not a useful one. Until we
have a heuristic that allows us to not consider this a leak, not emitting a
diagnostic is our best bet.
This commit disables all of the ivar-related retain count tests, but does not
remove them to ensure that we don't crash trying to evaluate either valid or
erroneous code. The next commit will add a new test for the example above so
that this commit (and the previous one) can be reverted wholesale when a better
solution is implemented.
Kit Barton [Mon, 30 Mar 2015 19:40:59 +0000 (19:40 +0000)]
[PPC] Move argument range checks for HTM and crypto builtins to Sema
The argument range checks for the HTM and Crypto builtins were implemented in
CGBuiltin.cpp, not in Sema. This change moves them to the appropriate location
in SemaChecking.cpp. It requires the creation of a new method in the Sema class
to do checks for PPC-specific builtins.
Ulrich Weigand [Mon, 30 Mar 2015 13:50:21 +0000 (13:50 +0000)]
[SystemZ] Fix definition of IntMaxType / Int64Type
Like on other 64-bit platforms, Int64Type should be SignedLong
on SystemZ, not SignedLongLong as per default. This could cause
ABI incompatibilities in certain cases (e.g. name mangling).
Ulrich Weigand [Mon, 30 Mar 2015 13:49:01 +0000 (13:49 +0000)]
[SystemZ] Fix some ABI corner cases
Running the GCC's inter-compiler ABI compatibility test suite uncovered
a couple of errors in clang's SystemZ ABI implementation. These all
affect only rare corner cases:
- Short vector types
GCC synthetic vector types defined with __attribute__ ((vector_size ...))
are always passed and returned by reference. (This is not documented in
the official ABI document, but is the de-facto ABI implemented by GCC.)
clang would do that only for vector sizes >= 16 bytes, but not for shorter
vector types.
- Float-like aggregates and empty bitfields
clang would consider any aggregate containing an empty bitfield as
first element to be a float-like aggregate. That's obviously wrong.
According to the ABI doc, the presence of an empty bitfield makes
an aggregate to be *not* float-like. However, due to a bug in GCC,
empty bitfields are ignored in C++; this patch changes clang to be
compatible with this "feature" of GCC.
- Float-like aggregates and va_arg
The va_arg implementation would mis-detect some aggregates as float-like
that aren't actually passed as such. This applies to aggregates that
have only a single element of type float or double, but using an aligned
attribute that increases the total struct size to more than 8 bytes.
This error occurred because the va_arg implement used to have an copy
of the float-like aggregate detection logic (i.e. it would call the
isFPArgumentType routine, but not perform the size check).
To simplify the logic, this patch removes the duplicated logic and
instead simply checks the (possibly coerced) LLVM argument type as
already determined by classifyArgumentType.
Alexey Bataev [Mon, 30 Mar 2015 05:20:59 +0000 (05:20 +0000)]
[OPENMP] Codegen for 'atomic update' construct.
Adds atomic update codegen for the following forms of expressions:
x binop= expr;
x++;
++x;
x--;
--x;
x = x binop expr;
x = expr binop x;
If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted.
Otherwise compare-and-swap sequence is emitted:
Alexey Bataev [Mon, 30 Mar 2015 04:30:22 +0000 (04:30 +0000)]
[OPENMP] Improved codegen for implicit/explicit 'barrier' constructs.
Replace boolean IsExplicit parameter of OpenMPRuntime::emitBarrierCall() method by OpenMPDirectiveKind Kind for better compatibility with the runtime library. Also add processing of 'nowait' clause on worksharing directives.
Differential Revision: http://reviews.llvm.org/D8659
Petar Jovanovic [Mon, 30 Mar 2015 00:43:56 +0000 (00:43 +0000)]
Add check for kind of UnqualifiedId in Declarator::isStaticMember()
Method CXXMethodDecl::isStaticOverloadedOperator expects Operator field
from the struct OperatorFunctionId, which is a member of the union in
the class UnqualifiedId. If the kind of UnqualifiedId is not checked,
there is no guarantee that the value that this method receives will be
correct, because it can be the value of another union member and not
OperatorFunctionId.
This bug manifests itself when running make check-all on mips64 BE.
This fix resolves the following regression tests:
Clang :: CXX/special/class.dtor/p9.cpp
Clang :: CodeGenCXX/2006-09-12-OpaqueStructCrash.cpp
Clang :: CodeGenCXX/ctor-dtor-alias.cpp
Clang :: CodeGenCXX/debug-info-windows-dtor.cpp
Clang :: CodeGenCXX/dllexport-members.cpp
Clang :: CodeGenCXX/dllexport.cpp
David Majnemer [Sun, 29 Mar 2015 21:55:10 +0000 (21:55 +0000)]
[MS ABI] Rework .xdata HandlerType emission
Utilizing IMAGEREL relocations for synthetic IR constructs isn't
valuable, just clutter. While we are here, simplify HandlerType names
by making the numeric value for the 'adjective' part of the mangled name
instead of appending '.const', etc. The old scheme made for very long
global names and leads to wordy things like '.std_bad_alloc'
Chandler Carruth [Sat, 28 Mar 2015 01:10:44 +0000 (01:10 +0000)]
[Modules] Don't compute a modules cache path if we're not using modules!
Notably, this prevents us from doing *tons* of work to compute the
modules hash, including trying to read a darwin specific plist file off
of the system. There is a lot that needs cleaning up below this layer
too.
Richard Smith [Sat, 28 Mar 2015 00:31:40 +0000 (00:31 +0000)]
A conversion from a scoped enumeration bitfield to an integral type is an
integral promotion only if it converts to the underlying type or its promoted
type, not if it converts to the promoted type that the bitfield would have it
if were of the underlying type.
An upcoming LLVM commit will make calling
`DIBuilder::retainType(nullptr)` illegal (actually, it already was, but
it wasn't verified). Check for null before calling.
This triggered in test/CodeGenObjC/debug-info-block-helper.m.
Chandler Carruth [Fri, 27 Mar 2015 21:40:58 +0000 (21:40 +0000)]
[Modules] Work around PR23030 again, in a different code path, where
I again added the "reasonable" assertions and they again fired during
a modules self-host.
This hopefully will un-break the self-host build bot. No test case handy
and adding one seems to have little or no value really.
Richard Smith [Fri, 27 Mar 2015 21:16:39 +0000 (21:16 +0000)]
[modules] When merging class definitions, make the retained definition visible
if the merged definition is visible, and perform lookups into all merged copies
of the definition (not just for special members) so that we can complete the
redecl chains for members of the class.
Chandler Carruth [Fri, 27 Mar 2015 01:48:11 +0000 (01:48 +0000)]
[Modules] When walking the lookup results in a namespace, sort them by
declaration name so that we mark declarations for emission in
a deterministic order (and in turn give them deterministic IDs).
This is the last for loop or data structure I can find by inspection of
the AST writer which doesn't use a deterministic order.
Kaelyn Takata [Fri, 27 Mar 2015 01:44:47 +0000 (01:44 +0000)]
Diagnose delayed typos in an expr list that is in an invalid expression.
Previously, if the expr list parsed fine but the expr to the left of the
open parenthesis was invalid (when parsing the suffix of a
postfix-expression), the parsed expr list was just ignored.
Chandler Carruth [Fri, 27 Mar 2015 00:31:20 +0000 (00:31 +0000)]
[Modules] Sort the file IDs prior to building the flattened array of
DeclIDs so that in addition to be grouped by file, the order of these
groups is stable.
Found by inspection, no test case. Not sure this can be observed without
a randomized seed for the hash table, but we shouldn't be relying on the
hash table layout under any circumstances.
Chandler Carruth [Thu, 26 Mar 2015 23:58:11 +0000 (23:58 +0000)]
[Modules] Fix an obvious lack of deterministic ordering when processing
rewritten decls for Objective-C modules.
Found by inspection and completely obvious, so no test case. Many of the
remaining determinism fixes won't have precise test cases at this point,
but these are the kinds of things we wouldn't ask for a specific test of
during code review but ask authors to fix. The functionality isn't
changing, and should (he he!) already be tested.
Chandler Carruth [Thu, 26 Mar 2015 23:54:15 +0000 (23:54 +0000)]
[Modules] Make the AST serialization always use lexicographic order when
traversing the identifier table.
No easy test case as this table is somewhere between hard and impossible
to observe as non-deterministically ordered. The table is a hash table
but we hash the string contents and never remove entries from the table
so the growth pattern, etc, is all completely fixed. However, relying on
the hash function being deterministic is specifically against the
long-term direction of LLVM's hashing datastructures, which are intended
to provide *no* ordering guarantees. As such, this defends against these
things by sorting the identifiers. Sorting identifiers right before we
emit them to a serialized form seems a low cost for predictability here.
Chandler Carruth [Thu, 26 Mar 2015 23:45:40 +0000 (23:45 +0000)]
[Modules] Delete stale, pointless code. All tests still pass with this
logic removed.
This logic was both inserting all builtins into the identifier table and
ensuring they would get serialized. The first happens unconditionally
now, and we always write out the entire identifier table. This code can
simply go away.
Chandler Carruth [Thu, 26 Mar 2015 22:27:09 +0000 (22:27 +0000)]
[Modules] Fix a sneaky bug in r233249 where we would look for implicit
constructors in the current lexical context even though name lookup
found them via some other context merged into the redecl chain.
This can only happen for implicit constructors which can only have the
name of the type of the current context, so we can fix this by simply
*always* merging those names first. This also has the advantage of
removing the walk of the current lexical context from the common case
when this is the only constructor name we need to deal with (implicit or
otherwise).
I've enhanced the tests to cover this case (and uncovered an unrelated
bug which I fixed in r233325).
Chandler Carruth [Thu, 26 Mar 2015 22:22:22 +0000 (22:22 +0000)]
[Modules] Fix tiny bug where we failed to get the canonical decl when
deserializing an inherited constructor.
This is the exact same logic we use when deserializing method overrides
for the same reason: the canonical decl may end up pinned to a different
decl when we are improting modules, we need to re-pin to the canonical
one during reading.
My test case for this will come in a subsequent commit. I was trying to
test a more tricky bug fix and the test case happened to tickle this bug
as well.
Richard Smith [Thu, 26 Mar 2015 22:10:01 +0000 (22:10 +0000)]
[modules] Restrict the module use-declaration to only appear in top-level
modules, and allow sub-modules of a module with a use-declaration to make use
of the nominated modules.
Bill Schmidt [Thu, 26 Mar 2015 20:16:52 +0000 (20:16 +0000)]
[PowerPC] Remove assembly testing from test/CodeGen/ppc64-elf-abi.c
Eric Christopher pointed out that we have a check for assembly code
generation in a clang test, which isn't cool. We already have Driver
and back-end CodeGen tests for the .abiversion handling, so this
testing is unnecessary anyway. Make it go away.
Ed Schouten [Thu, 26 Mar 2015 17:50:28 +0000 (17:50 +0000)]
Enable -ffunction-sections and -fdata-sections for CloudABI by default.
Unlike most of the other platforms supported by Clang, CloudABI only
supports static linkage, for the reason that global filesystem access is
prohibited. Functions provided by dlfcn.h are not present. As we know
that applications will not try to do any symbol lookups at run-time, we
can garbage collect unused code quite aggressively. Because of this, it
makes sense to enable -ffunction-sections and -fdata-sections by
default.
Object files will be a bit larger than usual, but the resulting binary
will not be affected, as the sections are merged again. However, when
--gc-sections is used, the linker is able to remove unused code far more
more aggressively. It also has the advantage that transitive library
dependencies only need to be provided to the linker in case that
functionality is actually used.