Commit Graph

46204 Commits

Author SHA1 Message Date
Richard Smith 4f9b3f4a5b Update comment to match dr1770.
llvm-svn: 290552
2016-12-26 22:28:29 +00:00
Simon Pilgrim 6f3e1ea403 Wdocumentation fix
llvm-svn: 290547
2016-12-26 18:11:49 +00:00
Marina Yatsina c5cf7a8b00 Fix build error caused by r290539.
llvm-svn: 290541
2016-12-26 13:16:40 +00:00
Marina Yatsina c42fd03bf8 [inline-asm]No error for conflict between inputs\outputs and clobber list
According to extended asm syntax, a case where the clobber list includes a variable from the inputs or outputs should be an error - conflict.
for example:

const long double a = 0.0;
int main()
{

char b;
double t1 = a;
__asm__ ("fucompp": "=a" (b) : "u" (t1), "t" (t1) : "cc", "st", "st(1)");

return 0;
}

This should conflict with the output - t1 which is st, and st which is st aswell.
The patch fixes it.

Commit on behald of Ziv Izhar.

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

llvm-svn: 290539
2016-12-26 12:23:42 +00:00
Saleem Abdulrasool d133dc226f Driver: warn on -fPIC/-fpic/-fPIE/-fpie on Windows
Use of these flags would result in the use of ELF-style PIE/PIC code
which is incorrect on Windows.  Windows is inherently PIC by means of
the DLL slide that occurs at load.  This also mirrors the behaviour on
GCC for MinGW.  Currently, the Windows x86_64 forces the relocation
model to PIC (Level 2).  This is unchanged for now, though we should
remove any assumptions on that and change it to a static relocation
model.

llvm-svn: 290533
2016-12-26 03:35:24 +00:00
Richard Smith 993f203278 Fix assertion failure when deducing an auto-typed argument against a different-width int.
llvm-svn: 290522
2016-12-25 20:21:12 +00:00
Amjad Aboud e2aab8c30c [DebugInfo] Added support for Checksum debug info feature.
Differential Revision: https://reviews.llvm.org/D27641

llvm-svn: 290515
2016-12-25 10:12:27 +00:00
Richard Smith 87d263e870 Fix some subtle wrong partial ordering bugs particularly with C++1z auto-typed
non-type template parameters.

During partial ordering, when checking the substituted deduced template
arguments match the original, check the types of non-type template arguments
match even if they're dependent. The only way we get dependent types here is if
they really represent types of the other template (which are supposed to be
modeled as being substituted for unique, non-dependent types).

In order to make this work for auto-typed non-type template arguments, we need
to be able to perform auto deduction even when the initializer and
(potentially) the auto type are dependent, support for which is the bulk of
this patch. (Note that this requires the ability to deduce only a single level
of a multi-level dependent type.)

llvm-svn: 290511
2016-12-25 08:05:23 +00:00
David Majnemer a5cfddc367 [MS ABI] Mangle unnamed enums correctly
Unnamed enums take the name of the first enumerator they define.

llvm-svn: 290509
2016-12-25 05:26:02 +00:00
Kelvin Li 83c451e998 [OpenMP] Sema and parsing for 'target teams distribute' pragma
This patch is to implement sema and parsing for 'target teams distribute' pragma.

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

llvm-svn: 290508
2016-12-25 04:52:54 +00:00
Anton Yartsev 5ac3720620 Fix for PR15623 (corrected r290413 reverted at 290415). The patch eliminates unwanted ProgramState checker data propagation from an operand of the logical operation to operation result.
The patch also simplifies an assume of a constraint of the form: "(exp comparison_op expr) != 0" to true into an assume of "exp comparison_op expr" to true. (And similarly, an assume of the form "(exp comparison_op expr) == 0" to true as an assume of exp comparison_op expr to false.) which improves precision overall.
https://reviews.llvm.org/D22862

llvm-svn: 290505
2016-12-25 00:57:51 +00:00
Richard Smith 0da6dc47d1 Factor out duplication between partial ordering for class template partial
specializations and variable template partial specializations.

llvm-svn: 290497
2016-12-24 16:40:51 +00:00
Yaron Keren 1c4bbc9a41 Deduplicate several GD.getDecl() calls into Decl * local variable.
llvm-svn: 290495
2016-12-24 15:32:39 +00:00
Malcolm Parsons 4ca3d18b96 [ASTMatchers] Add hasInClassInitializer traversal matcher for FieldDecl.
Summary:
I needed to know whether a FieldDecl had an in-class
initializer for D26453. I used a narrowing matcher there, but a
traversal matcher might be generally useful.

Reviewers: sbenza, bkramer, klimek, aaron.ballman

Subscribers: aaron.ballman, Prazek, cfe-commits

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

llvm-svn: 290492
2016-12-24 13:35:14 +00:00
Richard Smith 2c3fb80b23 Remove accidentally-left-behind commented out code.
llvm-svn: 290485
2016-12-24 04:22:52 +00:00
Richard Smith e68a38f0a8 Fix crash if substitution fails during deduction of variable template partial specialization arguments.
llvm-svn: 290484
2016-12-24 04:20:31 +00:00
Richard Smith 792c22dbd4 When producing a name of a partial specialization in a diagnostic, use the
template arguments as written rather than the canonical template arguments,
so we print more user-friendly names for template parameters.

llvm-svn: 290483
2016-12-24 04:09:05 +00:00
NAKAMURA Takumi afc8e54205 clangCodeGen: Add LLVMPasses to libdeps. r290450 introduced it.
llvm-svn: 290478
2016-12-24 01:55:12 +00:00
Richard Smith 0bda5b5ff4 ArrayRefize lists of TemplateArguments in template argument deduction.
llvm-svn: 290461
2016-12-23 23:46:56 +00:00
Ekaterina Romanova 16166a4d71 [DOXYGEN] Improved doxygen comments for tmmintrin.h intrinsics.
Added \n commands to insert a line breaks where necessary to make the documentation more readable. 
Formatted comments to fit into 80 chars.

llvm-svn: 290458
2016-12-23 23:36:26 +00:00
Ekaterina Romanova 6de0cd870b [DOXYGEN] Improved doxygen comments for tmmintrin.h intrinsics.
Tagged parameter names with \a doxygen command to display parameters in italics.
Added \n commands to insert a line break to make the documentation more readable. 
Formatted comments to fit into 80 chars.

llvm-svn: 290455
2016-12-23 22:47:16 +00:00
Chandler Carruth 50f9e893f2 [PM] Introduce options to enable the (still experimental) new pass
manager, and a code path to use it.

The option is actually a top-level option but does contain
'experimental' in the name. This is the compromise suggested by Richard
in discussions. We expect this option will be around long enough and
have enough users towards the end that it merits not being relegated to
CC1, but it still needs to be clear that this option will go away at
some point.

The backend code is a fresh codepath dedicated to handling the flow with
the new pass manager. This was also Richard's suggested code structuring
to essentially leave a clean path for development rather than carrying
complexity or idiosyncracies of how we do things just to share code with
the parts of this in common with the legacy pass manager. And it turns
out, not much is really in common even though we use the legacy pass
manager for codegen at this point.

I've switched a couple of tests to run with the new pass manager, and
they appear to work. There are still plenty of bugs that need squashing
(just with basic experiments I've found two already!) but they aren't in
this code, and the whole point is to expose the necessary hooks to start
experimenting with the pass manager in more realistic scenarios.

That said, I want to *strongly caution* anyone itching to play with
this: it is still *very shaky*. Several large components have not yet
been shaken down. For example I have bugs in both the always inliner and
inliner that I have already spotted and will be fixing independently.

Still, this is a fun milestone. =D

One thing not in this patch (but that might be very reasonable to add)
is some level of support for raw textual pass pipelines such as what
Sean had a patch for some time ago. I'm mostly interested in the more
traditional flow of getting the IR out of Clang and then running it
through opt, but I can see other use cases so someone may want to add
it.

And of course, *many* features are not yet supported!
- O1 is currently more like O2
- None of the sanitizers are wired up
- ObjC ARC optimizer isn't wired up
- ...

So plenty of stuff still lef to do!

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

llvm-svn: 290450
2016-12-23 20:44:01 +00:00
Egor Churaev 28f00aab73 [OpenCL] Align fake address space map with the SPIR target maps.
Summary:
We compile user opencl kernel code with spir triple. But built-ins are written in OpenCL and we compile it with triple x86_64 to be able to use x86 intrinsics. And we need address spaces to match in both cases. So, we change fake address space map in OpenCL for matching with spir.

On CPU address spaces are not really important but we'd like to preserve address space information in order to perform optimizations relying on this info like enhanced alias analysis.

Reviewers: pekka.jaaskelainen, Anastasia

Subscribers: pekka.jaaskelainen, yaxunl, bader, cfe-commits

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

llvm-svn: 290436
2016-12-23 16:11:25 +00:00
Egor Churaev 89831421af Fix problems in "[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand."
Summary: Fixed warnings in commit: https://reviews.llvm.org/rL290171

Reviewers: djasper, Anastasia

Subscribers: yaxunl, cfe-commits, bader

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

llvm-svn: 290431
2016-12-23 14:55:49 +00:00
Piotr Padlewski 1ec383c74a Use after move bug fixes
Summary: Bunch of fixed bugs in Clang after running misc-use-after-move in clang-tidy.

Reviewers: rsmith, mboehme

Subscribers: cfe-commits, klimek

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

llvm-svn: 290424
2016-12-23 11:40:44 +00:00
Chandler Carruth 8df65e4a2a Add an assert to catch improperly constructed %diff sequences in
diagnostics and fix one such diagnostic.

Sadly, this assert doesn't catch this bug because we have no tests that
emit this diagnostic! Doh! I'm following up on the commit that
introduces it to get that fixed. Then this assert will help in a more
direct way.

llvm-svn: 290417
2016-12-23 05:19:47 +00:00
Anton Yartsev b2a5eb87f8 Revert changes made by r290413 until regression is fixed.
llvm-svn: 290415
2016-12-23 04:09:18 +00:00
Anton Yartsev 1a2a9e3087 Fix for PR15623. The patch eliminates unwanted ProgramState checker data propagation from an operand of the logical operation to operation result.
The patch also simplifies an assume of a constraint of the form: "(exp comparison_op expr) != 0" to true into an assume of "exp comparison_op expr" to true. (And similarly, an assume of the form "(exp comparison_op expr) == 0" to true as an assume of exp comparison_op expr to false.) which improves precision overall.
https://reviews.llvm.org/D22862

llvm-svn: 290413
2016-12-23 03:31:00 +00:00
Richard Smith 43e14d271c Move generation of injected template arguments for a template parameter list
out of an internal function and into ASTContext; this is needed in template
argument deduction for P0522R0.

llvm-svn: 290405
2016-12-23 02:10:11 +00:00
Richard Smith 9341790509 Only substitute into type of non-type template parameter once, rather than
twice, in finalization of template argument deduction.

This is a re-commit of r290310 (reverted in r290329); the bug found by the
buildbots was fixed in r290399 (we would sometimes build a deduced template
argument with a bogus type).

llvm-svn: 290403
2016-12-23 02:00:24 +00:00
Richard Smith 593d6a168f When merging two deduced non-type template arguments for the same parameter,
fail the merge if the arguments have different types (except if one of them was
deduced from an array bound, in which case take the type from the other).

This is correct because (except in the array bound case) the type of the
template argument in each deduction must match the type of the parameter, so at
least one of the two deduced arguments must have a mismatched type.

This is necessary because we would otherwise lose the type information for the
discarded template argument in the merge, and fail to diagnose the mismatch.

In order to power this, we now properly retain the type of a deduced non-type
template argument deduced from a declaration, rather than giving it the type of
the template parameter; we'll convert it to the template parameter type when
checking the deduced arguments.

llvm-svn: 290399
2016-12-23 01:30:39 +00:00
Chandler Carruth fcd33149b4 Cleanup the handling of noinline function attributes, -fno-inline,
-fno-inline-functions, -O0, and optnone.

These were really, really tangled together:
- We used the noinline LLVM attribute for -fno-inline
  - But not for -fno-inline-functions (breaking LTO)
  - But we did use it for -finline-hint-functions (yay, LTO is happy!)
  - But we didn't for -O0 (LTO is sad yet again...)
- We had weird structuring of CodeGenOpts with both an inlining
  enumeration and a boolean. They interacted in weird ways and
  needlessly.
- A *lot* of set smashing went on with setting these, and then got worse
  when we considered optnone and other inlining-effecting attributes.
- A bunch of inline affecting attributes were managed in a completely
  different place from -fno-inline.
- Even with -fno-inline we failed to put the LLVM noinline attribute
  onto many generated function definitions because they didn't show up
  as AST-level functions.
- If you passed -O0 but -finline-functions we would run the normal
  inliner pass in LLVM despite it being in the O0 pipeline, which really
  doesn't make much sense.
- Lastly, we used things like '-fno-inline' to manipulate the pass
  pipeline which forced the pass pipeline to be much more
  parameterizable than it really needs to be. Instead we can *just* use
  the optimization level to select a pipeline and control the rest via
  attributes.

Sadly, this causes a bunch of churn in tests because we don't run the
optimizer in the tests and check the contents of attribute sets. It
would be awesome if attribute sets were a bit more FileCheck friendly,
but oh well.

I think this is a significant improvement and should remove the semantic
need to change what inliner pass we run in order to comply with the
requested inlining semantics by relying completely on attributes. It
also cleans up tho optnone and related handling a bit.

One unfortunate aspect of this is that for generating alwaysinline
routines like those in OpenMP we end up removing noinline and then
adding alwaysinline. I tried a bunch of other approaches, but because we
recompute function attributes from scratch and don't have a declaration
here I couldn't find anything substantially cleaner than this.

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

llvm-svn: 290398
2016-12-23 01:24:49 +00:00
Chandler Carruth 93786da2cb Make '-disable-llvm-optzns' an alias for '-disable-llvm-passes'.
Much to my surprise, '-disable-llvm-optzns' which I thought was the
magical flag I wanted to get at the raw LLVM IR coming out of Clang
deosn't do that. It still runs some passes over the IR. I don't want
that, I really want the *raw* IR coming out of Clang and I strongly
suspect everyone else using it is in the same camp.

There is actually a flag that does what I want that I didn't know about
called '-disable-llvm-passes'. I suspect many others don't know about it
either. It both does what I want and is much simpler.

This removes the confusing version and makes that spelling of the flag
an alias for '-disable-llvm-passes'. I've also moved everything in Clang
to use the 'passes' spelling as it seems both more accurate (*all* LLVM
passes are disabled, not just optimizations) and much easier to remember
and spell correctly.

This is part of simplifying how Clang drives LLVM to make it cleaner to
wire up to the new pass manager.

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

llvm-svn: 290392
2016-12-23 00:23:01 +00:00
Alexey Bataev 5e87c3465e [OPENMP] Fix for PR31417: assert failure when compiling trivial openmp
program

Offload related code is not quite ready yet, but some simple examples
must not crash the compiler. Patch fixes the problem in offloading code
with exceptions.

llvm-svn: 290364
2016-12-22 19:44:05 +00:00
George Burgess IV a804957476 Fix warning introduced by r290297.
llvm-svn: 290356
2016-12-22 19:00:31 +00:00
Devin Coughlin e17f621529 [analyzer] Update GTestChecker to tighten API detection
Update the GTestChecker to tighten up the API detection and make it
cleaner in response to post-commit feedback. Also add tests for when
temporary destructors are enabled to make sure we get the expected behavior
when inlining constructors for temporaries.

llvm-svn: 290352
2016-12-22 17:52:57 +00:00
Artem Dergachev 0e0a8b4d85 [analyzer] Improve suppress-on-sink behavior in incomplete analyses.
Warnings with suppress-on-sink are discarded during FlushReports when
BugReporter notices that all paths in ExplodedGraph that pass through the
warning eventually run into a sink node.

However, suppress-on-sink fails to filter out false positives when the analysis
terminates too early - by running into analyzer limits, such as block count
limits or graph size limits - and the interruption hits the narrow window
between throwing the leak report and reaching the no-return function call. In
such case the report is there, however suppression-on-sink doesn't work, because
the sink node was never constructed in the incomplete ExplodedGraph.

This patch implements a very partial solution: also suppress reports thrown
against a statement-node that corresponds to a statement that belongs to a
no-return block of the CFG.

rdar://problem/28832541

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

llvm-svn: 290341
2016-12-22 14:48:52 +00:00
Daniel Jasper 2388861f09 clang-format: Less eagerly try to keep label-value pairs on a line.
Before:
  string v =
      StrCat("aaaaaaaaaaaaaaaaaaaaaaaaaaa: ", SomeFunction(aaaaaaaaaaaa,
                                                           aaaaaaaaaaaaaaa),
             bbbbbbbbbbbbbbbbbbbbbbb);

After:
  string v = StrCat("aaaaaaaaaaaaaaaaaaaaaaaaaaa: ",
                    SomeFunction(aaaaaaaaaaaa, aaaaaaaaaaaaaaa),
                    bbbbbbbbbbbbbbbbbbbbbbb);

llvm-svn: 290337
2016-12-22 12:37:06 +00:00
Richard Smith e824775399 Speculative revert of r290310 to see if that's the change that's making some of
the bots unhappy.

llvm-svn: 290329
2016-12-22 07:24:39 +00:00
Bruno Cardoso Lopes 82ec4fde42 [CrashReproducer] Add support for merging -ivfsoverlay
Merge all VFS mapped files inside -ivfsoverlay inputs into the vfs
overlay provided by the crash reproducer. This is the last missing piece
to allow crash reproducers to fully work with user frameworks; when
combined with headermaps, it allows clang to find additional frameworks.

rdar://problem/27913709

llvm-svn: 290326
2016-12-22 07:06:03 +00:00
Antonio Maiorano 34c037641b Make FormatStyle.GetStyleOfFile test work on MSVC
Modify getStyle to use vfs::FileSystem::makeAbsolute just like FS.addFile does,
rather than sys::fs::make_absolute. The latter gets the CWD from the platform,
while the former expects it to be set by the client, causing a mismatch when
converting relative paths to absolute.

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

llvm-svn: 290319
2016-12-22 05:10:07 +00:00
Saleem Abdulrasool 78704fb6dc Sema: print qualified name for overload candidates
Print the fully qualified names for the overload candidates.  This makes
it easier to tell what the ambiguity is.  Especially if a template
is instantiated after a using namespace, it will not inherit the
namespace where it was declared.  The specialization will give a message
about a partial order being ambiguous for the same (unqualified) name,
which does not help identify the failure.

Addresses PR31450!

llvm-svn: 290315
2016-12-22 04:26:57 +00:00
Richard Smith e27c6dfd31 Only substitute into type of non-type template parameter once, rather than
twice, in finalization of template argumetn deduction.

llvm-svn: 290310
2016-12-22 03:52:37 +00:00
Saleem Abdulrasool 2511d6049e Driver: use the triple to query the arch, not the toolchain
Although the result is the same, the intent is much more clear this way:
we care about the architecture we are targeting.  NFC.

llvm-svn: 290305
2016-12-22 03:09:04 +00:00
Saleem Abdulrasool 491d1d4b00 Driver: remove unnecessary parameter
We can query the Triple and EffectiveTriple from the ToolChain.  Avoid
passing in the argument and query it in the function.  NFC.

llvm-svn: 290304
2016-12-22 03:09:02 +00:00
Saleem Abdulrasool 416852fe37 Driver: rename parameter to reduce confusion
The parameter to ParsePICOpts passed the effective triple and then used
that in a few places and used the actual triple in others.  This was
slightly confusing.  Rename the parameter to make it more obvious.

llvm-svn: 290303
2016-12-22 03:09:00 +00:00
George Burgess IV e37633713d Add the alloc_size attribute to clang, attempt 2.
This is a recommit of r290149, which was reverted in r290169 due to msan
failures. msan was failing because we were calling
`isMostDerivedAnUnsizedArray` on an invalid designator, which caused us
to read uninitialized memory. To fix this, the logic of the caller of
said function was simplified, and we now have a `!Invalid` assert in
`isMostDerivedAnUnsizedArray`, so we can catch this particular bug more
easily in the future.

Fingers crossed that this patch sticks this time. :)

Original commit message:

This patch does three things:
- Gives us the alloc_size attribute in clang, which lets us infer the
  number of bytes handed back to us by malloc/realloc/calloc/any user
  functions that act in a similar manner.
- Teaches our constexpr evaluator that evaluating some `const` variables
  is OK sometimes. This is why we have a change in
  test/SemaCXX/constant-expression-cxx11.cpp and other seemingly
  unrelated tests. Richard Smith okay'ed this idea some time ago in
  person.
- Uniques some Blocks in CodeGen, which was reviewed separately at
  D26410. Lack of uniquing only really shows up as a problem when
  combined with our new eagerness in the face of const.

llvm-svn: 290297
2016-12-22 02:50:20 +00:00
Richard Smith 52e624f3ec Perform type-checking for a converted constant expression in a template
argument even if the expression is value-dependent (we need to suppress the
final portion of the narrowing check, but the rest of the checking can still be
done eagerly).

This affects template template argument validity and partial ordering under
p0522r0.

llvm-svn: 290276
2016-12-21 21:42:57 +00:00
Tim Northover c67803fb14 ARM: define a macro for the FPv5 FPU in ARM mode.
FPv5 is in Cortex-M7 and the 64-bit CPUs when running in 32-bit mode. The name
is from the Cortex-M7 TRM.

llvm-svn: 290268
2016-12-21 20:49:43 +00:00
Daniel Jasper 083d1700a0 clang-format: Fix bug in handling of single-column lists.
Members that are themselves wrapped in fake parentheses would lead to
AvoidBinPacking be set on the wrong ParenState.

After:
  vector<int> aaaa = {
      aaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
      aaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
      aaaaaa.aaaaaaa,
      aaaaaa.aaaaaaa,
      aaaaaa.aaaaaaa,
      aaaaaa.aaaaaaa,
  };

Before we were falling back to bin-packing these.

llvm-svn: 290259
2016-12-21 17:02:06 +00:00