Richard Smith [Thu, 23 Jun 2016 19:02:52 +0000 (19:02 +0000)]
Re-commit r273548, reverted in r273589, with a fix to not produce
-Wfor-loop-analysis warnings for a for-loop with a condition variable. In such
a case, the loop condition variable is modified on each iteration of the loop
by definition.
Original commit message:
Rearrange condition handling so that semantic checks on a condition variable
are performed before the other substatements of the construct are parsed,
rather than deferring them until the end. This allows better error recovery
from semantic errors in the condition, improves diagnostic order, and is a
prerequisite for C++17 constexpr if.
During the core analysis, ExplodedNodes are added to the
ExplodedGraph, and those nodes are cached for deduplication purposes.
After core analysis, reports are generated. Here, trimmed copies of
the ExplodedGraph are made. Since the ExplodedGraph has already been
deduplicated, there is no need to deduplicate again.
This change makes it possible to add ExplodedNodes to an
ExplodedGraph without the overhead of deduplication. "Uncached" nodes
also cannot be iterated over, but none of the report generation code
attempts to iterate over all nodes. This change reduces the analysis
time of a large .C file from 3m43.941s to 3m40.256s (~1.6% speedup).
It should slightly reduce memory consumption. Gains should be roughly
proportional to the number (and path length) of static analysis
warnings.
This patch enables future work that should remove the need for an
InterExplodedGraphMap inverse map. I plan on using the (now unused)
ExplodedNode link to connect new nodes to the original nodes.
Rafael Espindola [Thu, 23 Jun 2016 15:07:32 +0000 (15:07 +0000)]
Restructure the propagation of -fPIC/-fPIE.
The PIC and PIE levels are not independent. In fact, if PIE is defined
it is always the same as PIC.
This is clear in the driver where ParsePICArgs returns a PIC level and
a IsPIE boolean. Unfortunately that is currently lost and we pass two
redundant levels down the pipeline.
This patch keeps a bool and a PIC level all the way down to codegen.
Aaron Ballman [Thu, 23 Jun 2016 14:33:53 +0000 (14:33 +0000)]
Fixing a FIXME related to Unicode support on Windows. Converted the Win32 APIs to explicitly use the W version when it involves strings that can hold non-ASCII characters (like file paths). Now explicitly using the A version for strings that will always be ASCII (like registry key paths).
No extra tests required as this is currently covered by existing testing, and this is basically impossible to write Unicode-specific tests for.
We would incorrectly emit the directive sections due to the missing overridden
methods. We now emit the expected "/DEFAULTLIB" rather than "-l" options for
requested linkage
Richard Smith [Thu, 23 Jun 2016 08:41:20 +0000 (08:41 +0000)]
Rearrange condition handling so that semantic checks on a condition variable
are performed before the other substatements of the construct are parsed,
rather than deferring them until the end. This allows better error recovery
from semantic errors in the condition, improves diagnostic order, and is a
prerequisite for C++17 constexpr if.
Simon Atanasyan [Wed, 22 Jun 2016 20:00:50 +0000 (20:00 +0000)]
[driver][mips] Factor out findMIPSMultilibs code into separate functions. NFC
The findMIPSMultilibs is too long. One more reason for splitting is to
escape redundant calls of MultilibSet::FilterOut method which lead to
disk access.
Vedant Kumar [Wed, 22 Jun 2016 19:57:58 +0000 (19:57 +0000)]
[Coverage] Push a new region when handling CXXTryStmts
Push a new region for the try block and propagate execution counts
through it. This ensures that catch statements get a region counter
distinct from the try block's counter.
Rafael Espindola [Wed, 22 Jun 2016 18:04:52 +0000 (18:04 +0000)]
Make this test a bit more strict and fix it.
We do pass -pic-level to cc1 when targeting darwin. Given that codegen
itself doesn't use it, the only difference is whether __PIE__ and
__pie__ are defined.
Devin Coughlin [Wed, 22 Jun 2016 17:03:10 +0000 (17:03 +0000)]
[analyzer] Teach ObjCDeallocChecker about XCTestCase
Like with SenTestCase, subclasses of XCTestCase follow a "tear down" idiom to
release instance variables and so typically do not release ivars in -dealloc.
This commit applies the existing special casing for SenTestCase to XCTestCase
as well.
Hans Wennborg [Wed, 22 Jun 2016 16:56:16 +0000 (16:56 +0000)]
Add support for /Ob1 and -finline-hint-functions flags
Add support for /Ob1 (and equivalent -finline-hint-functions), which enable
inlining only for functions marked inline, either explicitly (via inline
keyword, for example), or implicitly (function definition in class body,
for example).
This works by enabling inlining pass, and adding noinline attribute to
every function not marked inline.
Hans Wennborg [Wed, 22 Jun 2016 16:21:14 +0000 (16:21 +0000)]
Widen EHScope::ClenupBitFields::FixupDepth to avoid overflowing it (PR23490)
It currently only takes 2048 gotos to overflow the FixupDepth bitfield,
causing silent miscompilation. Apparently some parser generators run into
this (see PR).
I don't know that that data structure is terribly size sensitive anyway,
and since there's no room to widen the bitfield, let's just use a separate
word in EHCatchScope for it.
Yaxun Liu [Wed, 22 Jun 2016 14:56:35 +0000 (14:56 +0000)]
[OpenCL] Use function metadata to represent kernel attributes
This patch uses function metadata to represent reqd_work_group_size, work_group_size_hint and vector_type_hint kernel attributes and kernel argument info.
Craig Topper [Wed, 22 Jun 2016 06:36:21 +0000 (06:36 +0000)]
[AVX512] Fix _mm_setzero_di to not require avx512vl since its used by the avx512dqintrin.h. Also update the avx512dq test to not enable avx512vl feature so we can ensure correct dependencies.
CodeGen: Replace test/CodeGen/thinlto_backend.c with a functional test.
This new test tests that functions are capable of being imported, rather than
that the import pass is run. This new test is compatible with the approach
being developed in D20268 which runs the importer on its own rather than in
a pass.
Devin Coughlin [Wed, 22 Jun 2016 00:20:00 +0000 (00:20 +0000)]
[analyzer] Teach trackNullOrUndefValue() about class property accessors.
Teach trackNullOrUndefValue() how to properly look through PseudoObjectExprs
to find the underlying semantic method call for property getters. This fixes a
crash when looking through class property getters that I introduced in r265839.
Summary:
If the RenderScript LangOpt is set, either via '-x renderscript' or the '.rs'
file extension, set the DWARF language tag to be that of RenderScript.
This is a fix for PR28112:
https://llvm.org/bugs/show_bug.cgi?id=28112
The FP comparison intrinsics that take an immediate parameter (rather than specifying
a comparison predicate in the function name) were added with AVX; these are macros in
avxintrin.h. This patch makes clang behavior match gcc (error if a program tries to use
these without -mavx) and matches the Intel documentation, eg:
VCMPPS: m128 _mm_cmp_ps(m128 a, __m128 b, const int imm)
'V' means this is intended to only work with the AVX form of the instruction.
Richard Smith [Tue, 21 Jun 2016 20:10:11 +0000 (20:10 +0000)]
Refactor scope building in JumpDiagnostics for simplicity. This fixes a
(currently theoretical) bug where recursive calls to BuildScopeInformation
would do the wrong thing if the type of the statement is one of the kinds with
special handling, but this is not currently observable because the relevant
recursive calls happen to all be for CompoundStmts. (This becomes visible with
the C++17 'constexpr if' feature, where we get a protected scope for the 'then'
/ 'else' cases of some 'if's, and don't necessarily have a corresponding
compound statement.)
David Majnemer [Tue, 21 Jun 2016 03:40:16 +0000 (03:40 +0000)]
[CodeGen] Do not run initializers for imported variables
The export side is responsible for running any initializers, they are
run when the module is first loaded. Attempting to run an initializer
for the import side is not possible.
[Docs] More warning fixes to unbreak the docs buildbot.
A number of warnings still remain, but these were the last of the
"unlexable code"-related ones (AFAICT).
I changed a few examples in docs/UsersManual.rst to showcase
-Wextra-tokens because it's already documented (-Wmultichar isn't), and
the sphinx C lexer apparently can't handle char literals like 'ab'. It
seemed like a better overall approach than just marking the code blocks
as none or console.
Zvi Rackover [Sat, 18 Jun 2016 20:01:07 +0000 (20:01 +0000)]
[X86] _MM_ALIGN16 attribute support for non-windows targets
Summary:
This patch adds support for the _MM_ALIGN16 attribute on non-windows targets. This aligns Clang with ICC which supports the attribute on all targets.
David Majnemer [Fri, 17 Jun 2016 17:47:24 +0000 (17:47 +0000)]
[CodeGen] Use pointer-sized integers for ptrtoint sources
Given something like:
void *v = (void *)100;
We need to synthesize a ptrtoint operation from 100. During constant
emission, we choose i64 as the type for our constant because it
guaranteed not to drop any bits from our CharUnits representation of the
value. However, this is suboptimal for 32-bit targets: LLVM passes like
GlobalOpt will get confused by these sorts of casts resulting in
pessimization.
Instead, make sure the ptrtoint operand has a pointer-sized integer
type.
Driver: introduce and use `-isystem-after` for cross-windows
This mirrors the many other -i*after options to insert a new system search
directory at the end of the search path. This makes it possible to actually
inject a search path after the resource dir. This option is similar in spirit
to the /imsvc option in the clang-cl driver. This is needed to properly use the
driver for Windows targets where the clang headers wrap some of the system
headers.
This concept is actually useful on other targets (e.g. Linux) and would be
really easy to support on the core toolchain.
Ranjeet Singh [Fri, 17 Jun 2016 00:59:41 +0000 (00:59 +0000)]
[ARM] Add mrrc/mrrc2 intrinsics and update existing mcrr/mcrr2 intrinsics.
Reapplying patch in r272777 which was reverted
because the llvm patch which added support
for generating the mcrr/mcrr2 instructions
from the intrinsic was causing an assertion
failure. This has now been fixed in llvm.
Olivier Goffart [Thu, 16 Jun 2016 21:39:46 +0000 (21:39 +0000)]
Functions declared in a scope should not hide previous declaration in earlier scopes
This code should be an error:
void foo(int);
void f3() {
int foo(float);
{
float foo(int); // expected-error {{functions that differ only in their return type cannot be overloaded}}
}
}
the foo(float) function declared at function scope should not hide the float(int)
while trying to redeclare functions.