[PATCH] D100368: [X86] Support some missing intrinsics

2021-04-19 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100368/new/

https://reviews.llvm.org/D100368

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


[PATCH] D99160: [X86][FastISEL] Support DW_TAG_call_site_parameter with FastISEL

2021-04-19 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok added a comment.

In D99160#2699038 , @dblaikie wrote:

> In D99160#2698980 , @alok wrote:
>
>> In D99160#2671899 , @dblaikie wrote:
>>
>>> In D99160#2670460 , @djtodoro 
>>> wrote:
>>>
 In D99160#2669576 , @dblaikie 
 wrote:

> In D99160#2668977 , @djtodoro 
> wrote:
>
>> I think that the Debug Entry Values feature should not be enabled by 
>> default for non optimized code, so the 
>> `TargetOptions::ShouldEmitDebugEntryValues()` should be patched with 
>> checking of optimization level (it should be > 0).
>
> That's currently intended to be already handled by the frontend, right? 
> (clang only sets `EnableDebugEntryValues` (which 
> `ShouldEmitDebugEntryValues` checks (hmm, it checks under 'or', not 
> 'and', so I'm not sure where the "only above -O0" is implemented, but it 
> is implemented somewhere?) if optimizations are enabled, yeah?)
>
> Oh, is entry_values actually not conditionalized? It's only the call_site 
> support that's currently conditionalized on "above -O0"?

 Looks like there is no explicit check of optimization level (above "-O0"), 
 neither on frontend nor backend for entry-values generation. I think it is 
 the situation since there should not be any optimization (at least that I 
 am aware of, in the case of C/C++) that would cause the entry-values 
 generation...

> Hmm - If that's the case, and we currently have some cases where 
> entry_values are emitted at -O0, I'm not sure /not/ emitting those is the 
> right call either. If we believe/have data to show that there are so few 
> useful uses of entry_value at -O0 that it's not worth the DWARF size 
> growth to put call_sites in at -O0, then I think it might still be worth 
> leaving the entry_values in (unless they take up a bunch of extra space) 
> for the cases of mixed optimization compilation (-O0 some code you're 
> debugging, but building the rest with optimizations).

 Yeah... That is valuable example... I am thinking in that direction as 
 well, and I am closer to the enabling it for -O0 case if that is useful 
 (and there is no dramatic cost in terms of DWARF size).
>>>
>>> Does anyone have this example (where DW_OP_entry_value is used at -O0)? 
>>> It'd be great to look at it & see if it's a case of unnecessarily losing 
>>> the location, or legitimately losing it and using entry_value for 
>>> best-effort recovery (& then a question of whether the loss is appropriate 
>>> at -O0, or if we want to pessimize -O0 further to avoid the loss).
>
> I think this ^ still needs understanding/investigation. Do you have an 
> example with OP_entry_value at -O0?
>
>>> I'd worry about turning on call_sites at -O0 - there'd be a lot more calls 
>>> (especially for C++ code with lots of implicit operations), but numbers 
>>> will be needed in any case, so not worth much speculation.
>>
>> Sorry for late response.
>> I tried building  
>> https://github.com/flang-compiler/classic-flang-llvm-project.git (branch 
>> release_11x) with compiler (current patch (https://reviews.llvm.org/D99160) 
>> and https://reviews.llvm.org/D99238) with -O0 -g . 
>> Interestingly there was no difference.
>> Reason: https://reviews.llvm.org/D99238 is not sufficient for clang/clang++ 
>> to enable call-site generation with FastISel though it is sufficient for 
>> Flang compiler.
>> Below additional patch is needed to generate call-sites
>>
>>   `
>>
>> diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
>> b/clang/lib/CodeGen/CGDebugInfo.cpp
>> index a77f52bd235b..8d4e11faa018 100644
>>
>> - a/clang/lib/CodeGen/CGDebugInfo.cpp
>>
>> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
>> @@ -5149,9 +5149,9 @@ llvm::DebugLoc 
>> CGDebugInfo::SourceLocToDebugLoc(SourceLocation Loc) {
>>  }
>>
>> llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const {
>>
>> - // Call site-related attributes are only useful in optimized programs, and
>> - // when there's a possibility of debugging backtraces.
>> - if (!CGM.getLangOpts().Optimize || DebugKind == 
>> codegenoptions::NoDebugInfo ||
>>
>> +  // Call site-related attributes are useful when there's a possibility of
>> +  // debugging backtraces.
>> +  if (DebugKind == codegenoptions::NoDebugInfo ||
>>
>> DebugKind == codegenoptions::LocTrackingOnly)
>>   return llvm::DINode::FlagZero;
>>
>>   `
>>
>> With this patch Clang/Clang++ turn on LLVM IR flag 
>> "DIFlagAllCallsDescribed", in absence of this LLVM does not generate 
>> call-site.
>>
>> With the above patch applied below is the comparison of sizes of shared 
>> libraries.
>>
>> Name of 

[PATCH] D100739: [Coroutines] Handle overaligned frame allocation (2)

2021-04-19 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D100739#2700273 , @ChuanqiXu wrote:

> I hadn't looked into the details. I would try to make it.
> But from my understanding to this problem, the correct solution should remain 
> the previous behavior if the end user doesn't specify `alignas` for 
> `promise_type`. I mean, it shouldn't make so many test cases fail.

The failures mostly are due to the `llvm.coro.size()` -> `llvm.coro.size(i1 
alloc)` intrinsic signature change. The rest are due to the `align` arg of 
`llvm.coro.id` is illegal 0 in most of the tests. This patch would read that 
value causing asssertions.

>> The alloca of the raw frame pointer (suppose we insert it in the frontend) 
>> would be included in the non-overaligned frame if we don't teach CoroFrame 
>> how to elide it.
>
> It is confusing to me, maybe I need to look into the codes. First, the raw 
> frame pointer isn't inserted in the frontend. Do you mean coro.begin? Then, 
> what's the relationship between eliding and over-aligned? It also makes me 
> confused.

Since we don't know if the frame is overaligned or not until after the frame 
type is decided in CoroFrame, *suppose* we do this (adding raw frame ptr alloca 
in frontend regardless of the presence of overalignment or not) in the 
frontend, the code generated from CGCoroutine would be like this:

  %1 = alloc i8*
  %2 = malloc(x)
  store %2, %1
  ..
  ..
  %11 = load %1
  free(%11)

The alloca `%1` must be there even if the frame is not aligned. Then in the 
CoroFrame, we have to check if the frame is really overaligned and if not, 
reverse the above patterns. Otherwise, the alloca `%1` would be in the frame 
needlessly and the following optimizations could not reliably remove it.

This patch defers adding the alloca until CoroFrame where we know for sure that 
the frame is aligned.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100739/new/

https://reviews.llvm.org/D100739

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


[PATCH] D100739: [Coroutines] Handle overaligned frame allocation (2)

2021-04-19 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

I hadn't looked into the details. I would try to make it.
But from my understanding to this problem, the correct solution should remain 
the previous behavior if the end user doesn't specify `alignas` for 
`promise_type`. I mean, it shouldn't make so many test cases fail.

> The alloca of the raw frame pointer (suppose we insert it in the frontend) 
> would be included in the non-overaligned frame if we don't teach CoroFrame 
> how to elide it.

It is confusing to me, maybe I need to look into the codes. First, the raw 
frame pointer isn't inserted in the frontend. Do you mean coro.begin? Then, 
what's the relationship between eliding and over-aligned? It also makes me 
confused.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100739/new/

https://reviews.llvm.org/D100739

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


[PATCH] D99839: [C++, test] Fix typo in NSS* vars

2021-04-19 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/test/CodeGenCXX/split-stacks.cpp:30
 // CHECK-NOSEGSTK: define dso_local i32 @_Z7nosplitv() [[NSS1:#[0-9]+]] {
 // CHECK-NOSEGSTK: define linkonce_odr dso_local i32 @_Z8tnosplitIiEiv() 
[[NSS2:#[0-9]+]] comdat {
+// CHECK-NOSEGSTK-NOT: [[NSS0]] = { {{.*}} "split-stack" {{.*}} }

I find NSS2 equals to NSS0, which is `#0`. It looks good to me if this could 
handle the inconsistency.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99839/new/

https://reviews.llvm.org/D99839

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


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: ab, t.p.northover.
Herald added subscribers: ributzka, kristof.beyls.
arphaman requested review of this revision.
Herald added a project: clang.

Clang's driver currently prints out different default triples when it's invoked 
like this on Apple Silicon:

  $ clang --version
  Target: arm64-apple-darwin19.0.0
  $ clang -arch arm64 --version
  Target: aarch64-apple-darwin19.0.0

This change ensures that the driver uses the canonical arch names for a Darwin 
triple when the target triple is being printed out by the driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100807

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm64_32-link.c
  clang/test/Driver/default-toolchain.c


Index: clang/test/Driver/default-toolchain.c
===
--- clang/test/Driver/default-toolchain.c
+++ clang/test/Driver/default-toolchain.c
@@ -2,7 +2,10 @@
 // RUN: grep 'Target: x86_64-unknown-unknown' %t
 
 // RUN: %clang -target i386-apple-darwin9 -arch ppc -m64 -v 2> %t
-// RUN: grep 'Target: powerpc64-apple-darwin9' %t
+// RUN: grep 'Target: ppc64-apple-darwin9' %t
 
 // RUN: %clang -target i386-apple-darwin9 -arch ppc64 -m32 -v 2> %t
-// RUN: grep 'Target: powerpc-apple-darwin9' %t
+// RUN: grep 'Target: ppc-apple-darwin9' %t
+
+// RUN: %clang -target x86_64-apple-macos11 -arch arm64 -v 2>&1 | FileCheck 
--check-prefix=ARM64 %s
+// ARM64: Target: arm64-apple-macos11
Index: clang/test/Driver/arm64_32-link.c
===
--- clang/test/Driver/arm64_32-link.c
+++ clang/test/Driver/arm64_32-link.c
@@ -1,4 +1,4 @@
 // RUN: %clang -target x86_64-apple-darwin -arch arm64_32 
-miphoneos-version-min=8.0 %s -### 2>&1 | FileCheck %s
 
-// CHECK: "-cc1"{{.*}} "-triple" "aarch64_32-apple-ios8.0.0"
+// CHECK: "-cc1"{{.*}} "-triple" "arm64_32-apple-ios8.0.0"
 // CHECK: ld{{.*}} "-arch" "arm64_32"
Index: clang/test/Driver/aarch64-cpus.c
===
--- clang/test/Driver/aarch64-cpus.c
+++ clang/test/Driver/aarch64-cpus.c
@@ -33,7 +33,7 @@
 // ARM64E-DARWIN: "-cc1"{{.*}} "-triple" "arm64e{{.*}}" "-target-cpu" 
"apple-a12"
 
 // RUN: %clang -target arm64-apple-darwin -arch arm64_32 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64_32-DARWIN %s
-// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "aarch64_32{{.*}}" "-target-cpu" 
"apple-s4"
+// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "arm64_32{{.*}}" "-target-cpu" 
"apple-s4"
 
 // RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA35 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 
2>&1 | FileCheck -check-prefix=CA35 %s
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -237,7 +237,13 @@
   StringRef getDefaultUniversalArchName() const;
 
   std::string getTripleString() const {
-return Triple.getTriple();
+if (!Triple.isOSDarwin())
+  return Triple.getTriple();
+// Use the default architecture name (that's expected by -arch) for a
+// Darwin triple to provide consistent triple output to the user.
+llvm::Triple TT = Triple;
+TT.setArchName(getDefaultUniversalArchName());
+return TT.getTriple();
   }
 
   /// Get the toolchain's effective clang triple.


Index: clang/test/Driver/default-toolchain.c
===
--- clang/test/Driver/default-toolchain.c
+++ clang/test/Driver/default-toolchain.c
@@ -2,7 +2,10 @@
 // RUN: grep 'Target: x86_64-unknown-unknown' %t
 
 // RUN: %clang -target i386-apple-darwin9 -arch ppc -m64 -v 2> %t
-// RUN: grep 'Target: powerpc64-apple-darwin9' %t
+// RUN: grep 'Target: ppc64-apple-darwin9' %t
 
 // RUN: %clang -target i386-apple-darwin9 -arch ppc64 -m32 -v 2> %t
-// RUN: grep 'Target: powerpc-apple-darwin9' %t
+// RUN: grep 'Target: ppc-apple-darwin9' %t
+
+// RUN: %clang -target x86_64-apple-macos11 -arch arm64 -v 2>&1 | FileCheck --check-prefix=ARM64 %s
+// ARM64: Target: arm64-apple-macos11
Index: clang/test/Driver/arm64_32-link.c
===
--- clang/test/Driver/arm64_32-link.c
+++ clang/test/Driver/arm64_32-link.c
@@ -1,4 +1,4 @@
 // RUN: %clang -target x86_64-apple-darwin -arch arm64_32 -miphoneos-version-min=8.0 %s -### 2>&1 | FileCheck %s
 
-// CHECK: "-cc1"{{.*}} "-triple" "aarch64_32-apple-ios8.0.0"
+// CHECK: "-cc1"{{.*}} "-triple" "arm64_32-apple-ios8.0.0"
 // CHECK: ld{{.*}} "-arch" "arm64_32"
Index: clang/test/Driver/aarch64-cpus.c
===
--- clang/test/Driver/aarch64-cpus.c
+++ clang/test/Driver/aarch64-cpus.c
@@ -33,7 +33,7 @@
 // 

[PATCH] D100567: BPF: emit debuginfo for Function of DeclRefExpr if requested

2021-04-19 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@dblaikie I did some investigation, found the root cause and provided an 
alternative solution. Could you check whether you are okay with either approach?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100567/new/

https://reviews.llvm.org/D100567

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-19 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

So I checked gcc on godbolt since gcc docs are not so clear.

UnusedButSetParameter is ignored with:

- -Wunused alone
- -Wextra alone
- -Wall -Wunused

But works with -Wextra -Wunused or  -Wall -Wextra.

So I think we should put UnusedButSetParameter under -Wextra

  def Extra : DiagGroup<"extra", [
  DeprecatedCopy,
  MissingFieldInitializers,
  IgnoredQualifiers,
  InitializerOverrides,
  SemiBeforeMethodBody,
  MissingMethodReturnType,
  SignCompare,
  UnusedButSetParameter
  UnusedParameter,
  NullPointerArithmetic,
  EmptyInitStatement,
  StringConcatation,
  FUseLdPath,
]>;

UnusedButSetVariable is part of -Wall and -Wunused (gcc's -Wunused is enabled 
by -Wall.)

So I would just put UnusedButSetVariable under -Wunused (and -Wunused is part 
of -Wall):

  def Unused : DiagGroup<"unused",
 [UnusedArgument, UnusedButSetVariable,
  UnusedFunction, UnusedLabel,
  // UnusedParameter, (matches GCC's behavior)
  // UnusedTemplate, (clean-up libc++ before enabling)
  // UnusedMemberFunction, (clean-up llvm before 
enabling)
  UnusedPrivateField, UnusedLambdaCapture,
  UnusedLocalTypedef, UnusedValue, UnusedVariable,
  UnusedPropertyIvar]>,
  DiagCategory<"Unused Entity Issue">;

WDYT?




Comment at: clang/test/Sema/warn-unused-but-set-variables-cpp.cpp:1
+// RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused-but-set-variable -verify %s
+

I would suggest move it to clang/test/SemaCXX/warn-unused-but-set-variables.cpp


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100581/new/

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-19 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield added a comment.

In D100581#2699412 , @xbolva00 wrote:

> I am a little bit worried that another off by default warning is not ideal 
> from user point of view. Either the user simply would fail to find out that 
> there is a new option or will be surprised that gcc fires and clang does not 
> even when we claim we implemented this “gcc’s” warning.

Understood. How about putting `-Wunused-but-set-parameter` in `-Wextra` (which 
is what clang does for `-Wunused-parameter`) and `-Wunused-but-set-variable` in 
`-Wunused` (which is what gcc does)? I don't know why the parameter ones go in 
`-Wextra` and the variable ones go in `-Wunused`, but this seems most 
consistent with currrent diagnostic groups.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100581/new/

https://reviews.llvm.org/D100581

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


[PATCH] D98450: [clang] store an identifer instead of declref for ns_error_domain attribute

2021-04-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In D98450#2699970 , @arphaman wrote:

> Sorry, getting back to this only now.
>
> In D98450#2621907 , @aaron.ballman 
> wrote:
>
>> In D98450#2621877 , @MForster wrote:
>>
>>> That's ok for me. I'd suggest to wait for Aaron's feedback, because IIRC it 
>>> was his suggestion in the first place to go to declref.
>>
>> I have the same concerns with this patch as I did with the initial one, see 
>> https://reviews.llvm.org/D84005#inline-775391 -- basically, we're doing a 
>> lookup here in SemaDeclAttr.cpp and saying "I found the identifier, 
>> everything's good", then storing the identifier into the attribute so we can 
>> look it up again later, at which point looking up the identifier may find 
>> something totally unrelated to what was found in SemaDeclAttr.cpp.
>>
>>> The attribute with declref is incompatible with Apple's SDKs, as the 
>>> declref at the point of use in the attribute might not be available due to 
>>> the availability annotations on the domain declaration.
>>
>> Can you help me to understand why this isn't the expected behavior? If you 
>> name something that's not available, it seems surprising to me that it would 
>> then be available but only as one particular attribute argument.
>
> Your argument makes sense. The problem right now is that clang doesn't allow 
> the name to be used even when the user marks up availability correctly trying 
> to guard the use of the declaration. This stems from the combination of this 
> macro in Foundation:
>
>   #define NS_ERROR_ENUM(_type, _name, _domain)  \
> enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) 
> _name : _type
>
> and the fact that when the user uses it like this:
>
>   API_AVAILABLE(ios(14.0)) API_UNAVAILABLE(macos, tvos)
>   typedef NS_ERROR_ENUM(NIErrorDomain, NIErrorCode) {
>   NIErrorA = 1,
>   };
>
> which is equivalent to:
>
>   __attribute__((availability(ios,introduced=14.0))) 
> __attribute__((availability(macos,unavailable))) 
> __attribute__((availability(tvos,unavailable)))
>   NSErrorDomain const NIErrorDomain;
>   
>   __attribute__((availability(ios,introduced=14.0))) 
> __attribute__((availability(macos,unavailable))) 
> __attribute__((availability(tvos,unavailable)))
>   typedef enum NIErrorCode : NSInteger NIErrorCode; enum 
> __attribute__((ns_error_domain(NIErrorDomain))) NIErrorCode : NSInteger {
>NIErrorA = 1
>   };
>
> In this case clang doesn't know about availability on the `NIErrorDomain` 
> declaration as it's placed on the typedef, so it reports the diagnostic that 
> `NIErrorDomain` is unavailable for macOS, even though from users perspective 
> the use is guarded correctly by the `API_UNAVAILABLE(macos, tvOS)` before the 
> NS_ERROR_ENUM macro.
>
> Do you think in this case it would make sense to try to teach clang to reason 
> about this by special casing the fact that the enum declaration should check 
> if the typedef is annotated with the correct availability?

I'm thinking maybe we could have an attribute that transcribes the availability 
from the typedef to the enum, e.g.

  #define NS_ERROR_ENUM(_type, _name, _domain)  \
enum _name : _type _name; enum 
__attribute__((transcribe_availability(_name))) 
__attribute__((ns_error_domain(_domain))) _name : _type

in that case we could teach clang that the enum should take the availability 
attributes from the typedef and apply to the enum, which should solve the use 
problem in the `ns_error_domain` attribute. Or potentially clang could try to 
infer it without the new attribute just by detecting this code pattern. WDYT?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98450/new/

https://reviews.llvm.org/D98450

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


[PATCH] D98450: [clang] store an identifer instead of declref for ns_error_domain attribute

2021-04-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Sorry, getting back to this only now.

In D98450#2621907 , @aaron.ballman 
wrote:

> In D98450#2621877 , @MForster wrote:
>
>> That's ok for me. I'd suggest to wait for Aaron's feedback, because IIRC it 
>> was his suggestion in the first place to go to declref.
>
> I have the same concerns with this patch as I did with the initial one, see 
> https://reviews.llvm.org/D84005#inline-775391 -- basically, we're doing a 
> lookup here in SemaDeclAttr.cpp and saying "I found the identifier, 
> everything's good", then storing the identifier into the attribute so we can 
> look it up again later, at which point looking up the identifier may find 
> something totally unrelated to what was found in SemaDeclAttr.cpp.
>
>> The attribute with declref is incompatible with Apple's SDKs, as the declref 
>> at the point of use in the attribute might not be available due to the 
>> availability annotations on the domain declaration.
>
> Can you help me to understand why this isn't the expected behavior? If you 
> name something that's not available, it seems surprising to me that it would 
> then be available but only as one particular attribute argument.

Your argument makes sense. The problem right now is that clang doesn't allow 
the name to be used even when the user marks up availability correctly trying 
to guard the use of the declaration. This stems from the combination of this 
macro in Foundation:

  #define NS_ERROR_ENUM(_type, _name, _domain)  \
enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) 
_name : _type

and the fact that when the user uses it like this:

  API_AVAILABLE(ios(14.0)) API_UNAVAILABLE(macos, tvos)
  typedef NS_ERROR_ENUM(NIErrorDomain, NIErrorCode) {
  NIErrorA = 1,
  };

which is equivalent to:

  __attribute__((availability(ios,introduced=14.0))) 
__attribute__((availability(macos,unavailable))) 
__attribute__((availability(tvos,unavailable)))
  NSErrorDomain const NIErrorDomain;
  
  typedef enum NIErrorCode : NSInteger NIErrorCode; enum 
__attribute__((ns_error_domain(NIErrorDomain))) NIErrorCode : NSInteger {
   NIErrorA = 1
  };

In this case clang doesn't know about availability on the `NIErrorDomain` 
declaration as it's placed on the typedef, so it reports the diagnostic that 
`NIErrorDomain` is unavailable for macOS, even though from users perspective 
the use is guarded correctly by the `API_UNAVAILABLE(macos, tvOS)` before the 
NS_ERROR_ENUM macro.

Do you think in this case it would make sense to try to teach clang to reason 
about this by special casing the fact that the enum declaration should check if 
the typedef is annotated with the correct availability?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98450/new/

https://reviews.llvm.org/D98450

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


[PATCH] D100801: Thread safety analysis: Replace flags in FactEntry by SourceKind [NFC]

2021-04-19 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: aaron.ballman, delesley.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The motivation here is to make it available in the base class whether a
fact is managed or not. That would have meant three flags on the base
class, so I had a look whether we really have 8 possible combinations.

It turns out we don't: asserted and declared are obviously mutually
exclusive. Managed facts are only created when we acquire a capability
through a scoped capability. Adopting an asserted or declared lock will
not (in fact can not, because Facts are immutable) make them managed.

We probably don't want to allow adopting an asserted lock (because then
the function should probably have a release attribute, and then the
assertion is pointless), but we might at some point decide to replace a
declared fact on adoption.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100801

Files:
  clang/lib/Analysis/ThreadSafety.cpp

Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -105,32 +105,37 @@
 ///
 /// FIXME: this analysis does not currently support re-entrant locking.
 class FactEntry : public CapabilityExpr {
+public:
+  /// Where a fact comes from.
+  enum SourceKind {
+Acquired, ///< The fact has been directly acquired.
+Asserted, ///< The fact has been asserted to be held.
+Declared, ///< The fact is assumed to be held by callers.
+Managed,  ///< The fact has been acquired through a scoped capability.
+  };
+
 private:
   /// Exclusive or shared.
-  LockKind LKind;
+  LockKind LKind : 8;
+
+  // How it was acquired.
+  SourceKind Source : 8;
 
   /// Where it was acquired.
   SourceLocation AcquireLoc;
 
-  /// True if the lock was asserted.
-  bool Asserted;
-
-  /// True if the lock was declared.
-  bool Declared;
-
 public:
   FactEntry(const CapabilityExpr , LockKind LK, SourceLocation Loc,
-bool Asrt, bool Declrd = false)
-  : CapabilityExpr(CE), LKind(LK), AcquireLoc(Loc), Asserted(Asrt),
-Declared(Declrd) {}
+SourceKind Src)
+  : CapabilityExpr(CE), LKind(LK), Source(Src), AcquireLoc(Loc) {}
   virtual ~FactEntry() = default;
 
   LockKind kind() const { return LKind;  }
   SourceLocation loc() const { return AcquireLoc; }
-  bool asserted() const { return Asserted; }
-  bool declared() const { return Declared; }
 
-  void setDeclared(bool D) { Declared = D; }
+  bool asserted() const { return Source == Asserted; }
+  bool declared() const { return Source == Declared; }
+  bool managed()  const { return Source == Managed; }
 
   virtual void
   handleRemovalFromIntersection(const FactSet , FactManager ,
@@ -851,20 +856,16 @@
 namespace {
 
 class LockableFactEntry : public FactEntry {
-private:
-  /// managed by ScopedLockable object
-  bool Managed;
-
 public:
   LockableFactEntry(const CapabilityExpr , LockKind LK, SourceLocation Loc,
-bool Mng = false, bool Asrt = false)
-  : FactEntry(CE, LK, Loc, Asrt), Managed(Mng) {}
+SourceKind Src = Acquired)
+  : FactEntry(CE, LK, Loc, Src) {}
 
   void
   handleRemovalFromIntersection(const FactSet , FactManager ,
 SourceLocation JoinLoc, LockErrorKind LEK,
 ThreadSafetyHandler ) const override {
-if (!Managed && !asserted() && !negative() && !isUniversal()) {
+if (!managed() && !asserted() && !negative() && !isUniversal()) {
   Handler.handleMutexHeldEndOfScope("mutex", toString(), loc(), JoinLoc,
 LEK);
 }
@@ -903,7 +904,7 @@
 
 public:
   ScopedLockableFactEntry(const CapabilityExpr , SourceLocation Loc)
-  : FactEntry(CE, LK_Exclusive, Loc, false) {}
+  : FactEntry(CE, LK_Exclusive, Loc, Acquired) {}
 
   void addLock(const CapabilityExpr ) {
 UnderlyingMutexes.emplace_back(M.sexpr(), UCK_Acquired);
@@ -983,7 +984,7 @@
 } else {
   FSet.removeLock(FactMan, !Cp);
   FSet.addLock(FactMan,
-   std::make_unique(Cp, kind, loc, true));
+   std::make_unique(Cp, kind, loc, Managed));
 }
   }
 
@@ -1854,10 +1855,11 @@
 CapExprSet AssertLocks;
 Analyzer->getMutexIDs(AssertLocks, A, Exp, D, VD);
 for (const auto  : AssertLocks)
-  Analyzer->addLock(FSet,
-std::make_unique(
-AssertLock, LK_Exclusive, Loc, false, true),
-ClassifyDiagnostic(A));
+  Analyzer->addLock(
+  FSet,
+  std::make_unique(AssertLock, LK_Exclusive, Loc,
+  FactEntry::Asserted),
+  ClassifyDiagnostic(A));
 break;
   }
 

[PATCH] D100794: [HIP] Support overloaded math functions for hipRTC

2021-04-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a subscriber: jlebar.
tra added a comment.

LGTM overall.

@jlebar: I could use your opinion here.




Comment at: clang/lib/Headers/__clang_hip_cmath.h:341
 
-  typedef decltype(__test(std::declval<_Tp>())) type;
-  static const bool value = !std::is_same::value;
+  typedef decltype(__test(_Tp{})) type;
+  static const bool value = !is_same::value;

@jlebar : Should we expect any observable surprises here?



Comment at: clang/lib/Headers/__clang_hip_runtime_wrapper.h:76-86
+#if !defined(__HIPCC_RTC__)
 #include <__clang_cuda_math_forward_declares.h>
+#endif // __HIPCC_RTC__
 #include <__clang_hip_cmath.h>
+#if !defined(__HIPCC_RTC__)
 #include <__clang_cuda_complex_builtins.h>
 

I'd add an empty line separators between `#if/#endif` blocks.

Or, perhaps, it should be restructured as 
```
#if defined(__HIPCC_RTC__)
#include <__clang_hip_cmath.h>
#else
#include <__clang_cuda_math_forward_declares.h>
#include <__clang_hip_cmath.h>
#include <__clang_cuda_complex_builtins.h>
#include 
#include 
#include 
#endif // __HIPCC_RTC__
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100794/new/

https://reviews.llvm.org/D100794

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


[PATCH] D17183: Make TargetInfo store an actual DataLayout instead of a string.

2021-04-19 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Maybe LLVM should grow an `LLVMTargetInfo` library that sits between 
`LLVMSupport` and `LLVMCore`, as a version of solution 2 that doesn't induce 
more bloating in Support.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D17183/new/

https://reviews.llvm.org/D17183

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


[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-04-19 Thread Luis Penagos via Phabricator via cfe-commits
penagos updated this revision to Diff 338648.
penagos added a comment.

Update Format test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100778/new/

https://reviews.llvm.org/D100778

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7649,6 +7649,8 @@
   verifyFormat("a = 1;", Style);
   verifyFormat("a >>= 1;", Style);
 
+  verifyFormat("test < a | b >> c;");
+  verifyFormat("test> c;");
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -119,7 +119,10 @@
 // a statement.
 if (CurrentToken->Next && CurrentToken->Next->is(tok::greater) &&
 Left->ParentBracket != tok::less &&
-isKeywordWithCondition(*Line.First))
+(isKeywordWithCondition(*Line.First) ||
+ CurrentToken->getStartOfNonWhitespace() ==
+ 
CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
   return false;
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7649,6 +7649,8 @@
   verifyFormat("a = 1;", Style);
   verifyFormat("a >>= 1;", Style);
 
+  verifyFormat("test < a | b >> c;");
+  verifyFormat("test> c;");
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -119,7 +119,10 @@
 // a statement.
 if (CurrentToken->Next && CurrentToken->Next->is(tok::greater) &&
 Left->ParentBracket != tok::less &&
-isKeywordWithCondition(*Line.First))
+(isKeywordWithCondition(*Line.First) ||
+ CurrentToken->getStartOfNonWhitespace() ==
+ CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
   return false;
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 199c397 - Revert "[clang-scan-deps] Add support for clang-cl"

2021-04-19 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2021-04-19T17:45:18-04:00
New Revision: 199c39748292cbc89cd148a0d8364ebb1014ec38

URL: 
https://github.com/llvm/llvm-project/commit/199c39748292cbc89cd148a0d8364ebb1014ec38
DIFF: 
https://github.com/llvm/llvm-project/commit/199c39748292cbc89cd148a0d8364ebb1014ec38.diff

LOG: Revert "[clang-scan-deps] Add support for clang-cl"

This reverts commit bb26fa8c286bf524ed9235c3e293ad22ecf3e984.

Added: 


Modified: 
clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
clang/test/ClangScanDeps/Inputs/headerwithdirname.json
clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
clang/test/ClangScanDeps/Inputs/no-werror.json
clang/test/ClangScanDeps/Inputs/static-analyzer-cdb.json
clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json
clang/test/ClangScanDeps/Inputs/target-filename-cdb.json
clang/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
clang/test/ClangScanDeps/error.cpp
clang/test/ClangScanDeps/has_include_if_elif.cpp
clang/test/ClangScanDeps/header_stat_before_open.m
clang/test/ClangScanDeps/headerwithdirname.cpp
clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp
clang/test/ClangScanDeps/modules-full.cpp
clang/test/ClangScanDeps/modules.cpp
clang/test/ClangScanDeps/no-werror.cpp
clang/test/ClangScanDeps/regular_cdb.cpp
clang/test/ClangScanDeps/static-analyzer.c
clang/test/ClangScanDeps/strip_diag_serialize.cpp
clang/test/ClangScanDeps/target-filename.cpp
clang/test/ClangScanDeps/vfsoverlay.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 
clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json
clang/test/ClangScanDeps/Inputs/regular_cdb_clangcl.json



diff  --git a/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json 
b/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
index 8fcc7ea34a9bc..36ca006b03297 100644
--- a/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
+++ b/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
@@ -3,10 +3,5 @@
   "directory": "DIR",
   "command": "clang -E DIR/has_include_if_elif2.cpp -IInputs",
   "file": "DIR/has_include_if_elif2.cpp"
-},
-{
-  "directory": "DIR",
-  "command": "clang-cl /E /IInputs -- DIR/has_include_if_elif2_clangcl.cpp",
-  "file": "DIR/has_include_if_elif2_clangcl.cpp"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json 
b/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
index b99b541b12986..c5f027e9fd28a 100644
--- a/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
+++ b/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
@@ -3,10 +3,5 @@
   "directory": "DIR",
   "command": "clang -E DIR/header_stat_before_open_input.m -iframework 
Inputs/frameworks",
   "file": "DIR/header_stat_before_open_input.m"
-},
-{
-  "directory": "DIR",
-  "command": "clang-cl /E -Xclang -iframework -Xclang Inputs/frameworks -- 
DIR/header_stat_before_open_input_clangcl.m",
-  "file": "DIR/header_stat_before_open_input_clangcl.m"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/headerwithdirname.json 
b/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
index ac12c92308fda..2ae561935bec3 100644
--- a/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
+++ b/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -3,10 +3,5 @@
   "directory": "DIR",
   "command": "clang -c -IDIR -IDIR/foodir -IInputs 
DIR/headerwithdirname_input.cpp",
   "file": "DIR/headerwithdirname_input.cpp"
-},
-{
-  "directory": "DIR",
-  "command": "clang-cl /c /IDIR /IDIR/foodir -IInputs -- 
DIR/headerwithdirname_input_clangcl.cpp",
-  "file": "DIR/headerwithdirname_input_clangcl.cpp"
 }
 ]

diff  --git 
a/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json 
b/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
index 1886328a9c3e9..de7759d0b110c 100644
--- a/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
+++ b/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
@@ -3,10 +3,5 @@
   "directory": "DIR",
   "command": "clang -c -IDIR -IInputs DIR/headerwithdirname_input.cpp",
   "file": "DIR/headerwithdirname_input.cpp"
-},
-{
-  "directory": "DIR",
-  "command": "clang-cl /c /IDIR /IInputs -- 
DIR/headerwithdirname_input_clangcl.cpp",
-  "file": "DIR/headerwithdirname_input_clangcl.cpp"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json 
b/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json
deleted file mode 100644
index a1f12867c45d5..0
--- a/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json
+++ /dev/null
@@ -1,22 +0,0 @@
-[
-{
-  "directory": "DIR",
-  "command": 

[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-04-19 Thread Luis Penagos via Phabricator via cfe-commits
penagos marked an inline comment as done.
penagos added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7652
 
+  verifyFormat("test < a - 1 >> 1;");
   verifyFormat("test >> a >> b;");

Quuxplusone wrote:
> Quuxplusone wrote:
> > IMO you should use `"test < a | b >> c;"` as your test case here, to 
> > reassure the reader that it doesn't depend on the fact that `... 1;` is 
> > visibly not a variable declaration.
> > Personally I'd also like to see `"test> c;"` tested on the very 
> > next line, to show off the intended difference between the two. (Assuming 
> > that I understand the intent of this patch correctly.)
> > (I also switched to a bitwise operator just for the heck of it; that makes 
> > this expression just a //very tiny bit// less implausible — but still 
> > highly implausible, to the point where I question why we're special-casing 
> > it.)
> Btw, a much-bigger-scope way to fix this would be to teach clang-format about 
> "input encoding" versus "output encoding." The only time clang-format should 
> //ever// be inserting space in the middle of `>>` is if it's translating 
> C++11-encoded input into C++03-encoded output. If the input is known to 
> already be C++03-encoded, then breaking up an `>>` token into a pair of `> >` 
> tokens is //guaranteed// to introduce a bug.
> Right now, my impression is that clang-format has a concept of "output 
> encoding" (i.e. "language mode") but has no way of knowing the "input 
> encoding."
Thanks for the feedback. Your 2 test suggestions make sense to me; I've updated 
the patch diff. I hadn't considered teaching clang-format input encoding, but 
that does sound like the preferable long term solution. This patch is intended 
to be a lightweight fix to fix a very narrow use case.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100778/new/

https://reviews.llvm.org/D100778

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


[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-04-19 Thread Luis Penagos via Phabricator via cfe-commits
penagos updated this revision to Diff 338641.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100778/new/

https://reviews.llvm.org/D100778

Files:
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7649,7 +7649,8 @@
   verifyFormat("a = 1;", Style);
   verifyFormat("a >>= 1;", Style);
 
-  verifyFormat("test < a - 1 >> 1;");
+  verifyFormat("test < a | b >> c;");
+  verifyFormat("test> c;");
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");
 


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7649,7 +7649,8 @@
   verifyFormat("a = 1;", Style);
   verifyFormat("a >>= 1;", Style);
 
-  verifyFormat("test < a - 1 >> 1;");
+  verifyFormat("test < a | b >> c;");
+  verifyFormat("test> c;");
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100794: [HIP] Support overloaded math functions for hipRTC

2021-04-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

Remove the dependence on standard C++ header
for overloaded math functions in HIP header
since standard C++ header is not available for hipRTC.


https://reviews.llvm.org/D100794

Files:
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_runtime_wrapper.h
  clang/test/Headers/hip-header.hip

Index: clang/test/Headers/hip-header.hip
===
--- clang/test/Headers/hip-header.hip
+++ clang/test/Headers/hip-header.hip
@@ -21,7 +21,21 @@
 }
 
 // CHECK-LABEL: define{{.*}} i64 @_Z11test_size_tv
-// CHEC: ret i64 8
+// CHECK: ret i64 8
 __device__ size_t test_size_t() {
   return sizeof(size_t);
 }
+
+// Check there is no ambiguity when calling overloaded math functions.
+
+// CHECK-LABEL: define{{.*}}@_Z10test_floorv
+// CHECK: call {{.*}}double @__ocml_floor_f64(double
+__device__ float test_floor() {
+  return floor(5);
+}
+
+// CHECK-LABEL: define{{.*}}@_Z8test_maxv
+// CHECK: call {{.*}}double @__ocml_fmax_f64(double {{.*}}, double
+__device__ float test_max() {
+  return max(5, 6.0);
+}
Index: clang/lib/Headers/__clang_hip_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_hip_runtime_wrapper.h
+++ clang/lib/Headers/__clang_hip_runtime_wrapper.h
@@ -72,10 +72,12 @@
 #include <__clang_hip_libdevice_declares.h>
 #include <__clang_hip_math.h>
 
-#if !defined(__HIPCC_RTC__)
 #if !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
+#if !defined(__HIPCC_RTC__)
 #include <__clang_cuda_math_forward_declares.h>
+#endif // __HIPCC_RTC__
 #include <__clang_hip_cmath.h>
+#if !defined(__HIPCC_RTC__)
 #include <__clang_cuda_complex_builtins.h>
 
 #include 
Index: clang/lib/Headers/__clang_hip_cmath.h
===
--- clang/lib/Headers/__clang_hip_cmath.h
+++ clang/lib/Headers/__clang_hip_cmath.h
@@ -22,7 +22,7 @@
 #endif
 #include 
 #include 
-#endif // __HIPCC_RTC__
+#endif // !defined(__HIPCC_RTC__)
 
 #pragma push_macro("__DEVICE__")
 #define __DEVICE__ static __device__ inline __attribute__((always_inline))
@@ -36,6 +36,9 @@
 __DEVICE__ float fma(float __x, float __y, float __z) {
   return ::fmaf(__x, __y, __z);
 }
+#if !defined(__HIPCC_RTC__)
+// The value returned by fpclassify is platform dependent, therefore it is not
+// supported by hipRTC.
 __DEVICE__ int fpclassify(float __x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
@@ -44,6 +47,8 @@
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
 }
+#endif // !defined(__HIPCC_RTC__)
+
 __DEVICE__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
@@ -209,11 +214,115 @@
 
 template  struct __hip_enable_if { typedef __T type; };
 
+namespace __hip {
+template  struct is_integral {
+  enum { value = 0 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+
+template  struct is_arithmetic {
+  enum { value = 0 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic<_Float16> {
+  enum { value = 1 };
+};
+
+struct true_type {
+  static const __constant__ 

[PATCH] D93325: Add srcloc output to clang-query

2021-04-19 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

@aaron.ballman ping?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93325/new/

https://reviews.llvm.org/D93325

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


[PATCH] D92191: [clang-scan-deps] Add support for clang-cl

2021-04-19 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added a comment.

> Thanks! We found the issue. I think I'll revert the patch, and will reland a 
> fixed version.

Great, thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92191/new/

https://reviews.llvm.org/D92191

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


[PATCH] D100712: [AST] Add NestedNameSpecifierLoc accessors to node introspection

2021-04-19 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 338631.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100712/new/

https://reviews.llvm.org/D100712

Files:
  clang/lib/Tooling/DumpTool/APIData.h
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -210,15 +210,37 @@
   llvm::sort(ExpectedLocations);
 
   // clang-format off
-  EXPECT_EQ(
-  llvm::makeArrayRef(ExpectedLocations),
-  (ArrayRef>{
+  std::vector> ActualLocations{
 STRING_LOCATION_STDPAIR(MethodDecl, getBeginLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getBodyRBrace()),
 STRING_LOCATION_STDPAIR(MethodDecl, getEndLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getInnerLocStart()),
 STRING_LOCATION_STDPAIR(MethodDecl, getLocation()),
 STRING_LOCATION_STDPAIR(MethodDecl, getOuterLocStart()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getLocalBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getLocalEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getLocalBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getLocalEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getLocalBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getLocalEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getPrefix().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getPrefix().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getPrefix().getLocalBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getPrefix().getLocalEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getTypeLoc().getAs().getLAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getTypeLoc().getAs().getRAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getTypeLoc().getAs().getTemplateNameLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getTypeLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getTypeLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getTypeLoc().getAs().getNameLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getTypeLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getTypeLoc().getEndLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLParenLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLocalRangeBegin()),
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLocalRangeEnd()),
@@ -228,6 +250,14 @@
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getAs().getTemplateNameLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getBeginLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getLocalBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getLocalEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getPrefix().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getPrefix().getEndLoc()),

[PATCH] D92191: [clang-scan-deps] Add support for clang-cl

2021-04-19 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thanks! We found the issue. I think I'll revert the patch, and will reland a 
fixed version.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92191/new/

https://reviews.llvm.org/D92191

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


[PATCH] D92191: [clang-scan-deps] Add support for clang-cl

2021-04-19 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added a comment.

> @gulfem We're taking a look now. Could you please post a link to the full 
> build log, including the cmake flags used?

This is the link to one of our failing builds:
https://ci.chromium.org/ui/p/fuchsia/builders/ci/clang-linux-arm64/b8849674814150864912/overview

Here, you can see the `cmake` flags:
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8849674814150864912/+/u/clang/configure/execution_details


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92191/new/

https://reviews.llvm.org/D92191

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


[PATCH] D99630: phase 01: add new command line flag to enable UAR in 3 modes (always, [runtime], never).

2021-04-19 Thread Kevin Athey via Phabricator via cfe-commits
kda abandoned this revision.
kda added a comment.

will attempt in smaller pieces.




Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:3317
  ConstantInt::get(IntptrTy, LocalStackSize));
-IRB.SetInsertPoint(InsBefore);
-FakeStack = createPHI(IRB, UseAfterReturnIsEnabled, FakeStackValue, Term,
-  ConstantInt::get(IntptrTy, 0));
-
-Value *NoFakeStack =
-IRB.CreateICmpEQ(FakeStack, Constant::getNullValue(IntptrTy));
-Term = SplitBlockAndInsertIfThen(NoFakeStack, InsBefore, false);
-IRBIf.SetInsertPoint(Term);
-Value *AllocaValue =
-DoDynamicAlloca ? createAllocaForLayout(IRBIf, L, true) : StaticAlloca;
-
-IRB.SetInsertPoint(InsBefore);
-LocalStackBase = createPHI(IRB, NoFakeStack, AllocaValue, Term, FakeStack);
-IRB.CreateStore(LocalStackBase, LocalStackBaseAlloca);
-DIExprFlags |= DIExpression::DerefBefore;
+  IRB.SetInsertPoint(InsBefore);
+  PHINode *FakeStack = IRB.CreatePHI(IntptrTy, 1);

I think this is where things start going wrong, but after a few hours looking, 
I'm not sure what the code should look like.
I know I don't want a branch, but I don't know how to just stick the call in to 
the stack allocator.
I think once that is right, then the pieces after it follow in a straightforwad 
manner.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99630/new/

https://reviews.llvm.org/D99630

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


[PATCH] D100776: [clang/Basic] Make TargetInfo.h not use DataLayout again

2021-04-19 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D100776#2699565 , @rnk wrote:

> Of the three people who commented on D17183 
> , you and I are on the only ones in favor of 
> this approach. I think @echristo and @jyknight both preferred approach 2. I'd 
> like to get at least an agreement to disagree from one of them before 
> approving this.

That's 50% in people, and 15/24 voting by changes that landed in clang/ since 
start of year ;) Don't know why 2/2 is "only".

I'm also not dismissing approach 2: I implemented it as well, and it's 
ready-to-go as soon as someone wants to pursue the direction mentioned there. 
If someone wants to do that, I don't have a problem with it, but until then 
this here is simpler and more self-consistent since it preserves the original 
design of TargetInfo.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100776/new/

https://reviews.llvm.org/D100776

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


[PATCH] D92191: [clang-scan-deps] Add support for clang-cl

2021-04-19 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@gulfem We're taking a look now. Could you please post a link to the full build 
log, including the cmake flags used?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92191/new/

https://reviews.llvm.org/D92191

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


[PATCH] D100673: [OPENMP]Fix PR49698: OpenMP declare mapper causes segmentation fault.

2021-04-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 338624.
ABataev added a comment.

Fixes and rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100673/new/

https://reviews.llvm.org/D100673

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  openmp/libomptarget/src/omptarget.cpp
  
openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_array.cpp
  
openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_array_subscript.cpp
  
openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_complex_structure.cpp
  
openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_ptr_subscript.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_var.cpp

Index: openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_var.cpp
===
--- /dev/null
+++ openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_var.cpp
@@ -0,0 +1,62 @@
+// RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda
+
+#include 
+#include 
+
+typedef struct {
+  int a;
+  double *b;
+} C1;
+#pragma omp declare mapper(C1 s) map(to : s.a) map(from : s.b [0:2])
+
+typedef struct {
+  int a;
+  double *b;
+  C1 c;
+} C;
+#pragma omp declare mapper(C s) map(to : s.a, s.c) map(from : s.b [0:2])
+
+typedef struct {
+  int e;
+  C f;
+  int h;
+} D;
+
+int main() {
+  constexpr int N = 10;
+  D s;
+  s.e = 111;
+  s.f.a = 222;
+  s.f.c.a = 777;
+  double x[2];
+  double x1[2];
+  x[1] = 20;
+  s.f.b = [0];
+  s.f.c.b = [0];
+  s.h = N;
+
+  printf("%d %d %d %4.5f %d\n", s.e, s.f.a, s.f.c.a, s.f.b[1],
+ s.f.b == [0] ? 1 : 0);
+  // CHECK: 111 222 777 20.0 1
+
+  __intptr_t p = reinterpret_cast<__intptr_t>([0]);
+
+#pragma omp target map(tofrom : s) firstprivate(p)
+  {
+printf("%d %d %d\n", s.f.a, s.f.c.a,
+   s.f.b == reinterpret_cast(p) ? 1 : 0);
+// CHECK: 222 777 0
+s.e = 333;
+s.f.a = 444;
+s.f.c.a = 555;
+s.f.b[1] = 40;
+  }
+
+  printf("%d %d %d %4.5f %d\n", s.e, s.f.a, s.f.c.a, s.f.b[1],
+ s.f.b == [0] ? 1 : 0);
+  // CHECK: 333 222 777 40.0 1
+}
Index: openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_ptr_subscript.cpp
===
--- /dev/null
+++ openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_ptr_subscript.cpp
@@ -0,0 +1,62 @@
+// RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda
+
+#include 
+#include 
+
+typedef struct {
+  int a;
+  double *b;
+} C1;
+#pragma omp declare mapper(C1 s) map(to : s.a) map(from : s.b [0:2])
+
+typedef struct {
+  int a;
+  double *b;
+  C1 c;
+} C;
+#pragma omp declare mapper(C s) map(to : s.a, s.c) map(from : s.b [0:2])
+
+typedef struct {
+  int e;
+  C f;
+  int h;
+} D;
+
+int main() {
+  constexpr int N = 10;
+  D s;
+  s.e = 111;
+  s.f.a = 222;
+  s.f.c.a = 777;
+  double x[2];
+  double x1[2];
+  x[1] = 20;
+  s.f.b = [0];
+  s.f.c.b = [0];
+  s.h = N;
+
+  D *sp = 
+
+  printf("%d %d %d %4.5f %d\n", sp[0].e, sp[0].f.a, sp[0].f.c.a, sp[0].f.b[1],
+ sp[0].f.b == [0] ? 1 : 0);
+  // CHECK: 111 222 777 20.0 1
+
+  __intptr_t p = reinterpret_cast<__intptr_t>([0]);
+#pragma omp target map(tofrom : sp[0]) firstprivate(p)
+  {
+printf("%d %d %d\n", sp[0].f.a, sp[0].f.c.a,
+   sp[0].f.b == reinterpret_cast(p) ? 1 : 0);
+// CHECK: 222 777 0
+sp[0].e = 333;
+sp[0].f.a = 444;
+sp[0].f.c.a = 555;
+sp[0].f.b[1] = 40;
+  }
+  printf("%d %d %d %4.5f %d\n", sp[0].e, sp[0].f.a, sp[0].f.c.a, sp[0].f.b[1],
+ sp[0].f.b == [0] ? 1 : 0);
+  // CHECK: 333 222 777 40.0 1
+}
Index: openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_complex_structure.cpp
===
--- /dev/null
+++ openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_complex_structure.cpp
@@ -0,0 +1,129 @@
+// RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu
+// RUN: 

[PATCH] D100776: [clang/Basic] Make TargetInfo.h not use DataLayout again

2021-04-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added subscribers: jyknight, echristo.
rnk added a comment.

Of the three people who commented on D17183 , 
you and I are on the only ones in favor of this approach. I think @echristo and 
@jyknight both preferred approach 2. I'd like to get at least an agreement to 
disagree from one of them before approving this.

---

I remember now that the last time this came up, we wanted to preserve the 
ability for the frontend to generate IR for any target, even if it has no 
registered backend. This means we don't need `REQUIRES: foo-registered-target` 
lines in our clang IRgen tests. LLVM keeps the data layout in the backends. 
This dependency from clangBasic to LLVMIR wasn't a major consideration at the 
time. That makes me lean a little bit towards leaving this as it is.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100776/new/

https://reviews.llvm.org/D100776

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


[PATCH] D100712: [AST] Add NestedNameSpecifierLoc accessors to node introspection

2021-04-19 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/unittests/Introspection/IntrospectionTest.cpp:280
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSpecStartLoc())
   }));
   // clang-format on

steveire wrote:
> njames93 wrote:
> > I'm not entirely sure on the case, but the windows bot is giving a [[ 
> > https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2026?view=msvc-160
> >  | C2026 ]] error here. Not entirely sure why as there is no string over 
> > the max length allowed.
> After https://reviews.llvm.org/D100720 is in, I'll push an update to fix this.
My guess is that googletest converts the macro to a string which is too long.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100712/new/

https://reviews.llvm.org/D100712

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


[PATCH] D100712: [AST] Add NestedNameSpecifierLoc accessors to node introspection

2021-04-19 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 338620.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100712/new/

https://reviews.llvm.org/D100712

Files:
  clang/lib/Tooling/DumpTool/APIData.h
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -210,15 +210,37 @@
   llvm::sort(ExpectedLocations);
 
   // clang-format off
-  EXPECT_EQ(
-  llvm::makeArrayRef(ExpectedLocations),
-  (ArrayRef>{
+  std::vector> ActualLocations{
 STRING_LOCATION_STDPAIR(MethodDecl, getBeginLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getBodyRBrace()),
 STRING_LOCATION_STDPAIR(MethodDecl, getEndLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getInnerLocStart()),
 STRING_LOCATION_STDPAIR(MethodDecl, getLocation()),
 STRING_LOCATION_STDPAIR(MethodDecl, getOuterLocStart()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getLocalBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getLocalEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getLocalBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getLocalEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getLocalBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getLocalEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getPrefix().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getPrefix().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getPrefix().getLocalBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getPrefix().getPrefix().getLocalEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getTypeLoc().getAs().getLAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getTypeLoc().getAs().getRAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getTypeLoc().getAs().getTemplateNameLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getTypeLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getTypeLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getTypeLoc().getAs().getNameLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getTypeLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getTypeLoc().getEndLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLParenLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLocalRangeBegin()),
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLocalRangeEnd()),
@@ -228,6 +250,14 @@
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getAs().getTemplateNameLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getBeginLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getLocalBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getLocalEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getPrefix().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getQualifierLoc().getPrefix().getEndLoc()),

[clang] 782c3e2 - [AST] Fix comparison to of SourceRanges in container

2021-04-19 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-04-19T21:19:21+01:00
New Revision: 782c3e23ba09ca7b01034d0fbf0b34044c1c79a3

URL: 
https://github.com/llvm/llvm-project/commit/782c3e23ba09ca7b01034d0fbf0b34044c1c79a3
DIFF: 
https://github.com/llvm/llvm-project/commit/782c3e23ba09ca7b01034d0fbf0b34044c1c79a3.diff

LOG: [AST] Fix comparison to of SourceRanges in container

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

Added: 


Modified: 
clang/lib/Tooling/NodeIntrospection.cpp
clang/unittests/Introspection/IntrospectionTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/NodeIntrospection.cpp 
b/clang/lib/Tooling/NodeIntrospection.cpp
index 6a8d7267f8ae4..8e2d446c3efec 100644
--- a/clang/lib/Tooling/NodeIntrospection.cpp
+++ b/clang/lib/Tooling/NodeIntrospection.cpp
@@ -44,9 +44,6 @@ namespace internal {
 bool RangeLessThan::operator()(
 std::pair const ,
 std::pair const ) const {
-  if (!LHS.first.isValid() || !RHS.first.isValid())
-return false;
-
   if (LHS.first.getBegin() < RHS.first.getBegin())
 return true;
   else if (LHS.first.getBegin() != RHS.first.getBegin())

diff  --git a/clang/unittests/Introspection/IntrospectionTest.cpp 
b/clang/unittests/Introspection/IntrospectionTest.cpp
index 1db3e6a8e6d65..76b47b34a7916 100644
--- a/clang/unittests/Introspection/IntrospectionTest.cpp
+++ b/clang/unittests/Introspection/IntrospectionTest.cpp
@@ -91,6 +91,20 @@ TEST(Introspection, SourceLocations_CallContainer) {
   EXPECT_EQ(slm.size(), 2u);
 }
 
+TEST(Introspection, SourceLocations_CallContainer2) {
+  SourceRangeMap slm;
+  SharedLocationCall Prefix;
+  slm.insert(
+  std::make_pair(SourceRange(), llvm::makeIntrusiveRefCnt(
+Prefix, "getCXXOperatorNameRange")));
+  EXPECT_EQ(slm.size(), 1u);
+
+  slm.insert(std::make_pair(
+  SourceRange(),
+  llvm::makeIntrusiveRefCnt(Prefix, "getSourceRange")));
+  EXPECT_EQ(slm.size(), 2u);
+}
+
 TEST(Introspection, SourceLocations_CallChainFormatting) {
   SharedLocationCall Prefix;
   auto chainedCall = llvm::makeIntrusiveRefCnt(



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


[PATCH] D100723: [AST] Fix comparison to of SourceRanges in container

2021-04-19 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG782c3e23ba09: [AST] Fix comparison to of SourceRanges in 
container (authored by stephenkelly).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100723/new/

https://reviews.llvm.org/D100723

Files:
  clang/lib/Tooling/NodeIntrospection.cpp
  clang/unittests/Introspection/IntrospectionTest.cpp


Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -91,6 +91,20 @@
   EXPECT_EQ(slm.size(), 2u);
 }
 
+TEST(Introspection, SourceLocations_CallContainer2) {
+  SourceRangeMap slm;
+  SharedLocationCall Prefix;
+  slm.insert(
+  std::make_pair(SourceRange(), llvm::makeIntrusiveRefCnt(
+Prefix, "getCXXOperatorNameRange")));
+  EXPECT_EQ(slm.size(), 1u);
+
+  slm.insert(std::make_pair(
+  SourceRange(),
+  llvm::makeIntrusiveRefCnt(Prefix, "getSourceRange")));
+  EXPECT_EQ(slm.size(), 2u);
+}
+
 TEST(Introspection, SourceLocations_CallChainFormatting) {
   SharedLocationCall Prefix;
   auto chainedCall = llvm::makeIntrusiveRefCnt(
Index: clang/lib/Tooling/NodeIntrospection.cpp
===
--- clang/lib/Tooling/NodeIntrospection.cpp
+++ clang/lib/Tooling/NodeIntrospection.cpp
@@ -44,9 +44,6 @@
 bool RangeLessThan::operator()(
 std::pair const ,
 std::pair const ) const {
-  if (!LHS.first.isValid() || !RHS.first.isValid())
-return false;
-
   if (LHS.first.getBegin() < RHS.first.getBegin())
 return true;
   else if (LHS.first.getBegin() != RHS.first.getBegin())


Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -91,6 +91,20 @@
   EXPECT_EQ(slm.size(), 2u);
 }
 
+TEST(Introspection, SourceLocations_CallContainer2) {
+  SourceRangeMap slm;
+  SharedLocationCall Prefix;
+  slm.insert(
+  std::make_pair(SourceRange(), llvm::makeIntrusiveRefCnt(
+Prefix, "getCXXOperatorNameRange")));
+  EXPECT_EQ(slm.size(), 1u);
+
+  slm.insert(std::make_pair(
+  SourceRange(),
+  llvm::makeIntrusiveRefCnt(Prefix, "getSourceRange")));
+  EXPECT_EQ(slm.size(), 2u);
+}
+
 TEST(Introspection, SourceLocations_CallChainFormatting) {
   SharedLocationCall Prefix;
   auto chainedCall = llvm::makeIntrusiveRefCnt(
Index: clang/lib/Tooling/NodeIntrospection.cpp
===
--- clang/lib/Tooling/NodeIntrospection.cpp
+++ clang/lib/Tooling/NodeIntrospection.cpp
@@ -44,9 +44,6 @@
 bool RangeLessThan::operator()(
 std::pair const ,
 std::pair const ) const {
-  if (!LHS.first.isValid() || !RHS.first.isValid())
-return false;
-
   if (LHS.first.getBegin() < RHS.first.getBegin())
 return true;
   else if (LHS.first.getBegin() != RHS.first.getBegin())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100723: [AST] Fix comparison to of SourceRanges in container

2021-04-19 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Tooling/NodeIntrospection.cpp:47
 std::pair const ) const {
-  if (!LHS.first.isValid() || !RHS.first.isValid())
-return false;

steveire wrote:
> njames93 wrote:
> > Maybe we should assert the ranges (or locations) are valid before 
> > inserting. Will require modification to the generator script but it would 
> > make subsequent handling simpler. 
> I don't think I agree, but I think that's a different patch. We should fix 
> the bug for now.
Fair enough, though this doesn't seem a great solution, Semantics of 
Sourcelocation comparisons for invalid source lox


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100723/new/

https://reviews.llvm.org/D100723

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


[PATCH] D92191: [clang-scan-deps] Add support for clang-cl

2021-04-19 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added a comment.

This seems to break our `Fucshia` builds.
If we cannot do a quick fix, we need to revert this patch.
Please see the error message below:

  FAIL: Clang :: ClangScanDeps/vfsoverlay.cpp (1863 of 27822)
   TEST 'Clang :: ClangScanDeps/vfsoverlay.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   rm -rf 
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir
  : 'RUN: at line 2';   rm -rf 
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.cdb
  : 'RUN: at line 3';   mkdir -p 
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir
  : 'RUN: at line 4';   cp 
/opt/s/w/ir/x/w/llvm-project/clang/test/ClangScanDeps/vfsoverlay.cpp 
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/vfsoverlay_input.cpp
  : 'RUN: at line 5';   cp 
/opt/s/w/ir/x/w/llvm-project/clang/test/ClangScanDeps/vfsoverlay.cpp 
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/vfsoverlay_input_clangcl.cpp
  : 'RUN: at line 6';   sed -e 
"s|DIR|/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir|g"
 /opt/s/w/ir/x/w/llvm-project/clang/test/ClangScanDeps/Inputs/vfsoverlay.yaml > 
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/vfsoverlay.yaml
  : 'RUN: at line 7';   mkdir 
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/Inputs
  : 'RUN: at line 8';   cp 
/opt/s/w/ir/x/w/llvm-project/clang/test/ClangScanDeps/Inputs/header.h 
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/Inputs/header.h
  : 'RUN: at line 9';   sed -e 
"s|DIR|/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir|g"
 
/opt/s/w/ir/x/w/llvm-project/clang/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
 > 
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.cdb
  : 'RUN: at line 11';   clang-scan-deps -compilation-database 
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.cdb
 -j 1 |/opt/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
/opt/s/w/ir/x/w/llvm-project/clang/test/ClangScanDeps/vfsoverlay.cpp
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  /opt/s/w/ir/x/w/llvm-project/clang/test/ClangScanDeps/vfsoverlay.cpp:20:11: 
error: CHECK: expected string not found in input
  // CHECK: vfsoverlay_input_clangcl.o
^
  :3:113: note: scanning from here
   
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/Inputs/header.h

  ^
  :5:98: note: possible intended match here
   
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/vfsoverlay_input_clangcl.cpp
 \

   ^
  
  Input file: 
  Check file: 
/opt/s/w/ir/x/w/llvm-project/clang/test/ClangScanDeps/vfsoverlay.cpp
  
  -dump-input=help explains the following input dump.
  
  Input was:
  <<
  1: 
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/vfsoverlay_input.o:
 \ 
  2:  
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/vfsoverlay_input.cpp
 \ 
  3:  
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/Inputs/header.h
 
  check:20'0
 X error: no match found
  4: 
pt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/vfsoverlay.yaml:
 \ 
  check:20'0 
~
  5:  
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/vfsoverlay_input_clangcl.cpp
 \ 
  check:20'0 

  check:20'1
  ?   possible 
intended match
  6:  
/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir/Inputs/header.h
 
  check:20'0 
~
  >>


Repository:

[PATCH] D100720: [AST] Update introspection API to use const-ref for copyable types

2021-04-19 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGabacaef18162: [AST] Update introspection API to use 
const-ref for copyable types (authored by stephenkelly).

Changed prior to commit:
  https://reviews.llvm.org/D100720?vs=338366=338613#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100720/new/

https://reviews.llvm.org/D100720

Files:
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -298,7 +298,7 @@
 
   const auto *NNS = BoundNodes[0].getNodeAs("nns");
 
-  auto Result = NodeIntrospection::GetLocations(NNS);
+  auto Result = NodeIntrospection::GetLocations(*NNS);
 
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
@@ -352,7 +352,7 @@
 
   const auto *TA = BoundNodes[0].getNodeAs("ta");
 
-  auto Result = NodeIntrospection::GetLocations(TA);
+  auto Result = NodeIntrospection::GetLocations(*TA);
 
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
@@ -407,7 +407,7 @@
 
   const auto *TA = BoundNodes[0].getNodeAs("ta");
 
-  auto Result = NodeIntrospection::GetLocations(TA);
+  auto Result = NodeIntrospection::GetLocations(*TA);
 
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
@@ -444,7 +444,7 @@
 
   const auto *TA = BoundNodes[0].getNodeAs("ta");
 
-  auto Result = NodeIntrospection::GetLocations(TA);
+  auto Result = NodeIntrospection::GetLocations(*TA);
 
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
@@ -480,7 +480,7 @@
 
   const auto *TA = BoundNodes[0].getNodeAs("ta");
 
-  auto Result = NodeIntrospection::GetLocations(TA);
+  auto Result = NodeIntrospection::GetLocations(*TA);
 
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
@@ -517,7 +517,7 @@
 
   const auto *TA = BoundNodes[0].getNodeAs("ta");
 
-  auto Result = NodeIntrospection::GetLocations(TA);
+  auto Result = NodeIntrospection::GetLocations(*TA);
 
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
@@ -555,7 +555,7 @@
 
   const auto *TA = BoundNodes[0].getNodeAs("ta");
 
-  auto Result = NodeIntrospection::GetLocations(TA);
+  auto Result = NodeIntrospection::GetLocations(*TA);
 
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
@@ -591,7 +591,7 @@
 
   const auto *TA = BoundNodes[0].getNodeAs("ta");
 
-  auto Result = NodeIntrospection::GetLocations(TA);
+  auto Result = NodeIntrospection::GetLocations(*TA);
 
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
@@ -628,7 +628,7 @@
 
   const auto *TA = BoundNodes[0].getNodeAs("ta");
 
-  auto Result = NodeIntrospection::GetLocations(TA);
+  auto Result = NodeIntrospection::GetLocations(*TA);
 
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
Index: clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
===
--- clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -11,6 +11,8 @@
 
 implementationContent = ''
 
+RefClades = {"NestedNameSpecifierLoc", "TemplateArgumentLoc", "TypeLoc"}
+
 def __init__(self, templateClasses):
 self.templateClasses = templateClasses
 
@@ -54,7 +56,7 @@
 
 def GenerateBaseGetLocationsDeclaration(self, CladeName):
 InstanceDecoration = "*"
-if CladeName == "TypeLoc":
+if CladeName in self.RefClades:
 InstanceDecoration = "&"
 
 self.implementationContent += \
@@ -164,7 +166,7 @@
 
 MethodReturnType = 'NodeLocationAccessors'
 InstanceDecoration = "*"
-if CladeName == "TypeLoc":
+if CladeName in self.RefClades:
 InstanceDecoration = "&"
 
 Signature = \
@@ -196,7 +198,7 @@
 RecursionGuardParam = ', TypeLocRecursionGuard'
 
 ArgPrefix = '*'
-if CladeName == "TypeLoc":
+if CladeName in self.RefClades:
 ArgPrefix = ''
 self.implementationContent += \
 'GetLocations{0}(Prefix, {1}Object, Locs, Rngs {2});'.format(
@@ -290,7 +292,7 @@
 if (const auto *N = Node.get<{0}>())
 """.format(CladeName)
 ArgPrefix = ""
-if CladeName == "TypeLoc":
+if CladeName in self.RefClades:
 ArgPrefix = "*"
 self.implementationContent += \
 """
@@ -351,11 +353,11 @@
   return {};
 }
 NodeLocationAccessors NodeIntrospection::GetLocations(
-clang::NestedNameSpecifierLoc const*) {
+

[clang] abacaef - [AST] Update introspection API to use const-ref for copyable types

2021-04-19 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-04-19T21:07:47+01:00
New Revision: abacaef1816254fc425fa81d137a8d54215d5913

URL: 
https://github.com/llvm/llvm-project/commit/abacaef1816254fc425fa81d137a8d54215d5913
DIFF: 
https://github.com/llvm/llvm-project/commit/abacaef1816254fc425fa81d137a8d54215d5913.diff

LOG: [AST] Update introspection API to use const-ref for copyable types

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

Added: 


Modified: 
clang/include/clang/Tooling/NodeIntrospection.h
clang/lib/Tooling/CMakeLists.txt
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
clang/unittests/Introspection/IntrospectionTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h 
b/clang/include/clang/Tooling/NodeIntrospection.h
index dd7ffe3991207..a04c08823339d 100644
--- a/clang/include/clang/Tooling/NodeIntrospection.h
+++ b/clang/include/clang/Tooling/NodeIntrospection.h
@@ -83,8 +83,8 @@ bool hasIntrospectionSupport();
 NodeLocationAccessors GetLocations(clang::Stmt const *Object);
 NodeLocationAccessors GetLocations(clang::Decl const *Object);
 NodeLocationAccessors GetLocations(clang::CXXCtorInitializer const *Object);
-NodeLocationAccessors GetLocations(clang::NestedNameSpecifierLoc const *);
-NodeLocationAccessors GetLocations(clang::TemplateArgumentLoc const *);
+NodeLocationAccessors GetLocations(clang::NestedNameSpecifierLoc const &);
+NodeLocationAccessors GetLocations(clang::TemplateArgumentLoc const &);
 NodeLocationAccessors GetLocations(clang::CXXBaseSpecifier const *);
 NodeLocationAccessors GetLocations(clang::TypeLoc const &);
 NodeLocationAccessors GetLocations(clang::DynTypedNode const );

diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index a0bb108a2b6c4..2baea134271e5 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -48,11 +48,11 @@ NodeLocationAccessors NodeIntrospection::GetLocations(
   return {};
 }
 NodeLocationAccessors NodeIntrospection::GetLocations(
-clang::NestedNameSpecifierLoc const*) {
+clang::NestedNameSpecifierLoc const&) {
   return {};
 }
 NodeLocationAccessors NodeIntrospection::GetLocations(
-clang::TemplateArgumentLoc const*) {
+clang::TemplateArgumentLoc const&) {
   return {};
 }
 NodeLocationAccessors NodeIntrospection::GetLocations(

diff  --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py 
b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index 3664f521e27b7..fdf586e7e1150 100755
--- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -11,6 +11,8 @@ class Generator(object):
 
 implementationContent = ''
 
+RefClades = {"NestedNameSpecifierLoc", "TemplateArgumentLoc", "TypeLoc"}
+
 def __init__(self, templateClasses):
 self.templateClasses = templateClasses
 
@@ -54,7 +56,7 @@ def GeneratePrologue(self):
 
 def GenerateBaseGetLocationsDeclaration(self, CladeName):
 InstanceDecoration = "*"
-if CladeName == "TypeLoc":
+if CladeName in self.RefClades:
 InstanceDecoration = "&"
 
 self.implementationContent += \
@@ -164,7 +166,7 @@ def GenerateBaseGetLocationsFunction(self, ASTClassNames,
 
 MethodReturnType = 'NodeLocationAccessors'
 InstanceDecoration = "*"
-if CladeName == "TypeLoc":
+if CladeName in self.RefClades:
 InstanceDecoration = "&"
 
 Signature = \
@@ -196,7 +198,7 @@ def GenerateBaseGetLocationsFunction(self, ASTClassNames,
 RecursionGuardParam = ', TypeLocRecursionGuard'
 
 ArgPrefix = '*'
-if CladeName == "TypeLoc":
+if CladeName in self.RefClades:
 ArgPrefix = ''
 self.implementationContent += \
 'GetLocations{0}(Prefix, {1}Object, Locs, Rngs {2});'.format(
@@ -290,7 +292,7 @@ def GenerateDynNodeVisitor(self, CladeNames):
 if (const auto *N = Node.get<{0}>())
 """.format(CladeName)
 ArgPrefix = ""
-if CladeName == "TypeLoc":
+if CladeName in self.RefClades:
 ArgPrefix = "*"
 self.implementationContent += \
 """
@@ -351,11 +353,11 @@ def main():
   return {};
 }
 NodeLocationAccessors NodeIntrospection::GetLocations(
-clang::NestedNameSpecifierLoc const*) {
+clang::NestedNameSpecifierLoc const&) {
   return {};
 }
 NodeLocationAccessors NodeIntrospection::GetLocations(
-clang::TemplateArgumentLoc const*) {
+clang::TemplateArgumentLoc const&) {
   return {};
 }
 NodeLocationAccessors NodeIntrospection::GetLocations(

diff  --git a/clang/unittests/Introspection/IntrospectionTest.cpp 
b/clang/unittests/Introspection/IntrospectionTest.cpp
index 57431668a19f4..1db3e6a8e6d65 100644
--- a/clang/unittests/Introspection/IntrospectionTest.cpp
+++ 

[PATCH] D100727: [clang-format] Correctly apply AllowShortIfStatementsOnASingleLine: Always to else branch.

2021-04-19 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D100727#2698422 , @curdeius wrote:

> More I look at the current state of this option, more I think it's misleading.
> I would expect that the if after else is also controlled by this option. And, 
> the last else as well (adding yet another option for that seems to be a bit 
> an overkill)
>
> @klimek, @mydeveloperday, I'd love to hear your input as well on the best 
> course of action, as I've seen that you've discussed this topic a bit in 
> https://reviews.llvm.org/D59087.
>
> The current status quo looks like:
>
>   /// Different styles for handling short if statements.
>   enum ShortIfStyle : unsigned char {
> /// Never put short ifs on the same line.
> /// \code
> ///   if (a)
> /// return;
> ///
> ///   if (b)
> /// return;
> ///   else
> /// return;
> ///
> ///   if (c)
> /// return;
> ///   else {
> /// return;
> ///   }
> /// \endcode
> SIS_Never,
> /// Put short ifs on the same line only if there is no else statement.
> /// \code
> ///   if (a) return;
> ///
> ///   if (b)
> /// return;
> ///   else
> /// return;
> ///
> ///   if (c)
> /// return;
> ///   else {
> /// return;
> ///   }
> /// \endcode
> SIS_WithoutElse,
> /// Always put short ifs on the same line.
> /// \code
> ///   if (a) return;
> ///
> ///   if (b) return;
> ///   else
> /// return;
> ///
> ///   if (c) return;
> ///   else {
> /// return;
> ///   }
> /// \endcode
> SIS_Always,
>   };
>
> I.e. `WithoutElse` does not depend on the else statement being compound or 
> not. I think I'll push a NFC commit to fix documentation and add tests for 
> this.
>
> Anyway, what I'm inclined to do is to have these options:
>
> - Never (same as now)
> - WithoutElse (same as now, concerns only a simple `if (c) f();`)
> - OnlyFirstIf (renamed from `Always`, and `Always` kept for backward 
> compatibility, it would behave as currently, so only the first `if` in the 
> sequence of if else if else if else is concerned)
> - AllIfsAndElse (would do what I want to achieve in this patch, so format 
> like this:
>
>   if (c) f();
>   else if (c) f();
>   else if (c) f();
>   else if();
>
> Naming is hard. All suggestions are welcome :).

Sounds good.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100727/new/

https://reviews.llvm.org/D100727

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-19 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

another false positive:

  
../../third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:879:20:
 error: variable 'kBufSizeForHexFloatRepr' set but not used 
[-Werror,-Wunused-but-set-variable]
constexpr size_t kBufSizeForHexFloatRepr =

https://source.chromium.org/chromium/chromium/src/+/master:third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc;drc=dcb2703f69f9d66a848106b97f6c932a1d02f84e;l=879


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100581/new/

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-19 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a subscriber: rsmith.
xbolva00 added a comment.

In D100581#2697697 , @mbenfield wrote:

> In D100581#2693131 , @xbolva00 
> wrote:
>
 These warnings are not enabled by any other flags. This is different from 
 gcc, where -Wunused-but-set-variable is enabled by -Wextra in combination 
 with either -Wunused or -Wall.
>>
>> IMHO we should follow gcc here.
>
> I'd be happy to do so, but there are two issues:
>
> 1. I'm not sure this is feasible and fits in with how Clang's diagnostics are 
> organized. AFAICT clang's diagnostics are not set up to have a diagnostic 
> enabled only if //two// other flags are set. If I'm wrong please let me know.
>
> 2. In gcc, this is how `-Wunused-parameter` behaves, but clang's 
> `-Wunused-parameter` is already different. In clang, it's enabled by 
> `-Wextra` regardless of `-Wall` or `-Wunused`.

I am a little bit worried that another off by default warning is not ideal from 
user point of view. Either the user simply would fail to find out that there is 
a new option or will be surprised that gcc fires and clang does not even when 
we claim we implemented this “gcc’s” warning.

About your points, @rsmith may help you.

-


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100581/new/

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-19 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a reviewer: rtrieu.
george.burgess.iv added a comment.

Just a few more nits and LGTM. We probably want the thoughts of someone with 
ownership in warnings to be sure. +rtrieu might be good?




Comment at: clang/lib/Sema/SemaDecl.cpp:13740
+// other than assigning to it, sets the corresponding value to false.
+static void AreAllUsesSets(Stmt *Body,
+   llvm::SmallDenseMap *Map) {

mbenfield wrote:
> george.burgess.iv wrote:
> > nit: Should this be a `const Stmt*`? I don't think we should be mutating 
> > the `Body`
> Unfortunately the `RecursiveASTVisitor`'s non-overridden member functions 
> don't take `const`.
Yeah, I was thinking of StmtVisitor's interface -- my mistake



Comment at: clang/lib/Sema/SemaDecl.cpp:13813-13818
+// check for Ignored here, because if we have no candidates we can avoid
+// walking the AST
+if (Diags.getDiagnosticLevel(diag::warn_unused_but_set_parameter,
+ P->getLocation()) ==
+DiagnosticsEngine::Ignored)
+  return false;

mbenfield wrote:
> mbenfield wrote:
> > george.burgess.iv wrote:
> > > If we want to optimize for when this warning is disabled, would it be 
> > > better to hoist this to the start of DiagnoseUnusedButSetParameters?
> > Isn't it essentially at the beginning of the function as-is? If the warning 
> > is disabled for all parameters, it'll return false right away for all of 
> > them. However, I will add an extra check to end as soon as possible once no 
> > candidates are found. Let me know if it isn't ideal.
> I didn't modify this. I'm not sure there would be any advantage to checking 
> if warnings are disabled for every parameter before just doing all the checks 
> for all of them. Please push back if you think otherwise. 
Ah, I was misreading a bit; didn't realize that we were using the `SourceLoc` 
of each individual parameter to feed into `getDiagnosticLevel`. Yeah, this is 
fine as-is.



Comment at: clang/lib/Sema/SemaDecl.cpp:13752
+  // This is not an assignment to one of our NamedDecls.
+  TraverseStmt(LHS);
+}

since we try to exit early, should this be

```
if (!TraverseStmt(LHS))
  return false;
```

(and similar below)?



Comment at: clang/lib/Sema/SemaDecl.cpp:13760
+// If we remove all Decls, no need to keep searching.
+return (!S.erase(DRE->getFoundDecl()) || S.size());
+  }

nit: LLVM doesn't like superfluous parens; please write this as `return 
!S.erase(DRE->getFoundDecl()) || S.size();`



Comment at: clang/lib/Sema/SemaDecl.cpp:13825
+  Decl *D = Decl::castFromDeclContext((*Parameters.begin())->getDeclContext());
+  if (D)
+DiagnoseUnusedButSetDecls(this, D, Candidates,

nit: LLVM generally tries to write

```
auto *Foo = bar();
if (Foo)
  use(Foo);
```

as

```
if (auto *Foo = bar())
  use(Foo)
```

in part because the latter makes a bit better use of scopes



Comment at: clang/test/Sema/vector-gcc-compat.c:1
 // RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything -triple 
x86_64-apple-darwin10
 

nit: is it possible to add -Wno-unused-but-set-parameter & 
-Wno-unused-but-set-variable as a part of the RUN line?

if it becomes too long, you can use \ to wrap it:

```
// RUN: foo bar \
// RUN: baz
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100581/new/

https://reviews.llvm.org/D100581

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


[PATCH] D100762: [clang][cli] Extract AST dump format into extra option

2021-04-19 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D100762#2699252 , @arichardson 
wrote:

> I'm not sure it's a good idea to remove the `-ast-dump=json` option. While 
> this is -cc1 option, there do seem to be external consumers based on a quick 
> search for "-ast-dump=json". Keeping it would also reduce some of the test 
> churn.

Maybe `-ast-dump=json` can be changed to an alias for `-ast-dump 
-ast-dump-format json`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100762/new/

https://reviews.llvm.org/D100762

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


[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

2021-04-19 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D97183#2699080 , @RedDocMD wrote:

> For the following function:
>
>   void foo(std::unique_ptr P) {
> A* praw = P.get();
> A* other = praw;
> if (other) {}
> P->foo();
>   }
>
> Where do we expect a note? Where `praw` is initialized, where `other` is 
> initialized or both?

I would expect no notes at all, since there is no bug.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97183/new/

https://reviews.llvm.org/D97183

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


[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-04-19 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7652
 
+  verifyFormat("test < a - 1 >> 1;");
   verifyFormat("test >> a >> b;");

Quuxplusone wrote:
> IMO you should use `"test < a | b >> c;"` as your test case here, to reassure 
> the reader that it doesn't depend on the fact that `... 1;` is visibly not a 
> variable declaration.
> Personally I'd also like to see `"test> c;"` tested on the very 
> next line, to show off the intended difference between the two. (Assuming 
> that I understand the intent of this patch correctly.)
> (I also switched to a bitwise operator just for the heck of it; that makes 
> this expression just a //very tiny bit// less implausible — but still highly 
> implausible, to the point where I question why we're special-casing it.)
Btw, a much-bigger-scope way to fix this would be to teach clang-format about 
"input encoding" versus "output encoding." The only time clang-format should 
//ever// be inserting space in the middle of `>>` is if it's translating 
C++11-encoded input into C++03-encoded output. If the input is known to already 
be C++03-encoded, then breaking up an `>>` token into a pair of `> >` tokens is 
//guaranteed// to introduce a bug.
Right now, my impression is that clang-format has a concept of "output 
encoding" (i.e. "language mode") but has no way of knowing the "input encoding."


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100778/new/

https://reviews.llvm.org/D100778

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


[PATCH] D99993: [clang-tidy] bugprone-argument-comment: ignore name mismatches for decls from system headers

2021-04-19 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

friendly ping :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D3/new/

https://reviews.llvm.org/D3

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


[PATCH] D100782: [PowerPC] Improve f32 to i32 bitcast code gen

2021-04-19 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: saghir, nemanjai, PowerPC.
Conanap added projects: PowerPC, clang, LLVM.
Herald added a subscriber: kbarton.
Conanap requested review of this revision.

The code gen for f32 to i32 bitcast is not currently the most efficient. For 
example:

  int foo(float f) {
return *(int*)
  }

Generates:

  xscvdpspn vs0, f1
  xxsldwi vs0, vs0, vs0, 3
  mffprwz   r3, f0

However, `xxsldwi` is actually not needed as `xscvdpspn` already splats the 
value.

This patch removes that instruction for this specific code gen.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100782

Files:
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/bitcasts-direct-move.ll
  llvm/test/CodeGen/PowerPC/vec_insert_elt.ll


Index: llvm/test/CodeGen/PowerPC/vec_insert_elt.ll
===
--- llvm/test/CodeGen/PowerPC/vec_insert_elt.ll
+++ llvm/test/CodeGen/PowerPC/vec_insert_elt.ll
@@ -200,21 +200,19 @@
 ; CHECK-LABEL: testFloat1:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:xscvdpspn vs0, f1
-; CHECK-NEXT:extsw r3, r6
-; CHECK-NEXT:slwi r3, r3, 2
-; CHECK-NEXT:xxsldwi vs0, vs0, vs0, 3
-; CHECK-NEXT:mffprwz r4, f0
-; CHECK-NEXT:vinswrx v2, r3, r4
+; CHECK-NEXT:extsw r4, r6
+; CHECK-NEXT:slwi r4, r4, 2
+; CHECK-NEXT:mffprwz r3, f0
+; CHECK-NEXT:vinswrx v2, r4, r3
 ; CHECK-NEXT:blr
 ;
 ; CHECK-BE-LABEL: testFloat1:
 ; CHECK-BE:   # %bb.0: # %entry
 ; CHECK-BE-NEXT:xscvdpspn vs0, f1
-; CHECK-BE-NEXT:extsw r3, r6
-; CHECK-BE-NEXT:slwi r3, r3, 2
-; CHECK-BE-NEXT:xxsldwi vs0, vs0, vs0, 3
-; CHECK-BE-NEXT:mffprwz r4, f0
-; CHECK-BE-NEXT:vinswlx v2, r3, r4
+; CHECK-BE-NEXT:extsw r4, r6
+; CHECK-BE-NEXT:slwi r4, r4, 2
+; CHECK-BE-NEXT:mffprwz r3, f0
+; CHECK-BE-NEXT:vinswlx v2, r4, r3
 ; CHECK-BE-NEXT:blr
 ;
 ; CHECK-P9-LABEL: testFloat1:
Index: llvm/test/CodeGen/PowerPC/bitcasts-direct-move.ll
===
--- llvm/test/CodeGen/PowerPC/bitcasts-direct-move.ll
+++ llvm/test/CodeGen/PowerPC/bitcasts-direct-move.ll
@@ -10,8 +10,8 @@
 ; CHECK-P7: stfs 1,
 ; CHECK-P7: lwa 3,
 ; CHECK: xscvdpspn [[CONVREG:[0-9]+]], 1
-; CHECK: xxsldwi [[SHIFTREG:[0-9]+]], [[CONVREG]], [[CONVREG]], 3
-; CHECK: mffprwz 3, [[SHIFTREG]]
+; CHECK-NOT: xxsldwi
+; CHECK: mffprwz 3, [[CONVREG]]
 }
 
 define i64 @f64toi64(double %a) {
@@ -50,8 +50,8 @@
 ; CHECK-P7: stfs 1,
 ; CHECK-P7: lwz 3,
 ; CHECK: xscvdpspn [[CONVREG:[0-9]+]], 1
-; CHECK: xxsldwi [[SHIFTREG:[0-9]+]], [[CONVREG]], [[CONVREG]], 3
-; CHECK: mffprwz 3, [[SHIFTREG]]
+; CHECK-NOT: xxsldwi
+; CHECK: mffprwz 3, [[CONVREG]]
 }
 
 define i64 @f64toi64u(double %a) {
Index: llvm/lib/Target/PowerPC/PPCInstrVSX.td
===
--- llvm/lib/Target/PowerPC/PPCInstrVSX.td
+++ llvm/lib/Target/PowerPC/PPCInstrVSX.td
@@ -1814,8 +1814,7 @@
 
 // Output dag used to bitcast f32 to i32 and f64 to i64
 def Bitcast {
-  dag FltToInt = (i32 (MFVSRWZ (EXTRACT_SUBREG (XXSLDWI (XSCVDPSPN $A),
-  (XSCVDPSPN $A), 3), sub_64)));
+  dag FltToInt = (i32 (MFVSRWZ (EXTRACT_SUBREG (XSCVDPSPN $A), sub_64)));
   dag DblToLong = (i64 (MFVSRD $A));
 }
 


Index: llvm/test/CodeGen/PowerPC/vec_insert_elt.ll
===
--- llvm/test/CodeGen/PowerPC/vec_insert_elt.ll
+++ llvm/test/CodeGen/PowerPC/vec_insert_elt.ll
@@ -200,21 +200,19 @@
 ; CHECK-LABEL: testFloat1:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:xscvdpspn vs0, f1
-; CHECK-NEXT:extsw r3, r6
-; CHECK-NEXT:slwi r3, r3, 2
-; CHECK-NEXT:xxsldwi vs0, vs0, vs0, 3
-; CHECK-NEXT:mffprwz r4, f0
-; CHECK-NEXT:vinswrx v2, r3, r4
+; CHECK-NEXT:extsw r4, r6
+; CHECK-NEXT:slwi r4, r4, 2
+; CHECK-NEXT:mffprwz r3, f0
+; CHECK-NEXT:vinswrx v2, r4, r3
 ; CHECK-NEXT:blr
 ;
 ; CHECK-BE-LABEL: testFloat1:
 ; CHECK-BE:   # %bb.0: # %entry
 ; CHECK-BE-NEXT:xscvdpspn vs0, f1
-; CHECK-BE-NEXT:extsw r3, r6
-; CHECK-BE-NEXT:slwi r3, r3, 2
-; CHECK-BE-NEXT:xxsldwi vs0, vs0, vs0, 3
-; CHECK-BE-NEXT:mffprwz r4, f0
-; CHECK-BE-NEXT:vinswlx v2, r3, r4
+; CHECK-BE-NEXT:extsw r4, r6
+; CHECK-BE-NEXT:slwi r4, r4, 2
+; CHECK-BE-NEXT:mffprwz r3, f0
+; CHECK-BE-NEXT:vinswlx v2, r4, r3
 ; CHECK-BE-NEXT:blr
 ;
 ; CHECK-P9-LABEL: testFloat1:
Index: llvm/test/CodeGen/PowerPC/bitcasts-direct-move.ll
===
--- llvm/test/CodeGen/PowerPC/bitcasts-direct-move.ll
+++ llvm/test/CodeGen/PowerPC/bitcasts-direct-move.ll
@@ -10,8 +10,8 @@
 ; CHECK-P7: stfs 1,
 ; CHECK-P7: lwa 3,
 ; CHECK: xscvdpspn [[CONVREG:[0-9]+]], 1
-; CHECK: xxsldwi [[SHIFTREG:[0-9]+]], [[CONVREG]], [[CONVREG]], 3
-; CHECK: mffprwz 3, [[SHIFTREG]]
+; CHECK-NOT: xxsldwi
+; CHECK: mffprwz 3, 

[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-04-19 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7652
 
+  verifyFormat("test < a - 1 >> 1;");
   verifyFormat("test >> a >> b;");

IMO you should use `"test < a | b >> c;"` as your test case here, to reassure 
the reader that it doesn't depend on the fact that `... 1;` is visibly not a 
variable declaration.
Personally I'd also like to see `"test> c;"` tested on the very 
next line, to show off the intended difference between the two. (Assuming that 
I understand the intent of this patch correctly.)
(I also switched to a bitwise operator just for the heck of it; that makes this 
expression just a //very tiny bit// less implausible — but still highly 
implausible, to the point where I question why we're special-casing it.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100778/new/

https://reviews.llvm.org/D100778

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


[PATCH] D100620: [OpenMP] Make sure classes work on the device as they do on the host

2021-04-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: 
clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h:20
+// need to `include `.
+#include 
+#endif

jdoerfert wrote:
> JonChesterfield wrote:
> > I think there are legitimate use cases for writing code that doesn't 
> > include new. Can we add the forms that are meant to be available without 
> > the include here, instead of just pulling in all new?
> Hm, what forms would you not like to see in the code by default, and why?
> 
I would prefer the default includes exactly the expressions/syntax that C++ 
provides by default, which may mean writing some inline here though I'm 
perplexed that we need to do something different to clang compiling c++. I'd 
have to look up which operators are magic and which are in the header.

At least some reluctance is that we don't have a gpu , so this will be 
whatever host libstdc++/libc++ is in use, and I'd like to avoid including 
gpu-unaware code on the gpu wherever possible.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100620/new/

https://reviews.llvm.org/D100620

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


[PATCH] D98193: [CUDA][HIP] Allow non-ODR use of host var in device

2021-04-19 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd8805574c183: [CUDA][HIP] Allow non-ODR use of host var in 
device (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98193/new/

https://reviews.llvm.org/D98193

Files:
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/device-use-host-var.cu
  clang/test/Headers/hip-header.hip
  clang/test/SemaCUDA/device-use-host-var.cu

Index: clang/test/SemaCUDA/device-use-host-var.cu
===
--- clang/test/SemaCUDA/device-use-host-var.cu
+++ clang/test/SemaCUDA/device-use-host-var.cu
@@ -5,37 +5,96 @@
 
 #include "Inputs/cuda.h"
 
-int global_host_var;
+struct A {
+  int x;
+  static int host_var;
+};
+
+int A::host_var;
+
+namespace X {
+  int host_var;
+}
+
+static int static_host_var;
+
 __device__ int global_dev_var;
 __constant__ int global_constant_var;
 __shared__ int global_shared_var;
-constexpr int global_constexpr_var = 1;
+
+int global_host_var;
 const int global_const_var = 1;
+constexpr int global_constexpr_var = 1;
+
+int global_host_array[2] = {1, 2};
+const int global_const_array[2] = {1, 2};
+constexpr int global_constexpr_array[2] = {1, 2};
+
+A global_host_struct_var{1};
+const A global_const_struct_var{1};
+constexpr A global_constexpr_struct_var{1};
 
 template
 __global__ void kernel(F f) { f(); } // dev-note2 {{called by 'kernel<(lambda}}
 
 __device__ void dev_fun(int *out) {
-  int _host_var = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  // Check access device variables are allowed.
   int _dev_var = global_dev_var;
   int _constant_var = global_constant_var;
   int _shared_var = global_shared_var;
-  const int _constexpr_var = global_constexpr_var;
-  const int _const_var = global_const_var;
-
-  *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  *out = ref_dev_var;
+  *out = ref_constant_var;
+  *out = ref_shared_var;
   *out = global_dev_var;
   *out = global_constant_var;
   *out = global_shared_var;
-  *out = global_constexpr_var;
+
+  // Check access of non-const host variables are not allowed.
+  *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
   *out = global_const_var;
+  *out = global_constexpr_var;
+  global_host_var = 1; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
 
+  // Check reference of non-constexpr host variables are not allowed.
+  int _host_var = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  const int _const_var = global_const_var; // dev-error {{reference to __host__ variable 'global_const_var' in __device__ function}}
+  const int _constexpr_var = global_constexpr_var;
   *out = ref_host_var;
-  *out = ref_dev_var;
-  *out = ref_constant_var;
-  *out = ref_shared_var;
   *out = ref_constexpr_var;
   *out = ref_const_var;
+
+  // Check access member of non-constexpr struct type host variable is not allowed.
+  *out = global_host_struct_var.x; // dev-error {{reference to __host__ variable 'global_host_struct_var' in __device__ function}}
+  *out = global_const_struct_var.x; // dev-error {{reference to __host__ variable 'global_const_struct_var' in __device__ function}}
+  *out = global_constexpr_struct_var.x;
+  global_host_struct_var.x = 1; // dev-error {{reference to __host__ variable 'global_host_struct_var' in __device__ function}}
+
+  // Check address taking of non-constexpr host variables is not allowed.
+  int *p = _host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  const int *cp = _const_var; // dev-error {{reference to __host__ variable 'global_const_var' in __device__ function}}
+  const int *cp2 = _constexpr_var;
+
+  // Check access elements of non-constexpr host array is not allowed.
+  *out = global_host_array[1]; // dev-error {{reference to __host__ variable 'global_host_array' in __device__ function}}
+  *out = global_const_array[1]; // dev-error {{reference to __host__ variable 'global_const_array' in __device__ function}}
+  *out = global_constexpr_array[1];
+
+  // Check ODR-use of host variables in namespace is not allowed.
+  *out = X::host_var; // dev-error {{reference to __host__ variable 'host_var' in __device__ function}}
+
+  // Check ODR-use of static host varables in class or file scope is not allowed.
+  *out = A::host_var; // dev-error {{reference to __host__ variable 'host_var' in __device__ function}}
+  *out = static_host_var; // dev-error {{reference to __host__ variable 'static_host_var' in __device__ function}}
+
+  // Check function-scope static variable is allowed.
+  static int static_var;
+  *out = 

[clang] d880557 - [CUDA][HIP] Allow non-ODR use of host var in device

2021-04-19 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-04-19T14:45:24-04:00
New Revision: d8805574c183484f02855fa82d2e8932415e

URL: 
https://github.com/llvm/llvm-project/commit/d8805574c183484f02855fa82d2e8932415e
DIFF: 
https://github.com/llvm/llvm-project/commit/d8805574c183484f02855fa82d2e8932415e.diff

LOG: [CUDA][HIP] Allow non-ODR use of host var in device

Reviewed by: Artem Belevich, Richard Smith

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

Added: 
clang/test/CodeGenCUDA/device-use-host-var.cu

Modified: 
clang/lib/Headers/__clang_hip_math.h
clang/lib/Sema/SemaExpr.cpp
clang/test/Headers/hip-header.hip
clang/test/SemaCUDA/device-use-host-var.cu

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_math.h 
b/clang/lib/Headers/__clang_hip_math.h
index 35cf0ad3ba6c5..1f0982d92eff3 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -38,7 +38,7 @@ template
 struct __compare_result{};
 template<>
 struct __compare_result {
-  static const bool valid;
+  static const __device__ bool valid;
 };
 
 __DEVICE__

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 38c25ca65374f..4c44295e7e142 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -355,24 +355,6 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, 
ArrayRef Locs,
 
   diagnoseUseOfInternalDeclInInlineFunction(*this, D, Loc);
 
-  // CUDA/HIP: Diagnose invalid references of host global variables in device
-  // functions. Reference of device global variables in host functions is
-  // allowed through shadow variables therefore it is not diagnosed.
-  if (LangOpts.CUDAIsDevice) {
-auto *FD = dyn_cast_or_null(CurContext);
-auto Target = IdentifyCUDATarget(FD);
-if (FD && Target != CFT_Host) {
-  const auto *VD = dyn_cast(D);
-  if (VD && VD->hasGlobalStorage() && !VD->hasAttr() &&
-  !VD->hasAttr() && !VD->hasAttr() &&
-  !VD->getType()->isCUDADeviceBuiltinSurfaceType() &&
-  !VD->getType()->isCUDADeviceBuiltinTextureType() &&
-  !VD->isConstexpr() && !VD->getType().isConstQualified())
-targetDiag(*Locs.begin(), diag::err_ref_bad_target)
-<< /*host*/ 2 << /*variable*/ 1 << VD << Target;
-}
-  }
-
   if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)) {
 if (auto *VD = dyn_cast(D))
   checkDeviceDecl(VD, Loc);
@@ -17143,6 +17125,31 @@ MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, 
Sema ,
 CaptureType, DeclRefType,
 FunctionScopeIndexToStopAt);
 
+  // Diagnose ODR-use of host global variables in device functions. Reference
+  // of device global variables in host functions is allowed through shadow
+  // variables therefore it is not diagnosed.
+  if (SemaRef.LangOpts.CUDA && SemaRef.LangOpts.CUDAIsDevice) {
+auto *FD = dyn_cast_or_null(SemaRef.CurContext);
+auto Target = SemaRef.IdentifyCUDATarget(FD);
+auto IsEmittedOnDeviceSide = [](VarDecl *Var) {
+  if (Var->hasAttr() || Var->hasAttr() ||
+  Var->hasAttr() ||
+  Var->getType()->isCUDADeviceBuiltinSurfaceType() ||
+  Var->getType()->isCUDADeviceBuiltinTextureType())
+return true;
+  // Function-scope static variable in device functions or kernels are
+  // emitted on device side.
+  if (auto *FD = dyn_cast(Var->getDeclContext())) {
+return FD->hasAttr() || FD->hasAttr();
+  }
+  return false;
+};
+if (Var && Var->hasGlobalStorage() && !IsEmittedOnDeviceSide(Var)) {
+  SemaRef.targetDiag(Loc, diag::err_ref_bad_target)
+  << /*host*/ 2 << /*variable*/ 1 << Var << Target;
+}
+  }
+
   Var->markUsed(SemaRef.Context);
 }
 

diff  --git a/clang/test/CodeGenCUDA/device-use-host-var.cu 
b/clang/test/CodeGenCUDA/device-use-host-var.cu
new file mode 100644
index 0..40dcef89bf5bf
--- /dev/null
+++ b/clang/test/CodeGenCUDA/device-use-host-var.cu
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 -triple amdgcn-amd-amdhsa \
+// RUN:   -fcuda-is-device -emit-llvm -o - -x hip %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+struct A {
+  int x;
+};
+
+constexpr int constexpr_var = 1;
+constexpr A constexpr_struct{2};
+constexpr A constexpr_array[4] = {0, 0, 0, 3};
+constexpr char constexpr_str[] = "abcd";
+const int const_var = 4;
+
+// CHECK-DAG: @_ZL13constexpr_str.const = private unnamed_addr addrspace(4) 
constant [5 x i8] c"abcd\00"
+// CHECK-DAG: @_ZL13constexpr_var = internal addrspace(4) constant i32 1
+// CHECK-DAG: @_ZL16constexpr_struct = internal addrspace(4) constant 
%struct.A { i32 2 }
+// CHECK-DAG: @_ZL15constexpr_array = internal addrspace(4) constant [4 x 
%struct.A] [%struct.A zeroinitializer, %struct.A zeroinitializer, %struct.A 
zeroinitializer, %struct.A { i32 3 }]
+// CHECK-NOT: external
+
+// CHECK-LABEL: define{{.*}}@_Z7dev_funPiPPKi
+// CHECK: store i32 1

[PATCH] D100762: [clang][cli] Extract AST dump format into extra option

2021-04-19 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson requested changes to this revision.
arichardson added a reviewer: aaron.ballman.
arichardson added a comment.

I'm not sure it's a good idea to remove the `-ast-dump=json` option. While this 
is -cc1 option, there do seem to be external consumers based on a quick search 
for "-ast-dump=json". Keeping it would also reduce some of the test churn.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100762/new/

https://reviews.llvm.org/D100762

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


[PATCH] D100762: [clang][cli] Extract AST dump format into extra option

2021-04-19 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith requested changes to this revision.
dexonsmith added inline comments.
This revision now requires changes to proceed.



Comment at: clang/test/AST/ast-dump-comment-json.cpp:44
 // CHECK-NEXT:  "loc": {
-// CHECK-NEXT:   "offset": 72,
+// CHECK-NEXT:   "offset": 89,
 // CHECK-NEXT:   "line": 3,

This is a lot of noise in the tests just from changing `RUN` lines. Maybe these 
tests shouldn't be checking the `offset:` field.

I suggest:
1. Create (if it doesn't exist) one **small** test that checks that `offset:` 
works correctly. In the same commit, replace the `offset:` lines in all the 
other tests to check against `[[0-9+]],` instead of the specific character 
offset.
3. Land this change, which no longer needs to update all the `offset:` fields.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100762/new/

https://reviews.llvm.org/D100762

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


[PATCH] D100282: [Coroutines] Set presplit attribute in Clang instead of CoroEarly pass

2021-04-19 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D100282#2699171 , @rjmccall wrote:

> MLIR is an in-tree project that can be updated.

Sure, but I think there are some important differences.
As far as I understand, in MLIR, unlike in C++/Swift frontend where a coroutine 
function body is represented by an explicit AST type, there is no concept for 
coroutine functions. Instead functions just contain async dialects. So for MLIR 
to properly annotate coroutine functions, it will need to look for either those 
dialects or these intrinsics after IRGen in order to do so, which is pretty 
much the same thing that we were doing in CoroEarly to annotate coroutine 
functions. The complexity introduced by duplicating this to all frontends, 
especially in MLIR where we need to do the same thing as we were doing in 
CoroEarly, seems to out-weight the benefits on conceptual clarity.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100282/new/

https://reviews.llvm.org/D100282

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


[PATCH] D77013: [AMDGPU] Add options -mamdgpu-ieee -mno-amdgpu-ieee

2021-04-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 338575.
yaxunl added a comment.

rebase


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77013/new/

https://reviews.llvm.org/D77013

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenOpenCL/amdgpu-ieee.cl

Index: clang/test/CodeGenOpenCL/amdgpu-ieee.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/amdgpu-ieee.cl
@@ -0,0 +1,48 @@
+// REQUIRES: amdgpu-registered-target
+//
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   | FileCheck -check-prefixes=COMMON,ON %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -mamdgpu-ieee | FileCheck -check-prefixes=COMMON,ON %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -mno-amdgpu-ieee | FileCheck -check-prefixes=COMMON,OFF %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -menable-no-nans | FileCheck -check-prefixes=COMMON,OFF %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -menable-no-nans -mamdgpu-ieee | FileCheck -check-prefixes=COMMON,ON %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -cl-fast-relaxed-math | FileCheck -check-prefixes=COMMON,OFF %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -cl-fast-relaxed-math -mamdgpu-ieee \
+
+// Check AMDGCN ISA generation.
+
+// RUN: | FileCheck -check-prefixes=COMMON,ON %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O3 -S -o - %s \
+// RUN:   -mamdgpu-ieee \
+// RUN: | FileCheck -check-prefixes=ISA-ON %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O3 -S -o - %s \
+// RUN:   -mno-amdgpu-ieee \
+// RUN: | FileCheck -check-prefixes=ISA-OFF %s
+
+// COMMON: define{{.*}} amdgpu_kernel void @kern{{.*}} [[ATTRS1:#[0-9]+]]
+// ISA-ON: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-ON: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-ON: v_min_f32_e32
+// ISA-ON: ; IeeeMode: 1
+// ISA-OFF-NOT: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-OFF-NOT: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-OFF: v_min_f32_e32
+// ISA-OFF: ; IeeeMode: 0
+kernel void kern(global float *x, float y, float z) {
+  *x = __builtin_fmin(y, z);
+}
+
+// COMMON: define{{.*}}void @fun() [[ATTRS2:#[0-9]+]]
+void fun() {
+}
+
+// ON-NOT: attributes [[ATTRS1]] = {{.*}} "amdgpu-ieee"
+// OFF: attributes [[ATTRS1]] = {{.*}} "amdgpu-ieee"="false"
+// ON-NOT: attributes [[ATTRS2]] = {{.*}} "amdgpu-ieee"
+// OFF: attributes [[ATTRS2]] = {{.*}} "amdgpu-ieee"="false"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1943,6 +1943,13 @@
   else if (Args.hasArg(options::OPT_fno_finite_loops))
 Opts.FiniteLoops = CodeGenOptions::FiniteLoopsKind::Never;
 
+  // When NaN is not honored, floating point opcodes that support exception
+  // flag gathering does not need to quiet or propagate signaling NaN inputs
+  // per IEEE 754-2008. Note this only concerns about signaling NaN.
+  Opts.EmitIEEENaNCompliantInsts =
+  Args.hasFlag(options::OPT_mamdgpu_ieee, options::OPT_mno_amdgpu_ieee,
+   !LangOptsRef.NoHonorNaNs);
+
   return Diags.getNumErrors() == NumErrorsBefore;
 }
 
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9166,6 +9166,9 @@
 
   if (M.getContext().getTargetInfo().allowAMDGPUUnsafeFPAtomics())
 F->addFnAttr("amdgpu-unsafe-fp-atomics", "true");
+
+  if (!getABIInfo().getCodeGenOpts().EmitIEEENaNCompliantInsts)
+F->addFnAttr("amdgpu-ieee", "false");
 }
 
 unsigned AMDGPUTargetCodeGenInfo::getOpenCLKernelCallingConv() const {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3171,6 +3171,12 @@
  Values<"command,reactor">,
  HelpText<"Execution model (WebAssembly only)">;
 
+def mamdgpu_ieee : Flag<["-"], "mamdgpu-ieee">, Flags<[CC1Option]>,
+  Group, HelpText<"Floating point opcodes that support exception flag "
+   "gathering quiet and propagate signaling NaN inputs per IEEE 754-2008 (AMDGPU only)">;
+def mno_amdgpu_ieee : Flag<["-"], "mno-amdgpu-ieee">, Flags<[CC1Option]>,
+  Group;
+
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, Group,
   HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;
Index: clang/include/clang/Basic/CodeGenOptions.def

[PATCH] D98995: [CGAtomic] Lift stronger requirements on cmpxch and add support for acquire failure mode

2021-04-19 Thread Julian Lettner via Phabricator via cfe-commits
yln added inline comments.



Comment at: clang/lib/CodeGen/CGAtomic.cpp:444-447
+// Prior to c++17, "the failure argument shall be no stronger than the
+// success argument". This condition has been lifted and the only
+// precondition is 31.7.2.18. Effectively treat this as a DR and skip
+// language version checks.

yln wrote:
> Should the following assert in `AtomicCmpXchgInst::Init()` have been changed 
> as well?
> ```
> assert(!isStrongerThan(FailureOrdering, SuccessOrdering) &&
>"AtomicCmpXchg failure argument shall be no stronger than the success "
>"argument");
> ```
> https://github.com/llvm/llvm-project/blob/dad5caa59e6b2bde8d6cf5b64a972c393c526c82/llvm/lib/IR/Instructions.cpp#L1561
> 
> I am observing a crash on an internal code base most likely caused by this.
//friendly ping// @bruno 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98995/new/

https://reviews.llvm.org/D98995

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


[PATCH] D100282: [Coroutines] Set presplit attribute in Clang instead of CoroEarly pass

2021-04-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

MLIR is an in-tree project that can be updated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100282/new/

https://reviews.llvm.org/D100282

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


[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-04-19 Thread Luis Penagos via Phabricator via cfe-commits
penagos created this revision.
penagos added reviewers: Saldivarcher, MyDeveloperDay, JakeMerdichAMD, krasimir.
penagos requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This serves to augment the improvements made in 
https://reviews.llvm.org/D86581. It prevents clang-format from interpreting 
bitshift operators as template arguments in certain circumstances.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100778

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7649,6 +7649,7 @@
   verifyFormat("a = 1;", Style);
   verifyFormat("a >>= 1;", Style);
 
+  verifyFormat("test < a - 1 >> 1;");
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -119,7 +119,10 @@
 // a statement.
 if (CurrentToken->Next && CurrentToken->Next->is(tok::greater) &&
 Left->ParentBracket != tok::less &&
-isKeywordWithCondition(*Line.First))
+(isKeywordWithCondition(*Line.First) ||
+ CurrentToken->getStartOfNonWhitespace() ==
+ 
CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
   return false;
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7649,6 +7649,7 @@
   verifyFormat("a = 1;", Style);
   verifyFormat("a >>= 1;", Style);
 
+  verifyFormat("test < a - 1 >> 1;");
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -119,7 +119,10 @@
 // a statement.
 if (CurrentToken->Next && CurrentToken->Next->is(tok::greater) &&
 Left->ParentBracket != tok::less &&
-isKeywordWithCondition(*Line.First))
+(isKeywordWithCondition(*Line.First) ||
+ CurrentToken->getStartOfNonWhitespace() ==
+ CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
   return false;
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93031: Enable fexec-charset option

2021-04-19 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 338565.
abhina.sreeskantharajan added a comment.

Rebase + set size of char as 1 when creating a StringRef to fix lit failure


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93031/new/

https://reviews.llvm.org/D93031

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TokenKinds.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/LiteralConverter.h
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Lex/CMakeLists.txt
  clang/lib/Lex/LiteralConverter.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/CodeGen/systemz-charset.c
  clang/test/CodeGen/systemz-charset.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1046,6 +1046,13 @@
   return Tmp.split('-').second;  // Strip second component
 }
 
+// System charset on z/OS is IBM-1047 and UTF-8 otherwise
+StringRef Triple::getSystemCharset() const {
+  if (getOS() == llvm::Triple::ZOS)
+return "IBM-1047";
+  return "UTF-8";
+}
+
 static unsigned EatNumber(StringRef ) {
   assert(!Str.empty() && isDigit(Str[0]) && "Not a number");
   unsigned Result = 0;
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -397,6 +397,9 @@
   /// if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// getSystemCharset - Get the system charset of the triple.
+  StringRef getSystemCharset() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -222,8 +222,14 @@
 // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
 
-// RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
-// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
+// RUN: %clang -### -S -fexec-charset=invalid-charset -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
+// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'invalid-charset' in '-fexec-charset=invalid-charset'
+
+// Test that we support the following exec charsets.
+// RUN: %clang -### -S -fexec-charset=UTF-8 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: %clang -### -S -fexec-charset=ISO8859-1 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: %clang -### -S -fexec-charset=IBM-1047 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// INVALID-NOT: error: invalid value
 
 // Test that we don't error on these.
 // RUN: %clang -### -S -Werror\
@@ -237,7 +243,7 @@
 // RUN: -fident -fno-ident\
 // RUN: -fimplicit-templates -fno-implicit-templates  \
 // RUN: -finput-charset=UTF-8 \
-// RUN: -fexec-charset=UTF-8 \
+// RUN: -fexec-charset=UTF-8  \
 // RUN: -fivopts -fno-ivopts  \
 // RUN: -fnon-call-exceptions -fno-non-call-exceptions\
 // RUN: -fpermissive -fno-permissive  \
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -210,10 +210,11 @@
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
 // source-charset-utf-16: invalid value 'utf-16' in '/source-charset:utf-16'
 
-// /execution-charset: should warn on everything except UTF-8.
-// RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
-// execution-charset-utf-16: invalid value 'utf-16' in '/execution-charset:utf-16'
+// /execution-charset: should warn on invalid charsets.
+// RUN: %clang_cl /execution-charset:invalid-charset -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-invalid %s
+// execution-charset-invalid: invalid value 

[PATCH] D100776: [clang/Basic] Make TargetInfo.h not use DataLayout again

2021-04-19 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.
Herald added subscribers: dexonsmith, kerbowa, kbarton, mgorny, nhaehnle, 
jvesely, nemanjai.
thakis requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Reverts parts of https://reviews.llvm.org/D17183, but keeps the
resetDataLayout() API and adds an assert that checks that datalayout string and
user label prefix are in sync.

Approach 1 in https://reviews.llvm.org/D17183#2653279
Reduces number of TUs build for 'clang-format' from 689 to 575.

I also implemented approach 1 in D100764 . If 
someone feels motivated
to make us use DataLayout more, it's easy to revert this change here
and go with D100764  instead. I don't plan on 
doing more work in this
area though, so I prefer going with the smaller, more self-consistent change.


https://reviews.llvm.org/D100776

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/CodeGen/BackendUtil.h
  clang/lib/AST/Mangle.cpp
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/ModuleBuilder.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/unittests/AST/DeclTest.cpp
  llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
@@ -45,10 +45,10 @@
 "//clang/include/clang/Sema:AttrParsedAttrKinds",
 "//clang/include/clang/Sema:AttrSpellingListIndex",
 "//llvm/include/llvm/Config:llvm-config",
-"//llvm/lib/IR",
 "//llvm/lib/MC",
 "//llvm/lib/Support",
   ]
+  assert_no_deps = [ "//llvm/lib/IR" ]
   include_dirs = [ "." ]
   sources = [
 "Attributes.cpp",
Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -75,7 +75,7 @@
   auto AST =
   tooling::buildASTFromCodeWithArgs(Code, {"-target", "i386-apple-darwin"});
   ASTContext  = AST->getASTContext();
-  assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
+  assert(Ctx.getTargetInfo().getUserLabelPrefix() == StringRef("_") &&
  "Expected target to have a global prefix");
   DiagnosticsEngine  = AST->getDiagnostics();
 
@@ -118,7 +118,7 @@
   auto AST =
   tooling::buildASTFromCodeWithArgs(Code, {"-target", "i386-apple-darwin"});
   ASTContext  = AST->getASTContext();
-  assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
+  assert(Ctx.getTargetInfo().getUserLabelPrefix() == StringRef("_") &&
  "Expected target to have a global prefix");
   DiagnosticsEngine  = AST->getDiagnostics();
 
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -985,8 +985,7 @@
   DefineFastIntType(64, true, TI, Builder);
   DefineFastIntType(64, false, TI, Builder);
 
-  char UserLabelPrefix[2] = {TI.getDataLayout().getGlobalPrefix(), 0};
-  Builder.defineMacro("__USER_LABEL_PREFIX__", UserLabelPrefix);
+  Builder.defineMacro("__USER_LABEL_PREFIX__", TI.getUserLabelPrefix());
 
   if (LangOpts.FastMath || LangOpts.FiniteMathOnly)
 Builder.defineMacro("__FINITE_MATH_ONLY__", "1");
Index: clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
===
--- clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -166,7 +166,7 @@
 Ctx = 
 VMContext.reset(new llvm::LLVMContext());
 M.reset(new llvm::Module(MainFileName, *VMContext));
-M->setDataLayout(Ctx->getTargetInfo().getDataLayout());
+M->setDataLayout(Ctx->getTargetInfo().getDataLayoutString());
 Builder.reset(new CodeGen::CodeGenModule(
 *Ctx, HeaderSearchOpts, PreprocessorOpts, CodeGenOpts, *M, Diags));
 
@@ -245,7 +245,7 @@
   return;
 
 M->setTargetTriple(Ctx.getTargetInfo().getTriple().getTriple());
-M->setDataLayout(Ctx.getTargetInfo().getDataLayout());
+M->setDataLayout(Ctx.getTargetInfo().getDataLayoutString());
 
 // PCH files don't have a signature field in the control block,
 // but LLVM detects DWO CUs by looking for a non-zero DWO id.
@@ -295,7 +295,7 @@
   llvm::SmallString<0> Buffer;
   clang::EmitBackendOutput(
   Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts, LangOpts,
-  

[PATCH] D100720: [AST] Update introspection API to use const-ref for copyable types

2021-04-19 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.
This revision is now accepted and ready to land.

LG with 1 nit.




Comment at: clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py:14
 
+RefClades = ["NestedNameSpecifierLoc", "TemplateArgumentLoc", "TypeLoc"]
+

nit: Any reason not to use set notation here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100720/new/

https://reviews.llvm.org/D100720

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


[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

2021-04-19 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

For the following function:

  void foo(std::unique_ptr P) {
A* praw = P.get();
A* other = praw;
if (other) {}
P->foo();
  }

Where do we expect a note? Where `praw` is initialized, where `other` is 
initialized or both?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97183/new/

https://reviews.llvm.org/D97183

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


[PATCH] D95976: [OpenMP] Simplify offloading parallel call codegen

2021-04-19 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis updated this revision to Diff 338554.
ggeorgakoudis marked 2 inline comments as done.
ggeorgakoudis added a comment.

Fix


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95976/new/

https://reviews.llvm.org/D95976

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
  openmp/libomptarget/deviceRTLs/common/generated_microtask_cases.gen
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/common/src/support.cu
  openmp/libomptarget/deviceRTLs/common/support.h
  openmp/libomptarget/deviceRTLs/interface.h
  openmp/libomptarget/utils/generate_microtask_cases.py

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


[PATCH] D99554: [ThinLTO] During module importing, close one source module before open another one for distributed mode.

2021-04-19 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D99554#2674229 , @wenlei wrote:

> Does this help non-distributed ThinLTO as well? cc: @weiwang

No. See the note in Wei's description about this:

> Note that this patch only changes the distributed thinlto mode. For in 
> process thinlto mode, one source module is shared across different thinlto 
> backend threads so it is not changed in this patch.

Specifically, for in-process ThinLTO all modules are kept open so that we don't 
need to reload a module for each thread that wants to import from it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99554/new/

https://reviews.llvm.org/D99554

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


[PATCH] D98193: [CUDA][HIP] Allow non-ODR use of host var in device

2021-04-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 338552.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Rebase and fix HIP header bug exposed by this patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98193/new/

https://reviews.llvm.org/D98193

Files:
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/device-use-host-var.cu
  clang/test/Headers/hip-header.hip
  clang/test/SemaCUDA/device-use-host-var.cu

Index: clang/test/SemaCUDA/device-use-host-var.cu
===
--- clang/test/SemaCUDA/device-use-host-var.cu
+++ clang/test/SemaCUDA/device-use-host-var.cu
@@ -5,37 +5,96 @@
 
 #include "Inputs/cuda.h"
 
-int global_host_var;
+struct A {
+  int x;
+  static int host_var;
+};
+
+int A::host_var;
+
+namespace X {
+  int host_var;
+}
+
+static int static_host_var;
+
 __device__ int global_dev_var;
 __constant__ int global_constant_var;
 __shared__ int global_shared_var;
-constexpr int global_constexpr_var = 1;
+
+int global_host_var;
 const int global_const_var = 1;
+constexpr int global_constexpr_var = 1;
+
+int global_host_array[2] = {1, 2};
+const int global_const_array[2] = {1, 2};
+constexpr int global_constexpr_array[2] = {1, 2};
+
+A global_host_struct_var{1};
+const A global_const_struct_var{1};
+constexpr A global_constexpr_struct_var{1};
 
 template
 __global__ void kernel(F f) { f(); } // dev-note2 {{called by 'kernel<(lambda}}
 
 __device__ void dev_fun(int *out) {
-  int _host_var = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  // Check access device variables are allowed.
   int _dev_var = global_dev_var;
   int _constant_var = global_constant_var;
   int _shared_var = global_shared_var;
-  const int _constexpr_var = global_constexpr_var;
-  const int _const_var = global_const_var;
-
-  *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  *out = ref_dev_var;
+  *out = ref_constant_var;
+  *out = ref_shared_var;
   *out = global_dev_var;
   *out = global_constant_var;
   *out = global_shared_var;
-  *out = global_constexpr_var;
+
+  // Check access of non-const host variables are not allowed.
+  *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
   *out = global_const_var;
+  *out = global_constexpr_var;
+  global_host_var = 1; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
 
+  // Check reference of non-constexpr host variables are not allowed.
+  int _host_var = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  const int _const_var = global_const_var; // dev-error {{reference to __host__ variable 'global_const_var' in __device__ function}}
+  const int _constexpr_var = global_constexpr_var;
   *out = ref_host_var;
-  *out = ref_dev_var;
-  *out = ref_constant_var;
-  *out = ref_shared_var;
   *out = ref_constexpr_var;
   *out = ref_const_var;
+
+  // Check access member of non-constexpr struct type host variable is not allowed.
+  *out = global_host_struct_var.x; // dev-error {{reference to __host__ variable 'global_host_struct_var' in __device__ function}}
+  *out = global_const_struct_var.x; // dev-error {{reference to __host__ variable 'global_const_struct_var' in __device__ function}}
+  *out = global_constexpr_struct_var.x;
+  global_host_struct_var.x = 1; // dev-error {{reference to __host__ variable 'global_host_struct_var' in __device__ function}}
+
+  // Check address taking of non-constexpr host variables is not allowed.
+  int *p = _host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  const int *cp = _const_var; // dev-error {{reference to __host__ variable 'global_const_var' in __device__ function}}
+  const int *cp2 = _constexpr_var;
+
+  // Check access elements of non-constexpr host array is not allowed.
+  *out = global_host_array[1]; // dev-error {{reference to __host__ variable 'global_host_array' in __device__ function}}
+  *out = global_const_array[1]; // dev-error {{reference to __host__ variable 'global_const_array' in __device__ function}}
+  *out = global_constexpr_array[1];
+
+  // Check ODR-use of host variables in namespace is not allowed.
+  *out = X::host_var; // dev-error {{reference to __host__ variable 'host_var' in __device__ function}}
+
+  // Check ODR-use of static host varables in class or file scope is not allowed.
+  *out = A::host_var; // dev-error {{reference to __host__ variable 'host_var' in __device__ function}}
+  *out = static_host_var; // dev-error {{reference to __host__ variable 'static_host_var' in __device__ function}}
+
+  // Check function-scope static variable is allowed.
+  static int static_var;
+  *out = static_var;
+
+  // Check non-ODR use of host varirables are allowed.
+  *out = 

[PATCH] D99160: [X86][FastISEL] Support DW_TAG_call_site_parameter with FastISEL

2021-04-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D99160#2698980 , @alok wrote:

> In D99160#2671899 , @dblaikie wrote:
>
>> In D99160#2670460 , @djtodoro wrote:
>>
>>> In D99160#2669576 , @dblaikie 
>>> wrote:
>>>
 In D99160#2668977 , @djtodoro 
 wrote:

> I think that the Debug Entry Values feature should not be enabled by 
> default for non optimized code, so the 
> `TargetOptions::ShouldEmitDebugEntryValues()` should be patched with 
> checking of optimization level (it should be > 0).

 That's currently intended to be already handled by the frontend, right? 
 (clang only sets `EnableDebugEntryValues` (which 
 `ShouldEmitDebugEntryValues` checks (hmm, it checks under 'or', not 'and', 
 so I'm not sure where the "only above -O0" is implemented, but it is 
 implemented somewhere?) if optimizations are enabled, yeah?)

 Oh, is entry_values actually not conditionalized? It's only the call_site 
 support that's currently conditionalized on "above -O0"?
>>>
>>> Looks like there is no explicit check of optimization level (above "-O0"), 
>>> neither on frontend nor backend for entry-values generation. I think it is 
>>> the situation since there should not be any optimization (at least that I 
>>> am aware of, in the case of C/C++) that would cause the entry-values 
>>> generation...
>>>
 Hmm - If that's the case, and we currently have some cases where 
 entry_values are emitted at -O0, I'm not sure /not/ emitting those is the 
 right call either. If we believe/have data to show that there are so few 
 useful uses of entry_value at -O0 that it's not worth the DWARF size 
 growth to put call_sites in at -O0, then I think it might still be worth 
 leaving the entry_values in (unless they take up a bunch of extra space) 
 for the cases of mixed optimization compilation (-O0 some code you're 
 debugging, but building the rest with optimizations).
>>>
>>> Yeah... That is valuable example... I am thinking in that direction as 
>>> well, and I am closer to the enabling it for -O0 case if that is useful 
>>> (and there is no dramatic cost in terms of DWARF size).
>>
>> Does anyone have this example (where DW_OP_entry_value is used at -O0)? It'd 
>> be great to look at it & see if it's a case of unnecessarily losing the 
>> location, or legitimately losing it and using entry_value for best-effort 
>> recovery (& then a question of whether the loss is appropriate at -O0, or if 
>> we want to pessimize -O0 further to avoid the loss).

I think this ^ still needs understanding/investigation. Do you have an example 
with OP_entry_value at -O0?

>> I'd worry about turning on call_sites at -O0 - there'd be a lot more calls 
>> (especially for C++ code with lots of implicit operations), but numbers will 
>> be needed in any case, so not worth much speculation.
>
> Sorry for late response.
> I tried building  
> https://github.com/flang-compiler/classic-flang-llvm-project.git (branch 
> release_11x) with compiler (current patch (https://reviews.llvm.org/D99160) 
> and https://reviews.llvm.org/D99238) with -O0 -g . 
> Interestingly there was no difference.
> Reason: https://reviews.llvm.org/D99238 is not sufficient for clang/clang++ 
> to enable call-site generation with FastISel though it is sufficient for 
> Flang compiler.
> Below additional patch is needed to generate call-sites
>
>   `
>
> diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index a77f52bd235b..8d4e11faa018 100644
>
> - a/clang/lib/CodeGen/CGDebugInfo.cpp
>
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -5149,9 +5149,9 @@ llvm::DebugLoc 
> CGDebugInfo::SourceLocToDebugLoc(SourceLocation Loc) {
>  }
>
> llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const {
>
> - // Call site-related attributes are only useful in optimized programs, and
> - // when there's a possibility of debugging backtraces.
> - if (!CGM.getLangOpts().Optimize || DebugKind == codegenoptions::NoDebugInfo 
> ||
>
> +  // Call site-related attributes are useful when there's a possibility of
> +  // debugging backtraces.
> +  if (DebugKind == codegenoptions::NoDebugInfo ||
>
> DebugKind == codegenoptions::LocTrackingOnly)
>   return llvm::DINode::FlagZero;
>
>   `
>
> With this patch Clang/Clang++ turn on LLVM IR flag "DIFlagAllCallsDescribed", 
> in absence of this LLVM does not generate call-site.
>
> With the above patch applied below is the comparison of sizes of shared 
> libraries.
>
> Name of shared library - Size (without callsite) - Size (with callsites) - % 
> incresase in size
>
>   
> 

[PATCH] D100509: Support GCC's -fstack-usage flag

2021-04-19 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng updated this revision to Diff 338551.
pzheng added a comment.

Add missing comments. Thanks for spotting it, @xbolva00.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100509/new/

https://reviews.llvm.org/D100509

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-usage.c
  clang/test/Driver/stack-usage.c
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1163,6 +1163,42 @@
   OutStreamer->PopSection();
 }
 
+void AsmPrinter::emitStackUsage(const MachineFunction ) {
+  if (!MF.getTarget().Options.EmitStackUsage)
+return;
+
+  const MachineFrameInfo  = MF.getFrameInfo();
+  uint64_t StackSize = FrameInfo.getStackSize();
+
+  auto OutputFilename = MF.getTarget().Options.StackUsageOutput;
+  if (OutputFilename.empty()) {
+SmallString<128> Val = MF.getFunction().getParent()->getName();
+
+llvm::sys::path::replace_extension(Val, "su");
+OutputFilename = std::string(Val.str());
+  }
+
+  if (StackUsageStream == nullptr) {
+std::error_code EC;
+StackUsageStream =
+std::make_unique(OutputFilename, EC, sys::fs::OF_Text);
+if (EC) {
+  errs() << "Could not open file: " << EC.message();
+  return;
+}
+  }
+
+  *StackUsageStream << MF.getFunction().getParent()->getName();
+  if (const DISubprogram *DSP = MF.getFunction().getSubprogram())
+*StackUsageStream << ":" << DSP->getLine();
+
+  *StackUsageStream << ":" << MF.getName() << "\t" << StackSize << "\t";
+  if (FrameInfo.hasVarSizedObjects())
+*StackUsageStream << "dynamic\n";
+  else
+*StackUsageStream << "static\n";
+}
+
 static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction ) {
   MachineModuleInfo  = MF.getMMI();
   if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo())
@@ -1447,6 +1483,9 @@
   // Emit section containing stack size metadata.
   emitStackSizeSection(*MF);
 
+  // Emit .su file containing function stack size information.
+  emitStackUsage(*MF);
+
   emitPatchableFunctionEntries();
 
   if (isVerbose())
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -130,7 +130,7 @@
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
   EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
   DisableIntegratedAS(false), RelaxELFRelocations(false),
-  FunctionSections(false), DataSections(false),
+  FunctionSections(false), DataSections(false), EmitStackUsage(false),
   IgnoreXCOFFVisibility(false), XCOFFTracebackTable(true),
   UniqueSectionNames(true), UniqueBasicBlockSectionNames(false),
   TrapUnreachable(false), NoTrapAfterNoreturn(false), TLSSize(0),
@@ -249,6 +249,9 @@
 /// Emit data into separate sections.
 unsigned DataSections : 1;
 
+/// Emit .su file containing information on function stack sizes.
+unsigned EmitStackUsage : 1;
+
 /// Do not emit visibility attribute for xcoff.
 unsigned IgnoreXCOFFVisibility : 1;
 
@@ -341,6 +344,11 @@
 /// Stack protector guard reg to use, e.g. usually fs or gs in X86.
 std::string StackProtectorGuardReg = "None";
 
+/// Name of the stack usage file (i.e., .su file). If empty, the name of the
+/// source file should be used to name the stack usage file (e.g., foo.su
+/// for foo.c)
+std::string StackUsageOutput = "";
+
 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
 /// on the command line. This setting may either be Default, Soft, or Hard.
 /// Default selects the target's default behavior. Soft selects the ABI for
Index: llvm/include/llvm/CodeGen/AsmPrinter.h
===
--- llvm/include/llvm/CodeGen/AsmPrinter.h
+++ llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -175,6 +175,9 @@
   /// Emit comments in assembly output if this is true.
   bool VerboseAsm;
 
+  /// Output stream for the stack usage file (i.e., .su file).
+  std::unique_ptr StackUsageStream = nullptr;
+
   static char ID;
 
 protected:
@@ -351,6 +354,8 @@
 
   void emitStackSizeSection(const MachineFunction );
 
+  void emitStackUsage(const MachineFunction );
+
   void emitBBAddrMapSection(const MachineFunction );
 
   void emitPseudoProbe(const MachineInstr );
Index: 

[PATCH] D100251: [IR][sanitizer] Set nounwind on module ctor/dtor, additionally set uwtable if -fasynchronous-unwind-tables

2021-04-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added subscribers: vitalybuka, eugenis.
MaskRay added a comment.

@eugenis @vitalybuka


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100251/new/

https://reviews.llvm.org/D100251

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


[PATCH] D99160: [X86][FastISEL] Support DW_TAG_call_site_parameter with FastISEL

2021-04-19 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok added a comment.

In D99160#2671899 , @dblaikie wrote:

> In D99160#2670460 , @djtodoro wrote:
>
>> In D99160#2669576 , @dblaikie wrote:
>>
>>> In D99160#2668977 , @djtodoro 
>>> wrote:
>>>
 I think that the Debug Entry Values feature should not be enabled by 
 default for non optimized code, so the 
 `TargetOptions::ShouldEmitDebugEntryValues()` should be patched with 
 checking of optimization level (it should be > 0).
>>>
>>> That's currently intended to be already handled by the frontend, right? 
>>> (clang only sets `EnableDebugEntryValues` (which 
>>> `ShouldEmitDebugEntryValues` checks (hmm, it checks under 'or', not 'and', 
>>> so I'm not sure where the "only above -O0" is implemented, but it is 
>>> implemented somewhere?) if optimizations are enabled, yeah?)
>>>
>>> Oh, is entry_values actually not conditionalized? It's only the call_site 
>>> support that's currently conditionalized on "above -O0"?
>>
>> Looks like there is no explicit check of optimization level (above "-O0"), 
>> neither on frontend nor backend for entry-values generation. I think it is 
>> the situation since there should not be any optimization (at least that I am 
>> aware of, in the case of C/C++) that would cause the entry-values 
>> generation...
>>
>>> Hmm - If that's the case, and we currently have some cases where 
>>> entry_values are emitted at -O0, I'm not sure /not/ emitting those is the 
>>> right call either. If we believe/have data to show that there are so few 
>>> useful uses of entry_value at -O0 that it's not worth the DWARF size growth 
>>> to put call_sites in at -O0, then I think it might still be worth leaving 
>>> the entry_values in (unless they take up a bunch of extra space) for the 
>>> cases of mixed optimization compilation (-O0 some code you're debugging, 
>>> but building the rest with optimizations).
>>
>> Yeah... That is valuable example... I am thinking in that direction as well, 
>> and I am closer to the enabling it for -O0 case if that is useful (and there 
>> is no dramatic cost in terms of DWARF size).
>
> Does anyone have this example (where DW_OP_entry_value is used at -O0)? It'd 
> be great to look at it & see if it's a case of unnecessarily losing the 
> location, or legitimately losing it and using entry_value for best-effort 
> recovery (& then a question of whether the loss is appropriate at -O0, or if 
> we want to pessimize -O0 further to avoid the loss).
>
> I'd worry about turning on call_sites at -O0 - there'd be a lot more calls 
> (especially for C++ code with lots of implicit operations), but numbers will 
> be needed in any case, so not worth much speculation.

Sorry for late response.
I tried building  
https://github.com/flang-compiler/classic-flang-llvm-project.git (branch 
release_11x) with compiler (current patch (https://reviews.llvm.org/D99160) and 
https://reviews.llvm.org/D99238) with -O0 -g . 
Interestingly there was no difference.
Reason: https://reviews.llvm.org/D99238 is not sufficient for clang/clang++ to 
enable call-site generation with FastISel though it is sufficient for Flang 
compiler.
Below additional patch is needed to generate call-sites

  `

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index a77f52bd235b..8d4e11faa018 100644

- a/clang/lib/CodeGen/CGDebugInfo.cpp

+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5149,9 +5149,9 @@ llvm::DebugLoc 
CGDebugInfo::SourceLocToDebugLoc(SourceLocation Loc) {
 }

llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const {

- // Call site-related attributes are only useful in optimized programs, and
- // when there's a possibility of debugging backtraces.
- if (!CGM.getLangOpts().Optimize || DebugKind == codegenoptions::NoDebugInfo ||

+  // Call site-related attributes are useful when there's a possibility of
+  // debugging backtraces.
+  if (DebugKind == codegenoptions::NoDebugInfo ||

DebugKind == codegenoptions::LocTrackingOnly)
  return llvm::DINode::FlagZero;

  `

With this patch Clang/Clang++ turn on LLVM IR flag "DIFlagAllCallsDescribed", 
in absence of this LLVM does not generate call-site.

With the above patch applied below is the comparison of sizes of shared 
libraries.

Name of shared library - Size (without callsite) - Size (with callsites) - % 
incresase in size

  
```

PipSqueak.so 73192 75048 2%
SecondLib.so 73192 75048 2%
TestPlugin.so 1694024 1700704 0%
libLLVMDlltoolDriver.so 336568 347872 3%
libLLVMDebugInfoPDB.so 14463832 15360784 6%
libLLVMOrcError.so 108880 84 2%
libLLVMTarget.so 2645104 2677448 1%
libLLVMFrontendOpenMP.so 2354728 2505232 6%

[PATCH] D100350: [AIX] Diagnose thinLTO usage in clang on AIX.

2021-04-19 Thread wael yehia via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG369c0e0f48dd: [AIX] Diagnose thinLTO usage in clang on AIX. 
(authored by w2yehia).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100350/new/

https://reviews.llvm.org/D100350

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/aix-unsupported-features.c


Index: clang/test/Driver/aix-unsupported-features.c
===
--- /dev/null
+++ clang/test/Driver/aix-unsupported-features.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -flto=thin 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECKTHINLTO %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -flto=thin 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECKTHINLTO %s
+
+// CHECKTHINLTO: error: the clang compiler does not support 'thinLTO on AIX'
+
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -3998,10 +3998,13 @@
   }
 
   const llvm::Triple  = C.getDefaultToolChain().getTriple();
-  if (RawTriple.isOSAIX())
+  if (RawTriple.isOSAIX()) {
 if (Arg *A = C.getArgs().getLastArg(options::OPT_G))
   Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getSpelling() << RawTriple.str();
+if (LTOMode == LTOK_Thin)
+  Diag(diag::err_drv_clang_unsupported) << "thinLTO on AIX";
+  }
 
   // Collect the list of architectures.
   llvm::StringSet<> ArchNames;


Index: clang/test/Driver/aix-unsupported-features.c
===
--- /dev/null
+++ clang/test/Driver/aix-unsupported-features.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -flto=thin 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECKTHINLTO %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -flto=thin 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECKTHINLTO %s
+
+// CHECKTHINLTO: error: the clang compiler does not support 'thinLTO on AIX'
+
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -3998,10 +3998,13 @@
   }
 
   const llvm::Triple  = C.getDefaultToolChain().getTriple();
-  if (RawTriple.isOSAIX())
+  if (RawTriple.isOSAIX()) {
 if (Arg *A = C.getArgs().getLastArg(options::OPT_G))
   Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getSpelling() << RawTriple.str();
+if (LTOMode == LTOK_Thin)
+  Diag(diag::err_drv_clang_unsupported) << "thinLTO on AIX";
+  }
 
   // Collect the list of architectures.
   llvm::StringSet<> ArchNames;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 369c0e0 - [AIX] Diagnose thinLTO usage in clang on AIX.

2021-04-19 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2021-04-19T16:39:48Z
New Revision: 369c0e0f48dd3585566d251cc99955dbdeed84a1

URL: 
https://github.com/llvm/llvm-project/commit/369c0e0f48dd3585566d251cc99955dbdeed84a1
DIFF: 
https://github.com/llvm/llvm-project/commit/369c0e0f48dd3585566d251cc99955dbdeed84a1.diff

LOG: [AIX] Diagnose thinLTO usage in clang on AIX.

Reviewed By: Xiangling Liao

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

Added: 
clang/test/Driver/aix-unsupported-features.c

Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 39a630a7b4e8a..9a1b106673263 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3998,10 +3998,13 @@ void Driver::BuildJobs(Compilation ) const {
   }
 
   const llvm::Triple  = C.getDefaultToolChain().getTriple();
-  if (RawTriple.isOSAIX())
+  if (RawTriple.isOSAIX()) {
 if (Arg *A = C.getArgs().getLastArg(options::OPT_G))
   Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getSpelling() << RawTriple.str();
+if (LTOMode == LTOK_Thin)
+  Diag(diag::err_drv_clang_unsupported) << "thinLTO on AIX";
+  }
 
   // Collect the list of architectures.
   llvm::StringSet<> ArchNames;

diff  --git a/clang/test/Driver/aix-unsupported-features.c 
b/clang/test/Driver/aix-unsupported-features.c
new file mode 100644
index 0..0004575a223ae
--- /dev/null
+++ b/clang/test/Driver/aix-unsupported-features.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -flto=thin 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECKTHINLTO %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -flto=thin 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECKTHINLTO %s
+
+// CHECKTHINLTO: error: the clang compiler does not support 'thinLTO on AIX'
+



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


[PATCH] D96418: [clang] Refactor mustprogress handling, add it to all loops in c++11+.

2021-04-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

I only found one tiny nit, and otherwise it LGTM, but this is a bit out of my 
wheelhouse.




Comment at: clang/lib/CodeGen/CodeGenFunction.h:529
+// following (6.9.2.3.1 in C++11):
+// - terminate,
+//  - make a call to a library I/O function,




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96418/new/

https://reviews.llvm.org/D96418

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


[clang] 6a72ed2 - [clang] NFC: Fix range-based for loop warnings related to decl lookup

2021-04-19 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-04-19T18:31:31+02:00
New Revision: 6a72ed239cc3f30c1149721f07de463b4b459b16

URL: 
https://github.com/llvm/llvm-project/commit/6a72ed239cc3f30c1149721f07de463b4b459b16
DIFF: 
https://github.com/llvm/llvm-project/commit/6a72ed239cc3f30c1149721f07de463b4b459b16.diff

LOG: [clang] NFC: Fix range-based for loop warnings related to decl lookup

Added: 


Modified: 
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaCodeComplete.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 7e5d96fb8633e..5ecd88e7a14c9 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -2887,7 +2887,7 @@ static void configureBlocksRuntimeObject(CodeGenModule 
,
"expected Function or GlobalVariable");
 
 const NamedDecl *ND = nullptr;
-for (const auto  : DC->lookup())
+for (const auto *Result : DC->lookup())
   if ((ND = dyn_cast(Result)) ||
   (ND = dyn_cast(Result)))
 break;

diff  --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 27fe048f827d0..1cd718d2e22fc 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -337,7 +337,7 @@ void CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction 
,
   IdentifierInfo  =
   CGM.getContext().Idents.get(LaunchKernelName);
   FunctionDecl *cudaLaunchKernelFD = nullptr;
-  for (const auto  : DC->lookup()) {
+  for (auto *Result : DC->lookup()) {
 if (FunctionDecl *FD = dyn_cast(Result))
   cudaLaunchKernelFD = FD;
   }

diff  --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 6e6b73f550e35..a790841caa0b3 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -1232,7 +1232,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
 
 const ObjCInterfaceDecl *OID = nullptr;
-for (const auto  : DC->lookup())
+for (const auto *Result : DC->lookup())
   if ((OID = dyn_cast(Result)))
 break;
 
@@ -2319,7 +2319,7 @@ llvm::Value 
*CGObjCGNU::EmitNSAutoreleasePoolClassRef(CodeGenFunction ) {
   DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
 
   const VarDecl *VD = nullptr;
-  for (const auto  : DC->lookup())
+  for (const auto *Result : DC->lookup())
 if ((VD = dyn_cast(Result)))
   break;
 

diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 76ea28c933134..3de67bb4bbc5c 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -6522,7 +6522,7 @@ static llvm::GlobalValue::DLLStorageClassTypes 
getStorage(CodeGenModule ,
   DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
 
   const VarDecl *VD = nullptr;
-  for (const auto  : DC->lookup())
+  for (const auto *Result : DC->lookup())
 if ((VD = dyn_cast(Result)))
   break;
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index f719f009ea999..45c150c57c6c3 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3644,8 +3644,8 @@ GetRuntimeFunctionDecl(ASTContext , StringRef Name) {
   DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
 
   IdentifierInfo  = C.Idents.get(Name);
-  for (const auto  : DC->lookup())
-if (const auto FD = dyn_cast(Result))
+  for (const auto *Result : DC->lookup())
+if (const auto *FD = dyn_cast(Result))
   return FD;
 
   if (!C.getLangOpts().CPlusPlus)
@@ -3659,15 +3659,15 @@ GetRuntimeFunctionDecl(ASTContext , StringRef Name) {
 
   for (const auto  : {"__cxxabiv1", "std"}) {
 IdentifierInfo  = C.Idents.get(N);
-for (const auto  : DC->lookup()) {
-  NamespaceDecl *ND = dyn_cast(Result);
-  if (auto LSD = dyn_cast(Result))
-for (const auto  : LSD->lookup())
+for (const auto *Result : DC->lookup()) {
+  const NamespaceDecl *ND = dyn_cast(Result);
+  if (auto *LSD = dyn_cast(Result))
+for (const auto *Result : LSD->lookup())
   if ((ND = dyn_cast(Result)))
 break;
 
   if (ND)
-for (const auto  : ND->lookup())
+for (const auto *Result : ND->lookup())
   if (const auto *FD = dyn_cast(Result))
 return FD;
 }
@@ -5038,7 +5038,7 @@ CodeGenModule::GetAddrOfConstantCFString(const 
StringLiteral *Literal) {
 DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
 
 const VarDecl *VD = nullptr;
-for (const auto  : DC->lookup())
+for (const auto *Result : DC->lookup())
   if ((VD = dyn_cast(Result)))
 

[PATCH] D98193: [CUDA][HIP] Allow non-ODR use of host var in device

2021-04-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/test/CodeGenCUDA/device-use-host-var.cu:22
+
+// CHECK: store i32 1
+// CHECK: store i32 2

tra wrote:
> Nit: You may want to add a `CHECK-LABEL: `. It does not make 
> much of a difference in this file, but is useful in general to explicitly 
> restrict the search scope. 
will do


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98193/new/

https://reviews.llvm.org/D98193

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


[PATCH] D98193: [CUDA][HIP] Allow non-ODR use of host var in device

2021-04-19 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Small test nit. LGTM otherwise.




Comment at: clang/test/CodeGenCUDA/device-use-host-var.cu:22
+
+// CHECK: store i32 1
+// CHECK: store i32 2

Nit: You may want to add a `CHECK-LABEL: `. It does not make 
much of a difference in this file, but is useful in general to explicitly 
restrict the search scope. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98193/new/

https://reviews.llvm.org/D98193

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


[PATCH] D100499: [AArch64] Neon Polynomial vadd Intrinsic Fix

2021-04-19 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic added a comment.

Here's the fix for enabling these on ARM:
https://reviews.llvm.org/D100772


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100499/new/

https://reviews.llvm.org/D100499

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


[PATCH] D100772: [ARM] Neon Polynomial vadd Intrinsic fix

2021-04-19 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic created this revision.
rsanthir.quic added reviewers: t.p.northover, DavidSpickett, labrinea, apazos.
Herald added subscribers: danielkiss, kristof.beyls.
rsanthir.quic requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The Neon vadd intrinsics were added to the ARMSIMD intrinsic map,
however due to being defined under an AArch64 guard in arm_neon.td,
were not previously useable on ARM. This change rectifies that.

It is important to note that poly128 is not valid on ARM, thus it was
extracted out of the original arm_neon.td definition and separated
for the sake of AArch64.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100772

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/test/CodeGen/arm-poly-add.c

Index: clang/test/CodeGen/arm-poly-add.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-poly-add.c
@@ -0,0 +1,86 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple armv8.2a-arm-none-eabi \
+// RUN:   -target-feature +neon \
+// RUN:   -target-feature +bf16 -mfloat-abi hard \
+// RUN: -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg \
+// RUN:  | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vadd_p8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <8 x i8> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:ret <8 x i8> [[TMP0]]
+//
+poly8x8_t test_vadd_p8(poly8x8_t a, poly8x8_t b) {
+  return vadd_p8 (a, b);
+}
+
+// CHECK-LABEL: @test_vadd_p16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i16> [[A:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <8 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to <4 x i16>
+// CHECK-NEXT:ret <4 x i16> [[TMP3]]
+//
+poly16x4_t test_vadd_p16(poly16x4_t a, poly16x4_t b) {
+  return vadd_p16 (a, b);
+}
+
+// CHECK-LABEL: @test_vadd_p64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <1 x i64> [[A:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <1 x i64> [[B:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <8 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to <1 x i64>
+// CHECK-NEXT:ret <1 x i64> [[TMP3]]
+//
+poly64x1_t test_vadd_p64(poly64x1_t a, poly64x1_t b) {
+  return vadd_p64(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <16 x i8> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+poly8x16_t test_vaddq_p8(poly8x16_t a, poly8x16_t b){
+  return vaddq_p8(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <8 x i16> [[A:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x i16> [[B:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP3]]
+//
+poly16x8_t test_vaddq_p16(poly16x8_t a, poly16x8_t b){
+  return vaddq_p16(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <2 x i64> [[A:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <2 x i64> [[B:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to <2 x i64>
+// CHECK-NEXT:ret <2 x i64> [[TMP3]]
+//
+poly64x2_t test_vaddq_p64(poly64x2_t a, poly64x2_t b){
+  return vaddq_p64(a, b);
+}
+
+// TODO: poly128_t not implemented on aarch32
+// CHCK-LABEL: @test_vaddq_p128(
+// CHCK-NEXT:  entry:
+// CHCK-NEXT:[[TMP0:%.*]] = bitcast i128 [[A:%.*]] to <16 x i8>
+// CHCK-NEXT:[[TMP1:%.*]] = bitcast i128 [[B:%.*]] to <16 x i8>
+// CHCK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHCK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to i128
+// CHCK-NEXT:ret i128 [[TMP3]]
+//
+//poly128_t test_vaddq_p128 (poly128_t a, poly128_t b){
+//  return vaddq_p128(a, b);
Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -708,6 +708,11 @@
 def SCALAR_HALF_GET_LANEQ : IOpInst<"vget_lane", "1.I", "Qh", OP_SCALAR_HALF_GET_LNQ>;
 def SCALAR_HALF_SET_LANEQ : IOpInst<"vset_lane", ".1.I", "Qh", OP_SCALAR_HALF_SET_LNQ>;
 
+
+// Crypto
+// TODO: poly128_t not implemented on aarch32
+def VADDP_Q   : WInst<"vadd", "...", "PcPsPlQPcQPsQPl">;
+
 
 // AArch64 Intrinsics
 
@@ -1160,7 +1165,7 @@
 def SM4EKEY : SInst<"vsm4ekey", "...", "QUi">;
 }
 
-def VADDP   

[PATCH] D99861: [Clang] Record tokens in attribute arguments for user-defined C++/C2x attributes

2021-04-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D99861#2697449 , @Qix- wrote:

> I'm not sure exactly how to continue after the last few comments - what 
> should the approach be for this patch? Or are these things we can shoot for 
> in later patches?

I don't think they're things we should shoot for in a later patch; the token 
replay approach doesn't seem like it would work for more complicated attribute 
arguments. As a concrete example of what would be super difficult to support 
would be:

  struct S {
int member;
void func(int i, int j) [[plugin::attr(i + j + member)]];
  };

because it would be very difficult to recognize that `member` is looked up in 
the context of the declaration of `S::func()` after having left the parsing 
context for the structure.

I think the one way to continue is along the lines of what's described in 
https://bugs.llvm.org/show_bug.cgi?id=46446#c11 so that the plugin handles 
parsing the arguments by invoking calls on the parser.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99861/new/

https://reviews.llvm.org/D99861

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


[PATCH] D100499: [AArch64] Neon Polynomial vadd Intrinsic Fix

2021-04-19 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic updated this revision to Diff 338539.
rsanthir.quic added a comment.

only the pol128 intrinsic is incompatible with ARM, the rest should be 
supported.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100499/new/

https://reviews.llvm.org/D100499

Files:
  clang/lib/CodeGen/CGBuiltin.cpp


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5460,8 +5460,7 @@
   NEONMAP1(vabsq_v, arm_neon_vabs, 0),
   NEONMAP0(vadd_v),
   NEONMAP0(vaddhn_v),
-  NEONMAP0(vaddq_p128),
-  NEONMAP0(vaddq_v),
+  NEONMAP0(vaddq_v),
   NEONMAP1(vaesdq_v, arm_neon_aesd, 0),
   NEONMAP1(vaeseq_v, arm_neon_aese, 0),
   NEONMAP1(vaesimcq_v, arm_neon_aesimc, 0),


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5460,8 +5460,7 @@
   NEONMAP1(vabsq_v, arm_neon_vabs, 0),
   NEONMAP0(vadd_v),
   NEONMAP0(vaddhn_v),
-  NEONMAP0(vaddq_p128),
-  NEONMAP0(vaddq_v),
+  NEONMAP0(vaddq_v),
   NEONMAP1(vaesdq_v, arm_neon_aesd, 0),
   NEONMAP1(vaeseq_v, arm_neon_aese, 0),
   NEONMAP1(vaesimcq_v, arm_neon_aesimc, 0),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100499: [AArch64] Neon Polynomial vadd Intrinsic Fix

2021-04-19 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic added a comment.

Thanks for looking into this @DavidSpickett ! What you found makes sense. I'll 
update this patch to remove only the poly128 vadd from the mapping. I'll also 
add another patch that will correctly enable the remaining vadd intrinsics for 
ARM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100499/new/

https://reviews.llvm.org/D100499

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


[PATCH] D95976: [OpenMP] Simplify offloading parallel call codegen

2021-04-19 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:591-592
 
   return Bld.CreateAnd(Bld.CreateNUWSub(NumThreads, Bld.getInt32(1)),
Bld.CreateNot(Mask), "master_tid");
 }

This is another undefined codegen call order which causes the current pre-merge 
checks to fail.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95976/new/

https://reviews.llvm.org/D95976

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


[PATCH] D99433: [Matrix] Including __builtin_matrix_multiply_add for the matrix type extension.

2021-04-19 Thread Florian Hahn via Phabricator via cfe-commits
fhahn requested changes to this revision.
fhahn added a comment.
This revision now requires changes to proceed.

In D99433#2662275 , 
@everton.constantino wrote:

> Great, Ill update the patch then. Thanks for the comments!

Sounds good to me, thanks! Marking as changes requested until then, to remove 
it from the review queue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99433/new/

https://reviews.llvm.org/D99433

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


[PATCH] D100768: [Clang][OpenMP] Remove the mandatory flush for capture for OpenMP 5.1

2021-04-19 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, ABataev.
Herald added subscribers: jfb, guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

In OpenMP 5.1, the required flush for capture is gone.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100768

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/atomic_capture_codegen.cpp

Index: clang/test/OpenMP/atomic_capture_codegen.cpp
===
--- clang/test/OpenMP/atomic_capture_codegen.cpp
+++ clang/test/OpenMP/atomic_capture_codegen.cpp
@@ -1,11 +1,19 @@
 
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-50 %s
 
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp-simd -x c -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -fopenmp-version=51 -x c -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp-simd -fopenmp-version=51 -x c -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 // expected-no-diagnostics
 #ifndef HEADER
@@ -343,7 +351,7 @@
 // CHECK: [[IM_CAST:%.+]] = fptrunc double [[NEW_IM]] to float
 // CHECK: store float [[RE_CAST]], float* getelementptr inbounds ({ float, float }, { float, float }* @{{.+}}, i32 0, i32 0),
 // CHECK: store float [[IM_CAST]], float* getelementptr inbounds ({ float, float }, { float, float }* @{{.+}}, i32 0, i32 1),
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic capture seq_cst
   {cdx = cdx - cdv; cfv = cdx;}
 // CHECK: [[BV:%.+]] = load i8, i8* @{{.+}}
@@ -393,7 +401,7 @@
 // CHECK: br i1 [[SUCCESS_FAIL]], label %[[EXIT:.+]], label %[[CONT]]
 // CHECK: [[EXIT]]
 // CHECK: store i8 [[NEW]], i8* @{{.+}},
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic capture, seq_cst
   {cx = cx >> ucv; cv = cx;}
 // CHECK: [[SV:%.+]]  = load i16, i16* @{{.+}},
@@ -436,7 +444,7 @@
 // CHECK: [[OLD:%.+]] = atomicrmw or i32* @{{.+}}, i32 [[EXPR]] seq_cst, align 4
 // CHECK: [[DESIRED:%.+]] = or i32 [[EXPR]], [[OLD]]
 // CHECK: store i32 [[DESIRED]], i32* @{{.+}},
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic seq_cst, capture
   {uix = iv | uix; uiv = uix;}
 // CHECK: [[EXPR:%.+]] = load i32, i32* @{{.+}}
@@ -904,7 +912,7 @@
 // CHECK: [[EXIT]]
 // CHECK: [[NEW_VAL:%.+]] = trunc i64 [[CONV]] to i32
 // CHECK: store i32 [[NEW_VAL]], i32* @{{.+}},
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic capture release
   {bfx4.b /= ldv; iv = bfx4.b;}
 // CHECK: [[EXPR:%.+]] = load x86_fp80, x86_fp80* @{{.+}}
@@ -937,7 +945,7 @@
 // CHECK: [[EXIT]]
 // CHECK: [[NEW_VAL_I32:%.+]] = trunc i64 [[NEW_VAL]] to i32
 // CHECK: store i32 [[NEW_VAL_I32]], i32* @{{.+}},
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic capture acquire
   iv = bfx4_packed.b += ldv;
 // CHECK: load i64, i64*
@@ -963,7 +971,7 @@
 // CHECK: br i1 [[FAIL_SUCCESS]], label %[[EXIT:.+]], label %[[CONT]]
 // CHECK: [[EXIT]]
 // CHECK: store float [[X]], float* @{{.+}},
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic capture acq_rel
   {fv = float2x.x; float2x.x = ulv - float2x.x;}
 // CHECK: 

[PATCH] D96418: [clang] Refactor mustprogress handling, add it to all loops in c++11+.

2021-04-19 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D96418#2676338 , @lebedev.ri wrote:

> Seems fine to me.
> Might be good for someone else (@aaron.ballman ?) to also take a look, not 
> sure.

ping. @aaron.ballman any chance you could take another quick look?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96418/new/

https://reviews.llvm.org/D96418

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


[PATCH] D100673: [OPENMP]Fix PR49698: OpenMP declare mapper causes segmentation fault.

2021-04-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D100673#2698168 , @protze.joachim 
wrote:

> I tested the patch and still get wrong results (I modified the 
> `declare_mapper_nested_default_mappers_complex_structure.cpp` test to use my 
> verbose printf from bugzilla):
>
>   Modified Data Hierarchy:
>   Object C (0x623e50, 2) Contents:
>   Object B (0x623e80, 2) Contents:
>   Object A (0x6243f0) Contents:
>   data1 = 6439680  data2 = 0
>   Object A (0x6243f8) Contents:
>   data1 = -784902216  data2 = 11062
>   Object B (0x623e90, 2) Contents:
>   Object A (0x6249e0) Contents:
>   data1 = 6441856  data2 = 0
>   Object A (0x6249e8) Contents:
>   data1 = 6439904  data2 = 0
>   Object C (0x623e60, 2) Contents:
>   Object B (0x623ef0, 2) Contents:
>   Object A (0x624b90) Contents:
>   data1 = 6438736  data2 = 0
>   Object A (0x624b98) Contents:
>   data1 = 6441344  data2 = 0
>   Object B (0x623f00, 2) Contents:
>   Object A (0x624c60) Contents:
>   data1 = 6444032  data2 = 0
>   Object A (0x624c68) Contents:
>   data1 = 6441856  data2 = 0
>
> The values inside the target region look good, but things break when mapping 
> back.
>
> When I remove the `teams distribute for` and only leave `#pragma omp target`, 
> I get a different result and the test mistakenly passes:
>
>   Modified Data Hierarchy:
>   Object C (0x622e40, 2) Contents:
>   Object B (0x622e70, 2) Contents:
>   Object A (0x6233e0) Contents:
>   data1 = 6433120  data2 = 0
>   Object A (0x6233e8) Contents:
>   data1 = 11  data2 = 22
>   Object B (0x622e80, 2) Contents:
>   Object A (0x6239d0) Contents:
>   data1 = 6435792  data2 = 0
>   Object A (0x6239d8) Contents:
>   data1 = 11  data2 = 22
>   Object C (0x622e50, 2) Contents:
>   Object B (0x622ee0, 2) Contents:
>   Object A (0x623b80) Contents:
>   data1 = 6437312  data2 = 0
>   Object A (0x623b88) Contents:
>   data1 = 11  data2 = 22
>   Object B (0x622ef0, 2) Contents:
>   Object A (0x623c50) Contents:
>   data1 = 6437744  data2 = 0
>   Object A (0x623c58) Contents:
>   data1 = 11  data2 = 22
>   Testing for correctness...
>   outer[1].arr[1].arr[1].data2 = 22.
>
> I'm currently only testing x86_64 offloading.

The problem is in transferring from the device. Looks like we need not only to 
invert the list of data in one data transfer block but also invert the list of 
blocks. Trying to implement this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100673/new/

https://reviews.llvm.org/D100673

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


[PATCH] D90835: [RFC][clang-tidy] Ignore diagnostics due to macro expansion from not-interested headers

2021-04-19 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 338520.
DmitryPolukhin added a comment.

Fix wrong character


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90835/new/

https://reviews.llvm.org/D90835

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/macros.h
  clang-tools-extra/test/clang-tidy/infrastructure/macros_filter.h

Index: clang-tools-extra/test/clang-tidy/infrastructure/macros_filter.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/macros_filter.h
@@ -0,0 +1,3 @@
+#define HEADER_FILTER_MACRO_DIAG_IN_ARG(a) a
+#define HEADER_FILTER_MACRO_DIAG_IN_BODY int var_B1[10]
+#define HEADER_FILTER_MACRO_DIAG_IN_BODY2 int var_B2[10]
Index: clang-tools-extra/test/clang-tidy/infrastructure/macros.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/macros.h
@@ -0,0 +1,9 @@
+#define HEADER_MACRO_DIAG_IN_ARG(a) a
+#define HEADER_MACRO_DIAG_IN_BODY int var_C1[10]
+#define HEADER_MACRO_DIAG_IN_BODY2 int var_C2[10]
+
+#define DEFINE_bool(name, val)\
+  namespace fLB { \
+  typedef char FLAG_##name##_value_is_not_a_bool[(sizeof(val) != sizeof(bool)) ? -1 : 1]; \
+  }   \
+  bool FLAG_##name = val
Index: clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
@@ -1,7 +1,42 @@
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' %s -- | FileCheck %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor,modernize-avoid-c-arrays' --header-filter='macros_filter.h' --filter-macro-from-headers %s -- | FileCheck %s
+// RUN: clang-tidy --config='{"Checks": "-*,google-explicit-constructor,modernize-avoid-c-arrays", "HeaderFilterRegex": "macros_filter.h", "FilterMacroFromHeaders": true}' %s -- | FileCheck %s
+
+#include "macros.h"
+#include "macros_filter.h"
 
 #define Q(name) class name { name(int i); }
 
 Q(A);
 // CHECK: :[[@LINE-1]]:3: warning: single-argument constructors must be marked explicit
-// CHECK: :3:30: note: expanded from macro 'Q'
+// CHECK: :[[@LINE-4]]:30: note: expanded from macro 'Q'
+
+#define MAIN_MACRO_DIAG_IN_ARG(a) a
+MAIN_MACRO_DIAG_IN_ARG(int var_A[10]);
+// CHECK: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use std::array<> instead
+
+#define MAIN_MACRO_DIAG_IN_BODY int var_A1[10]
+MAIN_MACRO_DIAG_IN_BODY;
+// CHECK: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK: :[[@LINE-3]]:33: note: expanded from macro 'MAIN_MACRO_DIAG_IN_BODY'
+
+HEADER_FILTER_MACRO_DIAG_IN_ARG(int var_B[10]);
+// CHECK: :[[@LINE-1]]:33: warning: do not declare C-style arrays, use std::array<> instead
+
+HEADER_FILTER_MACRO_DIAG_IN_BODY;
+// CHECK: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK: note: expanded from macro 'HEADER_FILTER_MACRO_DIAG_IN_BODY'
+
+#define MAIN_MACRO_WRAPPER HEADER_FILTER_MACRO_DIAG_IN_BODY2
+MAIN_MACRO_WRAPPER;
+// CHECK: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK: note: expanded from macro 'MAIN_MACRO_WRAPPER'
+// CHECK: note: expanded from macro 'HEADER_FILTER_MACRO_DIAG_IN_BODY2'
+
+HEADER_MACRO_DIAG_IN_ARG(int var_C[10]);
+HEADER_MACRO_DIAG_IN_BODY;
+
+#define MAIN_MACRO_WRAPPER2 HEADER_MACRO_DIAG_IN_BODY2
+MAIN_MACRO_WRAPPER2;
+
+DEFINE_bool(test, false);
+// CHECK-NOT: warning:
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -43,12 +43,13 @@
 
 $ clang-tidy -dump-config
 ---
-Checks:  '-*,some-check'
-WarningsAsErrors:''
-HeaderFilterRegex:   ''
-FormatStyle: none
-InheritParentConfig: true
-User:user
+Checks: '-*,some-check'
+WarningsAsErrors:   ''
+HeaderFilterRegex:  ''
+FilterMacroFromHeaders: true
+FormatStyle:none
+InheritParentConfig:true
+User:   user
 CheckOptions:
   - key: some-check.SomeOption

[PATCH] D93978: [clangd] Use dirty filesystem when performing cross file tweaks

2021-04-19 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 338518.
njames93 added a comment.

Fix up compilation failures and test failures.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93978/new/

https://reviews.llvm.org/D93978

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
@@ -68,13 +68,14 @@
 // Returns None if and only if prepare() failed.
 llvm::Optional>
 applyTweak(ParsedAST , const Annotations , StringRef TweakID,
-   const SymbolIndex *Index) {
+   const SymbolIndex *Index, llvm::vfs::FileSystem *FS) {
   auto Range = rangeOrPoint(Input);
   llvm::Optional> Result;
   SelectionTree::createEach(AST.getASTContext(), AST.getTokens(), Range.first,
 Range.second, [&](SelectionTree ST) {
   Tweak::Selection S(Index, AST, Range.first,
- Range.second, std::move(ST));
+ Range.second, std::move(ST),
+ FS);
   if (auto T = prepareTweak(TweakID, S, nullptr)) {
 Result = (*T)->apply(S);
 return true;
@@ -98,7 +99,9 @@
   TU.ExtraArgs = ExtraArgs;
   TU.AdditionalFiles = std::move(ExtraFiles);
   ParsedAST AST = TU.build();
-  auto Result = applyTweak(AST, Input, TweakID, Index);
+  auto Result = applyTweak(
+  AST, Input, TweakID, Index,
+  ().getFileManager().getVirtualFileSystem());
   // We only care if prepare() succeeded, but must handle Errors.
   if (Result && !*Result)
 consumeError(Result->takeError());
@@ -119,7 +122,9 @@
   TU.ExtraArgs = ExtraArgs;
   ParsedAST AST = TU.build();
 
-  auto Result = applyTweak(AST, Input, TweakID, Index.get());
+  auto Result = applyTweak(
+  AST, Input, TweakID, Index.get(),
+  ().getFileManager().getVirtualFileSystem());
   if (!Result)
 return "unavailable";
   if (!*Result)
Index: clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
===
--- clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
+++ clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
@@ -47,7 +47,8 @@
   auto Tree =
   SelectionTree::createRight(AST.getASTContext(), AST.getTokens(), 0, 0);
   auto Actual = prepareTweak(
-  TweakID, Tweak::Selection(nullptr, AST, 0, 0, std::move(Tree)), );
+  TweakID, Tweak::Selection(nullptr, AST, 0, 0, std::move(Tree), nullptr),
+  );
   ASSERT_TRUE(bool(Actual));
   EXPECT_EQ(Actual->get()->id(), TweakID);
 }
Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -210,7 +210,8 @@
   vlog("  {0} {1}", Pos, Tok.text(AST->getSourceManager()));
   auto Tree = SelectionTree::createRight(AST->getASTContext(),
  AST->getTokens(), Start, End);
-  Tweak::Selection Selection(, *AST, Start, End, std::move(Tree));
+  Tweak::Selection Selection(, *AST, Start, End, std::move(Tree),
+ nullptr);
   for (const auto  :
prepareTweaks(Selection, Opts.TweakFilter, Opts.FeatureModules)) {
 auto Result = T->apply(Selection);
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -64,9 +64,8 @@
 
 llvm::Optional getSourceFile(llvm::StringRef FileName,
const Tweak::Selection ) {
-  if (auto Source = getCorrespondingHeaderOrSource(
-  FileName,
-  >getSourceManager().getFileManager().getVirtualFileSystem()))
+  assert(Sel.FS);
+  if (auto Source = getCorrespondingHeaderOrSource(FileName, Sel.FS))
 return *Source;
   return getCorrespondingHeaderOrSource(FileName, *Sel.AST, Sel.Index);
 }
@@ -414,12 +413,11 @@
   return error("Couldn't get absolute path for main file.");
 
 auto CCFile = getSourceFile(*MainFileName, Sel);
+
 if (!CCFile)
   return error("Couldn't find a suitable implementation file.");
-
-auto  =
-

[PATCH] D90835: [RFC][clang-tidy] Ignore diagnostics due to macro expansion from not-interested headers

2021-04-19 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 338517.
DmitryPolukhin added a comment.

Put feature behind flag


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90835/new/

https://reviews.llvm.org/D90835

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/macros.h
  clang-tools-extra/test/clang-tidy/infrastructure/macros_filter.h

Index: clang-tools-extra/test/clang-tidy/infrastructure/macros_filter.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/macros_filter.h
@@ -0,0 +1,3 @@
+#define HEADER_FILTER_MACRO_DIAG_IN_ARG(a) a
+#define HEADER_FILTER_MACRO_DIAG_IN_BODY int var_B1[10]
+#define HEADER_FILTER_MACRO_DIAG_IN_BODY2 int var_B2[10]
Index: clang-tools-extra/test/clang-tidy/infrastructure/macros.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/macros.h
@@ -0,0 +1,9 @@
+#define HEADER_MACRO_DIAG_IN_ARG(a) a
+#define HEADER_MACRO_DIAG_IN_BODY int var_C1[10]
+#define HEADER_MACRO_DIAG_IN_BODY2 int var_C2[10]
+
+#define DEFINE_bool(name, val)\
+  namespace fLB { \
+  typedef char FLAG_##name##_value_is_not_a_bool[(sizeof(val) != sizeof(bool)) ? -1 : 1]; \
+  }   \
+  bool FLAG_##name = val
Index: clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
@@ -1,7 +1,42 @@
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' %s -- | FileCheck %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor,modernize-avoid-c-arrays' --header-filter='macros_filter.h' --filter-macro-from-headers %s -- | FileCheck %s
+// RUN: clang-tidy --config='{"Checks": "-*,google-explicit-constructor,modernize-avoid-c-arrays", "HeaderFilterRegex": "macros_filter.h", "FilterMacroFromHeaders": true}' %s -- | FileCheck %s
+
+#include "macros.h"
+#include "macros_filter.h"
 
 #define Q(name) class name { name(int i); }
 
 Q(A);
 // CHECK: :[[@LINE-1]]:3: warning: single-argument constructors must be marked explicit
-// CHECK: :3:30: note: expanded from macro 'Q'
+// CHECK: :[[@LINE-4]]:30: note: expanded from macro 'Q'
+
+#define MAIN_MACRO_DIAG_IN_ARG(a) a
+MAIN_MACRO_DIAG_IN_ARG(int var_A[10]);
+// CHECK: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use std::array<> instead
+
+#define MAIN_MACRO_DIAG_IN_BODY int var_A1[10]
+MAIN_MACRO_DIAG_IN_BODY;
+// CHECK: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK: :[[@LINE-3]]:33: note: expanded from macro 'MAIN_MACRO_DIAG_IN_BODY'
+
+HEADER_FILTER_MACRO_DIAG_IN_ARG(int var_B[10]);
+// CHECK: :[[@LINE-1]]:33: warning: do not declare C-style arrays, use std::array<> instead
+
+HEADER_FILTER_MACRO_DIAG_IN_BODY;
+// CHECK: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK: note: expanded from macro 'HEADER_FILTER_MACRO_DIAG_IN_BODY'
+
+#define MAIN_MACRO_WRAPPER HEADER_FILTER_MACRO_DIAG_IN_BODY2
+MAIN_MACRO_WRAPPER;
+// CHECK: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK: note: expanded from macro 'MAIN_MACRO_WRAPPER'
+// CHECK: note: expanded from macro 'HEADER_FILTER_MACRO_DIAG_IN_BODY2'
+
+HEADER_MACRO_DIAG_IN_ARG(int var_C[10]);
+HEADER_MACRO_DIAG_IN_BODY;
+
+#define MAIN_MACRO_WRAPPER2 HEADER_MACRO_DIAG_IN_BODY2
+MAIN_MACRO_WRAPPER2;
+
+DEFINE_bool(test, false);
+// CHECK-NOT: warning:
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -43,12 +43,13 @@
 
 $ clang-tidy -dump-config
 ---
-Checks:  '-*,some-check'
-WarningsAsErrors:''
-HeaderFilterRegex:   ''
-FormatStyle: none
-InheritParentConfig: true
-User:user
+Checks: '-*,some-check'
+WarningsAsErrors:   ''
+HeaderFilterRegex:  ''
+FilterMacroFromHeaders: true
+FormatStyle:none
+InheritParentConfig:true
+User:   user
 CheckOptions:
   - key: 

[PATCH] D100762: [clang][cli] Extract AST dump format into extra option

2021-04-19 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arichardson.
Herald added subscribers: dang, usaxena95, kadircet, arphaman.
jansvoboda11 requested review of this revision.
Herald added projects: clang, LLVM, clang-tools-extra.
Herald added subscribers: llvm-commits, cfe-commits.

When dumping AST, the JSON format can be requested in two ways: 
`-ast-dump=json` and `-ast-dump-all=json`. Both of those command line options 
control `FrontendOptions::ASTDumpFormat`.

This patch deduplicates the options by introducing `-ast-dump-format`, removes 
the `_EQ` variants of `-ast-dump` and `-ast-dump-all`, and simplifies option 
parsing/generation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100762

Files:
  clang-tools-extra/clangd/DumpAST.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/AST/ast-dump-comment-json.cpp
  clang/test/AST/ast-dump-decl-context-json.cpp
  clang/test/AST/ast-dump-decl-json.c
  clang/test/AST/ast-dump-decl-json.m
  clang/test/AST/ast-dump-enum-json.cpp
  clang/test/AST/ast-dump-expr-json.c
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr-json.m
  clang/test/AST/ast-dump-file-line-json.c
  clang/test/AST/ast-dump-funcs-json.cpp
  clang/test/AST/ast-dump-if-json.cpp
  clang/test/AST/ast-dump-macro-json.c
  clang/test/AST/ast-dump-namespace-json.cpp
  clang/test/AST/ast-dump-objc-arc-json.m
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-stmt-json.c
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt-json.m
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/ast-dump-types-errors-json.cpp
  clang/test/AST/ast-dump-types-json.cpp
  clang/test/AST/gen_ast_dump_json_test.py
  clang/test/AST/multistep-explicit-cast-json.c
  clang/test/AST/multistep-explicit-cast-json.cpp
  llvm/utils/update_cc_test_checks.py

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


[PATCH] D98193: [CUDA][HIP] Allow non-ODR use of host var in device

2021-04-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98193/new/

https://reviews.llvm.org/D98193

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


[PATCH] D100460: [WIP][clang] Move deep copy into CompilerInvocation::clone

2021-04-19 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 338507.
jansvoboda11 added a comment.

Rebase, delete RefBase copy assignment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100460/new/

https://reviews.llvm.org/D100460

Files:
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/tool/Check.cpp
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/ARCMigrate/ARCMT.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/ChainedIncludesSource.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -97,29 +97,34 @@
   ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
 }
 
-// Copy constructor/assignment perform deep copy of reference-counted pointers.
+// Clone performs deep copy of reference-counted pointers.
 
-TEST(CompilerInvocationTest, DeepCopyConstructor) {
+TEST(CompilerInvocationTest, CloneWithMoveConstructor) {
   CompilerInvocation A;
   A.getAnalyzerOpts()->Config["Key"] = "Old";
 
-  CompilerInvocation B(A);
+  CompilerInvocation B(A.clone());
   B.getAnalyzerOpts()->Config["Key"] = "New";
 
   ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
 }
 
-TEST(CompilerInvocationTest, DeepCopyAssignment) {
+TEST(CompilerInvocationTest, CloneWithMoveAssignment) {
   CompilerInvocation A;
   A.getAnalyzerOpts()->Config["Key"] = "Old";
 
   CompilerInvocation B;
-  B = A;
+  B = A.clone();
   B.getAnalyzerOpts()->Config["Key"] = "New";
 
   ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
 }
 
+TEST(CompilerInvocationTest, NotCopyConstructibleNorAssignable) {
+  ASSERT_FALSE(std::is_copy_constructible::value);
+  ASSERT_FALSE(std::is_copy_assignable::value);
+}
+
 // Boolean option with a keypath that defaults to true.
 // The only flag with a negative spelling can set the keypath to false.
 
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -21,7 +21,7 @@
 static CompilerInvocation
 makeInvocationForModuleBuildWithoutPaths(const ModuleDeps ) {
   // Make a deep copy of the invocation.
-  CompilerInvocation CI(*Deps.Invocation);
+  CompilerInvocation CI(Deps.Invocation->clone());
 
   // Remove options incompatible with explicit module build.
   CI.getFrontendOpts().Inputs.clear();
Index: clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
+++ clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
@@ -64,7 +64,8 @@
 return;
   }
 
-  auto Invocation = std::make_shared(CI.getInvocation());
+  auto Invocation =
+  std::make_shared(CI.getInvocation().clone());
 
   FrontendOptions  = Invocation->getFrontendOpts();
   InputKind IK = Language::CXX; // FIXME
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -244,7 +244,7 @@
 CompilerInstance Instance(CI.getPCHContainerOperations(),
   ());
 Instance.setInvocation(
-std::make_shared(CI.getInvocation()));
+std::make_shared(CI.getInvocation().clone()));
 Instance.createDiagnostics(
 new ForwardingDiagnosticConsumer(CI.getDiagnosticClient()),
 /*ShouldOwnClient=*/true);
Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -317,7 +317,8 @@
 PreambleCallbacks ) {
   assert(VFS && "VFS is null");
 
-  auto PreambleInvocation = std::make_shared(Invocation);
+  auto PreambleInvocation =
+  std::make_shared(Invocation.clone());
   FrontendOptions  = PreambleInvocation->getFrontendOpts();
   PreprocessorOptions  =
   PreambleInvocation->getPreprocessorOpts();
@@ -501,7 +502,8 @@
   Bounds.Size <= MainFileBuffer.getBufferSize() &&
   "Buffer is too large. Bounds were calculated from a different buffer?");
 
-  auto PreambleInvocation = std::make_shared(Invocation);
+  auto PreambleInvocation =
+  std::make_shared(Invocation.clone());
   PreprocessorOptions  =
   

[clang] aa1e391 - Fix test/Frontend/print-header-includes.c

2021-04-19 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-04-19T15:39:09+02:00
New Revision: aa1e3914020b1211e6bdd306d4f5f2010971d6ee

URL: 
https://github.com/llvm/llvm-project/commit/aa1e3914020b1211e6bdd306d4f5f2010971d6ee
DIFF: 
https://github.com/llvm/llvm-project/commit/aa1e3914020b1211e6bdd306d4f5f2010971d6ee.diff

LOG: Fix test/Frontend/print-header-includes.c

I managed to run the wrong tests before committing D100759.

Added: 


Modified: 
clang/test/Frontend/print-header-includes.c

Removed: 




diff  --git a/clang/test/Frontend/print-header-includes.c 
b/clang/test/Frontend/print-header-includes.c
index c7f84e221150c..292941d4353ec 100644
--- a/clang/test/Frontend/print-header-includes.c
+++ b/clang/test/Frontend/print-header-includes.c
@@ -9,7 +9,7 @@
 // CHECK-NOT: .. {{.*test2.h}}
 
 // RUN: %clang_cc1 -I%S -isystem %S/Inputs/SystemHeaderPrefix \
-// RUN: -E -H -show-skipped-includes -o /dev/null %s 2> %t.stderr
+// RUN: -E -H -fshow-skipped-includes -o /dev/null %s 2> %t.stderr
 // RUN: FileCheck --check-prefix=SKIPPED < %t.stderr %s
 
 // SKIPPED-NOT: . {{.*noline.h}}



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


[clang] 05b4bab - [SystemZ][z/OS] Set more text files as text

2021-04-19 Thread Abhina Sreeskantharajan via cfe-commits

Author: Abhina Sreeskantharajan
Date: 2021-04-19T09:31:46-04:00
New Revision: 05b4babc9d85a6669a39a58351fd8b1ebca2ab96

URL: 
https://github.com/llvm/llvm-project/commit/05b4babc9d85a6669a39a58351fd8b1ebca2ab96
DIFF: 
https://github.com/llvm/llvm-project/commit/05b4babc9d85a6669a39a58351fd8b1ebca2ab96.diff

LOG: [SystemZ][z/OS] Set more text files as text

This patch corrects more instances of text files being opened as text.

Reviewed By: Jonathan.Crowther

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

Added: 


Modified: 
clang/tools/driver/cc1gen_reproducer_main.cpp
clang/tools/libclang/CIndexer.cpp
llvm/include/llvm/Support/GraphWriter.h

Removed: 




diff  --git a/clang/tools/driver/cc1gen_reproducer_main.cpp 
b/clang/tools/driver/cc1gen_reproducer_main.cpp
index 472055ee21708..89b7227fdb17a 100644
--- a/clang/tools/driver/cc1gen_reproducer_main.cpp
+++ b/clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -162,7 +162,7 @@ int cc1gen_reproducer_main(ArrayRef Argv, 
const char *Argv0,
   // Parse the invocation descriptor.
   StringRef Input = Argv[0];
   llvm::ErrorOr> Buffer =
-  llvm::MemoryBuffer::getFile(Input);
+  llvm::MemoryBuffer::getFile(Input, /*IsText=*/true);
   if (!Buffer) {
 llvm::errs() << "error: failed to read " << Input << ": "
  << Buffer.getError().message() << "\n";

diff  --git a/clang/tools/libclang/CIndexer.cpp 
b/clang/tools/libclang/CIndexer.cpp
index 3d8c00cf21154..c7baab3a2c470 100644
--- a/clang/tools/libclang/CIndexer.cpp
+++ b/clang/tools/libclang/CIndexer.cpp
@@ -163,7 +163,8 @@ LibclangInvocationReporter::LibclangInvocationReporter(
   TempPath = Path;
   llvm::sys::path::append(TempPath, "libclang-");
   int FD;
-  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath))
+  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath,
+  llvm::sys::fs::OF_Text))
 return;
   File = std::string(TempPath.begin(), TempPath.end());
   llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true);

diff  --git a/llvm/include/llvm/Support/GraphWriter.h 
b/llvm/include/llvm/Support/GraphWriter.h
index 4bb410d99f3f5..b886bf45f474b 100644
--- a/llvm/include/llvm/Support/GraphWriter.h
+++ b/llvm/include/llvm/Support/GraphWriter.h
@@ -331,7 +331,8 @@ std::string WriteGraph(const GraphType , const Twine 
,
   if (Filename.empty()) {
 Filename = createGraphFilename(Name.str(), FD);
   } else {
-std::error_code EC = sys::fs::openFileForWrite(Filename, FD);
+std::error_code EC = sys::fs::openFileForWrite(
+Filename, FD, sys::fs::CD_CreateAlways, sys::fs::OF_Text);
 
 // Writing over an existing file is not considered an error.
 if (EC == std::errc::file_exists) {



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


[PATCH] D100654: [SystemZ][z/OS] Set more text files as text

2021-04-19 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05b4babc9d85: [SystemZ][z/OS] Set more text files as text 
(authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100654/new/

https://reviews.llvm.org/D100654

Files:
  clang/tools/driver/cc1gen_reproducer_main.cpp
  clang/tools/libclang/CIndexer.cpp
  llvm/include/llvm/Support/GraphWriter.h


Index: llvm/include/llvm/Support/GraphWriter.h
===
--- llvm/include/llvm/Support/GraphWriter.h
+++ llvm/include/llvm/Support/GraphWriter.h
@@ -331,7 +331,8 @@
   if (Filename.empty()) {
 Filename = createGraphFilename(Name.str(), FD);
   } else {
-std::error_code EC = sys::fs::openFileForWrite(Filename, FD);
+std::error_code EC = sys::fs::openFileForWrite(
+Filename, FD, sys::fs::CD_CreateAlways, sys::fs::OF_Text);
 
 // Writing over an existing file is not considered an error.
 if (EC == std::errc::file_exists) {
Index: clang/tools/libclang/CIndexer.cpp
===
--- clang/tools/libclang/CIndexer.cpp
+++ clang/tools/libclang/CIndexer.cpp
@@ -163,7 +163,8 @@
   TempPath = Path;
   llvm::sys::path::append(TempPath, "libclang-");
   int FD;
-  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath))
+  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath,
+  llvm::sys::fs::OF_Text))
 return;
   File = std::string(TempPath.begin(), TempPath.end());
   llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true);
Index: clang/tools/driver/cc1gen_reproducer_main.cpp
===
--- clang/tools/driver/cc1gen_reproducer_main.cpp
+++ clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -162,7 +162,7 @@
   // Parse the invocation descriptor.
   StringRef Input = Argv[0];
   llvm::ErrorOr> Buffer =
-  llvm::MemoryBuffer::getFile(Input);
+  llvm::MemoryBuffer::getFile(Input, /*IsText=*/true);
   if (!Buffer) {
 llvm::errs() << "error: failed to read " << Input << ": "
  << Buffer.getError().message() << "\n";


Index: llvm/include/llvm/Support/GraphWriter.h
===
--- llvm/include/llvm/Support/GraphWriter.h
+++ llvm/include/llvm/Support/GraphWriter.h
@@ -331,7 +331,8 @@
   if (Filename.empty()) {
 Filename = createGraphFilename(Name.str(), FD);
   } else {
-std::error_code EC = sys::fs::openFileForWrite(Filename, FD);
+std::error_code EC = sys::fs::openFileForWrite(
+Filename, FD, sys::fs::CD_CreateAlways, sys::fs::OF_Text);
 
 // Writing over an existing file is not considered an error.
 if (EC == std::errc::file_exists) {
Index: clang/tools/libclang/CIndexer.cpp
===
--- clang/tools/libclang/CIndexer.cpp
+++ clang/tools/libclang/CIndexer.cpp
@@ -163,7 +163,8 @@
   TempPath = Path;
   llvm::sys::path::append(TempPath, "libclang-");
   int FD;
-  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath))
+  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath,
+  llvm::sys::fs::OF_Text))
 return;
   File = std::string(TempPath.begin(), TempPath.end());
   llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true);
Index: clang/tools/driver/cc1gen_reproducer_main.cpp
===
--- clang/tools/driver/cc1gen_reproducer_main.cpp
+++ clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -162,7 +162,7 @@
   // Parse the invocation descriptor.
   StringRef Input = Argv[0];
   llvm::ErrorOr> Buffer =
-  llvm::MemoryBuffer::getFile(Input);
+  llvm::MemoryBuffer::getFile(Input, /*IsText=*/true);
   if (!Buffer) {
 llvm::errs() << "error: failed to read " << Input << ": "
  << Buffer.getError().message() << "\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100727: [clang-format] Correctly apply AllowShortIfStatementsOnASingleLine: Always to else branch.

2021-04-19 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius planned changes to this revision.
curdeius added a subscriber: klimek.
curdeius added a comment.

More I look at the current state of this option, more I think it's misleading.
I would expect that the if after else is also controlled by this option. And, 
the last else as well (adding yet another option for that seems to be a bit an 
overkill)

@klimek, @mydeveloperday, I'd love to hear your input as well on the best 
course of action, as I've seen that you've discussed this topic a bit in 
https://reviews.llvm.org/D59087.

The current status quo looks like:

  /// Different styles for handling short if statements.
  enum ShortIfStyle : unsigned char {
/// Never put short ifs on the same line.
/// \code
///   if (a)
/// return;
///
///   if (b)
/// return;
///   else
/// return;
///
///   if (c)
/// return;
///   else {
/// return;
///   }
/// \endcode
SIS_Never,
/// Put short ifs on the same line only if there is no else statement.
/// \code
///   if (a) return;
///
///   if (b)
/// return;
///   else
/// return;
///
///   if (c)
/// return;
///   else {
/// return;
///   }
/// \endcode
SIS_WithoutElse,
/// Always put short ifs on the same line.
/// \code
///   if (a) return;
///
///   if (b) return;
///   else
/// return;
///
///   if (c) return;
///   else {
/// return;
///   }
/// \endcode
SIS_Always,
  };

I.e. `WithoutElse` does not depend on the else statement being compound or not. 
I think I'll push a NFC commit to fix documentation and add tests for this.

Anyway, what I'm inclined to do is to have these options:

- Never (same as now)
- WithoutElse (same as now, concerns only a simple `if (c) f();`)
- OnlyFirstIf (renamed from `Always`, and `Always` kept for backward 
compatibility, it would behave as currently, so only the first `if` in the 
sequence of if else if else if else is concerned)
- AllIfsAndElse (would do what I want to achieve in this patch, so format like 
this:

  if (c) f();
  else if (c) f();
  else if (c) f();
  else if();

Naming is hard. All suggestions are welcome :).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100727/new/

https://reviews.llvm.org/D100727

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


[PATCH] D100654: [SystemZ][z/OS] Set more text files as text

2021-04-19 Thread Jonathan Crowther via Phabricator via cfe-commits
Jonathan.Crowther accepted this revision.
Jonathan.Crowther added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100654/new/

https://reviews.llvm.org/D100654

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


[PATCH] D100759: Rename -show-skipped-includes to -fshow-skipped-includes and make it a driver option

2021-04-19 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb36dc8dcf1c: Rename -show-skipped-includes to 
-fshow-skipped-includes and make it a driver… (authored by hans).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100759/new/

https://reviews.llvm.org/D100759

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5134,6 +5134,7 @@
 CmdArgs.push_back("-H");
 CmdArgs.push_back("-sys-header-deps");
   }
+  Args.AddAllArgs(CmdArgs, options::OPT_fshow_skipped_includes);
 
   if (D.CCPrintHeaders && !D.CCGenDiagnostics) {
 CmdArgs.push_back("-header-include-file");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -629,6 +629,12 @@
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
 HelpText<"Show header includes and nesting depth">,
 MarshallingInfoFlag>;
+def fshow_skipped_includes : Flag<["-"], "fshow-skipped-includes">,
+  Flags<[CC1Option]>, HelpText<"Show skipped includes in -H output.">,
+  DocBrief<[{#include files may be "skipped" due to include guard optimization
+ or #pragma once. This flag makes -H show also such includes.}]>,
+  MarshallingInfoFlag>;
+
 def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
@@ -4945,11 +4951,6 @@
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
-def show_skipped_includes : Flag<["-"], "show-skipped-includes">,
-  HelpText<"Show skipped includes in -H output.">,
-  DocBrief<[{#include files may be "skipped" due to include guard optimization
- or #pragma once. This flag makes -H show also such includes.}]>,
-  MarshallingInfoFlag>;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag>;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5134,6 +5134,7 @@
 CmdArgs.push_back("-H");
 CmdArgs.push_back("-sys-header-deps");
   }
+  Args.AddAllArgs(CmdArgs, options::OPT_fshow_skipped_includes);
 
   if (D.CCPrintHeaders && !D.CCGenDiagnostics) {
 CmdArgs.push_back("-header-include-file");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -629,6 +629,12 @@
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
 HelpText<"Show header includes and nesting depth">,
 MarshallingInfoFlag>;
+def fshow_skipped_includes : Flag<["-"], "fshow-skipped-includes">,
+  Flags<[CC1Option]>, HelpText<"Show skipped includes in -H output.">,
+  DocBrief<[{#include files may be "skipped" due to include guard optimization
+ or #pragma once. This flag makes -H show also such includes.}]>,
+  MarshallingInfoFlag>;
+
 def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
@@ -4945,11 +4951,6 @@
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
-def show_skipped_includes : Flag<["-"], "show-skipped-includes">,
-  HelpText<"Show skipped includes in -H output.">,
-  DocBrief<[{#include files may be "skipped" due to include guard optimization
- or #pragma once. This flag makes -H show also such includes.}]>,
-  MarshallingInfoFlag>;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bb36dc8 - Rename -show-skipped-includes to -fshow-skipped-includes and make it a driver option

2021-04-19 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-04-19T15:22:15+02:00
New Revision: bb36dc8dcf1c4a16cafdafc6b225ec6036144f41

URL: 
https://github.com/llvm/llvm-project/commit/bb36dc8dcf1c4a16cafdafc6b225ec6036144f41
DIFF: 
https://github.com/llvm/llvm-project/commit/bb36dc8dcf1c4a16cafdafc6b225ec6036144f41.diff

LOG: Rename -show-skipped-includes to -fshow-skipped-includes and make it a 
driver option

This is a user-facing option, so it doesn't make sense for it to be cc1
only.

Follow-up to D100420

Differential revision: https://reviews.llvm.org/D100759

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9e15712eb2d51..f93b8a2496e07 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -629,6 +629,12 @@ def G_EQ : Joined<["-"], "G=">, Flags<[NoXarchOption]>, 
Group, Alias
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
 HelpText<"Show header includes and nesting depth">,
 MarshallingInfoFlag>;
+def fshow_skipped_includes : Flag<["-"], "fshow-skipped-includes">,
+  Flags<[CC1Option]>, HelpText<"Show skipped includes in -H output.">,
+  DocBrief<[{#include files may be "skipped" due to include guard optimization
+ or #pragma once. This flag makes -H show also such includes.}]>,
+  MarshallingInfoFlag>;
+
 def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
@@ -4945,11 +4951,6 @@ def fdenormal_fp_math_f32_EQ : Joined<["-"], 
"fdenormal-fp-math-f32=">,
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
-def show_skipped_includes : Flag<["-"], "show-skipped-includes">,
-  HelpText<"Show skipped includes in -H output.">,
-  DocBrief<[{#include files may be "skipped" due to include guard optimization
- or #pragma once. This flag makes -H show also such includes.}]>,
-  MarshallingInfoFlag>;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag>;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 074556089a243..95ca99565351c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5134,6 +5134,7 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 CmdArgs.push_back("-H");
 CmdArgs.push_back("-sys-header-deps");
   }
+  Args.AddAllArgs(CmdArgs, options::OPT_fshow_skipped_includes);
 
   if (D.CCPrintHeaders && !D.CCGenDiagnostics) {
 CmdArgs.push_back("-header-include-file");



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


[PATCH] D100759: Rename -show-skipped-includes to -fshow-skipped-includes and make it a driver option

2021-04-19 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added a reviewer: thakis.
Herald added subscribers: jansvoboda11, dang.
hans requested review of this revision.
Herald added a project: clang.

This is a user-facing option, so it doesn't make sense for it to be cc1 only.

Follow-up to D100420 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100759

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5134,6 +5134,7 @@
 CmdArgs.push_back("-H");
 CmdArgs.push_back("-sys-header-deps");
   }
+  Args.AddAllArgs(CmdArgs, options::OPT_fshow_skipped_includes);
 
   if (D.CCPrintHeaders && !D.CCGenDiagnostics) {
 CmdArgs.push_back("-header-include-file");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -629,6 +629,12 @@
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
 HelpText<"Show header includes and nesting depth">,
 MarshallingInfoFlag>;
+def fshow_skipped_includes : Flag<["-"], "fshow-skipped-includes">,
+  Flags<[CC1Option]>, HelpText<"Show skipped includes in -H output.">,
+  DocBrief<[{#include files may be "skipped" due to include guard optimization
+ or #pragma once. This flag makes -H show also such includes.}]>,
+  MarshallingInfoFlag>;
+
 def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
@@ -4945,11 +4951,6 @@
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
-def show_skipped_includes : Flag<["-"], "show-skipped-includes">,
-  HelpText<"Show skipped includes in -H output.">,
-  DocBrief<[{#include files may be "skipped" due to include guard optimization
- or #pragma once. This flag makes -H show also such includes.}]>,
-  MarshallingInfoFlag>;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag>;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5134,6 +5134,7 @@
 CmdArgs.push_back("-H");
 CmdArgs.push_back("-sys-header-deps");
   }
+  Args.AddAllArgs(CmdArgs, options::OPT_fshow_skipped_includes);
 
   if (D.CCPrintHeaders && !D.CCGenDiagnostics) {
 CmdArgs.push_back("-header-include-file");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -629,6 +629,12 @@
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
 HelpText<"Show header includes and nesting depth">,
 MarshallingInfoFlag>;
+def fshow_skipped_includes : Flag<["-"], "fshow-skipped-includes">,
+  Flags<[CC1Option]>, HelpText<"Show skipped includes in -H output.">,
+  DocBrief<[{#include files may be "skipped" due to include guard optimization
+ or #pragma once. This flag makes -H show also such includes.}]>,
+  MarshallingInfoFlag>;
+
 def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
@@ -4945,11 +4951,6 @@
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
-def show_skipped_includes : Flag<["-"], "show-skipped-includes">,
-  HelpText<"Show skipped includes in -H output.">,
-  DocBrief<[{#include files may be "skipped" due to include guard optimization
- or #pragma once. This flag makes -H show also such includes.}]>,
-  MarshallingInfoFlag>;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100536: [clang][deps] NFC: Remove unused FullDependencies member

2021-04-19 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG95588c0da4ef: [clang][deps] NFC: Remove unused 
FullDependencies member (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D100536?vs=337660=338500#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100536/new/

https://reviews.llvm.org/D100536

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -16,10 +16,10 @@
 std::vector FullDependencies::getAdditionalCommandLine(
 std::function LookupPCMPath,
 std::function LookupModuleDeps) const {
-  std::vector Ret = AdditionalNonPathCommandLine;
-
-  Ret.push_back("-fno-implicit-modules");
-  Ret.push_back("-fno-implicit-module-maps");
+  std::vector Ret{
+  "-fno-implicit-modules",
+  "-fno-implicit-module-maps",
+  };
 
   std::vector PCMPaths;
   std::vector ModMapPaths;
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
===
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -38,13 +38,6 @@
   /// determined that the differences are benign for this compilation.
   std::vector ClangModuleDeps;
 
-  /// A partial addtional set of command line arguments that can be used to
-  /// build this translation unit.
-  ///
-  /// Call \c getFullAdditionalCommandLine() to get a command line suitable for
-  /// appending to the original command line to pass to clang.
-  std::vector AdditionalNonPathCommandLine;
-
   /// Get additional arguments suitable for appending to the original Clang
   /// command line.
   ///


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -16,10 +16,10 @@
 std::vector FullDependencies::getAdditionalCommandLine(
 std::function LookupPCMPath,
 std::function LookupModuleDeps) const {
-  std::vector Ret = AdditionalNonPathCommandLine;
-
-  Ret.push_back("-fno-implicit-modules");
-  Ret.push_back("-fno-implicit-module-maps");
+  std::vector Ret{
+  "-fno-implicit-modules",
+  "-fno-implicit-module-maps",
+  };
 
   std::vector PCMPaths;
   std::vector ModMapPaths;
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
===
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -38,13 +38,6 @@
   /// determined that the differences are benign for this compilation.
   std::vector ClangModuleDeps;
 
-  /// A partial addtional set of command line arguments that can be used to
-  /// build this translation unit.
-  ///
-  /// Call \c getFullAdditionalCommandLine() to get a command line suitable for
-  /// appending to the original command line to pass to clang.
-  std::vector AdditionalNonPathCommandLine;
-
   /// Get additional arguments suitable for appending to the original Clang
   /// command line.
   ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 95588c0 - [clang][deps] NFC: Remove unused FullDependencies member

2021-04-19 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-04-19T15:02:54+02:00
New Revision: 95588c0da4ef08d8e497f7e4b094d96f6c38c3e5

URL: 
https://github.com/llvm/llvm-project/commit/95588c0da4ef08d8e497f7e4b094d96f6c38c3e5
DIFF: 
https://github.com/llvm/llvm-project/commit/95588c0da4ef08d8e497f7e4b094d96f6c38c3e5.diff

LOG: [clang][deps] NFC: Remove unused FullDependencies member

This patch removes the `FullDependencies::AdditionalNonPathCommandLine` member, 
as it's value-initialized and never mutated.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
index 09c385783c52..33e155f4b4ae 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -38,13 +38,6 @@ struct FullDependencies {
   /// determined that the 
diff erences are benign for this compilation.
   std::vector ClangModuleDeps;
 
-  /// A partial addtional set of command line arguments that can be used to
-  /// build this translation unit.
-  ///
-  /// Call \c getFullAdditionalCommandLine() to get a command line suitable for
-  /// appending to the original command line to pass to clang.
-  std::vector AdditionalNonPathCommandLine;
-
   /// Get additional arguments suitable for appending to the original Clang
   /// command line.
   ///

diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
index afb3ceb0ca54..a59ab688b10b 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -16,10 +16,10 @@ namespace dependencies{
 std::vector FullDependencies::getAdditionalCommandLine(
 std::function LookupPCMPath,
 std::function LookupModuleDeps) const {
-  std::vector Ret = AdditionalNonPathCommandLine;
-
-  Ret.push_back("-fno-implicit-modules");
-  Ret.push_back("-fno-implicit-module-maps");
+  std::vector Ret{
+  "-fno-implicit-modules",
+  "-fno-implicit-module-maps",
+  };
 
   std::vector PCMPaths;
   std::vector ModMapPaths;



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


  1   2   >