Re: r274084 - Revert "[PS4] Tighten up a test (noticed in passing)"

2016-07-01 Thread Sean Silva via cfe-commits
On Thu, Jun 30, 2016 at 5:30 PM, Robinson, Paul 
wrote:

> Okay, that is peculiar.  But I can repro it.  If I put either orbis-ld or
> orbis-ld.exe co-located with clang.exe, it builds a command line without
> the .exe suffix (but using the directory where clang.exe lives).
>

Yeah, as I described in the commit message of r262285 it is due to an
extra-high-priority lookup done in Driver::GetProgramPath that overrides
the PATH lookup. In fact, in the production PS4 SDK the PATH lookup
purportedly tested in this test *never occurs* since these "look in the the
directory containing clang" lookups always find orbis-ld first (since it is
always(?) right beside clang).

So this test probably needs to be changed to copy the clang binary into a
directory, put an orbis-ld.exe there, and then verify that clang finds that
orbis-ld. There is little point to testing PATH lookups since AFAIK we
don't really advertise to licensees that they should mess with the contents
of the sdk dir (i.e. to cause clang to not be beside orbis-ld and instead
find orbis-ld through a PATH lookup).

(actually, copying the clang binary is not ideal since that binary may be
quite large)


>
> I do think a bug report would have been appropriate, rather than just
> munging the test…
>
As it is (with your mods) the test is not checking what we want it to
> check.  I'll write an internal bug for this.
>

Thanks. To be completely honest I had not noticed that due to the prefix
property it wouldn't quite check the right thing.

-- Sean Silva


> --paulr
>
>
>
> *From:* Sean Silva [mailto:chisophu...@gmail.com]
> *Sent:* Thursday, June 30, 2016 4:03 PM
> *To:* Robinson, Paul
> *Cc:* cfe-commits (cfe-commits@lists.llvm.org)
> *Subject:* Re: r274084 - Revert "[PS4] Tighten up a test (noticed in
> passing)"
>
>
>
>
>
>
>
> On Thu, Jun 30, 2016 at 3:52 PM, Robinson, Paul 
> wrote:
>
>
>
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of
> > Sean Silva via cfe-commits
> > Sent: Tuesday, June 28, 2016 5:29 PM
> > To: cfe-commits@lists.llvm.org
> > Subject: r274084 - Revert "[PS4] Tighten up a test (noticed in passing)"
> >
> > Author: silvas
> > Date: Tue Jun 28 19:29:23 2016
> > New Revision: 274084
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=274084&view=rev
> > Log:
> > Revert "[PS4] Tighten up a test (noticed in passing)"
> >
> > This reverts commit r269709.
> >
> > r262285 changed this deliberately so that the test would not be
> > sensitive to which binaries are in the same directory as clang.
> > See the commit message of that commit for more background.
>
> Okay, but the point of the test is to match a "file.exe" instead
> of just "file". See commentary at the top of the test.
> Also "orbis-ld" is a prefix of "orbis-ld.gold" and so matching
> just the former doesn't verify we're looking for the right one.
>
> I understand taking out the path part of the check in r262285 but
> if you named your test linker "orbis-ld.exe" instead of "orbis-ld"
> then the test would pass with r269709, right?
>
>
>
> Unfortunately not.
>
>
>
> -- Sean Silva
>
>
>
>   If that's all this
> is about, please undo this revert and use the standard Windows
> file extension for your test linkers.
> --paulr
>
>
> >
> > Modified:
> > cfe/trunk/test/Driver/ps4-linker-win.c
> >
> > Modified: cfe/trunk/test/Driver/ps4-linker-win.c
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-linker-
> > win.c?rev=274084&r1=274083&r2=274084&view=diff
> >
> ==
> > 
> > --- cfe/trunk/test/Driver/ps4-linker-win.c (original)
> > +++ cfe/trunk/test/Driver/ps4-linker-win.c Tue Jun 28 19:29:23 2016
> > @@ -22,5 +22,5 @@
> >  // RUN: env "PATH=%T;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared
> > \
> >  // RUN: -fuse-ld=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-
> > LINKER %s
> >
> > -// CHECK-PS4-GOLD: \\orbis-ld.gold.exe"
> > -// CHECK-PS4-LINKER: \\orbis-ld.exe"
> > +// CHECK-PS4-GOLD: \\orbis-ld.gold
> > +// CHECK-PS4-LINKER: \\orbis-ld
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18172: [CUDA][OpenMP] Add a generic offload action builder

2016-07-01 Thread Justin Lebar via cfe-commits
jlebar added a subscriber: jlebar.
jlebar added a comment.

Yeah, I'd say that in the absence of a rule, consistency with surrounding
code is king.  Otherwise we're sending a message when we don't mean to be.

I'm not at my machine, but my recollection is that most of the driver uses
final sparingly.  But whatever the convention is we should do that, I think.


http://reviews.llvm.org/D18172



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18172: [CUDA][OpenMP] Add a generic offload action builder

2016-07-01 Thread Justin Lebar via cfe-commits
Yeah, I'd say that in the absence of a rule, consistency with surrounding
code is king.  Otherwise we're sending a message when we don't mean to be.

I'm not at my machine, but my recollection is that most of the driver uses
final sparingly.  But whatever the convention is we should do that, I think.
On Jun 30, 2016 9:16 PM, "Samuel Antao"  wrote:

> sfantao added a comment.
>
> In http://reviews.llvm.org/D18172#471861, @jlebar wrote:
>
> > Alexey, it seems that you're asking for "final" on all classes that are
> not inherited from.  Forgive my ignorance, but would you mind pointing me
> to the document that talks about our position on "final" in LLVM source?  I
> don't see it in the style guide, but I may be missing something.
> >
> > The style guide does talk a good bit about writing concise and generally
> not-misleading code.  My concern is that adding "final" everywhere paints
> an inaccurate picture and will mislead readers.  Specifically, "final" is
> useful as a signal to readers that a class cannot safely be inherited
> from.  "Don't even think about it, buster."  But here we're adding "final"
> to a lot of classes that, as far as I can tell, aren't distinctive except
> in that they have no subclasses today.  The problem with this is that, if
> we use "final" in this way, it dilutes the first "don't even try" meaning.
> Now when I see a class with "final" that I want to subclass, I'm just going
> to rip the "final" off, because chances are, I can do so safely.  Now
> "final" does not serve as a warning to me that I shouldn't do this.
> >
> > Sorry to focus on a superficial issue, but I think this really does
> matter for usability.
>
>
> Hi Justin,
>
> Thanks for the comment!
>
> I understand both interpretations can be useful for different purposes,
> i.e. "don't inherit, it is not safe" vs "feel free to change this class
> without worrying with subclasses". I tend to think that the latter (which I
> believe is what Alexey has in mind) can, in general, be more useful in the
> sense that a class is usually safe to extend - you can always add features
> that are somewhat orthogonal to what the parent class is doing. I can, of
> course, imagine cases where your argument is valid - you can have an
> implementation that allocates memory based on the type of the parent
> therefore it does not observe the extra storage required by derived
> classes. However, I think these cases are less common.
>
> I also look at the programming guidelines and couldn't find a clear answer
> to the issue you raised.
>
> I don't have a strong opinion about this, just giving my two cents.
>
> Thanks again!
> Samuel
>
>
> http://reviews.llvm.org/D18172
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21603: [include-fixer] Add missing namespace qualifiers after inserting a missing header.

2016-07-01 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include-fixer/IncludeFixer.cpp:224
@@ +223,3 @@
+  std::string MinimizedFilePath = minimizeInclude(
+  ((FilePath[0] == '"' || FilePath[0] == '<') ? FilePath
+  : "\"" + FilePath + 
"\""),

Ah, I see. This was just moved. Sorry, missed that.


Comment at: include-fixer/IncludeFixer.cpp:258
@@ +257,3 @@
+
+// Query the symbol based on C++ name Lookup rules.
+// Firstly, lookup the identifier with scoped namespace contexts; If fails,

Could you add something about this to the CL description? Or actually, I think 
this is very separate from fixing the namespace qualifiers. Can we move this 
part to a different patch?

Or am I missing something so that one cannot go without the other? 
Fundamentally, this seems to be doing two things:
1) Insert namespace qualifiers if they are missing.
2) Take existing namespace qualifiers to ensure we aren't looking up the wrong 
symbol.


Comment at: include-fixer/IncludeFixerContext.h:31
@@ +30,3 @@
+MatchedSymbols(Symbols), SymbolRange(Range) {
+// Deduplicate headers, so that we don't want to suggest the same header
+// twice.

This again seems like something that is unrelated to what the patch is actually 
meant to do. Can we split this into a separate patch?


Comment at: include-fixer/find-all-symbols/SymbolInfo.cpp:93
@@ -92,1 +92,3 @@
 
+std::string SymbolInfo::getFullyQualifiedName() const {
+  std::string FullyQuanlifiedName = Name;

I think "getQualifiedName" is sufficient and then matches what's in NamedDecl.


Comment at: include-fixer/find-all-symbols/SymbolInfo.cpp:94
@@ +93,3 @@
+std::string SymbolInfo::getFullyQualifiedName() const {
+  std::string FullyQuanlifiedName = Name;
+  for (const auto &Context : Contexts) {

There is an extra "n" in "FullyQuanlifiedName".


Comment at: include-fixer/tool/ClangIncludeFixer.cpp:88
@@ -86,1 +87,3 @@
 
+cl::opt FixNamespaceQualifiers("fix-namespace-qualifiers",
+   cl::desc("Add missing namespace qualifiers to the "

I'd strongly recommend not doing that. Removing flags that people are using is 
hard (breaks them). Make this good enough so that it is always the right thing 
to do.


Comment at: unittests/include-fixer/IncludeFixerTest.cpp:144
@@ -141,1 +143,3 @@
+runIncludeFixer("a::b::foo bar;\n",
+/*FixNamespaceQualifiers=*/false, IncludePath));
 

Do you need to set FixNamespaceQualifiers to false here?


http://reviews.llvm.org/D21603



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21706: [libcxx] refactor for throw

2016-07-01 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Generally looks OK to me.

There are similar uses in test sources as well, but those can be taken care of 
separately (I'm hoping to get back to the -fno-exceptions XFAILs soon).


http://reviews.llvm.org/D21706



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-07-01 Thread Alexey Bader via cfe-commits
bader added inline comments.


Comment at: lib/Sema/SemaChecking.cpp:6773-6774
@@ -6772,4 +7016,2 @@
 
-namespace {
-
 /// Structure recording the 'active' range of an integer-valued

The con of this change - it will export all the symbols from this unnamed 
namespace.
The better approach would be to move the code that uses CheckImplicitConversion 
method below this namespace.


http://reviews.llvm.org/D20249



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21603: [include-fixer] Add missing namespace qualifiers after inserting a missing header.

2016-07-01 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 62473.
hokein marked 5 inline comments as done.
hokein added a comment.

Fix review comments.


http://reviews.llvm.org/D21603

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixerContext.h
  include-fixer/SymbolIndexManager.cpp
  include-fixer/SymbolIndexManager.h
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/tool/ClangIncludeFixer.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -50,7 +50,7 @@
 }
 
 static std::string runIncludeFixer(
-StringRef Code,
+StringRef Code, bool FixNamespaceQualifiers = false,
 const std::vector &ExtraArgs = std::vector()) {
   std::vector Symbols = {
   SymbolInfo("string", SymbolInfo::SymbolKind::Class, "", 1,
@@ -82,14 +82,17 @@
   IncludeFixerContext FixerContext;
   IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContext, "llvm");
 
-  runOnCode(&Factory, Code, "input.cc", ExtraArgs);
-  if (FixerContext.Headers.empty())
+  std::string FakeFileName = "input.cc";
+  runOnCode(&Factory, Code, FakeFileName, ExtraArgs);
+  if (FixerContext.getMatchedSymbols().empty())
 return Code;
   tooling::Replacements Replacements =
   clang::include_fixer::createInsertHeaderReplacements(
-  Code, "input.cc", FixerContext.Headers.front());
+  Code, FakeFileName, FixerContext.getHeaders().front());
   clang::RewriterTestContext Context;
-  clang::FileID ID = Context.createInMemoryFile("input.cc", Code);
+  clang::FileID ID = Context.createInMemoryFile(FakeFileName, Code);
+  if (FixNamespaceQualifiers && FixerContext.getSymbolRange().getLength() > 0)
+Replacements.insert(FixerContext.createSymbolReplacement(FakeFileName, 0));
   clang::tooling::applyAllReplacements(Replacements, Context.Rewrite);
   return Context.getRewrittenText(ID);
 }
@@ -137,19 +140,23 @@
 TEST(IncludeFixer, MinimizeInclude) {
   std::vector IncludePath = {"-Idir/"};
   EXPECT_EQ("#include \"otherdir/qux.h\"\na::b::foo bar;\n",
-runIncludeFixer("a::b::foo bar;\n", IncludePath));
+runIncludeFixer("a::b::foo bar;\n",
+/*FixNamespaceQualifiers=*/true, IncludePath));
 
   IncludePath = {"-isystemdir"};
   EXPECT_EQ("#include \na::b::foo bar;\n",
-runIncludeFixer("a::b::foo bar;\n", IncludePath));
+runIncludeFixer("a::b::foo bar;\n",
+/*FixNamespaceQualifiers=*/true, IncludePath));
 
   IncludePath = {"-iquotedir"};
   EXPECT_EQ("#include \"otherdir/qux.h\"\na::b::foo bar;\n",
-runIncludeFixer("a::b::foo bar;\n", IncludePath));
+runIncludeFixer("a::b::foo bar;\n",
+/*FixNamespaceQualifiers=*/true, IncludePath));
 
   IncludePath = {"-Idir", "-Idir/otherdir"};
   EXPECT_EQ("#include \"qux.h\"\na::b::foo bar;\n",
-runIncludeFixer("a::b::foo bar;\n", IncludePath));
+runIncludeFixer("a::b::foo bar;\n",
+/*FixNamespaceQualifiers=*/true, IncludePath));
 }
 
 TEST(IncludeFixer, NestedName) {
@@ -221,6 +228,44 @@
 runIncludeFixer("a::Vector v;"));
 }
 
+TEST(IncludeFixer, FixNamespaceQualifiers) {
+  EXPECT_EQ("#include \"bar.h\"\na::b::bar b;\n",
+runIncludeFixer("b::bar b;\n", /*FixNamespaceQualifiers=*/true));
+  EXPECT_EQ("#include \"bar.h\"\na::b::bar b;\n",
+runIncludeFixer("a::b::bar b;\n", /*FixNamespaceQualifiers=*/true));
+  EXPECT_EQ("#include \"bar.h\"\na::b::bar b;\n",
+runIncludeFixer("bar b;\n", /*FixNamespaceQualifiers=*/true));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar b;\n}\n",
+runIncludeFixer("namespace a {\nb::bar b;\n}\n",
+/*FixNamespaceQualifiers==*/true));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar b;\n}\n",
+runIncludeFixer("namespace a {\nbar b;\n}\n",
+/*FixNamespaceQualifiers==*/true));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nnamespace b{\nbar b;\n}\n}\n",
+runIncludeFixer("namespace a {\nnamespace b{\nbar b;\n}\n}\n",
+/*FixNamespaceQualifiers==*/true));
+  EXPECT_EQ("c::b::bar b;\n",
+runIncludeFixer("c::b::bar b;\n", /*FixNamespaceQualifiers=*/true));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar b;\n}\n",
+runIncludeFixer("namespace c {\nbar b;\n}\n",
+/*FixNamespaceQualifiers=*/true));
+
+  EXPECT_EQ(
+  "#include \"color.h\"\nint test = a::b::Green;\n",
+  runIncludeFixer("int test = Green;\n", /*FixNamespaceQualifiers=*/true));
+  EXPECT_EQ("#include \"color.h\"\nnamespace d {\nint test = a::b::Green;\n}\n",
+runIncludeFi

Re: [PATCH] D21603: [include-fixer] Add missing namespace qualifiers after inserting a missing header.

2016-07-01 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: include-fixer/IncludeFixer.cpp:258
@@ +257,3 @@
+
+// Query the symbol based on C++ name Lookup rules.
+// Firstly, lookup the identifier with scoped namespace contexts; If fails,

djasper wrote:
> Could you add something about this to the CL description? Or actually, I 
> think this is very separate from fixing the namespace qualifiers. Can we move 
> this part to a different patch?
> 
> Or am I missing something so that one cannot go without the other? 
> Fundamentally, this seems to be doing two things:
> 1) Insert namespace qualifiers if they are missing.
> 2) Take existing namespace qualifiers to ensure we aren't looking up the 
> wrong symbol.
It's not introduced by this patch. Actually it moves from `query` function 
caller to the function body. Why we make this change? Because we need to save 
the scoped qualifiers of the symbol, so that include-fixer can know how to 
create a **correct** qualifiers for the symbol.


Comment at: include-fixer/IncludeFixerContext.h:31
@@ +30,3 @@
+MatchedSymbols(Symbols), SymbolRange(Range) {
+// Deduplicate headers, so that we don't want to suggest the same header
+// twice.

djasper wrote:
> This again seems like something that is unrelated to what the patch is 
> actually meant to do. Can we split this into a separate patch?
This is also a move from `rankByPopularity` in `SymbolIndexManager.cpp`.


Comment at: unittests/include-fixer/IncludeFixerTest.cpp:144
@@ -141,1 +143,3 @@
+runIncludeFixer("a::b::foo bar;\n",
+/*FixNamespaceQualifiers=*/false, IncludePath));
 

djasper wrote:
> Do you need to set FixNamespaceQualifiers to false here?
No need to. Both are OK. Change to `true` here.


http://reviews.llvm.org/D21603



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-07-01 Thread Aleksei Sidorin via cfe-commits
a.sidorin marked 5 inline comments as done.
a.sidorin added a comment.

Thank you for your comments! And sorry for late response after pinging.



Comment at: lib/AST/ASTImporter.cpp:2518-2519
@@ +2517,4 @@
+Importer.Import(D->getMessage()));
+  if (!Message)
+return nullptr;
+

sepavloff wrote:
> Since C++17 `static_assert` may be used without message, so null pointer here 
> is not an error.
I will modify the check, but may be we should check the language standard as 
well?


Comment at: lib/AST/ASTImporter.cpp:3363
@@ +3362,3 @@
+
+  // Determine whether we've already imported this decl.
+  // FriendDecl is not a NamedDecl so we cannot use localUncachedLookup.

sepavloff wrote:
> Maybe it is more natural to put this check into `bool 
> IsStructurallyEquivalent(StructuralEquivalenceContext &Context, RecordDecl 
> *D1, RecordDecl *D2)`? If records are equivalent, existing decl can be used 
> as a result of import, if not - entire record must be recreated anyway.
Sorry, it seems like I don't completely understand your idea. Won't 
`IsStructurallyEquivalent()` do an additional amount of work?


http://reviews.llvm.org/D14326



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-07-01 Thread Aleksei Sidorin via cfe-commits
a.sidorin marked 2 inline comments as done.


Comment at: lib/AST/ASTImporter.cpp:3363
@@ +3362,3 @@
+
+  // Determine whether we've already imported this decl.
+  // FriendDecl is not a NamedDecl so we cannot use localUncachedLookup.

a.sidorin wrote:
> sepavloff wrote:
> > Maybe it is more natural to put this check into `bool 
> > IsStructurallyEquivalent(StructuralEquivalenceContext &Context, RecordDecl 
> > *D1, RecordDecl *D2)`? If records are equivalent, existing decl can be used 
> > as a result of import, if not - entire record must be recreated anyway.
> Sorry, it seems like I don't completely understand your idea. Won't 
> `IsStructurallyEquivalent()` do an additional amount of work?
And also, even if they are equivalent, we should search for the equivalent 
FriendDecl to return it.


http://reviews.llvm.org/D14326



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-07-01 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 62474.
a.sidorin added a comment.

Fix some issues pointed by Serge Pavlov.
Serge: putting a check of FriendDecls to `IsStructurallyEquivalent()` seems 
like a good idea for me, but we need some additional changes for it.  
`CXXRecodeDecl::getFirstDecl()` is private and `StructuralEquivalenceContext()` 
is located in an anonymous namespace so we cannot forward-declare it in 
DeclCXX.h to make it friend. We can move  `StructuralEquivalenceContext()` out 
of anonymous namespace, however. What do you think?


http://reviews.llvm.org/D14326

Files:
  include/clang/AST/ASTImporter.h
  include/clang/AST/DeclFriend.h
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/class3.cpp
  test/ASTMerge/Inputs/exprs3.cpp
  test/ASTMerge/class2.cpp
  test/ASTMerge/exprs.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -456,5 +456,48 @@
 }
 
 
+const internal::VariadicDynCastAllOfMatcher vaArgExpr;
+
+/// \brief Matches the decayed type, whose original type matches \c InnerMatcher
+AST_MATCHER_P(DecayedType, hasOriginalType, internal::Matcher,
+  InnerType) {
+  return InnerType.matches(Node.getOriginalType(), Finder, Builder);
+}
+
+TEST(ImportExpr, ImportVAArgExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+testImport(
+  "void declToImport(__builtin_va_list list, ...) {"
+  "  (void)__builtin_va_arg(list, int); }",
+  Lang_CXX, "", Lang_CXX, Verifier,
+  functionDecl(
+hasParameter(0,
+ varDecl(
+   hasName("list"),
+   hasType(
+ decayedType(
+   hasOriginalType(
+ typedefType(
+   hasDeclaration(
+ typedefDecl(
+   hasName("__builtin_va_list"),
+   hasType(
+ constantArrayType(
+   hasSize(1),
+   hasElementType(
+ qualType(
+   recordType(),
+   asString("struct __va_list_tag"
+  ),
+hasBody(
+  compoundStmt(
+has(
+  cStyleCastExpr(
+hasSourceExpression(
+  vaArgExpr();
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: test/ASTMerge/exprs.cpp
===
--- /dev/null
+++ test/ASTMerge/exprs.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -emit-pch -o %t.1.ast %S/Inputs/exprs3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+static_assert(Ch1 == 'a');
+static_assert(Ch2 == 'b');
+static_assert(Ch3 == 'c');
+
+static_assert(Ch4 == L'd');
+static_assert(Ch5 == L'e');
+static_assert(Ch6 == L'f');
+
+static_assert(C1 == 12);
+static_assert(C2 == 13);
+
+static_assert(C3 == 12);
+static_assert(C4 == 13);
+
+static_assert(C5 == 22L);
+static_assert(C6 == 23L);
+
+static_assert(C7 == 66LL);
+static_assert(C8 == 67ULL);
+
+static_assert(bval1 == true);
+static_assert(bval2 == false);
+
+static_assert(ExpressionTrait == false);
+
+static_assert(ArrayRank == 2);
+static_assert(ArrayExtent == 20);
+
+void testImport(int *x, const S1 &cs1, S1 &s1) {
+  testNewThrowDelete();
+  testArrayElement(nullptr, 12);
+  testTernaryOp(0, 1, 2);
+  testConstCast(cs1);
+  testStaticCast(s1);
+  testReinterpretCast(s1);
+  testDynamicCast(s1);
+  testScalarInit(42);
+  testOffsetOf();
+  testDefaultArg(12);
+  useTemplateType();
+}
Index: test/ASTMerge/class2.cpp
===
--- /dev/null
+++ test/ASTMerge/class2.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -emit-pch -o %t.1.ast %S/Inputs/class3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+class C3 {
+  int method_1(C2 *x) {
+return x->x;
+  }
+};
Index: test/ASTMerge/Inputs/exprs3.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/exprs3.cpp
@@ -0,0 +1,131 @@
+// Integer literals
+const char Ch1 = 'a';
+const signed char Ch2 = 'b';
+const unsigned char Ch3 = 'c';
+
+const wchar_t Ch4 = L'd';
+const signed wchar_t Ch5 = L'e';
+con

Re: RFC: Default language standard mode policy

2016-07-01 Thread Andrey Bokhanko via cfe-commits
It doesn't break anything for us and in general the proposal make sense to
me.

Yours,
Andrey
=
Software Engineer
Intel Compiler Team


On Wed, Jun 29, 2016 at 10:09 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi all!
>
> I'd like to establish a policy for Clang's default language standard (if
> none is specified with -std), as follows:
>
>   Clang defaults to the most recent published standard for the selected
> language that it fully implements.
>
> The practical impact of this is that clang++ will default to C++14 for C++
> compilations (for version 3.9 onwards) and will default to C++17 once our
> implementation support is complete and the standard is published (whichever
> happens later).
>
> I'd suggest that we apply the same policy for clang-cl, but if it's
> important that we enable a not-yet-fully-implemented standard for cl
> compatibility, that seems reasonable.
>
> The question of whether the default mode for the GCC-compatible driver
> should be -std=gnuXXX or -std=cXXX is separate, but also likely worth
> discussing. Enabling GNU keywords by default is a very odd choice, and if
> we believe we can change our defaults without breaking the world then this
> seems like a good time to do so.
>
> I also intend to make explicit in our documentation that our -std=XXX flag
> enables the selected standard, *plus all relevant issues in Defect Report
> status from the relevant language committee* (it doesn't make sense to
> support a language without its bugfixes).
>
> Thoughts?
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping?

Any comment on this?

Thank you very much.


http://reviews.llvm.org/D20561



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-07-01 Thread Anastasia Stulova via cfe-commits
Anastasia updated this revision to Diff 62485.
Anastasia marked an inline comment as done.
Anastasia added a comment.

Undo removal of anonymous namespace and move the position of function 
definition instead.


http://reviews.llvm.org/D20249

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/opencl-c.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaInit.cpp
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/clang-builtin-version.cl
  test/SemaOpenCL/to_addr_builtin.cl

Index: test/SemaOpenCL/to_addr_builtin.cl
===
--- test/SemaOpenCL/to_addr_builtin.cl
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -10,43 +10,44 @@
 
   glob = to_global(glob, loc);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{implicit declaration of function 'to_global' is invalid in C99}}
+  // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
 #else
-  // expected-error@-4{{invalid number of arguments to function: 'to_global'}}
+  // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
 #endif
 
   int x;
   glob = to_global(x);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
 #else
   // expected-error@-4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}}
 #endif
 
   glob = to_global(con);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
 #else
   // expected-error@-4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}}
 #endif
 
   glob = to_global(con_typedef);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
 #else
   // expected-error@-4{{invalid argument con_typedef to function: 'to_global', expecting a generic pointer argument}}
 #endif
 
   loc = to_global(glob);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
 #else
   // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
 #endif
 
   global char *glob_c = to_global(loc);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{incompatible integer to pointer conversion initializing '__global char *' with an expression of type 'int'}}
 #else
   // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}}
 #endif
Index: test/SemaOpenCL/clang-builtin-version.cl
===
--- /dev/null
+++ test/SemaOpenCL/clang-builtin-version.cl
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -fblocks -verify -pedantic -fsyntax-only -ferror-limit 100
+
+// Confirm CL2.0 Clang builtins are not available in earlier versions
+
+kernel void dse_builtins() {
+  int tmp;
+  enqueue_kernel(tmp, tmp, tmp, ^(void) { // expected-warning{{implicit declaration of function 'enqueue_kernel' is invalid in C99}}
+return;
+  });
+  unsigned size = get_kernel_work_group_size(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_work_group_size' is invalid in C99}}
+return;
+  });
+  size = get_kernel_preferred_work_group_size_multiple(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_preferred_work_group_size_multiple' is invalid in C99}}
+return;
+  });
+}
+
+void pipe_builtins() {
+  int tmp;
+
+  read_pipe(tmp, tmp);  // expected-warning{{implicit declaration of function 'read_pipe' is invalid in C99}}
+  write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'write_pipe' is invalid in C99}}
+
+  reserve_read_pipe(tmp, tmp);  // expected-warning{{implicit declaration of function 'reserve_read_pipe' is invalid in C99}}
+  reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'reserve_write_pipe' is invalid in C99}}
+
+  work_group_reserve_read_pipe(tmp, tmp);  // expected-warning{{implicit declaration of function 'w

Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-07-01 Thread Anastasia Stulova via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added a comment.

http://reviews.llvm.org/D20249



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21385: Adjust Registry interface to not require plugins to export a registry

2016-07-01 Thread John Brawn via cfe-commits
john.brawn added a comment.

In http://reviews.llvm.org/D21385#471807, @Ilod wrote:

> I gave up after this. I have Pyhton 3.5 64 bits, and was building clang 
> 32-bits on Windows with Visual Studio 2015 Update 2.


python 3 isn't supported when building llvm/clang, according to llvm's 
CMakeLists.txt.

> If that's all, I suppose it's better to have your limitation to plugin 
> support rather than a full support which will bug if you call a function that 
> accesses a static member.

> 

> (By the way, the previous attempt works fine, it was reverted because of a 
> mingw crash which can be fixed by the patch http://reviews.llvm.org/D18847)

> 

> However, couldn't we enable by default LLVM_EXPORT_SYMBOLS_FOR_PLUGINS on the 
> platforms/compilers which doesn't currently support the plugins? Having 
> plugins only work on custom builds of clang seems to be against the main use 
> of plugins. (If testing is the only problem, I would gladly test it on 
> Windows with mingw, and maybe Mac if needed)


After this patch goes in I plan to email llvm-dev/cfe-dev to see if people 
think that's a good idea.

> Also, could you add in the documentation (cfe/trunk/docs/ClangPlugins.rst) 
> what are the limitations/setup needed to make an out-of-tree plugin?


Will do.


Repository:
  rL LLVM

http://reviews.llvm.org/D21385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-07-01 Thread Alexey Bader via cfe-commits
bader added a comment.

LGTM!
Thanks a lot for working on this.


http://reviews.llvm.org/D20249



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21385: Adjust Registry interface to not require plugins to export a registry

2016-07-01 Thread Rudy Pons via cfe-commits
Ilod added a comment.

In http://reviews.llvm.org/D21385#472268, @john.brawn wrote:

> In http://reviews.llvm.org/D21385#471807, @Ilod wrote:
>
> > I gave up after this. I have Pyhton 3.5 64 bits, and was building clang 
> > 32-bits on Windows with Visual Studio 2015 Update 2.
>
>
> python 3 isn't supported when building llvm/clang, according to llvm's 
> CMakeLists.txt.


Oops, will try again tonight with Python 2.
http://clang.llvm.org/get_started.html doesn't specify a version of Python, the 
LLVM webpage only say >= 2.7, and I ran the tests without any problem with 
Python 3 (but maybe some tests were automatically skipped?). Also, Python is 
also marked as only necessary to build the tests, which is no longer true with 
your script.


Repository:
  rL LLVM

http://reviews.llvm.org/D21385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21619: [Sema] Implement C++14's DR1579: Prefer moving id-expression out of functions

2016-07-01 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a subscriber: mehdi_amini.
mehdi_amini added a comment.

Is it also PR23849? Is it dup with PR27785?


Repository:
  rL LLVM

http://reviews.llvm.org/D21619



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21907: [AArch64] fix profiling with GNU LINUX on Aarch64

2016-07-01 Thread Brian Rzycki via cfe-commits
brzycki added a comment.

I realized after posting this I made a mistake in compilation and test. Because 
of this clang wasn't properly tested. This patch actually causes "ninja 
check-all" to fail for non-GNU AArch64 Linux targets.

I am able to link with clang using -pg -meabi gnu src.c

I'd like to withdraw this patch from revew.


http://reviews.llvm.org/D21907



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21706: [libcxx] refactor for throw

2016-07-01 Thread Noel Grandin via cfe-commits
grandinj added inline comments.


Comment at: include/array:209
@@ -211,7 +208,3 @@
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+__libcpp_throw(out_of_range("array::at"));
 return __elems_[__n];

the error message of the assert was perhaps better?


Comment at: include/array:219
@@ -225,7 +218,3 @@
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+__libcpp_throw(out_of_range("array::at"));
 return __elems_[__n];

the error message of the assert was perhaps better?


Comment at: include/experimental/dynarray:279
@@ -286,7 +278,3 @@
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("dynarray::at");
-#else
-assert(!"dynarray::at out_of_range");
-#endif
+__libcpp_throw(out_of_range("dynarray::at"));
 }

the error message of the assert was perhaps better?


Comment at: include/experimental/dynarray:291
@@ -302,7 +290,3 @@
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("dynarray::at");
-#else
-assert(!"dynarray::at out_of_range");
-#endif
+__libcpp_throw(out_of_range("dynarray::at"));
 }

ditto


Comment at: include/map:1446
@@ -1446,4 +1445,3 @@
 if (__child == nullptr)
-throw out_of_range("map::at:  key not found");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+__libcpp_throw(out_of_range("map::at:  key not found"));
 return static_cast<__node_pointer>(__child)->__value_.__cc.second;

looks like extra spaces in this message (which was there in the original, I 
know)


Comment at: include/map:1457
@@ -1459,4 +1456,3 @@
 if (__child == nullptr)
-throw out_of_range("map::at:  key not found");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+__libcpp_throw(out_of_range("map::at:  key not found"));
 return static_cast<__node_pointer>(__child)->__value_.__cc.second;

extra spaces here too


http://reviews.llvm.org/D21706



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21678: Fix For pr28288 - Error message in shift of vector values

2016-07-01 Thread Vladimir Yakovlev via cfe-commits
vbyakovl updated this revision to Diff 62464.

http://reviews.llvm.org/D21678

Files:
  llvm/tools/clang/lib/Sema/SemaExpr.cpp
  llvm/tools/clang/test/Sema/shift.c

Index: llvm/tools/clang/lib/Sema/SemaExpr.cpp
===
--- llvm/tools/clang/lib/Sema/SemaExpr.cpp
+++ llvm/tools/clang/lib/Sema/SemaExpr.cpp
@@ -8592,11 +8592,10 @@
 << RHS.get()->getSourceRange();
 }
 
-/// \brief Return the resulting type when an OpenCL vector is shifted
+/// \brief Return the resulting type when a vector is shifted
 ///by a scalar or vector shift amount.
-static QualType checkOpenCLVectorShift(Sema &S,
-   ExprResult &LHS, ExprResult &RHS,
-   SourceLocation Loc, bool IsCompAssign) {
+static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
+ SourceLocation Loc, bool IsCompAssign) {
   // OpenCL v1.1 s6.3.j says RHS can be a vector only if LHS is a vector.
   if (!LHS.get()->getType()->isVectorType()) {
 S.Diag(Loc, diag::err_shift_rhs_only_vector)
@@ -8636,9 +8635,8 @@
   }
 
   if (RHSVecTy) {
-// OpenCL v1.1 s6.3.j says that for vector types, the operators
-// are applied component-wise. So if RHS is a vector, then ensure
-// that the number of elements is the same as LHS...
+// For vector types, the operators are applied component-wise. So if RHS is
+// a vector, then ensure that the number of elements is the same as LHS...
 if (RHSVecTy->getNumElements() != LHSVecTy->getNumElements()) {
   S.Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
 << LHS.get()->getType() << RHS.get()->getType()
@@ -8664,23 +8662,18 @@
   // Vector shifts promote their scalar inputs to vector type.
   if (LHS.get()->getType()->isVectorType() ||
   RHS.get()->getType()->isVectorType()) {
-if (LangOpts.OpenCL)
-  return checkOpenCLVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
 if (LangOpts.ZVector) {
   // The shift operators for the z vector extensions work basically
-  // like OpenCL shifts, except that neither the LHS nor the RHS is
+  // like general shifts, except that neither the LHS nor the RHS is
   // allowed to be a "vector bool".
   if (auto LHSVecType = LHS.get()->getType()->getAs())
 if (LHSVecType->getVectorKind() == VectorType::AltiVecBool)
   return InvalidOperands(Loc, LHS, RHS);
   if (auto RHSVecType = RHS.get()->getType()->getAs())
 if (RHSVecType->getVectorKind() == VectorType::AltiVecBool)
   return InvalidOperands(Loc, LHS, RHS);
-  return checkOpenCLVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
 }
-return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
-   /*AllowBothBool*/true,
-   /*AllowBoolConversions*/false);
+return checkVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
   }
 
   // Shifts don't perform usual arithmetic conversions, they just do integer
Index: llvm/tools/clang/test/Sema/shift.c
===
--- llvm/tools/clang/test/Sema/shift.c
+++ llvm/tools/clang/test/Sema/shift.c
@@ -67,3 +67,24 @@
 (void) (x >> 80); // no-warning
   (void) (x >> 80); // expected-warning {{shift count >= width of type}}
 }
+
+typedef unsigned vec16 __attribute__ ((vector_size (16)));
+typedef unsigned vec8 __attribute__ ((vector_size (8)));
+
+void
+vect_shift_1 (vec16 *x)
+{
+   *x = *x << 4 ;
+}
+
+void
+vect_shift_2 (vec16 *x,vec16 y)
+{
+   *x = *x << y ;
+}
+
+void
+vect_shift_3 (vec16 *x,vec8 y)
+{
+   *x = *x << y ; // expected-error {{vector operands do not have the same 
number of elements}}
+}


Index: llvm/tools/clang/lib/Sema/SemaExpr.cpp
===
--- llvm/tools/clang/lib/Sema/SemaExpr.cpp
+++ llvm/tools/clang/lib/Sema/SemaExpr.cpp
@@ -8592,11 +8592,10 @@
 << RHS.get()->getSourceRange();
 }
 
-/// \brief Return the resulting type when an OpenCL vector is shifted
+/// \brief Return the resulting type when a vector is shifted
 ///by a scalar or vector shift amount.
-static QualType checkOpenCLVectorShift(Sema &S,
-   ExprResult &LHS, ExprResult &RHS,
-   SourceLocation Loc, bool IsCompAssign) {
+static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
+ SourceLocation Loc, bool IsCompAssign) {
   // OpenCL v1.1 s6.3.j says RHS can be a vector only if LHS is a vector.
   if (!LHS.get()->getType()->isVectorType()) {
 S.Diag(Loc, diag::err_shift_rhs_only_vector)
@@ -8636,9 +8635,8 @@
   }
 
   if (RHSVecTy) {
-// OpenCL v1.1 s6.3.j says that for vector types, the operators
-// are applied component-wise. So if RHS is a vector, then ensure
-// that the number of elements is th

r274348 - Add postorder traversal support to the RecursiveASTVisitor.

2016-07-01 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jul  1 08:28:31 2016
New Revision: 274348

URL: http://llvm.org/viewvc/llvm-project?rev=274348&view=rev
Log:
Add postorder traversal support to the RecursiveASTVisitor.

This feature needs to be explicitly enabled by overriding 
shouldTraversePostOrder()
as it has performance drawbacks for the iterative Stmt-traversal.

Patch by Raphael Isemann!

Reviewed by Richard Smith and Benjamin Kramer.

Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/unittests/AST/CMakeLists.txt

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=274348&r1=274347&r2=274348&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Jul  1 08:28:31 2016
@@ -72,8 +72,8 @@ namespace clang {
   return false;
\
   } while (0)
 
-/// \brief A class that does preorder depth-first traversal on the
-/// entire Clang AST and visits each node.
+/// \brief A class that does preordor or postorder
+/// depth-first traversal on the entire Clang AST and visits each node.
 ///
 /// This class performs three distinct tasks:
 ///   1. traverse the AST (i.e. go to each node);
@@ -133,6 +133,10 @@ namespace clang {
 /// to return true, in which case all known implicit and explicit
 /// instantiations will be visited at the same time as the pattern
 /// from which they were produced.
+///
+/// By default, this visitor preorder traverses the AST. If postorder traversal
+/// is needed, the \c shouldTraversePostOrder method needs to be overriden
+/// to return \c true.
 template  class RecursiveASTVisitor {
 public:
   /// A queue used for performing data recursion over statements.
@@ -158,6 +162,9 @@ public:
   /// code, e.g., implicit constructors and destructors.
   bool shouldVisitImplicitCode() const { return false; }
 
+  /// \brief Return whether this visitor should traverse post-order.
+  bool shouldTraversePostOrder() const { return false; }
+
   /// \brief Recursively visit a statement or expression, by
   /// dispatching to Traverse*() based on the argument's dynamic type.
   ///
@@ -349,7 +356,7 @@ public:
   bool TraverseUnary##NAME(UnaryOperator *S,   
\
DataRecursionQueue *Queue = nullptr) {  
\
 TRY_TO(WalkUpFromUnary##NAME(S));  
\
-TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  
  \
+TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  
\
 return true;   
\
   }
\
   bool WalkUpFromUnary##NAME(UnaryOperator *S) {   
\
@@ -367,9 +374,10 @@ public:
 // (they're all opcodes in BinaryOperator) but do have visitors.
 #define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE)   
\
   bool TraverseBin##NAME(BINOP_TYPE *S, DataRecursionQueue *Queue = nullptr) { 
\
-TRY_TO(WalkUpFromBin##NAME(S));
\
-TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS());  
  \
-TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS());  
  \
+if (!getDerived().shouldTraversePostOrder())   
\
+  TRY_TO(WalkUpFromBin##NAME(S));  
\
+TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS());  
\
+TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS());  
\
 return true;   
\
   }
\
   bool WalkUpFromBin##NAME(BINOP_TYPE *S) {
\
@@ -499,6 +507,7 @@ private:
   bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node);
 
   bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
+  bool PostVisitStmt(Stmt *S);
 };
 
 template 
@@ -556,6 +565,24 @@ bool RecursiveASTVisitor::dataT
 
 #undef DISPATCH_STMT
 
+
+template 
+bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) {
+  switch (S->getStmtClass()) {
+  case Stmt::NoStmtClass:
+break;
+#define ABSTRACT_STMT(STMT)
+#define STMT(CLASS, PARENT)
\
+  case Stmt::CLASS##Class: 
\
+TRY_TO(WalkUpFrom##CLASS(static_cast(S))); break;
+#include "clang/AST/StmtNodes.inc"
+  }
+
+  return true;
+}
+
+#undef DISPATCH_STMT
+
 template 
 bool RecursiveASTVisitor::TraverseStmt(Stmt *S,
 

r274349 - Add forgotten test to r274348.

2016-07-01 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jul  1 08:30:08 2016
New Revision: 274349

URL: http://llvm.org/viewvc/llvm-project?rev=274349&view=rev
Log:
Add forgotten test to r274348.

Added:
cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp

Added: cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp?rev=274349&view=auto
==
--- cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp (added)
+++ cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp Fri Jul  1 08:30:08 2016
@@ -0,0 +1,123 @@
+//===- unittests/AST/PostOrderASTVisitor.cpp - Declaration printer tests 
--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains tests for the post-order traversing functionality
+// of RecursiveASTVisitor.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Tooling/Tooling.h"
+
+using namespace clang;
+
+namespace {
+
+  class RecordingVisitor
+: public RecursiveASTVisitor {
+
+bool VisitPostOrder;
+  public:
+explicit RecordingVisitor(bool VisitPostOrder)
+  : VisitPostOrder(VisitPostOrder) {
+}
+
+// List of visited nodes during traversal.
+std::vector VisitedNodes;
+
+bool shouldTraversePostOrder() const { return VisitPostOrder; }
+
+bool VisitBinaryOperator(BinaryOperator *Op) {
+  VisitedNodes.push_back(Op->getOpcodeStr());
+  return true;
+}
+
+bool VisitIntegerLiteral(IntegerLiteral *Lit) {
+  VisitedNodes.push_back(Lit->getValue().toString(10, false));
+  return true;
+}
+
+bool VisitVarDecl(VarDecl* D) {
+  VisitedNodes.push_back(D->getNameAsString());
+  return true;
+}
+
+bool VisitCXXMethodDecl(CXXMethodDecl *D) {
+  VisitedNodes.push_back(D->getQualifiedNameAsString());
+  return true;
+}
+
+bool VisitReturnStmt(Stmt *S) {
+  VisitedNodes.push_back("return");
+  return true;
+}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {
+  VisitedNodes.push_back(Declaration->getQualifiedNameAsString());
+  return true;
+}
+
+bool VisitTemplateTypeParmType(TemplateTypeParmType *T) {
+  VisitedNodes.push_back(T->getDecl()->getQualifiedNameAsString());
+  return true;
+}
+  };
+
+}
+
+TEST(RecursiveASTVisitor, PostOrderTraversal) {
+  auto ASTUnit = tooling::buildASTFromCode(
+"template  class A {"
+"  class B {"
+"int foo() { while(4) { int i = 9; } return (1 + 3) + 2; }"
+"  };"
+"};"
+  );
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+  // We traverse the translation unit and store all
+  // visited nodes.
+  RecordingVisitor Visitor(true);
+  Visitor.TraverseTranslationUnitDecl(TU);
+
+  std::vector expected = {
+"4", "9", "i", "1", "3", "+", "2", "+", "return", "A::B::foo", "A::B", 
"A", "A::T"
+  };
+  // Compare the list of actually visited nodes
+  // with the expected list of visited nodes.
+  ASSERT_EQ(expected.size(), Visitor.VisitedNodes.size());
+  for (std::size_t I = 0; I < expected.size(); I++) {
+ASSERT_EQ(expected[I], Visitor.VisitedNodes[I]);
+  }
+}
+
+TEST(RecursiveASTVisitor, NoPostOrderTraversal) {
+  auto ASTUnit = tooling::buildASTFromCode(
+"template  class A {"
+"  class B {"
+"int foo() { return 1 + 2; }"
+"  };"
+"};"
+  );
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+  // We traverse the translation unit and store all
+  // visited nodes.
+  RecordingVisitor Visitor(false);
+  Visitor.TraverseTranslationUnitDecl(TU);
+
+  std::vector expected = {
+"A", "A::B", "A::B::foo", "return", "+", "1", "2", "A::T"
+  };
+  // Compare the list of actually visited nodes
+  // with the expected list of visited nodes.
+  ASSERT_EQ(expected.size(), Visitor.VisitedNodes.size());
+  for (std::size_t I = 0; I < expected.size(); I++) {
+ASSERT_EQ(expected[I], Visitor.VisitedNodes[I]);
+  }
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20382: Add postorder support to RecursiveASTVisitor

2016-07-01 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r274348 and r274349.


http://reviews.llvm.org/D20382



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12834: add gcc abi_tag support

2016-07-01 Thread James Y Knight via cfe-commits
jyknight added a subscriber: jyknight.
jyknight commandeered this revision.
jyknight added a reviewer: stbuehler.
jyknight added a comment.

I believe this was fully superseded by
http://reviews.llvm.org/D17567: [GCC] PR23529 Sema part of attrbute abi_tag 
support
http://reviews.llvm.org/D18035: [GCC] PR23529 Mangler part of attrbute abi_tag 
support
which are now committed. So, abandoning.


Repository:
  rL LLVM

http://reviews.llvm.org/D12834



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21510: [libc++] Check hash before calling __hash_table key_eq function

2016-07-01 Thread Kwasi Mensah via cfe-commits
Thanks. For future reference, do these benchmarking tests live some place
where I can run them myself in the future?

On Thu, Jun 30, 2016 at 2:15 AM, Eric Fiselier  wrote:

> EricWF accepted this revision.
> EricWF added a comment.
> This revision is now accepted and ready to land.
>
> LGTM. I benchmarked the change against different key types and:
>
> 1. The change doesn't have a large detrimental impact when the key
> equality is as expensive as hash equality. I benchmarked
> std::unordered_set.find(...) at 27ns and 29ns before and after the
> change for a load factor >= 3.5, and 15ns vs 17 ns when the load factor is
> less than one.
>
> 2. The change has a large positive impact when the load factor is > 1 and
> where key equality is more expensive than hash equality. For strings of
> size 1024 that only differed in the last characters I noticed a change of
> 880ns to 650ns. for a load factor >= 3.5.
>
> 3. This change has a slight positive inpact when the load factor is < 1.
> For the same string inputs (mentioned above)  I  saw timings of 661ns and
> 623ns before and after.
>
>
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D21510
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21510: [libc++] Check hash before calling __hash_table key_eq function

2016-07-01 Thread Kwasi Mensah via cfe-commits
kmensah added a comment.

Thanks. For future reference, do these benchmarking tests live some place
where I can run them myself in the future?


Repository:
  rL LLVM

http://reviews.llvm.org/D21510



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r274352 - [OpenMP] Issue warning if a simd construct nested inside another simd

2016-07-01 Thread Kelvin Li via cfe-commits
Author: kli
Date: Fri Jul  1 09:30:25 2016
New Revision: 274352

URL: http://llvm.org/viewvc/llvm-project?rev=274352&view=rev
Log:
[OpenMP] Issue warning if a simd construct nested inside another simd
construct

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=274352&r1=274351&r2=274352&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul  1 09:30:25 
2016
@@ -8318,6 +8318,9 @@ def err_omp_expected_int_param : Error<
   "expected a reference to an integer-typed parameter">;
 def err_omp_at_least_one_motion_clause_required : Error<
   "expected at least one 'to' clause or 'from' clause specified to '#pragma 
omp target update'">;
+def warn_omp_nesting_simd : Warning<
+  "OpenMP only allows an ordered construct with the simd clause nested in a 
simd construct">,
+  InGroup;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=274352&r1=274351&r2=274352&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jul  1 09:30:25 2016
@@ -2940,15 +2940,19 @@ static bool CheckNestingOfRegions(Sema &
   ShouldBeInTargetRegion,
   ShouldBeInTeamsRegion
 } Recommend = NoRecommend;
-if (isOpenMPSimdDirective(ParentRegion) && CurrentRegion != OMPD_ordered &&
-CurrentRegion != OMPD_simd) {
+if (isOpenMPSimdDirective(ParentRegion) && CurrentRegion != OMPD_ordered) {
   // OpenMP [2.16, Nesting of Regions]
   // OpenMP constructs may not be nested inside a simd region.
   // OpenMP [2.8.1,simd Construct, Restrictions]
-  // An ordered construct with the simd clause is the only OpenMP construct
-  // that can appear in the simd region.
-  SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_simd);
-  return true;
+  // An ordered construct with the simd clause is the only OpenMP
+  // construct that can appear in the simd region.
+  // Allowing a SIMD consruct nested in another SIMD construct is an
+  // extension. The OpenMP 4.5 spec does not allow it. Issue a warning
+  // message.
+  SemaRef.Diag(StartLoc, (CurrentRegion != OMPD_simd)
+ ? diag::err_omp_prohibited_region_simd
+ : diag::warn_omp_nesting_simd);
+  return CurrentRegion != OMPD_simd;
 }
 if (ParentRegion == OMPD_atomic) {
   // OpenMP [2.16, Nesting of Regions]

Modified: cfe/trunk/test/OpenMP/nesting_of_regions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nesting_of_regions.cpp?rev=274352&r1=274351&r2=274352&view=diff
==
--- cfe/trunk/test/OpenMP/nesting_of_regions.cpp (original)
+++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp Fri Jul  1 09:30:25 2016
@@ -153,7 +153,7 @@ void foo() {
   }
 #pragma omp simd
   for (int i = 0; i < 10; ++i) {
-#pragma omp simd
+#pragma omp simd // expected-warning {{OpenMP only allows an ordered construct 
with the simd clause nested in a simd construct}}
 for (int i = 0; i < 10; ++i)
   ;
   }
@@ -257,6 +257,16 @@ void foo() {
   }
 #pragma omp simd
   for (int i = 0; i < 10; ++i) {
+#pragma omp ordered simd // OK
+bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered threads // expected-error {{OpenMP constructs may not be 
nested inside a simd region}}
+bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested 
inside a simd region}}
 ++a;
   }
@@ -516,7 +526,7 @@ void foo() {
   }
 #pragma omp for simd
   for (int i = 0; i < 10; ++i) {
-#pragma omp simd
+#pragma omp simd // expected-warning {{OpenMP only allows an ordered construct 
with the simd clause nested in a simd construct}}
 for (int i = 0; i < 10; ++i)
   ;
   }
@@ -620,6 +630,16 @@ void foo() {
   }
 #pragma omp for simd
   for (int i = 0; i < 10; ++i) {
+#pragma omp ordered simd // OK
+bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered threads // expected-error {{OpenMP constructs may not be 
nested inside a simd region}}
+bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested 
inside a simd region}}
 ++a;
   }
@@ -1902,7 +1922,7

Re: [PATCH] D21545: CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-07-01 Thread Teresa Johnson via cfe-commits
tejohnson added inline comments.


Comment at: lib/CodeGen/BackendUtil.cpp:758
@@ +757,3 @@
+
+  lto::Config Conf;
+  if (Error E = thinBackend(

Can we pass along -save-temps here (i.e. invoke Conf.addSaveTemps)?


http://reviews.llvm.org/D21545



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r274084 - Revert "[PS4] Tighten up a test (noticed in passing)"

2016-07-01 Thread Robinson, Paul via cfe-commits
With some digging I worked out at least part of the history.  It's not that we 
care about PATH per se; the test is making sure that even if you don't have a 
linker in the package, there's still a file with the right name for clang to 
find in a place that it would (eventually) look.  If you *do* have a linker in 
the package, clang should find it and still construct the command line 
correctly.
An upstream lit test can't arrange a co-located linker (without extraordinary 
measures such as you suggest, which I think we don't want); we should have an 
internal regression test for that case, but apparently do not.

The *actual bug* is the missing .exe extension.  This appears to be a 
regression, looking at the original (internal) bug. You were correct to remove 
the directory part of the path check, but not to remove the .exe part, as that 
masked the regression.
You should be able to drop 'orbis-ld.exe' in the directory with clang and have 
clang find it correctly.  The same is not true if you drop 'orbis-ld' into that 
directory.
--paulr

From: Sean Silva [mailto:chisophu...@gmail.com]
Sent: Friday, July 01, 2016 12:09 AM
To: Robinson, Paul
Cc: cfe-commits (cfe-commits@lists.llvm.org)
Subject: Re: r274084 - Revert "[PS4] Tighten up a test (noticed in passing)"



On Thu, Jun 30, 2016 at 5:30 PM, Robinson, Paul 
mailto:paul.robin...@sony.com>> wrote:
Okay, that is peculiar.  But I can repro it.  If I put either orbis-ld or 
orbis-ld.exe co-located with clang.exe, it builds a command line without the 
.exe suffix (but using the directory where clang.exe lives).

Yeah, as I described in the commit message of r262285 it is due to an 
extra-high-priority lookup done in Driver::GetProgramPath that overrides the 
PATH lookup. In fact, in the production PS4 SDK the PATH lookup purportedly 
tested in this test *never occurs* since these "look in the the directory 
containing clang" lookups always find orbis-ld first (since it is always(?) 
right beside clang).

So this test probably needs to be changed to copy the clang binary into a 
directory, put an orbis-ld.exe there, and then verify that clang finds that 
orbis-ld. There is little point to testing PATH lookups since AFAIK we don't 
really advertise to licensees that they should mess with the contents of the 
sdk dir (i.e. to cause clang to not be beside orbis-ld and instead find 
orbis-ld through a PATH lookup).

(actually, copying the clang binary is not ideal since that binary may be quite 
large)


I do think a bug report would have been appropriate, rather than just munging 
the test…
As it is (with your mods) the test is not checking what we want it to check.  
I'll write an internal bug for this.

Thanks. To be completely honest I had not noticed that due to the prefix 
property it wouldn't quite check the right thing.

-- Sean Silva

--paulr

From: Sean Silva [mailto:chisophu...@gmail.com]
Sent: Thursday, June 30, 2016 4:03 PM
To: Robinson, Paul
Cc: cfe-commits (cfe-commits@lists.llvm.org)
Subject: Re: r274084 - Revert "[PS4] Tighten up a test (noticed in passing)"



On Thu, Jun 30, 2016 at 3:52 PM, Robinson, Paul 
mailto:paul.robin...@sony.com>> wrote:


> -Original Message-
> From: cfe-commits 
> [mailto:cfe-commits-boun...@lists.llvm.org]
>  On Behalf Of
> Sean Silva via cfe-commits
> Sent: Tuesday, June 28, 2016 5:29 PM
> To: cfe-commits@lists.llvm.org
> Subject: r274084 - Revert "[PS4] Tighten up a test (noticed in passing)"
>
> Author: silvas
> Date: Tue Jun 28 19:29:23 2016
> New Revision: 274084
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274084&view=rev
> Log:
> Revert "[PS4] Tighten up a test (noticed in passing)"
>
> This reverts commit r269709.
>
> r262285 changed this deliberately so that the test would not be
> sensitive to which binaries are in the same directory as clang.
> See the commit message of that commit for more background.

Okay, but the point of the test is to match a "file.exe" instead
of just "file". See commentary at the top of the test.
Also "orbis-ld" is a prefix of "orbis-ld.gold" and so matching
just the former doesn't verify we're looking for the right one.

I understand taking out the path part of the check in r262285 but
if you named your test linker "orbis-ld.exe" instead of "orbis-ld"
then the test would pass with r269709, right?

Unfortunately not.

-- Sean Silva

  If that's all this
is about, please undo this revert and use the standard Windows
file extension for your test linkers.
--paulr

>
> Modified:
> cfe/trunk/test/Driver/ps4-linker-win.c
>
> Modified: cfe/trunk/test/Driver/ps4-linker-win.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-linker-
> win.c?rev=274084&r1=274083&r2=274084&view=diff
> ==
> 
> --- cfe/trunk/test/Driver/ps4-linker-win.c (origi

Re: [PATCH] D21385: Adjust Registry interface to not require plugins to export a registry

2016-07-01 Thread John Brawn via cfe-commits
john.brawn added a comment.

> http://clang.llvm.org/get_started.html doesn't specify a version of Python, 
> the LLVM webpage only say >= 2.7, and I ran the tests without any problem 
> with Python 3 (but maybe some tests were automatically skipped?). Also, 
> Python is also marked as only necessary to build the tests, which is no 
> longer true with your script.


Hmm, it looks like this webpage (and 
http://llvm.org/docs/GettingStarted.html#requirements) has been out of date 
since 2011 (commits r143742 and r143793), when python started being necessary 
always as it's used to run llvm-build. Python 3 not being supported appears to 
come from commit r184732 which just says "All of LLVM's Python scripts only 
support Python 2 for widely understood reasons", though I must confess I don't 
know what those reasons are. I'll look into making extract_symbols.py work with 
python 3, though I haven't touched python 3 before now so I don't know how much 
luck I'll have.


Repository:
  rL LLVM

http://reviews.llvm.org/D21385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r274356 - Driver: support -L for MSVC toolchain under the GNU driver

2016-07-01 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Jul  1 10:36:31 2016
New Revision: 274356

URL: http://llvm.org/viewvc/llvm-project?rev=274356&view=rev
Log:
Driver: support -L for MSVC toolchain under the GNU driver

When not using clang in the CL emulation mode, honour the -L flags as additional
library paths to pass to the linker invocation.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/msvc-link.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=274356&r1=274355&r2=274356&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul  1 10:36:31 2016
@@ -9950,6 +9950,10 @@ void visualstudio::Linker::ConstructJob(
WindowsSdkLibPath.c_str()));
   }
 
+  if (!C.getDriver().IsCLMode() && Args.hasArg(options::OPT_L))
+for (const auto &LibPath : Args.getAllArgValues(options::OPT_L))
+  CmdArgs.push_back(Args.MakeArgString("-libpath:" + LibPath));
+
   CmdArgs.push_back("-nologo");
 
   if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))

Modified: cfe/trunk/test/Driver/msvc-link.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msvc-link.c?rev=274356&r1=274355&r2=274356&view=diff
==
--- cfe/trunk/test/Driver/msvc-link.c (original)
+++ cfe/trunk/test/Driver/msvc-link.c Fri Jul  1 10:36:31 2016
@@ -10,3 +10,9 @@
 // DLL: "-defaultlib:libcmt"
 // DLL: "-nologo"
 // DLL: "-dll"
+
+// RUN: %clang -target i686-pc-windows-msvc -L/var/empty -L/usr/lib -### %s 
2>&1 | FileCheck --check-prefix LIBPATH %s
+// LIBPATH: "-libpath:/var/empty"
+// LIBPATH: "-libpath:/usr/lib"
+// LIBPATH: "-nologo"
+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18639: Use __builtin_isnan/isinf/isfinite in complex

2016-07-01 Thread Steve Canon via cfe-commits
scanon added a comment.

I agree with Marshall.  Aside from the points he raises, this approach looks 
fine.


http://reviews.llvm.org/D18639



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21619: [Sema] Implement C++14's DR1579: Prefer moving id-expression out of functions

2016-07-01 Thread Erik Pilkington via cfe-commits
erik.pilkington added a comment.

Yes, also PR28096. I marked them as being duplicates on the bugzilla.


Repository:
  rL LLVM

http://reviews.llvm.org/D21619



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r274359 - Revert r274348 and r274349 until the Windows failures are fixed.

2016-07-01 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jul  1 11:07:57 2016
New Revision: 274359

URL: http://llvm.org/viewvc/llvm-project?rev=274359&view=rev
Log:
Revert r274348 and r274349 until the Windows failures are fixed.

Removed:
cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp
Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/unittests/AST/CMakeLists.txt

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=274359&r1=274358&r2=274359&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Jul  1 11:07:57 2016
@@ -72,8 +72,8 @@ namespace clang {
   return false;
\
   } while (0)
 
-/// \brief A class that does preordor or postorder
-/// depth-first traversal on the entire Clang AST and visits each node.
+/// \brief A class that does preorder depth-first traversal on the
+/// entire Clang AST and visits each node.
 ///
 /// This class performs three distinct tasks:
 ///   1. traverse the AST (i.e. go to each node);
@@ -133,10 +133,6 @@ namespace clang {
 /// to return true, in which case all known implicit and explicit
 /// instantiations will be visited at the same time as the pattern
 /// from which they were produced.
-///
-/// By default, this visitor preorder traverses the AST. If postorder traversal
-/// is needed, the \c shouldTraversePostOrder method needs to be overriden
-/// to return \c true.
 template  class RecursiveASTVisitor {
 public:
   /// A queue used for performing data recursion over statements.
@@ -162,9 +158,6 @@ public:
   /// code, e.g., implicit constructors and destructors.
   bool shouldVisitImplicitCode() const { return false; }
 
-  /// \brief Return whether this visitor should traverse post-order.
-  bool shouldTraversePostOrder() const { return false; }
-
   /// \brief Recursively visit a statement or expression, by
   /// dispatching to Traverse*() based on the argument's dynamic type.
   ///
@@ -356,7 +349,7 @@ public:
   bool TraverseUnary##NAME(UnaryOperator *S,   
\
DataRecursionQueue *Queue = nullptr) {  
\
 TRY_TO(WalkUpFromUnary##NAME(S));  
\
-TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  
\
+TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  
  \
 return true;   
\
   }
\
   bool WalkUpFromUnary##NAME(UnaryOperator *S) {   
\
@@ -374,10 +367,9 @@ public:
 // (they're all opcodes in BinaryOperator) but do have visitors.
 #define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE)   
\
   bool TraverseBin##NAME(BINOP_TYPE *S, DataRecursionQueue *Queue = nullptr) { 
\
-if (!getDerived().shouldTraversePostOrder())   
\
-  TRY_TO(WalkUpFromBin##NAME(S));  
\
-TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS());  
\
-TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS());  
\
+TRY_TO(WalkUpFromBin##NAME(S));
\
+TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS());  
  \
+TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS());  
  \
 return true;   
\
   }
\
   bool WalkUpFromBin##NAME(BINOP_TYPE *S) {
\
@@ -507,7 +499,6 @@ private:
   bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node);
 
   bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
-  bool PostVisitStmt(Stmt *S);
 };
 
 template 
@@ -565,24 +556,6 @@ bool RecursiveASTVisitor::dataT
 
 #undef DISPATCH_STMT
 
-
-template 
-bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) {
-  switch (S->getStmtClass()) {
-  case Stmt::NoStmtClass:
-break;
-#define ABSTRACT_STMT(STMT)
-#define STMT(CLASS, PARENT)
\
-  case Stmt::CLASS##Class: 
\
-TRY_TO(WalkUpFrom##CLASS(static_cast(S))); break;
-#include "clang/AST/StmtNodes.inc"
-  }
-
-  return true;
-}
-
-#undef DISPATCH_STMT
-
 template 
 bool RecursiveASTVisitor::TraverseStmt(Stmt *S,
 DataRecursionQueue *Queue) {
@@ -604,9 +577,6 @@ bool RecursiveASTVisitor::Trave
 if (Visited) {
   LocalQueue.po

Re: [PATCH] D18172: [CUDA][OpenMP] Add a generic offload action builder

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62506.
sfantao added a comment.

- Use double instead of triple slash in one comment.


http://reviews.llvm.org/D18172

Files:
  include/clang/Driver/Compilation.h
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1387,131 +1387,521 @@
   }
 }
 
-// For each unique --cuda-gpu-arch= argument creates a TY_CUDA_DEVICE
-// input action and then wraps each in CudaDeviceAction paired with
-// appropriate GPU arch name. In case of partial (i.e preprocessing
-// only) or device-only compilation, each device action is added to /p
-// Actions and /p Current is released. Otherwise the function creates
-// and returns a new CudaHostAction which wraps /p Current and device
-// side actions.
-static Action *buildCudaActions(Compilation &C, DerivedArgList &Args,
-const Arg *InputArg, Action *HostAction,
-ActionList &Actions) {
-  Arg *PartialCompilationArg = Args.getLastArg(
-  options::OPT_cuda_host_only, options::OPT_cuda_device_only,
-  options::OPT_cuda_compile_host_device);
-  bool CompileHostOnly =
-  PartialCompilationArg &&
-  PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only);
-  bool CompileDeviceOnly =
-  PartialCompilationArg &&
-  PartialCompilationArg->getOption().matches(options::OPT_cuda_device_only);
-
-  if (CompileHostOnly) {
+namespace {
+/// Provides a convenient interface for different programming models to generate
+/// the required device actions.
+class OffloadingActionBuilder final {
+  /// Flag used to trace errors in the builder.
+  bool IsValid = false;
+
+  /// The compilation that is using this builder.
+  Compilation &C;
+
+  /// The derived arguments associated with this builder.
+  DerivedArgList &Args;
+
+  /// Map between an input argument and the offload kinds used to process it.
+  std::map InputArgToOffloadKindMap;
+
+  /// Builder interface. It doesn't build anything or keep any state.
+  class DeviceActionBuilder {
+  public:
+typedef llvm::SmallVector PhasesTy;
+
+enum ActionBuilderReturnCode {
+  // The builder acted successfully on the current action.
+  ABRT_Success,
+  // The builder didn't have to act on the current action.
+  ABRT_Inactive,
+  // The builder was successful and requested the host action to not be
+  // generated.
+  ABRT_Ignore_Host,
+};
+
+  protected:
+/// Compilation associated with this builder.
+Compilation &C;
+
+/// Tool chains associated with this builder. The same programming
+/// model may have associated one or more tool chains.
+SmallVector ToolChains;
+
+/// The derived arguments associated with this builder.
+DerivedArgList &Args;
+
+/// The inputs associated with this builder.
+const Driver::InputList &Inputs;
+
+/// The associated offload kind.
+Action::OffloadKind AssociatedOffloadKind = Action::OFK_None;
+
+  public:
+DeviceActionBuilder(Compilation &C, DerivedArgList &Args,
+const Driver::InputList &Inputs,
+Action::OffloadKind AssociatedOffloadKind)
+: C(C), Args(Args), Inputs(Inputs),
+  AssociatedOffloadKind(AssociatedOffloadKind) {}
+virtual ~DeviceActionBuilder() {}
+
+/// Fill up the array \a DA with all the device dependences that should be
+/// added to the provided host action \a HostAction. By default it is
+/// inactive.
+virtual ActionBuilderReturnCode
+getDeviceDepences(OffloadAction::DeviceDependences &DA, phases::ID CurPhase,
+  phases::ID FinalPhase, PhasesTy &Phases) {
+  return ABRT_Inactive;
+}
+
+/// Update the state to include the provided host action \a HostAction as a
+/// dependency of the current device action. By default it is inactive.
+virtual ActionBuilderReturnCode addDeviceDepences(Action *HostAction) {
+  return ABRT_Inactive;
+}
+
+/// Append top level actions generated by the builder. Return true if errors
+/// were found.
+virtual void appendTopLevelActions(ActionList &AL) {}
+
+/// Append linker actions generated by the builder. Return true if errors
+/// were found.
+virtual void appendLinkDependences(OffloadAction::DeviceDependences &DA) {}
+
+/// Initialize the builder. Return true if any initialization errors are
+/// found.
+virtual bool initialize() { return false; }
+
+/// Return true if this builder is valid. We have a valid builder if we have
+/// associated device tool chains.
+bool isValid() { return !ToolChains.empty(); }
+
+/// Return the associated offload kind.
+Action::OffloadKind getAssociatedOffloadKind() {
+  return AssociatedOffloadKind;
+}
+  };
+
+  /// \brief CUDA action builder. It injects device code in the host backend
+  /// 

Re: [PATCH] D21385: Adjust Registry interface to not require plugins to export a registry

2016-07-01 Thread John Brawn via cfe-commits
john.brawn added a comment.

Commit r274365 should make extract_symbols.py work with Python 3.


Repository:
  rL LLVM

http://reviews.llvm.org/D21385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21840: [Driver][CUDA][OpenMP] Reimplement tool selection in the driver.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62507.
sfantao marked 7 inline comments as done.
sfantao added a comment.

- Fix comments.
- Mark functions properly with const and static.
- Remove \brief.


http://reviews.llvm.org/D21840

Files:
  include/clang/Driver/Action.h
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1894,7 +1894,7 @@
 
 // Create the offload action with all dependences. When an offload action
 // is created the kinds are propagated to the host action, so we don't have
-// to do that explicitely here.
+// to do that explicitly here.
 OffloadAction::HostDependence HDep(
 *HostAction, *C.getSingleOffloadToolChain(),
 /*BoundArch*/ nullptr, ActiveOffloadKinds);
@@ -2328,142 +2328,292 @@
 }
   }
 }
-/// Collapse an offloading action looking for a job of the given type. The input
-/// action is changed to the input of the collapsed sequence. If we effectively
-/// had a collapse return the corresponding offloading action, otherwise return
-/// null.
-template 
-static OffloadAction *collapseOffloadingAction(Action *&CurAction) {
-  if (!CurAction)
-return nullptr;
-  if (auto *OA = dyn_cast(CurAction)) {
-if (OA->hasHostDependence())
-  if (auto *HDep = dyn_cast(OA->getHostDependence())) {
-CurAction = HDep;
-return OA;
-  }
-if (OA->hasSingleDeviceDependence())
-  if (auto *DDep = dyn_cast(OA->getSingleDeviceDependence())) {
-CurAction = DDep;
-return OA;
+
+namespace {
+/// Utility class to control the collapse of dependent actions and select the
+/// tools accordingly.
+class ToolSelector final {
+  /// The tool chain this selector refers to.
+  const ToolChain &TC;
+
+  /// The compilation this selector refers to.
+  const Compilation &C;
+
+  /// The base action this selector refers to.
+  const JobAction *BaseAction;
+
+  /// Set to true if the current toolchain refers to host actions.
+  bool IsHostSelector;
+
+  /// Set to true if save-temps and embed-bitcode functionalities are active.
+  bool SaveTemps;
+  bool EmbedBitcode;
+
+  /// Get dependence action or null if that does not exist. If \a CanBeCollapsed
+  /// is false, that action must be legal to collapse or null will be returned.
+  const JobAction *getDependenceAction(const ActionList &Inputs,
+   ActionList &SavedOffloadAction,
+   bool CanBeCollapsed = true) {
+// An option can be collapsed only if it has a single input.
+if (Inputs.size() != 1)
+  return nullptr;
+
+Action *CurAction = *Inputs.begin();
+if (!CurAction->isCollapsingWithDependingActionLegal() && CanBeCollapsed)
+  return nullptr;
+
+// If the input action is an offload action. Look through it and save any
+// offload action that can be dropped in the event of a collapse.
+if (auto *OA = dyn_cast(CurAction)) {
+  // If the depending action is a device action, we will attempt to collapse
+  // only with other device actions. Otherwise, we would do the same but
+  // with host actions only.
+  if (!IsHostSelector) {
+if (OA->hasSingleDeviceDependence(/*DoNotConsiderHostActions=*/true)) {
+  CurAction =
+  OA->getSingleDeviceDependence(/*DoNotConsiderHostActions=*/true);
+  if (!CurAction->isCollapsingWithDependingActionLegal() &&
+  CanBeCollapsed)
+return nullptr;
+  SavedOffloadAction.push_back(OA);
+  return dyn_cast(CurAction);
+}
+  } else if (OA->hasHostDependence()) {
+CurAction = OA->getHostDependence();
+if (!CurAction->isCollapsingWithDependingActionLegal() &&
+CanBeCollapsed)
+  return nullptr;
+SavedOffloadAction.push_back(OA);
+return dyn_cast(CurAction);
   }
+  return nullptr;
+}
+
+return dyn_cast(CurAction);
   }
-  return nullptr;
-}
-// Returns a Tool for a given JobAction.  In case the action and its
-// predecessors can be combined, updates Inputs with the inputs of the
-// first combined action. If one of the collapsed actions is a
-// CudaHostAction, updates CollapsedCHA with the pointer to it so the
-// caller can deal with extra handling such action requires.
-static const Tool *selectToolForJob(Compilation &C, bool SaveTemps,
-bool EmbedBitcode, const ToolChain *TC,
-const JobAction *JA,
-const ActionList *&Inputs,
-ActionList &CollapsedOffloadAction) {
-  const Tool *ToolForJob = nullptr;
-  CollapsedOffloadAction.clear();
-
-  // See if we should look for a compiler with an integrated assembler. We match
-  // bottom up, so what we are actually looking for is an assembler job with a
-  // compiler in

r274370 - Emit more intrinsics for builtin functions

2016-07-01 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Fri Jul  1 12:38:14 2016
New Revision: 274370

URL: http://llvm.org/viewvc/llvm-project?rev=274370&view=rev
Log:
Emit more intrinsics for builtin functions

This is important for building libclc. Since r273039 tests are failing
due to now emitting calls to these functions instead of emitting the
DAG node. The libm function names are implemented for OpenCL, and should
call the locally defined versions, so -fno-builtin is used. The IR
Some functions use the __builtins and expect the intrinsics to be
emitted. Without this we end up with nobuiltin calls to intrinsics
or to unsupported library calls.

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=274370&r1=274369&r2=274370&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Jul  1 12:38:14 2016
@@ -217,6 +217,51 @@ static Value *MakeAtomicCmpXchgValue(Cod
ValueType);
 }
 
+// Emit a simple mangled intrinsic that has 1 argument and a return type
+// matching the argument type.
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF,
+   const CallExpr *E,
+   unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, Src0);
+}
+
+// Emit an intrinsic that has 2 operands of the same type as its result.
+static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
+const CallExpr *E,
+unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, { Src0, Src1 });
+}
+
+// Emit an intrinsic that has 3 operands of the same type as its result.
+static Value *emitTernaryBuiltin(CodeGenFunction &CGF,
+ const CallExpr *E,
+ unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+  llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
+}
+
+// Emit an intrinsic that has 1 float or double operand, and 1 integer.
+static Value *emitFPIntBuiltin(CodeGenFunction &CGF,
+   const CallExpr *E,
+   unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, {Src0, Src1});
+}
+
 /// EmitFAbs - Emit a call to @llvm.fabs().
 static Value *EmitFAbs(CodeGenFunction &CGF, Value *V) {
   Value *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType());
@@ -286,40 +331,6 @@ static llvm::Value *EmitOverflowIntrinsi
   return CGF.Builder.CreateExtractValue(Tmp, 0);
 }
 
-// Emit a simple mangled intrinsic that has 1 argument and a return type
-// matching the argument type.
-static Value *emitUnaryBuiltin(CodeGenFunction &CGF,
-   const CallExpr *E,
-   unsigned IntrinsicID) {
-  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
-
-  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
-  return CGF.Builder.CreateCall(F, Src0);
-}
-
-// Emit an intrinsic that has 3 float or double operands.
-static Value *emitTernaryFPBuiltin(CodeGenFunction &CGF,
-   const CallExpr *E,
-   unsigned IntrinsicID) {
-  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
-  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
-  llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
-
-  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
-  return CGF.Builder.CreateCall(F, {Src0, Src1, Src2});
-}
-
-// Emit an intrinsic that has 1 float or double operand, and 1 integer.
-static Value *emitFPIntBuiltin(CodeGenFunction &CGF,
-   const CallExpr *E,
-   unsigned IntrinsicID) {
-  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
-  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
-
-  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
-  return CGF.Builder.CreateCall(F, {Src0, Src1});
-}
-
 namespace {
   struct WidthAndSignedness {
 unsigned Width;
@@ -497,9 +508,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   case Builtin::BI__builtin_f

Re: [PATCH] D5896: Emit more intrinsics for builtin functions

2016-07-01 Thread Matt Arsenault via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r274370


http://reviews.llvm.org/D5896



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21706: [libcxx] refactor for throw

2016-07-01 Thread Weiming Zhao via cfe-commits
weimingz updated this revision to Diff 62515.
weimingz marked 5 inline comments as done.
weimingz added a comment.

fix issues per Noel's suggestion


http://reviews.llvm.org/D21706

Files:
  include/__functional_03
  include/__locale
  include/array
  include/bitset
  include/complex
  include/deque
  include/exception
  include/experimental/dynarray
  include/experimental/optional
  include/fstream
  include/functional
  include/future
  include/locale
  include/map
  include/memory
  include/regex
  include/string
  include/unordered_map
  include/vector
  src/debug.cpp
  src/experimental/memory_resource.cpp
  src/future.cpp
  src/hash.cpp
  src/ios.cpp
  src/locale.cpp
  src/new.cpp
  src/string.cpp
  src/system_error.cpp
  src/thread.cpp
  src/typeinfo.cpp

Index: src/typeinfo.cpp
===
--- src/typeinfo.cpp
+++ src/typeinfo.cpp
@@ -52,15 +52,11 @@
   // because bad_cast and bad_typeid are defined in his higher level library
   void __cxxabiv1::__cxa_bad_typeid()
   {
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw std::bad_typeid();
-#endif
+ __libcpp_throw(std::bad_typeid());
   }
   void __cxxabiv1::__cxa_bad_cast()
   {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-  throw std::bad_cast();
-#endif
+  __libcpp_throw(std::bad_cast());
   }
 #endif
 
Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -53,10 +53,9 @@
 if (ec == 0)
 __t_ = 0;
 }
-#ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
-throw system_error(error_code(ec, system_category()), "thread::join failed");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+__libcpp_throw(system_error(error_code(ec, system_category()),
+   "thread::join failed"));
 }
 
 void
@@ -69,10 +68,9 @@
 if (ec == 0)
 __t_ = 0;
 }
-#ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
-throw system_error(error_code(ec, system_category()), "thread::detach failed");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+__libcpp_throw(system_error(error_code(ec, system_category()),
+   "thread::detach failed"));
 }
 
 unsigned
Index: src/system_error.cpp
===
--- src/system_error.cpp
+++ src/system_error.cpp
@@ -253,12 +253,7 @@
 void
 __throw_system_error(int ev, const char* what_arg)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw system_error(error_code(ev, system_category()), what_arg);
-#else
-(void)ev;
-(void)what_arg;
-#endif
+__libcpp_throw(system_error(error_code(ev, system_category()), what_arg));
 }
 
 _LIBCPP_END_NAMESPACE_STD
Index: src/string.cpp
===
--- src/string.cpp
+++ src/string.cpp
@@ -32,28 +32,16 @@
 namespace
 {
 
-template
-inline
-void throw_helper( const string& msg )
-{
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw T( msg );
-#else
-fprintf(stderr, "%s\n", msg.c_str());
-abort();
-#endif
-}
-
 inline
 void throw_from_string_out_of_range( const string& func )
 {
-throw_helper(func + ": out of range");
+__libcpp_throw(out_of_range(func + ": out of range"));
 }
 
 inline
 void throw_from_string_invalid_arg( const string& func )
 {
-throw_helper(func + ": no conversion");
+__libcpp_throw(invalid_argument(func + ": no conversion"));
 }
 
 // as_integer
Index: src/new.cpp
===
--- src/new.cpp
+++ src/new.cpp
@@ -56,7 +56,7 @@
 nh();
 else
 #ifndef _LIBCPP_NO_EXCEPTIONS
-throw std::bad_alloc();
+__libcpp_throw(std::bad_alloc());
 #else
 break;
 #endif
Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -436,10 +436,8 @@
 const locale::facet*
 locale::__imp::use_facet(long id) const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
 if (!has_facet(id))
-throw bad_cast();
-#endif  // _LIBCPP_NO_EXCEPTIONS
+__libcpp_throw(bad_cast());
 return facets_[static_cast(id)];
 }
 
@@ -528,6 +526,7 @@
 #else  // _LIBCPP_NO_EXCEPTIONS
 : __locale_(new __imp(*other.__locale_, name, c))
 #endif
+
 {
 __locale_->__add_shared();
 }
@@ -646,22 +645,18 @@
 : collate(refs),
   __l(newlocale(LC_ALL_MASK, n, 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
 if (__l == 0)
-throw runtime_error("collate_byname::collate_byname"
-" failed to construct for " + string(n));
-#endif  // _LIBCPP_NO_EXCEPTIONS
+__libcpp_throw(runtime_error("collate_byname::collate_byname"
+" failed to construct for " + string(n)));
 }
 
 collate_byname::collate_byname(const string& name, size_t refs)
 : collate(refs),
   __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
 if (_

Re: [cfe-dev] RFC: Default language standard mode policy

2016-07-01 Thread Joerg Sonnenberger via cfe-commits
On Thu, Jun 30, 2016 at 01:41:00PM -0700, Richard Smith wrote:
> On Thu, Jun 30, 2016 at 2:02 AM, David Chisnall  > wrote:
> 
> > On 29 Jun 2016, at 23:07, Richard Smith via cfe-dev <
> > cfe-...@lists.llvm.org> wrote:
> > >
> > > Yes, those are real problems, but it's not reasonable for us to keep the
> > default at C++98/03 forever. GCC has already taken the plunge here, so a
> > lot of open-source code that doesn't work in C++11 onwards already
> > explicitly specifies an appropriate -std= flag.
> > >
> >
> > Could you clarify exactly what the issue is?  Currently, if I have some
> > legacy C++98 code, the odds are that it just compiles with ${CXX}.  If I
> > have new C++11 or C++14 code, then its build system likely sticks on the
> > required -std= flag and it builds independent of what the compiler default
> > is.
> >
> 
> Why should new C++ code pay this tax to use the language that is currently
> called C++, that is taught as C++, that is covered by books on C++, and so
> on? C++98 is increasingly the odd one out, and it's the one where an
> explicit -std= flag should be required.

Well, if the C++ language wouldn't change in backwards incompatible
ways, we wouldn't have this discussion. As I said before, the compiler
authors are not the one paying the price for the breakage they
introduce. We've been moderately good with LLVM/Clang to not introduce
miscompiled code in the name of exploiting random UB. Changing the C++
version falls into pretty much the same category. I don't even
understand your point about paying a "tax" for using newer C++ features.
I find it pretty much the reverse actually. It clearly documents
requirements and makes them auditable as well. Given the complex
compatibility/implementation status of C++ across different systems,
that's a good thing and not something bad.

Joerg
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62516.
sfantao marked an inline comment as done.
sfantao added a comment.

- Check the OpenMP flags only in one place for purposes of obtaining the 
runtime kind.


http://reviews.llvm.org/D21843

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Action.h
  include/clang/Driver/Driver.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- /dev/null
+++ test/Driver/openmp-offload.c
@@ -0,0 +1,37 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+/// ###
+
+/// Check whether an invalid OpenMP target is specified:
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-INVALID-TARGET %s
+// RUN:   %clang -### -fopenmp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-INVALID-TARGET %s
+// CHK-INVALID-TARGET: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'
+
+/// ###
+
+/// Check warning for empty -fopenmp-targets
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
+// RUN:   %clang -### -fopenmp -fopenmp-targets=  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
+// CHK-EMPTY-OMPTARGETS: warning: joined argument expects additional value: '-fopenmp-targets='
+
+/// ###
+
+/// Check error for no -fopenmp option
+// RUN:   %clang -### -fopenmp-targets=powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NO-FOPENMP %s
+// RUN:   %clang -### -fopenmp=libgomp -fopenmp-targets=powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NO-FOPENMP %s
+// CHK-NO-FOPENMP: error: The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading.
+
+/// ###
+
+/// Check warning for duplicate offloading targets.
+// RUN:   %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-DUPLICATES %s
+// CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored.
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2999,72 +2999,23 @@
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
 }
 
-namespace {
-enum OpenMPRuntimeKind {
-  /// An unknown OpenMP runtime. We can't generate effective OpenMP code
-  /// without knowing what runtime to target.
-  OMPRT_Unknown,
-
-  /// The LLVM OpenMP runtime. When completed and integrated, this will become
-  /// the default for Clang.
-  OMPRT_OMP,
-
-  /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for
-  /// this runtime but can swallow the pragmas, and find and link against the
-  /// runtime library itself.
-  OMPRT_GOMP,
-
-  /// The legacy name for the LLVM OpenMP runtime from when it was the Intel
-  /// OpenMP runtime. We support this mode for users with existing dependencies
-  /// on this runtime library name.
-  OMPRT_IOMP5
-};
-}
-
-/// Compute the desired OpenMP runtime from the flag provided.
-static OpenMPRuntimeKind getOpenMPRuntime(const ToolChain &TC,
-  const ArgList &Args) {
-  StringRef RuntimeName(CLANG_DEFAULT_OPENMP_RUNTIME);
-
-  const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ);
-  if (A)
-RuntimeName = A->getValue();
-
-  auto RT = llvm::StringSwitch(RuntimeName)
-.Case("libomp", OMPRT_OMP)
-.Case("libgomp", OMPRT_GOMP)
-.Case("libiomp5", OMPRT_IOMP5)
-.Default(OMPRT_Unknown);
-
-  if (RT == OMPRT_Unknown) {
-if (A)
-  TC.getDriver().Diag(diag::err_drv_unsupported_option_argument)
-  << A->getOption().getName() << A->getValue();
-else
-  // FIXME: We could use a nicer diagnostic here.
-  TC.getDriver().Diag(diag::err_drv_unsupported_opt) << "-fopenmp";
-  }
-
-  return RT;
-}
-
 static void addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC,
   const ArgList &Args) {
   if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
 options::OPT_fno_openmp, false))
 return;
 
-  switch (getOpenMPRuntime(TC, Args)) {
-  case OMPRT_OMP:
+  switch (TC.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:

Re: [PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: lib/Driver/Driver.cpp:464-468
@@ +463,7 @@
+  RuntimeName = A->getValue();
+HasCompatibleOpenMP = llvm::StringSwitch(RuntimeName)
+  .Case("libomp", true)
+  .Case("libgomp", false)
+  .Case("libiomp5", true)
+  .Default(false);
+  }

ABataev wrote:
> I don't like the fact that we have similar string comparisons in different 
> files. This must be handled in a single place.
Ok, that makes sense. I moved the ownership of `OpenMPRuntimeKind` to the 
`Driver`, given that the Driver was being retrieved in `Tools.cpp` in order to 
emit the diagnostics.


http://reviews.llvm.org/D21843



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21840: [Driver][CUDA][OpenMP] Reimplement tool selection in the driver.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: lib/Driver/Driver.cpp:2416
@@ +2415,3 @@
+  /// be collapsed with it.
+  struct JobActionInfoTy {
+// \brief The action this info refers to.

ABataev wrote:
> I think this can be marked 'final' and add 'nullptr' as a default initializer 
> for 'JA' field
Yep, I'm doing that now.


Comment at: lib/Driver/Driver.cpp:2426
@@ +2425,3 @@
+  /// in the action info array.
+  void appendCollapsedOffloadAction(ActionList &CollapsedOffloadAction,
+ArrayRef &ActionInfo,

ABataev wrote:
> I think this function can be marked as 'static', no?
You're right, using static now.


http://reviews.llvm.org/D21840



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62518.
sfantao added a comment.

- Add code dropped accidently in the previous diff.


http://reviews.llvm.org/D21843

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Action.h
  include/clang/Driver/Driver.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- /dev/null
+++ test/Driver/openmp-offload.c
@@ -0,0 +1,37 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+/// ###
+
+/// Check whether an invalid OpenMP target is specified:
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-INVALID-TARGET %s
+// RUN:   %clang -### -fopenmp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-INVALID-TARGET %s
+// CHK-INVALID-TARGET: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'
+
+/// ###
+
+/// Check warning for empty -fopenmp-targets
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
+// RUN:   %clang -### -fopenmp -fopenmp-targets=  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
+// CHK-EMPTY-OMPTARGETS: warning: joined argument expects additional value: '-fopenmp-targets='
+
+/// ###
+
+/// Check error for no -fopenmp option
+// RUN:   %clang -### -fopenmp-targets=powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NO-FOPENMP %s
+// RUN:   %clang -### -fopenmp=libgomp -fopenmp-targets=powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NO-FOPENMP %s
+// CHK-NO-FOPENMP: error: The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading.
+
+/// ###
+
+/// Check warning for duplicate offloading targets.
+// RUN:   %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-DUPLICATES %s
+// CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored.
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2999,72 +2999,23 @@
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
 }
 
-namespace {
-enum OpenMPRuntimeKind {
-  /// An unknown OpenMP runtime. We can't generate effective OpenMP code
-  /// without knowing what runtime to target.
-  OMPRT_Unknown,
-
-  /// The LLVM OpenMP runtime. When completed and integrated, this will become
-  /// the default for Clang.
-  OMPRT_OMP,
-
-  /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for
-  /// this runtime but can swallow the pragmas, and find and link against the
-  /// runtime library itself.
-  OMPRT_GOMP,
-
-  /// The legacy name for the LLVM OpenMP runtime from when it was the Intel
-  /// OpenMP runtime. We support this mode for users with existing dependencies
-  /// on this runtime library name.
-  OMPRT_IOMP5
-};
-}
-
-/// Compute the desired OpenMP runtime from the flag provided.
-static OpenMPRuntimeKind getOpenMPRuntime(const ToolChain &TC,
-  const ArgList &Args) {
-  StringRef RuntimeName(CLANG_DEFAULT_OPENMP_RUNTIME);
-
-  const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ);
-  if (A)
-RuntimeName = A->getValue();
-
-  auto RT = llvm::StringSwitch(RuntimeName)
-.Case("libomp", OMPRT_OMP)
-.Case("libgomp", OMPRT_GOMP)
-.Case("libiomp5", OMPRT_IOMP5)
-.Default(OMPRT_Unknown);
-
-  if (RT == OMPRT_Unknown) {
-if (A)
-  TC.getDriver().Diag(diag::err_drv_unsupported_option_argument)
-  << A->getOption().getName() << A->getValue();
-else
-  // FIXME: We could use a nicer diagnostic here.
-  TC.getDriver().Diag(diag::err_drv_unsupported_opt) << "-fopenmp";
-  }
-
-  return RT;
-}
-
 static void addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC,
   const ArgList &Args) {
   if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
 options::OPT_fno_openmp, false))
 return;
 
-  switch (getOpenMPRuntime(TC, Args)) {
-  case OMPRT_OMP:
+  switch (TC.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:
 CmdArgs.push_back("-lomp");
 break;
-  case OMPRT_GOMP:
+  case Driver::O

Re: [PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62519.
sfantao marked an inline comment as done.
sfantao added a comment.

- Mark class as final and remove \brief from comments.


http://reviews.llvm.org/D21845

Files:
  lib/Driver/Driver.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -35,3 +35,106 @@
 // RUN:   %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu  %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-DUPLICATES %s
 // CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored.
+
+/// ###
+
+/// Check the phases graph when using a single target, different from the host.
+/// We should have an offload action joining the host compile and device
+/// preprocessor and another one joining the device linking outputs to the host
+/// action.
+// RUN:   %clang -ccc-print-phases -fopenmp -target powerpc64le-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES %s
+// CHK-PHASES: 0: input, "[[INPUT:.+\.c]]", c, (host-openmp)
+// CHK-PHASES: 1: preprocessor, {0}, cpp-output, (host-openmp)
+// CHK-PHASES: 2: compiler, {1}, ir, (host-openmp)
+// CHK-PHASES: 3: backend, {2}, assembler, (host-openmp)
+// CHK-PHASES: 4: assembler, {3}, object, (host-openmp)
+// CHK-PHASES: 5: linker, {4}, image, (host-openmp)
+// CHK-PHASES: 6: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES: 7: preprocessor, {6}, cpp-output, (device-openmp)
+// CHK-PHASES: 8: compiler, {7}, ir, (device-openmp)
+// CHK-PHASES: 9: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir
+// CHK-PHASES: 10: backend, {9}, assembler, (device-openmp)
+// CHK-PHASES: 11: assembler, {10}, object, (device-openmp)
+// CHK-PHASES: 12: linker, {11}, image, (device-openmp)
+// CHK-PHASES: 13: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {5}, "device-openmp (x86_64-pc-linux-gnu)" {12}, image
+
+/// ###
+
+/// Check the phases when using multiple targets. Here we also add a library to
+/// make sure it is treated as input by the device.
+// RUN:   %clang -ccc-print-phases -lsomelib -fopenmp -target powerpc64-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES-LIB %s
+// CHK-PHASES-LIB: 0: input, "somelib", object, (host-openmp)
+// CHK-PHASES-LIB: 1: input, "[[INPUT:.+\.c]]", c, (host-openmp)
+// CHK-PHASES-LIB: 2: preprocessor, {1}, cpp-output, (host-openmp)
+// CHK-PHASES-LIB: 3: compiler, {2}, ir, (host-openmp)
+// CHK-PHASES-LIB: 4: backend, {3}, assembler, (host-openmp)
+// CHK-PHASES-LIB: 5: assembler, {4}, object, (host-openmp)
+// CHK-PHASES-LIB: 6: linker, {0, 5}, image, (host-openmp)
+// CHK-PHASES-LIB: 7: input, "somelib", object, (device-openmp)
+// CHK-PHASES-LIB: 8: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES-LIB: 9: preprocessor, {8}, cpp-output, (device-openmp)
+// CHK-PHASES-LIB: 10: compiler, {9}, ir, (device-openmp)
+// CHK-PHASES-LIB: 11: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {10}, ir
+// CHK-PHASES-LIB: 12: backend, {11}, assembler, (device-openmp)
+// CHK-PHASES-LIB: 13: assembler, {12}, object, (device-openmp)
+// CHK-PHASES-LIB: 14: linker, {7, 13}, image, (device-openmp)
+// CHK-PHASES-LIB: 15: input, "somelib", object, (device-openmp)
+// CHK-PHASES-LIB: 16: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES-LIB: 17: preprocessor, {16}, cpp-output, (device-openmp)
+// CHK-PHASES-LIB: 18: compiler, {17}, ir, (device-openmp)
+// CHK-PHASES-LIB: 19: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (powerpc64-ibm-linux-gnu)" {18}, ir
+// CHK-PHASES-LIB: 20: backend, {19}, assembler, (device-openmp)
+// CHK-PHASES-LIB: 21: assembler, {20}, object, (device-openmp)
+// CHK-PHASES-LIB: 22: linker, {15, 21}, image, (device-openmp)
+// CHK-PHASES-LIB: 23: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {6}, "device-openmp (x86_64-pc-linux-gnu)" {14}, "device-openmp (powerpc64-ibm-linux-gnu)" {22}, image
+
+
+/// ###
+
+/// Check the phases when using multiple targets and multiple source files
+// RUN:   echo " " > %t.c
+// RUN:   %clang -ccc-print-phases -lsomelib -fopenmp -target powerpc64-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s %t.c 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES-FILES %s
+// CHK-PHASES-FILES: 0: input, "somelib", object, (host-openmp)
+// CHK-PHASES-FILES: 1: input, "[[INPUT1:.+\

Re: [PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review! Addressed your comment in the new diff. Also removed 
`\brief` from the comments.


http://reviews.llvm.org/D21845



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21334: Add TargetInfo for 32-bit and 64-bit RenderScript

2016-07-01 Thread Pirama Arumuga Nainar via cfe-commits
pirama updated this revision to Diff 62520.
pirama added a comment.

Reformatted with clang-format for just the parts I added.  I ignored
clang-format-suggested changes in code unrelated to this patch.

Is there a policy or practise on periodically fixing format-related issues?  If
not, I can format this file in an one-off basis in a separate patch.


http://reviews.llvm.org/D21334

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/renderscript.c

Index: test/CodeGen/renderscript.c
===
--- /dev/null
+++ test/CodeGen/renderscript.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -triple=renderscript32-none-linux-gnueabi -emit-llvm -o 
- -Werror | FileCheck %s -check-prefix=CHECK-RS32
+// RUN: %clang_cc1 %s -triple=renderscript64-none-linux-android -emit-llvm -o 
- -Werror | FileCheck %s -check-prefix=CHECK-RS64
+// RUN: %clang_cc1 %s -triple=armv7-none-linux-gnueabi -emit-llvm -o - -Werror 
| FileCheck %s -check-prefix=CHECK-ARM
+
+// Ensure that the bitcode has the correct triple
+// CHECK-RS32: target triple = "armv7-none-linux-gnueabi"
+// CHECK-RS64: target triple = "aarch64-none-linux-android"
+// CHECK-ARM: target triple = "armv7-none-linux-gnueabi"
+
+// Ensure that long data type has 8-byte size and alignment in RenderScript
+#ifdef __RENDERSCRIPT__
+#define LONG_WIDTH_AND_ALIGN 8
+#else
+#define LONG_WIDTH_AND_ALIGN 4
+#endif
+
+_Static_assert(sizeof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong");
+_Static_assert(_Alignof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong");
+
+// CHECK-RS32: i64 @test_long(i64 %v)
+// CHECK-RS64: i64 @test_long(i64 %v)
+// CHECK-ARM: i32 @test_long(i32 %v)
+long test_long(long v) {
+  return v + 1;
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7992,6 +7992,42 @@
 return true;
   }
 };
+
+// 32-bit RenderScript is armv7 with width and align of 'long' set to 8-bytes
+class RenderScript32TargetInfo : public ARMleTargetInfo {
+public:
+  RenderScript32TargetInfo(const llvm::Triple &Triple,
+   const TargetOptions &Opts)
+  : ARMleTargetInfo(llvm::Triple("armv7", Triple.getVendorName(),
+ Triple.getOSName(),
+ Triple.getEnvironmentName()),
+Opts) {
+LongWidth = LongAlign = 64;
+  }
+  void getTargetDefines(const LangOptions &Opts,
+MacroBuilder &Builder) const override {
+Builder.defineMacro("__RENDERSCRIPT__");
+ARMleTargetInfo::getTargetDefines(Opts, Builder);
+  }
+};
+
+// 64-bit RenderScript is aarch64
+class RenderScript64TargetInfo : public AArch64leTargetInfo {
+public:
+  RenderScript64TargetInfo(const llvm::Triple &Triple,
+   const TargetOptions &Opts)
+  : AArch64leTargetInfo(llvm::Triple("aarch64", Triple.getVendorName(),
+ Triple.getOSName(),
+ Triple.getEnvironmentName()),
+Opts) {}
+
+  void getTargetDefines(const LangOptions &Opts,
+MacroBuilder &Builder) const override {
+Builder.defineMacro("__RENDERSCRIPT__");
+AArch64leTargetInfo::getTargetDefines(Opts, Builder);
+  }
+};
+
 } // end anonymous namespace
 
 
//===--===//
@@ -8420,6 +8456,11 @@
 if (!(Triple == llvm::Triple("wasm64-unknown-unknown")))
   return nullptr;
 return new WebAssemblyOSTargetInfo(Triple, Opts);
+
+  case llvm::Triple::renderscript32:
+return new LinuxTargetInfo(Triple, Opts);
+  case llvm::Triple::renderscript64:
+return new LinuxTargetInfo(Triple, Opts);
   }
 }
 


Index: test/CodeGen/renderscript.c
===
--- /dev/null
+++ test/CodeGen/renderscript.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -triple=renderscript32-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS32
+// RUN: %clang_cc1 %s -triple=renderscript64-none-linux-android -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS64
+// RUN: %clang_cc1 %s -triple=armv7-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-ARM
+
+// Ensure that the bitcode has the correct triple
+// CHECK-RS32: target triple = "armv7-none-linux-gnueabi"
+// CHECK-RS64: target triple = "aarch64-none-linux-android"
+// CHECK-ARM: target triple = "armv7-none-linux-gnueabi"
+
+// Ensure that long data type has 8-byte size and alignment in RenderScript
+#ifdef __RENDERSCRIPT__
+#define LONG_WIDTH_AND_ALIGN 8
+#else
+#define LONG_WIDTH_AND_ALIGN 4
+#endif
+
+_Static_assert(sizeof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong");
+_Static_assert(_Alignof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong");
+
+// CHECK-RS32: i64 @test_lo

r274378 - [libclang] Sync-up the way top-level decls in an ASTUnit are handled with how decls in a DeclContext are handled.

2016-07-01 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Jul  1 14:10:54 2016
New Revision: 274378

URL: http://llvm.org/viewvc/llvm-project?rev=274378&view=rev
Log:
[libclang] Sync-up the way top-level decls in an ASTUnit are handled with how 
decls in a DeclContext are handled.

rdar://19775013

Modified:
cfe/trunk/test/Index/properties-class-extensions.m
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CursorVisitor.h

Modified: cfe/trunk/test/Index/properties-class-extensions.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/properties-class-extensions.m?rev=274378&r1=274377&r2=274378&view=diff
==
--- cfe/trunk/test/Index/properties-class-extensions.m (original)
+++ cfe/trunk/test/Index/properties-class-extensions.m Fri Jul  1 14:10:54 2016
@@ -70,7 +70,7 @@
 // CHECK-NOT: properties-class-extensions.m:16:25: 
ObjCInstanceMethodDecl=bar:16:25 Extent=[16:25 - 16:28]
 // CHECK: properties-class-extensions.m:19:26: 
ObjCInstanceMethodDecl=setBar::19:26 Extent=[19:26 - 19:29]
 // CHECK: properties-class-extensions.m:19:26: ParmDecl=bar:19:26 (Definition) 
Extent=[19:26 - 19:29]
-// CHECK: properties-class-extensions.m:24:8: 
ObjCInterfaceDecl=Rdar8467189_Bar:24:8 Extent=[24:1 - 24:23]
+// CHECK-NOT: properties-class-extensions.m:24:8: 
ObjCInterfaceDecl=Rdar8467189_Bar:24:8
 // CHECK: properties-class-extensions.m:24:8: 
ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[24:8 - 24:23]
 // CHECK: properties-class-extensions.m:25:11: 
ObjCProtocolDecl=Rdar8467189_FooProtocol:25:11 (Definition) Extent=[25:1 - 27:5]
 // CHECK: properties-class-extensions.m:26:39: 
ObjCPropertyDecl=Rdar8467189_Bar:26:39 [readonly,] Extent=[26:1 - 26:54]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=274378&r1=274377&r2=274378&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Jul  1 14:10:54 2016
@@ -523,8 +523,10 @@ bool CursorVisitor::VisitChildren(CXCurs
   for (ASTUnit::top_level_iterator TL = CXXUnit->top_level_begin(),
 TLEnd = CXXUnit->top_level_end();
TL != TLEnd; ++TL) {
-if (Visit(MakeCXCursor(*TL, TU, RegionOfInterest), true))
-  return true;
+const Optional V = handleDeclForVisitation(*TL);
+if (!V.hasValue())
+  continue;
+return V.getValue();
   }
 } else if (VisitDeclContext(
 
CXXUnit->getASTContext().getTranslationUnitDecl()))
@@ -621,42 +623,50 @@ bool CursorVisitor::VisitDeclContext(Dec
 Decl *D = *I;
 if (D->getLexicalDeclContext() != DC)
   continue;
-CXCursor Cursor = MakeCXCursor(D, TU, RegionOfInterest);
-
-// Ignore synthesized ivars here, otherwise if we have something like:
-//   @synthesize prop = _prop;
-// and '_prop' is not declared, we will encounter a '_prop' ivar before
-// encountering the 'prop' synthesize declaration and we will think that
-// we passed the region-of-interest.
-if (ObjCIvarDecl *ivarD = dyn_cast(D)) {
-  if (ivarD->getSynthesize())
-continue;
-}
-
-// FIXME: ObjCClassRef/ObjCProtocolRef for forward class/protocol
-// declarations is a mismatch with the compiler semantics.
-if (Cursor.kind == CXCursor_ObjCInterfaceDecl) {
-  ObjCInterfaceDecl *ID = cast(D);
-  if (!ID->isThisDeclarationADefinition())
-Cursor = MakeCursorObjCClassRef(ID, ID->getLocation(), TU);
-
-} else if (Cursor.kind == CXCursor_ObjCProtocolDecl) {
-  ObjCProtocolDecl *PD = cast(D);
-  if (!PD->isThisDeclarationADefinition())
-Cursor = MakeCursorObjCProtocolRef(PD, PD->getLocation(), TU);
-}
-
-const Optional &V = shouldVisitCursor(Cursor);
+const Optional V = handleDeclForVisitation(D);
 if (!V.hasValue())
   continue;
-if (!V.getValue())
-  return false;
-if (Visit(Cursor, true))
-  return true;
+return V.getValue();
   }
   return false;
 }
 
+Optional CursorVisitor::handleDeclForVisitation(const Decl *D) {
+  CXCursor Cursor = MakeCXCursor(D, TU, RegionOfInterest);
+
+  // Ignore synthesized ivars here, otherwise if we have something like:
+  //   @synthesize prop = _prop;
+  // and '_prop' is not declared, we will encounter a '_prop' ivar before
+  // encountering the 'prop' synthesize declaration and we will think that
+  // we passed the region-of-interest.
+  if (auto *ivarD = dyn_cast(D)) {
+if (ivarD->getSynthesize())
+  return None;
+  }
+
+  // FIXME: ObjCClassRef/ObjCProtocolRef for forward class/protocol
+  // declarations is a mismatch with the compiler semantics.
+  if (Cursor.kind == CXCursor_ObjCInterfaceDecl) {
+auto *ID = cast(D);
+if (!ID->isThisDeclarationADefi

Re: [PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62523.
sfantao marked an inline comment as done.
sfantao added a comment.

- Use llvm::sys::path::replace_extension to deal with the extension of the 
linker script.


http://reviews.llvm.org/D21847

Files:
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -138,3 +138,95 @@
 // CHK-PHASES-FILES: 38: assembler, {37}, object, (device-openmp)
 // CHK-PHASES-FILES: 39: linker, {26, 32, 38}, image, (device-openmp)
 // CHK-PHASES-FILES: 40: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {11}, "device-openmp (x86_64-pc-linux-gnu)" {25}, "device-openmp (powerpc64-ibm-linux-gnu)" {39}, image
+
+
+/// ###
+
+/// Check of the commands passed to each tool when using valid OpenMP targets.
+/// Here we also check that offloading does not break the use of integrated
+/// assembler. It does however preclude the merge of the host compile and
+/// backend phases. There are also two offloading specific options:
+/// -fopenmp-is-device: will tell the frontend that it will generate code for a
+/// target.
+/// -fopenmp-host-ir-file-path: specifies the host IR file that can be loaded by
+/// the target code generation to gather information about which declaration
+/// really need to be emitted.
+///
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS %s
+// Run the save temp test in a temporary folder as the linker script will be
+// created there.
+// RUN:   cd %T &&  \
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS-ST %s
+// RUN:   FileCheck -check-prefix=CHK-LKS %s --input-file %t.lk
+//
+// Generate host BC file.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]"
+// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+
+//
+// Compile for the powerpc device.
+/
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS: ld" {{.*}}"-o" "[[T1BIN:.+\.out]]" {{.*}}"[[T1OBJ]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]"
+// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]]
+
+//
+// Compile for the x86 device.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj"  {{.*}}"-fopenmp"  {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS: ld" {{.*}}"-o" "[[T2BIN:.+\.out]]" {{.*}}"[[T2OBJ]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]"
+// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]]
+
+//
+// Generate host object from the BC file and link using the linker s

Re: [PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.

2016-07-01 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Hi, Alexy.  Would you mind not asking for 'final' in additional reviews until 
we've resolved this thread elsewhere?  Feel free to find me on IRC if you want 
to talk about it synchronously.

Thanks!


http://reviews.llvm.org/D21845



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review! Addressed the comments in the new diff.


http://reviews.llvm.org/D21847



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.

2016-07-01 Thread Felix Berger via cfe-commits
flx updated this revision to Diff 62524.
flx marked 5 inline comments as done.
flx added a comment.

Thanks for the review. I addressed all remaining comments.


http://reviews.llvm.org/D20277

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.h
  clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tidy/utils/DeclRefExprUtils.h
  clang-tidy/utils/Matchers.h
  clang-tidy/utils/TypeTraits.cpp
  clang-tidy/utils/TypeTraits.h
  docs/clang-tidy/checks/performance-unnecessary-value-param.rst
  test/clang-tidy/performance-unnecessary-value-param.cpp

Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -1,5 +1,7 @@
 // RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
 
+// CHECK-FIXES: #include 
+
 struct ExpensiveToCopyType {
   const ExpensiveToCopyType & constReference() const {
 return *this;
@@ -30,6 +32,15 @@
   void constMethod() const;
 };
 
+struct ExpensiveMovableType {
+  ExpensiveMovableType();
+  ExpensiveMovableType(ExpensiveMovableType &&);
+  ExpensiveMovableType(const ExpensiveMovableType &) = default;
+  ExpensiveMovableType &operator=(const ExpensiveMovableType &) = default;
+  ExpensiveMovableType &operator=(ExpensiveMovableType &&);
+  ~ExpensiveMovableType();
+};
+
 void positiveExpensiveConstValue(const ExpensiveToCopyType Obj);
 // CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj);
 void positiveExpensiveConstValue(const ExpensiveToCopyType Obj) {
@@ -180,3 +191,36 @@
 void NegativeMoveOnlyTypePassedByValue(MoveOnlyType M) {
   M.constMethod();
 }
+
+void PositiveMoveOnCopyConstruction(ExpensiveMovableType E) {
+  auto F = E;
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: parameter 'E' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
+  // CHECK-FIXES: auto F = std::move(E);
+}
+
+void PositiveConstRefNotMoveSinceReferencedMultipleTimes(ExpensiveMovableType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:79: warning: the parameter 'E' is copied
+  // CHECK-FIXES: void PositiveConstRefNotMoveSinceReferencedMultipleTimes(const ExpensiveMovableType& E) {
+  auto F = E;
+  auto G = E;
+}
+
+void PositiveMoveOnCopyAssignment(ExpensiveMovableType E) {
+  ExpensiveMovableType F;
+  F = E;
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: parameter 'E' is passed by value
+  // CHECK-FIXES: F = std::move(E);
+}
+
+void PositiveConstRefNotMoveConstructible(ExpensiveToCopyType T) {
+  // CHECK-MESSAGES: [[@LINE-1]]:63: warning: the parameter 'T' is copied
+  // CHECK-FIXES: void PositiveConstRefNotMoveConstructible(const ExpensiveToCopyType& T) {
+  auto U = T;
+}
+
+void PositiveConstRefNotMoveAssignable(ExpensiveToCopyType A) {
+  // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the parameter 'A' is copied
+  // CHECK-FIXES: void PositiveConstRefNotMoveAssignable(const ExpensiveToCopyType& A) {
+  ExpensiveToCopyType B;
+  B = A;
+}
Index: docs/clang-tidy/checks/performance-unnecessary-value-param.rst
===
--- docs/clang-tidy/checks/performance-unnecessary-value-param.rst
+++ docs/clang-tidy/checks/performance-unnecessary-value-param.rst
@@ -10,7 +10,7 @@
 which means they are not trivially copyable or have a non-trivial copy
 constructor or destructor.
 
-To ensure that it is safe to replace the value paramater with a const reference
+To ensure that it is safe to replace the value parameter with a const reference
 the following heuristic is employed:
 
 1. the parameter is const qualified;
@@ -31,3 +31,25 @@
 Value.ConstMethd();
 ExpensiveToCopy Copy(Value);
   }
+
+If the parameter is not const, only copied or assigned once and has a
+non-trivial move-constructor or move-assignment operator respectively the check
+will suggest to move it.
+
+Example:
+
+.. code-block:: c++
+
+  void setValue(string Value) {
+Field = Value;
+  }
+
+Will become:
+
+.. code-block:: c++
+
+  #include 
+
+  void setValue(string Value) {
+Field = std::move(Value);
+  }
Index: clang-tidy/utils/TypeTraits.h
===
--- clang-tidy/utils/TypeTraits.h
+++ clang-tidy/utils/TypeTraits.h
@@ -29,6 +29,12 @@
 bool recordIsTriviallyDefaultConstructible(const RecordDecl &RecordDecl,
const ASTContext &Context);
 
+/// Returns true if `Type` has a non-trivial move constructor.
+bool hasNonTrivialMoveConstructor(QualType Type);
+
+/// Return true if `Type` has a non-trivial move assignment operator.
+bool hasNonTrivialMoveAssignment(QualType Type);
+
 } // type_traits
 } // namespace utils
 } // namespace tidy
Index: clang-tidy/utils/TypeTraits.cpp
==

Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.

2016-07-01 Thread Felix Berger via cfe-commits
flx added inline comments.


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:34
@@ -29,1 +33,3 @@
 
+template  bool isSetDifferenceEmpty(const S &S1, const S &S2) {
+  for (const auto &E : S1)

alexfh wrote:
> +1 to `isSubset`. And please add a comment explaining what should be a subset 
> of what for this function to return `true`.
Omitted the comment by making the parameter names very explicit.


Comment at: clang-tidy/utils/Matchers.h:50
@@ +49,3 @@
+AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isReferenceToConst) {
+  return ast_matchers::referenceType(ast_matchers::pointee(
+  ast_matchers::qualType(ast_matchers::isConstQualified(;

alexfh wrote:
> How about `using ast_matchers;` in this function to make the statement easier 
> to read?
Used `using namespace ast_matchers;`.


http://reviews.llvm.org/D20277



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r274379 - [Driver] Delete some dead code (NFC)

2016-07-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Jul  1 14:41:20 2016
New Revision: 274379

URL: http://llvm.org/viewvc/llvm-project?rev=274379&view=rev
Log:
[Driver] Delete some dead code (NFC)

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=274379&r1=274378&r2=274379&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul  1 14:41:20 2016
@@ -1738,9 +1738,6 @@ static void getSparcTargetFeatures(const
 
 void Clang::AddSparcTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
-  //const Driver &D = getToolChain().getDriver();
-  std::string Triple = getToolChain().ComputeEffectiveClangTriple(Args);
-
   sparc::FloatABI FloatABI =
   sparc::getSparcFloatABI(getToolChain().getDriver(), Args);
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62525.
sfantao added a comment.

- Remove \brief from one comment.


http://reviews.llvm.org/D21847

Files:
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -138,3 +138,95 @@
 // CHK-PHASES-FILES: 38: assembler, {37}, object, (device-openmp)
 // CHK-PHASES-FILES: 39: linker, {26, 32, 38}, image, (device-openmp)
 // CHK-PHASES-FILES: 40: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {11}, "device-openmp (x86_64-pc-linux-gnu)" {25}, "device-openmp (powerpc64-ibm-linux-gnu)" {39}, image
+
+
+/// ###
+
+/// Check of the commands passed to each tool when using valid OpenMP targets.
+/// Here we also check that offloading does not break the use of integrated
+/// assembler. It does however preclude the merge of the host compile and
+/// backend phases. There are also two offloading specific options:
+/// -fopenmp-is-device: will tell the frontend that it will generate code for a
+/// target.
+/// -fopenmp-host-ir-file-path: specifies the host IR file that can be loaded by
+/// the target code generation to gather information about which declaration
+/// really need to be emitted.
+///
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS %s
+// Run the save temp test in a temporary folder as the linker script will be
+// created there.
+// RUN:   cd %T &&  \
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS-ST %s
+// RUN:   FileCheck -check-prefix=CHK-LKS %s --input-file %t.lk
+//
+// Generate host BC file.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]"
+// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+
+//
+// Compile for the powerpc device.
+/
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS: ld" {{.*}}"-o" "[[T1BIN:.+\.out]]" {{.*}}"[[T1OBJ]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]"
+// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]]
+
+//
+// Compile for the x86 device.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj"  {{.*}}"-fopenmp"  {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS: ld" {{.*}}"-o" "[[T2BIN:.+\.out]]" {{.*}}"[[T2OBJ]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]"
+// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]]
+
+//
+// Generate host object from the BC file and link using the linker script.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"

Re: [PATCH] D21706: [libcxx] refactor for throw

2016-07-01 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

This is getting close.  A nit, and a couple of non-trivial comments.



Comment at: include/exception:262
@@ -261,3 +261,3 @@
 _LIBCPP_INLINE_VISIBILITY
-inline void __libcpp_throw(_Exception const& __e) {
+inline __attribute__((noreturn)) void __libcpp_throw(_Exception const& __e) {
 #ifndef _LIBCPP_NO_EXCEPTIONS

I thought that we were going to add a macro for the "no return if no exceptions"


Comment at: src/future.cpp:96
@@ -96,4 +95,3 @@
 if (__has_value())
-throw 
future_error(make_error_code(future_errc::promise_already_satisfied));
-#endif
+
__libcpp_throw(future_error(make_error_code(future_errc::promise_already_satisfied)));
 __state_ |= __constructed | ready;

Is the indentation right here? (or is phab lying to me?)


Comment at: src/locale.cpp:527
@@ -528,3 +526,3 @@
 #else  // _LIBCPP_NO_EXCEPTIONS
 : __locale_(new __imp(*other.__locale_, name, c))
 #endif

Did you miss one here?


http://reviews.llvm.org/D21706



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21848: [Driver][OpenMP] Add logic for offloading-specific argument translation.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62528.
sfantao marked 3 inline comments as done.
sfantao added a comment.

- Add default initializers to toolchain arguments key and use range based 
iterator in Dtor.


http://reviews.llvm.org/D21848

Files:
  include/clang/Driver/Compilation.h
  include/clang/Driver/ToolChain.h
  lib/Driver/Compilation.cpp
  lib/Driver/Driver.cpp
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -169,25 +169,25 @@
 
 //
 // Compile for the powerpc device.
-/
-// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
 // CHK-COMMANDS: ld" {{.*}}"-o" "[[T1BIN:.+\.out]]" {{.*}}"[[T1OBJ]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]"
-// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]]
+// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]]
 
 //
 // Compile for the x86 device.
 //
-// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj"  {{.*}}"-fopenmp"  {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj"  {{.*}}"-pic-level" "2" {{.*}}"-fopenmp"  {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
 // CHK-COMMANDS: ld" {{.*}}"-o" "[[T2BIN:.+\.out]]" {{.*}}"[[T2OBJ]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]"
-// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]]
+// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]]
 
 //
 // Generate host object from the BC file and link using the linker script.
@@ -228,5 +228,3 @@
 // CHK-LKS:   }
 // CHK-LKS: }
 // CHK-LKS: INSERT BEFORE .data
-
-
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -208,6 +208,9 @@
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
   bool IsIntegratedAssemblerDefault() const override;
+  llvm::opt::DerivedArgList *
+  TranslateArgs(const llvm::opt::DerivedArgList &Args, const char *BoundArch,
+Action::OffloadKind DeviceOffloadKind) const override;
 
 protected:
   Tool *getTool(Action::ActionClass AC) const override;
@@ -306,8 +309,8 @@
   bool HasNativeLLVMSupport() const override;
 
   llvm::opt::DerivedArgList *
-  TranslateArgs(const llvm::opt::DerivedArgList &A

Re: [PATCH] D21848: [Driver][OpenMP] Add logic for offloading-specific argument translation.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: include/clang/Driver/Compilation.h:73
@@ +72,3 @@
+  /// architecture, and device offload kind.
+  struct TCArgsKey {
+const ToolChain *TC;

ABataev wrote:
> 1. 'final'
> 2. default initializers for fields.
I added the default initializers but that required me to add a Ctor so that 
initializer lists work when this struct is built.


Comment at: include/clang/Driver/Compilation.h:206
@@ +205,3 @@
+  const llvm::opt::DerivedArgList &
+  getArgsForToolChain(const ToolChain *TC, const char *BoundArch,
+  Action::OffloadKind DeviceOffloadKind);

ABataev wrote:
> 'const' function?
This one can't be marked const has it potentially changes the cache of 
translated arguments.


http://reviews.llvm.org/D21848



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r274380 - [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.

2016-07-01 Thread Felix Berger via cfe-commits
Author: flx
Date: Fri Jul  1 15:12:15 2016
New Revision: 274380

URL: http://llvm.org/viewvc/llvm-project?rev=274380&view=rev
Log:
[clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const 
value parameter can be moved.

Summary:

Make check more useful in the following two cases:

The parameter is passed by non-const value, has a non-deleted move constructor 
and is only referenced once in the function as argument to the type's copy 
constructor.
The parameter is passed by non-const value, has a non-deleted move assignment 
operator and is only referenced once in the function as argument of the the 
type's copy assignment operator.
In this case suggest a fix to move the parameter which avoids the unnecessary 
copy and is closest to what the user might have intended.

Reviewers: alexfh, sbenza

Subscribers: cfe-commits, Prazek

Differential Revision: http://reviews.llvm.org/D20277

Modified:

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h
clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.h
clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp
clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h

clang-tools-extra/trunk/docs/clang-tidy/checks/performance-unnecessary-value-param.rst

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=274380&r1=274379&r2=274380&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
Fri Jul  1 15:12:15 2016
@@ -12,6 +12,10 @@
 #include "../utils/DeclRefExprUtils.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/Matchers.h"
+#include "../utils/TypeTraits.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
 
 using namespace clang::ast_matchers;
 
@@ -27,8 +31,22 @@ std::string paramNameOrIndex(StringRef N
   .str();
 }
 
+template 
+bool isSubset(const S &SubsetCandidate, const S &SupersetCandidate) {
+  for (const auto &E : SubsetCandidate)
+if (SupersetCandidate.count(E) == 0)
+  return false;
+  return true;
+}
+
 } // namespace
 
+UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
+  Options.get("IncludeStyle", "llvm"))) {}
+
 void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) {
   const auto ExpensiveValueParamDecl =
   parmVarDecl(hasType(hasCanonicalType(allOf(matchers::isExpensiveToCopy(),
@@ -58,12 +76,39 @@ void UnnecessaryValueParamCheck::check(c
   // Do not trigger on non-const value parameters when:
   // 1. they are in a constructor definition since they can likely trigger
   //misc-move-constructor-init which will suggest to move the argument.
-  // 2. they are not only used as const.
   if (!IsConstQualified && (llvm::isa(Function) ||
-!Function->doesThisDeclarationHaveABody() ||
-!utils::decl_ref_expr::isOnlyUsedAsConst(
-*Param, *Function->getBody(), 
*Result.Context)))
+!Function->doesThisDeclarationHaveABody()))
 return;
+
+  auto AllDeclRefExprs = utils::decl_ref_expr::allDeclRefExprs(
+  *Param, *Function->getBody(), *Result.Context);
+  auto ConstDeclRefExprs = utils::decl_ref_expr::constReferenceDeclRefExprs(
+  *Param, *Function->getBody(), *Result.Context);
+  // 2. they are not only used as const.
+  if (!isSubset(AllDeclRefExprs, ConstDeclRefExprs))
+return;
+
+  // If the parameter is non-const, check if it has a move constructor and is
+  // only referenced once to copy-construct another object or whether it has a
+  // move assignment operator and is only referenced once when copy-assigned.
+  // In this case wrap DeclRefExpr with std::move() to avoid the unnecessary
+  // copy.
+  if (!IsConstQualified) {
+auto CanonicalType = Param->getType().getCanonicalType();
+if (AllDeclRefExprs.size() == 1 &&
+((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) &&
+  utils::decl_ref_expr::isCopyConstructorArgument(
+  **AllDeclRefExprs.begin(), *Function->getBody(),
+  *Result.Context)) ||
+ (utils::type_traits::hasNonTrivialMoveAssignment(CanonicalType) &&
+   

Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.

2016-07-01 Thread Felix Berger via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274380: [clang-tidy] UnnecessaryValueParamCheck - suggest 
std::move() if non-const… (authored by flx).

Changed prior to commit:
  http://reviews.llvm.org/D20277?vs=62524&id=62530#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20277

Files:
  clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h
  clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.h
  clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
  clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp
  clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h
  
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-unnecessary-value-param.rst
  
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp

Index: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -12,6 +12,10 @@
 #include "../utils/DeclRefExprUtils.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/Matchers.h"
+#include "../utils/TypeTraits.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
 
 using namespace clang::ast_matchers;
 
@@ -27,8 +31,22 @@
   .str();
 }
 
+template 
+bool isSubset(const S &SubsetCandidate, const S &SupersetCandidate) {
+  for (const auto &E : SubsetCandidate)
+if (SupersetCandidate.count(E) == 0)
+  return false;
+  return true;
+}
+
 } // namespace
 
+UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
+  Options.get("IncludeStyle", "llvm"))) {}
+
 void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) {
   const auto ExpensiveValueParamDecl =
   parmVarDecl(hasType(hasCanonicalType(allOf(matchers::isExpensiveToCopy(),
@@ -58,12 +76,39 @@
   // Do not trigger on non-const value parameters when:
   // 1. they are in a constructor definition since they can likely trigger
   //misc-move-constructor-init which will suggest to move the argument.
-  // 2. they are not only used as const.
   if (!IsConstQualified && (llvm::isa(Function) ||
-!Function->doesThisDeclarationHaveABody() ||
-!utils::decl_ref_expr::isOnlyUsedAsConst(
-*Param, *Function->getBody(), *Result.Context)))
+!Function->doesThisDeclarationHaveABody()))
 return;
+
+  auto AllDeclRefExprs = utils::decl_ref_expr::allDeclRefExprs(
+  *Param, *Function->getBody(), *Result.Context);
+  auto ConstDeclRefExprs = utils::decl_ref_expr::constReferenceDeclRefExprs(
+  *Param, *Function->getBody(), *Result.Context);
+  // 2. they are not only used as const.
+  if (!isSubset(AllDeclRefExprs, ConstDeclRefExprs))
+return;
+
+  // If the parameter is non-const, check if it has a move constructor and is
+  // only referenced once to copy-construct another object or whether it has a
+  // move assignment operator and is only referenced once when copy-assigned.
+  // In this case wrap DeclRefExpr with std::move() to avoid the unnecessary
+  // copy.
+  if (!IsConstQualified) {
+auto CanonicalType = Param->getType().getCanonicalType();
+if (AllDeclRefExprs.size() == 1 &&
+((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) &&
+  utils::decl_ref_expr::isCopyConstructorArgument(
+  **AllDeclRefExprs.begin(), *Function->getBody(),
+  *Result.Context)) ||
+ (utils::type_traits::hasNonTrivialMoveAssignment(CanonicalType) &&
+  utils::decl_ref_expr::isCopyAssignmentArgument(
+  **AllDeclRefExprs.begin(), *Function->getBody(),
+  *Result.Context {
+  handleMoveFix(*Param, **AllDeclRefExprs.begin(), *Result.Context);
+  return;
+}
+  }
+
   auto Diag =
   diag(Param->getLocation(),
IsConstQualified ? "the const qualified parameter %0 is "
@@ -86,6 +131,40 @@
   }
 }
 
+void UnnecessaryValueParamCheck::registerPPCallbacks(
+CompilerInstance &Compiler) {
+  Inserter.reset(new utils::IncludeInserter(
+  Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
+  Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
+}
+
+void UnnecessaryValueParamCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "IncludeStyle",
+utils::IncludeSorter::toString(IncludeStyle));
+}
+

Re: [PATCH] D18172: [CUDA][OpenMP] Add a generic offload action builder

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao added a comment.

In http://reviews.llvm.org/D18172#472152, @jlebar wrote:

> Yeah, I'd say that in the absence of a rule, consistency with surrounding
>  code is king.  Otherwise we're sending a message when we don't mean to be.
>
> I'm not at my machine, but my recollection is that most of the driver uses
>  final sparingly.  But whatever the convention is we should do that, I think.


True, `final` is not widely used in the driver. Again, I don't feel strongly 
about doing this one way or the other. For the moment, I'll update the diffs 
according to what Alexey requested. If you guys decide that I should do that 
differently, I'm happy to go to back to each review and update it accordingly.

Thanks again!
Samuel


http://reviews.llvm.org/D18172



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21303: [clang-tidy] Adds performance-returning-type check.

2016-07-01 Thread Piotr Padlewski via cfe-commits
Prazek added a reviewer: rsmith.
Prazek added a comment.

Adding Richard who was working on standard defect report that deprived sense of 
this check. There are some corner cases that are not in the standard and 
probably won't be handled in the future that we could handle still.


http://reviews.llvm.org/D21303



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21706: [libcxx] refactor for throw

2016-07-01 Thread Weiming Zhao via cfe-commits
weimingz added inline comments.


Comment at: include/exception:262
@@ -261,3 +261,3 @@
 _LIBCPP_INLINE_VISIBILITY
-inline void __libcpp_throw(_Exception const& __e) {
+inline __attribute__((noreturn)) void __libcpp_throw(_Exception const& __e) {
 #ifndef _LIBCPP_NO_EXCEPTIONS

mclow.lists wrote:
> I thought that we were going to add a macro for the "no return if no 
> exceptions"
something like this?

#ifndef __LIBCPP_NO_EXCEPTIONS
  #define NORETURN_EXP __attribute__((noreturn))
#else
  #define NORETURN_EXP
#endif

inline NORETURN_EXP void __libcpp_throw(_Exception const& __e) {
  ...
}


Comment at: src/future.cpp:96
@@ -96,4 +95,3 @@
 if (__has_value())
-throw 
future_error(make_error_code(future_errc::promise_already_satisfied));
-#endif
+
__libcpp_throw(future_error(make_error_code(future_errc::promise_already_satisfied)));
 __state_ |= __constructed | ready;

mclow.lists wrote:
> Is the indentation right here? (or is phab lying to me?)
It looks ok here. The first underscore  is on the same column as "__has_value" 
(the line above). 4 space indention


Comment at: src/locale.cpp:527
@@ -528,3 +526,3 @@
 #else  // _LIBCPP_NO_EXCEPTIONS
 : __locale_(new __imp(*other.__locale_, name, c))
 #endif

mclow.lists wrote:
> Did you miss one here?
The reason I skipeed this and two or three other similar cases is the 
constructor expects the function __libcpp_throw() to return a pointer. 


http://reviews.llvm.org/D21706



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-01 Thread Jake VanAdrighem via cfe-commits
jakev updated this revision to Diff 62527.
jakev added a comment.

Don't allow `-fpgo-train` and `-fpgo-apply` together. Add 
`-fpgo-train-default-output=*` to set the default profile output file.


Repository:
  rL LLVM

http://reviews.llvm.org/D21823

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/clang_f_opts.c

Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -97,23 +97,42 @@
 // RUN: %clang -### -S -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s
 // RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
 // RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
+// RUN: %clang -### -S -fpgo-train=source-cfg %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
+// RUN: %clang -### -S -fpgo-train=optimizer-cfg %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
+// RUN: %clang -### -S -fpgo-train-default-output=file %s 2>&1 | FileCheck -check-prefix=CHECK-DEFAULT-AND-TRAIN %s
+// RUN: %clang -### -S -fpgo-train=source-cfg -fpgo-train-default-output=/tmp/somefile.profraw %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
+// RUN: %clang -### -S -fpgo-train=optimizer-cfg -fpgo-train-default-output=/tmp/somefile.profraw %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
+// RUN: %clang -### -S -fpgo-train=source-cfg -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s
+// RUN: %clang -### -S -fpgo-train=optimizer-cfg -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s
+// RUN: %clang -### -S -fpgo-train=source-cfg -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-TRAIN-GEN %s
+// RUN: %clang -### -S -fpgo-train=optimizer-cfg -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-TRAIN-GEN %s
+// RUN: %clang -### -S -fpgo-train=source-cfg -fpgo-apply=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
+// RUN: %clang -### -S -fpgo-train=optimizer-cfg -fpgo-apply=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
+// CHECK-PROFILE-GENERATE-LLVM: "-fprofile-instrument=llvm"
 // CHECK-PROFILE-GENERATE-DIR: "-fprofile-instrument-path=/some/dir{{/|}}default.profraw"
 // CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
+// CHECK-NO-MIX-TRAIN-GEN: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
 // CHECK-DISABLE-GEN-NOT: "-fprofile-instrument=clang"
 // CHECK-DISABLE-USE-NOT: "-fprofile-instr-use"
 // CHECK-COVERAGE-AND-GEN: '-fcoverage-mapping' only allowed with '-fprofile-instr-generate'
+// CHECK-DEFAULT-AND-TRAIN: '-fpgo-train-default-output' only allowed with '-fpgo-train'
 // CHECK-DISABLE-COVERAGE-NOT: "-fcoverage-mapping"
 
 // RUN: %clang -### -S -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
 // RUN: %clang -### -S -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
 // RUN: mkdir -p %t.d/some/dir
 // RUN: %clang -### -S -fprofile-use=%t.d/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-DIR %s
 // RUN: %clang -### -S -fprofile-instr-use=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
+// RUN: %clang -### -S -fpgo-apply=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
+// RUN: %clang -### -S -fpgo-train=source-cfg -fpgo-apply=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
+// RUN: %clang -### -S -fpgo-train=optimizer-cfg  -fpgo-apply=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
+// RUN: %clang -### -S -fprofile-instr-use=/tmp/somefile.prof -fpgo-apply=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-APPLY-USE %s
 // CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata"
 // CHECK-PROFILE-USE-DIR: "-fprofile-instrument-use-path={{.*}}.d/some/dir{{/|}}default.profdata"
 // CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof"
+// CHECK-NO-MIX-APPLY-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
 
 // RUN: %clang -### -S -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
 // RUN: %clang -### -S -fno-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3468,6 +3468,28 @@
 static void addPGOAndCoverageFlags(Compilation &C, const Driver &D,
const InputInfo &Output, const ArgLi

Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-01 Thread Jake VanAdrighem via cfe-commits
jakev added a comment.

In http://reviews.llvm.org/D21823#470516, @xur wrote:

> (1) It seems the original options of -fprofile-instr-generate and 
> -fprofile-instr-use will be kept. Is so, what is the guideline to use these 
> two sets of options.


Sorry I'm not sure I understand what you're asking, but it's my understanding 
that we would simply detail the lack of interoperability between the existing 
set of flags and the ones added by this patch.

> Also, we need some documentations for the new user-visible

>  options.


I'm happy to add some info to the Clang UserManual in this patch if everyone is 
happy with the flag names.

> (2) One difference b/w -fprofile-instr-generate/-fprofile-instr-use and the 
> new options is -fpgo-train={source-cfg | optimizer-cfg} can coexist with 
> -fpgo-apply=. I don't think they work as intended in current 
> implementation. I would suggest to not allow it.


Sure, I've updated the patch to not allow this.


Repository:
  rL LLVM

http://reviews.llvm.org/D21823



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21031: [OpenCL] Allow -cl-std and other standard -cl- options in driver

2016-07-01 Thread Jan Vesely via cfe-commits
jvesely added a subscriber: jvesely.


Comment at: cfe/trunk/include/clang/Driver/Options.td:381
@@ +380,3 @@
+def cl_unsafe_math_optimizations : Flag<["-"], 
"cl-unsafe-math-optimizations">, Group, Flags<[CC1Option]>,
+  HelpText<"OpenCL only. Allow unsafe floating-point optimizations.  Also 
implies -cl-no-signed-zeros and -cl-mad-enable.">;
+def cl_fast_relaxed_math : Flag<["-"], "cl-fast-relaxed-math">, 
Group, Flags<[CC1Option]>,

It'd be nice if you added cl-no-signed-zeros since it's mentioned here


Repository:
  rL LLVM

http://reviews.llvm.org/D21031



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21936: [clang-tidy] UnnecessaryValueParamCheck - only warn for virtual methods

2016-07-01 Thread Felix Berger via cfe-commits
flx created this revision.
flx added reviewers: alexfh, sbenza.
flx added a subscriber: cfe-commits.
flx set the repository for this revision to rL LLVM.

As changing virtual methods could break method overrides disable applying the 
fix and just warn.

Repository:
  rL LLVM

http://reviews.llvm.org/D21936

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp

Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -224,3 +224,16 @@
   ExpensiveToCopyType B;
   B = A;
 }
+
+struct VirtualMethodWarningOnly {
+  virtual void methodWithExpensiveValueParam(ExpensiveToCopyType T) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:66: warning: the parameter 'T' is copied
+  // CHECK-FIXES: virtual void 
methodWithExpensiveValueParam(ExpensiveToCopyType T) {}
+  virtual ~VirtualMethodWarningOnly() {}
+};
+
+struct PositiveNonVirualMethod {
+  void method(const ExpensiveToCopyType T) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:41: warning: the const qualified parameter 
'T' is copied
+  // CHECK-FIXES: void method(const ExpensiveToCopyType& T) {}
+};
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -118,8 +118,10 @@
   "invocation but only used as a const reference; "
   "consider making it a const reference")
   << paramNameOrIndex(Param->getName(), Index);
-  // Do not propose fixes in macros since we cannot place them correctly.
-  if (Param->getLocStart().isMacroID())
+  // Do not propose fixes in macros since we cannot place them correctly, or if
+  // function is virtual as it might break overrides.
+  const auto *Method = llvm::dyn_cast(Function);
+  if (Param->getLocStart().isMacroID() || (Method && Method->isVirtual()))
 return;
   for (const auto *FunctionDecl = Function; FunctionDecl != nullptr;
FunctionDecl = FunctionDecl->getPreviousDecl()) {


Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -224,3 +224,16 @@
   ExpensiveToCopyType B;
   B = A;
 }
+
+struct VirtualMethodWarningOnly {
+  virtual void methodWithExpensiveValueParam(ExpensiveToCopyType T) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:66: warning: the parameter 'T' is copied
+  // CHECK-FIXES: virtual void methodWithExpensiveValueParam(ExpensiveToCopyType T) {}
+  virtual ~VirtualMethodWarningOnly() {}
+};
+
+struct PositiveNonVirualMethod {
+  void method(const ExpensiveToCopyType T) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:41: warning: the const qualified parameter 'T' is copied
+  // CHECK-FIXES: void method(const ExpensiveToCopyType& T) {}
+};
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -118,8 +118,10 @@
   "invocation but only used as a const reference; "
   "consider making it a const reference")
   << paramNameOrIndex(Param->getName(), Index);
-  // Do not propose fixes in macros since we cannot place them correctly.
-  if (Param->getLocStart().isMacroID())
+  // Do not propose fixes in macros since we cannot place them correctly, or if
+  // function is virtual as it might break overrides.
+  const auto *Method = llvm::dyn_cast(Function);
+  if (Param->getLocStart().isMacroID() || (Method && Method->isVirtual()))
 return;
   for (const auto *FunctionDecl = Function; FunctionDecl != nullptr;
FunctionDecl = FunctionDecl->getPreviousDecl()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62538.
sfantao marked 9 inline comments as done.
sfantao added a comment.

- Merge branch 'master' into patch-D13909
- Remove unecessary returns and fix iterators.


http://reviews.llvm.org/D13909

Files:
  test/CMakeLists.txt
  test/Driver/clang-offload-bundler.c
  tools/CMakeLists.txt
  tools/clang-offload-bundler/CMakeLists.txt
  tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- /dev/null
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -0,0 +1,671 @@
+//===-- clang-offload-bundler/ClangOffloadBundler.cpp - Clang format tool -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements a clang-offload-bundler that bundles different
+/// files that relate with the same source code but different targets into a
+/// single one. Also the implements the opposite functionality, i.e. unbundle
+/// files previous created by this tool.
+///
+//===--===//
+
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/Version.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+
+using namespace llvm;
+using namespace llvm::object;
+
+static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+// Mark all our options with this category, everything else (except for -version
+// and -help) will be hidden.
+static cl::OptionCategory
+ClangOffloadBundlerCategory("clang-offload-bundler options");
+
+static cl::list
+InputFileNames("inputs", cl::CommaSeparated, cl::OneOrMore,
+   cl::desc("[,...]"),
+   cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+OutputFileNames("outputs", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+TargetNames("targets", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[-,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+FilesType("type", cl::Required,
+  cl::desc("Type of the files to be bundled/unbundled.\n"
+   "Current supported types are:\n"
+   "  i   - cpp-output\n"
+   "  ii  - c++-cpp-output\n"
+   "  ll  - llvm\n"
+   "  bc  - llvm-bc\n"
+   "  s   - assembler\n"
+   "  o   - object\n"
+   "  gch - precompiled-header\n"
+   "  ast - clang AST file"),
+  cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+Unbundle("unbundle",
+ cl::desc("Unbundle bundled file into several output files.\n"),
+ cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
+/// \brief Magic string that marks the existence of offloading data.
+#define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
+
+/// \brief Obtain the offload kind and real machine triple out of the target
+/// information specified by the user.
+static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
+StringRef &Triple) {
+  auto KindTriplePair = Target.split('-');
+  OffloadKind = KindTriplePair.first;
+  Triple = KindTriplePair.second;
+}
+static bool hasHostKind(StringRef Target) {
+  StringRef OffloadKind;
+  StringRef Triple;
+  getOffloadKindAndTriple(Target, OffloadKind, Triple);
+  return OffloadKind == "host";
+}
+
+/// \brief Generic file handler interface.
+class FileHandler {
+public:
+  /// \brief Update the file handler with information from the header of the
+  /// bundled file
+  virtual void ReadHeader(MemoryBuffer &Input) = 0;
+  /// \brief Read the marker of the next bundled to be read in the file. The
+  /// triple of the target associated with that bundled is returned. An empty
+  /// string is returned if there are no more bundles to be read.
+  virtual StringRef ReadBundleStart(MemoryBuffer &Input) = 0;
+  /// \brief Read the marker that closes the current bundle.
+  virtual void ReadBundleEnd(MemoryBuffer &Input) = 0;
+  /// \brief Read the current bundle and write the

Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: test/Driver/clang-offload-bundler.c:14
@@ +13,3 @@
+//
+// RUN: touch %t.empty
+

ABataev wrote:
> Hmm, will it work on Windows? Maybe it is better just to add an empty test 
> file?
I see many other tests in clang using it. There used to be a directive 
`//requires-shell` but I don't think that is being used now. Should I go ahead 
and create an empty file? Unfortunately, it is not easy for me to try these 
things on Windows.


Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:477-478
@@ +476,4 @@
+  auto Input = InputBuffers.begin();
+  for (auto Triple = TargetNames.begin(); Triple < TargetNames.end();
+   ++Triple, ++Input) {
+FH.get()->WriteBundleStart(OutputFile, *Triple);

ABataev wrote:
> for (auto &Triple : TargetNames)
> 
Ok, moved the iterator `Input` to the end of the loop body.


Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:513-514
@@ +512,4 @@
+  auto Output = OutputFileNames.begin();
+  for (auto Triple = TargetNames.begin(); Triple < TargetNames.end();
+   ++Triple, ++Output)
+Worklist[*Triple] = *Output;

ABataev wrote:
> for (auto &Triple : TargetNames)
Ok, moved `Output` iterator to the bottom of the loop body.


http://reviews.llvm.org/D13909



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62540.
sfantao added a comment.

- Remove \brief when not needed.


http://reviews.llvm.org/D13909

Files:
  test/CMakeLists.txt
  test/Driver/clang-offload-bundler.c
  tools/CMakeLists.txt
  tools/clang-offload-bundler/CMakeLists.txt
  tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- /dev/null
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -0,0 +1,670 @@
+//===-- clang-offload-bundler/ClangOffloadBundler.cpp - Clang format tool -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements a clang-offload-bundler that bundles different
+/// files that relate with the same source code but different targets into a
+/// single one. Also the implements the opposite functionality, i.e. unbundle
+/// files previous created by this tool.
+///
+//===--===//
+
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/Version.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+
+using namespace llvm;
+using namespace llvm::object;
+
+static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+// Mark all our options with this category, everything else (except for -version
+// and -help) will be hidden.
+static cl::OptionCategory
+ClangOffloadBundlerCategory("clang-offload-bundler options");
+
+static cl::list
+InputFileNames("inputs", cl::CommaSeparated, cl::OneOrMore,
+   cl::desc("[,...]"),
+   cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+OutputFileNames("outputs", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+TargetNames("targets", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[-,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+FilesType("type", cl::Required,
+  cl::desc("Type of the files to be bundled/unbundled.\n"
+   "Current supported types are:\n"
+   "  i   - cpp-output\n"
+   "  ii  - c++-cpp-output\n"
+   "  ll  - llvm\n"
+   "  bc  - llvm-bc\n"
+   "  s   - assembler\n"
+   "  o   - object\n"
+   "  gch - precompiled-header\n"
+   "  ast - clang AST file"),
+  cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+Unbundle("unbundle",
+ cl::desc("Unbundle bundled file into several output files.\n"),
+ cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
+/// Magic string that marks the existence of offloading data.
+#define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
+
+/// Obtain the offload kind and real machine triple out of the target
+/// information specified by the user.
+static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
+StringRef &Triple) {
+  auto KindTriplePair = Target.split('-');
+  OffloadKind = KindTriplePair.first;
+  Triple = KindTriplePair.second;
+}
+static bool hasHostKind(StringRef Target) {
+  StringRef OffloadKind;
+  StringRef Triple;
+  getOffloadKindAndTriple(Target, OffloadKind, Triple);
+  return OffloadKind == "host";
+}
+
+/// Generic file handler interface.
+class FileHandler {
+public:
+  /// Update the file handler with information from the header of the bundled
+  /// file
+  virtual void ReadHeader(MemoryBuffer &Input) = 0;
+  /// Read the marker of the next bundled to be read in the file. The triple of
+  /// the target associated with that bundled is returned. An empty string is
+  /// returned if there are no more bundles to be read.
+  virtual StringRef ReadBundleStart(MemoryBuffer &Input) = 0;
+  /// Read the marker that closes the current bundle.
+  virtual void ReadBundleEnd(MemoryBuffer &Input) = 0;
+  /// Read the current bundle and write the result into the stream \a OS.
+  virtual void ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0;
+
+  /// Write the header of the bundled fi

r274385 - [Temporary, Lifetime] Add lifetime marks for temporaries

2016-07-01 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Jul  1 16:08:47 2016
New Revision: 274385

URL: http://llvm.org/viewvc/llvm-project?rev=274385&view=rev
Log:
[Temporary, Lifetime] Add lifetime marks for temporaries

With all MaterializeTemporaryExprs coming with a ExprWithCleanups, it's
easy to add correct lifetime.end marks into the right RunCleanupsScope.

Differential Revision: http://reviews.llvm.org/D20499

Added:
cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp
cfe/trunk/test/CodeGen/temporary-lifetime.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/EHScopeStack.h
cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=274385&r1=274384&r2=274385&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Fri Jul  1 16:08:47 2016
@@ -188,6 +188,7 @@ void *EHScopeStack::pushCleanup(CleanupK
   bool IsNormalCleanup = Kind & NormalCleanup;
   bool IsEHCleanup = Kind & EHCleanup;
   bool IsActive = !(Kind & InactiveCleanup);
+  bool IsLifetimeMarker = Kind & LifetimeMarker;
   EHCleanupScope *Scope =
 new (Buffer) EHCleanupScope(IsNormalCleanup,
 IsEHCleanup,
@@ -200,6 +201,8 @@ void *EHScopeStack::pushCleanup(CleanupK
 InnermostNormalCleanup = stable_begin();
   if (IsEHCleanup)
 InnermostEHScope = stable_begin();
+  if (IsLifetimeMarker)
+Scope->setLifetimeMarker();
 
   return Scope->getCleanupBuffer();
 }

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=274385&r1=274384&r2=274385&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Jul  1 16:08:47 2016
@@ -529,19 +529,6 @@ namespace {
   CGF.EmitCall(FnInfo, CleanupFn, ReturnValueSlot(), Args);
 }
   };
-
-  /// A cleanup to call @llvm.lifetime.end.
-  class CallLifetimeEnd final : public EHScopeStack::Cleanup {
-llvm::Value *Addr;
-llvm::Value *Size;
-  public:
-CallLifetimeEnd(Address addr, llvm::Value *size)
-  : Addr(addr.getPointer()), Size(size) {}
-
-void Emit(CodeGenFunction &CGF, Flags flags) override {
-  CGF.EmitLifetimeEnd(Size, Addr);
-}
-  };
 } // end anonymous namespace
 
 /// EmitAutoVarWithLifetime - Does the setup required for an automatic
@@ -1406,13 +1393,10 @@ void CodeGenFunction::EmitAutoVarCleanup
 
   // Make sure we call @llvm.lifetime.end.  This needs to happen
   // *last*, so the cleanup needs to be pushed *first*.
-  if (emission.useLifetimeMarkers()) {
-EHStack.pushCleanup(NormalAndEHCleanup,
+  if (emission.useLifetimeMarkers())
+EHStack.pushCleanup(NormalEHLifetimeMarker,
  emission.getAllocatedAddress(),
  emission.getSizeForLifetimeMarkers());
-EHCleanupScope &cleanup = cast(*EHStack.begin());
-cleanup.setLifetimeMarker();
-  }
 
   // Check the type for a cleanup.
   if (QualType::DestructionKind dtorKind = D.getType().isDestructedType())

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=274385&r1=274384&r2=274385&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Jul  1 16:08:47 2016
@@ -11,13 +11,14 @@
 //
 
//===--===//
 
-#include "CodeGenFunction.h"
 #include "CGCXXABI.h"
 #include "CGCall.h"
+#include "CGCleanup.h"
 #include "CGDebugInfo.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenMPRuntime.h"
 #include "CGRecordLayout.h"
+#include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
@@ -423,6 +424,23 @@ EmitMaterializeTemporaryExpr(const Mater
   EmitAnyExprToMem(E, Object, Qualifiers(), /*IsInit*/true);
 }
   } else {
+switch (M->getStorageDuration()) {
+case SD_Automatic:
+case SD_FullExpression:
+  if (auto *Size = EmitLifetimeStart(
+  CGM.getDataLayout().getTypeAllocSize(Object.getElementType()),
+  Object.getPointer())) {
+if (M->getStorageDuration() == SD_Automatic)
+  pushCleanupAfterFullExpr(NormalEHLifetimeMarker,
+Object, Size);
+else
+  pushFullExprCleanup(NormalEHLifetimeMarker, Object,
+   Size);
+  }
+  break;
+default:
+  b

Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries

2016-07-01 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
timshen marked an inline comment as done.
Closed by commit rL274385: [Temporary, Lifetime] Add lifetime marks for 
temporaries (authored by timshen).

Changed prior to commit:
  http://reviews.llvm.org/D20499?vs=62433&id=62543#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20499

Files:
  cfe/trunk/lib/CodeGen/CGCleanup.cpp
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/EHScopeStack.h
  cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp
  cfe/trunk/test/CodeGen/temporary-lifetime.cpp
  cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Index: cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp
===
--- cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp
+++ cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -fexceptions -fcxx-exceptions -std=c++11 -O1 -triple x86_64 -emit-llvm -o - | FileCheck %s
+
+// lifetime.end should be invoked even if the destructor doesn't run due to an
+// exception thrown from previous ctor call.
+
+struct A { A(); ~A(); };
+A Baz(const A&);
+
+void Test1() {
+  // CHECK-LABEL: @_Z5Test1v(
+  // CHECK: getelementptr
+  // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* [[TMP:[^ ]+]])
+  // CHECK-NEXT: getelementptr
+  // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* [[TMP1:[^ ]+]])
+
+  // Normal exit
+  // CHECK: call void @llvm.lifetime.end(i64 1, i8* [[TMP1]])
+  // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* [[TMP]])
+
+  // Exception exit
+  // CHECK: call void @llvm.lifetime.end(i64 1, i8* [[TMP1]])
+  // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* [[TMP]])
+  Baz(Baz(A()));
+}
Index: cfe/trunk/test/CodeGen/temporary-lifetime.cpp
===
--- cfe/trunk/test/CodeGen/temporary-lifetime.cpp
+++ cfe/trunk/test/CodeGen/temporary-lifetime.cpp
@@ -0,0 +1,165 @@
+// RUN: %clang_cc1 %s -std=c++11 -O1 -DWITH_DTOR -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-DTOR %s
+// RUN: %clang_cc1 %s -std=c++11 -O1 -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-NO-DTOR %s
+
+struct A {
+  A();
+#ifdef WITH_DTOR
+  ~A();
+#endif
+  char a[1024];
+  operator bool() const;
+};
+
+template 
+void Foo(T &&);
+
+template 
+void Bar(T &&);
+
+template 
+T Baz();
+
+void Test1() {
+  // CHECK-DTOR-LABEL: Test1
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-DTOR: }
+
+  // CHECK-NO-DTOR-LABEL: Test1
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-NO-DTOR: }
+  {
+const A &a = A{};
+Foo(a);
+  }
+  {
+const A &a = A{};
+Foo(a);
+  }
+}
+
+void Test2() {
+  // CHECK-DTOR-LABEL: Test2
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR2:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR2]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR2]])
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR1]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR1]])
+  // CHECK-DTOR: }
+
+  // CHECK-NO-DTOR-LABEL: Test2
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvO

Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-01 Thread David Li via cfe-commits
davidxl added inline comments.


Comment at: include/clang/Driver/Options.td:507
@@ +506,3 @@
+Group, Flags<[DriverOption]>, MetaVarName<"">,
+HelpText<"Set  to be the default profile output file (overridden by 
LLVM_PROFILE_FILE env var)">;
+def fpgo_apply_EQ : Joined<["-"], "fpgo-apply=">,

Why is it called 'default' output? The default output is the one used why user 
does not specify any name.

Why not just -fpgo-train-output=... ?


Comment at: lib/Driver/Tools.cpp:3560
@@ +3559,3 @@
+if (PGOTrainArg->getOption().matches(options::OPT_fpgo_train_EQ)) {
+  if (StringRef(PGOTrainArg->getValue()) == "source-cfg")
+CmdArgs.push_back("-fprofile-instrument=clang");

I think it is better to make the selector  'source' vs 'cfg'.

-fpgo-train=source
-fpgo-train=cfg


Repository:
  rL LLVM

http://reviews.llvm.org/D21823



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r274387 - Remove unncessary CHECKs from r274385

2016-07-01 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Jul  1 16:16:58 2016
New Revision: 274387

URL: http://llvm.org/viewvc/llvm-project?rev=274387&view=rev
Log:
Remove unncessary CHECKs from r274385

Modified:
cfe/trunk/test/CodeGen/temporary-lifetime.cpp

Modified: cfe/trunk/test/CodeGen/temporary-lifetime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/temporary-lifetime.cpp?rev=274387&r1=274386&r2=274387&view=diff
==
--- cfe/trunk/test/CodeGen/temporary-lifetime.cpp (original)
+++ cfe/trunk/test/CodeGen/temporary-lifetime.cpp Fri Jul  1 16:16:58 2016
@@ -85,7 +85,6 @@ void Test2() {
 
 void Test3() {
   // CHECK-DTOR-LABEL: Test3
-  // CHECK-DTOR: entry:
   // CHECK-DTOR: call void @llvm.lifetime.start
   // CHECK-DTOR: call void @llvm.lifetime.start
   // CHECK-DTOR: if.then:
@@ -105,7 +104,6 @@ void Test3() {
 
 void Test4() {
   // CHECK-DTOR-LABEL: Test4
-  // CHECK-DTOR: entry:
   // CHECK-DTOR: call void @llvm.lifetime.start
   // CHECK-DTOR: for.cond.cleanup:
   // CHECK-DTOR: call void @llvm.lifetime.end


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries

2016-07-01 Thread Tim Shen via cfe-commits
timshen added a comment.

Also committed r274387 to remove unnecessary CHECks. It seems to cause problems 
in certain platforms.


Repository:
  rL LLVM

http://reviews.llvm.org/D20499



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21334: Add TargetInfo for 32-bit and 64-bit RenderScript

2016-07-01 Thread Eric Christopher via cfe-commits
echristo added a comment.

In http://reviews.llvm.org/D21334#472548, @pirama wrote:

> Reformatted with clang-format for just the parts I added.  I ignored
>  clang-format-suggested changes in code unrelated to this patch.


Yep.

> Is there a policy or practise on periodically fixing format-related issues?  
> If

>  not, I can format this file in an one-off basis in a separate patch.


In general just format the lines you change and surrounding ones if it makes 
sense to reflow a function.

Thanks!

-eric


http://reviews.llvm.org/D21334



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62550.
sfantao marked 6 inline comments as done.
sfantao added a comment.

- Remove \brief and return errors instead of crashing when temporary tiles 
can't be created.


http://reviews.llvm.org/D21851

Files:
  test/Driver/clang-offload-bundler.c
  tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -75,14 +75,23 @@
 /// Magic string that marks the existence of offloading data.
 #define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
 
+/// Path to the current binary.
+static std::string BundlerExecutable;
+
 /// Obtain the offload kind and real machine triple out of the target
 /// information specified by the user.
 static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
 StringRef &Triple) {
   auto KindTriplePair = Target.split('-');
   OffloadKind = KindTriplePair.first;
   Triple = KindTriplePair.second;
 }
+static StringRef getTriple(StringRef Target) {
+  StringRef OffloadKind;
+  StringRef Triple;
+  getOffloadKindAndTriple(Target, OffloadKind, Triple);
+  return Triple;
+}
 static bool hasHostKind(StringRef Target) {
   StringRef OffloadKind;
   StringRef Triple;
@@ -113,37 +122,37 @@
   /// \a OS.
   virtual void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) = 0;
   /// Write the marker that closes a bundle for the triple \a TargetTriple to \a
-  /// OS.
-  virtual void WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0;
+  /// OS. Return true if any error was found.
+  virtual bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0;
   /// Write the bundle from \a Input into \a OS.
   virtual void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0;
 
   FileHandler() {}
   virtual ~FileHandler() {}
 };
 
-// Handler for binary files. The bundled file will have the following format
-// (all integers are stored in little-endian format):
-//
-// "OFFLOAD_BUNDLER_MAGIC_STR" (ASCII encoding of the string)
-//
-// NumberOfOffloadBundles (8-byte integer)
-//
-// OffsetOfBundle1 (8-byte integer)
-// SizeOfBundle1 (8-byte integer)
-// NumberOfBytesInTripleOfBundle1 (8-byte integer)
-// TripleOfBundle1 (byte length defined before)
-//
-// ...
-//
-// OffsetOfBundleN (8-byte integer)
-// SizeOfBundleN (8-byte integer)
-// NumberOfBytesInTripleOfBundleN (8-byte integer)
-// TripleOfBundleN (byte length defined before)
-//
-// Bundle1
-// ...
-// BundleN
+/// Handler for binary files. The bundled file will have the following format
+/// (all integers are stored in little-endian format):
+///
+/// "OFFLOAD_BUNDLER_MAGIC_STR" (ASCII encoding of the string)
+///
+/// NumberOfOffloadBundles (8-byte integer)
+///
+/// OffsetOfBundle1 (8-byte integer)
+/// SizeOfBundle1 (8-byte integer)
+/// NumberOfBytesInTripleOfBundle1 (8-byte integer)
+/// TripleOfBundle1 (byte length defined before)
+///
+/// ...
+///
+/// OffsetOfBundleN (8-byte integer)
+/// SizeOfBundleN (8-byte integer)
+/// NumberOfBytesInTripleOfBundleN (8-byte integer)
+/// TripleOfBundleN (byte length defined before)
+///
+/// Bundle1
+/// ...
+/// BundleN
 
 /// Read 8-byte integers to/from a buffer in little-endian format.
 static uint64_t Read8byteIntegerFromBuffer(StringRef Buffer, size_t pos) {
@@ -300,24 +309,241 @@
 }
   }
   void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) {}
-  void WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) {}
+  bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) {
+return false;
+  }
   void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) {
 OS.write(Input.getBufferStart(), Input.getBufferSize());
   }
 
   BinaryFileHandler() : FileHandler() {}
   ~BinaryFileHandler() {}
 };
 
-// Handler for text files. The bundled file will have the following format.
-//
-// "Comment OFFLOAD_BUNDLER_MAGIC_STR__START__ triple"
-// Bundle 1
-// "Comment OFFLOAD_BUNDLER_MAGIC_STR__END__ triple"
-// ...
-// "Comment OFFLOAD_BUNDLER_MAGIC_STR__START__ triple"
-// Bundle N
-// "Comment OFFLOAD_BUNDLER_MAGIC_STR__END__ triple"
+/// Handler for object files. The bundles are organized by sections with a
+/// designated name.
+///
+/// In order to bundle we create an IR file with the content of each section and
+/// use incremental linking to produce the resulting object. We also add section
+/// with a single byte to state the name of the component the main object file
+/// (the one we are bundling into) refers to.
+///
+/// To unbundle, we use just copy the contents of the designated section. If the
+/// requested bundle refer to the main object file, we just copy it with no
+/// changes.
+class ObjectFileHandler final : public FileHandler {
+
+  /// The object file we are currently dealing with.
+  

Re: [PATCH] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:345
@@ +344,3 @@
+  /// return the triple by reference.
+  bool isOffloadSection(SectionRef CurSection, StringRef &OffloadTriple) {
+StringRef SectionName;

ABataev wrote:
> 'const'? or 'static'?
It can be static.


Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:450
@@ +449,3 @@
+ BitcodeFileName))
+  llvm_unreachable("Error trying to create temporary file!");
+

ABataev wrote:
> Not sure that this a good solution to crash the compiler in this case. I 
> think it must exit gracefully.
Ok, replaced the unreachable code with logic to emit an error and exist the 
tool.


Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:468
@@ +467,3 @@
+  sys::fs::remove(BitcodeFileName);
+  llvm_unreachable("Can't find clang in path!");
+}

ABataev wrote:
> Again, maybe just emit an error an exit?
Emitting an error now.


http://reviews.llvm.org/D21851



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21852: [Driver][OpenMP] Update actions builder to create bundling action when necessary.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62553.
sfantao added a comment.

- Rebase.
- Fix format.


http://reviews.llvm.org/D21852

Files:
  include/clang/Driver/Action.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -228,3 +228,31 @@
 // CHK-LKS:   }
 // CHK-LKS: }
 // CHK-LKS: INSERT BEFORE .data
+
+
+/// ###
+
+/// Check separate compilation with offloading - bundling actions
+// RUN:   %clang -### -ccc-print-phases -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BUACTIONS %s
+
+// CHK-BUACTIONS: 0: input, "[[INPUT:.+\.c]]", c, (host-openmp)
+// CHK-BUACTIONS: 1: preprocessor, {0}, cpp-output, (host-openmp)
+// CHK-BUACTIONS: 2: compiler, {1}, ir, (host-openmp)
+// CHK-BUACTIONS: 3: input, "[[INPUT]]", c, (device-openmp)
+// CHK-BUACTIONS: 4: preprocessor, {3}, cpp-output, (device-openmp)
+// CHK-BUACTIONS: 5: compiler, {4}, ir, (device-openmp)
+// CHK-BUACTIONS: 6: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (powerpc64le-ibm-linux-gnu)" {5}, ir
+// CHK-BUACTIONS: 7: backend, {6}, assembler, (device-openmp)
+// CHK-BUACTIONS: 8: assembler, {7}, object, (device-openmp)
+// CHK-BUACTIONS: 9: offload, "device-openmp (powerpc64le-ibm-linux-gnu)" {8}, object
+// CHK-BUACTIONS: 10: input, "[[INPUT]]", c, (device-openmp)
+// CHK-BUACTIONS: 11: preprocessor, {10}, cpp-output, (device-openmp)
+// CHK-BUACTIONS: 12: compiler, {11}, ir, (device-openmp)
+// CHK-BUACTIONS: 13: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {12}, ir
+// CHK-BUACTIONS: 14: backend, {13}, assembler, (device-openmp)
+// CHK-BUACTIONS: 15: assembler, {14}, object, (device-openmp)
+// CHK-BUACTIONS: 16: offload, "device-openmp (x86_64-pc-linux-gnu)" {15}, object
+// CHK-BUACTIONS: 17: backend, {2}, assembler, (host-openmp)
+// CHK-BUACTIONS: 18: assembler, {17}, object, (host-openmp)
+// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp)
\ No newline at end of file
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -262,6 +262,10 @@
   case Action::VerifyPCHJobClass:
   case Action::BackendJobClass:
 return getClang();
+
+  case Action::OffloadBundlingJobClass:
+// FIXME: Add a tool for the bundling actions.
+return nullptr;
   }
 
   llvm_unreachable("Invalid tool kind.");
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1549,6 +1549,9 @@
 /// found.
 virtual bool initialize() { return false; }
 
+/// Return true if the builder can use bundling/unbundling.
+virtual bool canUseBundlerUnbundler() const { return false; }
+
 /// Return true if this builder is valid. We have a valid builder if we have
 /// associated device tool chains.
 bool isValid() { return !ToolChains.empty(); }
@@ -1870,6 +1873,26 @@
   return ABRT_Success;
 }
 
+void appendTopLevelActions(ActionList &AL) override {
+  if (OpenMPDeviceActions.empty())
+return;
+
+  // We should always have an action for each input.
+  assert(OpenMPDeviceActions.size() == ToolChains.size() &&
+ "Number of OpenMP actions and toolchains do not match.");
+
+  // Append all device actions followed by the proper offload action.
+  auto TI = ToolChains.begin();
+  for (auto *A : OpenMPDeviceActions) {
+OffloadAction::DeviceDependences Dep;
+Dep.add(*A, **TI, /*BoundArch=*/nullptr, Action::OFK_OpenMP);
+AL.push_back(C.MakeAction(Dep, A->getType()));
+++TI;
+  }
+  // We no longer need the action stored in this builder.
+  OpenMPDeviceActions.clear();
+}
+
 void appendLinkDependences(OffloadAction::DeviceDependences &DA) override {
   assert(ToolChains.size() == DeviceLinkerInputs.size() &&
  "Toolchains and linker inputs sizes do not match.");
@@ -1896,6 +1919,11 @@
   DeviceLinkerInputs.resize(ToolChains.size());
   return false;
 }
+
+bool canUseBundlerUnbundler() const override {
+  // OpenMP should use bundled files whenever possible.
+  return true;
+}
   };
 
   ///
@@ -1905,6 +1933,9 @@
   /// Specialized builders being used by this offloading action builder.
   SmallVector SpecializedBuilders;
 
+  /// Flag set to true if all valid builders allow file bundling/unbundling.
+  bool CanUseBundler;
+
 public:
   OffloadingActionBuilder(Compilation &C, DerivedArgList &Args,
  

r274392 - C++14 init-capture: error out instead of crashing.

2016-07-01 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Jul  1 17:27:16 2016
New Revision: 274392

URL: http://llvm.org/viewvc/llvm-project?rev=274392&view=rev
Log:
C++14 init-capture: error out instead of crashing.

When we have template arguments, we have a function and a pattern, the variable
in init-capture belongs to the pattern decl when checking if the lhs of
"max = current" is modifiable:
  auto find = [max = init](auto current) {
max = current;
  };

In function isReferenceToNonConstCapture, we handle the case where the decl
context for the variable is not part of the current context.

Instead of crashing, we emit an error message:
cannot assign to a variable captured by copy in a non-mutable lambda

rdar://26997922

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=274392&r1=274391&r2=274392&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jul  1 17:27:16 2016
@@ -9653,7 +9653,16 @@ static NonConstCaptureKind isReferenceTo
 
   // Decide whether the first capture was for a block or a lambda.
   DeclContext *DC = S.CurContext, *Prev = nullptr;
-  while (DC != var->getDeclContext()) {
+  // Decide whether the first capture was for a block or a lambda.
+  while (DC) {
+// For init-capture, it is possible that the variable belongs to the
+// template pattern of the current context.
+if (auto *FD = dyn_cast(DC))
+  if (var->isInitCapture() &&
+  FD->getTemplateInstantiationPattern() == var->getDeclContext())
+break;
+if (DC == var->getDeclContext())
+  break;
 Prev = DC;
 DC = DC->getParent();
   }

Modified: cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp?rev=274392&r1=274391&r2=274392&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp Fri Jul  1 17:27:16 2016
@@ -196,3 +196,13 @@ namespace N3922 {
   auto a = [x{X()}] { return x.n; }; // ok
   auto b = [x = {X()}] {}; // expected-error{{}}
 }
+
+namespace init_capture_non_mutable {
+void test(double weight) {
+  double init;
+  auto find = [max = init](auto current) {
+max = current; // expected-error{{cannot assign to a variable captured by 
copy in a non-mutable lambda}}
+  };
+  find(weight); // expected-note {{in instantiation of function template 
specialization}}
+}
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: include/clang/Driver/Types.h:78
@@ +77,3 @@
+  /// compilation phase is a preprocessor one.
+  bool isSrcFile(ID Id);
+

ABataev wrote:
> 'const'?
`isSrcFile` is not member of a class. It is an externally visible function of 
the namespace `types`, therefore can't mark it const.


http://reviews.llvm.org/D21853



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62558.
sfantao marked 3 inline comments as done.
sfantao added a comment.

- Mark classes 'final' and set defalt initializers.


http://reviews.llvm.org/D21853

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Types.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/Types.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -255,4 +255,57 @@
 // CHK-BUACTIONS: 16: offload, "device-openmp (x86_64-pc-linux-gnu)" {15}, object
 // CHK-BUACTIONS: 17: backend, {2}, assembler, (host-openmp)
 // CHK-BUACTIONS: 18: assembler, {17}, object, (host-openmp)
-// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp)
\ No newline at end of file
+// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp)
+
+/// ###
+
+/// Check separate compilation with offloading - unbundling actions
+// RUN:   touch %t.i
+// RUN:   %clang -### -ccc-print-phases -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UBACTIONS %s
+
+// CHK-UBACTIONS: 0: input, "somelib", object, (host-openmp)
+// CHK-UBACTIONS: 1: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp)
+// CHK-UBACTIONS: 2: clang-offload-unbundler, {1}, cpp-output, (host-openmp)
+// CHK-UBACTIONS: 3: compiler, {2}, ir, (host-openmp)
+// CHK-UBACTIONS: 4: backend, {3}, assembler, (host-openmp)
+// CHK-UBACTIONS: 5: assembler, {4}, object, (host-openmp)
+// CHK-UBACTIONS: 6: linker, {0, 5}, image, (host-openmp)
+// CHK-UBACTIONS: 7: input, "somelib", object, (device-openmp)
+// CHK-UBACTIONS: 8: compiler, {2}, ir, (device-openmp)
+// CHK-UBACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (powerpc64le-ibm-linux-gnu)" {8}, ir
+// CHK-UBACTIONS: 10: backend, {9}, assembler, (device-openmp)
+// CHK-UBACTIONS: 11: assembler, {10}, object, (device-openmp)
+// CHK-UBACTIONS: 12: linker, {7, 11}, image, (device-openmp)
+// CHK-UBACTIONS: 13: input, "somelib", object, (device-openmp)
+// CHK-UBACTIONS: 14: compiler, {2}, ir, (device-openmp)
+// CHK-UBACTIONS: 15: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {14}, ir
+// CHK-UBACTIONS: 16: backend, {15}, assembler, (device-openmp)
+// CHK-UBACTIONS: 17: assembler, {16}, object, (device-openmp)
+// CHK-UBACTIONS: 18: linker, {13, 17}, image, (device-openmp)
+// CHK-UBACTIONS: 19: offload, "host-openmp (powerpc64le--linux)" {6}, "device-openmp (powerpc64le-ibm-linux-gnu)" {12}, "device-openmp (x86_64-pc-linux-gnu)" {18}, image
+
+/// ###
+
+/// Check separate compilation with offloading - unbundling/bundling actions
+// RUN:   touch %t.i
+// RUN:   %clang -### -ccc-print-phases -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UBUACTIONS %s
+
+// CHK-UBUACTIONS: 0: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp)
+// CHK-UBUACTIONS: 1: clang-offload-unbundler, {0}, cpp-output, (host-openmp)
+// CHK-UBUACTIONS: 2: compiler, {1}, ir, (host-openmp)
+// CHK-UBUACTIONS: 3: compiler, {1}, ir, (device-openmp)
+// CHK-UBUACTIONS: 4: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (powerpc64le-ibm-linux-gnu)" {3}, ir
+// CHK-UBUACTIONS: 5: backend, {4}, assembler, (device-openmp)
+// CHK-UBUACTIONS: 6: assembler, {5}, object, (device-openmp)
+// CHK-UBUACTIONS: 7: offload, "device-openmp (powerpc64le-ibm-linux-gnu)" {6}, object
+// CHK-UBUACTIONS: 8: compiler, {1}, ir, (device-openmp)
+// CHK-UBUACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir
+// CHK-UBUACTIONS: 10: backend, {9}, assembler, (device-openmp)
+// CHK-UBUACTIONS: 11: assembler, {10}, object, (device-openmp)
+// CHK-UBUACTIONS: 12: offload, "device-openmp (x86_64-pc-linux-gnu)" {11}, object
+// CHK-UBUACTIONS: 13: backend, {2}, assembler, (host-openmp)
+// CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp)
+// CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp)
+
Index: lib/Driver/Types.cpp
===
--- lib/Driver/Types.cpp
+++ lib/Driver/Types.cpp
@@ -153,6 +153,10 @@
   }
 }
 
+bool types::isSrcFile(ID Id) {
+  return Id != TY_Object && getPreprocessedType(Id) != TY_INVALID;
+}
+
 types::ID types::lookupTypeForExtension(const char *Ext) {
   return llvm::StringSwitch(Ext)
.Case("c", TY_C)
Index: lib/Driver/ToolChain.cpp

Re: [PATCH] D21856: [Driver][OpenMP] Add support to create jobs for bundling actions.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62561.
sfantao marked 3 inline comments as done.
sfantao added a comment.

- Use StringRef instead of string and mark bundler tool as final.


http://reviews.llvm.org/D21856

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/ToolChain.h
  lib/Driver/Action.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -309,3 +309,37 @@
 // CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp)
 // CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp)
 
+/// ###
+
+/// Check separate compilation with offloading - bundling jobs construct
+// RUN:   %clang -### -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BUJOBS %s
+// RUN:   %clang -### -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BUJOBS-ST %s
+
+// Create host BC.
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc"  {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-E"  {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc"  {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+
+// Create target 1 object.
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]"
+
+// Create target 2 object.
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]"
+
+// Create host object and bundle.
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "-x" "ir" "[[HOSTBC]]"
+// CHK-BUJOBS: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTASM:.+\.s]]" "-x" "ir" "[[HOSTBC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le--linux" "-filetype" "obj" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "[[HOSTASM]]"
+// CHK-BUJOBS-ST: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]"
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -135,6 +135,19 @@
 const char *LinkingOutput) const override;
 };
 
+/// Offload bundler tool.
+class LLVM_LIBRARY_VISIBILITY OffloadBundler final : public Tool {
+public:
+  OffloadBundler(

Re: [PATCH] D21856: [Driver][OpenMP] Add support to create jobs for bundling actions.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: lib/Driver/Action.cpp:133
@@ +132,3 @@
+/// we assume 'host'.
+std::string Action::getOffloadKindName(OffloadKind Kind) {
+  switch (Kind) {

ABataev wrote:
> 1. Maybe it is enough to return just StringRef, rather than std::string
> 2. This can be made 'static'
True, it can be a `StringRef`. This function is already marked static in its 
declaration.


http://reviews.llvm.org/D21856



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r274396 - Removes CHECKs for symbolic label names (as Debug Clang will generate).

2016-07-01 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Jul  1 17:50:00 2016
New Revision: 274396

URL: http://llvm.org/viewvc/llvm-project?rev=274396&view=rev
Log:
Removes CHECKs for symbolic label names (as Debug Clang will generate).

Differential Revision: http://reviews.llvm.org/D20499

Modified:
cfe/trunk/test/CodeGen/temporary-lifetime.cpp

Modified: cfe/trunk/test/CodeGen/temporary-lifetime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/temporary-lifetime.cpp?rev=274396&r1=274395&r2=274396&view=diff
==
--- cfe/trunk/test/CodeGen/temporary-lifetime.cpp (original)
+++ cfe/trunk/test/CodeGen/temporary-lifetime.cpp Fri Jul  1 17:50:00 2016
@@ -87,11 +87,14 @@ void Test3() {
   // CHECK-DTOR-LABEL: Test3
   // CHECK-DTOR: call void @llvm.lifetime.start
   // CHECK-DTOR: call void @llvm.lifetime.start
-  // CHECK-DTOR: if.then:
+
+  // if.then:
   // CHECK-DTOR: call void @llvm.lifetime.end
-  // CHECK-DTOR: cleanup{{.*}}:
+
+  // cleanup:
   // CHECK-DTOR: call void @llvm.lifetime.end
-  // CHECK-DTOR: cleanup{{.*}}:
+
+  // cleanup:
   // CHECK-DTOR: call void @llvm.lifetime.end
   // CHECK-DTOR: }
   const A &a = A{};
@@ -105,9 +108,11 @@ void Test3() {
 void Test4() {
   // CHECK-DTOR-LABEL: Test4
   // CHECK-DTOR: call void @llvm.lifetime.start
-  // CHECK-DTOR: for.cond.cleanup:
+
+  // for.cond.cleanup:
   // CHECK-DTOR: call void @llvm.lifetime.end
-  // CHECK-DTOR: for.body:
+
+  // for.body:
   // CHECK-DTOR: }
   for (const A &a = A{}; a;) {
 Foo(a);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries

2016-07-01 Thread Tim Shen via cfe-commits
timshen added a comment.

...and r274396 to remove all of the checks for symbolic labels, which are not 
generated by release builds, nor controlled by a runtime-flag.


Repository:
  rL LLVM

http://reviews.llvm.org/D20499



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-07-01 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 62560.
ahatanak added a comment.

The new patch defines a new attribute "flexible_array", which gets attached to 
the last array member of a struct.

I made changes to clang to treat arrays marked "flexible_array" as C99's 
flexible array members where it made sense to do so. There are several places 
where C99's flexible arrays and "flexible_array" are treated differently. For 
example, the attribute doesn't change the way arguments are passed or values 
are returned from a function. It doesn't change objective-c's type encoding 
either.


http://reviews.llvm.org/D21453

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/AST/Decl.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenTBAA.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/object-size.c
  test/CodeGenCXX/catch-undef-behavior.cpp
  test/SemaCXX/flexible-array-attr.cpp

Index: test/SemaCXX/flexible-array-attr.cpp
===
--- /dev/null
+++ test/SemaCXX/flexible-array-attr.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+int g0[16] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fields}}
+
+struct S0 {
+  int a[4];
+  int foo1() __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fields}}
+};
+
+struct S1 {
+  int a[4];
+  int *b __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fixed sized array members}}
+};
+
+struct S2 {
+  int a[4];
+  int b[4] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to the last member of a struct}}
+  int c[4];
+};
+
+struct S3 {
+  int a[4];
+  int b[] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fixed sized array members}}
+};
+
+struct S4 {
+  int a[4];
+  int b[0] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to array members that have at least one element}}
+};
+
+template
+struct S5 {
+  int a[4];
+  int b[N] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fixed sized array members}}
+};
+
+struct S6 {
+  int a[4];
+  int b[1] __attribute__((flexible_array));
+};
+
+struct S7 : S6 { // expected-error {{base class 'S6' has a flexible array member}}
+};
+
+struct S8 {
+  int a;
+  S6 s6; // expected-error {{struct with a member marked 'flexible_array' cannot be nested}}
+};
+
+union U0 {
+  int a[4];
+  int b[4] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to members of structs or classes}}
+};
+
+int lambda_capture(S6 a) { // expected-note {{'a' declared here}}
+  return [a](){ return 0; }(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}}
+}
Index: test/CodeGenCXX/catch-undef-behavior.cpp
===
--- test/CodeGenCXX/catch-undef-behavior.cpp
+++ test/CodeGenCXX/catch-undef-behavior.cpp
@@ -327,6 +327,17 @@
   return incomplete[n];
 }
 
+struct FlexibleArray {
+  int a1[4];
+  int a2[4] __attribute__((flexible_array));
+};
+
+// CHECK-LABEL: @_Z14flexible_array
+int flexible_array(FlexibleArray *p, int n) {
+  // CHECK-NOT: call void @__ubsan_handle_out_of_bounds(
+  return p->a2[n];
+}
+
 typedef __attribute__((ext_vector_type(4))) int V4I;
 // CHECK-LABEL: @_Z12vector_index
 int vector_index(V4I v, int n) {
Index: test/CodeGen/object-size.c
===
--- test/CodeGen/object-size.c
+++ test/CodeGen/object-size.c
@@ -517,3 +517,19 @@
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(&dsv[9].snd[0], 1);
 }
+
+struct S0 {
+  int a[16];
+  int b[16] __attribute__((flexible_array));
+};
+
+// CHECK-LABEL: @test32
+void test32() {
+  struct S0 *s0;
+
+  // CHECK: store i32 64, i32* @gi
+  gi = __builtin_object_size(s0->a, 1);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(s0->b, 1);
+}
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -457,6 +457,7 @@
 void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) {
   VisitTagDecl(D);
   Record.push_back(D->hasFlexibleArrayMember());
+  Record.push_back(D->hasFlexibleArrayAttr());
   Record.push_back(D->isAnonymousStructOrUnion());
   Record.push_back(D->hasObjec

Re: [PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62565.
sfantao added a comment.

- Add Ctor dropped by mistake in the previous diff.


http://reviews.llvm.org/D21853

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Types.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/Types.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -255,4 +255,57 @@
 // CHK-BUACTIONS: 16: offload, "device-openmp (x86_64-pc-linux-gnu)" {15}, object
 // CHK-BUACTIONS: 17: backend, {2}, assembler, (host-openmp)
 // CHK-BUACTIONS: 18: assembler, {17}, object, (host-openmp)
-// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp)
\ No newline at end of file
+// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp)
+
+/// ###
+
+/// Check separate compilation with offloading - unbundling actions
+// RUN:   touch %t.i
+// RUN:   %clang -### -ccc-print-phases -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UBACTIONS %s
+
+// CHK-UBACTIONS: 0: input, "somelib", object, (host-openmp)
+// CHK-UBACTIONS: 1: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp)
+// CHK-UBACTIONS: 2: clang-offload-unbundler, {1}, cpp-output, (host-openmp)
+// CHK-UBACTIONS: 3: compiler, {2}, ir, (host-openmp)
+// CHK-UBACTIONS: 4: backend, {3}, assembler, (host-openmp)
+// CHK-UBACTIONS: 5: assembler, {4}, object, (host-openmp)
+// CHK-UBACTIONS: 6: linker, {0, 5}, image, (host-openmp)
+// CHK-UBACTIONS: 7: input, "somelib", object, (device-openmp)
+// CHK-UBACTIONS: 8: compiler, {2}, ir, (device-openmp)
+// CHK-UBACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (powerpc64le-ibm-linux-gnu)" {8}, ir
+// CHK-UBACTIONS: 10: backend, {9}, assembler, (device-openmp)
+// CHK-UBACTIONS: 11: assembler, {10}, object, (device-openmp)
+// CHK-UBACTIONS: 12: linker, {7, 11}, image, (device-openmp)
+// CHK-UBACTIONS: 13: input, "somelib", object, (device-openmp)
+// CHK-UBACTIONS: 14: compiler, {2}, ir, (device-openmp)
+// CHK-UBACTIONS: 15: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {14}, ir
+// CHK-UBACTIONS: 16: backend, {15}, assembler, (device-openmp)
+// CHK-UBACTIONS: 17: assembler, {16}, object, (device-openmp)
+// CHK-UBACTIONS: 18: linker, {13, 17}, image, (device-openmp)
+// CHK-UBACTIONS: 19: offload, "host-openmp (powerpc64le--linux)" {6}, "device-openmp (powerpc64le-ibm-linux-gnu)" {12}, "device-openmp (x86_64-pc-linux-gnu)" {18}, image
+
+/// ###
+
+/// Check separate compilation with offloading - unbundling/bundling actions
+// RUN:   touch %t.i
+// RUN:   %clang -### -ccc-print-phases -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UBUACTIONS %s
+
+// CHK-UBUACTIONS: 0: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp)
+// CHK-UBUACTIONS: 1: clang-offload-unbundler, {0}, cpp-output, (host-openmp)
+// CHK-UBUACTIONS: 2: compiler, {1}, ir, (host-openmp)
+// CHK-UBUACTIONS: 3: compiler, {1}, ir, (device-openmp)
+// CHK-UBUACTIONS: 4: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (powerpc64le-ibm-linux-gnu)" {3}, ir
+// CHK-UBUACTIONS: 5: backend, {4}, assembler, (device-openmp)
+// CHK-UBUACTIONS: 6: assembler, {5}, object, (device-openmp)
+// CHK-UBUACTIONS: 7: offload, "device-openmp (powerpc64le-ibm-linux-gnu)" {6}, object
+// CHK-UBUACTIONS: 8: compiler, {1}, ir, (device-openmp)
+// CHK-UBUACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir
+// CHK-UBUACTIONS: 10: backend, {9}, assembler, (device-openmp)
+// CHK-UBUACTIONS: 11: assembler, {10}, object, (device-openmp)
+// CHK-UBUACTIONS: 12: offload, "device-openmp (x86_64-pc-linux-gnu)" {11}, object
+// CHK-UBUACTIONS: 13: backend, {2}, assembler, (host-openmp)
+// CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp)
+// CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp)
+
Index: lib/Driver/Types.cpp
===
--- lib/Driver/Types.cpp
+++ lib/Driver/Types.cpp
@@ -153,6 +153,10 @@
   }
 }
 
+bool types::isSrcFile(ID Id) {
+  return Id != TY_Object && getPreprocessedType(Id) != TY_INVALID;
+}
+
 types::ID types::lookupTypeForExtension(const char *Ext) {
   return llvm::StringSwitch(Ext)
.Case("c", TY_C)
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ l

Re: [PATCH] D21856: [Driver][OpenMP] Add support to create jobs for bundling actions.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62567.
sfantao added a comment.

- Use StringRef instead of std::string, fix comments and mark class final.


http://reviews.llvm.org/D21856

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/ToolChain.h
  lib/Driver/Action.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -309,3 +309,37 @@
 // CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp)
 // CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp)
 
+/// ###
+
+/// Check separate compilation with offloading - bundling jobs construct
+// RUN:   %clang -### -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BUJOBS %s
+// RUN:   %clang -### -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BUJOBS-ST %s
+
+// Create host BC.
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc"  {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-E"  {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc"  {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+
+// Create target 1 object.
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]"
+
+// Create target 2 object.
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]"
+
+// Create host object and bundle.
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "-x" "ir" "[[HOSTBC]]"
+// CHK-BUJOBS: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTASM:.+\.s]]" "-x" "ir" "[[HOSTBC]]"
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le--linux" "-filetype" "obj" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "[[HOSTASM]]"
+// CHK-BUJOBS-ST: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]"
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -135,6 +135,19 @@
 const char *LinkingOutput) const override;
 };
 
+/// Offload bundler tool.
+class LLVM_LIBRARY_VISIBILITY OffloadBundler final : public Tool {
+public:
+  OffloadBundler(const ToolChain &TC)
+  : Too

r274401 - [CodeView] Include MSVC style names for unnamed types

2016-07-01 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Fri Jul  1 18:12:54 2016
New Revision: 274401

URL: http://llvm.org/viewvc/llvm-project?rev=274401&view=rev
Log:
[CodeView] Include MSVC style names for unnamed types

The CodeView printer expects to be able to generate fully qualified
names from the debug info graph.  This means that we need to include the
MSVC-style name in the debug info for anonymous types.

Added:
cfe/trunk/test/CodeGenCXX/debug-info-ms-anonymous-tag.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=274401&r1=274400&r2=274401&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jul  1 18:12:54 2016
@@ -259,20 +259,56 @@ StringRef CGDebugInfo::getSelectorName(S
 }
 
 StringRef CGDebugInfo::getClassName(const RecordDecl *RD) {
-  // quick optimization to avoid having to intern strings that are already
-  // stored reliably elsewhere
-  if (!isa(RD))
-return RD->getName();
-
-  SmallString<128> Name;
-  {
+  if (isa(RD)) {
+SmallString<128> Name;
 llvm::raw_svector_ostream OS(Name);
 RD->getNameForDiagnostic(OS, CGM.getContext().getPrintingPolicy(),
  /*Qualified*/ false);
+
+// Copy this name on the side and use its reference.
+return internString(Name);
+  }
+
+  // quick optimization to avoid having to intern strings that are already
+  // stored reliably elsewhere
+  if (const IdentifierInfo *II = RD->getIdentifier())
+return II->getName();
+
+  // The CodeView printer in LLVM wants to see the names of unnamed types: it 
is
+  // used to reconstruct the fully qualified type names.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
+if (const TypedefNameDecl *D = RD->getTypedefNameForAnonDecl()) {
+  assert(RD->getDeclContext() == D->getDeclContext() &&
+ "Typedef should not be in another decl context!");
+  assert(D->getDeclName().getAsIdentifierInfo() &&
+ "Typedef was not named!");
+  return D->getDeclName().getAsIdentifierInfo()->getName();
+}
+
+if (CGM.getLangOpts().CPlusPlus) {
+  StringRef Name;
+
+  ASTContext &Context = CGM.getContext();
+  if (const DeclaratorDecl *DD = 
Context.getDeclaratorForUnnamedTagDecl(RD))
+// Anonymous types without a name for linkage purposes have their
+// declarator mangled in if they have one.
+Name = DD->getName();
+  else if (const TypedefNameDecl *TND =
+   Context.getTypedefNameForUnnamedTagDecl(RD))
+// Anonymous types without a name for linkage purposes have their
+// associate typedef mangled in if they have one.
+Name = TND->getName();
+
+  if (!Name.empty()) {
+SmallString<256> UnnamedType("http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-ms-anonymous-tag.cpp?rev=274401&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-ms-anonymous-tag.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-ms-anonymous-tag.cpp Fri Jul  1 
18:12:54 2016
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -debug-info-kind=limited -gcodeview 
%s -emit-llvm -o - | FileCheck %s
+
+typedef struct {
+} test1;
+
+test1 gv1;
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "test1"
+
+struct {
+} test2;
+void *use_test2 = &test2;
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: 
""
+
+typedef struct {
+} *test3;
+test3 gv3;
+void *use_test3 = &gv3;
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: 
""


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r274403 - Work around ABI break caused by C++17 inline variables.

2016-07-01 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jul  1 18:22:25 2016
New Revision: 274403

URL: http://llvm.org/viewvc/llvm-project?rev=274403&view=rev
Log:
Work around ABI break caused by C++17 inline variables.

Modified:
libcxx/trunk/src/chrono.cpp

Modified: libcxx/trunk/src/chrono.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=274403&r1=274402&r2=274403&view=diff
==
--- libcxx/trunk/src/chrono.cpp (original)
+++ libcxx/trunk/src/chrono.cpp Fri Jul  1 18:22:25 2016
@@ -6,7 +6,7 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 
//===--===//
-
+#define _LIBCPP_BUILDING_CHRONO
 #include "chrono"
 #include "cerrno"// errno
 #include "system_error"  // __throw_system_error
@@ -32,6 +32,9 @@ namespace chrono
 // system_clock
 
 const bool system_clock::is_steady;
+// Make is_steady non-discardable in C++17
+// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395)
+static const bool& __is_steady_force_use1 __attribute__((used)) = 
system_clock::is_steady;
 
 system_clock::time_point
 system_clock::now() _NOEXCEPT
@@ -68,6 +71,10 @@ system_clock::from_time_t(time_t t) _NOE
 //  instead.
 
 const bool steady_clock::is_steady;
+// Make is_steady non-discardable in C++17
+// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395)
+static const bool& __is_steady_force_use2 __attribute__((used)) = 
steady_clock::is_steady;
+
 
 #ifdef CLOCK_MONOTONIC
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r274404 - Turn off ASAN's odr-violation diagnostics for now. See PR28391

2016-07-01 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jul  1 18:25:47 2016
New Revision: 274404

URL: http://llvm.org/viewvc/llvm-project?rev=274404&view=rev
Log:
Turn off ASAN's odr-violation diagnostics for now. See PR28391

Modified:
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=274404&r1=274403&r2=274404&view=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Fri Jul  1 18:25:47 2016
@@ -607,6 +607,9 @@ class Configuration(object):
 self.cxx.flags += ['-fsanitize=address']
 if llvm_symbolizer is not None:
 self.env['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer
+# FIXME: Turn ODR violation back on after PR28391 is resolved
+# https://llvm.org/bugs/show_bug.cgi?id=28391
+self.env['ASAN_OPTIONS'] = 'detect_odr_violation=0'
 self.config.available_features.add('asan')
 self.config.available_features.add('sanitizer-new-delete')
 elif san == 'Memory' or san == 'MemoryWithOrigins':


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-01 Thread Sean Silva via cfe-commits
silvas added inline comments.


Comment at: lib/Driver/Tools.cpp:3560
@@ +3559,3 @@
+if (PGOTrainArg->getOption().matches(options::OPT_fpgo_train_EQ)) {
+  if (StringRef(PGOTrainArg->getValue()) == "source-cfg")
+CmdArgs.push_back("-fprofile-instrument=clang");

davidxl wrote:
> I think it is better to make the selector  'source' vs 'cfg'.
> 
> -fpgo-train=source
> -fpgo-train=cfg
So would `-fpgo-train=cfg` enable icall instrumentation or not?

My thinking is that down the road we will have one flag for each independent 
instrumentation capability (and of course some are mutually incompatible). This 
mirrors what the sanitizers do. For example, we would have:
`-fpgo-train=optimizer-cfg` --> IR edge profiling
`-fpgo-train=optimizer-icall` --> IR icall value profiling
`-fpgo-train=optimizer-...` --> other independent instrumentation we can do in 
IR instrumentation.
`-fpgo-train=source-cfg` --> FE edge profiling
`-fpgo-train=source-icall` --> FE icall profiling (if that even exists; I see 
some code but there is no user-visible flag)
`-fpgo-train=source-...` --> other FE instrumentation.

We can then have `-fpgo-train=optimizer` enable e.g. 
`-fpgo-train=optimizer-cfg,optimizer-icall`.
We can also have `-fpgo-train=source` enable e.g. `-fpgo-train=source-cfg`.

Since instrumentation can have different overheads or different runtime 
requirements, users may want to disable some instrumentation.


Repository:
  rL LLVM

http://reviews.llvm.org/D21823



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r274403 - Work around ABI break caused by C++17 inline variables.

2016-07-01 Thread Richard Smith via cfe-commits
On Fri, Jul 1, 2016 at 4:22 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Fri Jul  1 18:22:25 2016
> New Revision: 274403
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274403&view=rev
> Log:
> Work around ABI break caused by C++17 inline variables.
>
> Modified:
> libcxx/trunk/src/chrono.cpp
>
> Modified: libcxx/trunk/src/chrono.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=274403&r1=274402&r2=274403&view=diff
>
> ==
> --- libcxx/trunk/src/chrono.cpp (original)
> +++ libcxx/trunk/src/chrono.cpp Fri Jul  1 18:22:25 2016
> @@ -6,7 +6,7 @@
>  // Source Licenses. See LICENSE.TXT for details.
>  //
>
>  
> //===--===//
> -
> +#define _LIBCPP_BUILDING_CHRONO
>  #include "chrono"
>  #include "cerrno"// errno
>  #include "system_error"  // __throw_system_error
> @@ -32,6 +32,9 @@ namespace chrono
>  // system_clock
>
>  const bool system_clock::is_steady;
>

Can you mark this as __attribute__((used)) instead of adding a separate use?


> +// Make is_steady non-discardable in C++17
> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395)
> +static const bool& __is_steady_force_use1 __attribute__((used)) =
> system_clock::is_steady;
>
>  system_clock::time_point
>  system_clock::now() _NOEXCEPT
> @@ -68,6 +71,10 @@ system_clock::from_time_t(time_t t) _NOE
>  //  instead.
>
>  const bool steady_clock::is_steady;
> +// Make is_steady non-discardable in C++17
> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395)
> +static const bool& __is_steady_force_use2 __attribute__((used)) =
> steady_clock::is_steady;
> +
>
>  #ifdef CLOCK_MONOTONIC
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21857: [Driver][OpenMP] Add support to create jobs for unbundling actions.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 62569.
sfantao marked 2 inline comments as done.
sfantao added a comment.

- Change name of static function, format comments and remove \brief.


http://reviews.llvm.org/D21857

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Tool.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tool.cpp
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -176,7 +176,7 @@
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]"
-// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]]
+// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T1BIN:.+\.out-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]]
 
 //
 // Compile for the x86 device.
@@ -187,7 +187,7 @@
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]"
-// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]]
+// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T2BIN:.+\.out-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]]
 
 //
 // Generate host object from the BC file and link using the linker script.
@@ -202,20 +202,20 @@
 // Check the linker script contains what we expect.
 //
 // CHK-LKS: TARGET(binary)
-// CHK-LKS: INPUT({{.+}}.out-device-openmp-powerpc64le-ibm-linux-gnu)
-// CHK-LKS: INPUT({{.+}}.out-device-openmp-x86_64-pc-linux-gnu)
+// CHK-LKS: INPUT({{.+}}.out-openmp-powerpc64le-ibm-linux-gnu)
+// CHK-LKS: INPUT({{.+}}.out-openmp-x86_64-pc-linux-gnu)
 // CHK-LKS: SECTIONS
 // CHK-LKS: {
 // CHK-LKS:   .omp_offloading :
 // CHK-LKS:   ALIGN(0x10)
 // CHK-LKS:   {
 // CHK-LKS: . = ALIGN(0x10);
 // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.powerpc64le-ibm-linux-gnu = .);
-// CHK-LKS: {{.+}}.out-device-openmp-powerpc64le-ibm-linux-gnu
+// CHK-LKS: {{.+}}.out-openmp-powerpc64le-ibm-linux-gnu
 // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.powerpc64le-ibm-linux-gnu = .);
 // CHK-LKS: . = ALIGN(0x10);
 // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.x86_64-pc-linux-gnu = .);
-// CHK-LKS: {{.+}}.out-device-openmp-x86_64-pc-linux-gnu
+// CHK-LKS: {{.+}}.out-openmp-x86_64-pc-linux-gnu
 // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.x86_64-pc-linux-gnu = .);
 // CHK-LKS:   }
 // CHK-LKS:   .omp_offloading.entries :
@@ -343,3 +343,92 @@
 // CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTASM:.+\.s]]" "-x" "ir" "[[HOSTBC]]"
 // CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le--linux" "-filetype" "obj" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "[[HOSTASM]]"
 // CHK-BUJOBS-ST: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]"
+
+/// ###
+
+/// Check separate compilation with offloading - unbundling jobs construct
+// RUN:   touch %t.i
+// RUN:   %clang -###  -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UBJOBS %s
+// RUN:   %clang -### -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i -save-temps 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UBJOBS-ST %s
+// RUN:   touch %t.o
+// RUN:   %clang -###  -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UBJOBS2 %s
+// RUN:   %clang -### -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.o -save-te

Re: [PATCH] D21857: [Driver][OpenMP] Add support to create jobs for unbundling actions.

2016-07-01 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey, thanks for the review!



Comment at: include/clang/Driver/Tool.h:132-140
@@ -131,1 +131,11 @@
 const char *LinkingOutput) const = 0;
+  /// ConstructJob - Construct jobs to perform the action \p JA,
+  /// writing to the \p Outputs and with \p Inputs, and add the jobs to
+  /// \p C. The default implementation assumes a single output and is expected
+  /// to be overloaded for the tools that support multiple inputs.
+  ///
+  /// \param TCArgs - The argument list for this toolchain, with any
+  /// tool chain specific translations applied.
+  /// \param LinkingOutput - If this output will eventually feed the
+  /// linker, then this is the final output name of the linked image.
+  virtual void ConstructJob(Compilation &C, const JobAction &JA,

ABataev wrote:
> Please, format properly. Remove the name of the function and '-' signs after 
> params
Ok, I was following the format used for the other version of the is function.


http://reviews.llvm.org/D21857



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r274403 - Work around ABI break caused by C++17 inline variables.

2016-07-01 Thread Eric Fiselier via cfe-commits
The attribute is ignored unless it is placed on the in-class declaration of
the member. It has no effect when applied to the explicit definition.
I would rather keep the workaround internal than make the change in the
headers.

On Fri, Jul 1, 2016 at 5:34 PM, Richard Smith  wrote:

> On Fri, Jul 1, 2016 at 4:22 PM, Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ericwf
>> Date: Fri Jul  1 18:22:25 2016
>> New Revision: 274403
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=274403&view=rev
>> Log:
>> Work around ABI break caused by C++17 inline variables.
>>
>> Modified:
>> libcxx/trunk/src/chrono.cpp
>>
>> Modified: libcxx/trunk/src/chrono.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=274403&r1=274402&r2=274403&view=diff
>>
>> ==
>> --- libcxx/trunk/src/chrono.cpp (original)
>> +++ libcxx/trunk/src/chrono.cpp Fri Jul  1 18:22:25 2016
>> @@ -6,7 +6,7 @@
>>  // Source Licenses. See LICENSE.TXT for details.
>>  //
>>
>>  
>> //===--===//
>> -
>> +#define _LIBCPP_BUILDING_CHRONO
>>  #include "chrono"
>>  #include "cerrno"// errno
>>  #include "system_error"  // __throw_system_error
>> @@ -32,6 +32,9 @@ namespace chrono
>>  // system_clock
>>
>>  const bool system_clock::is_steady;
>>
>
> Can you mark this as __attribute__((used)) instead of adding a separate
> use?
>
>
>> +// Make is_steady non-discardable in C++17
>> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395)
>> +static const bool& __is_steady_force_use1 __attribute__((used)) =
>> system_clock::is_steady;
>>
>>  system_clock::time_point
>>  system_clock::now() _NOEXCEPT
>> @@ -68,6 +71,10 @@ system_clock::from_time_t(time_t t) _NOE
>>  //  instead.
>>
>>  const bool steady_clock::is_steady;
>> +// Make is_steady non-discardable in C++17
>> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395)
>> +static const bool& __is_steady_force_use2 __attribute__((used)) =
>> steady_clock::is_steady;
>> +
>>
>>  #ifdef CLOCK_MONOTONIC
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >