[PATCH] D28889: Change where we handle arg-dependent diagnose_if attributes

2017-01-18 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv created this revision.

As it turns out, emitting diagnostics from places where you're not meant to 
emit them from is a very bad idea. :)

After some looking around, it seems that it's less insane to check for 
`diagnose_if` attributes in code that's already checking for e.g. nullness 
warnings. As a result, we get to rip out the `diagnose_if`-induced changes to 
overloading. Woohoo!

This also includes a slight change to how `diagnose_if` works: for "error" 
calls, we'll always assume that overload resolution chose the overload the user 
wanted. So, regardless of whetehr a `diagnose_if` attribute emits a diag or 
not, we'll continue building the AST/etc as usual.

This patch aims to fix PR31638, PR31639, and PR31640.


https://reviews.llvm.org/D28889

Files:
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOverload.cpp
  test/Sema/diagnose_if.c
  test/SemaCXX/diagnose_if.cpp

Index: test/SemaCXX/diagnose_if.cpp
===
--- test/SemaCXX/diagnose_if.cpp
+++ test/SemaCXX/diagnose_if.cpp
@@ -2,6 +2,8 @@
 
 #define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__)))
 
+using size_t = unsigned long;
+
 namespace type_dependent {
 template 
 void neverok() _diagnose_if(!T(), "oh no", "error") {} // expected-note 4{{from 'diagnose_if'}}
@@ -51,14 +53,14 @@
 }
 
 template 
-void errorIf(T a) _diagnose_if(T() != a, "oh no", "error") {} // expected-note {{candidate disabled: oh no}}
+void errorIf(T a) _diagnose_if(T() != a, "oh no", "error") {} // expected-note{{from 'diagnose_if'}}
 
 template 
-void warnIf(T a) _diagnose_if(T() != a, "oh no", "warning") {} // expected-note {{from 'diagnose_if'}}
+void warnIf(T a) _diagnose_if(T() != a, "oh no", "warning") {} // expected-note{{from 'diagnose_if'}}
 
 void runIf() {
   errorIf(0);
-  errorIf(1); // expected-error{{call to unavailable function}}
+  errorIf(1); // expected-error{{oh no}}
 
   warnIf(0);
   warnIf(1); // expected-warning{{oh no}}
@@ -114,14 +116,14 @@
 }
 
 template 
-void errorIf(int a) _diagnose_if(N != a, "oh no", "error") {} // expected-note {{candidate disabled: oh no}}
+void errorIf(int a) _diagnose_if(N != a, "oh no", "error") {} // expected-note{{from 'diagnose_if'}}
 
 template 
-void warnIf(int a) _diagnose_if(N != a, "oh no", "warning") {} // expected-note {{from 'diagnose_if'}}
+void warnIf(int a) _diagnose_if(N != a, "oh no", "warning") {} // expected-note{{from 'diagnose_if'}}
 
 void runIf() {
   errorIf<0>(0);
-  errorIf<0>(1); // expected-error{{call to unavailable function}}
+  errorIf<0>(1); // expected-error{{oh no}}
 
   warnIf<0>(0);
   warnIf<0>(1); // expected-warning{{oh no}}
@@ -135,17 +137,17 @@
 void bar(int);
 void bar(short) _diagnose_if(1, "oh no", "error");
 
-void fooArg(int a) _diagnose_if(a, "oh no", "error"); // expected-note{{candidate disabled: oh no}}
-void fooArg(short); // expected-note{{candidate function}}
+void fooArg(int a) _diagnose_if(a, "oh no", "error"); // expected-note{{from 'diagnose_if'}}
+void fooArg(short);
 
 void barArg(int);
 void barArg(short a) _diagnose_if(a, "oh no", "error");
 
 void runAll() {
   foo(1); // expected-error{{oh no}}
   bar(1);
 
-  fooArg(1); // expected-error{{call to unavailable function}}
+  fooArg(1); // expected-error{{oh no}}
   barArg(1);
 
   auto p = foo; // expected-error{{incompatible initializer of type ''}}
@@ -188,11 +190,11 @@
   void foo(int i) _diagnose_if(i, "bad i", "error"); // expected-note{{from 'diagnose_if'}}
   void bar(int i) _diagnose_if(i != T(), "bad i", "error"); // expected-note{{from 'diagnose_if'}}
 
-  void fooOvl(int i) _diagnose_if(i, "int bad i", "error"); // expected-note 2{{int bad i}}
-  void fooOvl(short i) _diagnose_if(i, "short bad i", "error"); // expected-note 2{{short bad i}}
+  void fooOvl(int i) _diagnose_if(i, "int bad i", "error"); // expected-note{{from 'diagnose_if'}}
+  void fooOvl(short i) _diagnose_if(i, "short bad i", "error"); // expected-note{{from 'diagnose_if'}}
 
-  void barOvl(int i) _diagnose_if(i != T(), "int bad i", "error"); // expected-note 2{{int bad i}}
-  void barOvl(short i) _diagnose_if(i != T(), "short bad i", "error"); // expected-note 2{{short bad i}}
+  void barOvl(int i) _diagnose_if(i != T(), "int bad i", "error"); // expected-note{{from 'diagnose_if'}}
+  void barOvl(short i) _diagnose_if(i != T(), "short bad i", "error"); // expected-note{{from 'diagnose_if'}}
 };
 
 void runErrors() {
@@ -203,14 +205,14 @@
   Errors().bar(1); // expected-error{{bad i}}
 
   Errors().fooOvl(0);
-  Errors().fooOvl(1); // expected-error{{call to unavailable}}
+  Errors().fooOvl(1); // expected-error{{int bad i}}
   Errors().fooOvl(short(0));
-  Errors().fooOvl(short(1)); // expected-error{{call to unavailable}}
+  Errors().fooOvl(short(1)); // expected-error{{short bad i}}
 
   Errors().barOvl(0);
-  

[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-01-18 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

Thanks for all the feedback.  I've tried to address all your comments, and 
reworked the documentation.  Please let me know if I missed or misunderstood 
anything.


https://reviews.llvm.org/D20693



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-01-18 Thread don hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 84926.
hintonda marked 22 inline comments as done.
hintonda added a comment.

- Add support for matching MemberPointerType's.
- Add noexcept(false) option plus test; allow invalid replacement ranges; 
enhance diagnostics.
- Updated docs.


https://reviews.llvm.org/D20693

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tidy/modernize/UseNoexceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-noexcept.rst
  test/clang-tidy/modernize-use-noexcept-macro.cpp
  test/clang-tidy/modernize-use-noexcept-opt.cpp
  test/clang-tidy/modernize-use-noexcept.cpp

Index: test/clang-tidy/modernize-use-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept.cpp
@@ -0,0 +1,87 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -- -std=c++11
+
+class A {};
+class B {};
+
+void foo() throw();
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+void bar() throw(...);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw(...)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void bar() noexcept(false);
+
+void k() throw(int(int));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void k() noexcept(false);
+
+void foobar() throw(A, B)
+{}
+// CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foobar() noexcept(false)
+
+void baz(int = (throw A(), 0)) throw(A, B) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void baz(int = (throw A(), 0)) noexcept(false) {}
+
+void g(void (*fp)(void) throw());
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void g(void (*fp)(void) noexcept);
+
+void f(void (*fp)(void) throw(int)) throw(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'throw(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void f(void (*fp)(void) noexcept(false)) noexcept(false);
+
+#define THROW throw
+void h(void (*fp)(void) THROW(int)) THROW(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'THROW(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'THROW(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void h(void (*fp)(void) noexcept(false)) noexcept(false);
+
+void j() throw(int(int) throw(void(void) throw(int)));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void j() noexcept(false);
+
+class Y {
+  Y() throw() = default;
+};
+// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: Y() noexcept = default;
+
+struct Z {
+  void operator delete(void *ptr) throw();
+  void operator delete[](void *ptr) throw(int);
+  ~Z() throw(int) {}
+};
+// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void operator delete(void *ptr) noexcept;
+// CHECK-FIXES: void operator delete[](void *ptr) noexcept(false);
+// CHECK-FIXES: ~Z() noexcept(false) {}
+
+struct S {
+  void f() throw();
+};
+void f(void (S::*)() throw());
+// CHECK-MESSAGES: :[[@LINE-3]]:12: 

Re: [PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-18 Thread Aaron Ballman via cfe-commits
On Jan 18, 2017 7:34 PM, "Akira Hatanaka via Phabricator" <
revi...@reviews.llvm.org> wrote:

ahatanak added a comment.

In https://reviews.llvm.org/D28467#649861, @krasin wrote:

> This change makes Clang hardly incompatible with MSVC++. Consider the
following program:
>
>   #include 
>
>   int main(void) {
> const int kDelta = 1001;
> auto g = [kDelta](int i)
>  {
>printf("%d\n", i % kDelta);
>  };
> g(2);
>   }
>
>
> Clang will warn about the unused lambda capture:
>
>   $ clang++ lala.cc -o lala -std=c++14 -Wall -Werror && ./lala
>   lala.cc:5:13: error: lambda capture 'kDelta' is not required to be
captured for use in an unevaluated context [-Werror,-Wunused-lambda-capture]
> auto g = [kDelta](int i)
>   ^
>   1 error generated.
>


Is kDelta considered to be used in an unevaluated context here? I thought
unevaluated context in c++ means the expression is used as operands of
operators such as typeid and decltype.


It is not used in an unevaluated context -- that is a bug.

~Aaron



Repository:
  rL LLVM

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


[PATCH] D28849: [compiler-rt] [test] Fix page address logic in clear_cache_test to use binary negation

2017-01-18 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

I wonder if we should take this a bit further.  Use something like a 
`PAGE_SIZE` constant to avoid this confusion entirely.  Furthremore, different 
targets could use different page sizes.  IIRC, SPARC has a 8K page size by 
default.


Repository:
  rL LLVM

https://reviews.llvm.org/D28849



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


[PATCH] D28785: Split exception.cpp and new.cpp implementation into different files for different runtimes

2017-01-18 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

While I love this direction (the original version really was an unintelligible 
pile of code), I really think that this change may be taking on too much.  Why 
not split it up first and do nothing else.  We could do the MS ABI 
implementation in a subsequent change.  This would improve the code and would 
not be gated on the MS ABI changes.


https://reviews.llvm.org/D28785



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


[PATCH] D28862: [compiler-rt] [test] Use approximate comparison on float types

2017-01-18 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

I think that the checks should be exact.  Instead, we should check the 
compilation mode and change the exact value (i.e. if we are using i387 mode, we 
would use the adjusted value).


Repository:
  rL LLVM

https://reviews.llvm.org/D28862



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


Re: r291955 - PR31606: Generalize our tentative DR resolution for inheriting copy/move

2017-01-18 Thread Hans Wennborg via cfe-commits
Merged in r292463.

Cheers,
Hans

On Tue, Jan 17, 2017 at 9:25 PM, Richard Smith  wrote:
> Yes, let's.
>
> On 17 Jan 2017 9:11 pm, "Hans Wennborg"  wrote:
>
> What do you think; time to merge it?
>
> On Fri, Jan 13, 2017 at 1:21 PM, Richard Smith 
> wrote:
>> I'd like to wait a bit to see how the dust settles on this one, but this
>> is
>> a bugfix for a previous bugfix for a standard change, and we've had
>> several
>> user complaints requesting that we fix the bug in the standard, so it's
>> probably a good change to get into Clang 4.
>>
>> -- Forwarded message --
>> From: Richard Smith via cfe-commits 
>> Date: 13 January 2017 at 12:46
>> Subject: r291955 - PR31606: Generalize our tentative DR resolution for
>> inheriting copy/move
>> To: cfe-commits@lists.llvm.org
>>
>>
>> Author: rsmith
>> Date: Fri Jan 13 14:46:54 2017
>> New Revision: 291955
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=291955=rev
>> Log:
>> PR31606: Generalize our tentative DR resolution for inheriting copy/move
>> constructors to better match the pre-P0136R1 behavior.
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaOverload.cpp
>> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p15.cpp
>> cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp
>> cfe/trunk/test/CXX/drs/dr16xx.cpp
>> cfe/trunk/test/CXX/drs/dr19xx.cpp
>> cfe/trunk/test/CXX/special/class.inhctor/p1.cpp
>> cfe/trunk/test/CXX/special/class.inhctor/p3.cpp
>> cfe/trunk/test/CXX/special/class.inhctor/p7.cpp
>> cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp
>> cfe/trunk/test/SemaTemplate/cxx1z-using-declaration.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>>
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291955=291954=291955=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13
>> 14:46:54
>> 2017
>> @@ -3344,8 +3344,8 @@ def note_ovl_candidate : Note<"candidate
>>  def note_ovl_candidate_inherited_constructor : Note<
>>  "constructor from base class %0 inherited here">;
>>  def note_ovl_candidate_inherited_constructor_slice : Note<
>> -"constructor inherited from base class cannot be used to initialize
>> from "
>> -"an argument of the derived class type">;
>> +"candidate %select{constructor|template}0 ignored: "
>> +"inherited constructor cannot be used to %select{copy|move}1
>> object">;
>>  def note_ovl_candidate_illegal_constructor : Note<
>>  "candidate %select{constructor|template}0 ignored: "
>>  "instantiation %select{takes|would take}0 its own class type by
>> value">;
>>
>> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
>> URL:
>>
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=291955=291954=291955=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Jan 13 14:46:54 2017
>> @@ -5944,6 +5944,28 @@ Sema::AddOverloadCandidate(FunctionDecl
>>Candidate.FailureKind = ovl_fail_illegal_constructor;
>>return;
>>  }
>> +
>> +// C++ [over.match.funcs]p8: (proposed DR resolution)
>> +//   A constructor inherited from class type C that has a first
>> parameter
>> +//   of type "reference to P" (including such a constructor
>> instantiated
>> +//   from a template) is excluded from the set of candidate functions
>> when
>> +//   constructing an object of type cv D if the argument list has
>> exactly
>> +//   one argument and D is reference-related to P and P is
>> reference-related
>> +//   to C.
>> +auto *Shadow =
>> dyn_cast(FoundDecl.getDecl());
>> +if (Shadow && Args.size() == 1 && Constructor->getNumParams() >= 1 &&
>> +Constructor->getParamDecl(0)->getType()->isReferenceType()) {
>> +  QualType P =
>> Constructor->getParamDecl(0)->getType()->getPointeeType();
>> +  QualType C = Context.getRecordType(Constructor->getParent());
>> +  QualType D = Context.getRecordType(Shadow->getParent());
>> +  SourceLocation Loc = Args.front()->getExprLoc();
>> +  if ((Context.hasSameUnqualifiedType(P, C) || IsDerivedFrom(Loc, P,
>> C)) &&
>> +  (Context.hasSameUnqualifiedType(D, P) || IsDerivedFrom(Loc, D,
>> P))) {
>> +Candidate.Viable = false;
>> +Candidate.FailureKind = ovl_fail_inhctor_slice;
>> +return;
>> +  }
>> +}
>>}
>>
>>unsigned NumParams = Proto->getNumParams();
>> @@ -6016,31 +6038,6 @@ Sema::AddOverloadCandidate(FunctionDecl
>>  }
>>}
>>
>> -  // C++ 

r292458 - Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile collection

2017-01-18 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Wed Jan 18 18:44:21 2017
New Revision: 292458

URL: http://llvm.org/viewvc/llvm-project?rev=292458=rev
Log:
Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile 
collection

Summary:
SamplePGO uses profile with debug info to collect profile. Unlike the 
traditional debugging purpose, sample pgo needs more accurate debug info to 
represent the profile. We add -femit-accurate-debug-info for this purpose. It 
can be combined with all debugging modes (-g, -gmlt, etc). It makes sure that 
the following pieces of info is always emitted:

* start line of all subprograms
* linkage name of all subprograms
* standalone subprograms (functions that has neither inlined nor been inlined)

The impact on speccpu2006 binary size (size increase comparing with -g0 binary, 
also includes data for -g binary, which does not change with this patch):

   -gmlt(orig) -gmlt(patched) -g
433.milc   4.68%   5.40%  19.73%
444.namd   8.45%   8.93%  45.99%
447.dealII 97.43%  115.21%374.89%
450.soplex 27.75%  31.88% 126.04%
453.povray 21.81%  26.16% 92.03%
470.lbm0.60%   0.67%  1.96%
482.sphinx35.77%   6.47%  26.17%
400.perlbench  17.81%  19.43% 73.08%
401.bzip2  3.73%   3.92%  12.18%
403.gcc31.75%  34.48% 122.75%
429.mcf0.78%   0.88%  3.89%
445.gobmk  6.08%   7.92%  42.27%
456.hmmer  10.36%  11.25% 35.23%
458.sjeng  5.08%   5.42%  14.36%
462.libquantum 1.71%   1.96%  6.36%
464.h264ref15.61%  16.56% 43.92%
471.omnetpp11.93%  15.84% 60.09%
473.astar  3.11%   3.69%  14.18%
483.xalancbmk  56.29%  81.63% 353.22%
geomean15.60%  18.30% 57.81%

Debug info size change for -gmlt binary with this patch:

433.milc   13.46%
444.namd   5.35%
447.dealII 18.21%
450.soplex 14.68%
453.povray 19.65%
470.lbm6.03%
482.sphinx311.21%
400.perlbench  8.91%
401.bzip2  4.41%
403.gcc8.56%
429.mcf8.24%
445.gobmk  29.47%
456.hmmer  8.19%
458.sjeng  6.05%
462.libquantum 11.23%
464.h264ref5.93%
471.omnetpp31.89%
473.astar  16.20%
483.xalancbmk  44.62%
geomean16.83%

Reviewers: davidxl, andreadb, rob.lougher, dblaikie, echristo

Reviewed By: dblaikie, echristo

Subscribers: hfinkel, rob.lougher, andreadb, gbedwell, cfe-commits, probinson, 
llvm-commits, mehdi_amini

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=292458=292457=292458=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jan 18 18:44:21 2017
@@ -516,6 +516,12 @@ def fprofile_sample_use_EQ : Joined<["-"
 HelpText<"Enable sample-based profile guided optimizations">;
 def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
 Alias;
+def fdebug_info_for_profiling : Flag<["-"], "fdebug-info-for-profiling">, 
Group,
+Flags<[CC1Option]>,
+HelpText<"Emit extra debug info to make sample profile more accurate.">;
+def fno_debug_info_for_profiling : Flag<["-"], 
"fno-debug-info-for-profiling">, Group,
+Flags<[DriverOption]>,
+HelpText<"Do not emit extra debug info for sample profiler.">;
 def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
 Group, Flags<[CoreOption]>,
 HelpText<"Generate instrumented code to collect execution counts into 
default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env 
var)">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=292458=292457=292458=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jan 18 18:44:21 2017
@@ -258,6 +258,9 @@ CODEGENOPT(PIECopyRelocations, 1, 0)
 /// paths that reach the end of a function without executing a required return.
 CODEGENOPT(StrictReturn, 1, 1)
 
+/// Whether emit extra debug info for sample pgo profile collection.
+CODEGENOPT(DebugInfoForProfiling, 1, 0)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT

Modified: 

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-18 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D28467#649861, @krasin wrote:

> This change makes Clang hardly incompatible with MSVC++. Consider the 
> following program:
>
>   #include 
>  
>   int main(void) {
> const int kDelta = 1001;
> auto g = [kDelta](int i)
>  {
>printf("%d\n", i % kDelta);
>  };
> g(2);
>   }
>
>
> Clang will warn about the unused lambda capture:
>
>   $ clang++ lala.cc -o lala -std=c++14 -Wall -Werror && ./lala
>   lala.cc:5:13: error: lambda capture 'kDelta' is not required to be captured 
> for use in an unevaluated context [-Werror,-Wunused-lambda-capture]
> auto g = [kDelta](int i)
>   ^
>   1 error generated.
>


Is kDelta considered to be used in an unevaluated context here? I thought 
unevaluated context in c++ means the expression is used as operands of 
operators such as typeid and decltype.


Repository:
  rL LLVM

https://reviews.llvm.org/D28467



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


[PATCH] D28785: Split exception.cpp and new.cpp implementation into different files for different runtimes

2017-01-18 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

@EricWF and I discussed this on IRC a bunch yesterday.

We were inadvertently statically linking the Microsoft C++ libraries into 
tests, which is why `std::set_new_handler` was working with this patch. With 
that incorrect link removed, we get an undefined reference to 
`std::set_new_handler`, as expected. libc++ will have to implement 
`std::get_new_handler` and `std:set_new_handler` itself.

`vcruntime_new.h` is a gigantic pain, since it defines the operator new/delete 
overloads itself and is just generally annoying. We can avoid pulling it in 
ourselves, but user code might pull it in, and we probably want to be resilient 
to that? (I don't know how common the usage of that header is and if it's worth 
trying to be interoperable or just failing miserably in its presence.)


https://reviews.llvm.org/D28785



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


[PATCH] D25435: Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile collection

2017-01-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.

Thanks for explaining all of this and going through it Dehao.

LGTM.

-eric


https://reviews.llvm.org/D25435



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


[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-18 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc updated this revision to Diff 84907.
pcc added a comment.
Herald added a subscriber: mgorny.

- Add missing test dependency


https://reviews.llvm.org/D28843

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CMakeLists.txt
  clang/test/CodeGenCXX/type-metadata-thinlto.cpp


Index: clang/test/CodeGenCXX/type-metadata-thinlto.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/type-metadata-thinlto.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux 
-fvisibility hidden -emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+
+// CHECK: @_ZTV1A = linkonce_odr
+class A {
+  virtual void f() {}
+};
+
+A *f() {
+  return new A;
+}
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -80,6 +80,7 @@
 llc
 llvm-bcanalyzer
 llvm-dis
+llvm-modextract
 llvm-nm
 llvm-objdump
 llvm-profdata
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -688,9 +688,11 @@
 break;
 
   case Backend_EmitBC:
-PerModulePasses.add(createBitcodeWriterPass(
-*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex,
-CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex)
+  PerModulePasses.add(createWriteThinLTOBitcodePass(*OS));
+else
+  PerModulePasses.add(
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
 break;
 
   case Backend_EmitLL:


Index: clang/test/CodeGenCXX/type-metadata-thinlto.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/type-metadata-thinlto.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux -fvisibility hidden -emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+
+// CHECK: @_ZTV1A = linkonce_odr
+class A {
+  virtual void f() {}
+};
+
+A *f() {
+  return new A;
+}
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -80,6 +80,7 @@
 llc
 llvm-bcanalyzer
 llvm-dis
+llvm-modextract
 llvm-nm
 llvm-objdump
 llvm-profdata
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -688,9 +688,11 @@
 break;
 
   case Backend_EmitBC:
-PerModulePasses.add(createBitcodeWriterPass(
-*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex,
-CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex)
+  PerModulePasses.add(createWriteThinLTOBitcodePass(*OS));
+else
+  PerModulePasses.add(
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
 break;
 
   case Backend_EmitLL:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292450 - Add llvm-dis dependency to check-clang.

2017-01-18 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Wed Jan 18 18:04:44 2017
New Revision: 292450

URL: http://llvm.org/viewvc/llvm-project?rev=292450=rev
Log:
Add llvm-dis dependency to check-clang.

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=292450=292449=292450=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed Jan 18 18:04:44 2017
@@ -79,6 +79,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 FileCheck count not
 llc
 llvm-bcanalyzer
+llvm-dis
 llvm-nm
 llvm-objdump
 llvm-profdata


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


[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-18 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D28843



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


r292448 - Move vtable type metadata emission behind a cc1-level flag.

2017-01-18 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Wed Jan 18 17:55:27 2017
New Revision: 292448

URL: http://llvm.org/viewvc/llvm-project?rev=292448=rev
Log:
Move vtable type metadata emission behind a cc1-level flag.

In ThinLTO mode, type metadata will require the module to be written as a
multi-module bitcode file, which is currently incompatible with the Darwin
linker. It is also useful to be able to enable or disable multi-module bitcode
for testing purposes. This introduces a cc1-level flag, -f{,no-}lto-unit,
which is used by the driver to enable multi-module bitcode on all but
Darwin+ThinLTO, and can also be used to enable/disable the feature manually.

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

Added:
cfe/trunk/test/CodeGenCXX/no-lto-unit.cpp
cfe/trunk/test/Driver/lto-unit.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGenCXX/cfi-ms-rtti.cpp
cfe/trunk/test/CodeGenCXX/type-metadata.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=292448=292447=292448=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Jan 18 17:55:27 2017
@@ -307,6 +307,9 @@ def fprofile_instrument_use_path_EQ :
 def flto_visibility_public_std:
 Flag<["-"], "flto-visibility-public-std">,
 HelpText<"Use public LTO visibility for classes in std and stdext 
namespaces">;
+def flto_unit: Flag<["-"], "flto-unit">,
+HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
+def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 
 
//===--===//
 // Dependency Output Options

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=292448=292447=292448=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jan 18 17:55:27 2017
@@ -89,6 +89,8 @@ CODEGENOPT(PrepareForLTO , 1, 0) ///
  ///< compile step.
 CODEGENOPT(EmitSummaryIndex, 1, 0)   ///< Set when -flto=thin is enabled on the
  ///< compile step.
+CODEGENOPT(LTOUnit, 1, 0) ///< Emit IR to support LTO unit features (CFI, whole
+  ///< program vtable opt).
 CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an object file which 
can
   ///< be used with an incremental
   ///< linker.

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=292448=292447=292448=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Jan 18 17:55:27 2017
@@ -942,7 +942,7 @@ bool CodeGenModule::HasHiddenLTOVisibili
 
 void CodeGenModule::EmitVTableTypeMetadata(llvm::GlobalVariable *VTable,
const VTableLayout ) {
-  if (!getCodeGenOpts().PrepareForLTO)
+  if (!getCodeGenOpts().LTOUnit)
 return;
 
   CharUnits PointerWidth =

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=292448=292447=292448=diff
==
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Wed Jan 18 17:55:27 2017
@@ -1554,7 +1554,7 @@ void MicrosoftCXXABI::EmitDestructorCall
 void MicrosoftCXXABI::emitVTableTypeMetadata(const VPtrInfo ,
  const CXXRecordDecl *RD,
  llvm::GlobalVariable *VTable) {
-  if (!CGM.getCodeGenOpts().PrepareForLTO)
+  if (!CGM.getCodeGenOpts().LTOUnit)
 return;
 
   // The location of the first virtual function pointer in the virtual table,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=292448=292447=292448=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan 18 17:55:27 2017
@@ -4238,8 +4238,16 @@ void Clang::ConstructJob(Compilation ,
 if 

[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-18 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc updated this revision to Diff 84903.
pcc added a comment.

Refresh


https://reviews.llvm.org/D28843

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGenCXX/type-metadata-thinlto.cpp


Index: clang/test/CodeGenCXX/type-metadata-thinlto.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/type-metadata-thinlto.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux 
-fvisibility hidden -emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+
+// CHECK: @_ZTV1A = linkonce_odr
+class A {
+  virtual void f() {}
+};
+
+A *f() {
+  return new A;
+}
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -688,9 +688,11 @@
 break;
 
   case Backend_EmitBC:
-PerModulePasses.add(createBitcodeWriterPass(
-*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex,
-CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex)
+  PerModulePasses.add(createWriteThinLTOBitcodePass(*OS));
+else
+  PerModulePasses.add(
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
 break;
 
   case Backend_EmitLL:


Index: clang/test/CodeGenCXX/type-metadata-thinlto.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/type-metadata-thinlto.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux -fvisibility hidden -emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+
+// CHECK: @_ZTV1A = linkonce_odr
+class A {
+  virtual void f() {}
+};
+
+A *f() {
+  return new A;
+}
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -688,9 +688,11 @@
 break;
 
   case Backend_EmitBC:
-PerModulePasses.add(createBitcodeWriterPass(
-*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex,
-CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex)
+  PerModulePasses.add(createWriteThinLTOBitcodePass(*OS));
+else
+  PerModulePasses.add(
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
 break;
 
   case Backend_EmitLL:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28877: Move vtable type metadata emission behind a cc1-level flag.

2017-01-18 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292448: Move vtable type metadata emission behind a 
cc1-level flag. (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D28877?vs=84900=84902#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28877

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CGVTables.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGenCXX/cfi-ms-rtti.cpp
  cfe/trunk/test/CodeGenCXX/no-lto-unit.cpp
  cfe/trunk/test/CodeGenCXX/type-metadata.cpp
  cfe/trunk/test/Driver/lto-unit.c

Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -631,6 +631,7 @@
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
   const Arg *A = Args.getLastArg(OPT_flto, OPT_flto_EQ);
   Opts.EmitSummaryIndex = A && A->containsValue("thin");
+  Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit, false);
   if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
 if (IK != IK_LLVM_IR)
   Diags.Report(diag::err_drv_argument_only_allowed_with)
Index: cfe/trunk/lib/CodeGen/CGVTables.cpp
===
--- cfe/trunk/lib/CodeGen/CGVTables.cpp
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp
@@ -942,7 +942,7 @@
 
 void CodeGenModule::EmitVTableTypeMetadata(llvm::GlobalVariable *VTable,
const VTableLayout ) {
-  if (!getCodeGenOpts().PrepareForLTO)
+  if (!getCodeGenOpts().LTOUnit)
 return;
 
   CharUnits PointerWidth =
Index: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1554,7 +1554,7 @@
 void MicrosoftCXXABI::emitVTableTypeMetadata(const VPtrInfo ,
  const CXXRecordDecl *RD,
  llvm::GlobalVariable *VTable) {
-  if (!CGM.getCodeGenOpts().PrepareForLTO)
+  if (!CGM.getCodeGenOpts().LTOUnit)
 return;
 
   // The location of the first virtual function pointer in the virtual table,
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4238,8 +4238,16 @@
 if (JA.getType() == types::TY_LLVM_BC)
   CmdArgs.push_back("-emit-llvm-uselists");
 
-if (D.isUsingLTO())
+if (D.isUsingLTO()) {
   Args.AddLastArg(CmdArgs, options::OPT_flto, options::OPT_flto_EQ);
+
+  // The Darwin linker currently uses the legacy LTO API, which does not
+  // support LTO unit features (CFI, whole program vtable opt) under
+  // ThinLTO.
+  if (!getToolChain().getTriple().isOSDarwin() ||
+  D.getLTOMode() == LTOK_Full)
+CmdArgs.push_back("-flto-unit");
+}
   }
 
   if (const Arg *A = Args.getLastArg(options::OPT_fthinlto_index_EQ)) {
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -89,6 +89,8 @@
  ///< compile step.
 CODEGENOPT(EmitSummaryIndex, 1, 0)   ///< Set when -flto=thin is enabled on the
  ///< compile step.
+CODEGENOPT(LTOUnit, 1, 0) ///< Emit IR to support LTO unit features (CFI, whole
+  ///< program vtable opt).
 CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an object file which can
   ///< be used with an incremental
   ///< linker.
Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -307,6 +307,9 @@
 def flto_visibility_public_std:
 Flag<["-"], "flto-visibility-public-std">,
 HelpText<"Use public LTO visibility for classes in std and stdext namespaces">;
+def flto_unit: Flag<["-"], "flto-unit">,
+HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable opt)">;
+def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 
 //===--===//
 // Dependency Output Options
Index: cfe/trunk/test/CodeGenCXX/type-metadata.cpp
===
--- cfe/trunk/test/CodeGenCXX/type-metadata.cpp
+++ 

[PATCH] D28877: Move vtable type metadata emission behind a cc1-level flag.

2017-01-18 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D28877



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


[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-18 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: clang/test/CodeGenCXX/type-metadata-thinlto.cpp:2
+// RUN: %clang_cc1 -flto=thin -triple x86_64-unknown-linux -fvisibility hidden 
-emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+

tejohnson wrote:
> mehdi_amini wrote:
> > tejohnson wrote:
> > > mehdi_amini wrote:
> > > > pcc wrote:
> > > > > mehdi_amini wrote:
> > > > > > pcc wrote:
> > > > > > > mehdi_amini wrote:
> > > > > > > > tejohnson wrote:
> > > > > > > > > Is it the case that now we will always split the module with 
> > > > > > > > > this change? Should that only be done under CFI options?
> > > > > > > > Devirtualization may happen whenever you have a hidden virtual 
> > > > > > > > table IIUC, independently of CFI.
> > > > > > > To be more precise: we normally add type metadata in LTO mode 
> > > > > > > when the class has hidden visibility. See: 
> > > > > > > http://clang.llvm.org/docs/LTOVisibility.html
> > > > > > > 
> > > > > > > That doesn't necessarily imply devirtualization, which is 
> > > > > > > controlled by the flag `-fwhole-program-vtables`.
> > > > > > So with hidden visibility but without CFI or 
> > > > > > -fwhole-program-vtables, do we split the module? What's the purpose?
> > > > > At the moment we would. The purpose is to simplify the overall 
> > > > > interface. If I want to compile a subset of my TUs without CFI or 
> > > > > devirtualization, I should be able to do that by enabling LTO but not 
> > > > > passing the CFI or devirtualization flags. In that case the vtables 
> > > > > themselves should still have type metadata so that TUs compiled 
> > > > > without CFI/devirtualization can correctly interoperate with TUs 
> > > > > compiled with CFI/devirtualization (to handle the cases where a class 
> > > > > defined in a TU compiled without CFI/devirt is used by code compiled 
> > > > > with LTO/devirt, or where the linker/LTO selects a linkonce_odr 
> > > > > vtable from a TU compiled without CFI/devirt).
> > > > > 
> > > > > I'd be open to changing the command line interface so that an 
> > > > > additional flag may be used to control the scope of the "LTO unit" 
> > > > > and which would just enable type metadata, but ideally I'd like to 
> > > > > keep things relatively simple.
> > > > > At the moment we would. The purpose is to simplify the overall 
> > > > > interface. 
> > > > 
> > > > Right, if it was the only reason, I wouldn't be in favor, but you raise 
> > > > a real use case below.
> > > > 
> > > > > If I want to compile a subset of my TUs without CFI or 
> > > > > devirtualization, I should be able to do that by enabling LTO but not 
> > > > > passing the CFI or devirtualization flags. 
> > > > 
> > > > Right, seems legit.
> > > > 
> > > > > In that case the vtables themselves should still have type metadata 
> > > > > so that TUs compiled without CFI/devirtualization can correctly 
> > > > > interoperate with TUs compiled with CFI/devirtualization 
> > > > 
> > > > That's what I wasn't sure about :)
> > > > 
> > > > > (to handle the cases where a class defined in a TU compiled without 
> > > > > CFI/devirt is used by code compiled with LTO/devirt, or where the 
> > > > > linker/LTO selects a linkonce_odr vtable from a TU compiled without 
> > > > > CFI/devirt).
> > > > 
> > > > Make sense, LGTM as is with this explanation!
> > > > Thanks.
> > > I would like some way to disable this, at least for debugging.
> > CC1 option then?
> > CC1 option then?
> 
> Sure
D28877


https://reviews.llvm.org/D28843



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


[PATCH] D28877: Move vtable type metadata emission behind a cc1-level flag.

2017-01-18 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc created this revision.

In ThinLTO mode, type metadata will require the module to be written as a
multi-module bitcode file, which is currently incompatible with the Darwin
linker. It is also useful to be able to enable or disable multi-module bitcode
for testing purposes. This introduces a cc1-level flag, -f{,no-}lto-unit,
which is used by the driver to enable multi-module bitcode on all but
Darwin+ThinLTO, and can also be used to enable/disable the feature manually.


https://reviews.llvm.org/D28877

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CodeGenOptions.def
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Driver/Tools.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/cfi-ms-rtti.cpp
  clang/test/CodeGenCXX/no-lto-unit.cpp
  clang/test/CodeGenCXX/type-metadata.cpp
  clang/test/Driver/lto-unit.c

Index: clang/test/Driver/lto-unit.c
===
--- /dev/null
+++ clang/test/Driver/lto-unit.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=full 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=full 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin 2>&1 | FileCheck --check-prefix=NOUNIT %s
+
+// UNIT: "-flto-unit"
+// NOUNIT-NOT: "-flto-unit"
Index: clang/test/CodeGenCXX/type-metadata.cpp
===
--- clang/test/CodeGenCXX/type-metadata.cpp
+++ clang/test/CodeGenCXX/type-metadata.cpp
@@ -1,16 +1,16 @@
 // Tests for the cfi-vcall feature:
-// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=CFI-NVT --check-prefix=ITANIUM --check-prefix=TT-ITANIUM --check-prefix=NDIAG %s
-// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=CFI-NVT --check-prefix=ITANIUM --check-prefix=TT-ITANIUM --check-prefix=ITANIUM-DIAG --check-prefix=DIAG --check-prefix=DIAG-ABORT %s
-// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden -fsanitize=cfi-vcall -fsanitize-recover=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=CFI-NVT --check-prefix=ITANIUM --check-prefix=TT-ITANIUM --check-prefix=ITANIUM-DIAG --check-prefix=DIAG --check-prefix=DIAG-RECOVER %s
-// RUN: %clang_cc1 -flto -triple x86_64-pc-windows-msvc -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=CFI-NVT --check-prefix=MS --check-prefix=TT-MS --check-prefix=NDIAG %s
+// RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -fvisibility hidden -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=CFI-NVT --check-prefix=ITANIUM --check-prefix=TT-ITANIUM --check-prefix=NDIAG %s
+// RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -fvisibility hidden -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=CFI-NVT --check-prefix=ITANIUM --check-prefix=TT-ITANIUM --check-prefix=ITANIUM-DIAG --check-prefix=DIAG --check-prefix=DIAG-ABORT %s
+// RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -fvisibility hidden -fsanitize=cfi-vcall -fsanitize-recover=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=CFI-NVT --check-prefix=ITANIUM --check-prefix=TT-ITANIUM --check-prefix=ITANIUM-DIAG --check-prefix=DIAG --check-prefix=DIAG-RECOVER %s
+// RUN: %clang_cc1 -flto -flto-unit -triple x86_64-pc-windows-msvc -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=CFI-NVT --check-prefix=MS --check-prefix=TT-MS --check-prefix=NDIAG %s
 
 // Tests for the whole-program-vtables feature:
-// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=VTABLE-OPT --check-prefix=ITANIUM --check-prefix=TT-ITANIUM %s
-// RUN: %clang_cc1 -flto -triple x86_64-pc-windows-msvc -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=VTABLE-OPT --check-prefix=MS --check-prefix=TT-MS %s
+// RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -fvisibility hidden -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=VTABLE-OPT --check-prefix=ITANIUM --check-prefix=TT-ITANIUM %s
+// RUN: %clang_cc1 -flto -flto-unit -triple x86_64-pc-windows-msvc -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=VTABLE-OPT --check-prefix=MS --check-prefix=TT-MS %s
 
 // Tests for cfi + 

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-18 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

MSVC's behaviour is discussed here: 
https://social.msdn.microsoft.com/Forums/SqlServer/en-US/4abf18bd-4ae4-4c72-ba3e-3b13e7909d5f/error-c2057-or-c3493-trying-to-use-an-integral-constant-expression-inside-a-lambda?forum=vclanguage
and here:
https://connect.microsoft.com/VisualStudio/feedback/details/725780


Repository:
  rL LLVM

https://reviews.llvm.org/D28467



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


[libcxx] r292443 - [libcxx] [test] Add msvc_stdlib_force_include.hpp.

2017-01-18 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Wed Jan 18 16:19:14 2017
New Revision: 292443

URL: http://llvm.org/viewvc/llvm-project?rev=292443=rev
Log:
[libcxx] [test] Add msvc_stdlib_force_include.hpp.

No functional change; nothing includes this, instead our test harness
injects it via the /FI compiler option.

No code review; blessed in advance by EricWF.

Added:
libcxx/trunk/test/support/msvc_stdlib_force_include.hpp

Added: libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/msvc_stdlib_force_include.hpp?rev=292443=auto
==
--- libcxx/trunk/test/support/msvc_stdlib_force_include.hpp (added)
+++ libcxx/trunk/test/support/msvc_stdlib_force_include.hpp Wed Jan 18 16:19:14 
2017
@@ -0,0 +1,79 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_HPP
+#define SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_HPP
+
+
+// This header is force-included when running MSVC's compiler and standard 
library with libc++'s tests.
+
+
+// Avoid assertion dialogs.
+#define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+
+#include 
+#include 
+
+struct AssertionDialogAvoider {
+AssertionDialogAvoider() {
+_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
+_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+
+_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
+_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+}
+};
+
+const AssertionDialogAvoider assertion_dialog_avoider{};
+
+
+// Simulate feature-test macros.
+#define __has_feature(X) _MSVC_HAS_FEATURE_ ## X
+#define _MSVC_HAS_FEATURE_cxx_exceptions1
+#define _MSVC_HAS_FEATURE_cxx_rtti  1
+#define _MSVC_HAS_FEATURE_address_sanitizer 0
+#define _MSVC_HAS_FEATURE_memory_sanitizer  0
+#define _MSVC_HAS_FEATURE_thread_sanitizer  0
+
+
+// atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix.
+#define _ENABLE_ATOMIC_ALIGNMENT_FIX
+
+
+// Enable features that /std:c++latest removes by default.
+#define _HAS_AUTO_PTR_ETC  1
+#define _HAS_FUNCTION_ASSIGN   1
+#define _HAS_OLD_IOSTREAMS_MEMBERS 1
+
+
+// MSVC doesn't have __int128_t.
+#define _LIBCPP_HAS_NO_INT128
+
+
+// MSVC has quick_exit() and at_quick_exit().
+#define _LIBCPP_HAS_QUICK_EXIT
+
+
+// MSVC's STL partially supports C++17.
+#define TEST_STD_VER 17
+
+
+// Silence warnings about raw pointers and other unchecked iterators.
+#define _SCL_SECURE_NO_WARNINGS
+
+
+// Silence compiler warnings.
+#pragma warning(disable: 4180) // qualifier applied to function type has no 
meaning; ignored
+#pragma warning(disable: 4521) // multiple copy constructors specified
+#pragma warning(disable: 4702) // unreachable code
+#pragma warning(disable: 6294) // Ill-defined for-loop:  initial condition 
does not satisfy test.  Loop body not executed.
+#pragma warning(disable: 28251) // Inconsistent annotation for 'new': this 
instance has no annotations.
+
+
+#endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_HPP


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


[PATCH] D28867: [Profile] Warn about out-of-date profiles only when there are mismatches

2017-01-18 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D28867#649760, @vsk wrote:

> Ah ok, so it sounds like a better approach would be to split the missing 
> record message into a separate off-by-default warning.


I'm in favor of this.


https://reviews.llvm.org/D28867



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


[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-18 Thread Ivan Krasin via Phabricator via cfe-commits
krasin added a comment.

This change makes Clang hardly incompatible with MSVC++. Consider the following 
program:

  #include 
  
  int main(void) {
const int kDelta = 1001;
auto g = [kDelta](int i)
 {
   printf("%d\n", i % kDelta);
 };
g(2);
  }

Clang will warn about the unused lambda capture:

  $ clang++ lala.cc -o lala -std=c++14 -Wall -Werror && ./lala
  lala.cc:5:13: error: lambda capture 'kDelta' is not required to be captured 
for use in an unevaluated context [-Werror,-Wunused-lambda-capture]
auto g = [kDelta](int i)
  ^
  1 error generated.

It will compile without any warnings if I remove kDelta from the list of 
captures:

  #include 
  
  int main(void) {
const int kDelta = 1001;
auto g = [](int i)
 {
   printf("%d\n", i % kDelta);
 };
g(2);
  }

But then Microsoft C++ compiler will raise the error:

  error C3493: 'kDelta' cannot be implicitly captured because no default 
capture mode has been specified

At this point, I am unsure how can this be improved, but I feel that pointing 
out this inconsistency might be useful.
For real world case, see https://codereview.chromium.org/2646553002/, where I 
tried to fix unused lambda captures in V8, in particular, this failure: 
https://build.chromium.org/p/tryserver.v8/builders/v8_win_rel_ng/builds/21172/steps/compile/logs/stdio


Repository:
  rL LLVM

https://reviews.llvm.org/D28467



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


[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-18 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: clang/test/CodeGenCXX/type-metadata-thinlto.cpp:2
+// RUN: %clang_cc1 -flto=thin -triple x86_64-unknown-linux -fvisibility hidden 
-emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+

mehdi_amini wrote:
> tejohnson wrote:
> > mehdi_amini wrote:
> > > pcc wrote:
> > > > mehdi_amini wrote:
> > > > > pcc wrote:
> > > > > > mehdi_amini wrote:
> > > > > > > tejohnson wrote:
> > > > > > > > Is it the case that now we will always split the module with 
> > > > > > > > this change? Should that only be done under CFI options?
> > > > > > > Devirtualization may happen whenever you have a hidden virtual 
> > > > > > > table IIUC, independently of CFI.
> > > > > > To be more precise: we normally add type metadata in LTO mode when 
> > > > > > the class has hidden visibility. See: 
> > > > > > http://clang.llvm.org/docs/LTOVisibility.html
> > > > > > 
> > > > > > That doesn't necessarily imply devirtualization, which is 
> > > > > > controlled by the flag `-fwhole-program-vtables`.
> > > > > So with hidden visibility but without CFI or -fwhole-program-vtables, 
> > > > > do we split the module? What's the purpose?
> > > > At the moment we would. The purpose is to simplify the overall 
> > > > interface. If I want to compile a subset of my TUs without CFI or 
> > > > devirtualization, I should be able to do that by enabling LTO but not 
> > > > passing the CFI or devirtualization flags. In that case the vtables 
> > > > themselves should still have type metadata so that TUs compiled without 
> > > > CFI/devirtualization can correctly interoperate with TUs compiled with 
> > > > CFI/devirtualization (to handle the cases where a class defined in a TU 
> > > > compiled without CFI/devirt is used by code compiled with LTO/devirt, 
> > > > or where the linker/LTO selects a linkonce_odr vtable from a TU 
> > > > compiled without CFI/devirt).
> > > > 
> > > > I'd be open to changing the command line interface so that an 
> > > > additional flag may be used to control the scope of the "LTO unit" and 
> > > > which would just enable type metadata, but ideally I'd like to keep 
> > > > things relatively simple.
> > > > At the moment we would. The purpose is to simplify the overall 
> > > > interface. 
> > > 
> > > Right, if it was the only reason, I wouldn't be in favor, but you raise a 
> > > real use case below.
> > > 
> > > > If I want to compile a subset of my TUs without CFI or 
> > > > devirtualization, I should be able to do that by enabling LTO but not 
> > > > passing the CFI or devirtualization flags. 
> > > 
> > > Right, seems legit.
> > > 
> > > > In that case the vtables themselves should still have type metadata so 
> > > > that TUs compiled without CFI/devirtualization can correctly 
> > > > interoperate with TUs compiled with CFI/devirtualization 
> > > 
> > > That's what I wasn't sure about :)
> > > 
> > > > (to handle the cases where a class defined in a TU compiled without 
> > > > CFI/devirt is used by code compiled with LTO/devirt, or where the 
> > > > linker/LTO selects a linkonce_odr vtable from a TU compiled without 
> > > > CFI/devirt).
> > > 
> > > Make sense, LGTM as is with this explanation!
> > > Thanks.
> > I would like some way to disable this, at least for debugging.
> CC1 option then?
> CC1 option then?

Sure


https://reviews.llvm.org/D28843



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


[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.

2017-01-18 Thread Manman Ren via Phabricator via cfe-commits
manmanren added a comment.

Ping :]
Hoping to wrap this up this week.
Cheers,
Manman


https://reviews.llvm.org/D28299



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


[PATCH] D27689: Module: hash the pcm content and use it as SIGNATURE for implicit modules.

2017-01-18 Thread Manman Ren via Phabricator via cfe-commits
manmanren marked an inline comment as done.
manmanren added a comment.

Ping :]
I am hoping to wrap this up this week. Thanks,
Manman


https://reviews.llvm.org/D27689



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


[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-18 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: clang/test/CodeGenCXX/type-metadata-thinlto.cpp:2
+// RUN: %clang_cc1 -flto=thin -triple x86_64-unknown-linux -fvisibility hidden 
-emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+

tejohnson wrote:
> mehdi_amini wrote:
> > pcc wrote:
> > > mehdi_amini wrote:
> > > > pcc wrote:
> > > > > mehdi_amini wrote:
> > > > > > tejohnson wrote:
> > > > > > > Is it the case that now we will always split the module with this 
> > > > > > > change? Should that only be done under CFI options?
> > > > > > Devirtualization may happen whenever you have a hidden virtual 
> > > > > > table IIUC, independently of CFI.
> > > > > To be more precise: we normally add type metadata in LTO mode when 
> > > > > the class has hidden visibility. See: 
> > > > > http://clang.llvm.org/docs/LTOVisibility.html
> > > > > 
> > > > > That doesn't necessarily imply devirtualization, which is controlled 
> > > > > by the flag `-fwhole-program-vtables`.
> > > > So with hidden visibility but without CFI or -fwhole-program-vtables, 
> > > > do we split the module? What's the purpose?
> > > At the moment we would. The purpose is to simplify the overall interface. 
> > > If I want to compile a subset of my TUs without CFI or devirtualization, 
> > > I should be able to do that by enabling LTO but not passing the CFI or 
> > > devirtualization flags. In that case the vtables themselves should still 
> > > have type metadata so that TUs compiled without CFI/devirtualization can 
> > > correctly interoperate with TUs compiled with CFI/devirtualization (to 
> > > handle the cases where a class defined in a TU compiled without 
> > > CFI/devirt is used by code compiled with LTO/devirt, or where the 
> > > linker/LTO selects a linkonce_odr vtable from a TU compiled without 
> > > CFI/devirt).
> > > 
> > > I'd be open to changing the command line interface so that an additional 
> > > flag may be used to control the scope of the "LTO unit" and which would 
> > > just enable type metadata, but ideally I'd like to keep things relatively 
> > > simple.
> > > At the moment we would. The purpose is to simplify the overall interface. 
> > 
> > Right, if it was the only reason, I wouldn't be in favor, but you raise a 
> > real use case below.
> > 
> > > If I want to compile a subset of my TUs without CFI or devirtualization, 
> > > I should be able to do that by enabling LTO but not passing the CFI or 
> > > devirtualization flags. 
> > 
> > Right, seems legit.
> > 
> > > In that case the vtables themselves should still have type metadata so 
> > > that TUs compiled without CFI/devirtualization can correctly interoperate 
> > > with TUs compiled with CFI/devirtualization 
> > 
> > That's what I wasn't sure about :)
> > 
> > > (to handle the cases where a class defined in a TU compiled without 
> > > CFI/devirt is used by code compiled with LTO/devirt, or where the 
> > > linker/LTO selects a linkonce_odr vtable from a TU compiled without 
> > > CFI/devirt).
> > 
> > Make sense, LGTM as is with this explanation!
> > Thanks.
> I would like some way to disable this, at least for debugging.
CC1 option then?


https://reviews.llvm.org/D28843



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


[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-18 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: clang/test/CodeGenCXX/type-metadata-thinlto.cpp:2
+// RUN: %clang_cc1 -flto=thin -triple x86_64-unknown-linux -fvisibility hidden 
-emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+

mehdi_amini wrote:
> pcc wrote:
> > mehdi_amini wrote:
> > > pcc wrote:
> > > > mehdi_amini wrote:
> > > > > tejohnson wrote:
> > > > > > Is it the case that now we will always split the module with this 
> > > > > > change? Should that only be done under CFI options?
> > > > > Devirtualization may happen whenever you have a hidden virtual table 
> > > > > IIUC, independently of CFI.
> > > > To be more precise: we normally add type metadata in LTO mode when the 
> > > > class has hidden visibility. See: 
> > > > http://clang.llvm.org/docs/LTOVisibility.html
> > > > 
> > > > That doesn't necessarily imply devirtualization, which is controlled by 
> > > > the flag `-fwhole-program-vtables`.
> > > So with hidden visibility but without CFI or -fwhole-program-vtables, do 
> > > we split the module? What's the purpose?
> > At the moment we would. The purpose is to simplify the overall interface. 
> > If I want to compile a subset of my TUs without CFI or devirtualization, I 
> > should be able to do that by enabling LTO but not passing the CFI or 
> > devirtualization flags. In that case the vtables themselves should still 
> > have type metadata so that TUs compiled without CFI/devirtualization can 
> > correctly interoperate with TUs compiled with CFI/devirtualization (to 
> > handle the cases where a class defined in a TU compiled without CFI/devirt 
> > is used by code compiled with LTO/devirt, or where the linker/LTO selects a 
> > linkonce_odr vtable from a TU compiled without CFI/devirt).
> > 
> > I'd be open to changing the command line interface so that an additional 
> > flag may be used to control the scope of the "LTO unit" and which would 
> > just enable type metadata, but ideally I'd like to keep things relatively 
> > simple.
> > At the moment we would. The purpose is to simplify the overall interface. 
> 
> Right, if it was the only reason, I wouldn't be in favor, but you raise a 
> real use case below.
> 
> > If I want to compile a subset of my TUs without CFI or devirtualization, I 
> > should be able to do that by enabling LTO but not passing the CFI or 
> > devirtualization flags. 
> 
> Right, seems legit.
> 
> > In that case the vtables themselves should still have type metadata so that 
> > TUs compiled without CFI/devirtualization can correctly interoperate with 
> > TUs compiled with CFI/devirtualization 
> 
> That's what I wasn't sure about :)
> 
> > (to handle the cases where a class defined in a TU compiled without 
> > CFI/devirt is used by code compiled with LTO/devirt, or where the 
> > linker/LTO selects a linkonce_odr vtable from a TU compiled without 
> > CFI/devirt).
> 
> Make sense, LGTM as is with this explanation!
> Thanks.
I would like some way to disable this, at least for debugging.


https://reviews.llvm.org/D28843



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


[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-18 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: clang/test/CodeGenCXX/type-metadata-thinlto.cpp:2
+// RUN: %clang_cc1 -flto=thin -triple x86_64-unknown-linux -fvisibility hidden 
-emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+

pcc wrote:
> mehdi_amini wrote:
> > pcc wrote:
> > > mehdi_amini wrote:
> > > > tejohnson wrote:
> > > > > Is it the case that now we will always split the module with this 
> > > > > change? Should that only be done under CFI options?
> > > > Devirtualization may happen whenever you have a hidden virtual table 
> > > > IIUC, independently of CFI.
> > > To be more precise: we normally add type metadata in LTO mode when the 
> > > class has hidden visibility. See: 
> > > http://clang.llvm.org/docs/LTOVisibility.html
> > > 
> > > That doesn't necessarily imply devirtualization, which is controlled by 
> > > the flag `-fwhole-program-vtables`.
> > So with hidden visibility but without CFI or -fwhole-program-vtables, do we 
> > split the module? What's the purpose?
> At the moment we would. The purpose is to simplify the overall interface. If 
> I want to compile a subset of my TUs without CFI or devirtualization, I 
> should be able to do that by enabling LTO but not passing the CFI or 
> devirtualization flags. In that case the vtables themselves should still have 
> type metadata so that TUs compiled without CFI/devirtualization can correctly 
> interoperate with TUs compiled with CFI/devirtualization (to handle the cases 
> where a class defined in a TU compiled without CFI/devirt is used by code 
> compiled with LTO/devirt, or where the linker/LTO selects a linkonce_odr 
> vtable from a TU compiled without CFI/devirt).
> 
> I'd be open to changing the command line interface so that an additional flag 
> may be used to control the scope of the "LTO unit" and which would just 
> enable type metadata, but ideally I'd like to keep things relatively simple.
> At the moment we would. The purpose is to simplify the overall interface. 

Right, if it was the only reason, I wouldn't be in favor, but you raise a real 
use case below.

> If I want to compile a subset of my TUs without CFI or devirtualization, I 
> should be able to do that by enabling LTO but not passing the CFI or 
> devirtualization flags. 

Right, seems legit.

> In that case the vtables themselves should still have type metadata so that 
> TUs compiled without CFI/devirtualization can correctly interoperate with TUs 
> compiled with CFI/devirtualization 

That's what I wasn't sure about :)

> (to handle the cases where a class defined in a TU compiled without 
> CFI/devirt is used by code compiled with LTO/devirt, or where the linker/LTO 
> selects a linkonce_odr vtable from a TU compiled without CFI/devirt).

Make sense, LGTM as is with this explanation!
Thanks.


https://reviews.llvm.org/D28843



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


[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-18 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: clang/test/CodeGenCXX/type-metadata-thinlto.cpp:2
+// RUN: %clang_cc1 -flto=thin -triple x86_64-unknown-linux -fvisibility hidden 
-emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+

mehdi_amini wrote:
> pcc wrote:
> > mehdi_amini wrote:
> > > tejohnson wrote:
> > > > Is it the case that now we will always split the module with this 
> > > > change? Should that only be done under CFI options?
> > > Devirtualization may happen whenever you have a hidden virtual table 
> > > IIUC, independently of CFI.
> > To be more precise: we normally add type metadata in LTO mode when the 
> > class has hidden visibility. See: 
> > http://clang.llvm.org/docs/LTOVisibility.html
> > 
> > That doesn't necessarily imply devirtualization, which is controlled by the 
> > flag `-fwhole-program-vtables`.
> So with hidden visibility but without CFI or -fwhole-program-vtables, do we 
> split the module? What's the purpose?
At the moment we would. The purpose is to simplify the overall interface. If I 
want to compile a subset of my TUs without CFI or devirtualization, I should be 
able to do that by enabling LTO but not passing the CFI or devirtualization 
flags. In that case the vtables themselves should still have type metadata so 
that TUs compiled without CFI/devirtualization can correctly interoperate with 
TUs compiled with CFI/devirtualization (to handle the cases where a class 
defined in a TU compiled without CFI/devirt is used by code compiled with 
LTO/devirt, or where the linker/LTO selects a linkonce_odr vtable from a TU 
compiled without CFI/devirt).

I'd be open to changing the command line interface so that an additional flag 
may be used to control the scope of the "LTO unit" and which would just enable 
type metadata, but ideally I'd like to keep things relatively simple.


https://reviews.llvm.org/D28843



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


r292439 - Remove now redundant code that ensured debug info for class definitions was emitted under certain circumstances

2017-01-18 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Jan 18 15:15:18 2017
New Revision: 292439

URL: http://llvm.org/viewvc/llvm-project?rev=292439=rev
Log:
Remove now redundant code that ensured debug info for class definitions was 
emitted under certain circumstances

Introduced in r181561 - it may've been subsumed by work done to allow
emission of declarations for vtable types while still emitting some of
their member functions correctly for those declarations. Whatever the
reason, the tests pass without this code now.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=292439=292438=292439=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Jan 18 15:15:18 2017
@@ -1828,22 +1828,6 @@ bool CodeGenModule::shouldEmitFunction(G
   return !isTriviallyRecursive(F);
 }
 
-/// If the type for the method's class was generated by
-/// CGDebugInfo::createContextChain(), the cache contains only a
-/// limited DIType without any declarations. Since EmitFunctionStart()
-/// needs to find the canonical declaration for each method, we need
-/// to construct the complete type prior to emitting the method.
-void CodeGenModule::CompleteDIClassType(const CXXMethodDecl* D) {
-  if (!D->isInstance())
-return;
-
-  if (CGDebugInfo *DI = getModuleDebugInfo())
-if (getCodeGenOpts().getDebugInfo() >= codegenoptions::LimitedDebugInfo) {
-  const auto *ThisPtr = cast(D->getThisType(getContext()));
-  DI->getOrCreateRecordType(ThisPtr->getPointeeType(), D->getLocation());
-}
-}
-
 void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD, llvm::GlobalValue *GV) 
{
   const auto *D = cast(GD.getDecl());
 
@@ -1858,7 +1842,6 @@ void CodeGenModule::EmitGlobalDefinition
   return;
 
 if (const auto *Method = dyn_cast(D)) {
-  CompleteDIClassType(Method);
   // Make sure to emit the definition(s) before we emit the thunks.
   // This is necessary for the generation of certain thunks.
   if (const auto *CD = dyn_cast(Method))

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=292439=292438=292439=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Jan 18 15:15:18 2017
@@ -1222,7 +1222,6 @@ private:
 
   void EmitDeclContext(const DeclContext *DC);
   void EmitLinkageSpec(const LinkageSpecDecl *D);
-  void CompleteDIClassType(const CXXMethodDecl* D);
 
   /// \brief Emit the function that initializes C++ thread_local variables.
   void EmitCXXThreadLocalInitFunc();


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


[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-18 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: clang/test/CodeGenCXX/type-metadata-thinlto.cpp:2
+// RUN: %clang_cc1 -flto=thin -triple x86_64-unknown-linux -fvisibility hidden 
-emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+

pcc wrote:
> mehdi_amini wrote:
> > tejohnson wrote:
> > > Is it the case that now we will always split the module with this change? 
> > > Should that only be done under CFI options?
> > Devirtualization may happen whenever you have a hidden virtual table IIUC, 
> > independently of CFI.
> To be more precise: we normally add type metadata in LTO mode when the class 
> has hidden visibility. See: http://clang.llvm.org/docs/LTOVisibility.html
> 
> That doesn't necessarily imply devirtualization, which is controlled by the 
> flag `-fwhole-program-vtables`.
So with hidden visibility but without CFI or -fwhole-program-vtables, do we 
split the module? What's the purpose?


https://reviews.llvm.org/D28843



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


[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM

2017-01-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D28820#649770, @efriedma wrote:

> > There would be a big performance penalty for ISRs with callees that don't 
> > use VFP regs.
>
> Sacrificing correctness for the sake of performance seems like a bad idea...


I don't quite see it that way, but I understand where you're coming from.

> especially given that the optimizer can insert calls to memcpy where they 
> didn't originally exist in the source.

That, however, is the nail in the coffin of my argument :)


https://reviews.llvm.org/D28820



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


[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-18 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:694
+else
+  PerModulePasses.add(
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));

tejohnson wrote:
> Can we transform other callers of createBitcodeWriterPass with 
> EmitSummaryIndex = true or EmitModuleHash = true to instead call 
> createWriteThinLTOBitcodePass as you did here, and then remove those 
> parameters from createBitcodeWriterPass?
http://llvm-cs.pcc.me.uk/lib/Bitcode/Writer/BitcodeWriterPass.cpp/rcreateBitcodeWriterPass

The only other caller like that is in opt. I think that if we change the "under 
the hood" parts of opt we should change it to not use a pass at all (c.f. our 
earlier discussion on D27324), then remove those parameters.



Comment at: clang/test/CodeGenCXX/type-metadata-thinlto.cpp:2
+// RUN: %clang_cc1 -flto=thin -triple x86_64-unknown-linux -fvisibility hidden 
-emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+

mehdi_amini wrote:
> tejohnson wrote:
> > Is it the case that now we will always split the module with this change? 
> > Should that only be done under CFI options?
> Devirtualization may happen whenever you have a hidden virtual table IIUC, 
> independently of CFI.
To be more precise: we normally add type metadata in LTO mode when the class 
has hidden visibility. See: http://clang.llvm.org/docs/LTOVisibility.html

That doesn't necessarily imply devirtualization, which is controlled by the 
flag `-fwhole-program-vtables`.


https://reviews.llvm.org/D28843



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


[PATCH] D28781: [OpenMP] Support for the if-clause on the combined directive 'target parallel'.

2017-01-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292437: [OpenMP] Support for the if-clause on the combined 
directive 'target parallel'. (authored by arpith).

Changed prior to commit:
  https://reviews.llvm.org/D28781?vs=84816=84883#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28781

Files:
  cfe/trunk/include/clang/AST/OpenMPClause.h
  cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
  cfe/trunk/lib/AST/OpenMPClause.cpp
  cfe/trunk/lib/AST/StmtProfile.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
  cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
  cfe/trunk/test/OpenMP/target_parallel_if_codegen.cpp
  cfe/trunk/tools/libclang/CIndex.cpp

Index: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
===
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
@@ -26,7 +26,7 @@
 namespace {
 /// Lexical scope for OpenMP executable constructs, that handles correct codegen
 /// for captured expressions.
-class OMPLexicalScope final : public CodeGenFunction::LexicalScope {
+class OMPLexicalScope : public CodeGenFunction::LexicalScope {
   void emitPreInitStmt(CodeGenFunction , const OMPExecutableDirective ) {
 for (const auto *C : S.clauses()) {
   if (auto *CPI = OMPClauseWithPreInit::get(C)) {
@@ -54,10 +54,11 @@
 
 public:
   OMPLexicalScope(CodeGenFunction , const OMPExecutableDirective ,
-  bool AsInlined = false)
+  bool AsInlined = false, bool EmitPreInitStmt = true)
   : CodeGenFunction::LexicalScope(CGF, S.getSourceRange()),
 InlinedShareds(CGF) {
-emitPreInitStmt(CGF, S);
+if (EmitPreInitStmt)
+  emitPreInitStmt(CGF, S);
 if (AsInlined) {
   if (S.hasAssociatedStmt()) {
 auto *CS = cast(S.getAssociatedStmt());
@@ -81,6 +82,22 @@
   }
 };
 
+/// Lexical scope for OpenMP parallel construct, that handles correct codegen
+/// for captured expressions.
+class OMPParallelScope final : public OMPLexicalScope {
+  bool EmitPreInitStmt(const OMPExecutableDirective ) {
+OpenMPDirectiveKind Kind = S.getDirectiveKind();
+return !isOpenMPTargetExecutionDirective(Kind) &&
+   isOpenMPParallelDirective(Kind);
+  }
+
+public:
+  OMPParallelScope(CodeGenFunction , const OMPExecutableDirective )
+  : OMPLexicalScope(CGF, S,
+/*AsInlined=*/false,
+/*EmitPreInitStmt=*/EmitPreInitStmt(S)) {}
+};
+
 /// Private scope for OpenMP loop-based directives, that supports capturing
 /// of used expression from loop statement.
 class OMPLoopScope : public CodeGenFunction::RunCleanupsScope {
@@ -1237,7 +1254,7 @@
 }
   }
 
-  OMPLexicalScope Scope(CGF, S);
+  OMPParallelScope Scope(CGF, S);
   llvm::SmallVector CapturedVars;
   CGF.GenerateOpenMPCapturedVars(*CS, CapturedVars);
   CGF.CGM.getOpenMPRuntime().emitParallelCall(CGF, S.getLocStart(), OutlinedFn,
@@ -3409,17 +3426,17 @@
   CodeGenModule  = CGF.CGM;
   const CapturedStmt  = *cast(S.getAssociatedStmt());
 
-  llvm::SmallVector CapturedVars;
-  CGF.GenerateOpenMPCapturedVars(CS, CapturedVars);
-
   llvm::Function *Fn = nullptr;
   llvm::Constant *FnID = nullptr;
 
-  // Check if we have any if clause associated with the directive.
   const Expr *IfCond = nullptr;
-
-  if (auto *C = S.getSingleClause()) {
-IfCond = C->getCondition();
+  // Check for the at most one if clause associated with the target region.
+  for (const auto *C : S.getClausesOfKind()) {
+if (C->getNameModifier() == OMPD_unknown ||
+C->getNameModifier() == OMPD_target) {
+  IfCond = C->getCondition();
+  break;
+}
   }
 
   // Check if we have any device clause associated with the directive.
@@ -3456,6 +3473,8 @@
   CGM.getOpenMPRuntime().emitTargetOutlinedFunction(S, ParentName, Fn, FnID,
 IsOffloadEntry, CodeGen);
   OMPLexicalScope Scope(CGF, S);
+  llvm::SmallVector CapturedVars;
+  CGF.GenerateOpenMPCapturedVars(CS, CapturedVars);
   CGM.getOpenMPRuntime().emitTargetCall(CGF, S, Fn, FnID, IfCond, Device,
 CapturedVars);
 }
Index: cfe/trunk/lib/AST/StmtProfile.cpp
===
--- cfe/trunk/lib/AST/StmtProfile.cpp
+++ cfe/trunk/lib/AST/StmtProfile.cpp
@@ -283,6 +283,7 @@
 }
 
 void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) {
+  VistOMPClauseWithPreInit(C);
   if (C->getCondition())
 Profiler->VisitStmt(C->getCondition());
 }
Index: cfe/trunk/lib/AST/OpenMPClause.cpp
===
--- cfe/trunk/lib/AST/OpenMPClause.cpp
+++ cfe/trunk/lib/AST/OpenMPClause.cpp
@@ -48,9 +48,10 @@
 return static_cast(C);
   case OMPC_linear:
 return static_cast(C);
+  case OMPC_if:
+return static_cast(C);
   

r292435 - [Modules] Correct test comment from obsolete earlier version of code. NFC

2017-01-18 Thread Graydon Hoare via cfe-commits
Author: graydon
Date: Wed Jan 18 14:34:44 2017
New Revision: 292435

URL: http://llvm.org/viewvc/llvm-project?rev=292435=rev
Log:
[Modules] Correct test comment from obsolete earlier version of code. NFC

Summary:
Code committed in rL290219 went through a few iterations; test wound up with
stale comment.

Reviewers: doug.gregor, manmanren

Reviewed By: manmanren

Subscribers: cfe-commits

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

Modified:
cfe/trunk/test/Modules/implicit-private-with-different-name.m

Modified: cfe/trunk/test/Modules/implicit-private-with-different-name.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/implicit-private-with-different-name.m?rev=292435=292434=292435=diff
==
--- cfe/trunk/test/Modules/implicit-private-with-different-name.m (original)
+++ cfe/trunk/test/Modules/implicit-private-with-different-name.m Wed Jan 18 
14:34:44 2017
@@ -3,7 +3,7 @@
 // Build PCH using A, with adjacent private module APrivate, which winds up 
being implicitly referenced
 // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name 
-emit-pch -o %t-A.pch %s
 
-// Use the PCH with no explicit way to resolve PrivateA, still pick it up 
through MODULE_DIRECTORY reference in PCH control block
+// Use the PCH with no explicit way to resolve APrivate, still pick it up by 
automatic second-chance search for "A" with "Private" appended
 // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name 
-include-pch %t-A.pch %s -fsyntax-only
 
 // Check the fixit


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


r292437 - [OpenMP] Support for the if-clause on the combined directive 'target parallel'.

2017-01-18 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Wed Jan 18 14:40:48 2017
New Revision: 292437

URL: http://llvm.org/viewvc/llvm-project?rev=292437=rev
Log:
[OpenMP] Support for the if-clause on the combined directive 'target parallel'.

The if-clause on the combined directive potentially applies to both the
'target' and the 'parallel' regions.  Codegen'ing the if-clause on the
combined directive requires additional support because the expression in
the clause must be captured by the 'target' capture statement but not
the 'parallel' capture statement.  Note that this situation arises for
other clauses such as num_threads.

The OMPIfClause class inherits OMPClauseWithPreInit to support capturing
of expressions in the clause.  A member CaptureRegion is added to
OMPClauseWithPreInit to indicate which captured statement (in this case
'target' but not 'parallel') captures these expressions.

To ensure correct codegen of captured expressions in the presence of
combined 'target' directives, OMPParallelScope was added to 'parallel'
codegen.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28781

Added:
cfe/trunk/test/OpenMP/target_parallel_if_codegen.cpp
Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=292437=292436=292437=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Wed Jan 18 14:40:48 2017
@@ -76,10 +76,17 @@ class OMPClauseWithPreInit {
   friend class OMPClauseReader;
   /// Pre-initialization statement for the clause.
   Stmt *PreInit;
+  /// Region that captures the associated stmt.
+  OpenMPDirectiveKind CaptureRegion;
+
 protected:
   /// Set pre-initialization statement for the clause.
-  void setPreInitStmt(Stmt *S) { PreInit = S; }
-  OMPClauseWithPreInit(const OMPClause *This) : PreInit(nullptr) {
+  void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion = OMPD_unknown) {
+PreInit = S;
+CaptureRegion = ThisRegion;
+  }
+  OMPClauseWithPreInit(const OMPClause *This)
+  : PreInit(nullptr), CaptureRegion(OMPD_unknown) {
 assert(get(This) && "get is not tuned for pre-init.");
   }
 
@@ -88,6 +95,8 @@ public:
   const Stmt *getPreInitStmt() const { return PreInit; }
   /// Get pre-initialization statement for the clause.
   Stmt *getPreInitStmt() { return PreInit; }
+  /// Get capture region for the stmt in the clause.
+  OpenMPDirectiveKind getCaptureRegion() { return CaptureRegion; }
   static OMPClauseWithPreInit *get(OMPClause *C);
   static const OMPClauseWithPreInit *get(const OMPClause *C);
 };
@@ -194,7 +203,7 @@ public:
 /// In this example directive '#pragma omp parallel' has simple 'if' clause 
with
 /// condition 'a > 5' and directive name modifier 'parallel'.
 ///
-class OMPIfClause : public OMPClause {
+class OMPIfClause : public OMPClause, public OMPClauseWithPreInit {
   friend class OMPClauseReader;
   /// \brief Location of '('.
   SourceLocation LParenLoc;
@@ -225,26 +234,31 @@ public:
   ///
   /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause.
   /// \param Cond Condition of the clause.
+  /// \param HelperCond Helper condition for the clause.
+  /// \param CaptureRegion Innermost OpenMP region where expressions in this
+  /// clause must be captured.
   /// \param StartLoc Starting location of the clause.
   /// \param LParenLoc Location of '('.
   /// \param NameModifierLoc Location of directive name modifier.
   /// \param ColonLoc [OpenMP 4.1] Location of ':'.
   /// \param EndLoc Ending location of the clause.
   ///
-  OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond,
-  SourceLocation StartLoc, SourceLocation LParenLoc,
-  SourceLocation NameModifierLoc, SourceLocation ColonLoc,
-  SourceLocation EndLoc)
-  : OMPClause(OMPC_if, StartLoc, EndLoc), LParenLoc(LParenLoc),
-Condition(Cond), ColonLoc(ColonLoc), NameModifier(NameModifier),
-NameModifierLoc(NameModifierLoc) {}
+  OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond,
+  OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
+  SourceLocation LParenLoc, SourceLocation NameModifierLoc,
+  SourceLocation ColonLoc, SourceLocation EndLoc)
+  : OMPClause(OMPC_if, StartLoc, EndLoc), OMPClauseWithPreInit(this),
+LParenLoc(LParenLoc), Condition(Cond), ColonLoc(ColonLoc),
+NameModifier(NameModifier), 

[PATCH] D28779: [ASTReader] Add a DeserializationListener callback for IMPORTED_MODULES

2017-01-18 Thread Graydon Hoare via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292436: [ASTReader] Add a DeserializationListener callback 
for IMPORTED_MODULES (authored by graydon).

Changed prior to commit:
  https://reviews.llvm.org/D28779?vs=84594=84881#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28779

Files:
  cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h
  cfe/trunk/lib/Serialization/ASTReader.cpp


Index: cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h
===
--- cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h
+++ cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h
@@ -26,6 +26,7 @@
 class MacroDefinitionRecord;
 class MacroInfo;
 class Module;
+class SourceLocation;
 
 class ASTDeserializationListener {
 public:
@@ -52,6 +53,9 @@
MacroDefinitionRecord *MD) {}
   /// \brief A module definition was read from the AST file.
   virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) {}
+  /// \brief A module import was read from the AST file.
+  virtual void ModuleImportRead(serialization::SubmoduleID ID,
+SourceLocation ImportLoc) {}
 };
 }
 
Index: cfe/trunk/lib/Serialization/ASTReader.cpp
===
--- cfe/trunk/lib/Serialization/ASTReader.cpp
+++ cfe/trunk/lib/Serialization/ASTReader.cpp
@@ -3251,8 +3251,11 @@
 for (unsigned I = 0, N = Record.size(); I != N; /**/) {
   unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
   SourceLocation Loc = ReadSourceLocation(F, Record, I);
-  if (GlobalID)
+  if (GlobalID) {
 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
+if (DeserializationListener)
+  DeserializationListener->ModuleImportRead(GlobalID, Loc);
+  }
 }
   }
   break;


Index: cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h
===
--- cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h
+++ cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h
@@ -26,6 +26,7 @@
 class MacroDefinitionRecord;
 class MacroInfo;
 class Module;
+class SourceLocation;
 
 class ASTDeserializationListener {
 public:
@@ -52,6 +53,9 @@
MacroDefinitionRecord *MD) {}
   /// \brief A module definition was read from the AST file.
   virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) {}
+  /// \brief A module import was read from the AST file.
+  virtual void ModuleImportRead(serialization::SubmoduleID ID,
+SourceLocation ImportLoc) {}
 };
 }
 
Index: cfe/trunk/lib/Serialization/ASTReader.cpp
===
--- cfe/trunk/lib/Serialization/ASTReader.cpp
+++ cfe/trunk/lib/Serialization/ASTReader.cpp
@@ -3251,8 +3251,11 @@
 for (unsigned I = 0, N = Record.size(); I != N; /**/) {
   unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
   SourceLocation Loc = ReadSourceLocation(F, Record, I);
-  if (GlobalID)
+  if (GlobalID) {
 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
+if (DeserializationListener)
+  DeserializationListener->ModuleImportRead(GlobalID, Loc);
+  }
 }
   }
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292436 - [ASTReader] Add a DeserializationListener callback for IMPORTED_MODULES

2017-01-18 Thread Graydon Hoare via cfe-commits
Author: graydon
Date: Wed Jan 18 14:36:59 2017
New Revision: 292436

URL: http://llvm.org/viewvc/llvm-project?rev=292436=rev
Log:
[ASTReader] Add a DeserializationListener callback for IMPORTED_MODULES

Summary:
Add a callback from ASTReader to DeserializationListener when the former
reads an IMPORTED_MODULES block. This supports Swift in using PCH for
bridging headers.

Reviewers: doug.gregor, manmanren, bruno

Reviewed By: manmanren

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h?rev=292436=292435=292436=diff
==
--- cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h 
(original)
+++ cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h Wed Jan 
18 14:36:59 2017
@@ -26,6 +26,7 @@ class QualType;
 class MacroDefinitionRecord;
 class MacroInfo;
 class Module;
+class SourceLocation;
 
 class ASTDeserializationListener {
 public:
@@ -52,6 +53,9 @@ public:
MacroDefinitionRecord *MD) {}
   /// \brief A module definition was read from the AST file.
   virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) {}
+  /// \brief A module import was read from the AST file.
+  virtual void ModuleImportRead(serialization::SubmoduleID ID,
+SourceLocation ImportLoc) {}
 };
 }
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=292436=292435=292436=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Jan 18 14:36:59 2017
@@ -3251,8 +3251,11 @@ ASTReader::ReadASTBlock(ModuleFile , u
 for (unsigned I = 0, N = Record.size(); I != N; /**/) {
   unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
   SourceLocation Loc = ReadSourceLocation(F, Record, I);
-  if (GlobalID)
+  if (GlobalID) {
 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
+if (DeserializationListener)
+  DeserializationListener->ModuleImportRead(GlobalID, Loc);
+  }
 }
   }
   break;


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


[PATCH] D28790: [Modules] Correct test comment from obsolete earlier version of code. NFC

2017-01-18 Thread Graydon Hoare via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292435: [Modules] Correct test comment from obsolete earlier 
version of code. NFC (authored by graydon).

Changed prior to commit:
  https://reviews.llvm.org/D28790?vs=84616=84879#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28790

Files:
  cfe/trunk/test/Modules/implicit-private-with-different-name.m


Index: cfe/trunk/test/Modules/implicit-private-with-different-name.m
===
--- cfe/trunk/test/Modules/implicit-private-with-different-name.m
+++ cfe/trunk/test/Modules/implicit-private-with-different-name.m
@@ -3,7 +3,7 @@
 // Build PCH using A, with adjacent private module APrivate, which winds up 
being implicitly referenced
 // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name 
-emit-pch -o %t-A.pch %s
 
-// Use the PCH with no explicit way to resolve PrivateA, still pick it up 
through MODULE_DIRECTORY reference in PCH control block
+// Use the PCH with no explicit way to resolve APrivate, still pick it up by 
automatic second-chance search for "A" with "Private" appended
 // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name 
-include-pch %t-A.pch %s -fsyntax-only
 
 // Check the fixit


Index: cfe/trunk/test/Modules/implicit-private-with-different-name.m
===
--- cfe/trunk/test/Modules/implicit-private-with-different-name.m
+++ cfe/trunk/test/Modules/implicit-private-with-different-name.m
@@ -3,7 +3,7 @@
 // Build PCH using A, with adjacent private module APrivate, which winds up being implicitly referenced
 // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -emit-pch -o %t-A.pch %s
 
-// Use the PCH with no explicit way to resolve PrivateA, still pick it up through MODULE_DIRECTORY reference in PCH control block
+// Use the PCH with no explicit way to resolve APrivate, still pick it up by automatic second-chance search for "A" with "Private" appended
 // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -include-pch %t-A.pch %s -fsyntax-only
 
 // Check the fixit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM

2017-01-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> There would be a big performance penalty for ISRs with callees that don't use 
> VFP regs.

Sacrificing correctness for the sake of performance seems like a bad idea... 
especially given that the optimizer can insert calls to memcpy where they 
didn't originally exist in the source.


https://reviews.llvm.org/D28820



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


[libcxx] r292434 - [libcxx] [test] Fix comment typos, strip trailing whitespace.

2017-01-18 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Wed Jan 18 14:10:25 2017
New Revision: 292434

URL: http://llvm.org/viewvc/llvm-project?rev=292434=rev
Log:
[libcxx] [test] Fix comment typos, strip trailing whitespace.

No functional change, no code review.

Modified:
libcxx/trunk/test/std/containers/associative/map/incomplete_type.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/incomplete_type.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/incomplete_type.pass.cpp
libcxx/trunk/test/std/containers/associative/set/incomplete_type.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/front_back.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/indexing.pass.cpp
libcxx/trunk/test/std/containers/sequences/list/incomplete_type.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.map/incomplete_type.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/incomplete.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multiset/incomplete.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/incomplete.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.append.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp
libcxx/trunk/test/std/experimental/filesystem/class.path/synop.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp

libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp

libcxx/trunk/test/std/experimental/string.view/string.view.access/at.pass.cpp

libcxx/trunk/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
libcxx/trunk/test/std/strings/string.view/string.view.access/at.pass.cpp

libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp

libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp
libcxx/trunk/test/support/constexpr_char_traits.hpp
libcxx/trunk/test/support/container_test_types.h
libcxx/trunk/test/support/controlled_allocators.hpp
libcxx/trunk/test/support/filesystem_test_helper.hpp
libcxx/trunk/test/support/platform_support.h
libcxx/trunk/test/support/test_memory_resource.hpp

Modified: 
libcxx/trunk/test/std/containers/associative/map/incomplete_type.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/incomplete_type.pass.cpp?rev=292434=292433=292434=diff
==
--- libcxx/trunk/test/std/containers/associative/map/incomplete_type.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/associative/map/incomplete_type.pass.cpp 
Wed Jan 18 14:10:25 2017
@@ -9,7 +9,7 @@
 
 // 
 
-// Check that std::map and it's iterators can be instantiated with 

[libcxx] r292432 - [libcxx] [test] Fix MSVC warnings C4127 and C6326 about constants.

2017-01-18 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Wed Jan 18 14:09:56 2017
New Revision: 292432

URL: http://llvm.org/viewvc/llvm-project?rev=292432=rev
Log:
[libcxx] [test] Fix MSVC warnings C4127 and C6326 about constants.

MSVC has compiler warnings C4127 "conditional expression is constant" (enabled
by /W4) and C6326 "Potential comparison of a constant with another constant"
(enabled by /analyze). They're potentially useful, although they're slightly
annoying to library devs who know what they're doing. In the latest version of
the compiler, C4127 is suppressed when the compiler sees simple tests like
"if (name_of_thing)", so extracting comparison expressions into named
constants is a workaround. At the same time, using std::integral_constant
avoids C6326, which doesn't look at template arguments.

test/std/containers/sequences/vector.bool/emplace.pass.cpp
Replace 1 == 1 with true, which is the same as far as the library is concerned.

Fixes D28837.

Modified:
libcxx/trunk/test/std/containers/sequences/vector.bool/emplace.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
libcxx/trunk/test/std/utilities/function.objects/unord.hash/enum.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/all.pass.cpp
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/any.pass.cpp

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/index.pass.cpp

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/none.pass.cpp

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/sequences/vector.bool/emplace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/emplace.pass.cpp?rev=292432=292431=292432=diff
==
--- libcxx/trunk/test/std/containers/sequences/vector.bool/emplace.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/emplace.pass.cpp Wed 
Jan 18 14:09:56 2017
@@ -34,7 +34,7 @@ int main()
 assert(c.front() == false);
 assert(c.back() == true);
 
-i = c.emplace(c.cbegin()+1, 1 == 1);
+i = c.emplace(c.cbegin()+1, true);
 assert(i == c.begin()+1);
 assert(c.size() == 3);
 assert(c.front() == false);
@@ -56,7 +56,7 @@ int main()
 assert(c.front() == false);
 assert(c.back() == true);
 
-i = c.emplace(c.cbegin()+1, 1 == 1);
+i = c.emplace(c.cbegin()+1, true);
 assert(i == c.begin()+1);
 assert(c.size() == 3);
 assert(c.size() == 3);

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp?rev=292432=292431=292432=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
 Wed Jan 18 14:09:56 2017
@@ -23,6 +23,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -66,11 +67,15 @@ int main()
 test_octal("17");
 test_octal< int64_t>("17");
 test_octal("17");
-if (sizeof(long) == sizeof(int64_t)) {
+
+const bool long_is_64 = std::integral_constant::value; // avoid compiler warnings
+const bool long_long_is_64 = std::integral_constant::value; // avoid compiler warnings
+
+if (long_is_64) {
 test_octal< unsigned long>("17");
 test_octal<  long>("17");
 }
-if (sizeof(long long) == sizeof(int64_t)) {
+if (long_long_is_64) {
 test_octal< unsigned long long>("17");
 test_octal<  long long>("17");
 }
@@ -81,11 +86,11 @@ int main()
 test_dec< int32_t>(  "-1");
 test_dec("18446744073709551615");
 test_dec< int64_t>(  "-1");
-if (sizeof(long) == sizeof(int64_t)) {
+if (long_is_64) {
 

[PATCH] D28867: [Profile] Warn about out-of-date profiles only when there are mismatches

2017-01-18 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Ah ok, so it sounds like a better approach would be to split the missing record 
message into a separate off-by-default warning. I don't have the time to update 
this diff this week, but will shoot for the next.


https://reviews.llvm.org/D28867



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


[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM

2017-01-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D28820#649738, @jroelofs wrote:

> In https://reviews.llvm.org/D28820#649726, @efriedma wrote:
>
> > Why can't the compiler handle this case itself transparently?  According to 
> > your description, the interrupt calling convention is different from the 
> > normal hard-float AAPCS calling convention: the VFP registers are all 
> > callee-save.  The compiler knows this; it should be able to insert the 
> > appropriate spills itself.
>
>
> There would be a big performance penalty for ISRs with callees that don't use 
> VFP regs.


Then again, it probably makes sense to add all the VFP regs to the ISR calling 
convention's CalleeSavedRegs, as the ISR /should/ be spilling them if it uses 
them.


https://reviews.llvm.org/D28820



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


[PATCH] D27872: [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)

2017-01-18 Thread Tim Shen via Phabricator via cfe-commits
timshen marked an inline comment as done.
timshen added a comment.

Friendly ping. :)

We still have internal test failures that this patch (and the next one) fixes, 
and I think this is the last "hard to review" patch in the APFloat refactoring.


https://reviews.llvm.org/D27872



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


[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM

2017-01-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D28820#649726, @efriedma wrote:

> Why can't the compiler handle this case itself transparently?  According to 
> your description, the interrupt calling convention is different from the 
> normal hard-float AAPCS calling convention: the VFP registers are all 
> callee-save.  The compiler knows this; it should be able to insert the 
> appropriate spills itself.


There would be a big performance penalty for ISRs with callees that don't use 
VFP regs.


https://reviews.llvm.org/D28820



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


[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.

2017-01-18 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: docs/UsersManual.rst:2065
+
+ $ clang -cc1 -triple spir64-unknown-unknown -cl-ext=-cl_khr_fp64 test.cl
+

pekka.jaaskelainen wrote:
> Anastasia wrote:
> > pekka.jaaskelainen wrote:
> > > Is this correct? I cannot make it work:
> > > 
> > > ```
> > > ~/local/stow/llvm-4.0-unpatched-Debug/bin/clang -Xclang 
> > > -finclude-default-header -emit-llvm -cc1 -triple spir64-unknown-unknown 
> > > kernel/test_halfs.cl -c -S -o -
> > > clang-4.0: error: unknown argument: '-cc1'
> > > clang-4.0: error: unknown argument: '-triple'
> > > clang-4.0: error: no such file or directory: 'spir64-unknown-unknown'
> > > ```
> > > 
> > > -target works instead. (But reveals another issue, there's no printf() 
> > > declaration, should I file a bug?)
> > > 
> > > ```
> > > ~/local/stow/llvm-4.0-unpatched-Debug/bin/clang -Xclang 
> > > -finclude-default-header -emit-llvm -target spir64-unknown-unknown 
> > > kernel/test_halfs.cl -c -S -o -
> > > kernel/test_halfs.cl:10:9: warning: implicit declaration of function 
> > > 'printf' is invalid in C99 [-Wimplicit-function-declaration]
> > > printf("max(a,b)[0] type=uint2 a=0x15b348c9 b=0xf88e7d07 
> > > want=0xf88e7d07 got=%x\n", max_[0]);
> > > ^
> > > kernel/test_halfs.cl:10:9: error: function with no prototype cannot use 
> > > the spir_function calling convention
> > > 1 warning and 1 error generated.
> > > ```
> > > 
> > > With 3.9 that kernel which calls printf() passes:
> > > ```
> > > /local/stow/llvm-3.9-debug/bin/clang -Xclang -finclude-default-header 
> > > -emit-llvm -target spir64-unknown-unknown kernel/test_halfs.cl -c -S -o -
> > > ; ModuleID = 'kernel/test_halfs.cl'
> > > source_filename = "kernel/test_halfs.cl"
> > > target datalayout = 
> > > "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
> > > target triple = "spir64-unknown-unknown"
> > > 
> > > ```
> > > 
> > > 
> > > 
> > It should be -triple with -cc1 and -target without.
> > 
> >   clang -cc1 -triple ...
> >   clang -target ...
> > 
> > We have disabled the C99 builtin functions as per spec v1.2 s6.9.f, but the 
> > OpenCL builtins should be available via the header now.
> > 
> > As I can see declaration of printf is in the header under CL1.2 and higher.
> > 
> > Could you try this command instead:
> >   clang -std=CL1.2 test.cl -Xclang -finclude-default-header
> > 
> Yes, std=CL1.2 helped, good point! But -cc1 -triple doesn't work (unknown 
> argument). However -target works. This is with Clang 4.0.
I think you pass something before -cc1. -cc1 option must be the first argument 
to the clang executable, otherwise it won't work.



https://reviews.llvm.org/D28080



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


[PATCH] D28867: [Profile] Warn about out-of-date profiles only when there are mismatches

2017-01-18 Thread Rong Xu via Phabricator via cfe-commits
xur added a comment.

This change gonna hide the missing profile for a function permanently if there 
is no mismatch. Like, if a user adds a new function without changing existing 
functions, he will never get a warning if using the old profiles.

In LLVM IR level PGO, we also find the missing profile warning sometime too 
verbose. We turn missing profile off by default, but not depending on mismatch. 
I think that is a better method.


https://reviews.llvm.org/D28867



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


[PATCH] D28755: [OpenMP] Codegen for the 'target parallel' directive on the NVPTX device.

2017-01-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292428: [OpenMP] Codegen for the 'target parallel' directive 
on the NVPTX device. (authored by arpith).

Changed prior to commit:
  https://reviews.llvm.org/D28755?vs=84512=84870#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28755

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
  cfe/trunk/test/OpenMP/nvptx_target_parallel_codegen.cpp

Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -26,6 +26,11 @@
   OMPRTL_NVPTX__kmpc_kernel_init,
   /// \brief Call to void __kmpc_kernel_deinit();
   OMPRTL_NVPTX__kmpc_kernel_deinit,
+  /// \brief Call to void __kmpc_spmd_kernel_init(kmp_int32 thread_limit,
+  /// short RequiresOMPRuntime, short RequiresDataSharing);
+  OMPRTL_NVPTX__kmpc_spmd_kernel_init,
+  /// \brief Call to void __kmpc_spmd_kernel_deinit();
+  OMPRTL_NVPTX__kmpc_spmd_kernel_deinit,
   /// \brief Call to void __kmpc_kernel_prepare_parallel(void
   /// *outlined_function);
   OMPRTL_NVPTX__kmpc_kernel_prepare_parallel,
@@ -76,6 +81,25 @@
 CGF.EmitRuntimeCall(ExitCallee, ExitArgs);
   }
 };
+
+// A class to track the execution mode when codegening directives within
+// a target region. The appropriate mode (generic/spmd) is set on entry
+// to the target region and used by containing directives such as 'parallel'
+// to emit optimized code.
+class ExecutionModeRAII {
+private:
+  CGOpenMPRuntimeNVPTX::ExecutionMode SavedMode;
+  CGOpenMPRuntimeNVPTX::ExecutionMode 
+
+public:
+  ExecutionModeRAII(CGOpenMPRuntimeNVPTX::ExecutionMode ,
+CGOpenMPRuntimeNVPTX::ExecutionMode NewMode)
+  : Mode(Mode) {
+SavedMode = Mode;
+Mode = NewMode;
+  }
+  ~ExecutionModeRAII() { Mode = SavedMode; }
+};
 } // anonymous namespace
 
 /// Get the GPU warp size.
@@ -116,12 +140,17 @@
 static void syncCTAThreads(CodeGenFunction ) { getNVPTXCTABarrier(CGF); }
 
 /// Get the value of the thread_limit clause in the teams directive.
-/// The runtime encodes thread_limit in the launch parameter, always starting
-/// thread_limit+warpSize threads per team.
-static llvm::Value *getThreadLimit(CodeGenFunction ) {
+/// For the 'generic' execution mode, the runtime encodes thread_limit in
+/// the launch parameters, always starting thread_limit+warpSize threads per
+/// CTA. The threads in the last warp are reserved for master execution.
+/// For the 'spmd' execution mode, all threads in a CTA are part of the team.
+static llvm::Value *getThreadLimit(CodeGenFunction ,
+   bool IsInSpmdExecutionMode = false) {
   CGBuilderTy  = CGF.Builder;
-  return Bld.CreateSub(getNVPTXNumThreads(CGF), getNVPTXWarpSize(CGF),
-   "thread_limit");
+  return IsInSpmdExecutionMode
+ ? getNVPTXNumThreads(CGF)
+ : Bld.CreateSub(getNVPTXNumThreads(CGF), getNVPTXWarpSize(CGF),
+ "thread_limit");
 }
 
 /// Get the thread id of the OMP master thread.
@@ -159,12 +188,33 @@
   CGM.SetInternalFunctionAttributes(/*D=*/nullptr, WorkerFn, *CGFI);
 }
 
+bool CGOpenMPRuntimeNVPTX::isInSpmdExecutionMode() const {
+  return CurrentExecutionMode == CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd;
+}
+
+static CGOpenMPRuntimeNVPTX::ExecutionMode
+getExecutionModeForDirective(CodeGenModule ,
+ const OMPExecutableDirective ) {
+  OpenMPDirectiveKind DirectiveKind = D.getDirectiveKind();
+  switch (DirectiveKind) {
+  case OMPD_target:
+return CGOpenMPRuntimeNVPTX::ExecutionMode::Generic;
+  case OMPD_target_parallel:
+return CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd;
+  default:
+llvm_unreachable("Unsupported directive on NVPTX device.");
+  }
+  llvm_unreachable("Unsupported directive on NVPTX device.");
+}
+
 void CGOpenMPRuntimeNVPTX::emitGenericKernel(const OMPExecutableDirective ,
  StringRef ParentName,
  llvm::Function *,
  llvm::Constant *,
  bool IsOffloadEntry,
  const RegionCodeGenTy ) {
+  ExecutionModeRAII ModeRAII(CurrentExecutionMode,
+ CGOpenMPRuntimeNVPTX::ExecutionMode::Generic);
   EntryFunctionState EST;
   WorkerFunctionState WST(CGM);
   Work.clear();
@@ -252,6 +302,94 @@
   EST.ExitBB = nullptr;
 }
 
+void CGOpenMPRuntimeNVPTX::emitSpmdKernel(const OMPExecutableDirective ,
+  StringRef ParentName,
+  llvm::Function *,
+  llvm::Constant *,
+ 

r292428 - [OpenMP] Codegen for the 'target parallel' directive on the NVPTX device.

2017-01-18 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Wed Jan 18 13:35:00 2017
New Revision: 292428

URL: http://llvm.org/viewvc/llvm-project?rev=292428=rev
Log:
[OpenMP] Codegen for the 'target parallel' directive on the NVPTX device.

This patch adds codegen for the 'target parallel' directive on the NVPTX
device.  We term offload OpenMP directives such as 'target parallel' and
'target teams distribute parallel for' as SPMD constructs.  SPMD constructs,
in contrast to Generic ones like the plain 'target', can never contain
a serial region.

SPMD constructs can be handled more efficiently on the GPU and do not
require the Warp Loop of the Generic codegen scheme. This patch adds
SPMD codegen support for 'target parallel' on the NVPTX device and can
be reused for other SPMD constructs.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28755

Added:
cfe/trunk/test/OpenMP/nvptx_target_parallel_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=292428=292427=292428=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Wed Jan 18 13:35:00 2017
@@ -26,6 +26,11 @@ enum OpenMPRTLFunctionNVPTX {
   OMPRTL_NVPTX__kmpc_kernel_init,
   /// \brief Call to void __kmpc_kernel_deinit();
   OMPRTL_NVPTX__kmpc_kernel_deinit,
+  /// \brief Call to void __kmpc_spmd_kernel_init(kmp_int32 thread_limit,
+  /// short RequiresOMPRuntime, short RequiresDataSharing);
+  OMPRTL_NVPTX__kmpc_spmd_kernel_init,
+  /// \brief Call to void __kmpc_spmd_kernel_deinit();
+  OMPRTL_NVPTX__kmpc_spmd_kernel_deinit,
   /// \brief Call to void __kmpc_kernel_prepare_parallel(void
   /// *outlined_function);
   OMPRTL_NVPTX__kmpc_kernel_prepare_parallel,
@@ -76,6 +81,25 @@ public:
 CGF.EmitRuntimeCall(ExitCallee, ExitArgs);
   }
 };
+
+// A class to track the execution mode when codegening directives within
+// a target region. The appropriate mode (generic/spmd) is set on entry
+// to the target region and used by containing directives such as 'parallel'
+// to emit optimized code.
+class ExecutionModeRAII {
+private:
+  CGOpenMPRuntimeNVPTX::ExecutionMode SavedMode;
+  CGOpenMPRuntimeNVPTX::ExecutionMode 
+
+public:
+  ExecutionModeRAII(CGOpenMPRuntimeNVPTX::ExecutionMode ,
+CGOpenMPRuntimeNVPTX::ExecutionMode NewMode)
+  : Mode(Mode) {
+SavedMode = Mode;
+Mode = NewMode;
+  }
+  ~ExecutionModeRAII() { Mode = SavedMode; }
+};
 } // anonymous namespace
 
 /// Get the GPU warp size.
@@ -116,12 +140,17 @@ static void getNVPTXCTABarrier(CodeGenFu
 static void syncCTAThreads(CodeGenFunction ) { getNVPTXCTABarrier(CGF); }
 
 /// Get the value of the thread_limit clause in the teams directive.
-/// The runtime encodes thread_limit in the launch parameter, always starting
-/// thread_limit+warpSize threads per team.
-static llvm::Value *getThreadLimit(CodeGenFunction ) {
+/// For the 'generic' execution mode, the runtime encodes thread_limit in
+/// the launch parameters, always starting thread_limit+warpSize threads per
+/// CTA. The threads in the last warp are reserved for master execution.
+/// For the 'spmd' execution mode, all threads in a CTA are part of the team.
+static llvm::Value *getThreadLimit(CodeGenFunction ,
+   bool IsInSpmdExecutionMode = false) {
   CGBuilderTy  = CGF.Builder;
-  return Bld.CreateSub(getNVPTXNumThreads(CGF), getNVPTXWarpSize(CGF),
-   "thread_limit");
+  return IsInSpmdExecutionMode
+ ? getNVPTXNumThreads(CGF)
+ : Bld.CreateSub(getNVPTXNumThreads(CGF), getNVPTXWarpSize(CGF),
+ "thread_limit");
 }
 
 /// Get the thread id of the OMP master thread.
@@ -159,12 +188,33 @@ void CGOpenMPRuntimeNVPTX::WorkerFunctio
   CGM.SetInternalFunctionAttributes(/*D=*/nullptr, WorkerFn, *CGFI);
 }
 
+bool CGOpenMPRuntimeNVPTX::isInSpmdExecutionMode() const {
+  return CurrentExecutionMode == CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd;
+}
+
+static CGOpenMPRuntimeNVPTX::ExecutionMode
+getExecutionModeForDirective(CodeGenModule ,
+ const OMPExecutableDirective ) {
+  OpenMPDirectiveKind DirectiveKind = D.getDirectiveKind();
+  switch (DirectiveKind) {
+  case OMPD_target:
+return CGOpenMPRuntimeNVPTX::ExecutionMode::Generic;
+  case OMPD_target_parallel:
+return CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd;
+  default:
+llvm_unreachable("Unsupported directive on NVPTX device.");
+  }
+  llvm_unreachable("Unsupported directive on NVPTX device.");
+}
+
 void CGOpenMPRuntimeNVPTX::emitGenericKernel(const OMPExecutableDirective ,
   

[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM

2017-01-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Why can't the compiler handle this case itself transparently?  According to 
your description, the interrupt calling convention is different from the normal 
hard-float AAPCS calling convention: the VFP registers are all callee-save.  
The compiler knows this; it should be able to insert the appropriate spills 
itself.


https://reviews.llvm.org/D28820



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


[PATCH] D25213: Fix PR28181: Prevent operator overloading related assertion failure crash that happens in C only

2017-01-18 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: lib/Sema/SemaExpr.cpp:11523
 // being assigned to.
 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
+  if (getLangOpts().CPlusPlus &&

Looks like you can fold both conditions below into one and check 
`getLangOpts().CPlusPlus` only once


Repository:
  rL LLVM

https://reviews.llvm.org/D25213



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


r292426 - PR9551: Implement DR1004 (http://wg21.link/cwg1004).

2017-01-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan 18 13:19:22 2017
New Revision: 292426

URL: http://llvm.org/viewvc/llvm-project?rev=292426=rev
Log:
PR9551: Implement DR1004 (http://wg21.link/cwg1004).

This rule permits the injected-class-name of a class template to be used as
both a template type argument and a template template argument, with no extra
syntax required to disambiguate.

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/drs/dr10xx.cpp
cfe/trunk/test/CXX/temp/temp.res/temp.local/p1.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=292426=292425=292426=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Jan 18 13:19:22 2017
@@ -4350,6 +4350,9 @@ public:
   const TemplateSpecializationType *getInjectedTST() const {
 return cast(InjectedType.getTypePtr());
   }
+  TemplateName getTemplateName() const {
+return getInjectedTST()->getTemplateName();
+  }
 
   CXXRecordDecl *getDecl() const;
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=292426=292425=292426=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 18 13:19:22 2017
@@ -6114,12 +6114,17 @@ public:
   /// \param Converted Will receive the converted, canonicalized template
   /// arguments.
   ///
+  /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
+  /// contain the converted forms of the template arguments as written.
+  /// Otherwise, \p TemplateArgs will not be modified.
+  ///
   /// \returns true if an error occurred, false otherwise.
   bool CheckTemplateArgumentList(TemplateDecl *Template,
  SourceLocation TemplateLoc,
  TemplateArgumentListInfo ,
  bool PartialTemplateArgs,
-   SmallVectorImpl );
+ SmallVectorImpl ,
+ bool UpdateArgsWithConversions = true);
 
   bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
  TemplateArgumentLoc ,

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=292426=292425=292426=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Jan 18 13:19:22 2017
@@ -3657,6 +3657,39 @@ Sema::SubstDefaultTemplateArgumentIfAvai
 TempTempParm->getDefaultArgument().getTemplateNameLoc());
 }
 
+/// Convert a template-argument that we parsed as a type into a template, if
+/// possible. C++ permits injected-class-names to perform dual service as
+/// template template arguments and as template type arguments.
+static TemplateArgumentLoc convertTypeTemplateArgumentToTemplate(TypeLoc TLoc) 
{
+  // Extract and step over any surrounding nested-name-specifier.
+  NestedNameSpecifierLoc QualLoc;
+  if (auto ETLoc = TLoc.getAs()) {
+if (ETLoc.getTypePtr()->getKeyword() != ETK_None)
+  return TemplateArgumentLoc();
+
+QualLoc = ETLoc.getQualifierLoc();
+TLoc = ETLoc.getNamedTypeLoc();
+  }
+
+  // If this type was written as an injected-class-name, it can be used as a
+  // template template argument.
+  if (auto InjLoc = TLoc.getAs())
+return TemplateArgumentLoc(InjLoc.getTypePtr()->getTemplateName(),
+   QualLoc, InjLoc.getNameLoc());
+
+  // If this type was written as an injected-class-name, it may have been
+  // converted to a RecordType during instantiation. If the RecordType is
+  // *not* wrapped in a TemplateSpecializationType and denotes a class
+  // template specialization, it must have come from an injected-class-name.
+  if (auto RecLoc = TLoc.getAs())
+if (auto *CTSD =
+dyn_cast(RecLoc.getDecl()))
+  return TemplateArgumentLoc(TemplateName(CTSD->getSpecializedTemplate()),
+ QualLoc, RecLoc.getNameLoc());
+
+  return TemplateArgumentLoc();
+}
+
 /// \brief Check that the given template argument corresponds to the given
 /// template parameter.
 ///
@@ -3863,6 +3896,17 @@ bool Sema::CheckTemplateArgument(NamedDe
   return true;
   }
 
+  // C++1z [temp.local]p1: (DR1004)
+  //   When [the injected-class-name] is used [...] as a template-argument for
+  //   a template template-parameter [...] it refers to the class template
+  //   itself.
+  if 

[PATCH] D28867: [Profile] Warn about out-of-date profiles only when there are mismatches

2017-01-18 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

Clang warns that a profile is out-of-date if it can't find a profile
record for any function in a TU. This warning is now noisy because llvm
can dead-strip functions with profiling instrumentation.

Only emit the out-of-date warning if there is an actual record mismatch.


https://reviews.llvm.org/D28867

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/Profile/c-outdated-data.c


Index: test/Profile/c-outdated-data.c
===
--- test/Profile/c-outdated-data.c
+++ test/Profile/c-outdated-data.c
@@ -4,23 +4,23 @@
 // doesn't play well with warnings that have no line number.
 
 // RUN: llvm-profdata merge %S/Inputs/c-outdated-data.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-outdated-data.c %s -o /dev/null -emit-llvm 
-fprofile-instrument-use-path=%t.profdata -Wprofile-instr-dropped 2>&1 | 
FileCheck %s
-// CHECK: warning: profile data may be out of date: of 3 functions, 1 has no 
data and 1 has mismatched data that will be ignored
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-outdated-data.c %s -o /dev/null -emit-llvm 
-fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s 
-check-prefix=OUTDATED
+// OUTDATED: warning: profile data may be out of date: of 3 functions, 1 has 
no data and 1 has mismatched data that will be ignored
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -DGENERATE_USABLE_DATA 
-main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm 
-fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s 
-check-prefix=USABLE -allow-empty
+// USABLE-NOT: warning: profile data may be out of date
 
 void no_usable_data() {
   int i = 0;
 
   if (i) {}
 
-#ifdef GENERATE_OUTDATED_DATA
+#ifdef GENERATE_USABLE_DATA
   if (i) {}
 #endif
 }
 
-#ifndef GENERATE_OUTDATED_DATA
 void no_data() {
 }
-#endif
 
 int main(int argc, const char *argv[]) {
   no_usable_data();
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -367,7 +367,7 @@
 if (MainFile.empty())
   MainFile = "";
 Diags.Report(diag::warn_profile_data_unprofiled) << MainFile;
-  } else
+  } else if (Mismatched > 0)
 Diags.Report(diag::warn_profile_data_out_of_date) << Visited << Missing
   << Mismatched;
 }


Index: test/Profile/c-outdated-data.c
===
--- test/Profile/c-outdated-data.c
+++ test/Profile/c-outdated-data.c
@@ -4,23 +4,23 @@
 // doesn't play well with warnings that have no line number.
 
 // RUN: llvm-profdata merge %S/Inputs/c-outdated-data.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata -Wprofile-instr-dropped 2>&1 | FileCheck %s
-// CHECK: warning: profile data may be out of date: of 3 functions, 1 has no data and 1 has mismatched data that will be ignored
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -check-prefix=OUTDATED
+// OUTDATED: warning: profile data may be out of date: of 3 functions, 1 has no data and 1 has mismatched data that will be ignored
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -DGENERATE_USABLE_DATA -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -check-prefix=USABLE -allow-empty
+// USABLE-NOT: warning: profile data may be out of date
 
 void no_usable_data() {
   int i = 0;
 
   if (i) {}
 
-#ifdef GENERATE_OUTDATED_DATA
+#ifdef GENERATE_USABLE_DATA
   if (i) {}
 #endif
 }
 
-#ifndef GENERATE_OUTDATED_DATA
 void no_data() {
 }
-#endif
 
 int main(int argc, const char *argv[]) {
   no_usable_data();
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -367,7 +367,7 @@
 if (MainFile.empty())
   MainFile = "";
 Diags.Report(diag::warn_profile_data_unprofiled) << MainFile;
-  } else
+  } else if (Mismatched > 0)
 Diags.Report(diag::warn_profile_data_out_of_date) << Visited << Missing
   << Mismatched;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxxabi] r292418 - Revert r286788

2017-01-18 Thread Jonathan Roelofs via cfe-commits



On 1/18/17 11:26 AM, Richard Smith via cfe-commits wrote:

On 18 January 2017 at 10:12, Jonathan Roelofs via cfe-commits
> wrote:

Author: jroelofs
Date: Wed Jan 18 12:12:39 2017
New Revision: 292418

URL: http://llvm.org/viewvc/llvm-project?rev=292418=rev

Log:
Revert r286788

The Itanium ABI [1] specifies that __cxa_demangle accept either:

   1) symbol names, which start with "_Z"
   2) type manglings, which do not start with "_Z"

r286788 erroneously assumes that it should only handle symbols, so
this patch
reverts it and adds a counterexample to the testcase.

1: https://mentorembedded.github.io/cxx-abi/abi.html#demangler



Thanks! Just FYI, the ABI document now lives
here: https://itanium-cxx-abi.github.io/cxx-abi/


Ah, didn't realize the canonical location changed. Should I get someone 
to change where this redirect points?


   "http://www.codesourcery.com/cxx-abi/: External link to this page"

As-is, that points at the 'mentorembedded.github.io' one.


Jon



Reviewers: zygoloid, EricWF

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp




--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292419 - [OpenMP] Codegen support for 'target parallel' on the host.

2017-01-18 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Wed Jan 18 12:18:53 2017
New Revision: 292419

URL: http://llvm.org/viewvc/llvm-project?rev=292419=rev
Log:
[OpenMP] Codegen support for 'target parallel' on the host.

This patch adds support for codegen of 'target parallel' on the host.
It is also the first combined directive that requires two or more
captured statements.  Support for this functionality is included in
the patch.

A combined directive such as 'target parallel' has two captured
statements, one for the 'target' and the other for the 'parallel'
region.  Two captured statements are required because each has
different implicit parameters (see SemaOpenMP.cpp).  For example,
the 'parallel' has 'global_tid' and 'bound_tid' while the 'target'
does not.  The patch adds support for handling multiple captured
statements based on the combined directive.

When codegen'ing the 'target parallel' directive, the 'target'
outlined function is created using the outer captured statement
and the 'parallel' outlined function is created using the inner
captured statement.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28753

Added:
cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen_registration_naming.cpp
Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=292419=292418=292419=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Wed Jan 18 12:18:53 2017
@@ -198,6 +198,26 @@ public:
 return const_cast(*child_begin());
   }
 
+  /// \brief Returns the captured statement associated with the
+  /// component region within the (combined) directive.
+  //
+  // \param RegionKind Component region kind.
+  CapturedStmt *getCapturedStmt(OpenMPDirectiveKind RegionKind) const {
+SmallVector CaptureRegions;
+getOpenMPCaptureRegions(CaptureRegions, getDirectiveKind());
+assert(std::any_of(
+   CaptureRegions.begin(), CaptureRegions.end(),
+   [=](const OpenMPDirectiveKind K) { return K == RegionKind; }) &&
+   "RegionKind not found in OpenMP CaptureRegions.");
+auto *CS = cast(getAssociatedStmt());
+for (auto ThisCaptureRegion : CaptureRegions) {
+  if (ThisCaptureRegion == RegionKind)
+return CS;
+  CS = cast(CS->getCapturedStmt());
+}
+llvm_unreachable("Incorrect RegionKind specified for directive.");
+  }
+
   OpenMPDirectiveKind getDirectiveKind() const { return Kind; }
 
   static bool classof(const Stmt *S) {

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=292419=292418=292419=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.h (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.h Wed Jan 18 12:18:53 2017
@@ -234,6 +234,11 @@ bool isOpenMPTaskingDirective(OpenMPDire
 /// directives that need loop bound sharing across loops outlined in nested
 /// functions
 bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind);
+
+/// Return the captured regions of an OpenMP directive.
+void getOpenMPCaptureRegions(
+llvm::SmallVectorImpl ,
+OpenMPDirectiveKind DKind);
 }
 
 #endif

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=292419=292418=292419=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 18 12:18:53 2017
@@ -8340,6 +8340,9 @@ public:
 return IsInOpenMPDeclareTargetContext;
   }
 
+  /// Return the number of captured regions created for an OpenMP directive.
+  static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);
+
   /// \brief Initialization of captured region for OpenMP region.
   void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope);
   /// \brief End of OpenMP region.

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=292419=292418=292419=diff

Re: [libcxxabi] r292418 - Revert r286788

2017-01-18 Thread Richard Smith via cfe-commits
On 18 January 2017 at 10:12, Jonathan Roelofs via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jroelofs
> Date: Wed Jan 18 12:12:39 2017
> New Revision: 292418
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292418=rev
> Log:
> Revert r286788
>
> The Itanium ABI [1] specifies that __cxa_demangle accept either:
>
>1) symbol names, which start with "_Z"
>2) type manglings, which do not start with "_Z"
>
> r286788 erroneously assumes that it should only handle symbols, so this
> patch
> reverts it and adds a counterexample to the testcase.
>
> 1: https://mentorembedded.github.io/cxx-abi/abi.html#demangler


Thanks! Just FYI, the ABI document now lives here:
https://itanium-cxx-abi.github.io/cxx-abi/

Reviewers: zygoloid, EricWF
>
> Modified:
> libcxxabi/trunk/src/cxa_demangle.cpp
> libcxxabi/trunk/test/test_demangle.pass.cpp
>
> Modified: libcxxabi/trunk/src/cxa_demangle.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/
> cxa_demangle.cpp?rev=292418=292417=292418=diff
> 
> ==
> --- libcxxabi/trunk/src/cxa_demangle.cpp (original)
> +++ libcxxabi/trunk/src/cxa_demangle.cpp Wed Jan 18 12:12:39 2017
> @@ -4979,22 +4979,12 @@ __cxa_demangle(const char *mangled_name,
>  return nullptr;
>  }
>
> -size_t len = std::strlen(mangled_name);
> -if (len < 2 || strncmp(mangled_name, "_Z", 2))
> -{
> -if (len < 4 || strncmp(mangled_name, "___Z", 4))
> -{
> -if (status)
> -*status = invalid_mangled_name;
> -return nullptr;
> -}
> -}
> -
>  size_t internal_size = buf != nullptr ? *n : 0;
>  arena a;
>  Db db(a);
>  db.template_param.emplace_back(a);
>  int internal_status = success;
> +size_t len = std::strlen(mangled_name);
>  demangle(mangled_name, mangled_name + len, db,
>   internal_status);
>  if (internal_status == success && db.fix_forward_references &&
>
> Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/
> test_demangle.pass.cpp?rev=292418=292417=292418=diff
> 
> ==
> --- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
> +++ libcxxabi/trunk/test/test_demangle.pass.cpp Wed Jan 18 12:12:39 2017
> @@ -29594,6 +29594,9 @@ const char* cases[][2] =
>  // NOTE: disable this test since it is a negative test case, you
> cannot demangle a non-mangled symbol
>  // {"\x6D", nullptr},  // This use to crash with ASAN
>  {"_ZTIU4_farrVKPi", "typeinfo for int* const volatile restrict _far"},
> +
> +// mangled names can include type manglings too, which don't start
> with _Z:
> +{"i", "int"},
>  };
>
>  const unsigned N = sizeof(cases) / sizeof(cases[0]);
>
>
> ___
> 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


[libcxxabi] r292418 - Revert r286788

2017-01-18 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Wed Jan 18 12:12:39 2017
New Revision: 292418

URL: http://llvm.org/viewvc/llvm-project?rev=292418=rev
Log:
Revert r286788

The Itanium ABI [1] specifies that __cxa_demangle accept either:

   1) symbol names, which start with "_Z"
   2) type manglings, which do not start with "_Z"

r286788 erroneously assumes that it should only handle symbols, so this patch
reverts it and adds a counterexample to the testcase.

1: https://mentorembedded.github.io/cxx-abi/abi.html#demangler


Reviewers: zygoloid, EricWF

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=292418=292417=292418=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Wed Jan 18 12:12:39 2017
@@ -4979,22 +4979,12 @@ __cxa_demangle(const char *mangled_name,
 return nullptr;
 }
 
-size_t len = std::strlen(mangled_name);
-if (len < 2 || strncmp(mangled_name, "_Z", 2))
-{
-if (len < 4 || strncmp(mangled_name, "___Z", 4))
-{
-if (status)
-*status = invalid_mangled_name;
-return nullptr;
-}
-}
-
 size_t internal_size = buf != nullptr ? *n : 0;
 arena a;
 Db db(a);
 db.template_param.emplace_back(a);
 int internal_status = success;
+size_t len = std::strlen(mangled_name);
 demangle(mangled_name, mangled_name + len, db,
  internal_status);
 if (internal_status == success && db.fix_forward_references &&

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=292418=292417=292418=diff
==
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Wed Jan 18 12:12:39 2017
@@ -29594,6 +29594,9 @@ const char* cases[][2] =
 // NOTE: disable this test since it is a negative test case, you cannot 
demangle a non-mangled symbol
 // {"\x6D", nullptr},  // This use to crash with ASAN
 {"_ZTIU4_farrVKPi", "typeinfo for int* const volatile restrict _far"},
+
+// mangled names can include type manglings too, which don't start with _Z:
+{"i", "int"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);


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


[PATCH] D28667: [clang-tidy] Don't modernize-raw-string-literal if replacement is longer.

2017-01-18 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

Don't do this without introducing an option to turn it off.


https://reviews.llvm.org/D28667



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


[PATCH] D28334: [clang-tidy] Add -extra-arg and -extra-arg-before to run-clang-tidy.py

2017-01-18 Thread Ehsan Akhgari via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ehsan marked an inline comment as done.
Closed by commit rL292415: [clang-tidy] Add -extra-arg and -extra-arg-before to 
run-clang-tidy.py (authored by ehsan).

Changed prior to commit:
  https://reviews.llvm.org/D28334?vs=83165=84854#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28334

Files:
  clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
@@ -59,7 +59,7 @@
 
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
-header_filter):
+header_filter, extra_arg, extra_arg_before):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if header_filter is not None:
@@ -76,6 +76,10 @@
 (handle, name) = tempfile.mkstemp(suffix='.yaml', dir=tmpdir)
 os.close(handle)
 start.append(name)
+  for arg in extra_arg:
+  start.append('-extra-arg=%s' % arg)
+  for arg in extra_arg_before:
+  start.append('-extra-arg-before=%s' % arg)
   start.append('-p=' + build_path)
   start.append(f)
   return start
@@ -96,7 +100,8 @@
   while True:
 name = queue.get()
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
- tmpdir, build_path, args.header_filter)
+ tmpdir, build_path, args.header_filter,
+ args.extra_arg, args.extra_arg_before)
 sys.stdout.write(' '.join(invocation) + '\n')
 subprocess.call(invocation)
 queue.task_done()
@@ -130,6 +135,14 @@
   'after applying fixes')
   parser.add_argument('-p', dest='build_path',
   help='Path used to read a compile command database.')
+  parser.add_argument('-extra-arg', dest='extra_arg',
+  action='append', default=[],
+  help='Additional argument to append to the compiler '
+  'command line.')
+  parser.add_argument('-extra-arg-before', dest='extra_arg_before',
+  action='append', default=[],
+  help='Additional argument to prepend to the compiler '
+  'command line.')
   args = parser.parse_args()
 
   db_path = 'compile_commands.json'


Index: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
@@ -59,7 +59,7 @@
 
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
-header_filter):
+header_filter, extra_arg, extra_arg_before):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if header_filter is not None:
@@ -76,6 +76,10 @@
 (handle, name) = tempfile.mkstemp(suffix='.yaml', dir=tmpdir)
 os.close(handle)
 start.append(name)
+  for arg in extra_arg:
+  start.append('-extra-arg=%s' % arg)
+  for arg in extra_arg_before:
+  start.append('-extra-arg-before=%s' % arg)
   start.append('-p=' + build_path)
   start.append(f)
   return start
@@ -96,7 +100,8 @@
   while True:
 name = queue.get()
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
- tmpdir, build_path, args.header_filter)
+ tmpdir, build_path, args.header_filter,
+ args.extra_arg, args.extra_arg_before)
 sys.stdout.write(' '.join(invocation) + '\n')
 subprocess.call(invocation)
 queue.task_done()
@@ -130,6 +135,14 @@
   'after applying fixes')
   parser.add_argument('-p', dest='build_path',
   help='Path used to read a compile command database.')
+  parser.add_argument('-extra-arg', dest='extra_arg',
+  action='append', default=[],
+  help='Additional argument to append to the compiler '
+  'command line.')
+  parser.add_argument('-extra-arg-before', dest='extra_arg_before',
+  action='append', default=[],
+  help='Additional argument to prepend to the compiler '
+  'command line.')
   args = parser.parse_args()
 
   db_path = 'compile_commands.json'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r292415 - [clang-tidy] Add -extra-arg and -extra-arg-before to run-clang-tidy.py

2017-01-18 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Wed Jan 18 11:49:35 2017
New Revision: 292415

URL: http://llvm.org/viewvc/llvm-project?rev=292415=rev
Log:
[clang-tidy] Add -extra-arg and -extra-arg-before to run-clang-tidy.py

Summary:
These flags allow specifying extra arguments to the tool's command
line which don't appear in the compilation database.

Reviewers: alexfh

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

Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=292415=292414=292415=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Wed Jan 18 
11:49:35 2017
@@ -59,7 +59,7 @@ def find_compilation_database(path):
 
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
-header_filter):
+header_filter, extra_arg, extra_arg_before):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if header_filter is not None:
@@ -76,6 +76,10 @@ def get_tidy_invocation(f, clang_tidy_bi
 (handle, name) = tempfile.mkstemp(suffix='.yaml', dir=tmpdir)
 os.close(handle)
 start.append(name)
+  for arg in extra_arg:
+  start.append('-extra-arg=%s' % arg)
+  for arg in extra_arg_before:
+  start.append('-extra-arg-before=%s' % arg)
   start.append('-p=' + build_path)
   start.append(f)
   return start
@@ -96,7 +100,8 @@ def run_tidy(args, tmpdir, build_path, q
   while True:
 name = queue.get()
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
- tmpdir, build_path, args.header_filter)
+ tmpdir, build_path, args.header_filter,
+ args.extra_arg, args.extra_arg_before)
 sys.stdout.write(' '.join(invocation) + '\n')
 subprocess.call(invocation)
 queue.task_done()
@@ -130,6 +135,14 @@ def main():
   'after applying fixes')
   parser.add_argument('-p', dest='build_path',
   help='Path used to read a compile command database.')
+  parser.add_argument('-extra-arg', dest='extra_arg',
+  action='append', default=[],
+  help='Additional argument to append to the compiler '
+  'command line.')
+  parser.add_argument('-extra-arg-before', dest='extra_arg_before',
+  action='append', default=[],
+  help='Additional argument to prepend to the compiler '
+  'command line.')
   args = parser.parse_args()
 
   db_path = 'compile_commands.json'


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


[PATCH] D28334: [clang-tidy] Add -extra-arg and -extra-arg-before to run-clang-tidy.py

2017-01-18 Thread Ehsan Akhgari via Phabricator via cfe-commits
ehsan marked an inline comment as done.
ehsan added inline comments.



Comment at: clang-tidy/tool/run-clang-tidy.py:80
+  for arg in extra_arg:
+  start.append('-extra-arg=%s' % arg[0])
+  for arg in extra_arg_before:

alexfh wrote:
> Why arg[0] and not just arg?
With nargs=1, extra_arg would be something like [['foo'], ['bar']] if 
-extra-arg foo -extra-arg bar is passed.  But I realized that there is no good 
reason why I need nargs=1 since action='append' will make the arg parser 
consume one argument, so I'll remove that and simplify this to just arg.


https://reviews.llvm.org/D28334



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


Re: [PATCH] D28845: Prototype of modules codegen

2017-01-18 Thread David Blaikie via cfe-commits
Oh, remembered I had one other question/idea:

Tangentially related to the question about non-inline functions in headers:

Currently .pcm files have the 'interesting decls' list. Are there any
interesting decls once modules codegen is in use? It seems mostly the
interesting decls are things like non-inline functions (& perhaps global
variables - I haven't got to those yet & I think I remember you mentioning
they might be trickier due to ordering requirements?). If not, we could
perhaps repurpose the interesting decls list as the modular codegen decls
list - but then we'd need a flag to say "actually, we're doing modular
codegen for this module". So perhaps having it as a separate list provides
the same functionality & is clearer anyway.

On Tue, Jan 17, 2017 at 8:08 PM David Blaikie via Phabricator via
cfe-commits  wrote:

> dblaikie created this revision.
>
> First pass at generating weak definitions of inline functions from module
> files
> (& currently skipping definitions of those functions in uses)
>
> I've done some manual testing (haven't delved into the preferred testing
> strategy for modules). Seems to work for simplest cases, including
> transitive
> modules.
>
> Also doesn't have an actual flag plumbed through, yet. I can submit that
> ahead
> of this in a separate patch (open to ideas, etc). Is there a goal for how
> explicit modules should be used via the driver (rather than cc1)? Otherwise
> this would be a cc1 option to match.
>
> One quandry: What to do with non-inline definitions in headers? Currently
> this
> prototype moves their emission (while keeping their linkage) to the module
> object. This would remove ODR violations and actually make it 'correct' to
> define a non-inline function in a header, which may or may not be
> desirable. It
> could be kept in all the users as it is today.
>
> I'm sure I don't know nearly enough about linkage and about how linkage is
> handled in Clang & LLVM. So I'm certainly open to ideas about how this
> implementation isn't ideal or correct - or the myriad of interesting
> linkage
> cases I should test/consider.
>
> Perhaps we could chat about this in person/over the shoulder if a faster
> iteration would be worthwhile.
>
>
> https://reviews.llvm.org/D28845
>
> Files:
>   include/clang/AST/ASTContext.h
>   include/clang/AST/ExternalASTSource.h
>   include/clang/Basic/LangOptions.def
>   include/clang/Basic/Module.h
>   include/clang/Serialization/ASTBitCodes.h
>   include/clang/Serialization/ASTReader.h
>   include/clang/Serialization/ASTWriter.h
>   lib/AST/ASTContext.cpp
>   lib/AST/ExternalASTSource.cpp
>   lib/Basic/Module.cpp
>   lib/CodeGen/CodeGenModule.cpp
>   lib/Lex/ModuleMap.cpp
>   lib/Serialization/ASTReader.cpp
>   lib/Serialization/ASTWriter.cpp
>   lib/Serialization/ASTWriterDecl.cpp
>
> ___
> 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] D28845: Prototype of modules codegen

2017-01-18 Thread David Blaikie via cfe-commits
On Wed, Jan 18, 2017 at 4:12 AM Hal Finkel via Phabricator <
revi...@reviews.llvm.org> wrote:

> hfinkel added a comment.
>
> Can you provide a high-level description of what you're trying to
> accomplish and the usage model?
>

Oh, for sure - sorry for the assumption/missing info. Stuff that's been
idly discussed (mostly offline) for a while, so I had more context in my
head than was conveyed in this email.

Starting with the assumption/restriction of this requiring explicit modules
and changes to the build system, here's the idea:

* In the original/normal object files: Demote linkonce_odr function
definitions derived from code in imported modules to available_externally
(Or removed entirely at -O0).
* Build new object files from every imported pcm across all object files
linked into a given binary.
  * In these new object files, emit weak_odr definitions of any inline
function defined in the module.

In this way, less code is generated, possibly saving compile time and
reducing the size of inputs to the link step. Also reducing the size of
debug info (DWARF debug info describes the inline function in every object
file where an out of line definition remains - and these definitions are
not deduplicated by the linker).

Once in place, this functionality can also be used to reduce DWARF debug
info further by omitting/emitting type descriptions in the same way. (if
the type is defined in a modular header - only emit the description of the
type's definition in the modular object file - rather than emitting it in
every object that uses that type)

Does that make sense? Happy to go into more detail, provide examples, etc.

- Dave


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


[clang-tools-extra] r292405 - [include-fixer] Don't return a correction if the header insertion failed.

2017-01-18 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Jan 18 10:22:58 2017
New Revision: 292405

URL: http://llvm.org/viewvc/llvm-project?rev=292405=rev
Log:
[include-fixer] Don't return a correction if the header insertion failed.

This is could happen in cases involving macros and we don't want to
return an invalid fixit for it or a confusing error message with no
fixit.

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=292405=292404=292405=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Wed Jan 18 10:22:58 
2017
@@ -118,14 +118,14 @@ bool IncludeFixerActionFactory::runInvoc
   return !Compiler.getDiagnostics().hasFatalErrorOccurred();
 }
 
-static void addDiagnosticsForContext(TypoCorrection ,
+static bool addDiagnosticsForContext(TypoCorrection ,
  const IncludeFixerContext ,
  StringRef Code, SourceLocation 
StartOfFile,
  ASTContext ) {
   auto Reps = createIncludeFixerReplacements(
   Code, Context, format::getLLVMStyle(), /*AddQualifiers=*/false);
-  if (!Reps)
-return;
+  if (!Reps || Reps->size() != 1)
+return false;
 
   unsigned DiagID = Ctx.getDiagnostics().getCustomDiagID(
   DiagnosticsEngine::Note, "Add '#include %0' to provide the missing "
@@ -133,7 +133,6 @@ static void addDiagnosticsForContext(Typ
 
   // FIXME: Currently we only generate a diagnostic for the first header. Give
   // the user choices.
-  assert(Reps->size() == 1 && "Expected exactly one replacement");
   const tooling::Replacement  = *Reps->begin();
 
   auto Begin = StartOfFile.getLocWithOffset(Placed.getOffset());
@@ -143,6 +142,7 @@ static void addDiagnosticsForContext(Typ
  << FixItHint::CreateReplacement(CharSourceRange::getCharRange(Begin, End),
  Placed.getReplacementText());
   Correction.addExtraDiagnostic(std::move(PD));
+  return true;
 }
 
 /// Callback for incomplete types. If we encounter a forward declaration we
@@ -286,12 +286,12 @@ clang::TypoCorrection IncludeFixerSemaSo
 FileID FID = SM.getFileID(Typo.getLoc());
 StringRef Code = SM.getBufferData(FID);
 SourceLocation StartOfFile = SM.getLocForStartOfFile(FID);
-addDiagnosticsForContext(
-Correction,
-getIncludeFixerContext(SM, CI->getPreprocessor().getHeaderSearchInfo(),
-   MatchedSymbols),
-Code, StartOfFile, CI->getASTContext());
-return Correction;
+if (addDiagnosticsForContext(
+Correction, getIncludeFixerContext(
+SM, CI->getPreprocessor().getHeaderSearchInfo(),
+MatchedSymbols),
+Code, StartOfFile, CI->getASTContext()))
+  return Correction;
   }
   return TypoCorrection();
 }


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


r292406 - [ASTUnit] Reset diag state when creating the ASTUnit.

2017-01-18 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Jan 18 10:25:48 2017
New Revision: 292406

URL: http://llvm.org/viewvc/llvm-project?rev=292406=rev
Log:
[ASTUnit] Reset diag state when creating the ASTUnit.

A client could call this with a dirty diagnostic engine, don't crash.

Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=292406=292405=292406=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Wed Jan 18 10:25:48 2017
@@ -1879,6 +1879,7 @@ bool ASTUnit::LoadFromCompilerInvocation
   // We'll manage file buffers ourselves.
   Invocation->getPreprocessorOpts().RetainRemappedFileBuffers = true;
   Invocation->getFrontendOpts().DisableFree = false;
+  getDiagnostics().Reset();
   ProcessWarningOptions(getDiagnostics(), Invocation->getDiagnosticOpts());
 
   std::unique_ptr OverrideMainBuffer;


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


[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.

2017-01-18 Thread Pekka Jääskeläinen via Phabricator via cfe-commits
pekka.jaaskelainen added inline comments.



Comment at: docs/UsersManual.rst:2065
+
+ $ clang -cc1 -triple spir64-unknown-unknown -cl-ext=-cl_khr_fp64 test.cl
+

Anastasia wrote:
> pekka.jaaskelainen wrote:
> > Is this correct? I cannot make it work:
> > 
> > ```
> > ~/local/stow/llvm-4.0-unpatched-Debug/bin/clang -Xclang 
> > -finclude-default-header -emit-llvm -cc1 -triple spir64-unknown-unknown 
> > kernel/test_halfs.cl -c -S -o -
> > clang-4.0: error: unknown argument: '-cc1'
> > clang-4.0: error: unknown argument: '-triple'
> > clang-4.0: error: no such file or directory: 'spir64-unknown-unknown'
> > ```
> > 
> > -target works instead. (But reveals another issue, there's no printf() 
> > declaration, should I file a bug?)
> > 
> > ```
> > ~/local/stow/llvm-4.0-unpatched-Debug/bin/clang -Xclang 
> > -finclude-default-header -emit-llvm -target spir64-unknown-unknown 
> > kernel/test_halfs.cl -c -S -o -
> > kernel/test_halfs.cl:10:9: warning: implicit declaration of function 
> > 'printf' is invalid in C99 [-Wimplicit-function-declaration]
> > printf("max(a,b)[0] type=uint2 a=0x15b348c9 b=0xf88e7d07 
> > want=0xf88e7d07 got=%x\n", max_[0]);
> > ^
> > kernel/test_halfs.cl:10:9: error: function with no prototype cannot use the 
> > spir_function calling convention
> > 1 warning and 1 error generated.
> > ```
> > 
> > With 3.9 that kernel which calls printf() passes:
> > ```
> > /local/stow/llvm-3.9-debug/bin/clang -Xclang -finclude-default-header 
> > -emit-llvm -target spir64-unknown-unknown kernel/test_halfs.cl -c -S -o -
> > ; ModuleID = 'kernel/test_halfs.cl'
> > source_filename = "kernel/test_halfs.cl"
> > target datalayout = 
> > "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
> > target triple = "spir64-unknown-unknown"
> > 
> > ```
> > 
> > 
> > 
> It should be -triple with -cc1 and -target without.
> 
>   clang -cc1 -triple ...
>   clang -target ...
> 
> We have disabled the C99 builtin functions as per spec v1.2 s6.9.f, but the 
> OpenCL builtins should be available via the header now.
> 
> As I can see declaration of printf is in the header under CL1.2 and higher.
> 
> Could you try this command instead:
>   clang -std=CL1.2 test.cl -Xclang -finclude-default-header
> 
Yes, std=CL1.2 helped, good point! But -cc1 -triple doesn't work (unknown 
argument). However -target works. This is with Clang 4.0.


https://reviews.llvm.org/D28080



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


[PATCH] D28514: [CodeCompletion] Reset the hidden declaration obtained after lookup when caching UsingShadowDecls

2017-01-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Sema/SemaCodeComplete.cpp:961
+// then incorrectly applied to the target declaration. This can be avoided
+// by resetting the declaration that's being hidden.
+if (Hiding && isa(Hiding))

ahatanak wrote:
> I'm not sure about this, but is it correct for 
> VisibleDeclsRecord::checkHidden to return the UsingDecl when the 
> UsingShadowDecl is being passed? I'm thinking perhaps the bug is in that 
> function, since it seems like it should just return a nullptr instead if 
> UsingDecl doesn't hide UsingShadowDecl, .
That makes sense I think, I've updated the code to fix 
`VisibleDeclsRecord::checkHidden` instead.


Repository:
  rL LLVM

https://reviews.llvm.org/D28514



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


[PATCH] D28514: [CodeCompletion] Reset the hidden declaration obtained after lookup when caching UsingShadowDecls

2017-01-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 84842.
arphaman marked an inline comment as done.
arphaman added a comment.

Avoid the hidden declaration in `VisibleDeclsRecord::checkHidden` instead of 
the decl consumer in code-completion


Repository:
  rL LLVM

https://reviews.llvm.org/D28514

Files:
  lib/Sema/SemaLookup.cpp
  test/Index/complete-cached-globals.cpp


Index: test/Index/complete-cached-globals.cpp
===
--- /dev/null
+++ test/Index/complete-cached-globals.cpp
@@ -0,0 +1,25 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+namespace SomeNamespace {
+class SomeClass {
+};
+void SomeFunction();
+}
+
+using SomeNamespace::SomeClass;
+using SomeNamespace::SomeFunction;
+
+static void foo() {
+  return;
+}
+
+// rdar://23454249
+
+// RUN: c-index-test -code-completion-at=%s:14:3 %s | FileCheck 
-check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test 
-code-completion-at=%s:14:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
+
+// CHECK-CC1: ClassDecl:{TypedText SomeClass} (50)
+// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText SomeFunction}{LeftParen 
(}{RightParen )} (50)
+// CHECK-CC1-NOT: {Text SomeNamespace::}{TypedText SomeClass}
+// CHECK-CC1-NOT: {Text SomeNamespace::}{TypedText SomeFunction}
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3428,6 +3428,11 @@
   SM == ShadowMaps.rbegin())
 continue;
 
+  // A shadow declaration that's created by a resolved using declaration
+  // is not hidden by the using declaration.
+  if (isa(ND) && isa(D))
+continue;
+
   // We've found a declaration that hides this one.
   return D;
 }


Index: test/Index/complete-cached-globals.cpp
===
--- /dev/null
+++ test/Index/complete-cached-globals.cpp
@@ -0,0 +1,25 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+namespace SomeNamespace {
+class SomeClass {
+};
+void SomeFunction();
+}
+
+using SomeNamespace::SomeClass;
+using SomeNamespace::SomeFunction;
+
+static void foo() {
+  return;
+}
+
+// rdar://23454249
+
+// RUN: c-index-test -code-completion-at=%s:14:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
+
+// CHECK-CC1: ClassDecl:{TypedText SomeClass} (50)
+// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText SomeFunction}{LeftParen (}{RightParen )} (50)
+// CHECK-CC1-NOT: {Text SomeNamespace::}{TypedText SomeClass}
+// CHECK-CC1-NOT: {Text SomeNamespace::}{TypedText SomeFunction}
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3428,6 +3428,11 @@
   SM == ShadowMaps.rbegin())
 continue;
 
+  // A shadow declaration that's created by a resolved using declaration
+  // is not hidden by the using declaration.
+  if (isa(ND) && isa(D))
+continue;
+
   // We've found a declaration that hides this one.
   return D;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28862: [compiler-rt] [test] Use approximate comparison on float types

2017-01-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Use approximate comparison between the result of __divsc3()
and the canonical value calculated, to allow the possible difference of
1 representable value resulting from optimization.

For example, the value of (0.01+j0.01) / (-0.50-j2.00))
computed the canonical way without specific machine flags is:

  z = -0x1.3bce70p-21 + j0x1.7af7bcp-22

However, if -march=i386 -mfpmath=387 is used, it becomes:

  z = -0x1.3bce72p-21 + j0x1.7af7bcp-22

While this difference is insignificant, it may cause the exact
comparison used in tests to fail. Allowing the difference of one
representable value seems to be a reasonable compromise.


Repository:
  rL LLVM

https://reviews.llvm.org/D28862

Files:
  test/builtins/Unit/divsc3_test.c


Index: test/builtins/Unit/divsc3_test.c
===
--- test/builtins/Unit/divsc3_test.c
+++ test/builtins/Unit/divsc3_test.c
@@ -14,6 +14,7 @@
 #include "int_lib.h"
 #include 
 #include 
+#include 
 #include 
 
 // Returns: the quotient of (a + ib) / (c + id)
@@ -47,6 +48,25 @@
 return non_zero;
 }
 
+// check for equality assuming that both real and imaginary parts
+// can differ by exactly 1 representable value, in order to handle
+// different levels of accuracy on 32-bit x86
+static bool approx_equal(float _Complex a, float _Complex b) {
+if (a != b) {
+float ra = __real__ a;
+float ia = __imag__ a;
+float rb = __real__ b;
+float ib = __imag__ b;
+
+if (ra != rb && nextafterf(ra, rb) != rb)
+return false;
+if (ia != ib && nextafterf(ia, ib) != ib)
+return false;
+}
+
+return true;
+}
+
 int test__divsc3(float a, float b, float c, float d)
 {
 float _Complex r = __divsc3(a, b, c, d);
@@ -100,7 +120,7 @@
 {
 float _Complex z = (a * c + b * d) / (c * c + d * d)
  + (b * c - a * d) / (c * c + d * d) * _Complex_I;
-if (r != z)
+if (!approx_equal(r, z))
 return 1;
 }
 break;


Index: test/builtins/Unit/divsc3_test.c
===
--- test/builtins/Unit/divsc3_test.c
+++ test/builtins/Unit/divsc3_test.c
@@ -14,6 +14,7 @@
 #include "int_lib.h"
 #include 
 #include 
+#include 
 #include 
 
 // Returns: the quotient of (a + ib) / (c + id)
@@ -47,6 +48,25 @@
 return non_zero;
 }
 
+// check for equality assuming that both real and imaginary parts
+// can differ by exactly 1 representable value, in order to handle
+// different levels of accuracy on 32-bit x86
+static bool approx_equal(float _Complex a, float _Complex b) {
+if (a != b) {
+float ra = __real__ a;
+float ia = __imag__ a;
+float rb = __real__ b;
+float ib = __imag__ b;
+
+if (ra != rb && nextafterf(ra, rb) != rb)
+return false;
+if (ia != ib && nextafterf(ia, ib) != ib)
+return false;
+}
+
+return true;
+}
+
 int test__divsc3(float a, float b, float c, float d)
 {
 float _Complex r = __divsc3(a, b, c, d);
@@ -100,7 +120,7 @@
 {
 float _Complex z = (a * c + b * d) / (c * c + d * d)
  + (b * c - a * d) / (c * c + d * d) * _Complex_I;
-if (r != z)
+if (!approx_equal(r, z))
 return 1;
 }
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25213: Fix PR28181: Prevent operator overloading related assertion failure crash that happens in C only

2017-01-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ping


Repository:
  rL LLVM

https://reviews.llvm.org/D25213



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


r292402 - [Basic] Remove source manager references from diag state points.

2017-01-18 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Jan 18 09:50:26 2017
New Revision: 292402

URL: http://llvm.org/viewvc/llvm-project?rev=292402=rev
Log:
[Basic] Remove source manager references from diag state points.

This is just wasted space, we don't support state points from multiple
source managers. Validate that there's no state when resetting the
source manager and use the 'global' reference to the sourcemanager
instead of the ones in the diag state.

Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/lib/Basic/Diagnostic.cpp

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=292402=292401=292402=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Wed Jan 18 09:50:26 2017
@@ -239,19 +239,9 @@ private:
   /// modifications done through the command-line.
   struct DiagStatePoint {
 DiagState *State;
-FullSourceLoc Loc;
-DiagStatePoint(DiagState *State, FullSourceLoc Loc)
+SourceLocation Loc;
+DiagStatePoint(DiagState *State, SourceLocation Loc)
   : State(State), Loc(Loc) { } 
-
-bool operator<(const DiagStatePoint ) const {
-  // If Loc is invalid it means it came from , in which case
-  // we regard it as coming before any valid source location.
-  if (RHS.Loc.isInvalid())
-return false;
-  if (Loc.isInvalid())
-return true;
-  return Loc.isBeforeInTranslationUnitThan(RHS.Loc);
-}
   };
 
   /// \brief A sorted vector of all DiagStatePoints representing changes in
@@ -271,16 +261,7 @@ private:
 return DiagStatePoints.back().State;
   }
 
-  void PushDiagStatePoint(DiagState *State, SourceLocation L) {
-FullSourceLoc Loc(L, getSourceManager());
-// Make sure that DiagStatePoints is always sorted according to Loc.
-assert(Loc.isValid() && "Adding invalid loc point");
-assert(!DiagStatePoints.empty() &&
-   (DiagStatePoints.back().Loc.isInvalid() ||
-DiagStatePoints.back().Loc.isBeforeInTranslationUnitThan(Loc)) &&
-   "Previous point loc comes after or is the same as new one");
-DiagStatePoints.push_back(DiagStatePoint(State, Loc));
-  }
+  void PushDiagStatePoint(DiagState *State, SourceLocation L);
 
   /// \brief Finds the DiagStatePoint that contains the diagnostic state of
   /// the given source location.
@@ -390,7 +371,11 @@ public:
 assert(SourceMgr && "SourceManager not set!");
 return *SourceMgr;
   }
-  void setSourceManager(SourceManager *SrcMgr) { SourceMgr = SrcMgr; }
+  void setSourceManager(SourceManager *SrcMgr) {
+assert(DiagStatePoints.size() == 1 && DiagStatePoints[0].Loc.isInvalid() &&
+   "Leftover diag state from a different SourceManager.");
+SourceMgr = SrcMgr;
+  }
 
   
//======//
   //  DiagnosticsEngine characterization methods, used by a client to customize

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=292402=292401=292402=diff
==
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Jan 18 09:50:26 2017
@@ -16,6 +16,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/PartialDiagnostic.h"
+#include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/CrashRecoveryContext.h"
@@ -137,7 +138,7 @@ void DiagnosticsEngine::Reset() {
   // Create a DiagState and DiagStatePoint representing diagnostic changes
   // through command-line.
   DiagStates.emplace_back();
-  DiagStatePoints.push_back(DiagStatePoint((), 
FullSourceLoc()));
+  DiagStatePoints.emplace_back((), SourceLocation());
 }
 
 void DiagnosticsEngine::SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1,
@@ -157,6 +158,18 @@ void DiagnosticsEngine::ReportDelayed()
   DelayedDiagArg2.clear();
 }
 
+void DiagnosticsEngine::PushDiagStatePoint(DiagState *State,
+   SourceLocation Loc) {
+  // Make sure that DiagStatePoints is always sorted according to Loc.
+  assert(Loc.isValid() && "Adding invalid loc point");
+  assert(!DiagStatePoints.empty() &&
+ (DiagStatePoints.back().Loc.isInvalid() ||
+  getSourceManager().isBeforeInTranslationUnit(
+  DiagStatePoints.back().Loc, Loc)) &&
+ "Previous point loc comes after or is the same as new one");
+  DiagStatePoints.push_back(DiagStatePoint(State, Loc));
+}
+
 DiagnosticsEngine::DiagStatePointsTy::iterator
 DiagnosticsEngine::GetDiagStatePointForLoc(SourceLocation L) const {
   assert(!DiagStatePoints.empty());
@@ -171,11 +184,21 @@ 

r292400 - Revert r292374 to debug Windows buildbot failure.

2017-01-18 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Wed Jan 18 09:36:05 2017
New Revision: 292400

URL: http://llvm.org/viewvc/llvm-project?rev=292400=rev
Log:
Revert r292374 to debug Windows buildbot failure.


Removed:
cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen_registration_naming.cpp
Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=292400=292399=292400=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Wed Jan 18 09:36:05 2017
@@ -198,26 +198,6 @@ public:
 return const_cast(*child_begin());
   }
 
-  /// \brief Returns the captured statement associated with the
-  /// component region within the (combined) directive.
-  //
-  // \param RegionKind Component region kind.
-  CapturedStmt *getCapturedStmt(OpenMPDirectiveKind RegionKind) const {
-ArrayRef CaptureRegions =
-getOpenMPCaptureRegions(getDirectiveKind());
-assert(std::any_of(
-   CaptureRegions.begin(), CaptureRegions.end(),
-   [=](const OpenMPDirectiveKind K) { return K == RegionKind; }) &&
-   "RegionKind not found in OpenMP CaptureRegions.");
-auto *CS = cast(getAssociatedStmt());
-for (auto ThisCaptureRegion : CaptureRegions) {
-  if (ThisCaptureRegion == RegionKind)
-return CS;
-  CS = cast(CS->getCapturedStmt());
-}
-llvm_unreachable("Incorrect RegionKind specified for directive.");
-  }
-
   OpenMPDirectiveKind getDirectiveKind() const { return Kind; }
 
   static bool classof(const Stmt *S) {

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=292400=292399=292400=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.h (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.h Wed Jan 18 09:36:05 2017
@@ -15,7 +15,6 @@
 #ifndef LLVM_CLANG_BASIC_OPENMPKINDS_H
 #define LLVM_CLANG_BASIC_OPENMPKINDS_H
 
-#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 
 namespace clang {
@@ -235,10 +234,6 @@ bool isOpenMPTaskingDirective(OpenMPDire
 /// directives that need loop bound sharing across loops outlined in nested
 /// functions
 bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind);
-
-/// Return the captured regions of an OpenMP directive.
-llvm::ArrayRef
-getOpenMPCaptureRegions(OpenMPDirectiveKind DKind);
 }
 
 #endif

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=292400=292399=292400=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 18 09:36:05 2017
@@ -8340,9 +8340,6 @@ public:
 return IsInOpenMPDeclareTargetContext;
   }
 
-  /// Return the number of captured regions created for an OpenMP directive.
-  static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);
-
   /// \brief Initialization of captured region for OpenMP region.
   void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope);
   /// \brief End of OpenMP region.

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=292400=292399=292400=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Wed Jan 18 09:36:05 2017
@@ -863,101 +863,3 @@ bool clang::isOpenMPLoopBoundSharingDire
  Kind == OMPD_target_teams_distribute_parallel_for_simd ||
  Kind == OMPD_target_teams_distribute_simd;
 }
-
-ArrayRef
-clang::getOpenMPCaptureRegions(OpenMPDirectiveKind DKind) {
-  assert(DKind <= OMPD_unknown);
-  switch (DKind) {
-  case OMPD_parallel:
-  case OMPD_parallel_for:
-  case OMPD_parallel_for_simd:
-  case OMPD_parallel_sections:
-return {OMPD_parallel};
-  case OMPD_teams:
-return {OMPD_teams};
-  case OMPD_target_teams:
-return {OMPD_target_teams};
-  case OMPD_simd:
-return {OMPD_simd};
-  case OMPD_for:
-return 

[libunwind] r292398 - Creating release directory for release_400.

2017-01-18 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 18 09:32:43 2017
New Revision: 292398

URL: http://llvm.org/viewvc/llvm-project?rev=292398=rev
Log:
Creating release directory for release_400.

Added:
libunwind/tags/RELEASE_400/

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


[libunwind] r292399 - Creating release candidate rc1 from release_400 branch

2017-01-18 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 18 09:32:46 2017
New Revision: 292399

URL: http://llvm.org/viewvc/llvm-project?rev=292399=rev
Log:
Creating release candidate rc1 from release_400 branch

Added:
libunwind/tags/RELEASE_400/rc1/
  - copied from r292398, libunwind/branches/release_40/

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


[libcxx] r292385 - Creating release candidate rc1 from release_400 branch

2017-01-18 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 18 09:32:14 2017
New Revision: 292385

URL: http://llvm.org/viewvc/llvm-project?rev=292385=rev
Log:
Creating release candidate rc1 from release_400 branch

Added:
libcxx/tags/RELEASE_400/rc1/   (props changed)
  - copied from r292384, libcxx/branches/release_40/

Propchange: libcxx/tags/RELEASE_400/rc1/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jan 18 09:32:14 2017
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:292013


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


[libcxxabi] r292387 - Creating release candidate rc1 from release_400 branch

2017-01-18 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 18 09:32:18 2017
New Revision: 292387

URL: http://llvm.org/viewvc/llvm-project?rev=292387=rev
Log:
Creating release candidate rc1 from release_400 branch

Added:
libcxxabi/tags/RELEASE_400/rc1/
  - copied from r292386, libcxxabi/branches/release_40/

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


[libcxxabi] r292386 - Creating release directory for release_400.

2017-01-18 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 18 09:32:16 2017
New Revision: 292386

URL: http://llvm.org/viewvc/llvm-project?rev=292386=rev
Log:
Creating release directory for release_400.

Added:
libcxxabi/tags/RELEASE_400/

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


[libcxx] r292384 - Creating release directory for release_400.

2017-01-18 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 18 09:32:11 2017
New Revision: 292384

URL: http://llvm.org/viewvc/llvm-project?rev=292384=rev
Log:
Creating release directory for release_400.

Added:
libcxx/tags/RELEASE_400/

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


[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM

2017-01-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs closed this revision.
jroelofs added a comment.

r292375


https://reviews.llvm.org/D28820



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


r292375 - Warn when calling a non interrupt function from an interrupt on ARM

2017-01-18 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Wed Jan 18 09:31:11 2017
New Revision: 292375

URL: http://llvm.org/viewvc/llvm-project?rev=292375=rev
Log:
Warn when calling a non interrupt function from an interrupt on ARM

The idea for this originated from a really tricky bug: ISRs on ARM don't
automatically save off the VFP regs, so if say, memcpy gets interrupted and the
ISR itself calls memcpy, the regs are left clobbered when the ISR is done.

https://reviews.llvm.org/D28820

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/arm-interrupt-attr.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=292375=292374=292375=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jan 18 09:31:11 
2017
@@ -259,6 +259,9 @@ def err_anyx86_interrupt_attribute : Err
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
+def warn_arm_interrupt_calling_convention : Warning<
+   "call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
+   InGroup;
 def warn_mips_interrupt_attribute : Warning<
"MIPS 'interrupt' attribute only applies to functions that have "
"%select{no parameters|a 'void' return type}0">,

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=292375=292374=292375=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jan 18 09:31:11 2017
@@ -5395,6 +5395,15 @@ Sema::BuildResolvedCallExpr(Expr *Fn, Na
 return ExprError();
   }
 
+  // Interrupt handlers don't save off the VFP regs automatically on ARM,
+  // so there's some risk when calling out to non-interrupt handler functions
+  // that the callee might not preserve them. This is easy to diagnose here,
+  // but can be very challenging to debug.
+  if (auto *Caller = getCurFunctionDecl())
+if (Caller->hasAttr())
+  if (!FDecl->hasAttr())
+Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
+
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting
   // builtin functions to function pointers in the callee of a call.

Modified: cfe/trunk/test/Sema/arm-interrupt-attr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/arm-interrupt-attr.c?rev=292375=292374=292375=diff
==
--- cfe/trunk/test/Sema/arm-interrupt-attr.c (original)
+++ cfe/trunk/test/Sema/arm-interrupt-attr.c Wed Jan 18 09:31:11 2017
@@ -17,3 +17,14 @@ __attribute__((interrupt("UNDEF"))) void
 __attribute__((interrupt)) void foo8() {}
 __attribute__((interrupt())) void foo9() {}
 __attribute__((interrupt(""))) void foo10() {}
+
+void callee1();
+__attribute__((interrupt("IRQ"))) void callee2();
+void caller1() {
+  callee1();
+  callee2();
+}
+__attribute__((interrupt("IRQ"))) void caller2() {
+  callee1(); // expected-warning {{call to function without interrupt 
attribute could clobber interruptee's VFP registers}}
+  callee2();
+}


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


[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM

2017-01-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D28820#649384, @rengolin wrote:

> Seems like a very specific corner case on ARM, but is that attribute 
> guaranteed to be ARM-only?
>
> If so, LGTM as is. If not, avoid mentioning "VFP" on the error message.


Yeah, the attribute is parsed in a target-specific way, so this warning as 
written won't match on other arches even though mips/x86 have their own similar 
spellings of it.


https://reviews.llvm.org/D28820



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


[PATCH] D28850: [docs] Tell Doxygen to expand LLVM_ALIGNAS to nothing

2017-01-18 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D28850#649462, @aaron.ballman wrote:

> LGTM, though I freely admit that I am no doxygen expert (from reading the 
> docs, this looks like the sensible approach though).


I couldn't find a code owner for docs to ask for review.

There are other doxygen.conf.in files in llvm:

docs/doxygen.cfg.in
tools/clang/tools/extra/docs/doxygen.cfg.in
tools/lldb/docs/doxygen.cfg.in

Should I change them all?


https://reviews.llvm.org/D28850



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


[PATCH] D28753: [OpenMP] Codegen support for 'target parallel' on the host.

2017-01-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292374: [OpenMP] Codegen support for 'target parallel' on 
the host. (authored by arpith).

Changed prior to commit:
  https://reviews.llvm.org/D28753?vs=84689=84832#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28753

Files:
  cfe/trunk/include/clang/AST/StmtOpenMP.h
  cfe/trunk/include/clang/Basic/OpenMPKinds.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Basic/OpenMPKinds.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
  cfe/trunk/test/OpenMP/target_parallel_codegen_registration.cpp
  cfe/trunk/test/OpenMP/target_parallel_codegen_registration_naming.cpp

Index: cfe/trunk/include/clang/AST/StmtOpenMP.h
===
--- cfe/trunk/include/clang/AST/StmtOpenMP.h
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h
@@ -198,6 +198,26 @@
 return const_cast(*child_begin());
   }
 
+  /// \brief Returns the captured statement associated with the
+  /// component region within the (combined) directive.
+  //
+  // \param RegionKind Component region kind.
+  CapturedStmt *getCapturedStmt(OpenMPDirectiveKind RegionKind) const {
+ArrayRef CaptureRegions =
+getOpenMPCaptureRegions(getDirectiveKind());
+assert(std::any_of(
+   CaptureRegions.begin(), CaptureRegions.end(),
+   [=](const OpenMPDirectiveKind K) { return K == RegionKind; }) &&
+   "RegionKind not found in OpenMP CaptureRegions.");
+auto *CS = cast(getAssociatedStmt());
+for (auto ThisCaptureRegion : CaptureRegions) {
+  if (ThisCaptureRegion == RegionKind)
+return CS;
+  CS = cast(CS->getCapturedStmt());
+}
+llvm_unreachable("Incorrect RegionKind specified for directive.");
+  }
+
   OpenMPDirectiveKind getDirectiveKind() const { return Kind; }
 
   static bool classof(const Stmt *S) {
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -8340,6 +8340,9 @@
 return IsInOpenMPDeclareTargetContext;
   }
 
+  /// Return the number of captured regions created for an OpenMP directive.
+  static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);
+
   /// \brief Initialization of captured region for OpenMP region.
   void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope);
   /// \brief End of OpenMP region.
Index: cfe/trunk/include/clang/Basic/OpenMPKinds.h
===
--- cfe/trunk/include/clang/Basic/OpenMPKinds.h
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_BASIC_OPENMPKINDS_H
 #define LLVM_CLANG_BASIC_OPENMPKINDS_H
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 
 namespace clang {
@@ -234,6 +235,10 @@
 /// directives that need loop bound sharing across loops outlined in nested
 /// functions
 bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind);
+
+/// Return the captured regions of an OpenMP directive.
+llvm::ArrayRef
+getOpenMPCaptureRegions(OpenMPDirectiveKind DKind);
 }
 
 #endif
Index: cfe/trunk/test/OpenMP/target_parallel_codegen_registration.cpp
===
--- cfe/trunk/test/OpenMP/target_parallel_codegen_registration.cpp
+++ cfe/trunk/test/OpenMP/target_parallel_codegen_registration.cpp
@@ -0,0 +1,437 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// Test target parallel codegen - host bc file has to be created first.

r292374 - [OpenMP] Codegen support for 'target parallel' on the host.

2017-01-18 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Wed Jan 18 09:14:52 2017
New Revision: 292374

URL: http://llvm.org/viewvc/llvm-project?rev=292374=rev
Log:
[OpenMP] Codegen support for 'target parallel' on the host.

This patch adds support for codegen of 'target parallel' on the host.
It is also the first combined directive that requires two or more
captured statements.  Support for this functionality is included in
the patch.

A combined directive such as 'target parallel' has two captured
statements, one for the 'target' and the other for the 'parallel'
region.  Two captured statements are required because each has
different implicit parameters (see SemaOpenMP.cpp).  For example,
the 'parallel' has 'global_tid' and 'bound_tid' while the 'target'
does not.  The patch adds support for handling multiple captured
statements based on the combined directive.

When codegen'ing the 'target parallel' directive, the 'target'
outlined function is created using the outer captured statement
and the 'parallel' outlined function is created using the inner
captured statement.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28753

Added:
cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen_registration_naming.cpp
Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=292374=292373=292374=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Wed Jan 18 09:14:52 2017
@@ -198,6 +198,26 @@ public:
 return const_cast(*child_begin());
   }
 
+  /// \brief Returns the captured statement associated with the
+  /// component region within the (combined) directive.
+  //
+  // \param RegionKind Component region kind.
+  CapturedStmt *getCapturedStmt(OpenMPDirectiveKind RegionKind) const {
+ArrayRef CaptureRegions =
+getOpenMPCaptureRegions(getDirectiveKind());
+assert(std::any_of(
+   CaptureRegions.begin(), CaptureRegions.end(),
+   [=](const OpenMPDirectiveKind K) { return K == RegionKind; }) &&
+   "RegionKind not found in OpenMP CaptureRegions.");
+auto *CS = cast(getAssociatedStmt());
+for (auto ThisCaptureRegion : CaptureRegions) {
+  if (ThisCaptureRegion == RegionKind)
+return CS;
+  CS = cast(CS->getCapturedStmt());
+}
+llvm_unreachable("Incorrect RegionKind specified for directive.");
+  }
+
   OpenMPDirectiveKind getDirectiveKind() const { return Kind; }
 
   static bool classof(const Stmt *S) {

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=292374=292373=292374=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.h (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.h Wed Jan 18 09:14:52 2017
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_BASIC_OPENMPKINDS_H
 #define LLVM_CLANG_BASIC_OPENMPKINDS_H
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 
 namespace clang {
@@ -234,6 +235,10 @@ bool isOpenMPTaskingDirective(OpenMPDire
 /// directives that need loop bound sharing across loops outlined in nested
 /// functions
 bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind);
+
+/// Return the captured regions of an OpenMP directive.
+llvm::ArrayRef
+getOpenMPCaptureRegions(OpenMPDirectiveKind DKind);
 }
 
 #endif

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=292374=292373=292374=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 18 09:14:52 2017
@@ -8340,6 +8340,9 @@ public:
 return IsInOpenMPDeclareTargetContext;
   }
 
+  /// Return the number of captured regions created for an OpenMP directive.
+  static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);
+
   /// \brief Initialization of captured region for OpenMP region.
   void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope);
   /// \brief End of OpenMP region.

Modified: 

[PATCH] D28781: [OpenMP] Support for the if-clause on the combined directive 'target parallel'.

2017-01-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D28781



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


[PATCH] D28860: [OpenCL] Diagnose write_only image3d when extension is disabled

2017-01-18 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.

Prior to OpenCL 2.0, image3d_t can only be used with the write_only
access qualifier when the cl_khr_3d_image_writes extension is enabled.
Clang did not diagnose write_only image3d arguments when the extension
was disabled.

Guard uses of write_only image3d in the OpenCL header.


https://reviews.llvm.org/D28860

Files:
  lib/Headers/opencl-c.h
  lib/Sema/SemaType.cpp
  test/Headers/opencl-c-header.cl
  test/SemaOpenCL/access-qualifier.cl

Index: test/SemaOpenCL/access-qualifier.cl
===
--- test/SemaOpenCL/access-qualifier.cl
+++ test/SemaOpenCL/access-qualifier.cl
@@ -74,3 +74,7 @@
   myPipeWrite(p); // expected-error {{passing 'read_only pipe int' to parameter of incompatible type 'write_only pipe int'}}
 }
 #endif
+
+#if __OPENCL_C_VERSION__ < 200
+kernel void test_image3d_wo(write_only image3d_t img) {} // expected-error {{use of type '__write_only image3d_t' requires cl_khr_3d_image_writes extension to be enabled}}
+#endif
Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -1,16 +1,11 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
 
-// CHECK: _Z16convert_char_rtec
-// CHECK-NOT: _Z3ctzc
-// CHECK20: _Z3ctzc
-// CHECK20-NOT: _Z16convert_char_rtec
-// CHECK-MOD: Reading modules
-
 // Test including the default header as a module.
 // The module should be compiled only once and loaded from cache afterwards.
 // Change the directory mode to read only to make sure no new modules are created.
 // Check time report to make sure module is used.
+// Check that some builtins occur in the generated IR when called.
 
 // ===
 // Clear current directory.
@@ -48,6 +43,12 @@
 // RUN: %clang_cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
 // RUN: chmod u+w %t
 
+// Verify that called builtins occur in the generated IR.
+
+// CHECK: _Z16convert_char_rtec
+// CHECK-NOT: _Z3ctzc
+// CHECK20: _Z3ctzc
+// CHECK20-NOT: _Z16convert_char_rtec
 char f(char x) {
 #if __OPENCL_C_VERSION__ != CL_VERSION_2_0
   return convert_char_rte(x);
@@ -59,3 +60,15 @@
   return ctz(x);
 #endif //__OPENCL_C_VERSION__
 }
+
+// Verify that a builtin using a write_only image3d_t type is available
+// from OpenCL 2.0 onwards.
+
+// CHECK20: _Z12write_imagef14ocl_image3d_wo
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+void test_image3dwo(write_only image3d_t img) {
+  write_imagef(img, (0), (0.0f));
+}
+#endif //__OPENCL_C_VERSION__
+
+// CHECK-MOD: Reading modules
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -6678,6 +6678,16 @@
 return;
   }
 
+  // OpenCL v1.1 s6.8b - The image3d_t type cannot be used with the __write_only
+  // access qualifier unless the cl_khr_3d_image_writes extension is enabled.
+  if (CurType->isOCLImage3dWOType() &&
+  !S.getOpenCLOptions().isEnabled("cl_khr_3d_image_writes")) {
+S.Diag(Attr.getLoc(), diag::err_opencl_requires_extension)
+<< 0 /* select type */ << CurType << "cl_khr_3d_image_writes";
+Attr.setInvalid();
+return;
+  }
+
   if (const TypedefType* TypedefTy = CurType->getAs()) {
 QualType PointeeTy = TypedefTy->desugar();
 S.Diag(Attr.getLoc(), diag::err_opencl_multiple_access_qualifiers);
Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -16,6 +16,12 @@
 #endif //cl_khr_depth_images
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#ifdef cl_khr_3d_image_writes
+#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
+#endif //cl_khr_3d_image_writes
+#endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0
+
 #define __ovld __attribute__((overloadable))
 #define __conv __attribute__((convergent))
 
@@ -15995,9 +16001,11 @@
 void __ovld write_imagei(write_only image1d_array_t image_array, int2 coord, int4 color);
 void __ovld write_imageui(write_only image1d_array_t image_array, int2 coord, uint4 color);
 
+#ifdef cl_khr_3d_image_writes
 void __ovld write_imagef(write_only image3d_t image, int4 coord, float4 color);
 void __ovld write_imagei(write_only image3d_t image, int4 coord, int4 color);
 void __ovld write_imageui(write_only image3d_t image, int4 coord, uint4 color);
+#endif
 
 #ifdef cl_khr_depth_images
 void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, float 

[PATCH] D28850: [docs] Tell Doxygen to expand LLVM_ALIGNAS to nothing

2017-01-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, though I freely admit that I am no doxygen expert (from reading the docs, 
this looks like the sensible approach though).


https://reviews.llvm.org/D28850



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


[PATCH] D27985: Add demangling support for C++11 thread_local variables

2017-01-18 Thread Dave Bozier via Phabricator via cfe-commits
davidb added a comment.

ping


Repository:
  rL LLVM

https://reviews.llvm.org/D27985



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


Re: [PATCH] D28753: [OpenMP] Codegen support for 'target parallel' on the host.

2017-01-18 Thread Alexey Bataev via cfe-commits
Armpit, fine, leave it as is

Best regards,
Alexey Bataev

> 18 янв. 2017 г., в 15:50, Arpith Jacob via Phabricator 
>  написал(а):
> 
> arpith-jacob added inline comments.
> 
> 
> 
> Comment at: lib/Sema/SemaOpenMP.cpp:1933-1937
> +  StmtResult SR = S;
> +  int ThisCaptureLevel =
> +  getOpenMPCaptureLevels(DSAStack->getCurrentDirective());
> +  while (--ThisCaptureLevel >= 0)
> +SR = ActOnCapturedRegionEnd(SR.get());
> 
> ABataev wrote:
>> Could you move this code to `CaptureRegionUnwinderRAII`?
> Hi Alexey, this code will be expanded in the next patch.  Have a look at:
> https://reviews.llvm.org/D28781
> SemaOpenMP.cpp:1930.
> This is the code to codegen preinits.  I think that code doesn't belong to 
> the RAII.  That's why I haven't moved this code to CaptureRegionUnwinderRAII.
> 
> Let me know if you disagree.
> 
> 
> https://reviews.llvm.org/D28753
> 
> 
> 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM

2017-01-18 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

Seems like a very specific corner case on ARM, but is that attribute guaranteed 
to be ARM-only?

If so, LGTM as is. If not, avoid mentioning "VFP" on the error message.


https://reviews.llvm.org/D28820



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


[PATCH] D28753: [OpenMP] Codegen support for 'target parallel' on the host.

2017-01-18 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:1933-1937
+  StmtResult SR = S;
+  int ThisCaptureLevel =
+  getOpenMPCaptureLevels(DSAStack->getCurrentDirective());
+  while (--ThisCaptureLevel >= 0)
+SR = ActOnCapturedRegionEnd(SR.get());

ABataev wrote:
> Could you move this code to `CaptureRegionUnwinderRAII`?
Hi Alexey, this code will be expanded in the next patch.  Have a look at:
https://reviews.llvm.org/D28781
SemaOpenMP.cpp:1930.
This is the code to codegen preinits.  I think that code doesn't belong to the 
RAII.  That's why I haven't moved this code to CaptureRegionUnwinderRAII.

Let me know if you disagree.


https://reviews.llvm.org/D28753



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


[PATCH] D28753: [OpenMP] Codegen support for 'target parallel' on the host.

2017-01-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG with nits




Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:848-860
+const StringRef outlinedHelperName, const RegionCodeGenTy ) {
   assert(ThreadIDVar->getType()->isPointerType() &&
  "thread id variable must be of type kmp_int32 *");
-  const CapturedStmt *CS = cast(D.getAssociatedStmt());
   CodeGenFunction CGF(CGM, true);
   bool HasCancel = false;
   if (auto *OPD = dyn_cast())
 HasCancel = OPD->hasCancel();

s/outlinedHelperName/OutlinedHelperName/g



Comment at: lib/Sema/SemaOpenMP.cpp:1933-1937
+  StmtResult SR = S;
+  int ThisCaptureLevel =
+  getOpenMPCaptureLevels(DSAStack->getCurrentDirective());
+  while (--ThisCaptureLevel >= 0)
+SR = ActOnCapturedRegionEnd(SR.get());

Could you move this code to `CaptureRegionUnwinderRAII`?


https://reviews.llvm.org/D28753



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


[PATCH] D28845: Prototype of modules codegen

2017-01-18 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

Can you provide a high-level description of what you're trying to accomplish 
and the usage model?


https://reviews.llvm.org/D28845



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


[PATCH] D28781: [OpenMP] Support for the if-clause on the combined directive 'target parallel'.

2017-01-18 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob updated this revision to Diff 84816.
arpith-jacob added a comment.

Inherit from OMPLexical scope with an added argument to reduce code duplication.


https://reviews.llvm.org/D28781

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_parallel_if_codegen.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2104,6 +2104,7 @@
 }
 
 void OMPClauseEnqueue::VisitOMPIfClause(const OMPIfClause *C) {
+  VisitOMPClauseWithPreInit(C);
   Visitor->AddStmt(C->getCondition());
 }
 
Index: test/OpenMP/target_parallel_if_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_parallel_if_codegen.cpp
@@ -0,0 +1,413 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CHECK-DAG: [[DEF_LOC:@.+]] = private unnamed_addr constant %ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+// CHECK-DAG: [[S1:%.+]] = type { double }
+// CHECK-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]], i32, i32 }
+// CHECK-DAG: [[DEVTY:%.+]] = type { i8*, i8*, [[ENTTY]]*, [[ENTTY]]* }
+// CHECK-DAG: [[DSCTY:%.+]] = type { i32, [[DEVTY]]*, [[ENTTY]]*, [[ENTTY]]* }

[PATCH] D28850: [docs] Tell Doxygen to expand LLVM_ALIGNAS to nothing

2017-01-18 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons created this revision.

Docs for clang::Decl and clang::TemplateSpecializationType have
not been generated since LLVM_ALIGNAS was added to them.

Tell Doxygen to expand LLVM_ALIGNAS to nothing as described at
https://www.stack.nl/~dimitri/doxygen/manual/preprocessing.html


https://reviews.llvm.org/D28850

Files:
  docs/doxygen.cfg.in


Index: docs/doxygen.cfg.in
===
--- docs/doxygen.cfg.in
+++ docs/doxygen.cfg.in
@@ -1885,15 +1885,15 @@
 # The default value is: NO.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-MACRO_EXPANSION= NO
+MACRO_EXPANSION= YES
 
 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
 # the macro expansion is limited to the macros specified with the PREDEFINED 
and
 # EXPAND_AS_DEFINED tags.
 # The default value is: NO.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-EXPAND_ONLY_PREDEF = NO
+EXPAND_ONLY_PREDEF = YES
 
 # If the SEARCH_INCLUDES tag is set to YES the includes files in the
 # INCLUDE_PATH will be searched if a #include is found.
@@ -1925,7 +1925,7 @@
 # recursively expanded use the := operator instead of the = operator.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-PREDEFINED =
+PREDEFINED = LLVM_ALIGNAS(x)=
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
 # tag can be used to specify a list of macro names that should be expanded. The


Index: docs/doxygen.cfg.in
===
--- docs/doxygen.cfg.in
+++ docs/doxygen.cfg.in
@@ -1885,15 +1885,15 @@
 # The default value is: NO.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-MACRO_EXPANSION= NO
+MACRO_EXPANSION= YES
 
 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
 # the macro expansion is limited to the macros specified with the PREDEFINED and
 # EXPAND_AS_DEFINED tags.
 # The default value is: NO.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-EXPAND_ONLY_PREDEF = NO
+EXPAND_ONLY_PREDEF = YES
 
 # If the SEARCH_INCLUDES tag is set to YES the includes files in the
 # INCLUDE_PATH will be searched if a #include is found.
@@ -1925,7 +1925,7 @@
 # recursively expanded use the := operator instead of the = operator.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-PREDEFINED =
+PREDEFINED = LLVM_ALIGNAS(x)=
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
 # tag can be used to specify a list of macro names that should be expanded. The
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28667: [clang-tidy] Don't modernize-raw-string-literal if replacement is longer.

2017-01-18 Thread András Leitereg via Phabricator via cfe-commits
leanil updated this revision to Diff 84805.
leanil added a comment.

Add test cases for the new functionality.
These should not produce warnings, because their raw string replacement would 
be longer.


https://reviews.llvm.org/D28667

Files:
  clang-tidy/modernize/RawStringLiteralCheck.cpp
  clang-tidy/modernize/RawStringLiteralCheck.h
  test/clang-tidy/modernize-raw-string-literal.cpp


Index: test/clang-tidy/modernize-raw-string-literal.cpp
===
--- test/clang-tidy/modernize-raw-string-literal.cpp
+++ test/clang-tidy/modernize-raw-string-literal.cpp
@@ -55,6 +55,10 @@
 wchar_t const *const WideLiteral(L"foobie\\bletch");
 wchar_t const *const WideRawLiteral(LR"(foobie\\bletch)");
 
+// Don't replace these, because the raw literal would be longer.
+char const *const JustAQuote("quote:\'");
+char const *const NeedDelimiter("\":)\"");
+
 char const *const SingleQuote("goink\'frob");
 // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: {{.*}} can be written as a raw 
string literal
 // CHECK-XFIXES: {{^}}char const *const SingleQuote(R"(goink'frob)");{{$}}
Index: clang-tidy/modernize/RawStringLiteralCheck.h
===
--- clang-tidy/modernize/RawStringLiteralCheck.h
+++ clang-tidy/modernize/RawStringLiteralCheck.h
@@ -32,7 +32,7 @@
 private:
   void replaceWithRawStringLiteral(
   const ast_matchers::MatchFinder::MatchResult ,
-  const StringLiteral *Literal);
+  const StringLiteral *Literal, StringRef Replacement);
 
   std::string DelimiterStem;
 };
Index: clang-tidy/modernize/RawStringLiteralCheck.cpp
===
--- clang-tidy/modernize/RawStringLiteralCheck.cpp
+++ clang-tidy/modernize/RawStringLiteralCheck.cpp
@@ -121,19 +121,24 @@
   if (Literal->getLocStart().isMacroID())
 return;
 
-  if (containsEscapedCharacters(Result, Literal))
-replaceWithRawStringLiteral(Result, Literal);
+  if (containsEscapedCharacters(Result, Literal)) {
+std::string Replacement = asRawStringLiteral(Literal, DelimiterStem);
+if (Replacement.length() <=
+Lexer::MeasureTokenLength(Literal->getLocStart(), 
*Result.SourceManager,
+  getLangOpts()))
+  replaceWithRawStringLiteral(Result, Literal, Replacement);
+  }
 }
 
 void RawStringLiteralCheck::replaceWithRawStringLiteral(
-const MatchFinder::MatchResult , const StringLiteral *Literal) {
+const MatchFinder::MatchResult , const StringLiteral *Literal,
+StringRef Replacement) {
   CharSourceRange CharRange = Lexer::makeFileCharRange(
   CharSourceRange::getTokenRange(Literal->getSourceRange()),
   *Result.SourceManager, getLangOpts());
   diag(Literal->getLocStart(),
"escaped string literal can be written as a raw string literal")
-  << FixItHint::CreateReplacement(
- CharRange, asRawStringLiteral(Literal, DelimiterStem));
+  << FixItHint::CreateReplacement(CharRange, Replacement);
 }
 
 } // namespace modernize


Index: test/clang-tidy/modernize-raw-string-literal.cpp
===
--- test/clang-tidy/modernize-raw-string-literal.cpp
+++ test/clang-tidy/modernize-raw-string-literal.cpp
@@ -55,6 +55,10 @@
 wchar_t const *const WideLiteral(L"foobie\\bletch");
 wchar_t const *const WideRawLiteral(LR"(foobie\\bletch)");
 
+// Don't replace these, because the raw literal would be longer.
+char const *const JustAQuote("quote:\'");
+char const *const NeedDelimiter("\":)\"");
+
 char const *const SingleQuote("goink\'frob");
 // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: {{.*}} can be written as a raw string literal
 // CHECK-XFIXES: {{^}}char const *const SingleQuote(R"(goink'frob)");{{$}}
Index: clang-tidy/modernize/RawStringLiteralCheck.h
===
--- clang-tidy/modernize/RawStringLiteralCheck.h
+++ clang-tidy/modernize/RawStringLiteralCheck.h
@@ -32,7 +32,7 @@
 private:
   void replaceWithRawStringLiteral(
   const ast_matchers::MatchFinder::MatchResult ,
-  const StringLiteral *Literal);
+  const StringLiteral *Literal, StringRef Replacement);
 
   std::string DelimiterStem;
 };
Index: clang-tidy/modernize/RawStringLiteralCheck.cpp
===
--- clang-tidy/modernize/RawStringLiteralCheck.cpp
+++ clang-tidy/modernize/RawStringLiteralCheck.cpp
@@ -121,19 +121,24 @@
   if (Literal->getLocStart().isMacroID())
 return;
 
-  if (containsEscapedCharacters(Result, Literal))
-replaceWithRawStringLiteral(Result, Literal);
+  if (containsEscapedCharacters(Result, Literal)) {
+std::string Replacement = asRawStringLiteral(Literal, DelimiterStem);
+if (Replacement.length() <=
+Lexer::MeasureTokenLength(Literal->getLocStart(), *Result.SourceManager,
+  getLangOpts()))
+  

  1   2   >