[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-12-28 Thread Marina Yatsina via Phabricator via cfe-commits
myatsina added a comment.

Vitaly,
Thanks for fixing the test!

Test was fixed by in 
https://reviews.llvm.org/rL290621: [asan] Fix test broken by r290540

Review:
https://reviews.llvm.org/D28128


Repository:
  rL LLVM

https://reviews.llvm.org/D15075



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


[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2016-12-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: lib/Format/Format.cpp:1890
   }
-  FormatStyle Style = getLLVMStyle();
-  Style.Language = getLanguageByFileName(FileName);
+  FormatStyle::LanguageKind Language = getLanguageByFileName(FileName);
 

amaiorano wrote:
> ioeric wrote:
> > amaiorano wrote:
> > > Since we won't always return a FormatStyle, we no longer construct one 
> > > here. Rather, instances are created in local scopes below when required.
> > I'd probably keep the default style so that we don't need to set `Language` 
> > repeatedly below.
> The thing is, it made a lot of sense to have a default constructed 
> FormatStyle before when we were sure to always return it. Since now we only 
> return a Style under 2 specific conditions (found a config file, or did not 
> return the FallbackStyle), otherwise return an error, I feel like it's more 
> clear this way. But if you firmly disagree, I can go back.
> 
> To make returning the Style with current Language more clear, I could use a 
> function that ties the two together and returns it (perhaps a local lambda), 
> like StyleWithLanguage(Style, Language).
I'd go with the old way with some comments, which should be clear enough.



Comment at: lib/Format/Format.cpp:1901
+  if (!getPredefinedStyle(FallbackStyleName, Language, &FallbackStyle)) {
+return make_string_error("Invalid fallback style \"" +
+ FallbackStyleName.str());

amaiorano wrote:
> ioeric wrote:
> > amaiorano wrote:
> > > I am unsure whether I should be returning these error strings at all. I 
> > > say this because some of the functions called in this one will output to 
> > > errs(), which means the caller doesn't get the full picture of what went 
> > > wrong.
> > > 
> > > Maybe it's better to keep the original code that outputs to errs(), and 
> > > just return an error code instead. Thoughts?
> > I think returning an `Expected` is the right approach. I think we should 
> > consider using customized format-relayed error codes (like that in the 
> > `tooling::Replacements` library) to provide richer information. For 
> > example, you could use customized error codes instead of 
> > `llvm::inconvertibleErrorCode` when constructing a `StringError` to provide 
> > additional information besides the error message. Other interfaces in the 
> > format library can potentially benefit from codes as well (e.g. 
> > `ParseError` can be merged). 
> I agree with you, returning more specific error codes would be useful. 
> However, I'm thinking we go at it incrementally. The point of this change is 
> to have getStyle return when an error occurs so that we return non-zero from 
> main, and more importantly, not use the fallback style when this happens. 
> 
> In that respect, what I'm wondering is whether I should just leave the errs() 
> output in getStyle, and simply return an error code, or keep what I've done 
> (returning StringError) as a stepping stone in the right direction - that is, 
> eventually returning customized format-relayed error codes, as you say.
> 
I think the interface should no longer write to `errs()` if we want to 
introduce error handling (either with error codes or `llvm::Error`). 

`StringError` does not really collide with error codes AFAICT - it can also 
carry error codes which you would have return directly. And even if you just 
return error codes, you would need some sort of customized error codes right?


https://reviews.llvm.org/D28081



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


[libcxx] r290662 - Fix ABI incompatible C++03 nullptr_t

2016-12-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 28 03:50:23 2016
New Revision: 290662

URL: http://llvm.org/viewvc/llvm-project?rev=290662&view=rev
Log:
Fix ABI incompatible C++03 nullptr_t

In C++03 libc++ emulates nullptr_t using a class, and #define's nullptr.
However this makes nullptr_t mangle differently between C++03 and C++11.
This breaks any function ABI which takes nullptr_t.

Thanfully Clang provides __nullptr in all dialects. This patch adds
an ABI option to switch to using __nullptr in C++03. In a perfect world
I would like to turn this on by default, since it's just ABI breaking fix
to an ABI breaking bug.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=290662&r1=290661&r2=290662&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Dec 28 03:50:23 2016
@@ -48,6 +48,10 @@
 #define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
 #define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
 #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
+// Don't use a nullptr_t simulation type in C++03 and use theh C++11 nullptr
+// provided under the alternate keyword __nullptr, which changes the mangling
+// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
+#define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
 #elif _LIBCPP_ABI_VERSION == 1
 // Feature macros for disabling pre ABI v1 features. All of these options
 // are deprecated.
@@ -266,7 +270,11 @@ typedef __char32_t char32_t;
 #endif
 
 #if !(__has_feature(cxx_nullptr))
-#define _LIBCPP_HAS_NO_NULLPTR
+# if __has_extension(cxx_nullptr) && 
defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
+#   define nullptr __nullptr
+# else
+#   define _LIBCPP_HAS_NO_NULLPTR
+# endif
 #endif
 
 #if !(__has_feature(cxx_rvalue_references))


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


[PATCH] D28124: [OpenMP] Code cleanup for NVPTX OpenMP codegen

2016-12-28 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.

Function names must start with a lower case letter. LG for other changes


https://reviews.llvm.org/D28124



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


[PATCH] D28125: [OpenMP] Update target codegen for NVPTX device.

2016-12-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:248
+  Address WorkFn = CGF.CreateTempAlloca(
+  CGF.Int8PtrTy, CharUnits::fromQuantity(8), /*Name*/ "work_fn");
+  Address ExecStatus =

I don't like the idea of using absolute numbers for alignment. Could use 
CreateDefaultAlignTempAlloca() instead?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:250-251
+  Address ExecStatus =
+  CGF.CreateTempAlloca(CGF.Int8Ty, CharUnits::fromQuantity(1),
+   /*Name*/ "exec_status");
+  CGF.InitTempAlloca(ExecStatus, Bld.getInt8(/*C=*/0));

The same



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:258-259
   // On termination condition (workid == 0), exit loop.
   llvm::Value *ShouldTerminate = Bld.CreateICmpEQ(
-  Bld.CreateAlignedLoad(WorkID, WorkID->getAlignment()),
-  llvm::Constant::getNullValue(WorkID->getType()->getElementType()),
+  Bld.CreateLoad(WorkFn), llvm::Constant::getNullValue(CGF.Int8PtrTy),
   "should_terminate");

Better to use Bld.CreateIsNull().



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:266
+  llvm::Value *IsActive =
+  Bld.CreateICmpNE(Bld.CreateLoad(ExecStatus), Bld.getInt8(0), 
"is_active");
+  Bld.CreateCondBr(IsActive, ExecuteBB, BarrierBB);

Better to use Bld.CreateIsNotNull()


https://reviews.llvm.org/D28125



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


[libcxx] r290666 - Fix typo in comment

2016-12-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 28 05:09:18 2016
New Revision: 290666

URL: http://llvm.org/viewvc/llvm-project?rev=290666&view=rev
Log:
Fix typo in comment

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=290666&r1=290665&r2=290666&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Dec 28 05:09:18 2016
@@ -48,7 +48,7 @@
 #define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
 #define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
 #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
-// Don't use a nullptr_t simulation type in C++03 and use theh C++11 nullptr
+// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
 // provided under the alternate keyword __nullptr, which changes the mangling
 // of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
 #define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR


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


[PATCH] D23934: Add a -ffixed-date-time= flag that sets the initial value of __DATE__, __TIME__, __TIMESTAMP__

2016-12-28 Thread Ed Schouten via Phabricator via cfe-commits
ed added a comment.

I'd be interested in seeing a feature like this appearing. Any chance this 
feature may be part of Clang 4.0?


https://reviews.llvm.org/D23934



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


[PATCH] D28136: [OpenCL] Implement as_type operator as alias of __builtin_astype.

2016-12-28 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
echuraev added a reviewer: Anastasia.
echuraev added subscribers: bader, yaxunl, cfe-commits.

https://reviews.llvm.org/D28136

Files:
  lib/Headers/opencl-c.h

Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -6578,777 +6578,86 @@
  * OpenCL v1.1/1.2/2.0 s6.2.4.2 - as_type operators
  * Reinterprets a data type as another data type of the same size
  */
-char __ovld __cnfn as_char(char);
-char __ovld __cnfn as_char(uchar);
-
-char2 __ovld __cnfn as_char2(char2);
-char2 __ovld __cnfn as_char2(uchar2);
-char2 __ovld __cnfn as_char2(short);
-char2 __ovld __cnfn as_char2(ushort);
-
-char3 __ovld __cnfn as_char3(char3);
-char3 __ovld __cnfn as_char3(char4);
-char3 __ovld __cnfn as_char3(uchar3);
-char3 __ovld __cnfn as_char3(uchar4);
-char3 __ovld __cnfn as_char3(short2);
-char3 __ovld __cnfn as_char3(ushort2);
-char3 __ovld __cnfn as_char3(int);
-char3 __ovld __cnfn as_char3(uint);
-char3 __ovld __cnfn as_char3(float);
-
-char4 __ovld __cnfn as_char4(char3);
-char4 __ovld __cnfn as_char4(char4);
-char4 __ovld __cnfn as_char4(uchar3);
-char4 __ovld __cnfn as_char4(uchar4);
-char4 __ovld __cnfn as_char4(short2);
-char4 __ovld __cnfn as_char4(ushort2);
-char4 __ovld __cnfn as_char4(int);
-char4 __ovld __cnfn as_char4(uint);
-char4 __ovld __cnfn as_char4(float);
-
-char8 __ovld __cnfn as_char8(char8);
-char8 __ovld __cnfn as_char8(uchar8);
-char8 __ovld __cnfn as_char8(short3);
-char8 __ovld __cnfn as_char8(short4);
-char8 __ovld __cnfn as_char8(ushort3);
-char8 __ovld __cnfn as_char8(ushort4);
-char8 __ovld __cnfn as_char8(int2);
-char8 __ovld __cnfn as_char8(uint2);
-char8 __ovld __cnfn as_char8(long);
-char8 __ovld __cnfn as_char8(ulong);
-char8 __ovld __cnfn as_char8(float2);
-
-char16 __ovld __cnfn as_char16(char16);
-char16 __ovld __cnfn as_char16(uchar16);
-char16 __ovld __cnfn as_char16(short8);
-char16 __ovld __cnfn as_char16(ushort8);
-char16 __ovld __cnfn as_char16(int3);
-char16 __ovld __cnfn as_char16(int4);
-char16 __ovld __cnfn as_char16(uint3);
-char16 __ovld __cnfn as_char16(uint4);
-char16 __ovld __cnfn as_char16(long2);
-char16 __ovld __cnfn as_char16(ulong2);
-char16 __ovld __cnfn as_char16(float3);
-char16 __ovld __cnfn as_char16(float4);
-
-uchar __ovld __cnfn as_uchar(char);
-uchar __ovld __cnfn as_uchar(uchar);
-
-uchar2 __ovld __cnfn as_uchar2(char2);
-uchar2 __ovld __cnfn as_uchar2(uchar2);
-uchar2 __ovld __cnfn as_uchar2(short);
-uchar2 __ovld __cnfn as_uchar2(ushort);
-
-uchar3 __ovld __cnfn as_uchar3(char3);
-uchar3 __ovld __cnfn as_uchar3(char4);
-uchar3 __ovld __cnfn as_uchar3(uchar3);
-uchar3 __ovld __cnfn as_uchar3(uchar4);
-uchar3 __ovld __cnfn as_uchar3(short2);
-uchar3 __ovld __cnfn as_uchar3(ushort2);
-uchar3 __ovld __cnfn as_uchar3(int);
-uchar3 __ovld __cnfn as_uchar3(uint);
-uchar3 __ovld __cnfn as_uchar3(float);
-
-uchar4 __ovld __cnfn as_uchar4(char3);
-uchar4 __ovld __cnfn as_uchar4(char4);
-uchar4 __ovld __cnfn as_uchar4(uchar3);
-uchar4 __ovld __cnfn as_uchar4(uchar4);
-uchar4 __ovld __cnfn as_uchar4(short2);
-uchar4 __ovld __cnfn as_uchar4(ushort2);
-uchar4 __ovld __cnfn as_uchar4(int);
-uchar4 __ovld __cnfn as_uchar4(uint);
-uchar4 __ovld __cnfn as_uchar4(float);
-
-uchar8 __ovld __cnfn as_uchar8(char8);
-uchar8 __ovld __cnfn as_uchar8(uchar8);
-uchar8 __ovld __cnfn as_uchar8(short3);
-uchar8 __ovld __cnfn as_uchar8(short4);
-uchar8 __ovld __cnfn as_uchar8(ushort3);
-uchar8 __ovld __cnfn as_uchar8(ushort4);
-uchar8 __ovld __cnfn as_uchar8(int2);
-uchar8 __ovld __cnfn as_uchar8(uint2);
-uchar8 __ovld __cnfn as_uchar8(long);
-uchar8 __ovld __cnfn as_uchar8(ulong);
-uchar8 __ovld __cnfn as_uchar8(float2);
-
-uchar16 __ovld __cnfn as_uchar16(char16);
-uchar16 __ovld __cnfn as_uchar16(uchar16);
-uchar16 __ovld __cnfn as_uchar16(short8);
-uchar16 __ovld __cnfn as_uchar16(ushort8);
-uchar16 __ovld __cnfn as_uchar16(int3);
-uchar16 __ovld __cnfn as_uchar16(int4);
-uchar16 __ovld __cnfn as_uchar16(uint3);
-uchar16 __ovld __cnfn as_uchar16(uint4);
-uchar16 __ovld __cnfn as_uchar16(long2);
-uchar16 __ovld __cnfn as_uchar16(ulong2);
-uchar16 __ovld __cnfn as_uchar16(float3);
-uchar16 __ovld __cnfn as_uchar16(float4);
-
-short __ovld __cnfn as_short(char2);
-short __ovld __cnfn as_short(uchar2);
-short __ovld __cnfn as_short(short);
-short __ovld __cnfn as_short(ushort);
-
-short2 __ovld __cnfn as_short2(char3);
-short2 __ovld __cnfn as_short2(char4);
-short2 __ovld __cnfn as_short2(uchar3);
-short2 __ovld __cnfn as_short2(uchar4);
-short2 __ovld __cnfn as_short2(short2);
-short2 __ovld __cnfn as_short2(ushort2);
-short2 __ovld __cnfn as_short2(int);
-short2 __ovld __cnfn as_short2(uint);
-short2 __ovld __cnfn as_short2(float);
-
-short3 __ovld __cnfn as_short3(char8);
-short3 __ovld __cnfn as_short3(uchar8);
-short3 __ovld __cnfn as_short3(short3);
-short3 __ovld __cnfn as_short3(short4);
-short3 __ovld __cnfn as_short3(ushort3);
-short3 __ovl

[PATCH] D16901: [Clang driver, ARM] Do not add +long-calls in PIC mode

2016-12-28 Thread Oleg Ranevskyy via Phabricator via cfe-commits
iid_iunknown abandoned this revision.
iid_iunknown added a comment.

Abandoning the patch as it is too old.


Repository:
  rL LLVM

https://reviews.llvm.org/D16901



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


[clang-tools-extra] r290668 - [clang-tidy] google-explicit-constructor: ignore compiler-generated conversion operators.

2016-12-28 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Dec 28 07:48:03 2016
New Revision: 290668

URL: http://llvm.org/viewvc/llvm-project?rev=290668&view=rev
Log:
[clang-tidy] google-explicit-constructor: ignore compiler-generated conversion 
operators.

Modified:
clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp?rev=290668&r1=290667&r2=290668&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp Wed 
Dec 28 07:48:03 2016
@@ -26,8 +26,11 @@ void ExplicitConstructorCheck::registerM
 return;
   Finder->addMatcher(cxxConstructorDecl(unless(isInstantiated())).bind("ctor"),
  this);
-  
Finder->addMatcher(cxxConversionDecl(unless(isExplicit())).bind("conversion"),
- this);
+  Finder->addMatcher(
+  cxxConversionDecl(unless(isExplicit()), // Already marked explicit.
+unless(isImplicit())) // Compiler-generated.
+  .bind("conversion"),
+  this);
 }
 
 // Looks for the token matching the predicate and returns the range of the 
found

Modified: 
clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp?rev=290668&r1=290667&r2=290668&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp Wed 
Dec 28 07:48:03 2016
@@ -80,6 +80,10 @@ struct B {
   // CHECK-FIXES: {{^  }}B(::std::initializer_list &&list6) {}
 };
 
+struct StructWithFnPointer {
+  void (*f)();
+} struct_with_fn_pointer = {[] {}};
+
 using namespace std;
 
 struct C {


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


[PATCH] D23934: Add a -ffixed-date-time= flag that sets the initial value of __DATE__, __TIME__, __TIMESTAMP__

2016-12-28 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D23934#631656, @ed wrote:

> I'd be interested in seeing a feature like this appearing.


I agree.




Comment at: lib/Driver/Tools.cpp:4687
+CmdArgs.push_back(Args.MakeArgString("-ffixed-date-time=" + DateTime));
+  }
+

This seems like a fairly random place for this code. It is far removed from any 
other handling of preprocessor-related options.



Comment at: lib/Driver/Tools.cpp:5996
   }
 
   Args.AddLastArg(CmdArgs, options::OPT_dM);

Somewhere around here would make more sense.


https://reviews.llvm.org/D23934



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-28 Thread Firat Kasmis via Phabricator via cfe-commits
firolino marked 27 inline comments as done.
firolino added inline comments.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:34
+  // a tag declaration (e.g. struct, class etc.):
+  // class A { } Object1, Object2;  <-- won't be matched
+  Finder->addMatcher(

aaron.ballman wrote:
> firolino wrote:
> > aaron.ballman wrote:
> > > Why do we not want to match this?
> > If we decide, whether we transform 
> > ```
> > class A { 
> > } Object1, Object2;
> > ``` 
> > to
> > ```
> > class A { 
> > } Object1, 
> > Object2;
> > ``` 
> > or
> > ```
> > class A { 
> > } 
> > Object1, 
> > Object2;
> > ``` 
> > I might consider adding support for it. Moreover, this kind of definition 
> > is usually seen globally and I don't know how to handle globals yet. See 
> > http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html
> I think this should be handled. It can be handled in either of the forms you 
> show, or by saying:
> ```
> A Object1;
> A Object2;
> ```
> If all of these turn out to be a problem, we can still diagnose without 
> providing a fixit.
> 
> As for globals in general, they can be handled in a separate patch once we 
> figure out the declaration grouping.
OK. I will try to split the object definition from the class definition, as you 
have suggested. Thus, I can kick out the tagDecl-matcher as well. If there is 
no easy way to do this, it will be reported anyway but without a fixit.

Note for me: Update documentation!



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:101
+  QualType Type;
+  if (const auto *FirstVar = dyn_cast(*FirstVarIt)) {
+Location = FirstVar->getLocation();

aaron.ballman wrote:
> firolino wrote:
> > aaron.ballman wrote:
> > > You can drop the `const` from the `dyn_cast`, here and elsewhere.
> > Alright, but can you explain why?
> The `const` on the declaration is sufficient to ensure const correctness. 
> It's morally equivalent to:
> ```
> void f(int i) {
>   const int ci = i; // No need to const_cast this either.
> }
> ```
Ah, got it. Thought first, you meant to remove any const in that dyn_cast line.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:137
+while (Type->isAnyPointerType() || Type->isArrayType())
+  Type = Type->getPointeeOrArrayElementType()->getCanonicalTypeInternal();
+  }

aaron.ballman wrote:
> firolino wrote:
> > aaron.ballman wrote:
> > > Why are you calling the Internal version of this function?
> > Because I need its QualType.
> You should not call functions that have Internal in the name (generally 
> speaking). Those are generally considered to be warts we want to remove once 
> we get rid of the last external caller.
> 
> All of your uses of `Type` are as a `clang::Type *`, so are you sure you need 
> the `QualType` at all? (Btw, you should consider a better name than `Type`.)
operator-> is overloaded in QualType... I was so confused all the time. Changed 
completely to Type.


https://reviews.llvm.org/D27621



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-28 Thread Firat Kasmis via Phabricator via cfe-commits
firolino marked 3 inline comments as done.
firolino added inline comments.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:34
+  // a tag declaration (e.g. struct, class etc.):
+  // class A { } Object1, Object2;  <-- won't be matched
+  Finder->addMatcher(

firolino wrote:
> aaron.ballman wrote:
> > firolino wrote:
> > > aaron.ballman wrote:
> > > > Why do we not want to match this?
> > > If we decide, whether we transform 
> > > ```
> > > class A { 
> > > } Object1, Object2;
> > > ``` 
> > > to
> > > ```
> > > class A { 
> > > } Object1, 
> > > Object2;
> > > ``` 
> > > or
> > > ```
> > > class A { 
> > > } 
> > > Object1, 
> > > Object2;
> > > ``` 
> > > I might consider adding support for it. Moreover, this kind of definition 
> > > is usually seen globally and I don't know how to handle globals yet. See 
> > > http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html
> > I think this should be handled. It can be handled in either of the forms 
> > you show, or by saying:
> > ```
> > A Object1;
> > A Object2;
> > ```
> > If all of these turn out to be a problem, we can still diagnose without 
> > providing a fixit.
> > 
> > As for globals in general, they can be handled in a separate patch once we 
> > figure out the declaration grouping.
> OK. I will try to split the object definition from the class definition, as 
> you have suggested. Thus, I can kick out the tagDecl-matcher as well. If 
> there is no easy way to do this, it will be reported anyway but without a 
> fixit.
> 
> Note for me: Update documentation!
What about
```
struct S {
} S1;
```
I would like to report this too, since two names are being declared here. `S` 
and `S1`. What do you think?


https://reviews.llvm.org/D27621



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


r290671 - [ThinLTO] Add missing FileCheck invocation

2016-12-28 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Wed Dec 28 10:45:37 2016
New Revision: 290671

URL: http://llvm.org/viewvc/llvm-project?rev=290671&view=rev
Log:
[ThinLTO] Add missing FileCheck invocation

One of the intended checks was not being performed.

Modified:
cfe/trunk/test/CodeGen/thinlto_backend.ll

Modified: cfe/trunk/test/CodeGen/thinlto_backend.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto_backend.ll?rev=290671&r1=290670&r2=290671&view=diff
==
--- cfe/trunk/test/CodeGen/thinlto_backend.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll Wed Dec 28 10:45:37 2016
@@ -20,7 +20,7 @@
 
 ; Ensure we get expected error for input files without summaries
 ; RUN: opt -o %t2.o %s
-; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c 
-fthinlto-index=%t.thinlto.bc
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c 
-fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR2
 ; CHECK-ERROR2: Error loading imported file '{{.*}}': Could not find module 
summary
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"


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


[PATCH] D28139: [ThinLTO] No need to rediscover imports in distributed backend

2016-12-28 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added reviewers: mehdi_amini, pcc.
tejohnson added a subscriber: cfe-commits.

We can simply import all external values with summaries included in
the individual index file created for the distributed backend job,
as only those are added to the individual index file created by the
WriteIndexesThinBackend (in addition to summaries for the original
module, which are skipped here).

While computing the cross module imports on this index would come to
the same conclusion as the original thin link import logic, it is
unnecessary work. And when tuning, it avoids the need to pass the
same function importing parameters (e.g. -import-instr-limit) to
both the thin link and the backends (otherwise they won't make the
same decisions).


https://reviews.llvm.org/D28139

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -863,11 +863,23 @@
   ModuleToDefinedGVSummaries;
   
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
 
-  // FIXME: We could simply import the modules mentioned in the combined index
-  // here.
+  // We can simply import the values mentioned in the combined index, since
+  // we should only invoke this using the individual indexes written out
+  // via a WriteIndexesThinBackend.
   FunctionImporter::ImportMapTy ImportList;
-  ComputeCrossModuleImportForModule(M->getModuleIdentifier(), *CombinedIndex,
-ImportList);
+  for (auto &GlobalList : *CombinedIndex) {
+auto GUID = GlobalList.first;
+assert(GlobalList.second.size() == 1 &&
+   "Expected individual combined index to have one summary per GUID");
+auto &Summary = GlobalList.second[0];
+// Skip the summaries for the importing module. These are included to
+// e.g. record required linkage changes.
+if (Summary->modulePath() == M->getModuleIdentifier())
+  continue;
+// Doesn't matter what value we plug in to the map, just needs an entry
+// to provoke importing by thinBackend.
+ImportList[Summary->modulePath()][GUID] = 1;
+  }
 
   std::vector> OwnedImports;
   MapVector ModuleMap;


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -863,11 +863,23 @@
   ModuleToDefinedGVSummaries;
   CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
 
-  // FIXME: We could simply import the modules mentioned in the combined index
-  // here.
+  // We can simply import the values mentioned in the combined index, since
+  // we should only invoke this using the individual indexes written out
+  // via a WriteIndexesThinBackend.
   FunctionImporter::ImportMapTy ImportList;
-  ComputeCrossModuleImportForModule(M->getModuleIdentifier(), *CombinedIndex,
-ImportList);
+  for (auto &GlobalList : *CombinedIndex) {
+auto GUID = GlobalList.first;
+assert(GlobalList.second.size() == 1 &&
+   "Expected individual combined index to have one summary per GUID");
+auto &Summary = GlobalList.second[0];
+// Skip the summaries for the importing module. These are included to
+// e.g. record required linkage changes.
+if (Summary->modulePath() == M->getModuleIdentifier())
+  continue;
+// Doesn't matter what value we plug in to the map, just needs an entry
+// to provoke importing by thinBackend.
+ImportList[Summary->modulePath()][GUID] = 1;
+  }
 
   std::vector> OwnedImports;
   MapVector ModuleMap;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r290569 - Driver: switch Windows to static RelocModel

2016-12-28 Thread Reid Kleckner via cfe-commits
I suspect this broke Win64:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/1410

On Mon, Dec 26, 2016 at 6:20 PM, Saleem Abdulrasool via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: compnerd
> Date: Mon Dec 26 20:20:35 2016
> New Revision: 290569
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290569&view=rev
> Log:
> Driver: switch Windows to static RelocModel
>
> Windows uses PE/COFF which is inherently position independent.  The use
> of the PIC model is unnecessary.  In fact, we would generate invalid
> code using the ELF PIC model when PIC was enabled previously.  Now that
> we no longer accept -fPIC and -fpoc, this switches the internal
> representation to the static model to permit us to make PIC modules
> invalid when targeting Windows.  This should not change the code
> generation, only the internal state management.
>
> Modified:
> cfe/trunk/lib/Driver/MSVCToolChain.cpp
> cfe/trunk/lib/Driver/ToolChains.cpp
> cfe/trunk/lib/Driver/ToolChains.h
> cfe/trunk/test/Driver/pic.c
>
> Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> MSVCToolChain.cpp?rev=290569&r1=290568&r2=290569&view=diff
> 
> ==
> --- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
> +++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Mon Dec 26 20:20:35 2016
> @@ -82,18 +82,6 @@ bool MSVCToolChain::IsUnwindTablesDefaul
>return getArch() == llvm::Triple::x86_64;
>  }
>
> -bool MSVCToolChain::isPICDefault() const {
> -  return getArch() == llvm::Triple::x86_64;
> -}
> -
> -bool MSVCToolChain::isPIEDefault() const {
> -  return false;
> -}
> -
> -bool MSVCToolChain::isPICDefaultForced() const {
> -  return getArch() == llvm::Triple::x86_64;
> -}
> -
>  #ifdef USE_WIN32
>  static bool readFullStringValue(HKEY hkey, const char *valueName,
>  std::string &value) {
>
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> ToolChains.cpp?rev=290569&r1=290568&r2=290569&view=diff
> 
> ==
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Dec 26 20:20:35 2016
> @@ -2880,22 +2880,13 @@ bool Generic_GCC::IsUnwindTablesDefault(
>
>  bool Generic_GCC::isPICDefault() const {
>switch (getArch()) {
> -  case llvm::Triple::x86_64:
> -return getTriple().isOSWindows();
> +  default: return false;
>case llvm::Triple::ppc64:
>case llvm::Triple::ppc64le:
>  return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX();
> -  default:
> -return false;
>}
>  }
>
> -bool Generic_GCC::isPIEDefault() const { return false; }
> -
> -bool Generic_GCC::isPICDefaultForced() const {
> -  return getArch() == llvm::Triple::x86_64 && getTriple().isOSWindows();
> -}
> -
>  bool Generic_GCC::IsIntegratedAssemblerDefault() const {
>switch (getTriple().getArch()) {
>case llvm::Triple::x86:
>
> Modified: cfe/trunk/lib/Driver/ToolChains.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> ToolChains.h?rev=290569&r1=290568&r2=290569&view=diff
> 
> ==
> --- cfe/trunk/lib/Driver/ToolChains.h (original)
> +++ cfe/trunk/lib/Driver/ToolChains.h Mon Dec 26 20:20:35 2016
> @@ -232,8 +232,8 @@ public:
>
>bool IsUnwindTablesDefault() const override;
>bool isPICDefault() const override;
> -  bool isPIEDefault() const override;
> -  bool isPICDefaultForced() const override;
> +  bool isPIEDefault() const override { return false; }
> +  bool isPICDefaultForced() const override { return false; }
>bool IsIntegratedAssemblerDefault() const override;
>llvm::opt::DerivedArgList *
>TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef
> BoundArch,
> @@ -1136,9 +1136,9 @@ public:
>
>bool IsIntegratedAssemblerDefault() const override;
>bool IsUnwindTablesDefault() const override;
> -  bool isPICDefault() const override;
> -  bool isPIEDefault() const override;
> -  bool isPICDefaultForced() const override;
> +  bool isPICDefault() const override { return false; }
> +  bool isPIEDefault() const override { return false; }
> +  bool isPICDefaultForced() const override { return false; }
>
>void
>AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
>
> Modified: cfe/trunk/test/Driver/pic.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/
> pic.c?rev=290569&r1=290568&r2=290569&view=diff
> 
> ==
> --- cfe/trunk/test/Driver/pic.c (original)
> +++ cfe/trunk/test/Driver/pic.c Mon Dec 26 20:20:35 2016
> @@ -255,9 +255,4 @@
>  // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
>  // RUN: %clang -c %s -target arm64-linux-android -### 2>&1 \

Re: r290569 - Driver: switch Windows to static RelocModel

2016-12-28 Thread Reid Kleckner via cfe-commits
This affected code generation of jump tables from switches. This was the
assembly difference for a switch when going from PIC to static:

$ cat t.cpp
void g(int);
void f(int x) {
  switch (x) {
  case 0: g(0); break;
  case 1: g(1); break;
  case 2: g(2); break;
  case 3: g(3); break;
  case 4: g(4); break;
  case 5: g(5); break;
  case 6: g(6); break;
  case 7: g(7); break;
  case 8: g(8); break;
  case 9: g(9); break;
  }
  g(10);
}

$ clang -cc1 t.cpp  -S -o - -munwind-tables -mrelocation-model pic -o pic.s

$ clang -cc1 t.cpp  -S -o - -munwind-tables -mrelocation-model static -o
static.s

$ diff -u pic.s static.s
--- pic.s   2016-12-28 09:32:48.190468800 -0800
+++ static.s2016-12-28 09:32:53.476899200 -0800
@@ -21,11 +21,9 @@
movq%rax, 40(%rsp)
movq%rdx, 32(%rsp)
ja  .LBB0_11
-   leaq.LJTI0_0(%rip), %rax
-   movq40(%rsp), %rcx
-   movslq  (%rax,%rcx,4), %rdx
-   addq%rax, %rdx
-   jmpq*%rdx
+   movq40(%rsp), %rax
+   movq.LJTI0_0(,%rax,8), %rcx
+   jmpq*%rcx
 .LBB0_1:
xorl%ecx, %ecx
callq   "?g@@YAXH@Z"
@@ -71,20 +69,21 @@
nop
addq$56, %rsp
retq
-   .p2align2, 0x90
+   .section.rdata,"dr"
+   .p2align3
 .LJTI0_0:
-   .long   .LBB0_1-.LJTI0_0
-   .long   .LBB0_2-.LJTI0_0
-   .long   .LBB0_3-.LJTI0_0
-   .long   .LBB0_4-.LJTI0_0
-   .long   .LBB0_5-.LJTI0_0
-   .long   .LBB0_6-.LJTI0_0
-   .long   .LBB0_7-.LJTI0_0
-   .long   .LBB0_8-.LJTI0_0
-   .long   .LBB0_9-.LJTI0_0
-   .long   .LBB0_10-.LJTI0_0
+   .quad   .LBB0_1
+   .quad   .LBB0_2
+   .quad   .LBB0_3
+   .quad   .LBB0_4
+   .quad   .LBB0_5
+   .quad   .LBB0_6
+   .quad   .LBB0_7
+   .quad   .LBB0_8
+   .quad   .LBB0_9
+   .quad   .LBB0_10
.seh_handlerdata
-   .text
+   .section.rdata,"dr"
 .Lcfi3:
.seh_endproc

I think we actually want the .rdata section, but we probably want to use
".long .LBB0_N@IMGREL" jump table entries.

This triggers a latent bug in unwind info emission, because .seh_endproc is
in the wrong section (.rdata, not .text).

Let's revert, fix the latent bug, make switch lowering do what we want, and
then re-land.

On Wed, Dec 28, 2016 at 9:10 AM, Reid Kleckner  wrote:

> I suspect this broke Win64:
> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/1410
>
> On Mon, Dec 26, 2016 at 6:20 PM, Saleem Abdulrasool via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: compnerd
>> Date: Mon Dec 26 20:20:35 2016
>> New Revision: 290569
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=290569&view=rev
>> Log:
>> Driver: switch Windows to static RelocModel
>>
>> Windows uses PE/COFF which is inherently position independent.  The use
>> of the PIC model is unnecessary.  In fact, we would generate invalid
>> code using the ELF PIC model when PIC was enabled previously.  Now that
>> we no longer accept -fPIC and -fpoc, this switches the internal
>> representation to the static model to permit us to make PIC modules
>> invalid when targeting Windows.  This should not change the code
>> generation, only the internal state management.
>>
>> Modified:
>> cfe/trunk/lib/Driver/MSVCToolChain.cpp
>> cfe/trunk/lib/Driver/ToolChains.cpp
>> cfe/trunk/lib/Driver/ToolChains.h
>> cfe/trunk/test/Driver/pic.c
>>
>> Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSV
>> CToolChain.cpp?rev=290569&r1=290568&r2=290569&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
>> +++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Mon Dec 26 20:20:35 2016
>> @@ -82,18 +82,6 @@ bool MSVCToolChain::IsUnwindTablesDefaul
>>return getArch() == llvm::Triple::x86_64;
>>  }
>>
>> -bool MSVCToolChain::isPICDefault() const {
>> -  return getArch() == llvm::Triple::x86_64;
>> -}
>> -
>> -bool MSVCToolChain::isPIEDefault() const {
>> -  return false;
>> -}
>> -
>> -bool MSVCToolChain::isPICDefaultForced() const {
>> -  return getArch() == llvm::Triple::x86_64;
>> -}
>> -
>>  #ifdef USE_WIN32
>>  static bool readFullStringValue(HKEY hkey, const char *valueName,
>>  std::string &value) {
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
>> lChains.cpp?rev=290569&r1=290568&r2=290569&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Dec 26 20:20:35 2016
>> @@ -2880,22 +2880,13 @@ bool Generic_GCC::IsUnwindTablesDefault(
>>
>>  bool Generic_GCC::isPICDefault() const {
>>switch (getArch()) {
>> -  case llvm::Triple::x86_64:
>> -return ge

Re: r290569 - Driver: switch Windows to static RelocModel

2016-12-28 Thread Reid Kleckner via cfe-commits
I filed https://llvm.org/bugs/show_bug.cgi?id=31488 for this.

On Wed, Dec 28, 2016 at 9:37 AM, Reid Kleckner  wrote:

> This affected code generation of jump tables from switches. This was the
> assembly difference for a switch when going from PIC to static:
>
> $ cat t.cpp
> void g(int);
> void f(int x) {
>   switch (x) {
>   case 0: g(0); break;
>   case 1: g(1); break;
>   case 2: g(2); break;
>   case 3: g(3); break;
>   case 4: g(4); break;
>   case 5: g(5); break;
>   case 6: g(6); break;
>   case 7: g(7); break;
>   case 8: g(8); break;
>   case 9: g(9); break;
>   }
>   g(10);
> }
>
> $ clang -cc1 t.cpp  -S -o - -munwind-tables -mrelocation-model pic -o pic.s
>
> $ clang -cc1 t.cpp  -S -o - -munwind-tables -mrelocation-model static -o
> static.s
>
> $ diff -u pic.s static.s
> --- pic.s   2016-12-28 09:32:48.190468800 -0800
> +++ static.s2016-12-28 09:32:53.476899200 -0800
> @@ -21,11 +21,9 @@
> movq%rax, 40(%rsp)
> movq%rdx, 32(%rsp)
> ja  .LBB0_11
> -   leaq.LJTI0_0(%rip), %rax
> -   movq40(%rsp), %rcx
> -   movslq  (%rax,%rcx,4), %rdx
> -   addq%rax, %rdx
> -   jmpq*%rdx
> +   movq40(%rsp), %rax
> +   movq.LJTI0_0(,%rax,8), %rcx
> +   jmpq*%rcx
>  .LBB0_1:
> xorl%ecx, %ecx
> callq   "?g@@YAXH@Z"
> @@ -71,20 +69,21 @@
> nop
> addq$56, %rsp
> retq
> -   .p2align2, 0x90
> +   .section.rdata,"dr"
> +   .p2align3
>  .LJTI0_0:
> -   .long   .LBB0_1-.LJTI0_0
> -   .long   .LBB0_2-.LJTI0_0
> -   .long   .LBB0_3-.LJTI0_0
> -   .long   .LBB0_4-.LJTI0_0
> -   .long   .LBB0_5-.LJTI0_0
> -   .long   .LBB0_6-.LJTI0_0
> -   .long   .LBB0_7-.LJTI0_0
> -   .long   .LBB0_8-.LJTI0_0
> -   .long   .LBB0_9-.LJTI0_0
> -   .long   .LBB0_10-.LJTI0_0
> +   .quad   .LBB0_1
> +   .quad   .LBB0_2
> +   .quad   .LBB0_3
> +   .quad   .LBB0_4
> +   .quad   .LBB0_5
> +   .quad   .LBB0_6
> +   .quad   .LBB0_7
> +   .quad   .LBB0_8
> +   .quad   .LBB0_9
> +   .quad   .LBB0_10
> .seh_handlerdata
> -   .text
> +   .section.rdata,"dr"
>  .Lcfi3:
> .seh_endproc
>
> I think we actually want the .rdata section, but we probably want to use
> ".long .LBB0_N@IMGREL" jump table entries.
>
> This triggers a latent bug in unwind info emission, because .seh_endproc
> is in the wrong section (.rdata, not .text).
>
> Let's revert, fix the latent bug, make switch lowering do what we want,
> and then re-land.
>
> On Wed, Dec 28, 2016 at 9:10 AM, Reid Kleckner  wrote:
>
>> I suspect this broke Win64:
>> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/1410
>>
>> On Mon, Dec 26, 2016 at 6:20 PM, Saleem Abdulrasool via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: compnerd
>>> Date: Mon Dec 26 20:20:35 2016
>>> New Revision: 290569
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=290569&view=rev
>>> Log:
>>> Driver: switch Windows to static RelocModel
>>>
>>> Windows uses PE/COFF which is inherently position independent.  The use
>>> of the PIC model is unnecessary.  In fact, we would generate invalid
>>> code using the ELF PIC model when PIC was enabled previously.  Now that
>>> we no longer accept -fPIC and -fpoc, this switches the internal
>>> representation to the static model to permit us to make PIC modules
>>> invalid when targeting Windows.  This should not change the code
>>> generation, only the internal state management.
>>>
>>> Modified:
>>> cfe/trunk/lib/Driver/MSVCToolChain.cpp
>>> cfe/trunk/lib/Driver/ToolChains.cpp
>>> cfe/trunk/lib/Driver/ToolChains.h
>>> cfe/trunk/test/Driver/pic.c
>>>
>>> Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSV
>>> CToolChain.cpp?rev=290569&r1=290568&r2=290569&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
>>> +++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Mon Dec 26 20:20:35 2016
>>> @@ -82,18 +82,6 @@ bool MSVCToolChain::IsUnwindTablesDefaul
>>>return getArch() == llvm::Triple::x86_64;
>>>  }
>>>
>>> -bool MSVCToolChain::isPICDefault() const {
>>> -  return getArch() == llvm::Triple::x86_64;
>>> -}
>>> -
>>> -bool MSVCToolChain::isPIEDefault() const {
>>> -  return false;
>>> -}
>>> -
>>> -bool MSVCToolChain::isPICDefaultForced() const {
>>> -  return getArch() == llvm::Triple::x86_64;
>>> -}
>>> -
>>>  #ifdef USE_WIN32
>>>  static bool readFullStringValue(HKEY hkey, const char *valueName,
>>>  std::string &value) {
>>>
>>> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
>>> lChains.cpp?rev=290569&r1=290568&r2=290569&view=diff
>>> ===

r290672 - Revert "Driver: switch Windows to static RelocModel"

2016-12-28 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Dec 28 11:41:36 2016
New Revision: 290672

URL: http://llvm.org/viewvc/llvm-project?rev=290672&view=rev
Log:
Revert "Driver: switch Windows to static RelocModel"

This reverts commit r290569. It caused unforeseen codegen changes for
switch jump tables described in PR31488.

Modified:
cfe/trunk/lib/Driver/MSVCToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/pic.c

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=290672&r1=290671&r2=290672&view=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Wed Dec 28 11:41:36 2016
@@ -82,6 +82,18 @@ bool MSVCToolChain::IsUnwindTablesDefaul
   return getArch() == llvm::Triple::x86_64;
 }
 
+bool MSVCToolChain::isPICDefault() const {
+  return getArch() == llvm::Triple::x86_64;
+}
+
+bool MSVCToolChain::isPIEDefault() const {
+  return false;
+}
+
+bool MSVCToolChain::isPICDefaultForced() const {
+  return getArch() == llvm::Triple::x86_64;
+}
+
 #ifdef USE_WIN32
 static bool readFullStringValue(HKEY hkey, const char *valueName,
 std::string &value) {

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=290672&r1=290671&r2=290672&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Dec 28 11:41:36 2016
@@ -2880,13 +2880,22 @@ bool Generic_GCC::IsUnwindTablesDefault(
 
 bool Generic_GCC::isPICDefault() const {
   switch (getArch()) {
-  default: return false;
+  case llvm::Triple::x86_64:
+return getTriple().isOSWindows();
   case llvm::Triple::ppc64:
   case llvm::Triple::ppc64le:
 return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX();
+  default:
+return false;
   }
 }
 
+bool Generic_GCC::isPIEDefault() const { return false; }
+
+bool Generic_GCC::isPICDefaultForced() const {
+  return getArch() == llvm::Triple::x86_64 && getTriple().isOSWindows();
+}
+
 bool Generic_GCC::IsIntegratedAssemblerDefault() const {
   switch (getTriple().getArch()) {
   case llvm::Triple::x86:

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=290672&r1=290671&r2=290672&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Wed Dec 28 11:41:36 2016
@@ -232,8 +232,8 @@ public:
 
   bool IsUnwindTablesDefault() const override;
   bool isPICDefault() const override;
-  bool isPIEDefault() const override { return false; }
-  bool isPICDefaultForced() const override { return false; }
+  bool isPIEDefault() const override;
+  bool isPICDefaultForced() const override;
   bool IsIntegratedAssemblerDefault() const override;
   llvm::opt::DerivedArgList *
   TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
@@ -1136,9 +1136,9 @@ public:
 
   bool IsIntegratedAssemblerDefault() const override;
   bool IsUnwindTablesDefault() const override;
-  bool isPICDefault() const override { return false; }
-  bool isPIEDefault() const override { return false; }
-  bool isPICDefaultForced() const override { return false; }
+  bool isPICDefault() const override;
+  bool isPIEDefault() const override;
+  bool isPICDefaultForced() const override;
 
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,

Modified: cfe/trunk/test/Driver/pic.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/pic.c?rev=290672&r1=290671&r2=290672&view=diff
==
--- cfe/trunk/test/Driver/pic.c (original)
+++ cfe/trunk/test/Driver/pic.c Wed Dec 28 11:41:36 2016
@@ -255,4 +255,9 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
 // RUN: %clang -c %s -target arm64-linux-android -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
-
+//
+// On Windows-X64 PIC is enabled by default
+// RUN: %clang -c %s -target x86_64-pc-windows-msvc18.0.0 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target x86_64-pc-windows-gnu -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2


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


r290673 - Fix format. NFC

2016-12-28 Thread Kelvin Li via cfe-commits
Author: kli
Date: Wed Dec 28 11:57:07 2016
New Revision: 290673

URL: http://llvm.org/viewvc/llvm-project?rev=290673&view=rev
Log:
Fix format. NFC

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=290673&r1=290672&r2=290673&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Dec 28 11:57:07 2016
@@ -2005,17 +2005,20 @@ void CodeGenFunction::EmitOMPTeamsDistri
 
 void CodeGenFunction::EmitOMPTargetTeamsDirective(
 const OMPTargetTeamsDirective &S) {
-  CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_target_teams,
-  [&S](CodeGenFunction &CGF, PrePostActionTy &) {
-
CGF.EmitStmt(cast(S.getAssociatedStmt())->getCapturedStmt());
+  CGM.getOpenMPRuntime().emitInlinedDirective(
+  *this, OMPD_target_teams, [&S](CodeGenFunction &CGF, PrePostActionTy &) {
+CGF.EmitStmt(
+cast(S.getAssociatedStmt())->getCapturedStmt());
   });
 }
 
 void CodeGenFunction::EmitOMPTargetTeamsDistributeDirective(
 const OMPTargetTeamsDistributeDirective &S) {
-  CGM.getOpenMPRuntime().emitInlinedDirective(*this, 
OMPD_target_teams_distribute,
+  CGM.getOpenMPRuntime().emitInlinedDirective(
+  *this, OMPD_target_teams_distribute,
   [&S](CodeGenFunction &CGF, PrePostActionTy &) {
-
CGF.EmitStmt(cast(S.getAssociatedStmt())->getCapturedStmt());
+CGF.EmitStmt(
+cast(S.getAssociatedStmt())->getCapturedStmt());
   });
 }
 


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


[PATCH] D28139: [ThinLTO] No need to rediscover imports in distributed backend

2016-12-28 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/D28139



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


r290674 - [ThinLTO] No need to rediscover imports in distributed backend

2016-12-28 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Wed Dec 28 12:00:08 2016
New Revision: 290674

URL: http://llvm.org/viewvc/llvm-project?rev=290674&view=rev
Log:
[ThinLTO] No need to rediscover imports in distributed backend

Summary:
We can simply import all external values with summaries included in
the individual index file created for the distributed backend job,
as only those are added to the individual index file created by the
WriteIndexesThinBackend (in addition to summaries for the original
module, which are skipped here).

While computing the cross module imports on this index would come to
the same conclusion as the original thin link import logic, it is
unnecessary work. And when tuning, it avoids the need to pass the
same function importing parameters (e.g. -import-instr-limit) to
both the thin link and the backends (otherwise they won't make the
same decisions).

Reviewers: mehdi_amini, pcc

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=290674&r1=290673&r2=290674&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Dec 28 12:00:08 2016
@@ -863,11 +863,23 @@ static void runThinLTOBackend(const Code
   ModuleToDefinedGVSummaries;
   
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
 
-  // FIXME: We could simply import the modules mentioned in the combined index
-  // here.
+  // We can simply import the values mentioned in the combined index, since
+  // we should only invoke this using the individual indexes written out
+  // via a WriteIndexesThinBackend.
   FunctionImporter::ImportMapTy ImportList;
-  ComputeCrossModuleImportForModule(M->getModuleIdentifier(), *CombinedIndex,
-ImportList);
+  for (auto &GlobalList : *CombinedIndex) {
+auto GUID = GlobalList.first;
+assert(GlobalList.second.size() == 1 &&
+   "Expected individual combined index to have one summary per GUID");
+auto &Summary = GlobalList.second[0];
+// Skip the summaries for the importing module. These are included to
+// e.g. record required linkage changes.
+if (Summary->modulePath() == M->getModuleIdentifier())
+  continue;
+// Doesn't matter what value we plug in to the map, just needs an entry
+// to provoke importing by thinBackend.
+ImportList[Summary->modulePath()][GUID] = 1;
+  }
 
   std::vector> OwnedImports;
   MapVector ModuleMap;


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


[PATCH] D28139: [ThinLTO] No need to rediscover imports in distributed backend

2016-12-28 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290674: [ThinLTO] No need to rediscover imports in 
distributed backend (authored by tejohnson).

Changed prior to commit:
  https://reviews.llvm.org/D28139?vs=82603&id=82608#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28139

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp


Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -863,11 +863,23 @@
   ModuleToDefinedGVSummaries;
   
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
 
-  // FIXME: We could simply import the modules mentioned in the combined index
-  // here.
+  // We can simply import the values mentioned in the combined index, since
+  // we should only invoke this using the individual indexes written out
+  // via a WriteIndexesThinBackend.
   FunctionImporter::ImportMapTy ImportList;
-  ComputeCrossModuleImportForModule(M->getModuleIdentifier(), *CombinedIndex,
-ImportList);
+  for (auto &GlobalList : *CombinedIndex) {
+auto GUID = GlobalList.first;
+assert(GlobalList.second.size() == 1 &&
+   "Expected individual combined index to have one summary per GUID");
+auto &Summary = GlobalList.second[0];
+// Skip the summaries for the importing module. These are included to
+// e.g. record required linkage changes.
+if (Summary->modulePath() == M->getModuleIdentifier())
+  continue;
+// Doesn't matter what value we plug in to the map, just needs an entry
+// to provoke importing by thinBackend.
+ImportList[Summary->modulePath()][GUID] = 1;
+  }
 
   std::vector> OwnedImports;
   MapVector ModuleMap;


Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -863,11 +863,23 @@
   ModuleToDefinedGVSummaries;
   CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
 
-  // FIXME: We could simply import the modules mentioned in the combined index
-  // here.
+  // We can simply import the values mentioned in the combined index, since
+  // we should only invoke this using the individual indexes written out
+  // via a WriteIndexesThinBackend.
   FunctionImporter::ImportMapTy ImportList;
-  ComputeCrossModuleImportForModule(M->getModuleIdentifier(), *CombinedIndex,
-ImportList);
+  for (auto &GlobalList : *CombinedIndex) {
+auto GUID = GlobalList.first;
+assert(GlobalList.second.size() == 1 &&
+   "Expected individual combined index to have one summary per GUID");
+auto &Summary = GlobalList.second[0];
+// Skip the summaries for the importing module. These are included to
+// e.g. record required linkage changes.
+if (Summary->modulePath() == M->getModuleIdentifier())
+  continue;
+// Doesn't matter what value we plug in to the map, just needs an entry
+// to provoke importing by thinBackend.
+ImportList[Summary->modulePath()][GUID] = 1;
+  }
 
   std::vector> OwnedImports;
   MapVector ModuleMap;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28124: [OpenMP] Code cleanup for NVPTX OpenMP codegen

2016-12-28 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:31
+// NVPTX Address space
+enum ADDRESS_SPACE {
+  ADDRESS_SPACE_SHARED = 3,

Please fix enum typename name and the name of the enumerator: 
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly


https://reviews.llvm.org/D28124



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


r290675 - Mention devirtualization in release notes

2016-12-28 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Wed Dec 28 12:23:23 2016
New Revision: 290675

URL: http://llvm.org/viewvc/llvm-project?rev=290675&view=rev
Log:
Mention devirtualization in release notes

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=290675&r1=290674&r2=290675&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Dec 28 12:23:23 2016
@@ -47,6 +47,24 @@ sections with improvements to Clang's su
 Major New Features
 --
 
+- Enhanced devirtualization with `-fstrict-vtable-pointers`. Clang 
devirtualizes
+across different basic blocks, like loops:
+
+.. code-block:: c++
+   struct A {
+   virtual void foo() {}
+   };
+   void indirect(A &a, int n) {
+   for (int i = 0 ; i < n; i++)
+   a.foo();
+
+   }
+   void test(int n) {
+   A a;
+   indirect(a);
+   }
+
+
 -  ...
 
 Improvements to Clang's diagnostics


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


[PATCH] D28125: [OpenMP] Update target codegen for NVPTX device.

2016-12-28 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

Apologies for the drive-by review.




Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.h:30
+  // Private state and methods.
+  //
+

This comment seems redundant with "private:" above?


https://reviews.llvm.org/D28125



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


r290676 - Revert "Mention devirtualization in release notes"

2016-12-28 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Wed Dec 28 12:25:30 2016
New Revision: 290676

URL: http://llvm.org/viewvc/llvm-project?rev=290676&view=rev
Log:
Revert "Mention devirtualization in release notes"

Accidental commit. LLVM changes have not been pushed yet
This reverts commit 592453413690a2d16784667d1644758b9af700c1.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=290676&r1=290675&r2=290676&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Dec 28 12:25:30 2016
@@ -47,24 +47,6 @@ sections with improvements to Clang's su
 Major New Features
 --
 
-- Enhanced devirtualization with `-fstrict-vtable-pointers`. Clang 
devirtualizes
-across different basic blocks, like loops:
-
-.. code-block:: c++
-   struct A {
-   virtual void foo() {}
-   };
-   void indirect(A &a, int n) {
-   for (int i = 0 ; i < n; i++)
-   a.foo();
-
-   }
-   void test(int n) {
-   A a;
-   indirect(a);
-   }
-
-
 -  ...
 
 Improvements to Clang's diagnostics


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


r290677 - [ItaniumABI] NFC changes

2016-12-28 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Wed Dec 28 12:26:08 2016
New Revision: 290677

URL: http://llvm.org/viewvc/llvm-project?rev=290677&view=rev
Log:
[ItaniumABI] NFC changes

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=290677&r1=290676&r2=290677&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Dec 28 12:26:08 2016
@@ -366,11 +366,12 @@ public:
   void emitCXXStructor(const CXXMethodDecl *MD, StructorType Type) override;
 
  private:
-   bool hasAnyUsedVirtualInlineFunction(const CXXRecordDecl *RD) const {
+   bool hasAnyVirtualInlineFunction(const CXXRecordDecl *RD) const {
 const auto &VtableLayout =
 CGM.getItaniumVTableContext().getVTableLayout(RD);
 
 for (const auto &VtableComponent : VtableLayout.vtable_components()) {
+  // Skip empty slot.
   if (!VtableComponent.isUsedFunctionPointerKind())
 continue;
 
@@ -1687,7 +1688,7 @@ bool ItaniumCXXABI::canSpeculativelyEmit
   // then we are safe to emit available_externally copy of vtable.
   // FIXME we can still emit a copy of the vtable if we
   // can emit definition of the inline functions.
-  return !hasAnyUsedVirtualInlineFunction(RD) && !isVTableHidden(RD);
+  return !hasAnyVirtualInlineFunction(RD) && !isVTableHidden(RD);
 }
 static llvm::Value *performTypeAdjustment(CodeGenFunction &CGF,
   Address InitialPtr,


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


[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2016-12-28 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added inline comments.



Comment at: lib/Format/Format.cpp:1984
+// If so, can't return this error here...
+return make_string_error("Configuration file(s) do(es) not support " +
+ getLanguageName(Language) + ": " +

amaiorano wrote:
> See the TODO comment above (which will be removed obviously). Is it an error 
> if we find no suitable config for the input language? If that happens, should 
> the fallback style be returned?
@ioeric Do you have any thoughts on my question here? Say the user specified 
"-file" and a fallback style, and we find files but they are not suitable (for 
a different language), do we use the fallback style, since it's as if we found 
no config file. If so, then we wouldn't consider this an error, and therefore 
would not print nor return the message that we see here ("Configuration file(s) 
do(es) not support...").

The fact that the original code output to errs() here leads me to believe that 
this should be considered an error condition, in which case I should keep my 
change - that is, return an error here and _not_ return the fallback style.


https://reviews.llvm.org/D28081



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


[PATCH] D26949: [libc++abi] Clean up visibility

2016-12-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Ping.


https://reviews.llvm.org/D26949



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


[PATCH] D28124: [OpenMP] Code cleanup for NVPTX OpenMP codegen

2016-12-28 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob updated this revision to Diff 82619.
arpith-jacob added a comment.

Addressed comments in review to start function names with a lowercase letter 
and to fix the enum type name along with the enumerator name.


https://reviews.llvm.org/D28124

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h

Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -50,38 +50,6 @@
 
 private:
   //
-  // NVPTX calls.
-  //
-
-  /// \brief Get the GPU warp size.
-  llvm::Value *getNVPTXWarpSize(CodeGenFunction &CGF);
-
-  /// \brief Get the id of the current thread on the GPU.
-  llvm::Value *getNVPTXThreadID(CodeGenFunction &CGF);
-
-  // \brief Get the maximum number of threads in a block of the GPU.
-  llvm::Value *getNVPTXNumThreads(CodeGenFunction &CGF);
-
-  /// \brief Get barrier to synchronize all threads in a block.
-  void getNVPTXCTABarrier(CodeGenFunction &CGF);
-
-  // \brief Synchronize all GPU threads in a block.
-  void syncCTAThreads(CodeGenFunction &CGF);
-
-  //
-  // OMP calls.
-  //
-
-  /// \brief Get the thread id of the OMP master thread.
-  /// The master thread id is the first thread (lane) of the last warp in the
-  /// GPU block.  Warp size is assumed to be some power of 2.
-  /// Thread id is 0 indexed.
-  /// E.g: If NumThreads is 33, master id is 32.
-  ///  If NumThreads is 64, master id is 32.
-  ///  If NumThreads is 1024, master id is 992.
-  llvm::Value *getMasterThreadID(CodeGenFunction &CGF);
-
-  //
   // Private state and methods.
   //
 
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -20,53 +20,64 @@
 using namespace clang;
 using namespace CodeGen;
 
-/// \brief Get the GPU warp size.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXWarpSize(CodeGenFunction &CGF) {
+namespace {
+enum OpenMPRTLFunctionNVPTX {
+  /// \brief Call to void __kmpc_kernel_init(kmp_int32 omp_handle,
+  /// kmp_int32 thread_limit);
+  OMPRTL_NVPTX__kmpc_kernel_init,
+};
+
+// NVPTX Address space
+enum AddressSpace {
+  AddressSpaceShared = 3,
+};
+} // namespace
+
+/// Get the GPU warp size.
+static llvm::Value *getNVPTXWarpSize(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  &CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
+  &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
   llvm::None, "nvptx_warp_size");
 }
 
-/// \brief Get the id of the current thread on the GPU.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXThreadID(CodeGenFunction &CGF) {
+/// Get the id of the current thread on the GPU.
+static llvm::Value *getNVPTXThreadID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  &CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_tid_x),
+  &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_tid_x),
   llvm::None, "nvptx_tid");
 }
 
-// \brief Get the maximum number of threads in a block of the GPU.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXNumThreads(CodeGenFunction &CGF) {
+/// Get the maximum number of threads in a block of the GPU.
+static llvm::Value *getNVPTXNumThreads(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  &CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_ntid_x),
+  &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_ntid_x),
   llvm::None, "nvptx_num_threads");
 }
 
-/// \brief Get barrier to synchronize all threads in a block.
-void CGOpenMPRuntimeNVPTX::getNVPTXCTABarrier(CodeGenFunction &CGF) {
+/// Get barrier to synchronize all threads in a block.
+static void getNVPTXCTABarrier(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
   Bld.CreateCall(llvm::Intrinsic::getDeclaration(
-  &CGM.getModule(), llvm::Intrinsic::nvvm_barrier0));
+  &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_barrier0));
 }
 
-// \brief Synchronize all GPU threads in a block.
-void CGOpenMPRuntimeNVPTX::syncCTAThreads(CodeGenFunction &CGF) {
-  getNVPTXCTABarrier(CGF);
-}
+/// Synchronize all GPU threads in a block.
+static void syncCTAThreads(CodeGenFunction &CGF) { getNVPTXCTABarrier(CGF); }
 
-/// \brief Get the thread id of the OMP master thread.
+/// Get the thread id of the OMP master thread.
 /// The master thread id is the first thread (lane) of the last warp in the
 /// GPU block.  Warp size is assumed to be some power of 2.
 /// Thread id is 0 indexed.
 /// E.g: If NumThreads is 33, master id is 32.
 ///  If NumThreads is 64, master id is 32.
 ///  If NumThreads is 1024, master id is 992.
-llvm::Value *CGOp

[PATCH] D28125: [OpenMP] Update target codegen for NVPTX device.

2016-12-28 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob updated this revision to Diff 82621.
arpith-jacob added a comment.

Alexey and Justin, thank you for spending the time to review this patch.  I've 
updated the patch accordingly.  I've also removed a dot ('.') from the worker 
function name since the character is not accepted by the nvidia linker ptxas in 
function names.


https://reviews.llvm.org/D28125

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

Index: test/OpenMP/nvptx_target_codegen.cpp
===
--- test/OpenMP/nvptx_target_codegen.cpp
+++ test/OpenMP/nvptx_target_codegen.cpp
@@ -8,9 +8,6 @@
 #ifndef HEADER
 #define HEADER
 
-// CHECK-DAG: [[OMP_NT:@.+]] = common addrspace(3) global i32 0
-// CHECK-DAG: [[OMP_WID:@.+]] = common addrspace(3) global i64 0
-
 template
 struct TT{
   tx X;
@@ -26,19 +23,22 @@
   double cn[5][n];
   TT d;
 
-  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l87}}_worker()
+  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l93}}_worker()
+  // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8,
+  // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*,
+  // CHECK: store i8* null, i8** [[OMP_WORK_FN]],
+  // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]],
   // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
-  // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i64 [[WORK]], 0
+  // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null
   // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
   //
   // CHECK: [[SEL_WORKERS]]
-  // CHECK: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
-  // CHECK: [[NT:%.+]] = load i32, i32 addrspace(3)* [[OMP_NT]]
-  // CHECK: [[IS_ACTIVE:%.+]] = icmp slt i32 [[TID]], [[NT]]
+  // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]],
+  // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0
   // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]]
   //
   // CHECK: [[EXEC_PARALLEL]]
@@ -54,31 +54,37 @@
   // CHECK: [[EXIT]]
   // CHECK: ret void
 
-  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+l87]]()
-  // CHECK: [[NTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
-  // CHECK: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
-  // CHECK: [[A:%.+]] = sub i32 [[WS]], 1
-  // CHECK: [[B:%.+]] = sub i32 [[NTID]], 1
-  // CHECK: [[MID:%.+]] = and i32 [[B]],
-  // CHECK: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
-  // CHECK: [[EXCESS:%.+]] = icmp ugt i32 [[TID]], [[MID]]
-  // CHECK: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
-  //
-  // CHECK: [[CHECK_WORKER]]
-  // CHECK: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[MID]]
-  // CHECK: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[MASTER:.+]]
+  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+l93]]()
+  // CHECK-DAG: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-DAG: [[NTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-DAG: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK-DAG: [[TH_LIMIT:%.+]] = sub i32 [[NTH]], [[WS]]
+  // CHECK: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[TH_LIMIT]]
+  // CHECK: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[CHECK_MASTER:.+]]
   //
   // CHECK: [[WORKER]]
   // CHECK: {{call|invoke}} void [[T1]]_worker()
   // CHECK: br label {{%?}}[[EXIT]]
   //
-  // CHECK: [[MASTER]]
-  // CHECK: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
-  // CHECK: call void @__kmpc_kernel_init(i32 0, i32 [[TID]])
-  // CHECK: br label {{%?}}[[TERM:.+]]
+  // CHECK: [[CHECK_MASTER]]
+  // CHECK-DAG: [[CMTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-DAG: [[CMNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-DAG: [[CMWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK: [[CMTMP1:%.+]] = sub i32 [[CMWS]], 1
+  // CHECK: [[CMTMP2:%.+]] = sub i32 [[CMNTH]], 1
+  // CHECK: [[MID:%.+]] = and i32 [[CMTMP2]],
+  // CHECK: [[IS_MASTER:%.+]] = icmp eq i32 [[CMTID]], [[MID]]
+  // CHECK: br i1 [[IS_MASTER]], label {{%?}}[[MASTER:.+]], label {{%?}}[[EXIT]]
   //
-  // CHECK: [[TERM]]
-  // CHECK: store i64 0, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK: [[MASTER]]
+  // CHECK-DAG: [[MNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK: [[MTMP1:%.+]] = sub i32 [[MNTH]], [[MWS]]
+  // CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]]
+  // CHECK: br label {{%?}}[[TERMINATE:.+]]
+  //
+  // CHECK: [[TERMINATE]]
+  // CHECK: call void @__kmpc_kernel_deinit()
   // CHECK: call void @llvm.nvvm.barrier0

[PATCH] D28144: clang support for Mageia 6 distro

2016-12-28 Thread Mika Laitio via Phabricator via cfe-commits
lamikr created this revision.
lamikr added a subscriber: cfe-commits.
Herald added subscribers: srhines, danalbert, aemerson.

- add Mageia definition and IsMageia method
- add Mageia name for triples arrays used for x86, x86_64 and 32-bit ARM soft 
and hard floating point toolchains
- --hash-style=gnu enabled just like for RedHat and OpenSUSE
- --no-add-needed enabled
- added the detection of Mageia distro to unittests (tested on upcoming mageia 
6)


https://reviews.llvm.org/D28144

Files:
  include/clang/Driver/Distro.h
  lib/Driver/Distro.cpp
  lib/Driver/ToolChains.cpp
  unittests/Driver/DistroTest.cpp

Index: unittests/Driver/DistroTest.cpp
===
--- unittests/Driver/DistroTest.cpp
+++ unittests/Driver/DistroTest.cpp
@@ -51,6 +51,7 @@
   ASSERT_FALSE(UbuntuTrusty.IsRedhat());
   ASSERT_FALSE(UbuntuTrusty.IsOpenSUSE());
   ASSERT_FALSE(UbuntuTrusty.IsDebian());
+  ASSERT_FALSE(UbuntuTrusty.IsMageia());
 
   vfs::InMemoryFileSystem UbuntuYakketyFileSystem;
   UbuntuYakketyFileSystem.addFile("/etc/debian_version", 0,
@@ -80,6 +81,7 @@
   ASSERT_FALSE(UbuntuYakkety.IsRedhat());
   ASSERT_FALSE(UbuntuYakkety.IsOpenSUSE());
   ASSERT_FALSE(UbuntuYakkety.IsDebian());
+  ASSERT_FALSE(UbuntuYakkety.IsMageia());
 }
 
 TEST(DistroTest, DetectRedhat) {
@@ -114,6 +116,7 @@
   ASSERT_TRUE(Fedora25.IsRedhat());
   ASSERT_FALSE(Fedora25.IsOpenSUSE());
   ASSERT_FALSE(Fedora25.IsDebian());
+  ASSERT_FALSE(Fedora25.IsMageia());
 
   vfs::InMemoryFileSystem CentOS7FileSystem;
   CentOS7FileSystem.addFile("/etc/system-release-cpe", 0,
@@ -150,6 +153,7 @@
   ASSERT_TRUE(CentOS7.IsRedhat());
   ASSERT_FALSE(CentOS7.IsOpenSUSE());
   ASSERT_FALSE(CentOS7.IsDebian());
+  ASSERT_FALSE(CentOS7.IsMageia());
 }
 
 TEST(DistroTest, DetectOpenSUSE) {
@@ -177,6 +181,7 @@
   ASSERT_FALSE(OpenSUSELeap421.IsRedhat());
   ASSERT_TRUE(OpenSUSELeap421.IsOpenSUSE());
   ASSERT_FALSE(OpenSUSELeap421.IsDebian());
+  ASSERT_FALSE(OpenSUSELeap421.IsMageia());
 
   vfs::InMemoryFileSystem OpenSUSE132FileSystem;
   OpenSUSE132FileSystem.addFile("/etc/SuSE-release", 0,
@@ -202,6 +207,7 @@
   ASSERT_FALSE(OpenSUSE132.IsRedhat());
   ASSERT_TRUE(OpenSUSE132.IsOpenSUSE());
   ASSERT_FALSE(OpenSUSE132.IsDebian());
+  ASSERT_FALSE(OpenSUSE132.IsMageia());
 
   vfs::InMemoryFileSystem SLES10FileSystem;
   SLES10FileSystem.addFile("/etc/SuSE-release", 0,
@@ -218,6 +224,7 @@
   ASSERT_FALSE(SLES10.IsRedhat());
   ASSERT_FALSE(SLES10.IsOpenSUSE());
   ASSERT_FALSE(SLES10.IsDebian());
+  ASSERT_FALSE(SLES10.IsMageia());
 }
 
 TEST(DistroTest, DetectDebian) {
@@ -240,6 +247,7 @@
   ASSERT_FALSE(DebianJessie.IsRedhat());
   ASSERT_FALSE(DebianJessie.IsOpenSUSE());
   ASSERT_TRUE(DebianJessie.IsDebian());
+  ASSERT_FALSE(DebianJessie.IsMageia());
 
   vfs::InMemoryFileSystem DebianStretchSidFileSystem;
   DebianStretchSidFileSystem.addFile("/etc/debian_version", 0,
@@ -258,6 +266,7 @@
   ASSERT_FALSE(DebianStretchSid.IsRedhat());
   ASSERT_FALSE(DebianStretchSid.IsOpenSUSE());
   ASSERT_TRUE(DebianStretchSid.IsDebian());
+  ASSERT_FALSE(DebianStretchSid.IsMageia());
 }
 
 TEST(DistroTest, DetectExherbo) {
@@ -279,6 +288,7 @@
   ASSERT_FALSE(Exherbo.IsRedhat());
   ASSERT_FALSE(Exherbo.IsOpenSUSE());
   ASSERT_FALSE(Exherbo.IsDebian());
+  ASSERT_FALSE(Exherbo.IsMageia());
 }
 
 TEST(DistroTest, DetectArchLinux) {
@@ -300,6 +310,32 @@
   ASSERT_FALSE(ArchLinux.IsRedhat());
   ASSERT_FALSE(ArchLinux.IsOpenSUSE());
   ASSERT_FALSE(ArchLinux.IsDebian());
+  ASSERT_FALSE(ArchLinux.IsMageia());
 }
 
+TEST(DistroTest, DetectMageia) {
+  vfs::InMemoryFileSystem curDistroFS;
+  curDistroFS.addFile("/etc/mageia-release", 0, // (empty)
+ llvm::MemoryBuffer::getMemBuffer(""));
+  curDistroFS.addFile("/etc/os-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("NAME=\"Mageia\"\n"
+   "VERSION=\"6\"\n"
+   "ID=mageia\n"
+   "VERSION_ID=6\n"
+   "ID_LIKE=\"mandriva fedora\"\n"
+   "PRETTY_NAME=\"Mageia 6\"\n"
+   "ANSI_COLOR=\"1;36\"\n"
+   "HOME_URL=\"http://www.mageia.org/\"\n";
+   "SUPPORT_URL=\"http://www.mageia.org/support/\"\n";
+   "BUG_REPORT_URL=\"https://bugs.mageia.org/\"\n";
+   "PRIVACY_POLICY_URL=\"https://wiki.mageia.org/en/Privacy_policy\"\n";));
+  Distro curDistro{curDistroFS};
+  ASSERT_EQ(Distro(Distro::Mageia), curDistro);
+  ASSERT_FALSE(curDistro.IsUbuntu());
+  ASSERT_FALSE(curDistro.IsRedhat());
+  ASSERT_FALSE(curDistro.IsOpenSUSE());
+  ASSERT_FALSE(curDistro.IsDebian());
+  ASSERT_TRUE(curDistro.IsMageia());
+}
+
 } // end anonymous namespace
Index: lib/Driver/ToolChains.cpp
==

[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.

2016-12-28 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: ABataev, sfantao, carlo.bertolli, kkwli0, caomhin.
arpith-jacob added a subscriber: cfe-commits.
Herald added a subscriber: jholewinski.

This patch introduces support for the execution of parallel constructs in a 
target
region on the NVPTX device.  Parallel regions must be in the lexical scope of 
the
target directive.

The master thread in the master warp signals parallel work for worker threads 
in worker
warps on encountering a parallel region.

Note: The patch does not yet support capture of arguments in a parallel region 
so
the test cases are simple.


https://reviews.llvm.org/D28145

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_parallel_codegen.cpp

Index: test/OpenMP/nvptx_parallel_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_parallel_codegen.cpp
@@ -0,0 +1,323 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template
+tx ftemplate(int n) {
+  tx a = 0;
+  short aa = 0;
+  tx b[10];
+
+  #pragma omp target if(0)
+  {
+#pragma omp parallel
+{
+  int a = 41;
+}
+a += 1;
+  }
+
+  #pragma omp target
+  {
+#pragma omp parallel
+{
+  int a = 42;
+}
+#pragma omp parallel if(0)
+{
+  int a = 43;
+}
+#pragma omp parallel if(1)
+{
+  int a = 44;
+}
+a += 1;
+  }
+
+  #pragma omp target if(n>40)
+  {
+#pragma omp parallel if(n>1000)
+{
+  int a = 45;
+}
+a += 1;
+aa += 1;
+b[2] += 1;
+  }
+
+  return a;
+}
+
+int bar(int n){
+  int a = 0;
+
+  a += ftemplate(n);
+
+  return a;
+}
+
+  // CHECK-NOT: define {{.*}}void {{@__omp_offloading_.+template.+l17}}_worker()
+
+
+
+
+
+
+  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l26}}_worker()
+  // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8,
+  // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*,
+  // CHECK: store i8* null, i8** [[OMP_WORK_FN]],
+  // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]],
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK: call void @llvm.nvvm.barrier0()
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
+  // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
+  // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null
+  // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]]
+  // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0
+  // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]]
+  //
+  // CHECK: [[EXEC_PARALLEL]]
+  // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*)
+  // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]]
+  //
+  // CHECK: [[EXEC_PFN1]]
+  // CHECK: call void [[PARALLEL_FN1]](
+  // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[CHECK_NEXT1]]
+  // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*)
+  // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]]
+  //
+  // CHECK: [[EXEC_PFN2]]
+  // CHECK: call void [[PARALLEL_FN2]](
+  // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[CHECK_NEXT2]]
+  // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+ 

[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.

2016-12-28 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:114
   /// \brief Get the name of the capture helper.
-  StringRef getHelperName() const override { return ".omp_outlined."; }
+  StringRef getHelperName() const override { return "__omp_outlined__"; }
 

On the nvptx device, it is illegal for an identifier to contain a dot ('.') so 
I've modified it here.  If there is a better way to do this, please let me know.


https://reviews.llvm.org/D28145



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


[PATCH] D28146: [compiler-rt] [test] [builtins] Remove obsolete/UB tests in __fixuns?fdi based

2016-12-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: ddunbar, sdmitrouk, dschuff.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: mehdi_amini, dberris.

Remove the failing tests for __fixunssfdi() and __fixunsdfdi() that
relied on undefined (and most likely obsolete in terms of compiler-rt
implementation behavior).

Both tests presumed that 0x1.p+64 would be converted to
0xLL, that is the largest value in uint64 range.
However, the C/C++ standards do not specify the behavior for converting
a floating-point value to an integer of smaller range, and in this case
both libgcc and compiler-rt implementations return 0 instead.

Since the current behavior is correct with regards to standards
and there is no good way of expressing 0xLL in single-
or double-precision float, I've removed the failing test altogether.


https://reviews.llvm.org/D28146

Files:
  test/builtins/Unit/fixunsdfdi_test.c
  test/builtins/Unit/fixunssfdi_test.c


Index: test/builtins/Unit/fixunssfdi_test.c
===
--- test/builtins/Unit/fixunssfdi_test.c
+++ test/builtins/Unit/fixunssfdi_test.c
@@ -79,8 +79,6 @@
 return 1;
 if (test__fixunssfdi(0x1.00p+63F, 0x8000LL))
 return 1;
-if (test__fixunssfdi(0x1.00p+64F, 0xLL))
-return 1;
 if (test__fixunssfdi(0x1.FEp+62F, 0x7F80LL))
 return 1;
 if (test__fixunssfdi(0x1.FCp+62F, 0x7F00LL))
Index: test/builtins/Unit/fixunsdfdi_test.c
===
--- test/builtins/Unit/fixunsdfdi_test.c
+++ test/builtins/Unit/fixunsdfdi_test.c
@@ -95,9 +95,6 @@
 if (test__fixunsdfdi(0x1.Ep+62, 0x7800LL))
 return 1;
 
-if (test__fixunsdfdi(0x1.p+64, 0xLL))
-return 1;
-
 #if !TARGET_LIBGCC
 if (test__fixunsdfdi(-0x1.Fp+62, 0))
 return 1;


Index: test/builtins/Unit/fixunssfdi_test.c
===
--- test/builtins/Unit/fixunssfdi_test.c
+++ test/builtins/Unit/fixunssfdi_test.c
@@ -79,8 +79,6 @@
 return 1;
 if (test__fixunssfdi(0x1.00p+63F, 0x8000LL))
 return 1;
-if (test__fixunssfdi(0x1.00p+64F, 0xLL))
-return 1;
 if (test__fixunssfdi(0x1.FEp+62F, 0x7F80LL))
 return 1;
 if (test__fixunssfdi(0x1.FCp+62F, 0x7F00LL))
Index: test/builtins/Unit/fixunsdfdi_test.c
===
--- test/builtins/Unit/fixunsdfdi_test.c
+++ test/builtins/Unit/fixunsdfdi_test.c
@@ -95,9 +95,6 @@
 if (test__fixunsdfdi(0x1.Ep+62, 0x7800LL))
 return 1;
 
-if (test__fixunsdfdi(0x1.p+64, 0xLL))
-return 1;
-
 #if !TARGET_LIBGCC
 if (test__fixunsdfdi(-0x1.Fp+62, 0))
 return 1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28148: [Sema] Suppress warnings for C's zero initializer

2016-12-28 Thread S. Gilles via Phabricator via cfe-commits
sgilles created this revision.
sgilles added reviewers: cfe-commits, rsmith, zaks.anna.

Add ZeroInitializer as a language option, attached to all standards of
C. Relax checks for -Wmissing-field-initializers and -Wmissing-braces so
that, for such languages, assigning to a structure with { 0 } produces
no warnings.  Add tests.

This fixes PR21689, which is mentioned by the Austin Group at
http://austingroupbugs.net/view.php?id=918 .  It does not extend this
treatment of { 0 } to C++.

Patch by S. Gilles


https://reviews.llvm.org/D28148

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Frontend/LangStandard.h
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaInit.cpp
  test/Sema/zero-initializer.c

Index: test/Sema/zero-initializer.c
===
--- /dev/null
+++ test/Sema/zero-initializer.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c99 -Wmissing-field-initializers -Wmissing-braces
+
+struct foo {
+/* */
+int x;
+int y;
+};
+
+struct bar {
+/* */
+struct foo a;
+struct foo b;
+};
+
+int main(void)
+{
+struct foo f = { 0 }; // expected-no-diagnostics
+struct foo g = { 9 }; // expected-warning {{missing field 'y' initializer}}
+struct foo h = { 9, 9 }; // expected-no-diagnostics
+struct bar i = { 0 }; // expected-no-diagnostics
+struct bar j = { 0, 0 }; // expected-warning {{suggest braces around initialization of suboject}} expected-warning {{missing field 'b' initializer}}
+struct bar k = { { 9, 9 }, { 9, 9 } }; // expected-no-diagnostics
+struct bar l = { { 9, 9 }, { 0 } }; // expected-no-diagnostics
+struct bar m = { { 0 }, { 0 } }; // expected-no-diagnostics
+struct bar n = { { 0 }, { 9, 9 } }; // expected-no-diagnostics
+struct bar o = { { 9, 9 }, { 0 } }; // expected-no-diagnostics
+struct bar p = { { 9 }, { 9, 9 } }; // expected-warning {{missing field 'y' initializer}}
+
+return f.x + g.x + h.x + i.a.x + j.a.x + k.a.x + l.a.x + m.a.x + n.a.x +
+   o.a.x + p.a.x;
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -880,8 +880,19 @@
   StructuredSubobjectInitList->setRBraceLoc(EndLoc);
 }
 
+bool MissingBracesOkay = false;
+
+if (SemaRef.getLangOpts().ZeroInitializer &&
+StructuredSubobjectInitList->getNumInits() == 1) {
+  if (const IntegerLiteral *lit = dyn_cast(StructuredSubobjectInitList->getInit(0))) {
+if (lit->getValue() == 0) {
+  MissingBracesOkay = true;
+}
+  }
+}
+
 // Complain about missing braces.
-if (T->isArrayType() || T->isRecordType()) {
+if (!MissingBracesOkay && (T->isArrayType() || T->isRecordType())) {
   SemaRef.Diag(StructuredSubobjectInitList->getLocStart(),
diag::warn_missing_braces)
   << StructuredSubobjectInitList->getSourceRange()
@@ -1828,6 +1839,17 @@
   RecordDecl *RD = DeclType->getAs()->getDecl();
   RecordDecl::field_iterator FieldEnd = RD->field_end();
   bool CheckForMissingFields = true;
+
+  // Check if this is C's zero initializer { 0 }
+  if (SemaRef.getLangOpts().ZeroInitializer &&
+  IList->getNumInits() == 1) {
+if (const IntegerLiteral *lit = dyn_cast(IList->getInit(0))) {
+  if (lit->getValue() == 0) {
+CheckForMissingFields = false;
+  }
+}
+  }
+
   while (Index < IList->getNumInits()) {
 Expr *Init = IList->getInit(Index);
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1599,6 +1599,7 @@
   Opts.GNUInline = Std.isC89();
   Opts.HexFloats = Std.hasHexFloats();
   Opts.ImplicitInt = Std.hasImplicitInt();
+  Opts.ZeroInitializer = Std.hasZeroInitializer();
 
   // Set OpenCL Version.
   Opts.OpenCL = isOpenCL(LangStd) || IK == IK_OpenCL;
Index: include/clang/Frontend/LangStandards.def
===
--- include/clang/Frontend/LangStandards.def
+++ include/clang/Frontend/LangStandards.def
@@ -30,66 +30,66 @@
 // C89-ish modes.
 LANGSTANDARD(c89, "c89",
  "ISO C 1990",
- C89 | ImplicitInt)
+ C89 | ImplicitInt | ZeroInitializer)
 LANGSTANDARD(c90, "c90",
  "ISO C 1990",
- C89 | ImplicitInt)
+ C89 | ImplicitInt | ZeroInitializer)
 LANGSTANDARD(iso9899_1990, "iso9899:1990",
  "ISO C 1990",
- C89 | ImplicitInt)
+ C89 | ImplicitInt | ZeroInitializer)
 
 LANGSTANDARD(c94, "iso9899:199409",
  "ISO C 1990 with amendment 1",
- C89 | Digraphs | ImplicitInt)
+ C89 | Digraphs | ImplicitInt | ZeroInitializer)
 
 LANGSTANDARD(gnu89

[PATCH] D28148: [Sema] Suppress warnings for C's zero initializer

2016-12-28 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Why are you adding a language option for this? Just use `!LangOpts.CPlusPlus`.


https://reviews.llvm.org/D28148



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


[PATCH] D26882: Refactor how FunctionDecl handles constexpr:

2016-12-28 Thread Nathan Wilson via Phabricator via cfe-commits
nwilson added a comment.

Small Ping. @rsmith - did you have anymore thoughts about this patch?


https://reviews.llvm.org/D26882



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


[PATCH] D28148: [Sema] Suppress warnings for C's zero initializer

2016-12-28 Thread S. Gilles via Phabricator via cfe-commits
sgilles added a comment.

In https://reviews.llvm.org/D28148#632002, @rsmith wrote:

> Why are you adding a language option for this? Just use `!LangOpts.CPlusPlus`.


I didn't want to have this change accidentally apply to other, non-C++ 
languages, since I'm not sure which languages would go through this path 
(Objective C, perhaps).  If that's not a problem,  I'll remove the language 
option and switch the checks to `!LangOpts.CPlusPlus`, which should be much 
cleaner.


https://reviews.llvm.org/D28148



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


[PATCH] D28148: [Sema] Suppress warnings for C's zero initializer

2016-12-28 Thread S. Gilles via Phabricator via cfe-commits
sgilles updated the summary for this revision.
sgilles updated this revision to Diff 82638.
sgilles added a comment.

Instead of adding a language option to distinguish C, negatively check
against C++.


https://reviews.llvm.org/D28148

Files:
  lib/Sema/SemaInit.cpp
  test/Sema/zero-initializer.c


Index: test/Sema/zero-initializer.c
===
--- /dev/null
+++ test/Sema/zero-initializer.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c99 -Wmissing-field-initializers -Wmissing-braces
+
+struct foo {
+  int x;
+  int y;
+};
+
+struct bar {
+  struct foo a;
+  struct foo b;
+};
+
+int main(void)
+{
+  struct foo f = { 0 }; // expected-no-diagnostics
+  struct foo g = { 9 }; // expected-warning {{missing field 'y' initializer}}
+  struct foo h = { 9, 9 }; // expected-no-diagnostics
+  struct bar i = { 0 }; // expected-no-diagnostics
+  struct bar j = { 0, 0 }; // expected-warning {{suggest braces around 
initialization of suboject}} expected-warning {{missing field 'b' initializer}}
+  struct bar k = { { 9, 9 }, { 9, 9 } }; // expected-no-diagnostics
+  struct bar l = { { 9, 9 }, { 0 } }; // expected-no-diagnostics
+  struct bar m = { { 0 }, { 0 } }; // expected-no-diagnostics
+  struct bar n = { { 0 }, { 9, 9 } }; // expected-no-diagnostics
+  struct bar o = { { 9, 9 }, { 0 } }; // expected-no-diagnostics
+  struct bar p = { { 9 }, { 9, 9 } }; // expected-warning {{missing field 'y' 
initializer}}
+
+  return f.x + g.x + h.x + i.a.x + j.a.x + k.a.x + l.a.x + m.a.x + n.a.x +
+ o.a.x + p.a.x;
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -880,8 +880,19 @@
   StructuredSubobjectInitList->setRBraceLoc(EndLoc);
 }
 
+bool MissingBracesOkay = false;
+
+if (!SemaRef.getLangOpts().CPlusPlus &&
+StructuredSubobjectInitList->getNumInits() == 1) {
+  if (const IntegerLiteral *lit = 
dyn_cast(StructuredSubobjectInitList->getInit(0))) {
+if (lit->getValue() == 0) {
+  MissingBracesOkay = true;
+}
+  }
+}
+
 // Complain about missing braces.
-if (T->isArrayType() || T->isRecordType()) {
+if (!MissingBracesOkay && (T->isArrayType() || T->isRecordType())) {
   SemaRef.Diag(StructuredSubobjectInitList->getLocStart(),
diag::warn_missing_braces)
   << StructuredSubobjectInitList->getSourceRange()
@@ -1828,6 +1839,17 @@
   RecordDecl *RD = DeclType->getAs()->getDecl();
   RecordDecl::field_iterator FieldEnd = RD->field_end();
   bool CheckForMissingFields = true;
+
+  // Check if this is C's zero initializer { 0 }
+  if (!SemaRef.getLangOpts().CPlusPlus &&
+  IList->getNumInits() == 1) {
+if (const IntegerLiteral *lit = 
dyn_cast(IList->getInit(0))) {
+  if (lit->getValue() == 0) {
+CheckForMissingFields = false;
+  }
+}
+  }
+
   while (Index < IList->getNumInits()) {
 Expr *Init = IList->getInit(Index);
 


Index: test/Sema/zero-initializer.c
===
--- /dev/null
+++ test/Sema/zero-initializer.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c99 -Wmissing-field-initializers -Wmissing-braces
+
+struct foo {
+  int x;
+  int y;
+};
+
+struct bar {
+  struct foo a;
+  struct foo b;
+};
+
+int main(void)
+{
+  struct foo f = { 0 }; // expected-no-diagnostics
+  struct foo g = { 9 }; // expected-warning {{missing field 'y' initializer}}
+  struct foo h = { 9, 9 }; // expected-no-diagnostics
+  struct bar i = { 0 }; // expected-no-diagnostics
+  struct bar j = { 0, 0 }; // expected-warning {{suggest braces around initialization of suboject}} expected-warning {{missing field 'b' initializer}}
+  struct bar k = { { 9, 9 }, { 9, 9 } }; // expected-no-diagnostics
+  struct bar l = { { 9, 9 }, { 0 } }; // expected-no-diagnostics
+  struct bar m = { { 0 }, { 0 } }; // expected-no-diagnostics
+  struct bar n = { { 0 }, { 9, 9 } }; // expected-no-diagnostics
+  struct bar o = { { 9, 9 }, { 0 } }; // expected-no-diagnostics
+  struct bar p = { { 9 }, { 9, 9 } }; // expected-warning {{missing field 'y' initializer}}
+
+  return f.x + g.x + h.x + i.a.x + j.a.x + k.a.x + l.a.x + m.a.x + n.a.x +
+ o.a.x + p.a.x;
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -880,8 +880,19 @@
   StructuredSubobjectInitList->setRBraceLoc(EndLoc);
 }
 
+bool MissingBracesOkay = false;
+
+if (!SemaRef.getLangOpts().CPlusPlus &&
+StructuredSubobjectInitList->getNumInits() == 1) {
+  if (const IntegerLiteral *lit = dyn_cast(StructuredSubobjectInitList->getInit(0))) {
+if (lit->getValue() == 0) {
+  MissingBracesOkay = true;
+}
+  }
+}
+
 // Complain about missing braces.
-if (T->isArrayType() || T->isRecordType()) {
+if (!Mi

[PATCH] D28153: [clang] Fix clean build of generate-order-file

2016-12-28 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.
alexshap added reviewers: beanz, bogner.
alexshap added a subscriber: cfe-commits.
alexshap set the repository for this revision to rL LLVM.
Herald added a subscriber: mgorny.

This diff fixes the clean build of the target generate-order-file.
In llvm/tools/clang/CMakeLists.txt 
add_subdirectory(utils/perf-training) should go after the block where 
the value of the variable CLANG_ORDER_FILE is set - otherwise 
(tested with cmake's version 3.6.2) the arguments of perf-helper.py 
gen-order-file
will be ill-formed (CLANG_ORDER_FILE will be empty).


Repository:
  rL LLVM

https://reviews.llvm.org/D28153

Files:
  CMakeLists.txt
  utils/perf-training/CMakeLists.txt


Index: utils/perf-training/CMakeLists.txt
===
--- utils/perf-training/CMakeLists.txt
+++ utils/perf-training/CMakeLists.txt
@@ -56,6 +56,10 @@
 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
 COMMENT "Clearing old dtrace data")
 
+  if (NOT CLANG_ORDER_FILE)
+message(FATAL_ERROR "Output clang order file is not set")
+  endif()
+
   add_custom_target(generate-order-file
 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
gen-order-file --binary $ --output ${CLANG_ORDER_FILE} 
${CMAKE_CURRENT_BINARY_DIR}
 COMMENT "Generating order file"
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -421,6 +421,29 @@
 endif()
 add_subdirectory(examples)
 
+if(APPLE)
+  # this line is needed as a cleanup to ensure that any CMakeCaches with the 
old
+  # default value get updated to the new default.
+  if(CLANG_ORDER_FILE STREQUAL "")
+unset(CLANG_ORDER_FILE CACHE)
+unset(CLANG_ORDER_FILE)
+  endif()
+
+
+  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
+"Order file to use when compiling clang in order to improve startup time 
(Darwin Only - requires ld64).")
+
+  if(CLANG_ORDER_FILE AND NOT EXISTS ${CLANG_ORDER_FILE})
+string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
+if(PATH_START EQUAL 0)
+  file(WRITE ${CLANG_ORDER_FILE} "\n")
+else()
+  message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not 
exist.")
+endif()
+  endif()
+endif()
+
+
 if( CLANG_INCLUDE_TESTS )
   if(EXISTS 
${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h)
 add_subdirectory(unittests)
@@ -455,29 +478,6 @@
   add_subdirectory(docs)
 endif()
 
-
-if(APPLE)
-  # this line is needed as a cleanup to ensure that any CMakeCaches with the 
old
-  # default value get updated to the new default.
-  if(CLANG_ORDER_FILE STREQUAL "")
-unset(CLANG_ORDER_FILE CACHE)
-unset(CLANG_ORDER_FILE)
-  endif()
-
-
-  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
-"Order file to use when compiling clang in order to improve startup time 
(Darwin Only - requires ld64).")
-
-  if(CLANG_ORDER_FILE AND NOT EXISTS ${CLANG_ORDER_FILE})
-string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
-if(PATH_START EQUAL 0)
-  file(WRITE ${CLANG_ORDER_FILE} "\n")
-else()
-  message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not 
exist.")
-endif()
-  endif()
-endif()
-
 add_subdirectory(cmake/modules)
 
 if(CLANG_STAGE)


Index: utils/perf-training/CMakeLists.txt
===
--- utils/perf-training/CMakeLists.txt
+++ utils/perf-training/CMakeLists.txt
@@ -56,6 +56,10 @@
 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
 COMMENT "Clearing old dtrace data")
 
+  if (NOT CLANG_ORDER_FILE)
+message(FATAL_ERROR "Output clang order file is not set")
+  endif()
+
   add_custom_target(generate-order-file
 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py gen-order-file --binary $ --output ${CLANG_ORDER_FILE} ${CMAKE_CURRENT_BINARY_DIR}
 COMMENT "Generating order file"
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -421,6 +421,29 @@
 endif()
 add_subdirectory(examples)
 
+if(APPLE)
+  # this line is needed as a cleanup to ensure that any CMakeCaches with the old
+  # default value get updated to the new default.
+  if(CLANG_ORDER_FILE STREQUAL "")
+unset(CLANG_ORDER_FILE CACHE)
+unset(CLANG_ORDER_FILE)
+  endif()
+
+
+  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
+"Order file to use when compiling clang in order to improve startup time (Darwin Only - requires ld64).")
+
+  if(CLANG_ORDER_FILE AND NOT EXISTS ${CLANG_ORDER_FILE})
+string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
+if(PATH_START EQUAL 0)
+  file

[PATCH] D28124: [OpenMP] Code cleanup for NVPTX OpenMP codegen

2016-12-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

LG


https://reviews.llvm.org/D28124



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


[PATCH] D28125: [OpenMP] Update target codegen for NVPTX device.

2016-12-28 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/D28125



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


[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.

2016-12-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:114
   /// \brief Get the name of the capture helper.
-  StringRef getHelperName() const override { return ".omp_outlined."; }
+  StringRef getHelperName() const override { return "__omp_outlined__"; }
 

arpith-jacob wrote:
> On the nvptx device, it is illegal for an identifier to contain a dot ('.') 
> so I've modified it here.  If there is a better way to do this, please let me 
> know.
Could you just override this function in CGOpenMPRuntimeNVPTX?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:127
+/// Get thread id in team.
+/// FIXME: Remove the expensive remainder operation.
+static llvm::Value *getTeamThreadId(CodeGenFunction &CGF) {

I believe this FIXME is not needed as there is already no reminder operation.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:130
+  CGBuilderTy &Bld = CGF.Builder;
+  // N % M = N & (M-1) it M is a power of 2. The master Id is expected to be a
+  // power of two in all cases.

s/it/if/g?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:325-326
+// Try to match this outlined function.
+auto ID = Bld.CreatePtrToInt(W, CGM.Int64Ty);
+ID = Bld.CreateIntToPtr(ID, CGM.Int8PtrTy);
+llvm::Value *WorkFnMatch =

Why you need double casting, could you just use 
Bld.CreatePointerBitCastOrAddrSpaceCast()?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:339
+// FIXME: Pass arguments to outlined function from master thread.
+auto Fn = cast(W);
+Address ZeroAddr =

auto *



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:343-345
+llvm::SmallVector FnArgs;
+FnArgs.push_back(ZeroAddr.getPointer());
+FnArgs.push_back(ZeroAddr.getPointer());

Could you use just an array here instead of SmallVector?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:358
+  createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_end_parallel),
+  ArrayRef());
   CGF.EmitBranch(BarrierBB);

Use llvm::None instead of default constructor.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:561
+OutlinedFnArgs.push_back(
+llvm::Constant::getNullValue(CGM.Int32Ty->getPointerTo()));
+OutlinedFnArgs.push_back(

use llvm::ConstantPointerNull::get() instead.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:563
+OutlinedFnArgs.push_back(
+llvm::Constant::getNullValue(CGM.Int32Ty->getPointerTo()));
+OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());

use llvm::ConstantPointerNull::get() instead.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:573-575
+  if (IfCond) {
+emitOMPIfClause(CGF, IfCond, L0ParallelGen, SeqGen);
+  } else {

No need for braces in one-line substatement


https://reviews.llvm.org/D28145



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