[PATCH] D118527: [X86] Promote default mtune from generic to sandybridge

2022-01-28 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D118527#3281488 , @craig.topper 
wrote:

> I believe the design here was supposed to be that "generic" would be updated 
> in X86.td on an ongoing basis to be more modern. So that if users pass 
> -mtune=generic it would evolve over time.
>
> This matches gcc behavior
>
>   ‘generic’
>   Produce code optimized for the most common IA32/AMD64/EM64T processors. If 
> you know the CPU on which your code will run, then you should use the 
> corresponding -mtune or -march option instead of -mtune=generic. But, if you 
> do not know exactly what CPU users of your application will have, then you 
> should use this option.
>   
>   As new processors are deployed in the marketplace, the behavior of this 
> option will change. Therefore, if you upgrade to a newer version of GCC, code 
> generation controlled by this option will change to reflect the processors 
> that are most common at the time that version of GCC is released.
>   
>   There is no -march=generic option because -march indicates the instruction 
> set the compiler can use, and there is no generic instruction set applicable 
> to all processors. In contrast, -mtune indicates the processor (or, in this 
> case, collection of processors) for which the code is optimized.

Thanks for the information, I'll try the other way, thanks Craig!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118527

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


[PATCH] D118527: [X86] Promote default mtune from generic to sandybridge

2022-01-28 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I believe the design here was supposed to be that "generic" would be updated in 
X86.td on an ongoing basis to be more modern. So that if users pass 
-mtune=generic it would evolve over time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118527

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


[PATCH] D110869: [X86] Implement -fzero-call-used-regs option

2022-01-28 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

Hey, y'all!

I've finished the initial part of this feature. I compiled a Linux kernel with 
it, and it booted via qemu.

Please give it a go and let me know what you think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110869

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


[PATCH] D114413: [OpenMPIRBuilder] Implement static-chunked workshare-loop schedules.

2022-01-28 Thread Peixin Qiao via Phabricator via cfe-commits
peixin added a comment.

When I investigated the edge cases you mentioned in D116292 
. Found one unsupported case as follows

  #include 
  #include 
  using namespace std;
  
  void func(unsigned long long lb, unsigned long long ub, unsigned long long 
step) {
unsigned long long i;
#pragma omp for schedule(static, 1)
for (i = lb; i > ub; i -= step) {
  cout << i << endl;
}
  }
  
  int main() {
unsigned long long lb, ub, step;
lb = ULLONG_MAX;
ub = ULLONG_MAX / 10;
step = ULLONG_MAX / 10;
cout << "lb: " << lb << endl;
cout << "ub: " << ub << endl;
cout << "step: " << step << endl;
  
func(lb, ub, step);
  
cout << endl;
return 0;
  }

  $ clang++ temp.cpp -fopenmp && ./a.out
  lb: 18446744073709551615
  ub: 1844674407370955161
  step: 1844674407370955161
  18446744073709551615
  16602069666338596454
  14757395258967641293
  12912720851596686132
  11068046444225730971
  9223372036854775810
  7378697629483820649
  5534023222112865488
  3689348814741910327
  1844674407370955166
  $ clang++ temp.cpp -fopenmp -fopenmp-enable-irbuilder
  clang-14: 
/home/qpx/compilers/llvm-community/static-chunk-codegen/llvm-project/llvm/lib/IR/Instructions.cpp:506:
 void llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, 
llvm::ArrayRef, 
llvm::ArrayRef >, const llvm::Twine&): 
Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == 
Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:

This is also for `schedule(static)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114413

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


[PATCH] D110869: [X86] Implement -fzero-call-used-regs option

2022-01-28 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 404236.
void added a comment.

Move the zeroing of registers to before the pop instructions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110869

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/zero-call-used-regs.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/zero_call_used_regs.c
  llvm/include/llvm/CodeGen/MachineRegisterInfo.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/include/llvm/CodeGen/TargetRegisterInfo.h
  llvm/include/llvm/Support/CodeGen.h
  llvm/lib/CodeGen/MachineRegisterInfo.cpp
  llvm/lib/CodeGen/PrologEpilogInserter.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86RegisterInfo.h
  llvm/test/CodeGen/X86/zero-call-used-regs-fmod.ll
  llvm/test/CodeGen/X86/zero-call-used-regs.ll

Index: llvm/test/CodeGen/X86/zero-call-used-regs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/zero-call-used-regs.ll
@@ -0,0 +1,292 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i386-unknown-linux-gnu | FileCheck %s --check-prefix=I386
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefix=X86-64
+
+@result = dso_local global i32 0, align 4
+
+define dso_local i32 @skip(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="skip" {
+; I386-LABEL: skip:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: skip:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used_gpr_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr-arg" {
+; I386-LABEL: used_gpr_arg:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used_gpr_arg:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used_gpr(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr" {
+; I386-LABEL: used_gpr:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used_gpr:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-arg" {
+; I386-LABEL: used_arg:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used_arg:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used" {
+; I386-LABEL: used:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @all_gpr_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="all-gpr-arg" {
+; I386-LABEL: all_gpr_arg:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:xorl %ecx, %ecx
+; I386-NEXT:xorl %edx, %edx
+; I386-NEXT:retl
+;
+; X86-64-LABEL: all_gpr_arg:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorq %rcx, %rcx
+; X86-64-NEXT:xorq %rdi, %rdi
+; X86-64-NEXT:xorq %rdx, %rdx
+; X86-64-NEXT:xorq %rsi, %rsi
+; X86-64-NEXT:xorq %r8, %r8
+; X86-64-NEXT:xorq %r9, %r9
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @all_gpr(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="all-gpr" {
+; I386-LABEL: all_gpr:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:xorl %ebp, %ebp
+; I386-NEXT:xorl %ebx, %ebx
+; I386-NEXT:xorl %ecx, %ecx
+; I386-NEXT:xorl %edi, %edi
+; I386-NEXT:xorl %edx, %edx
+; I386-NEXT:xorl %esi, %esi
+; I386-NEXT:retl
+;
+; X86-64-LABEL: all_gpr:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorq 

[PATCH] D116722: [clang] Verify ssp buffer size is a valid integer

2022-01-28 Thread Alex Tsao via Phabricator via cfe-commits
alextsao1999 marked 2 inline comments as done.
alextsao1999 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3209
+} else
+  D.Diag(clang::diag::err_invalid_ssp_buffer_size);
   }

compnerd wrote:
> Please consistently use the braces (either applied to both or on neither).
Thanks, fixed. Are there any other issues?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116722

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


[PATCH] D118527: [X86] Promote default mtune from generic to sandybridge

2022-01-28 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei created this revision.
pengfei added reviewers: craig.topper, spatel, erichkeane, RKSimon, 
andrew.w.kaylor.
pengfei requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We use `x86-64` as default target-cpu for a long time. It may be obsolete
given the old devices are phasing out.

Especially when we have added `x86-64-vN` for more than one year, more
and more users are using `x86-64-v2` now.

Conservatively, I think we have to use `x86-64` by default for a while.
But I believe promoting default mtune to sandybridge will do more good
than bad.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118527

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/x86-mtune.c


Index: clang/test/Driver/x86-mtune.c
===
--- clang/test/Driver/x86-mtune.c
+++ clang/test/Driver/x86-mtune.c
@@ -3,7 +3,7 @@
 // Default mtune should be generic.
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=notune
-// notune: "-tune-cpu" "generic"
+// notune: "-tune-cpu" "sandybridge"
 
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -mtune=generic 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=generic
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2255,11 +2255,11 @@
 
   // Handle -mtune.
 
-  // Default to "generic" unless -march is present or targetting the PS4.
+  // Default to "sandybridge" unless -march is present or targetting the PS4.
   std::string TuneCPU;
   if (!Args.hasArg(clang::driver::options::OPT_march_EQ) &&
   !getToolChain().getTriple().isPS4CPU())
-TuneCPU = "generic";
+TuneCPU = "sandybridge";
 
   // Override based on -mtune.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) {


Index: clang/test/Driver/x86-mtune.c
===
--- clang/test/Driver/x86-mtune.c
+++ clang/test/Driver/x86-mtune.c
@@ -3,7 +3,7 @@
 // Default mtune should be generic.
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=notune
-// notune: "-tune-cpu" "generic"
+// notune: "-tune-cpu" "sandybridge"
 
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -mtune=generic 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=generic
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2255,11 +2255,11 @@
 
   // Handle -mtune.
 
-  // Default to "generic" unless -march is present or targetting the PS4.
+  // Default to "sandybridge" unless -march is present or targetting the PS4.
   std::string TuneCPU;
   if (!Args.hasArg(clang::driver::options::OPT_march_EQ) &&
   !getToolChain().getTriple().isPS4CPU())
-TuneCPU = "generic";
+TuneCPU = "sandybridge";
 
   // Override based on -mtune.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118525: [modules] Merge ObjC interface ivars with anonymous types.

2022-01-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

@akyrtzi I believe you were working on the code responsible for decl contexts 
at some point. I'm not sure you'll be able to review the change. Can you 
recommend someone else knowledgeable with this code?


Repository:
  rC Clang

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

https://reviews.llvm.org/D118525

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


[PATCH] D118525: [modules] Merge ObjC interface ivars with anonymous types.

2022-01-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: ahatanak, rsmith.
vsapsai added a project: clang-modules.
Herald added a subscriber: ributzka.
vsapsai requested review of this revision.

Without the fix ivars with anonymous types can trigger errors like

> error: 'TestClass::structIvar' from module 'Target' is not present in 
> definition of 'TestClass' provided earlier
> [...]
> note: declaration of 'structIvar' does not match

It happens because types of ivars from different modules are considered
to be different. And it is caused by not merging anonymous `TagDecl`
from different modules.

To fix that I've changed `serialization::needsAnonymousDeclarationNumber`
to handle anonymous `TagDecl` inside `ObjCInterfaceDecl`. But that's not
sufficient as C code inside `ObjCInterfaceDecl` doesn't use interface
decl as a decl context but switches to its parent (TranslationUnit in
most cases).  I'm changing that to make `ObjCContainerDecl` the lexical
decl context but keeping the semantic decl context intact.  Though for
anonymous `TagDecl` `ObjCContainerDecl` is both a lexical and a semantic
decl context now. But it doesn't affect the lookup because such
`TagDecl`s don't have a name to use for the lookup.

Test "check-dup-decls-inside-objc.m" doesn't reflect a change in
functionality but captures the existing behavior to prevent regressions.

rdar://85563013


Repository:
  rC Clang

https://reviews.llvm.org/D118525

Files:
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/AST/ast-dump-decl.mm
  clang/test/Modules/merge-anon-record-definition-in-objc.m
  clang/test/SemaObjC/check-dup-decls-inside-objc.m

Index: clang/test/SemaObjC/check-dup-decls-inside-objc.m
===
--- /dev/null
+++ clang/test/SemaObjC/check-dup-decls-inside-objc.m
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -x objective-c++ %s
+
+// Test decls inside Objective-C entities are considered to be duplicates of same-name decls outside of these entities.
+
+@protocol SomeProtocol
+struct InProtocol {}; // expected-note {{previous definition is here}}
+- (union MethodReturnType { int x; float y; })returningMethod; // expected-note {{previous definition is here}}
+#ifdef __cplusplus
+// expected-error@-2 {{'MethodReturnType' cannot be defined in a parameter type}}
+#endif
+@end
+
+@interface Container {
+  struct InInterfaceCurliesWithField {} field; // expected-note {{previous definition is here}}
+  union InInterfaceCurlies { int x; float y; }; // expected-note {{previous definition is here}}
+}
+enum InInterface { kX = 0, }; // expected-note {{previous definition is here}}
+@end
+
+@interface Container(Category)
+union InCategory { int x; float y; }; // expected-note {{previous definition is here}}
+@end
+
+@interface Container() {
+  enum InExtensionCurliesWithField: int { kY = 1, } extensionField; // expected-note {{previous definition is here}}
+  struct InExtensionCurlies {}; // expected-note {{previous definition is here}}
+}
+union InExtension { int x; float y; }; // expected-note {{previous definition is here}}
+@end
+
+@implementation Container {
+  union InImplementationCurliesWithField { int x; float y; } implField; // expected-note {{previous definition is here}}
+  enum InImplementationCurlies { kZ = 2, }; // expected-note {{previous definition is here}}
+}
+struct InImplementation {}; // expected-note {{previous definition is here}}
+@end
+
+@implementation Container(Category)
+enum InCategoryImplementation { kW = 3, }; // expected-note {{previous definition is here}}
+@end
+
+
+struct InProtocol { int a; }; // expected-error {{redefinition of 'InProtocol'}}
+union MethodReturnType { int a; long b; }; // expected-error {{redefinition of 'MethodReturnType'}}
+
+struct InInterfaceCurliesWithField { int a; }; // expected-error {{redefinition of 'InInterfaceCurliesWithField'}}
+union InInterfaceCurlies { int a; long b; }; // expected-error {{redefinition of 'InInterfaceCurlies'}}
+enum InInterface { kA = 10, }; // expected-error {{redefinition of 'InInterface'}}
+
+union InCategory { int a; long b; }; // expected-error {{redefinition of 'InCategory'}}
+
+enum InExtensionCurliesWithField: int { kB = 11, }; // expected-error {{redefinition of 'InExtensionCurliesWithField'}}
+struct InExtensionCurlies { int a; }; // expected-error {{redefinition of 'InExtensionCurlies'}}
+union InExtension { int a; long b; }; // expected-error {{redefinition of 'InExtension'}}
+
+union InImplementationCurliesWithField { int a; long b; }; // expected-error {{redefinition of 'InImplementationCurliesWithField'}}
+enum InImplementationCurlies { kC = 12, }; // expected-error {{redefinition of 'InImplementationCurlies'}}
+struct InImplementation { int a; }; // expected-error {{redefinition 

[PATCH] D118311: [Clang][ModuleMap] Add conditional parsing via requires block declaration

2022-01-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Haven't really checked the code, at the moment thinking about various failure 
modes.

Cases that aren't tested but I suspect are valid ones:

- empty block, i.e., `requires cplusplus {}`
- nested blocks.

Is it possible to reference external module map from `requires` block? I mean 
that in one context the module has some extra requirements but in a different 
context doesn't have them.

It would be nice to have some mechanism to notify developers that includes are 
still performed regardless of `requires`. For example, in A.h we have

  #include 

and in module map

  module A {
header "A.h"
requires cplusplus {
  header "A_cpp_feature.h"
}
export *
  }

It doesn't mean the header A_cpp_feature.h is used only with cplusplus feature 
which is not obvious and with big headers can be hard to notice. But I feel 
like this request goes beyond the scope of your change, so not insisting on it.

Also it can be nice to diagnose strange conditions like `requires cplusplus, 
!cplusplus` but that's orthogonal to this feature.




Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:722
+def err_mmap_expected_lbrace_requires : Error<
+  "expected '{' to start rquires block">;
 def err_mmap_expected_rbrace : Error<"expected '}'">;

s/rquires/requires/

Would it be useful to put `requires` into some quotation marks to show it's not 
a part of the sentence but used verbatim?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118311

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


[PATCH] D118518: [clang][NFC] Change some ->getType()->isPlaceholderType() to just ->hasPlaceholderType()

2022-01-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu 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/D118518/new/

https://reviews.llvm.org/D118518

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


[PATCH] D118520: [clang-tidy] Output currently processing check and nodes on crash

2022-01-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:191
+  }
+  void setContext(const ASTContext ) { CurContext =  }
+  void clearContext() { CurContext = nullptr; }

Please separate with newline.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:26
 namespace ast_matchers {
 class MatchFinder;
+class BoundNodes;

Please sort alphabetically.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118520

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


[PATCH] D118520: [clang-tidy] Output currently processing check and nodes on crash

2022-01-28 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood accepted this revision.
LegalizeAdulthood added a comment.
This revision is now accepted and ready to land.

LGTM with a few whitespace nits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118520

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


[PATCH] D118520: [clang-tidy] Output currently processing check and nodes on crash

2022-01-28 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:181
+  }
+  void onResultEntry(StringRef CheckName,
+ const ast_matchers::BoundNodes ) {

blank line before `onResultEntry`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118520

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


[PATCH] D118520: [clang-tidy] Output currently processing check and nodes on crash

2022-01-28 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:201
+} // namespace clang
 ClangTidyError::ClangTidyError(StringRef CheckName,
ClangTidyError::Level DiagLevel,

Insert a blank line after the last closing namespace, please.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:393
+}
+void ClangTidyContext::onResultExit() const { Debugger->onResultLeave(); }
 } // namespace tidy

blank line between translation unit decls


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118520

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


[PATCH] D118520: [clang-tidy] Output currently processing check and nodes on crash

2022-01-28 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh, JonasToth, LegalizeAdulthood.
Herald added subscribers: carlosgalvezp, xazax.hun.
njames93 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Create a PrettyStackTraceEvent that will dump the current check as well as the 
bound nodes if a `ClangTidyCheck::check` call results in a segfault.
This should help massively in debugging random crashes users may be 
experiencing where the check causing the crash is unknown as well as the source 
location of the crash.

There are definitely some issues to iron out here as well as figuring out how 
to effectively test an error state.

I did force a check to assert and got this output:

  [build] Stack dump:
  [build] 0.Program arguments: clang-tidy 
llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-concat-nested-namespaces.cpp.tmp.cpp
 -fix --checks=-*,modernize-concat-nested-namespaces -header-filter=.* 
-config={} -- -I 
/home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output
 -std=c++17 -nostdinc++
  [build] 1.Processing check modernize-concat-nested-namespaces
  [build] Node 'namespace' - NamespaceDecl 0x58f780 
 line:1:11 nn1
  [build] `-NamespaceDecl 0x58f7f0  line:2:11 nn2
  [build]   `-FunctionDecl 0x58f8a8  col:6 t 'void ()'
  [build]
  [build] 2. parser at end of file


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118520

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -24,6 +24,7 @@
 class SourceManager;
 namespace ast_matchers {
 class MatchFinder;
+class BoundNodes;
 } // namespace ast_matchers
 namespace tooling {
 class CompilationDatabase;
@@ -61,6 +62,8 @@
   }
 };
 
+class CheckStackTraceDebug;
+
 /// Every \c ClangTidyCheck reports errors through a \c DiagnosticsEngine
 /// provided by this context.
 ///
@@ -204,12 +207,17 @@
 DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID)));
   }
 
+  void onResultEntry(StringRef CheckName,
+ const ast_matchers::BoundNodes ) const;
+  void onResultExit() const;
+
 private:
   // Writes to Stats.
   friend class ClangTidyDiagnosticConsumer;
 
   DiagnosticsEngine *DiagEngine;
   std::unique_ptr OptionsProvider;
+  std::unique_ptr Debugger;
 
   std::string CurrentFile;
   ClangTidyOptions CurrentOptions;
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTDiagnostic.h"
 #include "clang/AST/Attr.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
@@ -35,6 +36,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Regex.h"
 #include 
 #include 
@@ -151,6 +153,51 @@
 };
 } // end anonymous namespace
 
+namespace clang {
+namespace tidy {
+class CheckStackTraceDebug : public llvm::PrettyStackTraceEntry {
+public:
+  void print(raw_ostream ) const override {
+if (CurrentCheckName.empty())
+  return;
+// This should be an assert, but asserts shouldn't be used in signal
+// handlers
+if (!CurContext)
+  return;
+OS << "Processing check " << CurrentCheckName << '\n';
+CurrentCheckName = "";
+const clang::ast_matchers::BoundNodes::IDToNodeMap  =
+CurNodes->getMap();
+if (Map.empty()) {
+  OS << "No bound nodes\n";
+  return;
+}
+for (const auto  : Map) {
+  OS << "Node '" << Item.first << "' - ";
+  Item.second.dump(OS, *CurContext);
+  OS << "\n";
+}
+  }
+  void onResultEntry(StringRef CheckName,
+ const ast_matchers::BoundNodes ) {
+CurrentCheckName = CheckName;
+CurNodes = 
+  }
+
+  void onResultLeave() {
+CurrentCheckName = "";
+CurNodes = nullptr;
+  }
+  void setContext(const ASTContext ) { CurContext =  }
+  void clearContext() { CurContext = nullptr; }
+
+private:
+  mutable StringRef CurrentCheckName;
+  const ast_matchers::BoundNodes *CurNodes;
+  const ASTContext *CurContext;
+};
+} // namespace tidy
+} // namespace clang
 ClangTidyError::ClangTidyError(StringRef CheckName,
   

[clang-tools-extra] 93cf964 - Add 'clangd' prefix to remote index proto targets

2022-01-28 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-01-29T02:20:52+01:00
New Revision: 93cf9640fa3890aa3a4af8c4bd7c07322548b5e8

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

LOG: Add 'clangd' prefix to remote index proto targets

Some pieces of build infrastructure (shlib, debian package) classify
targets based on whether they begin with "clang".

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/CMakeLists.txt
clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
clang-tools-extra/clangd/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
index 5bfc241945437..3fd8930fd793b 100644
--- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -1,16 +1,16 @@
 if (CLANGD_ENABLE_REMOTE)
-  generate_protos(RemoteIndexProto "Index.proto")
-  generate_protos(MonitoringServiceProto "MonitoringService.proto"
+  generate_protos(clangdRemoteIndexProto "Index.proto")
+  generate_protos(clangdMonitoringServiceProto "MonitoringService.proto"
 GRPC)
-  generate_protos(RemoteIndexServiceProto "Service.proto"
+  generate_protos(clangdRemoteIndexServiceProto "Service.proto"
 DEPENDS "Index.proto"
 GRPC)
   # FIXME: Move this into generate_protos. Currently we only mention proto
   # filename as a dependency, but linking requires target name.
-  target_link_libraries(RemoteIndexServiceProto
+  target_link_libraries(clangdRemoteIndexServiceProto
 PRIVATE
-RemoteIndexProto
-MonitoringServiceProto
+clangdRemoteIndexProto
+clangdMonitoringServiceProto
 )
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
@@ -23,16 +23,16 @@ if (CLANGD_ENABLE_REMOTE)
 Client.cpp
 
 LINK_LIBS
-RemoteIndexProto
-RemoteIndexServiceProto
+clangdRemoteIndexProto
+clangdRemoteIndexServiceProto
 clangdRemoteMarshalling
 clangBasic
 clangDaemon
 clangdSupport
 
 DEPENDS
-RemoteIndexProto
-RemoteIndexServiceProto
+clangdRemoteIndexProto
+clangdRemoteIndexServiceProto
 )
 
   add_subdirectory(marshalling)

diff  --git a/clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
index a5f6ebd179ec9..071802a962647 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
@@ -2,11 +2,10 @@ add_clang_library(clangdRemoteMarshalling
   Marshalling.cpp
 
   LINK_LIBS
-  RemoteIndexProto
-
+  clangdRemoteIndexProto
   clangDaemon
   clangdSupport
 
   DEPENDS
-  RemoteIndexProto
+  clangdRemoteIndexProto
   )

diff  --git a/clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
index 602cb3e134dd6..194c7d5128a98 100644
--- a/clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
@@ -5,7 +5,7 @@ add_clang_executable(clangd-index-server-monitor
   Monitor.cpp
 
   DEPENDS
-  RemoteIndexServiceProto
+  clangdRemoteIndexServiceProto
   )
 
 target_link_libraries(clangd-index-server-monitor
@@ -13,6 +13,6 @@ target_link_libraries(clangd-index-server-monitor
   clangBasic
   clangdSupport
 
-  MonitoringServiceProto
-  RemoteIndexServiceProto
+  clangdMonitoringServiceProto
+  clangdRemoteIndexServiceProto
   )

diff  --git a/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
index f1131e53c9192..3bea34826f8a1 100644
--- a/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -5,8 +5,8 @@ add_clang_executable(clangd-index-server
   Server.cpp
 
   DEPENDS
-  RemoteIndexProto
-  RemoteIndexServiceProto
+  clangdRemoteIndexProto
+  clangdRemoteIndexServiceProto
   )
 
 target_link_libraries(clangd-index-server
@@ -14,9 +14,9 @@ target_link_libraries(clangd-index-server
   clangDaemon
   clangdSupport
 
-  MonitoringServiceProto
-  RemoteIndexProto
-  RemoteIndexServiceProto
+  clangdMonitoringServiceProto
+  clangdRemoteIndexProto
+  clangdRemoteIndexServiceProto
   clangdRemoteMarshalling
 
   ${REFLECTION_LIBRARY}

diff  --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index 29d177435f486..88af14700ec22 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ 

[PATCH] D118519: [clang-tidy] Organize the release notes a little better

2022-01-28 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood created this revision.
LegalizeAdulthood added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.
LegalizeAdulthood requested review of this revision.

- Sort new checks by check name
- Sort changes to existing checks by check name
- Link check names to the check's documentation
- Add docs for changes to readability-simplify-boolean-expr
- Move check changes from "Improvements to clang-tidy" to "Changes in existing 
checks" section


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118519

Files:
  clang-tools-extra/docs/ReleaseNotes.rst

Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -67,10 +67,6 @@
 Improvements to clang-tidy
 --
 
-- Make the `cppcoreguidelines-pro-bounds-array-to-pointer-decay` check accept
-  string literal to pointer decay in conditional operator even if operands are
-  of the same length.
-
 - Ignore warnings from macros defined in system headers, if not using the
   `-system-headers` flag.
 
@@ -80,21 +76,9 @@
 - Added support for `NOLINTBEGIN` ... `NOLINTEND` comments to suppress
   Clang-Tidy warnings over multiple lines.
 
-- Generalized the `modernize-use-default-member-init` check to handle non-default
-  constructors.
-
-- Eliminated false positives for `cppcoreguidelines-macro-usage` by restricting
-  the warning about using constants to only macros that expand to literals.
-
 New checks
 ^^
 
-- New :doc:`bugprone-stringview-nullptr
-  ` check.
-
-  Checks for various ways that the ``const CharT*`` constructor of
-  ``std::basic_string_view`` can be passed a null argument.
-
 - New :doc:`abseil-cleanup-ctad
   ` check.
 
@@ -102,6 +86,12 @@
   instances from the factory function to class template argument
   deduction (CTAD), in C++17 and higher.
 
+- New :doc:`bugprone-stringview-nullptr
+  ` check.
+
+  Checks for various ways that the ``const CharT*`` constructor of
+  ``std::basic_string_view`` can be passed a null argument.
+
 - New :doc:`bugprone-suspicious-memory-comparison
   ` check.
 
@@ -114,6 +104,11 @@
   Finds virtual classes whose destructor is neither public and virtual nor
   protected and non-virtual.
 
+- New :doc:`misc-misleading-bidirectional ` check.
+
+  Inspects string literal and comments for unterminated bidirectional Unicode
+  characters.
+
 - New :doc:`misc-misleading-identifier ` check.
 
   Reports identifier with unicode right-to-left characters.
@@ -141,11 +136,6 @@
   Reports identifiers whose names are too short. Currently checks local
   variables and function parameters only.
 
-- New :doc:`misc-misleading-bidirectional ` check.
-
-  Inspects string literal and comments for unterminated bidirectional Unicode
-  characters.
-
 New check aliases
 ^
 
@@ -167,40 +157,66 @@
 Changes in existing checks
 ^^
 
-- :doc:`bugprone-assert-side-effect `
-  check now supports an ``IgnoredFunctions`` option to explicitly consider
-  the specified semicolon-separated functions list as not having any
-  side-effects. Regular expressions for the list items are also accepted.
+- :doc:`bugprone-assert-side-effect
+  ` check now supports an
+  ``IgnoredFunctions`` option to explicitly consider the specified
+  semicolon-separated functions list as not having any side-effects.
+  Regular expressions for the list items are also accepted.
+
+- Fixed a false positive in :doc:`bugprone-throw-keyword-missing
+  ` when creating an
+  exception object using placement new.
 
 - Removed default setting ``cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors = "true"``,
-  from :doc:`cppcoreguidelines-explicit-virtual-functions `
+  from :doc:`cppcoreguidelines-explicit-virtual-functions
+  `
   to match the current state of the C++ Core Guidelines.
 
-- Removed suggestion ``use gsl::at`` from warning message in the
-  ``cppcoreguidelines-pro-bounds-constant-array-index`` check, since that is not
-  a requirement from the C++ Core Guidelines. This allows people to choose
-  their own safe indexing strategy. The fix-it is kept for those who want to
-  use the GSL library.
+- Eliminated false positives for :doc:`cppcoreguidelines-macro-usage
+  ` by restricting
+  the warning about using constants to only macros that expand to literals.
 
-- Updated :doc:`google-readability-casting
-  ` to diagnose and fix functional
-  casts, to achieve feature parity with the corresponding ``cpplint.py`` check.
+- :doc:`cppcoreguidelines-narrowing-conversions
+  `
+  check now supports a ``WarnOnIntegerToFloatingPointNarrowingConversion``
+  option to control whether to warn on narrowing integer to floating-point
+  conversions.
+
+- Make the :doc:`cppcoreguidelines-pro-bounds-array-to-pointer-decay
+  `
+  check accept string literal to pointer decay in conditional operator even
+  if operands are 

[PATCH] D118518: [clang][NFC] Change some ->getType()->isPlaceholderType() to just ->hasPlaceholderType()

2022-01-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone created this revision.
Quuxplusone added reviewers: ChuanqiXu, urnathan, efriedma, kazu.
Quuxplusone added a project: clang.
Quuxplusone requested review of this revision.
Herald added a subscriber: cfe-commits.

While trying to figure out https://github.com/llvm/llvm-project/issues/52909 
(which I still have not), it seemed like we could simplify some of these 
expressions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118518

Files:
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp

Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -564,7 +564,7 @@
 SourceLocation RParenLoc) {
   bool WasEvaluated = false;
   if (E && !E->isTypeDependent()) {
-if (E->getType()->isPlaceholderType()) {
+if (E->hasPlaceholderType()) {
   ExprResult result = CheckPlaceholderExpr(E);
   if (result.isInvalid()) return ExprError();
   E = result.get();
@@ -5704,7 +5704,7 @@
   SourceLocation RParen) {
   if (Queried->isTypeDependent()) {
 // Delay type-checking for type-dependent expressions.
-  } else if (Queried->getType()->isPlaceholderType()) {
+  } else if (Queried->hasPlaceholderType()) {
 ExprResult PE = CheckPlaceholderExpr(Queried);
 if (PE.isInvalid()) return ExprError();
 return BuildExpressionTrait(ET, KWLoc, PE.get(), RParen);
@@ -5720,8 +5720,8 @@
 ExprValueKind ,
 SourceLocation Loc,
 bool isIndirect) {
-  assert(!LHS.get()->getType()->isPlaceholderType() &&
- !RHS.get()->getType()->isPlaceholderType() &&
+  assert(!LHS.get()->hasPlaceholderType() &&
+ !RHS.get()->hasPlaceholderType() &&
  "placeholders should have been weeded out by now");
 
   // The LHS undergoes lvalue conversions if this is ->*, and undergoes the
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -497,7 +497,7 @@
 /// DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
 ExprResult Sema::DefaultFunctionArrayConversion(Expr *E, bool Diagnose) {
   // Handle any placeholder expressions which made it here.
-  if (E->getType()->isPlaceholderType()) {
+  if (E->hasPlaceholderType()) {
 ExprResult result = CheckPlaceholderExpr(E);
 if (result.isInvalid()) return ExprError();
 E = result.get();
@@ -621,7 +621,7 @@
 
 ExprResult Sema::DefaultLvalueConversion(Expr *E) {
   // Handle any placeholder expressions which made it here.
-  if (E->getType()->isPlaceholderType()) {
+  if (E->hasPlaceholderType()) {
 ExprResult result = CheckPlaceholderExpr(E);
 if (result.isInvalid()) return ExprError();
 E = result.get();
@@ -4685,7 +4685,7 @@
 Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base, SourceLocation lbLoc,
   Expr *idx, SourceLocation rbLoc) {
   if (base && !base->getType().isNull() &&
-  base->getType()->isSpecificPlaceholderType(BuiltinType::OMPArraySection))
+  base->hasPlaceholderType(BuiltinType::OMPArraySection))
 return ActOnOMPArraySectionExpr(base, lbLoc, idx, SourceLocation(),
 SourceLocation(), /*Length*/ nullptr,
 /*Stride=*/nullptr, rbLoc);
@@ -4711,8 +4711,7 @@
   };
   // The matrix subscript operator ([][])is considered a single operator.
   // Separating the index expressions by parenthesis is not allowed.
-  if (base->getType()->isSpecificPlaceholderType(
-  BuiltinType::IncompleteMatrixIdx) &&
+  if (base->hasPlaceholderType(BuiltinType::IncompleteMatrixIdx) &&
   !isa(base)) {
 Diag(base->getExprLoc(), diag::err_matrix_separate_incomplete_index)
 << SourceRange(base->getBeginLoc(), rbLoc);
@@ -4944,9 +4943,8 @@
   SourceLocation ColonLocSecond,
   Expr *Length, Expr *Stride,
   SourceLocation RBLoc) {
-  if (Base->getType()->isPlaceholderType() &&
-  !Base->getType()->isSpecificPlaceholderType(
-  BuiltinType::OMPArraySection)) {
+  if (Base->hasPlaceholderType() &&
+  !Base->hasPlaceholderType(BuiltinType::OMPArraySection)) {
 ExprResult Result = CheckPlaceholderExpr(Base);
 if (Result.isInvalid())
   return ExprError();
@@ -5114,8 +5112,7 @@
 }
   }
 
-  if (!Base->getType()->isSpecificPlaceholderType(
-  BuiltinType::OMPArraySection)) {
+  if (!Base->hasPlaceholderType(BuiltinType::OMPArraySection)) {
 ExprResult Result = DefaultFunctionArrayLvalueConversion(Base);
 if (Result.isInvalid())
   return 

[PATCH] D117937: [VFS] Add a "redirecting-with" field to overlays

2022-01-28 Thread Ben Barham via Phabricator via cfe-commits
bnbarham marked 5 inline comments as done.
bnbarham added inline comments.



Comment at: llvm/include/llvm/Support/VirtualFileSystem.h:575
+///   instead>
+///   'redirecting-with': 

keith wrote:
> bnbarham wrote:
> > keith wrote:
> > > I think `redirecting-with` is fine, and I can't come up with something 
> > > better
> > Thanks. Do you know if this format is documented anywhere that I would need 
> > to update?
> Folks here used to joke that the source was the documentation, and based on a 
> quick search that still seems to be the case, I don't see any places where 
> the others are mentioned
Not sure if I should be happy that I don't need to update anything or sad that 
this is the case  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117937

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


[PATCH] D117937: [VFS] Add a "redirecting-with" field to overlays

2022-01-28 Thread Ben Barham via Phabricator via cfe-commits
bnbarham updated this revision to Diff 404194.
bnbarham added a comment.

Updated to address Keith's comments. Added an error for an invalid redirect 
kind as well as when both `redirect-with` and `fallthrough` are given. Also 
added tests for these cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117937

Files:
  clang/test/VFS/Inputs/redirect-and-fallthrough.yaml
  clang/test/VFS/Inputs/unknown-redirect.yaml
  clang/test/VFS/fallback.c
  clang/test/VFS/parse-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1910,7 +1910,24 @@
   Lower);
   EXPECT_EQ(nullptr, FS.get());
 
-  EXPECT_EQ(26, NumDiagnostics);
+  // invalid redirect kind
+  FS = getFromYAMLString("{ 'redirecting-with': 'none', 'roots': [{\n"
+ "  'type': 'directory-remap',\n"
+ "  'name': '//root/A',\n"
+ "  'external-contents': '//root/B' }]}",
+ Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  // redirect and fallthrough passed
+  FS = getFromYAMLString("{ 'redirecting-with': 'none', 'fallthrough': true\n"
+ "  'roots': [{\n"
+ "'type': 'directory-remap',\n"
+ "'name': '//root/A',\n"
+ "'external-contents': '//root/B' }]}",
+ Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  EXPECT_EQ(28, NumDiagnostics);
 }
 
 TEST_F(VFSFromYAMLTest, UseExternalName) {
@@ -2710,6 +2727,121 @@
   EXPECT_FALSE(FS->exists(_c.path("c")));
 }
 
+TEST_F(VFSFromYAMLTest, RedirectingWith) {
+  IntrusiveRefCntPtr Both(new DummyFileSystem());
+  Both->addDirectory("//root/a");
+  Both->addRegularFile("//root/a/f");
+  Both->addDirectory("//root/b");
+  Both->addRegularFile("//root/b/f");
+
+  IntrusiveRefCntPtr AOnly(new DummyFileSystem());
+  AOnly->addDirectory("//root/a");
+  AOnly->addRegularFile("//root/a/f");
+
+  IntrusiveRefCntPtr BOnly(new DummyFileSystem());
+  BOnly->addDirectory("//root/b");
+  BOnly->addRegularFile("//root/b/f");
+
+  auto BaseStr = std::string("  'roots': [\n"
+ "{\n"
+ "  'type': 'directory-remap',\n"
+ "  'name': '//root/a',\n"
+ "  'external-contents': '//root/b'\n"
+ "}\n"
+ "  ]\n"
+ "}");
+  auto FallthroughStr = "{ 'redirecting-with': 'fallthrough',\n" + BaseStr;
+  auto FallbackStr = "{ 'redirecting-with': 'fallback',\n" + BaseStr;
+  auto RedirectOnlyStr = "{ 'redirecting-with': 'redirect-only',\n" + BaseStr;
+
+  auto ExpectPath = [&](vfs::FileSystem , StringRef Expected,
+StringRef Message) {
+auto AF = FS.openFileForRead("//root/a/f");
+ASSERT_FALSE(AF.getError()) << Message;
+auto AFName = (*AF)->getName();
+ASSERT_FALSE(AFName.getError()) << Message;
+EXPECT_EQ(Expected.str(), AFName.get()) << Message;
+
+auto AS = FS.status("//root/a/f");
+ASSERT_FALSE(AS.getError()) << Message;
+EXPECT_EQ(Expected.str(), AS->getName()) << Message;
+  };
+
+  auto ExpectFailure = [&](vfs::FileSystem , StringRef Message) {
+EXPECT_TRUE(FS.openFileForRead("//root/a/f").getError()) << Message;
+EXPECT_TRUE(FS.status("//root/a/f").getError()) << Message;
+  };
+
+  {
+// `f` in both `a` and `b`
+
+// `fallthrough` tries `external-name` first, so should be `b`
+IntrusiveRefCntPtr Fallthrough =
+getFromYAMLString(FallthroughStr, Both);
+ASSERT_TRUE(Fallthrough.get() != nullptr);
+ExpectPath(*Fallthrough, "//root/b/f", "fallthrough, both exist");
+
+// `fallback` tries the original name first, so should be `a`
+IntrusiveRefCntPtr Fallback =
+getFromYAMLString(FallbackStr, Both);
+ASSERT_TRUE(Fallback.get() != nullptr);
+ExpectPath(*Fallback, "//root/a/f", "fallback, both exist");
+
+// `redirect-only` is the same as `fallthrough` but doesn't try the
+// original on failure, so no change here (ie. `b`)
+IntrusiveRefCntPtr Redirect =
+getFromYAMLString(RedirectOnlyStr, Both);
+ASSERT_TRUE(Redirect.get() != nullptr);
+ExpectPath(*Redirect, "//root/b/f", "redirect-only, both exist");
+  }
+
+  {
+// `f` in `a` only
+
+// Fallthrough to the original path, `a`
+IntrusiveRefCntPtr Fallthrough =
+getFromYAMLString(FallthroughStr, AOnly);
+ASSERT_TRUE(Fallthrough.get() != nullptr);
+ExpectPath(*Fallthrough, "//root/a/f", "fallthrough, 

[PATCH] D118350: [Clang][Sema][AIX][PowerPC] Emit byval alignment warning only when struct member is passed to a function

2022-01-28 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA marked 8 inline comments as done.
ZarkoCA added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:12693-12695
   void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
- StringRef ParamName, QualType ArgTy, QualType 
ParamTy);
+ StringRef ParamName, QualType ArgTy, QualType ParamTy,
+ const Expr *Arg = nullptr);

ZarkoCA wrote:
> aaron.ballman wrote:
> > I'm not keen on passing both `Arg` and `ArgTy` such that they can get out 
> > of sync. Do all of the places calling `CheckArgAlignment()` have access to 
> > the `Expr` so that we can require it be passed (and drop the `ArgTy` 
> > parameter)?
> Thanks, that is something I overlooked. 
> 
> It seems like I can do this everywhere except the call from 
> `Sema::CheckConstructorCall`. Trying to figure out whether it's something I'm 
> missing. 
Thanks for the through review, I think I addressed everything but this comment. 
I agree with your concern about having `Arg` and `ArgTy` getting out of sync. I 
need to spend more time on that particular call from 
`Sema::CheckConstructorCall` and see what can be done. 



Comment at: clang/lib/Sema/SemaChecking.cpp:5220
+  // Using AArg so as to not modify Arg for the rest of the function.
+  const Expr *AArg = Arg->IgnoreParens();
+  if (AArg->getStmtClass() == Stmt::ImplicitCastExprClass) {

aaron.ballman wrote:
> Are there other things you want to ignore here (such as 
> `IgnoreParenNoopCasts()`)? (I don't have an opinion the current code is 
> wrong, just checking if those sort of cases were considered or not.)
Yes, thanks. I do have suspicions that `IgnoreParens()` may be too broad but I 
am worried that we may miss cases to diagnose otherwise. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118350

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


[PATCH] D118493: [WIP]Set rpath on openmp executables

2022-01-28 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 404193.
JonChesterfield added a comment.

- set rpath after libomptarget, reads better than between the two -l flags


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118493

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


Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -106,6 +106,9 @@
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 
+void addOpenMPRuntimeSpecificRPath(const ToolChain ,
+   const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList );
 void addArchSpecificRPath(const ToolChain , const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 /// Returns true, if an OpenMP runtime has been added.
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -645,6 +645,22 @@
  /*IsLTO=*/true);
 }
 
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain ,
+  const ArgList ,
+  ArgStringList ) {
+
+  if (Args.hasFlag(options::OPT_fopenmp_implicit_rpath,
+   options::OPT_fno_openmp_implicit_rpath, true)) {
+// Default to clang lib / lib64 folder, i.e. the same location as device
+// runtime
+SmallString<256> DefaultLibPath =
+llvm::sys::path::parent_path(TC.getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath, Twine("lib") + 
CLANG_LIBDIR_SUFFIX);
+CmdArgs.push_back("-rpath");
+CmdArgs.push_back(Args.MakeArgString(DefaultLibPath));
+  }
+}
+
 void tools::addArchSpecificRPath(const ToolChain , const ArgList ,
  ArgStringList ) {
   // Enable -frtlib-add-rpath by default for the case of VE.
@@ -702,6 +718,9 @@
 
   addArchSpecificRPath(TC, Args, CmdArgs);
 
+  if (RTKind == Driver::OMPRT_OMP)
+addOpenMPRuntimeSpecificRPath(TC, Args, CmdArgs);
+  
   return true;
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3895,6 +3895,11 @@
   HelpText<"Add -rpath with architecture-specific resource directory to the 
linker flags">;
 def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, 
Flags<[NoArgumentUnused]>,
   HelpText<"Do not add -rpath with architecture-specific resource directory to 
the linker flags">;
+defm openmp_implicit_rpath: BoolFOption<"openmp-implicit-rpath",
+  LangOpts<"OpenMP">,
+  DefaultTrue,
+  PosFlag,
+  NegFlag>;
 def r : Flag<["-"], "r">, Flags<[LinkerInput,NoArgumentUnused]>,
 Group;
 def save_temps_EQ : Joined<["-", "--"], "save-temps=">, Flags<[CC1Option, 
NoXarchOption]>,


Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -106,6 +106,9 @@
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 
+void addOpenMPRuntimeSpecificRPath(const ToolChain ,
+   const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList );
 void addArchSpecificRPath(const ToolChain , const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 /// Returns true, if an OpenMP runtime has been added.
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -645,6 +645,22 @@
  /*IsLTO=*/true);
 }
 
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain ,
+  const ArgList ,
+  ArgStringList ) {
+
+  if (Args.hasFlag(options::OPT_fopenmp_implicit_rpath,
+   options::OPT_fno_openmp_implicit_rpath, true)) {
+// Default to clang lib / lib64 folder, i.e. the same location as device
+// runtime
+SmallString<256> DefaultLibPath =
+llvm::sys::path::parent_path(TC.getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
+CmdArgs.push_back("-rpath");
+CmdArgs.push_back(Args.MakeArgString(DefaultLibPath));
+  }
+}
+
 void tools::addArchSpecificRPath(const ToolChain , 

[PATCH] D117924: [compiler_rt] Add a seperate runtime for Mac Catalyst

2022-01-28 Thread Byoungchan Lee via Phabricator via cfe-commits
bc-lee added a comment.

For the Chromium side issue is https://crbug.com/1259122. Also I opened LLVM 
issue https://github.com/llvm/llvm-project/issues/53477.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117924

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


[PATCH] D118350: [Clang][Sema][AIX][PowerPC] Emit byval alignment warning only when struct member is passed to a function

2022-01-28 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 404190.
ZarkoCA added a comment.

Addressed some of the comments:

- Applied code cleanup per suggestions
- Used `CharUnits` instead of hard coded values


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118350

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/aix-attr-align.c

Index: clang/test/Sema/aix-attr-align.c
===
--- clang/test/Sema/aix-attr-align.c
+++ clang/test/Sema/aix-attr-align.c
@@ -6,17 +6,31 @@
 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux -verify=off -fsyntax-only %s
 
 struct S {
-  int a[8] __attribute__((aligned(8))); // no-warning
+  int a[8] __attribute__((aligned(8)));  // no-warning
+  int b[8] __attribute__((aligned(16))); // no-warning
+  int c[2] __attribute__((aligned(32))); // no-warning
 };
 
 struct T {
-  int a[4] __attribute__((aligned(16))); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+  int a[4] __attribute__((aligned(16))); // no-warning
 };
 
 struct U {
-  int a[2] __attribute__((aligned(32))); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+  int a[2] __attribute__((aligned(32))); // no-warning
 };
 
 int a[8] __attribute__((aligned(8)));  // no-warning
 int b[4] __attribute__((aligned(16))); // no-warning
 int c[2] __attribute__((aligned(32))); // no-warning
+
+void baz(int *);
+void foo(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8,
+ struct S s) {
+  baz(s.a); // no-warning
+  baz(s.b); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+  baz(s.c); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+
+  baz(a); // no-warning
+  baz(b); // no-warning
+  baz(c); // no-warning
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4321,13 +4321,6 @@
 return;
 
   uint64_t AlignVal = Alignment.getZExtValue();
-  // 16 byte ByVal alignment not due to a vector member is not honoured by XL
-  // on AIX. Emit a warning here that users are generating binary incompatible
-  // code to be safe.
-  if (AlignVal >= 16 && isa(D) &&
-  Context.getTargetInfo().getTriple().isOSAIX())
-Diag(AttrLoc, diag::warn_not_xl_compatible) << E->getSourceRange();
-
   // C++11 [dcl.align]p2:
   //   -- if the constant expression evaluates to zero, the alignment
   //  specifier shall have no effect
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5201,18 +5201,42 @@
   }
 }
 
-/// Warn if a pointer or reference argument passed to a function points to an
-/// object that is less aligned than the parameter. This can happen when
+/// Check for problematic alignment properties of an argument. For example,
+/// warn if a pointer or reference argument passed to a function points to
+/// an object that is less aligned than the parameter. This can happen when
 /// creating a typedef with a lower alignment than the original type and then
 /// calling functions defined in terms of the original type.
 void Sema::CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
  StringRef ParamName, QualType ArgTy,
- QualType ParamTy) {
+ QualType ParamTy, const Expr *Arg) {
 
   // If a function accepts a pointer or reference type
   if (!ParamTy->isPointerType() && !ParamTy->isReferenceType())
 return;
 
+  // 16 byte ByVal alignment not due to a vector member is not honoured by XL
+  // on AIX. Emit a warning here that users are generating binary incompatible
+  // code to be safe.
+  // Here we try to get information about the alignment of the struct member
+  // argument being passed to the caller function.
+  if (Context.getTargetInfo().getTriple().isOSAIX() && Arg) {
+// Using AArg so as to not modify Arg for the rest of the function.
+const Expr *AArg = Arg->IgnoreParens();
+if (const auto *ICE = dyn_cast(AArg)) {
+  AArg = ICE->getSubExpr();
+  if (const auto *ME = dyn_cast(AArg)) {
+if (auto *FD = dyn_cast(ME->getMemberDecl())) {
+  if (const auto *AA = FD->getAttr()) {
+CharUnits Alignment =
+Context.toCharUnitsFromBits(AA->getAlignment(Context));
+  

[PATCH] D117888: [clang][driver][wasm] Support -stdlib=libstdc++ for WebAssembly

2022-01-28 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:448
+addSystemInclude(DriverArgs, CC1Args,
+ getDriver().SysRoot + "/include/c++/11");
+break;

Where does `11` come from here?  Do other drivers hardcode this the same way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117888

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


[PATCH] D111457: [clang][test] Add lit helper for windows paths

2022-01-28 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: clang/test/lit.cfg.py:60
+if platform.system() == 'Windows':
+root_sep = 'C:\\'
+else:

compnerd wrote:
> This isn't really a separator, this is the root itself.  I think that it 
> makes sense to name it accordingly.  Please do not hard code this to `C:\`.  
> There is no guarantee that the root is `C:\`.
Yea I didn't like the original naming here either, any suggestions? I avoid 
`path` in these because of the existing `pathsep`, maybe `fsroot` and `fssep`?

What are you suggesting in place of hardcoding `C:\`? I don't think we could 
detect what folks are using in the tests, so it does seem like it would be up 
for individual tests to do this however it makes sense. It appears that there 
are a few hundred uses of this in tests today, does that break in general if 
you're using another drive?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

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


[PATCH] D117888: [clang][driver][wasm] Support -stdlib=libstdc++ for WebAssembly

2022-01-28 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

I haven't reviewed this yet, but since we got one of these before and never 
merged it (https://reviews.llvm.org/D101464) we should probably land one of 
these.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117888

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


[PATCH] D118493: [WIP]Set rpath on openmp executables

2022-01-28 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Slightly stalled on testing - I'd like to emit the object and feed it to 
readelf, something like:
`// RUN: %clang %s -o %t && llvm-readelf --dynamic-table %t | FileCheck %s 
--check-prefixes=CHECK`

which errors with cannot find -lomp. I feel there should be a linker flag to 
the effect of "ignore libraries you can't find", which I have failed to 
identify. Candidate workarounds are putting empty files called libomp.a in 
Inputs, changing the control flow in addOpenMPRuntime or finding said linker 
flag.

Toolchain style testing (like Driver/amdgpu-openmp-toolchain) is sufficient to 
show rpath is inserted, e.g. `"-lomp" "-lomptarget" "-rpath" "*/llvm/lib"`, but 
doesn't let one check interaction with user provided rpaths. I'll pick this up 
over the weekend.

Poking it manually works as one would wish so the functionality looks fine. 
Please speak up in the meantime if you'd like the option to be named or 
documented differently, or if there's any other change desired for the 
non-testing part.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118493

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


[PATCH] D118495: [OpenMP] Accept shortened triples for -Xopenmp-target=

2022-01-28 Thread Joseph Huber 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 rG24f88f57de58: [OpenMP] Accept shortened triples for 
-Xopenmp-target= (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118495

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


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -343,3 +343,10 @@
 // RUN:   | FileCheck -check-prefix=SAVE_TEMPS_NAMES %s
 
 // SAVE_TEMPS_NAMES-NOT: "GNU::Linker"{{.*}}["[[SAVE_TEMPS_INPUT1:.*\.o]]", 
"[[SAVE_TEMPS_INPUT1]]"]
+
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64 
-Xopenmp-target=nvptx64 -march=sm_35 \
+// RUN:  -save-temps -no-canonical-prefixes %s -o openmp-offload-gpu 
2>&1 \
+// RUN:   | FileCheck -check-prefix=TRIPLE %s
+
+// TRIPLE: "-triple" "nvptx64-nvidia-cuda"
+// TRIPLE: "-target-cpu" "sm_35"
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1129,8 +1129,10 @@
 A->getOption().matches(options::OPT_Xopenmp_target);
 
 if (A->getOption().matches(options::OPT_Xopenmp_target_EQ)) {
+  llvm::Triple TT(getOpenMPTriple(A->getValue(0)));
+
   // Passing device args: -Xopenmp-target= -opt=val.
-  if (A->getValue(0) == getTripleString())
+  if (TT.getTriple() == getTripleString())
 Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
   else
 continue;
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -792,21 +792,9 @@
   if (HasValidOpenMPRuntime) {
 llvm::StringMap FoundNormalizedTriples;
 for (const char *Val : OpenMPTargets->getValues()) {
-  llvm::Triple TT(Val);
+  llvm::Triple TT(ToolChain::getOpenMPTriple(Val));
   std::string NormalizedName = TT.normalize();
 
-  // We want to expand the shortened versions of the triples passed in 
to
-  // the values used for the bitcode libraries for convenience.
-  if (TT.getVendor() == llvm::Triple::UnknownVendor ||
-  TT.getOS() == llvm::Triple::UnknownOS) {
-if (TT.getArch() == llvm::Triple::nvptx)
-  TT = llvm::Triple("nvptx-nvidia-cuda");
-else if (TT.getArch() == llvm::Triple::nvptx64)
-  TT = llvm::Triple("nvptx64-nvidia-cuda");
-else if (TT.getArch() == llvm::Triple::amdgcn)
-  TT = llvm::Triple("amdgcn-amd-amdhsa");
-  }
-
   // Make sure we don't have a duplicate triple.
   auto Duplicate = FoundNormalizedTriples.find(NormalizedName);
   if (Duplicate != FoundNormalizedTriples.end()) {
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -711,6 +711,22 @@
   const llvm::fltSemantics *FPType = nullptr) const {
 return llvm::DenormalMode::getIEEE();
   }
+
+  // We want to expand the shortened versions of the triples passed in to
+  // the values used for the bitcode libraries.
+  static llvm::Triple getOpenMPTriple(StringRef TripleStr) {
+llvm::Triple TT(TripleStr);
+if (TT.getVendor() == llvm::Triple::UnknownVendor ||
+TT.getOS() == llvm::Triple::UnknownOS) {
+  if (TT.getArch() == llvm::Triple::nvptx)
+return llvm::Triple("nvptx-nvidia-cuda");
+  if (TT.getArch() == llvm::Triple::nvptx64)
+return llvm::Triple("nvptx64-nvidia-cuda");
+  if (TT.getArch() == llvm::Triple::amdgcn)
+return llvm::Triple("amdgcn-amd-amdhsa");
+}
+return TT;
+  }
 };
 
 /// Set a ToolChain's effective triple. Reset it when the registration object


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -343,3 +343,10 @@
 // RUN:   | FileCheck -check-prefix=SAVE_TEMPS_NAMES %s
 
 // SAVE_TEMPS_NAMES-NOT: "GNU::Linker"{{.*}}["[[SAVE_TEMPS_INPUT1:.*\.o]]", "[[SAVE_TEMPS_INPUT1]]"]
+
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64 -Xopenmp-target=nvptx64 -march=sm_35 \
+// RUN:  -save-temps -no-canonical-prefixes %s -o openmp-offload-gpu 2>&1 \
+// RUN:   | FileCheck -check-prefix=TRIPLE %s
+
+// TRIPLE: "-triple" "nvptx64-nvidia-cuda"
+// TRIPLE: "-target-cpu" "sm_35"
Index: clang/lib/Driver/ToolChain.cpp

[clang] 24f88f5 - [OpenMP] Accept shortened triples for -Xopenmp-target=

2022-01-28 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-01-28T18:22:17-05:00
New Revision: 24f88f57de588817bd21e799e2ac1069c025674c

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

LOG: [OpenMP] Accept shortened triples for -Xopenmp-target=

This patch builds on the change in D117634 that expanded the short
triples when passed in by the user. This patch adds the same
functionality for the `-Xopenmp-target=` flag. Previously it was
unintuitive that passing `-fopenmp-targets=nvptx64
-Xopenmp-target=nvptx64 ` would not forward the arg because the
triples did not match on account of `nvptx64` being expanded to
`nvptx64-nvidia-cuda`.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/openmp-offload-gpu.c

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 329833bb13be..7cd6a5fd3777 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -711,6 +711,22 @@ class ToolChain {
   const llvm::fltSemantics *FPType = nullptr) const {
 return llvm::DenormalMode::getIEEE();
   }
+
+  // We want to expand the shortened versions of the triples passed in to
+  // the values used for the bitcode libraries.
+  static llvm::Triple getOpenMPTriple(StringRef TripleStr) {
+llvm::Triple TT(TripleStr);
+if (TT.getVendor() == llvm::Triple::UnknownVendor ||
+TT.getOS() == llvm::Triple::UnknownOS) {
+  if (TT.getArch() == llvm::Triple::nvptx)
+return llvm::Triple("nvptx-nvidia-cuda");
+  if (TT.getArch() == llvm::Triple::nvptx64)
+return llvm::Triple("nvptx64-nvidia-cuda");
+  if (TT.getArch() == llvm::Triple::amdgcn)
+return llvm::Triple("amdgcn-amd-amdhsa");
+}
+return TT;
+  }
 };
 
 /// Set a ToolChain's effective triple. Reset it when the registration object

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 61c2289f83e9..054f7d415539 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -792,21 +792,9 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation 
,
   if (HasValidOpenMPRuntime) {
 llvm::StringMap FoundNormalizedTriples;
 for (const char *Val : OpenMPTargets->getValues()) {
-  llvm::Triple TT(Val);
+  llvm::Triple TT(ToolChain::getOpenMPTriple(Val));
   std::string NormalizedName = TT.normalize();
 
-  // We want to expand the shortened versions of the triples passed in 
to
-  // the values used for the bitcode libraries for convenience.
-  if (TT.getVendor() == llvm::Triple::UnknownVendor ||
-  TT.getOS() == llvm::Triple::UnknownOS) {
-if (TT.getArch() == llvm::Triple::nvptx)
-  TT = llvm::Triple("nvptx-nvidia-cuda");
-else if (TT.getArch() == llvm::Triple::nvptx64)
-  TT = llvm::Triple("nvptx64-nvidia-cuda");
-else if (TT.getArch() == llvm::Triple::amdgcn)
-  TT = llvm::Triple("amdgcn-amd-amdhsa");
-  }
-
   // Make sure we don't have a duplicate triple.
   auto Duplicate = FoundNormalizedTriples.find(NormalizedName);
   if (Duplicate != FoundNormalizedTriples.end()) {

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 5fef1fb2ee5a..3c13f1b1cacb 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1129,8 +1129,10 @@ llvm::opt::DerivedArgList 
*ToolChain::TranslateOpenMPTargetArgs(
 A->getOption().matches(options::OPT_Xopenmp_target);
 
 if (A->getOption().matches(options::OPT_Xopenmp_target_EQ)) {
+  llvm::Triple TT(getOpenMPTriple(A->getValue(0)));
+
   // Passing device args: -Xopenmp-target= -opt=val.
-  if (A->getValue(0) == getTripleString())
+  if (TT.getTriple() == getTripleString())
 Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
   else
 continue;

diff  --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index 525ee465d246..3d523e4b69e4 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -343,3 +343,10 @@
 // RUN:   | FileCheck -check-prefix=SAVE_TEMPS_NAMES %s
 
 // SAVE_TEMPS_NAMES-NOT: "GNU::Linker"{{.*}}["[[SAVE_TEMPS_INPUT1:.*\.o]]", 
"[[SAVE_TEMPS_INPUT1]]"]
+
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64 
-Xopenmp-target=nvptx64 -march=sm_35 \
+// RUN:  -save-temps -no-canonical-prefixes %s -o openmp-offload-gpu 
2>&1 \
+// RUN:   | FileCheck -check-prefix=TRIPLE %s
+
+// TRIPLE: 

[PATCH] D117238: [C2x] Add BITINT_MAXWIDTH support

2022-01-28 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

I verified locally that reverting this patch fixes the build.
Reverted in fad7e491a0770ac4336934030ac67d77e7af5520 
 to 
unblock Green Dragon, etc.
@aaron.ballman Please take a look when you get a chance.


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

https://reviews.llvm.org/D117238

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


[clang] fad7e49 - Revert "Add BITINT_MAXWIDTH support"

2022-01-28 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2022-01-28T15:18:49-08:00
New Revision: fad7e491a0770ac4336934030ac67d77e7af5520

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

LOG: Revert "Add BITINT_MAXWIDTH support"

This reverts commit 86797fdb6f51d32f285e48b6d3e0fc5b8b852734.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/TargetInfo.h
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Headers/limits.h
clang/lib/Sema/SemaType.cpp
clang/test/CodeGen/ext-int-cc.c
clang/test/CodeGen/ext-int.c
clang/test/CodeGenCXX/ext-int.cpp
clang/test/Headers/limits.cpp
clang/test/Preprocessor/init-aarch64.c
clang/test/Preprocessor/init.c
clang/test/Sema/builtins-overflow.c
clang/test/SemaCXX/ext-int.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4b444bece68a7..f081ff0313e0a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -174,12 +174,7 @@ C Language Changes in Clang
   ``_BitInt(N)`` is supported as an extension in older C modes and in all C++
   modes. Note: the ABI for ``_BitInt(N)`` is still in the process of being
   stabilized, so this type should not yet be used in interfaces that require
-  ABI stability. The maximum width supported by Clang can be obtained from the
-  ``BITINT_MAXWIDTH`` macro in . Currently, Clang supports bit
-  widths <= 128 because backends are not yet able to cope with some math
-  operations (like division) on wider integer types. See
-  `PR44994 `_ for more
-  information.
+  ABI stability.
 - When using ``asm goto`` with outputs whose constraint modifier is ``"+"``, we
   now change the numbering of the labels to occur after hidden tied inputs for
   better compatibility with GCC.  For better portability between 
diff erent

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index a49342a34f3e8..642c8500364bb 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -590,17 +590,6 @@ class TargetInfo : public virtual TransferrableTargetInfo,
 return false;
   }
 
-  // Different targets may support a 
diff erent maximum width for the _BitInt
-  // type, depending on what operations are supported.
-  virtual size_t getMaxBitIntWidth() const {
-// FIXME: this value should be llvm::IntegerType::MAX_INT_BITS, which is
-// maximum bit width that LLVM claims its IR can support. However, most
-// backends currently have a bug where they only support division
-// operations on types that are <= 128 bits and crash otherwise. We're
-// setting the max supported value to 128 to be conservative.
-return 128;
-  }
-
   /// Determine whether _Float16 is supported on this target.
   virtual bool hasLegalHalfType() const { return HasLegalHalfType; }
 

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index e259ab47c5589..a9023a7a1171e 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -25,7 +25,6 @@
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/IR/DataLayout.h"
-#include "llvm/IR/DerivedTypes.h"
 using namespace clang;
 
 static bool MacroBodyEndsInBackslash(StringRef MacroBody) {
@@ -915,13 +914,6 @@ static void InitializePredefinedMacros(const TargetInfo 
,
   Builder.defineMacro("__LONG_WIDTH__", Twine(TI.getLongWidth()));
   Builder.defineMacro("__LLONG_WIDTH__", Twine(TI.getLongLongWidth()));
 
-  size_t BitIntMaxWidth = TI.getMaxBitIntWidth();
-  assert(BitIntMaxWidth <= llvm::IntegerType::MAX_INT_BITS &&
- "Target defined a max bit width larger than LLVM can support!");
-  assert(BitIntMaxWidth >= TI.getLongLongWidth() &&
- "Target defined a max bit width smaller than the C standard allows!");
-  Builder.defineMacro("__BITINT_MAXWIDTH__", Twine(BitIntMaxWidth));
-
   DefineTypeSize("__SCHAR_MAX__", TargetInfo::SignedChar, TI, Builder);
   DefineTypeSize("__SHRT_MAX__", TargetInfo::SignedShort, TI, Builder);
   DefineTypeSize("__INT_MAX__", TargetInfo::SignedInt, TI, Builder);

diff  --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index cfd23a219ee55..c2d3a7cf43539 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -78,8 +78,6 @@
 #define LONG_WIDTH   __LONG_WIDTH__
 #define ULLONG_WIDTH __LLONG_WIDTH__
 #define LLONG_WIDTH  __LLONG_WIDTH__
-
-#define BITINT_MAXWIDTH __BITINT_MAXWIDTH__
 #endif
 
 #ifdef __CHAR_UNSIGNED__  /* -funsigned-char */

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp

[clang-tools-extra] 99217fa - [clang-tidy] Recognize labelled statements when simplifying boolean exprs

2022-01-28 Thread via cfe-commits

Author: Richard
Date: 2022-01-28T16:09:46-07:00
New Revision: 99217fa8a027a893a9b2f46ed315ec4cab850e3d

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

LOG: [clang-tidy] Recognize labelled statements when simplifying boolean exprs

Inside a switch the caseStmt() and defaultStmt() have a nested statement
associated with them.  Similarly, labelStmt() has a nested statement.
These statements were being missed when looking for a compound-if of the
form "if (x) return true; return false;" when the if is nested under one
of these labelling constructs.

Enhance the matchers to look for these nested statements using some
private matcher hasSubstatement() traversal matcher on case, default
and label statements.  Add the private matcher hasSubstatementSequence()
to match the compound "if (x) return true; return false;" pattern.

- Add unit tests for private matchers and corresponding test
  infrastructure
- Add corresponding test file readability-simplify-bool-expr-case.cpp.
- Fix variable name copy/paste error in readability-simplify-bool-expr.cpp.
- Drop the asserts, which were used only for debugging matchers.
- Run clang-format on the whole check.
- Move local functions out of anonymous namespace and declare state, per
  LLVM style guide
- Declare labels constexpr
- Declare visitor arguments as pointer to const
- Drop braces around simple control statements per LLVM style guide
- Prefer explicit arguments over default arguments to methods

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

Fixes #27078

Added: 
clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprMatchers.h

clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-case.cpp

Modified: 
clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h

clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
index 4ea8ef65d3f8d..9c2ddf139a128 100644
--- a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -7,10 +7,10 @@
 
//===--===//
 
 #include "SimplifyBooleanExprCheck.h"
+#include "SimplifyBooleanExprMatchers.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Lex/Lexer.h"
 
-#include 
 #include 
 #include 
 
@@ -33,33 +33,44 @@ StringRef getText(const MatchFinder::MatchResult , T 
) {
   return getText(Result, Node.getSourceRange());
 }
 
-const char ConditionThenStmtId[] = "if-bool-yields-then";
-const char ConditionElseStmtId[] = "if-bool-yields-else";
-const char TernaryId[] = "ternary-bool-yields-condition";
-const char TernaryNegatedId[] = "ternary-bool-yields-not-condition";
-const char IfReturnsBoolId[] = "if-return";
-const char IfReturnsNotBoolId[] = "if-not-return";
-const char ThenLiteralId[] = "then-literal";
-const char IfAssignVariableId[] = "if-assign-lvalue";
-const char IfAssignLocId[] = "if-assign-loc";
-const char IfAssignBoolId[] = "if-assign";
-const char IfAssignNotBoolId[] = "if-assign-not";
-const char IfAssignVarId[] = "if-assign-var";
-const char CompoundReturnId[] = "compound-return";
-const char CompoundBoolId[] = "compound-bool";
-const char CompoundNotBoolId[] = "compound-bool-not";
-
-const char IfStmtId[] = "if";
-
-const char SimplifyOperatorDiagnostic[] =
+} // namespace
+
+static constexpr char ConditionThenStmtId[] = "if-bool-yields-then";
+static constexpr char ConditionElseStmtId[] = "if-bool-yields-else";
+static constexpr char TernaryId[] = "ternary-bool-yields-condition";
+static constexpr char TernaryNegatedId[] = "ternary-bool-yields-not-condition";
+static constexpr char IfReturnsBoolId[] = "if-return";
+static constexpr char IfReturnsNotBoolId[] = "if-not-return";
+static constexpr char ThenLiteralId[] = "then-literal";
+static constexpr char IfAssignVariableId[] = "if-assign-lvalue";
+static constexpr char IfAssignLocId[] = "if-assign-loc";
+static constexpr char IfAssignBoolId[] = "if-assign";
+static constexpr char IfAssignNotBoolId[] = "if-assign-not";
+static constexpr char IfAssignVarId[] = "if-assign-var";
+static constexpr char CompoundReturnId[] = "compound-return";
+static constexpr char CompoundIfId[] = "compound-if";
+static constexpr char CompoundBoolId[] = "compound-bool";
+static constexpr char CompoundNotBoolId[] = "compound-bool-not";
+static 

[PATCH] D56303: [clang-tidy] Recognize labelled statements when simplifying boolean exprs

2022-01-28 Thread Richard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG99217fa8a027: [clang-tidy] Recognize labelled statements 
when simplifying boolean exprs (authored by LegalizeAdulthood).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56303

Files:
  clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h
  clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprMatchers.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-case.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp
@@ -1,6 +1,9 @@
+#include "../../clang/unittests/ASTMatchers/ASTMatchersTest.h"
 #include "ClangTidyTest.h"
 #include "readability/BracesAroundStatementsCheck.h"
 #include "readability/NamespaceCommentCheck.h"
+#include "readability/SimplifyBooleanExprMatchers.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -9,6 +12,123 @@
 
 using readability::BracesAroundStatementsCheck;
 using readability::NamespaceCommentCheck;
+using namespace ast_matchers;
+
+TEST_P(ASTMatchersTest, HasCaseSubstatement) {
+  EXPECT_TRUE(matches(
+  "void f() { switch (1) { case 1: return; break; default: break; } }",
+  traverse(TK_AsIs, caseStmt(hasSubstatement(returnStmt());
+}
+
+TEST_P(ASTMatchersTest, HasDefaultSubstatement) {
+  EXPECT_TRUE(matches(
+  "void f() { switch (1) { case 1: return; break; default: break; } }",
+  traverse(TK_AsIs, defaultStmt(hasSubstatement(breakStmt());
+}
+
+TEST_P(ASTMatchersTest, HasLabelSubstatement) {
+  EXPECT_TRUE(
+  matches("void f() { while (1) { bar: break; foo: return; } }",
+  traverse(TK_AsIs, labelStmt(hasSubstatement(breakStmt());
+}
+
+TEST_P(ASTMatchersTest, HasSubstatementSequenceSimple) {
+  const char *Text = "int f() { int x = 5; if (x < 0) return 1; return 0; }";
+  EXPECT_TRUE(matches(
+  Text, compoundStmt(hasSubstatementSequence(ifStmt(), returnStmt();
+  EXPECT_FALSE(matches(
+  Text, compoundStmt(hasSubstatementSequence(ifStmt(), labelStmt();
+  EXPECT_FALSE(matches(
+  Text, compoundStmt(hasSubstatementSequence(returnStmt(), ifStmt();
+  EXPECT_FALSE(matches(
+  Text, compoundStmt(hasSubstatementSequence(switchStmt(), labelStmt();
+}
+
+TEST_P(ASTMatchersTest, HasSubstatementSequenceAlmost) {
+  const char *Text = R"code(
+int f() {
+  int x = 5;
+  if (x < 10)
+;
+  if (x < 0)
+return 1;
+  return 0;
+}
+)code";
+  EXPECT_TRUE(matches(
+  Text, compoundStmt(hasSubstatementSequence(ifStmt(), returnStmt();
+  EXPECT_TRUE(
+  matches(Text, compoundStmt(hasSubstatementSequence(ifStmt(), ifStmt();
+}
+
+TEST_P(ASTMatchersTest, HasSubstatementSequenceComplex) {
+  const char *Text = R"code(
+int f() {
+  int x = 5;
+  if (x < 10)
+x -= 10;
+  if (x < 0)
+return 1;
+  return 0;
+}
+)code";
+  EXPECT_TRUE(matches(
+  Text, compoundStmt(hasSubstatementSequence(ifStmt(), returnStmt();
+  EXPECT_FALSE(
+  matches(Text, compoundStmt(hasSubstatementSequence(ifStmt(), expr();
+}
+
+TEST_P(ASTMatchersTest, HasSubstatementSequenceExpression) {
+  const char *Text = R"code(
+int f() {
+  return ({ int x = 5;
+  int result;
+  if (x < 10)
+x -= 10;
+  if (x < 0)
+result = 1;
+  else
+result = 0;
+  result;
+});
+  }
+)code";
+  EXPECT_TRUE(
+  matches(Text, stmtExpr(hasSubstatementSequence(ifStmt(), expr();
+  EXPECT_FALSE(
+  matches(Text, stmtExpr(hasSubstatementSequence(ifStmt(), returnStmt();
+}
+
+// Copied from ASTMatchersTests
+static std::vector allTestClangConfigs() {
+  std::vector all_configs;
+  for (TestLanguage lang : {Lang_C89, Lang_C99, Lang_CXX03, Lang_CXX11,
+Lang_CXX14, Lang_CXX17, Lang_CXX20}) {
+TestClangConfig config;
+config.Language = lang;
+
+// Use an unknown-unknown triple so we don't instantiate the full system
+// toolchain.  On Linux, instantiating the toolchain involves stat'ing
+// large portions of /usr/lib, and this slows down not only this test, but
+// all other tests, via contention in the kernel.
+//
+// FIXME: This is a hack to work around the fact that there's no way to do
+// the equivalent of runToolOnCodeWithArgs without instantiating a full
+// Driver.  We should consider having a function, at least for tests, that
+

[PATCH] D117238: [C2x] Add BITINT_MAXWIDTH support

2022-01-28 Thread Shubham Sandeep Rastogi via Phabricator via cfe-commits
rastogishubham added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:2271-2274
+  const TargetInfo  = getASTContext().getTargetInfo();
+  if (NumBits > TI.getMaxBitIntWidth()) {
 Diag(Loc, diag::err_bit_int_max_size)
+<< IsUnsigned << TI.getMaxBitIntWidth();

Seems like this change broke the greendragon

https://green.lab.llvm.org/green/job/lldb-cmake/40733/console

Can you please take a look and either fix or revert your change?


Error message:

/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 error: use of overloaded operator '<<' is ambiguous (with operand types 'const 
clang::StreamingDiagnostic' and 'typename remove_reference::type' (aka 'unsigned long'))
DB << std::move(V);
~~ ^  
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Sema/Sema.h:1686:16:
 note: in instantiation of function template specialization 
'clang::DiagnosticBuilder::operator<<' requested here
  BaseDiag << std::move(V);
   ^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Sema/Sema.h:1760:24:
 note: in instantiation of function template specialization 
'clang::Sema::ImmediateDiagBuilder::operator<<' requested 
here
*ImmediateDiag << std::move(V);
   ^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Sema/SemaType.cpp:2274:23:
 note: in instantiation of function template specialization 
'clang::Sema::SemaDiagnosticBuilder::operator<<' requested 
here
<< IsUnsigned << TI.getMaxBitIntWidth();
  ^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1399:35:
 note: candidate function
inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
  ^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1405:35:
 note: candidate function
inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
  ^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1421:35:
 note: candidate function
inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
  ^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1427:35:
 note: candidate function
inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
  ^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(int, unsigned long)
DB << std::move(V);
   ^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(int, int)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(int, long)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(int, long long)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(int, __int128)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(int, unsigned int)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(int, unsigned long long)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(int, unsigned __int128)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(long, unsigned long)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(long long, unsigned long)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(__int128, unsigned long)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(unsigned int, unsigned long)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(unsigned long, unsigned long)
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 note: built-in candidate operator<<(unsigned long long, unsigned long)

[PATCH] D117238: [C2x] Add BITINT_MAXWIDTH support

2022-01-28 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

@aaron.ballman I believe this change broke the build starting with:

https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/26915/

  
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/clang/include/clang/Basic/Diagnostic.h:1352:8:
 error: use of overloaded operator '<<' is ambiguous (with operand types 'const 
clang::StreamingDiagnostic' and 'typename remove_reference::type' (aka 'unsigned long'))
  ...
  
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/clang/lib/Sema/SemaType.cpp:2274:23:
 note: in instantiation of function template specialization 
'clang::Sema::SemaDiagnosticBuilder::operator<<' requested 
here
  << IsUnsigned << TI.getMaxBitIntWidth();


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

https://reviews.llvm.org/D117238

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


[PATCH] D118313: [Driver] Remove -fno-experimental-new-pass-manager

2022-01-28 Thread Fangrui Song 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 rG5fc1261ef375: [Driver] Remove 
-fno-experimental-new-pass-manager (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118313

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/test/Driver/flegacy-pass-manager.c
  clang/test/Frontend/optimization-remark-with-hotness.c

Index: clang/test/Frontend/optimization-remark-with-hotness.c
===
--- clang/test/Frontend/optimization-remark-with-hotness.c
+++ /dev/null
@@ -1,78 +0,0 @@
-// Generate instrumentation and sampling profile data.
-// RUN: llvm-profdata merge \
-// RUN: %S/Inputs/optimization-remark-with-hotness.proftext \
-// RUN: -o %t.profdata
-// RUN: llvm-profdata merge -sample \
-// RUN: %S/Inputs/optimization-remark-with-hotness-sample.proftext \
-// RUN: -o %t-sample.profdata
-//
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -verify
-// The clang version of the previous test.
-// RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
-// RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -Xclang -verify
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
-// RUN: -verify
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 -verify
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \
-// RUN: -check-prefix=HOTNESS_OFF %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness \
-// RUN: -fdiagnostics-hotness-threshold=100 2>&1 \
-// RUN: | FileCheck -allow-empty -check-prefix=THRESHOLD %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -Rpass=inline -Rpass-analysis=inline \
-// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 2>&1 \
-// RUN: | FileCheck -check-prefix=NO_PGO %s
-
-int foo(int x, int y) __attribute__((always_inline));
-int foo(int x, int y) { return x + y; }
-
-int sum = 0;
-
-void bar(int x) {
-  // HOTNESS_OFF: 'foo' inlined into 'bar'
-  // HOTNESS_OFF-NOT: hotness:
-  // THRESHOLD-NOT: inlined
-  // THRESHOLD-NOT: hotness
-  // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information
-  // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information
-  // expected-remark@+1 {{'foo' inlined into 'bar' with (cost=always): always inliner at callsite bar:8:10; (hotness:}}
-  sum += foo(x, x - 2);
-}
-
-int main(int argc, const char *argv[]) {
-  for (int i = 0; i < 30; i++)
-// expected-remark@+1 {{'bar' not inlined into 'main' because it should never be inlined (cost=never): no alwaysinline attribute (hotness:}}
-bar(argc);
-  return sum;
-}
Index: clang/test/Driver/flegacy-pass-manager.c

[clang] 5fc1261 - [Driver] Remove -fno-experimental-new-pass-manager

2022-01-28 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-01-28T14:58:26-08:00
New Revision: 5fc1261ef37549484e9eb9edc90477d713d8223f

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

LOG: [Driver] Remove -fno-experimental-new-pass-manager

to give users a final warning that they need to migrate away. They could still
use -flegacy-pass-manager for Clang 14.0.0, but the functionality may not work
for 15.0.0.

-fexperimental-new-pass-manager is a no-op for default builds, so not urgent to
be removed for 14.0.0.

clang/test/Frontend/optimization-remark-with-hotness.c is removed because its
new PM replacement optimization-remark-with-hotness-new-pm.c exists.

Reviewed By: aeubanks, nikic

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/test/Driver/flegacy-pass-manager.c

Removed: 
clang/test/Frontend/optimization-remark-with-hotness.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index aa54be1efe1c5..4b444bece68a7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -107,7 +107,10 @@ Modified Compiler Flags
 Removed Compiler Flags
 -
 
-- ...
+- ``-fno-experimental-new-pass-manager`` has been removed.
+  ``-flegacy-pass-manager`` can be used as a makeshift,
+  Using the legacy pass manager for the optimization pipeline was deprecated in
+  13.0.0 and will be removed after 14.0.0.
 
 New Pragmas in Clang
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 52f05f392db2c..d3b309dfd5441 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1906,7 +1906,7 @@ defm legacy_pass_manager : BoolOption<"f", 
"legacy-pass-manager",
 def fexperimental_new_pass_manager : Flag<["-"], 
"fexperimental-new-pass-manager">,
   Group, Flags<[CC1Option]>, Alias;
 def fno_experimental_new_pass_manager : Flag<["-"], 
"fno-experimental-new-pass-manager">,
-  Group, Flags<[CC1Option]>, Alias;
+  Group, Flags<[CC1Option,NoDriverOption]>, 
Alias;
 def fexperimental_strict_floating_point : Flag<["-"], 
"fexperimental-strict-floating-point">,
   Group, Flags<[CC1Option]>,
   HelpText<"Enables experimental strict floating point in LLVM.">,

diff  --git a/clang/test/Driver/flegacy-pass-manager.c 
b/clang/test/Driver/flegacy-pass-manager.c
index 8ce2647ebc1df..2e45b5f6a1d07 100644
--- a/clang/test/Driver/flegacy-pass-manager.c
+++ b/clang/test/Driver/flegacy-pass-manager.c
@@ -1,9 +1,9 @@
 // RUN: %clang -### -c -flegacy-pass-manager -fno-legacy-pass-manager %s 2>&1 
| FileCheck --check-prefixes=NOWARN,NEW %s
 // RUN: %clang -### -c -fno-legacy-pass-manager -flegacy-pass-manager %s 2>&1 
| FileCheck --check-prefixes=NOWARN,LEGACY %s
 
-/// -f[no-]experimental-new-pass-manager are legacy aliases when the new PM 
was still experimental.
-// RUN: %clang -### -c -fno-experimental-new-pass-manager 
-fexperimental-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=NOWARN,NEW 
%s
-// RUN: %clang -### -c -fexperimental-new-pass-manager 
-fno-experimental-new-pass-manager %s 2>&1 | FileCheck 
--check-prefixes=NOWARN,LEGACY %s
+/// -fexperimental-new-pass-manager is a legacy alias. 
-fno-experimental-new-pass-manager has been removed.
+// RUN: %clang -### -c -fexperimental-new-pass-manager %s 2>&1 | FileCheck 
--check-prefixes=NOWARN,NEW %s
+// RUN: not %clang -### -fno-experimental-new-pass-manager %s
 
 // NOWARN-NOT: warning: argument unused
 
@@ -20,7 +20,6 @@
 // LTO_NEW:"-plugin-opt=new-pass-manager"
 
 // RUN: %clang -### -target x86_64-linux -flto -flegacy-pass-manager %s 2>&1 | 
FileCheck --check-prefix=LTO_LEGACY %s
-// RUN: %clang -### -target x86_64-linux -flto=thin 
-fno-experimental-new-pass-manager %s 2>&1 | FileCheck 
--check-prefix=LTO_LEGACY %s
 
 // LTO_LEGACY: "-plugin-opt=legacy-pass-manager"
 

diff  --git a/clang/test/Frontend/optimization-remark-with-hotness.c 
b/clang/test/Frontend/optimization-remark-with-hotness.c
deleted file mode 100644
index 43007b3f23303..0
--- a/clang/test/Frontend/optimization-remark-with-hotness.c
+++ /dev/null
@@ -1,78 +0,0 @@
-// Generate instrumentation and sampling profile data.
-// RUN: llvm-profdata merge \
-// RUN: %S/Inputs/optimization-remark-with-hotness.proftext \
-// RUN: -o %t.profdata
-// RUN: llvm-profdata merge -sample \
-// RUN: %S/Inputs/optimization-remark-with-hotness-sample.proftext \
-// RUN: -o %t-sample.profdata
-//
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: 

[PATCH] D117137: [Driver] Add CUDA support for --offload param

2022-01-28 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

Pushed for Daniele:

  To github.com:llvm/llvm-project.git
 99d2582164c4..6eb826567af0  main -> main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117137

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


[PATCH] D117137: [Driver] Add CUDA support for --offload param

2022-01-28 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6eb826567af0: [Driver] Add CUDA support for --offload param 
(authored by dcastagna, committed by jlebar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117137

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/cuda-device-triple.cu
  clang/test/Driver/invalid-offload-options.cpp

Index: clang/test/Driver/invalid-offload-options.cpp
===
--- clang/test/Driver/invalid-offload-options.cpp
+++ clang/test/Driver/invalid-offload-options.cpp
@@ -9,7 +9,7 @@
 // RUN:   --hip-path=%S/Inputs/hipspv -nogpuinc -nogpulib %s \
 // RUN: 2>&1 | FileCheck --check-prefix=INVALID-TARGET %s
 
-// INVALID-TARGET: error: Invalid or unsupported offload target: '{{.*}}'
+// INVALID-TARGET: error: invalid or unsupported offload target: '{{.*}}'
 
 // In the future we should be able to specify multiple targets for HIP
 // compilation but currently it is not supported.
@@ -22,7 +22,7 @@
 // RUN:   --hip-path=%S/Inputs/hipspv -nogpuinc -nogpulib %s \
 // RUN: 2>&1 | FileCheck --check-prefix=TOO-MANY-TARGETS %s
 
-// TOO-MANY-TARGETS: error: Only one offload target is supported in HIP.
+// TOO-MANY-TARGETS: error: only one offload target is supported
 
 // RUN: %clang -### -x hip -target x86_64-linux-gnu -nogpuinc -nogpulib \
 // RUN:   --offload=amdgcn-amd-amdhsa --offload-arch=gfx900 %s \
Index: clang/test/Driver/cuda-device-triple.cu
===
--- /dev/null
+++ clang/test/Driver/cuda-device-triple.cu
@@ -0,0 +1,6 @@
+// REQUIRES: clang-driver
+
+// RUN: %clang -### -emit-llvm --cuda-device-only \
+// RUN:   -nocudalib -nocudainc --offload=spirv32-unknown-unknown -c %s 2>&1 | FileCheck %s
+
+// CHECK: clang{{.*}}" "-cc1" "-triple" "spirv32-unknown-unknown" {{.*}} "-fcuda-is-device" {{.*}}
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -103,39 +103,58 @@
 using namespace llvm::opt;
 
 static llvm::Optional
-getHIPOffloadTargetTriple(const Driver , const ArgList ) {
-  if (Args.hasArg(options::OPT_offload_EQ)) {
-auto HIPOffloadTargets = Args.getAllArgValues(options::OPT_offload_EQ);
+getOffloadTargetTriple(const Driver , const ArgList ) {
+  auto OffloadTargets = Args.getAllArgValues(options::OPT_offload_EQ);
+  // Offload compilation flow does not support multiple targets for now. We
+  // need the HIPActionBuilder (and possibly the CudaActionBuilder{,Base}too)
+  // to support multiple tool chains first.
+  switch (OffloadTargets.size()) {
+  default:
+D.Diag(diag::err_drv_only_one_offload_target_supported);
+return llvm::None;
+  case 0:
+D.Diag(diag::err_drv_invalid_or_unsupported_offload_target) << "";
+return llvm::None;
+  case 1:
+break;
+  }
+  return llvm::Triple(OffloadTargets[0]);
+}
 
-// HIP compilation flow does not support multiple targets for now. We need
-// the HIPActionBuilder (and possibly the CudaActionBuilder{,Base}too) to
-// support multiple tool chains first.
-switch (HIPOffloadTargets.size()) {
-default:
-  D.Diag(diag::err_drv_only_one_offload_target_supported_in) << "HIP";
-  return llvm::None;
-case 0:
-  D.Diag(diag::err_drv_invalid_or_unsupported_offload_target) << "";
-  return llvm::None;
-case 1:
-  break;
-}
-llvm::Triple TT(HIPOffloadTargets[0]);
-if (TT.getArch() == llvm::Triple::amdgcn &&
-TT.getVendor() == llvm::Triple::AMD &&
-TT.getOS() == llvm::Triple::AMDHSA)
-  return TT;
-if (TT.getArch() == llvm::Triple::spirv64 &&
-TT.getVendor() == llvm::Triple::UnknownVendor &&
-TT.getOS() == llvm::Triple::UnknownOS)
+static llvm::Optional
+getNVIDIAOffloadTargetTriple(const Driver , const ArgList ,
+ const llvm::Triple ) {
+  if (!Args.hasArg(options::OPT_offload_EQ)) {
+return llvm::Triple(HostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda"
+ : "nvptx-nvidia-cuda");
+  }
+  auto TT = getOffloadTargetTriple(D, Args);
+  if (TT && (TT->getArch() == llvm::Triple::spirv32 ||
+ TT->getArch() == llvm::Triple::spirv64)) {
+if (Args.hasArg(options::OPT_emit_llvm))
   return TT;
-D.Diag(diag::err_drv_invalid_or_unsupported_offload_target)
-<< HIPOffloadTargets[0];
+D.Diag(diag::err_drv_cuda_offload_only_emit_bc);
 return llvm::None;
   }
-
-  static const llvm::Triple T("amdgcn-amd-amdhsa"); // Default HIP triple.
-  return T;
+  D.Diag(diag::err_drv_invalid_or_unsupported_offload_target) << TT->str();
+  return llvm::None;
+}
+static llvm::Optional

[clang] 6eb8265 - [Driver] Add CUDA support for --offload param

2022-01-28 Thread Justin Lebar via cfe-commits

Author: Daniele Castagna
Date: 2022-01-28T14:50:39-08:00
New Revision: 6eb826567af03c2b43cda78836b1065e12df84e4

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

LOG: [Driver] Add CUDA support for --offload param

The --offload option was added in D110622 to "override the default
device target". When it landed it supported only HIP.  This patch
extends that option to support SPIR-V targets for CUDA.

Reviewed By: tra

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

Added: 
clang/test/Driver/cuda-device-triple.cu

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/invalid-offload-options.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index e635be6b6d1bc..3efedbe0f6428 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -627,8 +627,10 @@ def err_cc1_unbounded_vscale_min : Error<
 def err_drv_ssp_missing_offset_argument : Error<
   "'%0' is used without '-mstack-protector-guard-offset', and there is no 
default">;
 
-def err_drv_only_one_offload_target_supported_in : Error<
-  "Only one offload target is supported in %0.">;
+def err_drv_only_one_offload_target_supported : Error<
+  "only one offload target is supported">;
 def err_drv_invalid_or_unsupported_offload_target : Error<
-  "Invalid or unsupported offload target: '%0'.">;
+  "invalid or unsupported offload target: '%0'">;
+def err_drv_cuda_offload_only_emit_bc : Error<
+  "CUDA offload target is supported only along with --emit-llvm">;
 }

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index fbdac93a8313d..52f05f392db2c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1143,8 +1143,7 @@ defm autolink : BoolFOption<"autolink",
 // languages and accept other values such as CPU/GPU architectures,
 // offload kinds and target aliases.
 def offload_EQ : CommaJoined<["--"], "offload=">, Flags<[NoXarchOption]>,
-  HelpText<"Specify comma-separated list of offloading target triples"
-   " (HIP only)">;
+  HelpText<"Specify comma-separated list of offloading target triples (CUDA 
and HIP only)">;
 
 // C++ Coroutines TS
 defm coroutines_ts : BoolFOption<"coroutines-ts",

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 2e4ebc10e9ba3..61c2289f83e9c 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -103,39 +103,58 @@ using namespace clang;
 using namespace llvm::opt;
 
 static llvm::Optional
-getHIPOffloadTargetTriple(const Driver , const ArgList ) {
-  if (Args.hasArg(options::OPT_offload_EQ)) {
-auto HIPOffloadTargets = Args.getAllArgValues(options::OPT_offload_EQ);
+getOffloadTargetTriple(const Driver , const ArgList ) {
+  auto OffloadTargets = Args.getAllArgValues(options::OPT_offload_EQ);
+  // Offload compilation flow does not support multiple targets for now. We
+  // need the HIPActionBuilder (and possibly the CudaActionBuilder{,Base}too)
+  // to support multiple tool chains first.
+  switch (OffloadTargets.size()) {
+  default:
+D.Diag(diag::err_drv_only_one_offload_target_supported);
+return llvm::None;
+  case 0:
+D.Diag(diag::err_drv_invalid_or_unsupported_offload_target) << "";
+return llvm::None;
+  case 1:
+break;
+  }
+  return llvm::Triple(OffloadTargets[0]);
+}
 
-// HIP compilation flow does not support multiple targets for now. We need
-// the HIPActionBuilder (and possibly the CudaActionBuilder{,Base}too) to
-// support multiple tool chains first.
-switch (HIPOffloadTargets.size()) {
-default:
-  D.Diag(diag::err_drv_only_one_offload_target_supported_in) << "HIP";
-  return llvm::None;
-case 0:
-  D.Diag(diag::err_drv_invalid_or_unsupported_offload_target) << "";
-  return llvm::None;
-case 1:
-  break;
-}
-llvm::Triple TT(HIPOffloadTargets[0]);
-if (TT.getArch() == llvm::Triple::amdgcn &&
-TT.getVendor() == llvm::Triple::AMD &&
-TT.getOS() == llvm::Triple::AMDHSA)
-  return TT;
-if (TT.getArch() == llvm::Triple::spirv64 &&
-TT.getVendor() == llvm::Triple::UnknownVendor &&
-TT.getOS() == llvm::Triple::UnknownOS)
+static llvm::Optional
+getNVIDIAOffloadTargetTriple(const Driver , const ArgList ,
+ const llvm::Triple ) {
+  if (!Args.hasArg(options::OPT_offload_EQ)) {
+return llvm::Triple(HostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda"
+ : "nvptx-nvidia-cuda");
+  }
+  auto TT = 

[PATCH] D114483: [SYCL] Add support for sycl_special_class attribute

2022-01-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay closed this revision.
MaskRay added a comment.

Closed by 8ba9c794feb30cd969b9776c39873def10c51bff 
.

If the commit message contained `Differential Revision:`, the differential 
would be closely automatically when you pushed it to the git repo.
Please ensure the tag is contained next time.

`clang/include/clang/Basic/AttrDocs.td` had some formatting issues and caused 
(`-DLLVM_ENABLE_SPHINX=ON`) `ninja docs-clang-html` to fail.
I fixed it. Please test this build target for new additions.


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

https://reviews.llvm.org/D114483

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


[clang] 354ec4a - [AttrDocs] Fix docs for the sycl_special_class attribute after D114483

2022-01-28 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-01-28T14:30:49-08:00
New Revision: 354ec4af749ccd910a1cffc5e9cce2bb93239b9b

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

LOG: [AttrDocs] Fix docs for the sycl_special_class attribute after D114483

Fixes `AttributeReference.rst:6628:Explicit markup ends without a blank line; 
unexpected unindent.`
for `ninja docs-clang-html`

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 18fac924b114..67a69bc9fd59 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -434,43 +434,43 @@ The syntax of the attribute is as follows:
 
 .. code-block:: c++
 
-   class __attribute__((sycl_special_class)) accessor {};
-   class [[clang::sycl_special_class]] accessor {};
+  class __attribute__((sycl_special_class)) accessor {};
+  class [[clang::sycl_special_class]] accessor {};
 
 This is a code example that illustrates the use of the attribute:
 
 .. code-block:: c++
 
-   class __attribute__((sycl_special_class)) SpecialType {
-   int F1;
-   int F2;
-   void __init(int f1) {
- F1 = f1;
- F2 = f1;
-   }
-   void __finalize() {}
-   public:
- SpecialType() = default;
- int getF2() const { return F2; }
-   };
-
-   int main () {
-   SpecialType T;
-   cgh.single_task([=] {
- T.getF2();
-   });
-}
+  class __attribute__((sycl_special_class)) SpecialType {
+int F1;
+int F2;
+void __init(int f1) {
+  F1 = f1;
+  F2 = f1;
+}
+void __finalize() {}
+  public:
+SpecialType() = default;
+int getF2() const { return F2; }
+  };
+
+  int main () {
+SpecialType T;
+cgh.single_task([=] {
+  T.getF2();
+});
+  }
 
 This would trigger the following kernel entry point in the AST:
 
 .. code-block:: c++
 
-   void __sycl_kernel(int f1) {
-   SpecialType T;
-   T.__init(f1);
-   ...
-   T.__finalize()
- }
+  void __sycl_kernel(int f1) {
+SpecialType T;
+T.__init(f1);
+...
+T.__finalize()
+  }
   }];
 }
 



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


[PATCH] D117616: GCC ABI Compatibility: Preserve alignment of non-pod members in packed structs

2022-01-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1895
+ Target.isPS4() || Target.isOSDarwin())) ||
+ D->hasAttr();
 

dblaikie wrote:
> rsmith wrote:
> > Would it make sense to warn here if `Packed && !FieldPacked`, like GCC does?
> Probably? Happy to implement that in a follow-up.
Warning sent for review here: https://reviews.llvm.org/D118511


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117616

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


[PATCH] D118511: Add a warning for not packing non-POD members in packed structs

2022-01-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie created this revision.
dblaikie added a reviewer: rsmith.
dblaikie requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118511

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/CodeGenCXX/warn-padded-packed.cpp


Index: clang/test/CodeGenCXX/warn-padded-packed.cpp
===
--- clang/test/CodeGenCXX/warn-padded-packed.cpp
+++ clang/test/CodeGenCXX/warn-padded-packed.cpp
@@ -146,8 +146,18 @@
   unsigned char b : 8;
 } __attribute__((packed));
 
+struct S28_non_pod {
+ protected:
+  int i;
+};
+struct S28 {
+  char c1;
+  short s1;
+  char c2;
+  S28_non_pod p1; // expected-warning {{not packing field 'p1' as it is 
non-POD}}
+} __attribute__((packed));
 
 // The warnings are emitted when the layout of the structs is computed, so we 
have to use them.
 void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*,
S14*, S15*, S16*, S17*, S18*, S19*, S20*, S21*, S22*, S23*, S24*, S25*,
-   S26*, S27*){}
+   S26*, S27*, S28*){}
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1888,11 +1888,17 @@
   LastBitfieldStorageUnitSize = 0;
 
   llvm::Triple Target = Context.getTargetInfo().getTriple();
-  bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
- Context.getLangOpts().getClangABICompat() <=
- LangOptions::ClangABI::Ver13 ||
- Target.isPS4() || Target.isOSDarwin())) ||
- D->hasAttr();
+  bool FieldPacked = Packed;
+  if (FieldPacked && FieldClass && !FieldClass->isPOD() &&
+  Context.getLangOpts().getClangABICompat() >
+  LangOptions::ClangABI::Ver13 &&
+  !Target.isPS4() && !Target.isOSDarwin()) {
+Diag(D->getLocation(), diag::warn_unpacked_field) << D;
+FieldPacked = false;
+  }
+
+  if (!FieldPacked && D->hasAttr())
+FieldPacked = true;
 
   AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;
Index: clang/include/clang/Basic/DiagnosticASTKinds.td
===
--- clang/include/clang/Basic/DiagnosticASTKinds.td
+++ clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -590,6 +590,8 @@
   InGroup, DefaultIgnore;
 def warn_unnecessary_packed : Warning<
   "packed attribute is unnecessary for %0">, InGroup, DefaultIgnore;
+def warn_unpacked_field : Warning<
+  "not packing field %0 as it is non-POD">, InGroup, DefaultIgnore;
 
 // -Wunaligned-access
 def warn_unaligned_access : Warning<


Index: clang/test/CodeGenCXX/warn-padded-packed.cpp
===
--- clang/test/CodeGenCXX/warn-padded-packed.cpp
+++ clang/test/CodeGenCXX/warn-padded-packed.cpp
@@ -146,8 +146,18 @@
   unsigned char b : 8;
 } __attribute__((packed));
 
+struct S28_non_pod {
+ protected:
+  int i;
+};
+struct S28 {
+  char c1;
+  short s1;
+  char c2;
+  S28_non_pod p1; // expected-warning {{not packing field 'p1' as it is non-POD}}
+} __attribute__((packed));
 
 // The warnings are emitted when the layout of the structs is computed, so we have to use them.
 void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*,
S14*, S15*, S16*, S17*, S18*, S19*, S20*, S21*, S22*, S23*, S24*, S25*,
-   S26*, S27*){}
+   S26*, S27*, S28*){}
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1888,11 +1888,17 @@
   LastBitfieldStorageUnitSize = 0;
 
   llvm::Triple Target = Context.getTargetInfo().getTriple();
-  bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
- Context.getLangOpts().getClangABICompat() <=
- LangOptions::ClangABI::Ver13 ||
- Target.isPS4() || Target.isOSDarwin())) ||
- D->hasAttr();
+  bool FieldPacked = Packed;
+  if (FieldPacked && FieldClass && !FieldClass->isPOD() &&
+  Context.getLangOpts().getClangABICompat() >
+  LangOptions::ClangABI::Ver13 &&
+  !Target.isPS4() && !Target.isOSDarwin()) {
+Diag(D->getLocation(), diag::warn_unpacked_field) << D;
+FieldPacked = false;
+  }
+
+  if (!FieldPacked && D->hasAttr())
+FieldPacked = true;
 
   AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;
Index: clang/include/clang/Basic/DiagnosticASTKinds.td
===
--- 

[PATCH] D118313: [Driver] Remove -fno-experimental-new-pass-manager

2022-01-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 404164.
MaskRay added a comment.

Mention -flegacy-pass-manager as a makeshift for 14.0.0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118313

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/test/Driver/flegacy-pass-manager.c
  clang/test/Frontend/optimization-remark-with-hotness.c

Index: clang/test/Frontend/optimization-remark-with-hotness.c
===
--- clang/test/Frontend/optimization-remark-with-hotness.c
+++ /dev/null
@@ -1,78 +0,0 @@
-// Generate instrumentation and sampling profile data.
-// RUN: llvm-profdata merge \
-// RUN: %S/Inputs/optimization-remark-with-hotness.proftext \
-// RUN: -o %t.profdata
-// RUN: llvm-profdata merge -sample \
-// RUN: %S/Inputs/optimization-remark-with-hotness-sample.proftext \
-// RUN: -o %t-sample.profdata
-//
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -verify
-// The clang version of the previous test.
-// RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
-// RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -Xclang -verify
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
-// RUN: -verify
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 -verify
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \
-// RUN: -check-prefix=HOTNESS_OFF %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness \
-// RUN: -fdiagnostics-hotness-threshold=100 2>&1 \
-// RUN: | FileCheck -allow-empty -check-prefix=THRESHOLD %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -Rpass=inline -Rpass-analysis=inline \
-// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 2>&1 \
-// RUN: | FileCheck -check-prefix=NO_PGO %s
-
-int foo(int x, int y) __attribute__((always_inline));
-int foo(int x, int y) { return x + y; }
-
-int sum = 0;
-
-void bar(int x) {
-  // HOTNESS_OFF: 'foo' inlined into 'bar'
-  // HOTNESS_OFF-NOT: hotness:
-  // THRESHOLD-NOT: inlined
-  // THRESHOLD-NOT: hotness
-  // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information
-  // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information
-  // expected-remark@+1 {{'foo' inlined into 'bar' with (cost=always): always inliner at callsite bar:8:10; (hotness:}}
-  sum += foo(x, x - 2);
-}
-
-int main(int argc, const char *argv[]) {
-  for (int i = 0; i < 30; i++)
-// expected-remark@+1 {{'bar' not inlined into 'main' because it should never be inlined (cost=never): no alwaysinline attribute (hotness:}}
-bar(argc);
-  return sum;
-}
Index: clang/test/Driver/flegacy-pass-manager.c
===
--- 

[PATCH] D118313: [Driver] Remove -fno-experimental-new-pass-manager

2022-01-28 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:112
+  pass manager for the optimization pipeline was deprecated in 13.0.0 and will
+  be removed after 14.0.0.
 

Would be good to mention `-flegacy-pass-manager` as the alternative here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118313

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


[PATCH] D118313: [Driver] Remove -fno-experimental-new-pass-manager

2022-01-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 404163.
MaskRay added a comment.

Add -fno-experimental-new-pass-manager to `Removed Compiler Flags` in release 
notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118313

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/test/Driver/flegacy-pass-manager.c
  clang/test/Frontend/optimization-remark-with-hotness.c

Index: clang/test/Frontend/optimization-remark-with-hotness.c
===
--- clang/test/Frontend/optimization-remark-with-hotness.c
+++ /dev/null
@@ -1,78 +0,0 @@
-// Generate instrumentation and sampling profile data.
-// RUN: llvm-profdata merge \
-// RUN: %S/Inputs/optimization-remark-with-hotness.proftext \
-// RUN: -o %t.profdata
-// RUN: llvm-profdata merge -sample \
-// RUN: %S/Inputs/optimization-remark-with-hotness-sample.proftext \
-// RUN: -o %t-sample.profdata
-//
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -verify
-// The clang version of the previous test.
-// RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
-// RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -Xclang -verify
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
-// RUN: -verify
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 -verify
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -fno-experimental-new-pass-manager \
-// RUN: -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \
-// RUN: -check-prefix=HOTNESS_OFF %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness \
-// RUN: -fdiagnostics-hotness-threshold=100 2>&1 \
-// RUN: | FileCheck -allow-empty -check-prefix=THRESHOLD %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -Rpass=inline -Rpass-analysis=inline \
-// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 2>&1 \
-// RUN: | FileCheck -check-prefix=NO_PGO %s
-
-int foo(int x, int y) __attribute__((always_inline));
-int foo(int x, int y) { return x + y; }
-
-int sum = 0;
-
-void bar(int x) {
-  // HOTNESS_OFF: 'foo' inlined into 'bar'
-  // HOTNESS_OFF-NOT: hotness:
-  // THRESHOLD-NOT: inlined
-  // THRESHOLD-NOT: hotness
-  // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information
-  // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information
-  // expected-remark@+1 {{'foo' inlined into 'bar' with (cost=always): always inliner at callsite bar:8:10; (hotness:}}
-  sum += foo(x, x - 2);
-}
-
-int main(int argc, const char *argv[]) {
-  for (int i = 0; i < 30; i++)
-// expected-remark@+1 {{'bar' not inlined into 'main' because it should never be inlined (cost=never): no alwaysinline attribute (hotness:}}
-bar(argc);
-  return sum;
-}
Index: clang/test/Driver/flegacy-pass-manager.c
===
--- 

[PATCH] D118495: [OpenMP] Accept shortened triples for -Xopenmp-target=

2022-01-28 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118495

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


[PATCH] D118313: [Driver] Remove -fno-experimental-new-pass-manager

2022-01-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D118313#3280822 , @aeubanks wrote:

> I think this is fine, it gives clang users another chance to report new PM 
> blockers

Yes. Thanks for accepting this before 14.0.0 branching:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118313

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


[PATCH] D118313: [Driver] Remove -fno-experimental-new-pass-manager

2022-01-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks accepted this revision.
aeubanks added a comment.
This revision is now accepted and ready to land.

I think this is fine, it gives clang users another chance to report new PM 
blockers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118313

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


[PATCH] D118297: [clang] add Diag -Wasm-volatile for implied volatile asm stmts

2022-01-28 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:31
+def warn_asm_volatile_goto : Warning<"volatile qualifier implied by goto">, 
InGroup;
+def warn_asm_volatile : Warning<"volatile qualifier implied by lack of 
outputs">, InGroup;
 }

should this go in clang/include/clang/Basic/DiagnosticSemaKinds.td instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118297

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


[PATCH] D91607: [clang][Sparc] Fix __builtin_extract_return_addr etc.

2022-01-28 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Testcase?

Do you need to ptrtoint/inttoptr?  I would expect that the address is an `i8*`, 
so you can just GEP an appropriate number of bytes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91607

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


[PATCH] D117937: [VFS] Add a "redirecting-with" field to overlays

2022-01-28 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: llvm/include/llvm/Support/VirtualFileSystem.h:575
+///   instead>
+///   'redirecting-with': 

bnbarham wrote:
> keith wrote:
> > I think `redirecting-with` is fine, and I can't come up with something 
> > better
> Thanks. Do you know if this format is documented anywhere that I would need 
> to update?
Folks here used to joke that the source was the documentation, and based on a 
quick search that still seems to be the case, I don't see any places where the 
others are mentioned


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117937

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


[PATCH] D118493: [WIP]Set rpath on openmp executables

2022-01-28 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 404156.
JonChesterfield added a comment.
Herald added a subscriber: dang.

- Now with commandline argument


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118493

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


Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -106,6 +106,9 @@
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 
+void addOpenMPRuntimeSpecificRPath(const ToolChain ,
+   const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList );
 void addArchSpecificRPath(const ToolChain , const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 /// Returns true, if an OpenMP runtime has been added.
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -645,6 +645,22 @@
  /*IsLTO=*/true);
 }
 
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain ,
+  const ArgList ,
+  ArgStringList ) {
+
+  if (Args.hasFlag(options::OPT_fopenmp_implicit_rpath,
+   options::OPT_fno_openmp_implicit_rpath, true)) {
+// Default to clang lib / lib64 folder, i.e. the same location as device
+// runtime
+SmallString<256> DefaultLibPath =
+llvm::sys::path::parent_path(TC.getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath, Twine("lib") + 
CLANG_LIBDIR_SUFFIX);
+CmdArgs.push_back("-rpath");
+CmdArgs.push_back(Args.MakeArgString(DefaultLibPath));
+  }
+}
+
 void tools::addArchSpecificRPath(const ToolChain , const ArgList ,
  ArgStringList ) {
   // Enable -frtlib-add-rpath by default for the case of VE.
@@ -697,6 +713,9 @@
   if (RTKind == Driver::OMPRT_GOMP && GompNeedsRT)
   CmdArgs.push_back("-lrt");
 
+  if (RTKind == Driver::OMPRT_OMP)
+addOpenMPRuntimeSpecificRPath(TC, Args, CmdArgs);
+
   if (IsOffloadingHost)
 CmdArgs.push_back("-lomptarget");
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3895,6 +3895,11 @@
   HelpText<"Add -rpath with architecture-specific resource directory to the 
linker flags">;
 def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, 
Flags<[NoArgumentUnused]>,
   HelpText<"Do not add -rpath with architecture-specific resource directory to 
the linker flags">;
+defm openmp_implicit_rpath: BoolFOption<"openmp-implicit-rpath",
+  LangOpts<"OpenMP">,
+  DefaultTrue,
+  PosFlag,
+  NegFlag>;
 def r : Flag<["-"], "r">, Flags<[LinkerInput,NoArgumentUnused]>,
 Group;
 def save_temps_EQ : Joined<["-", "--"], "save-temps=">, Flags<[CC1Option, 
NoXarchOption]>,


Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -106,6 +106,9 @@
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 
+void addOpenMPRuntimeSpecificRPath(const ToolChain ,
+   const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList );
 void addArchSpecificRPath(const ToolChain , const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 /// Returns true, if an OpenMP runtime has been added.
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -645,6 +645,22 @@
  /*IsLTO=*/true);
 }
 
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain ,
+  const ArgList ,
+  ArgStringList ) {
+
+  if (Args.hasFlag(options::OPT_fopenmp_implicit_rpath,
+   options::OPT_fno_openmp_implicit_rpath, true)) {
+// Default to clang lib / lib64 folder, i.e. the same location as device
+// runtime
+SmallString<256> DefaultLibPath =
+llvm::sys::path::parent_path(TC.getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
+CmdArgs.push_back("-rpath");
+

[PATCH] D117416: [clang-format] Handle C variables with name that matches c++ access specifier

2022-01-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius requested changes to this revision.
curdeius added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Format/FormatToken.h:125
 
+/// Sorted Operators that can follow a C variable.
+static const std::vector COperatorsFollowingVar = {





Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:122-129
+auto COperatorMatch = std::lower_bound(COperatorsFollowingVar.begin(),
+   COperatorsFollowingVar.end(),
+   RootToken.Next->Tok.getKind());
+if ((COperatorMatch == COperatorsFollowingVar.end() ||
+ *COperatorMatch != RootToken.Next->Tok.getKind()) &&
+!RootToken.Next->Tok.is(tok::coloncolon)) {
+  return true;

HazardyKnusperkeks wrote:
> Use `std::binary_search` instead of `std::lower_bound`. That should simplify 
> the following `if`.
Please do something along these lines. The idea is to put a cheaper check first.

Note. I haven't tested nor formatted these lines.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:905
   /// break after the "{", format all lines with correct indentation and the 
put
-  /// the closing "}" on yet another new line.
+  ///  the closing "}" on yet another new line.
   ///

Revert.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2716-2718
+  auto COperatorMatch =
+  std::lower_bound(COperatorsFollowingVar.begin(),
+   COperatorsFollowingVar.end(), FormatTok->Tok.getKind());

Please use `binary_search` and put it inside the `else` branch to avoid it if 
the first condition is satisfied.
Something like:
```
if (FormatTok->Tok.is(tok::colon)) {
...
} else if (!binary_search(...) {
} else if (...) {
}
```

Also, this code and the code in `UnwrappedLineFormatter` are pretty much 
similar.
Can we remove this duplication by e.g. setting the token kind here and checking 
it in the formatter?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117416

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


[PATCH] D118350: [Clang][Sema][AIX][PowerPC] Emit byval alignment warning only when struct member is passed to a function

2022-01-28 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:12693-12695
   void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
- StringRef ParamName, QualType ArgTy, QualType 
ParamTy);
+ StringRef ParamName, QualType ArgTy, QualType ParamTy,
+ const Expr *Arg = nullptr);

aaron.ballman wrote:
> I'm not keen on passing both `Arg` and `ArgTy` such that they can get out of 
> sync. Do all of the places calling `CheckArgAlignment()` have access to the 
> `Expr` so that we can require it be passed (and drop the `ArgTy` parameter)?
Thanks, that is something I overlooked. 

It seems like I can do this everywhere except the call from 
`Sema::CheckConstructorCall`. Trying to figure out whether it's something I'm 
missing. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118350

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


[PATCH] D118475: [clang-format] Fix misaligned trailing comments in the presence of an empty block comment.

2022-01-28 Thread Marek Kurdej 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 rG64df51624f08: [clang-format] Fix misaligned trailing 
comments in the presence of an empty… (authored by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118475

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/unittests/Format/FormatTestComments.cpp


Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -2842,6 +2842,12 @@
  "#define FOO_NODELOCAL 4  // Loopback\n\n"
  "} // namespace m\n",
  getLLVMStyleWithColumns(80)));
+
+  // https://llvm.org/PR53441
+  verifyFormat("/* */  //\n"
+   "int a; //\n");
+  verifyFormat("/**/   //\n"
+   "int a; //\n");
 }
 
 TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -555,7 +555,9 @@
 // We never need a decoration when breaking just the trailing "*/" postfix.
 bool HasRemainingText = Offset < Content[LineIndex].size();
 if (!HasRemainingText) {
-  LineLength -= Decoration.size();
+  bool HasDecoration = Lines[LineIndex].ltrim().startswith(Decoration);
+  if (HasDecoration)
+LineLength -= Decoration.size();
 }
   }
   return LineLength;


Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -2842,6 +2842,12 @@
  "#define FOO_NODELOCAL 4  // Loopback\n\n"
  "} // namespace m\n",
  getLLVMStyleWithColumns(80)));
+
+  // https://llvm.org/PR53441
+  verifyFormat("/* */  //\n"
+   "int a; //\n");
+  verifyFormat("/**/   //\n"
+   "int a; //\n");
 }
 
 TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -555,7 +555,9 @@
 // We never need a decoration when breaking just the trailing "*/" postfix.
 bool HasRemainingText = Offset < Content[LineIndex].size();
 if (!HasRemainingText) {
-  LineLength -= Decoration.size();
+  bool HasDecoration = Lines[LineIndex].ltrim().startswith(Decoration);
+  if (HasDecoration)
+LineLength -= Decoration.size();
 }
   }
   return LineLength;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 64df516 - [clang-format] Fix misaligned trailing comments in the presence of an empty block comment.

2022-01-28 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-01-28T22:28:48+01:00
New Revision: 64df51624f08f3b8d7370f820ab3545b1de98a0e

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

LOG: [clang-format] Fix misaligned trailing comments in the presence of an 
empty block comment.

Fixes https://github.com/llvm/llvm-project/issues/53441.

Expected code:
```
/**/   //
int a; //
```

was before misformatted to:
```
/**/ //
int a; //
```

Because the "remaining length" (after the starting `/*`) of an empty block 
comment `/**/` was computed to be 0 instead of 2.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

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

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp
clang/unittests/Format/FormatTestComments.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index 085713b5c81ca..f68d802c1f95f 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -555,7 +555,9 @@ unsigned BreakableBlockComment::getRemainingLength(unsigned 
LineIndex,
 // We never need a decoration when breaking just the trailing "*/" postfix.
 bool HasRemainingText = Offset < Content[LineIndex].size();
 if (!HasRemainingText) {
-  LineLength -= Decoration.size();
+  bool HasDecoration = Lines[LineIndex].ltrim().startswith(Decoration);
+  if (HasDecoration)
+LineLength -= Decoration.size();
 }
   }
   return LineLength;

diff  --git a/clang/unittests/Format/FormatTestComments.cpp 
b/clang/unittests/Format/FormatTestComments.cpp
index b5db353d4ae0a..b487440a06a3b 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -2842,6 +2842,12 @@ TEST_F(FormatTestComments, AlignTrailingComments) {
  "#define FOO_NODELOCAL 4  // Loopback\n\n"
  "} // namespace m\n",
  getLLVMStyleWithColumns(80)));
+
+  // https://llvm.org/PR53441
+  verifyFormat("/* */  //\n"
+   "int a; //\n");
+  verifyFormat("/**/   //\n"
+   "int a; //\n");
 }
 
 TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {



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


[PATCH] D117937: [VFS] Add a "redirecting-with" field to overlays

2022-01-28 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added a comment.

Thanks for taking a look at that @keith, I appreciate it :)! I'll make those 
changes today hopefully.




Comment at: llvm/include/llvm/Support/VirtualFileSystem.h:575
+///   instead>
+///   'redirecting-with': 

keith wrote:
> I think `redirecting-with` is fine, and I can't come up with something better
Thanks. Do you know if this format is documented anywhere that I would need to 
update?



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1341
+Iters.push_back(ExternalIter);
+  } else {
+Iters.push_back(ExternalIter);

keith wrote:
> I know we can only get here if the redirection != redirectOnly, but I think 
> it might be more readable if we had an explicit else if here with 
> fallthrough, and then added an else with an unreachable to make it clear, and 
> make sure if we ever move stuff around we revisit this ordering
Ah yep, I really should have done that in the first place. Thanks!



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1455-1456
+  return RedirectingFileSystem::RedirectKind::RedirectOnly;
+}
+return None;
+  }

keith wrote:
> Should this case error because the set value was invalid / a typo? Maybe this 
> bubbles up actually?
It ends up returning `false` down in `parse` but I need to add a call to 
`error` to actually describe the error.



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1870
+}
+  } else if (Key == "redirecting-with") {
+if (auto Kind = parseRedirectKind(I.getValue())) {

keith wrote:
> Should we error in the case that both this key and `fallthrough` are present? 
> Maybe that's too strict for backwards compat, but right now I guess 
> `fallthrough` could overwrite this value depending on order?
I intentionally allowed both for backwards compatibility, though I'm not sure 
if that is a real concern after more thinking about it - you'd have to use the 
new key for it to matter, in which case we don't need to worry about backwards 
compatibility. So yes, I think we should error if both are present.

I need to add tests for all these error cases as well (both keys present and 
passing an incorrect value).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117937

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


[PATCH] D117376: Remove reference type when checking const structs

2022-01-28 Thread Richard Trieu 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 rGbe2147db054e: Remove reference type when checking const 
structs (authored by rtrieu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117376

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGenCXX/merge-all-constants-references.cpp


Index: clang/test/CodeGenCXX/merge-all-constants-references.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/merge-all-constants-references.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -fmerge-all-constants 
%s -o /dev/null
+
+struct A {
+};
+
+struct B {
+  const struct A& a = {};
+};
+
+void Test(const struct B&);
+
+void Run() {
+  Test({});
+}
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -851,6 +851,7 @@
 }
 
 llvm::Constant *ConstStructBuilder::Finalize(QualType Type) {
+  Type = Type.getNonReferenceType();
   RecordDecl *RD = Type->castAs()->getDecl();
   llvm::Type *ValTy = CGM.getTypes().ConvertType(Type);
   return Builder.build(ValTy, RD->hasFlexibleArrayMember());


Index: clang/test/CodeGenCXX/merge-all-constants-references.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/merge-all-constants-references.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -fmerge-all-constants %s -o /dev/null
+
+struct A {
+};
+
+struct B {
+  const struct A& a = {};
+};
+
+void Test(const struct B&);
+
+void Run() {
+  Test({});
+}
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -851,6 +851,7 @@
 }
 
 llvm::Constant *ConstStructBuilder::Finalize(QualType Type) {
+  Type = Type.getNonReferenceType();
   RecordDecl *RD = Type->castAs()->getDecl();
   llvm::Type *ValTy = CGM.getTypes().ConvertType(Type);
   return Builder.build(ValTy, RD->hasFlexibleArrayMember());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] be2147d - Remove reference type when checking const structs

2022-01-28 Thread via cfe-commits

Author: Weverything
Date: 2022-01-28T13:08:58-08:00
New Revision: be2147db054ec096199d1251bfab9065c7e0f29b

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

LOG: Remove reference type when checking const structs

ConstStructBuilder::Finalize in CGExprConstant.ccp assumes that the
passed in QualType is a RecordType.  In some instances, the type is a
reference to a RecordType and the reference needs to be removed first.

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

Added: 
clang/test/CodeGenCXX/merge-all-constants-references.cpp

Modified: 
clang/lib/CodeGen/CGExprConstant.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index cf1f2e0eab92d..ac4b4d1308ab6 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -851,6 +851,7 @@ bool ConstStructBuilder::Build(const APValue , const 
RecordDecl *RD,
 }
 
 llvm::Constant *ConstStructBuilder::Finalize(QualType Type) {
+  Type = Type.getNonReferenceType();
   RecordDecl *RD = Type->castAs()->getDecl();
   llvm::Type *ValTy = CGM.getTypes().ConvertType(Type);
   return Builder.build(ValTy, RD->hasFlexibleArrayMember());

diff  --git a/clang/test/CodeGenCXX/merge-all-constants-references.cpp 
b/clang/test/CodeGenCXX/merge-all-constants-references.cpp
new file mode 100644
index 0..76c6f292ef421
--- /dev/null
+++ b/clang/test/CodeGenCXX/merge-all-constants-references.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -fmerge-all-constants 
%s -o /dev/null
+
+struct A {
+};
+
+struct B {
+  const struct A& a = {};
+};
+
+void Test(const struct B&);
+
+void Run() {
+  Test({});
+}



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


[PATCH] D118153: [CUDA][HIP] Do not treat host var address as constant in device compilation

2022-01-28 Thread Yaxun Liu 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 rG8428c75da1ab: [CUDA][HIP] Do not treat host var address as 
constant in device compilation (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118153

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/CodeGenCUDA/const-var.cu
  clang/test/SemaCUDA/const-var.cu

Index: clang/test/SemaCUDA/const-var.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/const-var.cu
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -x hip %s \
+// RUN:   -fsyntax-only -verify
+// RUN: %clang_cc1 -triple x86_64 -x hip %s \
+// RUN:   -fsyntax-only -verify=host
+
+// host-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+// Test const var initialized with address of a const var.
+// Both are promoted to device side.
+
+namespace Test1 {
+const int a = 1;
+
+struct B {
+static const int *const p;
+__device__ static const int *const p2;
+};
+const int *const B::p = 
+// Const variable 'a' is treated as __constant__ on device side,
+// therefore its address can be used as initializer for another
+// device variable.
+__device__ const int *const B::p2 = 
+
+__device__ void f() {
+  int y = a;
+  const int *x = B::p;
+  const int *z = B::p2;
+}
+}
+
+// Test const var initialized with address of a non-cost var.
+// Neither is promoted to device side.
+
+namespace Test2 {
+int a = 1;
+// expected-note@-1{{host variable declared here}}
+
+struct B {
+static int *const p;
+};
+int *const B::p = 
+// expected-note@-1{{const variable cannot be emitted on device side due to dynamic initialization}}
+
+__device__ void f() {
+  int y = a;
+  // expected-error@-1{{reference to __host__ variable 'a' in __device__ function}}
+  const int *x = B::p;
+  // expected-error@-1{{reference to __host__ variable 'p' in __device__ function}}
+}
+}
+
+// Test device var initialized with address of a non-const host var, __shared var,
+// __managed__ var, __device__ var, __constant__ var, texture var, surface var.
+
+namespace Test3 {
+struct textureReference {
+  int desc;
+};
+
+enum ReadMode {
+  ElementType = 0,
+  NormalizedFloat = 1
+};
+
+template 
+struct __attribute__((device_builtin_texture_type)) texture : public textureReference {
+};
+
+struct surfaceReference {
+  int desc;
+};
+
+template 
+struct __attribute__((device_builtin_surface_type)) surface : public surfaceReference {
+};
+
+// Partial specialization over `void`.
+template
+struct __attribute__((device_builtin_surface_type)) surface : public surfaceReference {
+};
+
+texture tex;
+surface surf;
+
+int a = 1;
+__shared__ int b;
+__managed__ int c = 1;
+__device__ int d = 1;
+__constant__ int e = 1;
+struct B {
+__device__ static int *const p1;
+__device__ static int *const p2;
+__device__ static int *const p3;
+__device__ static int *const p4;
+__device__ static int *const p5;
+__device__ static texture *const p6;
+__device__ static surface *const p7;
+};
+__device__ int *const B::p1 = 
+// expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}}
+__device__ int *const B::p2 = 
+// expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}}
+__device__ int *const B::p3 = 
+// expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}}
+__device__ int *const B::p4 = 
+__device__ int *const B::p5 = 
+__device__ texture *const B::p6 = 
+__device__ surface *const B::p7 = 
+}
Index: clang/test/CodeGenCUDA/const-var.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/const-var.cu
@@ -0,0 +1,54 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -x hip %s \
+// RUN:   -emit-llvm -o - | FileCheck -check-prefix=DEV %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -x hip %s \
+// RUN:   -emit-llvm -o - | FileCheck -check-prefix=HOST %s
+
+// Negative tests.
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -x hip %s \
+// RUN:   -emit-llvm -o - | FileCheck -check-prefix=DEV-NEG %s
+
+#include "Inputs/cuda.h"
+
+// Test const var initialized with address of a const var.
+// Both are promoted to device side.
+
+// DEV-DAG: @_ZN5Test1L1aE = internal addrspace(4) constant i32 1
+// DEV-DAG: @_ZN5Test11B2p1E = addrspace(4) externally_initialized constant i32* addrspacecast (i32 addrspace(4)* @_ZN5Test1L1aE to i32*)
+// DEV-DAG: @_ZN5Test11B2p2E = addrspace(4) externally_initialized constant 

[clang] 8428c75 - [CUDA][HIP] Do not treat host var address as constant in device compilation

2022-01-28 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2022-01-28T16:04:52-05:00
New Revision: 8428c75da1ab3149292c255057173cb502729d92

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

LOG: [CUDA][HIP] Do not treat host var address as constant in device compilation

Currently clang treats host var address as constant in device compilation,
which causes const vars initialized with host var address promoted to
device variables incorrectly and results in undefined symbols.

This patch fixes that.

Reviewed by: Artem Belevich

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

Fixes: SWDEV-309881

Change-Id: I0a69357063c6f8539ef259c96c250d04615f4473

Added: 
clang/test/CodeGenCUDA/const-var.cu
clang/test/SemaCUDA/const-var.cu

Modified: 
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Sema/SemaCUDA.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 0ebd17822cf4f..63c11e237d6c8 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -653,6 +653,20 @@ class ASTContext : public RefCountedBase {
   /// Returns the clang bytecode interpreter context.
   interp::Context ();
 
+  struct CUDAConstantEvalContext {
+/// Do not allow wrong-sided variables in constant expressions.
+bool NoWrongSidedVars = false;
+  } CUDAConstantEvalCtx;
+  struct CUDAConstantEvalContextRAII {
+ASTContext 
+CUDAConstantEvalContext SavedCtx;
+CUDAConstantEvalContextRAII(ASTContext _, bool NoWrongSidedVars)
+: Ctx(Ctx_), SavedCtx(Ctx_.CUDAConstantEvalCtx) {
+  Ctx_.CUDAConstantEvalCtx.NoWrongSidedVars = NoWrongSidedVars;
+}
+~CUDAConstantEvalContextRAII() { Ctx.CUDAConstantEvalCtx = SavedCtx; }
+  };
+
   /// Returns the dynamic AST node parent map context.
   ParentMapContext ();
 

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f9416e8e215d1..9e4088f94015c 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -983,6 +983,8 @@ namespace {
   discardCleanups();
 }
 
+ASTContext () const override { return Ctx; }
+
 void setEvaluatingDecl(APValue::LValueBase Base, APValue ,
EvaluatingDeclKind EDK = EvaluatingDeclKind::Ctor) {
   EvaluatingDecl = Base;
@@ -1116,8 +1118,6 @@ namespace {
 
 Expr::EvalStatus () const override { return EvalStatus; }
 
-ASTContext () const override { return Ctx; }
-
 // If we have a prior diagnostic, it will be noting that the expression
 // isn't a constant expression. This diagnostic is more important,
 // unless we require this evaluation to produce a constant expression.
@@ -2216,6 +2216,19 @@ static bool CheckLValueConstantExpression(EvalInfo 
, SourceLocation Loc,
   if (!isForManglingOnly(Kind) && Var->hasAttr())
 // FIXME: Diagnostic!
 return false;
+
+  // In CUDA/HIP device compilation, only device side variables have
+  // constant addresses.
+  if (Info.getCtx().getLangOpts().CUDA &&
+  Info.getCtx().getLangOpts().CUDAIsDevice &&
+  Info.getCtx().CUDAConstantEvalCtx.NoWrongSidedVars) {
+if ((!Var->hasAttr() &&
+ !Var->hasAttr() &&
+ !Var->getType()->isCUDADeviceBuiltinSurfaceType() &&
+ !Var->getType()->isCUDADeviceBuiltinTextureType()) ||
+Var->hasAttr())
+  return false;
+  }
 }
 if (const auto *FD = dyn_cast(BaseVD)) {
   // __declspec(dllimport) must be handled very carefully:

diff  --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 59601c5ce79d6..efa38554bc83f 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -590,6 +590,8 @@ bool HasAllowedCUDADeviceStaticInitializer(Sema , VarDecl 
*VD,
   };
   auto IsConstantInit = [&](const Expr *Init) {
 assert(Init);
+ASTContext::CUDAConstantEvalContextRAII EvalCtx(S.Context,
+/*NoWronSidedVars=*/true);
 return Init->isConstantInitializer(S.Context,
VD->getType()->isReferenceType());
   };

diff  --git a/clang/test/CodeGenCUDA/const-var.cu 
b/clang/test/CodeGenCUDA/const-var.cu
new file mode 100644
index 0..5ea5696ba8b8b
--- /dev/null
+++ b/clang/test/CodeGenCUDA/const-var.cu
@@ -0,0 +1,54 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -x hip %s \
+// RUN:   -emit-llvm -o - | FileCheck -check-prefix=DEV %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -x hip %s \
+// RUN:   -emit-llvm -o - | FileCheck -check-prefix=HOST %s
+
+// Negative tests.
+
+// RUN: %clang_cc1 -triple 

[PATCH] D118370: [clang-tidy] bugprone-signal-handler: Message improvement and code refactoring.

2022-01-28 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:146
+  if (!HandlerDecl->hasBody()) {
+checkFunction(HandlerDecl, HandlerExpr);
 return;

Can we put `(void) checkFunction(...)` here to make it clear
we're intentionally ignoring the return value?



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h:36
 private:
-  bool isFunctionAsyncSafe(const FunctionDecl *FD) const;
+  /// Check if a function is allowed as signal handler.
+  /// Should test properties of the function, and check in the code body.

... `as a signal handler`



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h:37
+  /// Check if a function is allowed as signal handler.
+  /// Should test properties of the function, and check in the code body.
+  /// Should not check function calls in the code (this part is done by the 
call

`Should test the properties` ...



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h:42
+  /// @param CallOrRef Location of the call to this function (in another
+  /// function) or the reference to the function (if it is used as registered
+  /// signal handler). This is the location where diagnostics are to be placed.

... `as a registered`



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h:44
+  /// signal handler). This is the location where diagnostics are to be placed.
+  /// @return true only if problem was found in the function.
+  bool checkFunction(const FunctionDecl *FD, const Expr *CallOrRef);

... `only if a problem` ...



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h:48
   bool isSystemCallAsyncSafe(const FunctionDecl *FD) const;
-  void reportBug(const FunctionDecl *CalledFunction, const Expr *CallOrRef,
- bool DirectHandler);
-  void reportHandlerCommon(llvm::df_iterator Itr,
-   const CallExpr *SignalCall,
-   const FunctionDecl *HandlerDecl,
-   const Expr *HandlerRef);
+  /// Add bug report notes to show the call chain of functions from signal
+  /// handler to an actual called function (from it).

... `from a signal`



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h:51
+  /// @param Itr Position during a call graph depth-first iteration. It 
contains
+  /// the "path" (call chain) from signal handler to the actual found function
+  /// call.

.. `from the signal handler` ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118370

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


[PATCH] D118495: [OpenMP] Accept shortened triples for -Xopenmp-target=

2022-01-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 404136.
jhuber6 added a comment.

Adding test and shared function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118495

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


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -343,3 +343,10 @@
 // RUN:   | FileCheck -check-prefix=SAVE_TEMPS_NAMES %s
 
 // SAVE_TEMPS_NAMES-NOT: "GNU::Linker"{{.*}}["[[SAVE_TEMPS_INPUT1:.*\.o]]", 
"[[SAVE_TEMPS_INPUT1]]"]
+
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64 
-Xopenmp-target=nvptx64 -march=sm_35 \
+// RUN:  -save-temps -no-canonical-prefixes %s -o openmp-offload-gpu 
2>&1 \
+// RUN:   | FileCheck -check-prefix=TRIPLE %s
+
+// TRIPLE: "-triple" "nvptx64-nvidia-cuda"
+// TRIPLE: "-target-cpu" "sm_35"
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1129,8 +1129,10 @@
 A->getOption().matches(options::OPT_Xopenmp_target);
 
 if (A->getOption().matches(options::OPT_Xopenmp_target_EQ)) {
+  llvm::Triple TT(getOpenMPTriple(A->getValue(0)));
+
   // Passing device args: -Xopenmp-target= -opt=val.
-  if (A->getValue(0) == getTripleString())
+  if (TT.getTriple() == getTripleString())
 Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
   else
 continue;
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -773,21 +773,9 @@
   if (HasValidOpenMPRuntime) {
 llvm::StringMap FoundNormalizedTriples;
 for (const char *Val : OpenMPTargets->getValues()) {
-  llvm::Triple TT(Val);
+  llvm::Triple TT(ToolChain::getOpenMPTriple(Val));
   std::string NormalizedName = TT.normalize();
 
-  // We want to expand the shortened versions of the triples passed in 
to
-  // the values used for the bitcode libraries for convenience.
-  if (TT.getVendor() == llvm::Triple::UnknownVendor ||
-  TT.getOS() == llvm::Triple::UnknownOS) {
-if (TT.getArch() == llvm::Triple::nvptx)
-  TT = llvm::Triple("nvptx-nvidia-cuda");
-else if (TT.getArch() == llvm::Triple::nvptx64)
-  TT = llvm::Triple("nvptx64-nvidia-cuda");
-else if (TT.getArch() == llvm::Triple::amdgcn)
-  TT = llvm::Triple("amdgcn-amd-amdhsa");
-  }
-
   // Make sure we don't have a duplicate triple.
   auto Duplicate = FoundNormalizedTriples.find(NormalizedName);
   if (Duplicate != FoundNormalizedTriples.end()) {
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -711,6 +711,22 @@
   const llvm::fltSemantics *FPType = nullptr) const {
 return llvm::DenormalMode::getIEEE();
   }
+
+  // We want to expand the shortened versions of the triples passed in to
+  // the values used for the bitcode libraries.
+  static llvm::Triple getOpenMPTriple(StringRef TripleStr) {
+llvm::Triple TT(TripleStr);
+if (TT.getVendor() == llvm::Triple::UnknownVendor ||
+TT.getOS() == llvm::Triple::UnknownOS) {
+  if (TT.getArch() == llvm::Triple::nvptx)
+return llvm::Triple("nvptx-nvidia-cuda");
+  if (TT.getArch() == llvm::Triple::nvptx64)
+return llvm::Triple("nvptx64-nvidia-cuda");
+  if (TT.getArch() == llvm::Triple::amdgcn)
+return llvm::Triple("amdgcn-amd-amdhsa");
+}
+return TT;
+  }
 };
 
 /// Set a ToolChain's effective triple. Reset it when the registration object


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -343,3 +343,10 @@
 // RUN:   | FileCheck -check-prefix=SAVE_TEMPS_NAMES %s
 
 // SAVE_TEMPS_NAMES-NOT: "GNU::Linker"{{.*}}["[[SAVE_TEMPS_INPUT1:.*\.o]]", "[[SAVE_TEMPS_INPUT1]]"]
+
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64 -Xopenmp-target=nvptx64 -march=sm_35 \
+// RUN:  -save-temps -no-canonical-prefixes %s -o openmp-offload-gpu 2>&1 \
+// RUN:   | FileCheck -check-prefix=TRIPLE %s
+
+// TRIPLE: "-triple" "nvptx64-nvidia-cuda"
+// TRIPLE: "-target-cpu" "sm_35"
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ 

[PATCH] D117924: [compiler_rt] Add a seperate runtime for Mac Catalyst

2022-01-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D117924#3274425 , @bc-lee wrote:

> It may not be appropriate to add other runtime libraries specifically for Mac 
> Catalyst. However, currently `lld` does not allow linking with dynamic 
> libraries with different types of build_version_command, whereas `ld64` does 
> allow for Mac Catalyst. Considering compatibility with lld

If lld doesn't support something we need, we should add support for the missing 
part to lld instead of working around it. Is there a bug on file for the 
missing lld bit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117924

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


[PATCH] D117937: [VFS] Add a "redirecting-with" field to overlays

2022-01-28 Thread Keith Smiley via Phabricator via cfe-commits
keith accepted this revision.
keith added a comment.
This revision is now accepted and ready to land.

I'm definitely not a VFS expert, but I do think this is much nicer than trying 
to do the other workarounds with multiple VFSs that you described, I left some 
minor comments, I reviewed carefully but this logic was and is quite dense so 
I'm heavily relying on the test coverage.




Comment at: llvm/include/llvm/Support/VirtualFileSystem.h:575
+///   instead>
+///   'redirecting-with': 

I think `redirecting-with` is fine, and I can't come up with something better



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1341
+Iters.push_back(ExternalIter);
+  } else {
+Iters.push_back(ExternalIter);

I know we can only get here if the redirection != redirectOnly, but I think it 
might be more readable if we had an explicit else if here with fallthrough, and 
then added an else with an unreachable to make it clear, and make sure if we 
ever move stuff around we revisit this ordering



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1455-1456
+  return RedirectingFileSystem::RedirectKind::RedirectOnly;
+}
+return None;
+  }

Should this case error because the set value was invalid / a typo? Maybe this 
bubbles up actually?



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1870
+}
+  } else if (Key == "redirecting-with") {
+if (auto Kind = parseRedirectKind(I.getValue())) {

Should we error in the case that both this key and `fallthrough` are present? 
Maybe that's too strict for backwards compat, but right now I guess 
`fallthrough` could overwrite this value depending on order?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117937

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


[PATCH] D117238: [C2x] Add BITINT_MAXWIDTH support

2022-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the reviews! I've commit in 
86797fdb6f51d32f285e48b6d3e0fc5b8b852734 
.


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

https://reviews.llvm.org/D117238

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


[clang] 86797fd - Add BITINT_MAXWIDTH support

2022-01-28 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-01-28T15:04:29-05:00
New Revision: 86797fdb6f51d32f285e48b6d3e0fc5b8b852734

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

LOG: Add BITINT_MAXWIDTH support

Part of the _BitInt feature in C2x
(http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2763.pdf) is a new
macro in limits.h named BITINT_MAXWIDTH that can be used to determine
the maximum width of a bit-precise integer type. This macro must expand
to a value that is at least as large as ULLONG_WIDTH.

This adds an implementation-defined macro named __BITINT_MAXWIDTH__ to
specify that value, which is used by limits.h for the standard macro.

This also limits the maximum bit width to 128 bits because backends do
not currently support all mathematical operations (such as division) on
wider types yet. This maximum is expected to be increased in the future.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/TargetInfo.h
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Headers/limits.h
clang/lib/Sema/SemaType.cpp
clang/test/CodeGen/ext-int-cc.c
clang/test/CodeGen/ext-int.c
clang/test/CodeGenCXX/ext-int.cpp
clang/test/Headers/limits.cpp
clang/test/Preprocessor/init-aarch64.c
clang/test/Preprocessor/init.c
clang/test/Sema/builtins-overflow.c
clang/test/SemaCXX/ext-int.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 45e80785e462a..aa54be1efe1c5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -171,7 +171,12 @@ C Language Changes in Clang
   ``_BitInt(N)`` is supported as an extension in older C modes and in all C++
   modes. Note: the ABI for ``_BitInt(N)`` is still in the process of being
   stabilized, so this type should not yet be used in interfaces that require
-  ABI stability.
+  ABI stability. The maximum width supported by Clang can be obtained from the
+  ``BITINT_MAXWIDTH`` macro in . Currently, Clang supports bit
+  widths <= 128 because backends are not yet able to cope with some math
+  operations (like division) on wider integer types. See
+  `PR44994 `_ for more
+  information.
 - When using ``asm goto`` with outputs whose constraint modifier is ``"+"``, we
   now change the numbering of the labels to occur after hidden tied inputs for
   better compatibility with GCC.  For better portability between 
diff erent

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 642c8500364bb..a49342a34f3e8 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -590,6 +590,17 @@ class TargetInfo : public virtual TransferrableTargetInfo,
 return false;
   }
 
+  // Different targets may support a 
diff erent maximum width for the _BitInt
+  // type, depending on what operations are supported.
+  virtual size_t getMaxBitIntWidth() const {
+// FIXME: this value should be llvm::IntegerType::MAX_INT_BITS, which is
+// maximum bit width that LLVM claims its IR can support. However, most
+// backends currently have a bug where they only support division
+// operations on types that are <= 128 bits and crash otherwise. We're
+// setting the max supported value to 128 to be conservative.
+return 128;
+  }
+
   /// Determine whether _Float16 is supported on this target.
   virtual bool hasLegalHalfType() const { return HasLegalHalfType; }
 

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index a9023a7a1171e..e259ab47c5589 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -25,6 +25,7 @@
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DerivedTypes.h"
 using namespace clang;
 
 static bool MacroBodyEndsInBackslash(StringRef MacroBody) {
@@ -914,6 +915,13 @@ static void InitializePredefinedMacros(const TargetInfo 
,
   Builder.defineMacro("__LONG_WIDTH__", Twine(TI.getLongWidth()));
   Builder.defineMacro("__LLONG_WIDTH__", Twine(TI.getLongLongWidth()));
 
+  size_t BitIntMaxWidth = TI.getMaxBitIntWidth();
+  assert(BitIntMaxWidth <= llvm::IntegerType::MAX_INT_BITS &&
+ "Target defined a max bit width larger than LLVM can support!");
+  assert(BitIntMaxWidth >= TI.getLongLongWidth() &&
+ "Target defined a max bit width smaller than the C standard allows!");
+  Builder.defineMacro("__BITINT_MAXWIDTH__", Twine(BitIntMaxWidth));
+
   DefineTypeSize("__SCHAR_MAX__", TargetInfo::SignedChar, TI, Builder);
   DefineTypeSize("__SHRT_MAX__", TargetInfo::SignedShort, TI, Builder);
   

[PATCH] D117416: [clang-format] Handle C variables with name that matches c++ access specifier

2022-01-28 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:119-121
+if (!RootToken.Next) {
+  return true;
+}

Drop Braces



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:122-126
+auto COperatorMatch = std::lower_bound(COperatorsFollowingVar.begin(),
+   COperatorsFollowingVar.end(),
+   RootToken.Next->Tok.getKind());
+if ((COperatorMatch == COperatorsFollowingVar.end() ||
+ *COperatorMatch != RootToken.Next->Tok.getKind()) &&

Use `std::binary_search` instead of `std::lower_bound`. That should simplify 
the following `if`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117416

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


[clang] edf7e02 - [clang][NFC] Fix Typo

2022-01-28 Thread Jacob Lambert via cfe-commits

Author: Jacob Lambert
Date: 2022-01-28T11:55:46-08:00
New Revision: edf7e026a8b4df5df7febaef126888f1ce65ebf6

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

LOG: [clang][NFC] Fix Typo

Added: 


Modified: 
clang/docs/ClangOffloadBundler.rst

Removed: 




diff  --git a/clang/docs/ClangOffloadBundler.rst 
b/clang/docs/ClangOffloadBundler.rst
index ac4c5b51904fc..997948a8217e5 100644
--- a/clang/docs/ClangOffloadBundler.rst
+++ b/clang/docs/ClangOffloadBundler.rst
@@ -290,7 +290,7 @@ clang-offload-bundler extracts compatible device binaries 
for a given target
 from the bundled device binaries in a heterogeneous device archive and creates
 a target specific device archive without bundling.
 
-clang-offlocad-bundler determines whether a device binary is compatible with a
+clang-offload-bundler determines whether a device binary is compatible with a
 target by comparing bundle ID's. Two bundle ID's are considered compatible if:
 
   * Their offload kind are the same



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


[PATCH] D118363: clang-format: [JS] sort import aliases.

2022-01-28 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

There should have been an entry in the `ReleaseNotes.rst`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118363

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


[PATCH] D109977: LLVM Driver Multicall tool

2022-01-28 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 404114.
beanz added a comment.

Adding support for multiple subcommands mapping to the same entry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/cmake/driver-template.cpp.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp

Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -402,7 +402,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   ToolName = argv[0];
 
Index: llvm/tools/llvm-objcopy/CMakeLists.txt
===
--- llvm/tools/llvm-objcopy/CMakeLists.txt
+++ llvm/tools/llvm-objcopy/CMakeLists.txt
@@ -43,6 +43,7 @@
   ObjcopyOptsTableGen
   InstallNameToolOptsTableGen
   StripOptsTableGen
+  GENERATE_DRIVER
   )
 
 add_llvm_tool_symlink(llvm-install-name-tool llvm-objcopy)
Index: llvm/tools/llvm-driver/llvm-driver.cpp
===
--- /dev/null
+++ llvm/tools/llvm-driver/llvm-driver.cpp
@@ -0,0 +1,62 @@
+//===-- llvm-driver.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+
+#define LLVM_DRIVER_TOOL(tool, entry, key) \
+  int entry##_main(int argc, char **argv);
+#include "LLVMDriverTools.def"
+
+// This function handles the case of not recognizing the tool requested, or if
+// --help or --version are passed directly to the llvm driver.
+int UnknownMain(int Argc, char **Argv) {
+  cl::OptionCategory LLVMDriverCategory("llvm options");
+#define LLVM_DRIVER_TOOL(tool, entry, key) \
+  cl::SubCommand key##Subcommand(tool, tool);
+#include "LLVMDriverTools.def"
+
+  cl::HideUnrelatedOptions(LLVMDriverCategory);
+  cl::ParseCommandLineOptions(Argc, Argv, "llvm compiler driver\n");
+  llvm_unreachable("We should never get here, parsing should always exit.");
+  return 1;
+}
+
+int main(int Argc, char **Argv) {
+  llvm::StringRef LaunchedTool = sys::path::stem(Argv[0]);
+  // If the driver is launched directly.
+  int PassThroughArgC = Argc;
+  char **PassThroughArgV = Argv;
+  bool ConsumeFirstArg = false;
+  if (LaunchedTool == "llvm") {
+LaunchedTool = Argv[1];
+ConsumeFirstArg = true;
+  }
+
+  // if it is launched through a symlink that is the tool name.
+  typedef int (*MainFunction)(int, char **);
+  MainFunction Func = StringSwitch(LaunchedTool)
+
+#define LLVM_DRIVER_TOOL(tool, entry, key) .Case(tool, entry##_main)
+#include "LLVMDriverTools.def"
+  .Default(UnknownMain);
+  // If the main function is unknown we don't consume any args, so that we can
+  // print the appropriate help spew.
+  if (Func != UnknownMain && ConsumeFirstArg) {
+--PassThroughArgC;
+++PassThroughArgV;
+  }
+
+  return Func(PassThroughArgC, PassThroughArgV);
+}
Index: llvm/tools/llvm-driver/CMakeLists.txt
===
--- /dev/null
+++ llvm/tools/llvm-driver/CMakeLists.txt
@@ -0,0 +1,30 @@
+get_property(LLVM_COMMON_DEPENDS GLOBAL PROPERTY LLVM_DRIVER_DEPS)
+get_property(LLVM_DRIVER_OBJLIBS GLOBAL PROPERTY LLVM_DRIVER_OBJLIBS)
+
+get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
+
+foreach(tool ${LLVM_DRIVER_TOOLS})
+  string(REPLACE "-" "_" tool_entry ${tool})
+  set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${tool}\", ${tool_entry}, ${tool_entry})\n")
+endforeach()
+

[PATCH] D117238: [C2x] Add BITINT_MAXWIDTH support

2022-01-28 Thread James Y Knight via Phabricator via cfe-commits
jyknight accepted this revision.
jyknight added a comment.

No additional comments, thanks!


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

https://reviews.llvm.org/D117238

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


[PATCH] D118050: [analyzer] Different address spaces cannot overlap

2022-01-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:728
+const MemRegion *R = loc.castAs().getRegion();
+if (const auto *SR = dyn_cast(R)) {
+  QualType Ty = SR->getSymbol()->getType();

That's a pretty big "if".

The natural way to handle the opposite case is `TypedRegion::getLocationType()`.

You can probably go with `SVal::getType()` here as it happens to do the right 
thing (treat `Loc` values as if they were pointers). But, again, it's 
speculative.



Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:750-751
+  if (RhsBitwidth && LhsBitwidth) {
+assert(RhsBitwidth == LhsBitwidth &&
+   "RhsLoc bitwidth must be same as LhsLoc bitwidth!");
+return RhsBitwidth == LhsBitwidth;

I think this is a good, correct assertion. It is up to the AST to insert 
implicit casts when bit widths don't match (or outright reject the code, I've 
no idea what really happens in such cases, but it's up to the compiler in any 
case).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118050

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


[PATCH] D118493: [WIP]Set rpath on openmp executables

2022-01-28 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

My plan is to feed executables to readelf -d. Commandline problems seem to be 
solvable by clean builds between changes, slow but feasible. Might upset the 
incremental buildbot


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118493

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


[PATCH] D118493: [WIP]Set rpath on openmp executables

2022-01-28 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Can we test this somehow?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118493

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


[PATCH] D118495: [OpenMP] Accept shortened triples for -Xopenmp-target=

2022-01-28 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

and test pls


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118495

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


[PATCH] D117616: GCC ABI Compatibility: Preserve alignment of non-pod members in packed structs

2022-01-28 Thread David Blaikie 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 rG277123376ce0: GCC ABI Compatibility: Preserve alignment of 
non-pod members in packed structs (authored by dblaikie).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117616

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangOptions.h
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/SemaCXX/class-layout.cpp

Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++98 -Wno-inaccessible-base
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=13
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=13 -DCLANG_ABI_COMPAT=13
 // expected-no-diagnostics
 
 #define SA(n, p) int a##n[(p) ? 1 : -1]
@@ -604,3 +607,37 @@
 #endif
 #pragma pack(pop)
 }
+
+namespace non_pod {
+struct t1 {
+protected:
+  int a;
+};
+// GCC prints warning: ignoring packed attribute because of unpacked non-POD field 't1 t2::v1'`
+struct t2 {
+  char c1;
+  short s1;
+  char c2;
+  t1 v1;
+} __attribute__((packed));
+#if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 13
+_Static_assert(_Alignof(t1) == 4, "");
+_Static_assert(_Alignof(t2) == 1, "");
+#else
+_Static_assert(_Alignof(t1) == 4, "");
+_Static_assert(_Alignof(t2) == 4, "");
+#endif
+_Static_assert(sizeof(t2) == 8, ""); // it's still packing the rest of the struct
+} // namespace non_pod
+
+namespace non_pod_packed {
+struct t1 {
+protected:
+  int a;
+} __attribute__((packed));
+struct t2 {
+  t1 v1;
+} __attribute__((packed));
+_Static_assert(_Alignof(t1) == 1, "");
+_Static_assert(_Alignof(t2) == 1, "");
+} // namespace non_pod_packed
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3560,6 +3560,8 @@
 GenerateArg(Args, OPT_fclang_abi_compat_EQ, "11.0", SA);
   else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver12)
 GenerateArg(Args, OPT_fclang_abi_compat_EQ, "12.0", SA);
+  else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver13)
+GenerateArg(Args, OPT_fclang_abi_compat_EQ, "13.0", SA);
 
   if (Opts.getSignReturnAddressScope() ==
   LangOptions::SignReturnAddressScopeKind::All)
@@ -4062,6 +4064,8 @@
 Opts.setClangABICompat(LangOptions::ClangABI::Ver11);
   else if (Major <= 12)
 Opts.setClangABICompat(LangOptions::ClangABI::Ver12);
+  else if (Major <= 13)
+Opts.setClangABICompat(LangOptions::ClangABI::Ver13);
 } else if (Ver != "latest") {
   Diags.Report(diag::err_drv_invalid_value)
   << A->getAsString(Args) << A->getValue();
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1887,7 +1887,12 @@
   UnfilledBitsInLastUnit = 0;
   LastBitfieldStorageUnitSize = 0;
 
-  bool FieldPacked = Packed || D->hasAttr();
+  llvm::Triple Target = Context.getTargetInfo().getTriple();
+  bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
+ Context.getLangOpts().getClangABICompat() <=
+ LangOptions::ClangABI::Ver13 ||
+ Target.isPS4() || Target.isOSDarwin())) ||
+ D->hasAttr();
 
   AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;
Index: clang/include/clang/Basic/LangOptions.h
===
--- clang/include/clang/Basic/LangOptions.h
+++ clang/include/clang/Basic/LangOptions.h
@@ -181,6 +181,10 @@
 /// global-scope inline variables incorrectly.
 Ver12,
 
+/// Attempt to be ABI-compatible with code generated by Clang 13.0.x.
+/// This causes clang to not pack non-POD members of packed structs.
+Ver13,
+
 /// Conform to the underlying platform's C and C++ ABIs as closely
 /// as we 

[clang] 2771233 - GCC ABI Compatibility: Preserve alignment of non-pod members in packed structs

2022-01-28 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-01-28T11:04:20-08:00
New Revision: 277123376ce08c98b07c154bf83e4092a5d4d3c6

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

LOG: GCC ABI Compatibility: Preserve alignment of non-pod members in packed 
structs

This matches GCC: https://godbolt.org/z/sM5q95PGY

I realize this is an API break for clang+clang - so I'm totally open to
discussing how we should deal with that. If Apple wants to keep the
Clang layout indefinitely, if we want to put a flag on this so non-Apple
folks can opt out of this fix/new behavior.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/SemaCXX/class-layout.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6a9b046a1427d..45e80785e462a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -236,6 +236,12 @@ ABI Changes in Clang
   is still in the process of being stabilized, so this type should not yet be
   used in interfaces that require ABI stability.
 
+- GCC doesn't pack non-POD members in packed structs unless the packed
+  attribute is also specified on the member. Clang historically did perform
+  such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
+  You can switch back to the old ABI behavior with the flag:
+  ``-fclang-abi-compat=13.0``.
+
 OpenMP Support in Clang
 ---
 

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 09afa641acf9b..50c7f038fc6be 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -181,6 +181,10 @@ class LangOptions : public LangOptionsBase {
 /// global-scope inline variables incorrectly.
 Ver12,
 
+/// Attempt to be ABI-compatible with code generated by Clang 13.0.x.
+/// This causes clang to not pack non-POD members of packed structs.
+Ver13,
+
 /// Conform to the underlying platform's C and C++ ABIs as closely
 /// as we can.
 Latest

diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index 61a30ead165ef..709e05716a562 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1887,7 +1887,12 @@ void ItaniumRecordLayoutBuilder::LayoutField(const 
FieldDecl *D,
   UnfilledBitsInLastUnit = 0;
   LastBitfieldStorageUnitSize = 0;
 
-  bool FieldPacked = Packed || D->hasAttr();
+  llvm::Triple Target = Context.getTargetInfo().getTriple();
+  bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
+ Context.getLangOpts().getClangABICompat() <=
+ LangOptions::ClangABI::Ver13 ||
+ Target.isPS4() || Target.isOSDarwin())) ||
+ D->hasAttr();
 
   AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 7f1ce3da7e7eb..553a0b31c0ab3 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3560,6 +3560,8 @@ void CompilerInvocation::GenerateLangArgs(const 
LangOptions ,
 GenerateArg(Args, OPT_fclang_abi_compat_EQ, "11.0", SA);
   else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver12)
 GenerateArg(Args, OPT_fclang_abi_compat_EQ, "12.0", SA);
+  else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver13)
+GenerateArg(Args, OPT_fclang_abi_compat_EQ, "13.0", SA);
 
   if (Opts.getSignReturnAddressScope() ==
   LangOptions::SignReturnAddressScopeKind::All)
@@ -4062,6 +4064,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions , 
ArgList ,
 Opts.setClangABICompat(LangOptions::ClangABI::Ver11);
   else if (Major <= 12)
 Opts.setClangABICompat(LangOptions::ClangABI::Ver12);
+  else if (Major <= 13)
+Opts.setClangABICompat(LangOptions::ClangABI::Ver13);
 } else if (Ver != "latest") {
   Diags.Report(diag::err_drv_invalid_value)
   << A->getAsString(Args) << A->getValue();

diff  --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 5403bd6e6a6f6..79fa677071109 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only 

[PATCH] D118350: [Clang][Sema][AIX][PowerPC] Emit byval alignment warning only when struct member is passed to a function

2022-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:12693-12695
   void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
- StringRef ParamName, QualType ArgTy, QualType 
ParamTy);
+ StringRef ParamName, QualType ArgTy, QualType ParamTy,
+ const Expr *Arg = nullptr);

I'm not keen on passing both `Arg` and `ArgTy` such that they can get out of 
sync. Do all of the places calling `CheckArgAlignment()` have access to the 
`Expr` so that we can require it be passed (and drop the `ArgTy` parameter)?



Comment at: clang/lib/Sema/SemaChecking.cpp:5218
+  if (Context.getTargetInfo().getTriple().isOSAIX() && Arg) {
+if (Arg->IgnoreParens()) {
+  // Using AArg so as to not modify Arg for the rest of the function.

There's no case where `IgnoreParens()` will return null.



Comment at: clang/lib/Sema/SemaChecking.cpp:5220
+  // Using AArg so as to not modify Arg for the rest of the function.
+  const Expr *AArg = Arg->IgnoreParens();
+  if (AArg->getStmtClass() == Stmt::ImplicitCastExprClass) {

Are there other things you want to ignore here (such as 
`IgnoreParenNoopCasts()`)? (I don't have an opinion the current code is wrong, 
just checking if those sort of cases were considered or not.)



Comment at: clang/lib/Sema/SemaChecking.cpp:5221-5222
+  const Expr *AArg = Arg->IgnoreParens();
+  if (AArg->getStmtClass() == Stmt::ImplicitCastExprClass) {
+const ImplicitCastExpr *ICE = dyn_cast(AArg);
+AArg = ICE->getSubExpr();

This achieves the same thing, but with less work.



Comment at: clang/lib/Sema/SemaChecking.cpp:5224-5225
+AArg = ICE->getSubExpr();
+if (AArg->getStmtClass() == Stmt::MemberExprClass) {
+  const auto *ME = dyn_cast(AArg);
+  ValueDecl *MD = ME->getMemberDecl();





Comment at: clang/lib/Sema/SemaChecking.cpp:5226-5228
+  ValueDecl *MD = ME->getMemberDecl();
+  auto *FD = dyn_cast(MD);
+  if (FD) {





Comment at: clang/lib/Sema/SemaChecking.cpp:5229-5230
+  if (FD) {
+if (FD->hasAttr()) {
+  auto *AA = FD->getAttr();
+  unsigned Aligned = AA->getAlignment(Context);





Comment at: clang/lib/Sema/SemaChecking.cpp:5232-5233
+  unsigned Aligned = AA->getAlignment(Context);
+  // Divide by 8 to get the bytes instead of using bits.
+  if (Aligned / 8 >= 16)
+Diag(Loc, diag::warn_not_xl_compatible) << FD;

Should we be using char bits rather than a hardcoded value?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118350

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


[PATCH] D101759: [PowerPC] Scalar IBM MASS library conversion pass

2022-01-28 Thread Masoud Ataei via Phabricator via cfe-commits
masoud.ataei added a comment.

Ready for another round of review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101759

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


[PATCH] D118495: [OpenMP] Accept shortened triples for -Xopenmp-target=

2022-01-28 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Do we have this same expansion logic in two places now? If so, probably want to 
factor it out to a function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118495

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


[PATCH] D118350: [Clang][Sema][AIX][PowerPC] Emit byval alignment warning only when struct member is passed to a function

2022-01-28 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 404090.
ZarkoCA added a comment.

Addressing comments:

- Change comment before checkArgAlignment()
- Add missing RUN lines


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118350

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/aix-attr-align.c

Index: clang/test/Sema/aix-attr-align.c
===
--- clang/test/Sema/aix-attr-align.c
+++ clang/test/Sema/aix-attr-align.c
@@ -6,17 +6,31 @@
 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux -verify=off -fsyntax-only %s
 
 struct S {
-  int a[8] __attribute__((aligned(8))); // no-warning
+  int a[8] __attribute__((aligned(8)));  // no-warning
+  int b[8] __attribute__((aligned(16))); // no-warning
+  int c[2] __attribute__((aligned(32))); // no-warning
 };
 
 struct T {
-  int a[4] __attribute__((aligned(16))); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+  int a[4] __attribute__((aligned(16))); // no-warning
 };
 
 struct U {
-  int a[2] __attribute__((aligned(32))); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+  int a[2] __attribute__((aligned(32))); // no-warning
 };
 
 int a[8] __attribute__((aligned(8)));  // no-warning
 int b[4] __attribute__((aligned(16))); // no-warning
 int c[2] __attribute__((aligned(32))); // no-warning
+
+void baz(int *);
+void foo(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8,
+ struct S s) {
+  baz(s.a); // no-warning
+  baz(s.b); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+  baz(s.c); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+
+  baz(a); // no-warning
+  baz(b); // no-warning
+  baz(c); // no-warning
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4321,13 +4321,6 @@
 return;
 
   uint64_t AlignVal = Alignment.getZExtValue();
-  // 16 byte ByVal alignment not due to a vector member is not honoured by XL
-  // on AIX. Emit a warning here that users are generating binary incompatible
-  // code to be safe.
-  if (AlignVal >= 16 && isa(D) &&
-  Context.getTargetInfo().getTriple().isOSAIX())
-Diag(AttrLoc, diag::warn_not_xl_compatible) << E->getSourceRange();
-
   // C++11 [dcl.align]p2:
   //   -- if the constant expression evaluates to zero, the alignment
   //  specifier shall have no effect
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5201,13 +5201,44 @@
   }
 }
 
-/// Warn if a pointer or reference argument passed to a function points to an
-/// object that is less aligned than the parameter. This can happen when
+/// Check for problematic alignment properties of an argument. For example,
+/// warn if a pointer or reference argument passed to a function points to
+/// an object that is less aligned than the parameter. This can happen when
 /// creating a typedef with a lower alignment than the original type and then
 /// calling functions defined in terms of the original type.
 void Sema::CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
  StringRef ParamName, QualType ArgTy,
- QualType ParamTy) {
+ QualType ParamTy, const Expr *Arg) {
+
+  // 16 byte ByVal alignment not due to a vector member is not honoured by XL
+  // on AIX. Emit a warning here that users are generating binary incompatible
+  // code to be safe.
+  // Here we try to get information about the alignment of the struct member
+  // argument being passed to the caller function.
+  if (Context.getTargetInfo().getTriple().isOSAIX() && Arg) {
+if (Arg->IgnoreParens()) {
+  // Using AArg so as to not modify Arg for the rest of the function.
+  const Expr *AArg = Arg->IgnoreParens();
+  if (AArg->getStmtClass() == Stmt::ImplicitCastExprClass) {
+const ImplicitCastExpr *ICE = dyn_cast(AArg);
+AArg = ICE->getSubExpr();
+if (AArg->getStmtClass() == Stmt::MemberExprClass) {
+  const auto *ME = dyn_cast(AArg);
+  ValueDecl *MD = ME->getMemberDecl();
+  auto *FD = dyn_cast(MD);
+  if (FD) {
+if (FD->hasAttr()) {
+  auto *AA = FD->getAttr();
+  unsigned Aligned 

[PATCH] D118495: [OpenMP] Accept shortened triples for -Xopenmp-target=

2022-01-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, jdoerfert, tianshilei1992.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch builds on the change in D117634  
that expanded the short
triples when passed in by the user. This patch adds the same
functionality for the `-Xopenmp-target=` flag. Previously it was
unintuitive that passing `-fopenmp-targets=nvptx64
-Xopenmp-target=nvptx64 ` would not forward the arg because the
triples did not match on account of `nvptx64` being expanded to
`nvptx64-nvidia-cuda`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118495

Files:
  clang/lib/Driver/ToolChain.cpp


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1129,8 +1129,20 @@
 A->getOption().matches(options::OPT_Xopenmp_target);
 
 if (A->getOption().matches(options::OPT_Xopenmp_target_EQ)) {
+  llvm::Triple TT(A->getValue(0));
+  // We want to expand the shortened versions of the triples passed in to
+  // the values used for the bitcode libraries for convenience.
+  if (TT.getVendor() == llvm::Triple::UnknownVendor ||
+  TT.getOS() == llvm::Triple::UnknownOS) {
+if (TT.getArch() == llvm::Triple::nvptx)
+  TT = llvm::Triple("nvptx-nvidia-cuda");
+else if (TT.getArch() == llvm::Triple::nvptx64)
+  TT = llvm::Triple("nvptx64-nvidia-cuda");
+else if (TT.getArch() == llvm::Triple::amdgcn)
+  TT = llvm::Triple("amdgcn-amd-amdhsa");
+  }
   // Passing device args: -Xopenmp-target= -opt=val.
-  if (A->getValue(0) == getTripleString())
+  if (TT.getTriple() == getTripleString())
 Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
   else
 continue;


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1129,8 +1129,20 @@
 A->getOption().matches(options::OPT_Xopenmp_target);
 
 if (A->getOption().matches(options::OPT_Xopenmp_target_EQ)) {
+  llvm::Triple TT(A->getValue(0));
+  // We want to expand the shortened versions of the triples passed in to
+  // the values used for the bitcode libraries for convenience.
+  if (TT.getVendor() == llvm::Triple::UnknownVendor ||
+  TT.getOS() == llvm::Triple::UnknownOS) {
+if (TT.getArch() == llvm::Triple::nvptx)
+  TT = llvm::Triple("nvptx-nvidia-cuda");
+else if (TT.getArch() == llvm::Triple::nvptx64)
+  TT = llvm::Triple("nvptx64-nvidia-cuda");
+else if (TT.getArch() == llvm::Triple::amdgcn)
+  TT = llvm::Triple("amdgcn-amd-amdhsa");
+  }
   // Passing device args: -Xopenmp-target= -opt=val.
-  if (A->getValue(0) == getTripleString())
+  if (TT.getTriple() == getTripleString())
 Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
   else
 continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109977: LLVM Driver Multicall tool

2022-01-28 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

Sorry for disappearing on this. I'm working right now on adding support for 
multi-entry tools (like objcopy). I'll get an update in today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[clang] 27ee911 - [AIX][clang] include_next through clang provided float.h

2022-01-28 Thread David Tenty via cfe-commits

Author: David Tenty
Date: 2022-01-28T13:27:10-05:00
New Revision: 27ee91162dd3f01d692e8f092903dd79f4e54348

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

LOG: [AIX][clang] include_next through clang provided float.h

AIX provides additional definitions in the system libc float.h that we
would like to be available to users, so we need to include_next through,
similar to what is done on some other platforms.

We also adjust the guards for some definitions which are restricted
based on language level to also be provide with the _ALL_SOURCE feature
test macro on AIX, similar to what is done by the platform float.h
header, so we don't run into cases where we don't provide the compiler
macro but still have a different definition from the system.

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

Added: 
clang/test/Headers/Inputs/include/float.h
clang/test/Headers/float-aix.c

Modified: 
clang/lib/Headers/float.h

Removed: 




diff  --git a/clang/lib/Headers/float.h b/clang/lib/Headers/float.h
index ed610b24aa103..c6a6cc08462da 100644
--- a/clang/lib/Headers/float.h
+++ b/clang/lib/Headers/float.h
@@ -14,10 +14,11 @@
  * additional definitions provided for Windows.
  * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
  *
- * Also fall back on Darwin to allow additional definitions and
+ * Also fall back on Darwin and AIX to allow additional definitions and
  * implementation-defined values.
  */
-#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
+#if (defined(__APPLE__) || defined(__MINGW32__) || defined(_MSC_VER) ||
\
+ defined(_AIX)) && 
\
 __STDC_HOSTED__ && __has_include_next()
 
 /* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level
@@ -37,7 +38,9 @@
 #  undef FLT_MANT_DIG
 #  undef DBL_MANT_DIG
 #  undef LDBL_MANT_DIG
-#  if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus 
>= 201103L
+#  if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) ||  
\
+  __cplusplus >= 201103L ||
\
+  (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #undef DECIMAL_DIG
 #  endif
 #  undef FLT_DIG
@@ -64,7 +67,9 @@
 #  undef FLT_MIN
 #  undef DBL_MIN
 #  undef LDBL_MIN
-#  if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus 
>= 201703L
+#  if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) ||  
\
+  __cplusplus >= 201703L ||
\
+  (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #undef FLT_TRUE_MIN
 #undef DBL_TRUE_MIN
 #undef LDBL_TRUE_MIN
@@ -87,7 +92,9 @@
 #define DBL_MANT_DIG __DBL_MANT_DIG__
 #define LDBL_MANT_DIG __LDBL_MANT_DIG__
 
-#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201103L
+#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) ||
\
+__cplusplus >= 201103L ||  
\
+(__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #  define DECIMAL_DIG __DECIMAL_DIG__
 #endif
 
@@ -123,7 +130,9 @@
 #define DBL_MIN __DBL_MIN__
 #define LDBL_MIN __LDBL_MIN__
 
-#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201703L
+#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) ||
\
+__cplusplus >= 201703L ||  
\
+(__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #  define FLT_TRUE_MIN __FLT_DENORM_MIN__
 #  define DBL_TRUE_MIN __DBL_DENORM_MIN__
 #  define LDBL_TRUE_MIN __LDBL_DENORM_MIN__

diff  --git a/clang/test/Headers/Inputs/include/float.h 
b/clang/test/Headers/Inputs/include/float.h
new file mode 100644
index 0..616a02c9c95c9
--- /dev/null
+++ b/clang/test/Headers/Inputs/include/float.h
@@ -0,0 +1,2 @@
+#pragma once
+#define FLOAT_LOCAL_DEF 1

diff  --git a/clang/test/Headers/float-aix.c b/clang/test/Headers/float-aix.c
new file mode 100644
index 0..d43eae79bcd17
--- /dev/null
+++ b/clang/test/Headers/float-aix.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -fsyntax-only -verify 
-internal-isystem %S/Inputs/include %s
+// expected-no-diagnostics
+
+#include 
+
+_Static_assert(FLOAT_LOCAL_DEF, "");



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


[PATCH] D117935: [AIX][clang] include_next through clang provided float.h

2022-01-28 Thread David Tenty 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 rG27ee91162dd3: [AIX][clang] include_next through clang 
provided float.h (authored by daltenty).

Changed prior to commit:
  https://reviews.llvm.org/D117935?vs=404083=404085#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117935

Files:
  clang/lib/Headers/float.h
  clang/test/Headers/Inputs/include/float.h
  clang/test/Headers/float-aix.c


Index: clang/test/Headers/float-aix.c
===
--- /dev/null
+++ clang/test/Headers/float-aix.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -fsyntax-only -verify 
-internal-isystem %S/Inputs/include %s
+// expected-no-diagnostics
+
+#include 
+
+_Static_assert(FLOAT_LOCAL_DEF, "");
Index: clang/test/Headers/Inputs/include/float.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/float.h
@@ -0,0 +1,2 @@
+#pragma once
+#define FLOAT_LOCAL_DEF 1
Index: clang/lib/Headers/float.h
===
--- clang/lib/Headers/float.h
+++ clang/lib/Headers/float.h
@@ -14,10 +14,11 @@
  * additional definitions provided for Windows.
  * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
  *
- * Also fall back on Darwin to allow additional definitions and
+ * Also fall back on Darwin and AIX to allow additional definitions and
  * implementation-defined values.
  */
-#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
+#if (defined(__APPLE__) || defined(__MINGW32__) || defined(_MSC_VER) ||
\
+ defined(_AIX)) && 
\
 __STDC_HOSTED__ && __has_include_next()
 
 /* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level
@@ -37,7 +38,9 @@
 #  undef FLT_MANT_DIG
 #  undef DBL_MANT_DIG
 #  undef LDBL_MANT_DIG
-#  if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus 
>= 201103L
+#  if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) ||  
\
+  __cplusplus >= 201103L ||
\
+  (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #undef DECIMAL_DIG
 #  endif
 #  undef FLT_DIG
@@ -64,7 +67,9 @@
 #  undef FLT_MIN
 #  undef DBL_MIN
 #  undef LDBL_MIN
-#  if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus 
>= 201703L
+#  if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) ||  
\
+  __cplusplus >= 201703L ||
\
+  (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #undef FLT_TRUE_MIN
 #undef DBL_TRUE_MIN
 #undef LDBL_TRUE_MIN
@@ -87,7 +92,9 @@
 #define DBL_MANT_DIG __DBL_MANT_DIG__
 #define LDBL_MANT_DIG __LDBL_MANT_DIG__
 
-#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201103L
+#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) ||
\
+__cplusplus >= 201103L ||  
\
+(__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #  define DECIMAL_DIG __DECIMAL_DIG__
 #endif
 
@@ -123,7 +130,9 @@
 #define DBL_MIN __DBL_MIN__
 #define LDBL_MIN __LDBL_MIN__
 
-#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201703L
+#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) ||
\
+__cplusplus >= 201703L ||  
\
+(__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #  define FLT_TRUE_MIN __FLT_DENORM_MIN__
 #  define DBL_TRUE_MIN __DBL_DENORM_MIN__
 #  define LDBL_TRUE_MIN __LDBL_DENORM_MIN__


Index: clang/test/Headers/float-aix.c
===
--- /dev/null
+++ clang/test/Headers/float-aix.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -fsyntax-only -verify -internal-isystem %S/Inputs/include %s
+// expected-no-diagnostics
+
+#include 
+
+_Static_assert(FLOAT_LOCAL_DEF, "");
Index: clang/test/Headers/Inputs/include/float.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/float.h
@@ -0,0 +1,2 @@
+#pragma once
+#define FLOAT_LOCAL_DEF 1
Index: clang/lib/Headers/float.h
===
--- clang/lib/Headers/float.h
+++ clang/lib/Headers/float.h
@@ -14,10 +14,11 @@
  * additional definitions provided for Windows.
  * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
  *
- * Also fall back on Darwin to allow additional definitions and
+ * Also fall back on Darwin and AIX to allow additional 

[PATCH] D117935: [AIX][clang] include_next through clang provided float.h

2022-01-28 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 404083.
daltenty added a comment.

Use more unique macro name


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

https://reviews.llvm.org/D117935

Files:
  clang/lib/Headers/float.h
  clang/test/Headers/Inputs/include/float.h
  clang/test/Headers/float-aix.c


Index: clang/test/Headers/float-aix.c
===
--- /dev/null
+++ clang/test/Headers/float-aix.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -fsyntax-only -verify 
-internal-isystem %S/Inputs/include %s
+// expected-no-diagnostics
+
+#include 
+
+_Static_assert(ERSATZ_SYSTEM_FLOAT_H, "");
Index: clang/test/Headers/Inputs/include/float.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/float.h
@@ -0,0 +1,2 @@
+#pragma once
+#define ERSATZ_SYSTEM_FLOAT_H 1
Index: clang/lib/Headers/float.h
===
--- clang/lib/Headers/float.h
+++ clang/lib/Headers/float.h
@@ -14,10 +14,11 @@
  * additional definitions provided for Windows.
  * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
  *
- * Also fall back on Darwin to allow additional definitions and
+ * Also fall back on Darwin and AIX to allow additional definitions and
  * implementation-defined values.
  */
-#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
+#if (defined(__APPLE__) || defined(__MINGW32__) || defined(_MSC_VER) ||
\
+ defined(_AIX)) && 
\
 __STDC_HOSTED__ && __has_include_next()
 
 /* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level
@@ -37,7 +38,9 @@
 #  undef FLT_MANT_DIG
 #  undef DBL_MANT_DIG
 #  undef LDBL_MANT_DIG
-#  if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus 
>= 201103L
+#  if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) ||  
\
+  __cplusplus >= 201103L ||
\
+  (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #undef DECIMAL_DIG
 #  endif
 #  undef FLT_DIG
@@ -64,7 +67,9 @@
 #  undef FLT_MIN
 #  undef DBL_MIN
 #  undef LDBL_MIN
-#  if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus 
>= 201703L
+#  if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) ||  
\
+  __cplusplus >= 201703L ||
\
+  (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #undef FLT_TRUE_MIN
 #undef DBL_TRUE_MIN
 #undef LDBL_TRUE_MIN
@@ -87,7 +92,9 @@
 #define DBL_MANT_DIG __DBL_MANT_DIG__
 #define LDBL_MANT_DIG __LDBL_MANT_DIG__
 
-#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201103L
+#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) ||
\
+__cplusplus >= 201103L ||  
\
+(__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #  define DECIMAL_DIG __DECIMAL_DIG__
 #endif
 
@@ -123,7 +130,9 @@
 #define DBL_MIN __DBL_MIN__
 #define LDBL_MIN __LDBL_MIN__
 
-#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201703L
+#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) ||
\
+__cplusplus >= 201703L ||  
\
+(__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #  define FLT_TRUE_MIN __FLT_DENORM_MIN__
 #  define DBL_TRUE_MIN __DBL_DENORM_MIN__
 #  define LDBL_TRUE_MIN __LDBL_DENORM_MIN__


Index: clang/test/Headers/float-aix.c
===
--- /dev/null
+++ clang/test/Headers/float-aix.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -fsyntax-only -verify -internal-isystem %S/Inputs/include %s
+// expected-no-diagnostics
+
+#include 
+
+_Static_assert(ERSATZ_SYSTEM_FLOAT_H, "");
Index: clang/test/Headers/Inputs/include/float.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/float.h
@@ -0,0 +1,2 @@
+#pragma once
+#define ERSATZ_SYSTEM_FLOAT_H 1
Index: clang/lib/Headers/float.h
===
--- clang/lib/Headers/float.h
+++ clang/lib/Headers/float.h
@@ -14,10 +14,11 @@
  * additional definitions provided for Windows.
  * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
  *
- * Also fall back on Darwin to allow additional definitions and
+ * Also fall back on Darwin and AIX to allow additional definitions and
  * implementation-defined values.
  */
-#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
+#if (defined(__APPLE__) || defined(__MINGW32__) || defined(_MSC_VER) ||\
+ defined(_AIX)) &&  

[PATCH] D101759: [PowerPC] Scalar IBM MASS library conversion pass

2022-01-28 Thread Masoud Ataei via Phabricator via cfe-commits
masoud.ataei marked 7 inline comments as done.
masoud.ataei added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:386
+  if (TM.getOptLevel() == CodeGenOpt::Aggressive){
+setOperationAction(ISD::FSIN , MVT::f64, Custom);
+setOperationAction(ISD::FCOS , MVT::f64, Custom);

bmahjour wrote:
> what about tan, acos, and the others?
These are the list of math functions that llvm creates intrinsic call for them. 
There is no llvm intrinsic for tan, acos and other math functions which (exist 
in MASS and) are not in this list. 



Comment at: llvm/test/CodeGen/PowerPC/lower-intrinsics-afn-mass.ll:148
+
+attributes #1 = { "approx-func-fp-math"="true" }

bmahjour wrote:
> All the calls have `afn`why do we need this attribute? 
Removed



Comment at: llvm/test/CodeGen/PowerPC/lower-intrinsics-fast-mass.ll:148
+
+attributes #1 = { "no-infs-fp-math"="true" "no-nans-fp-math"="true" 
"no-signed-zeros-fp-math"="true" "approx-func-fp-math"="true" }

bmahjour wrote:
> do we need this attribute? Can we remove it or have separate tests for 
> functions with attributes?
Removed



Comment at: llvm/test/CodeGen/PowerPC/lower-intrinsics-mass-aix.ll:1
+; RUN: llc -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s
+

bmahjour wrote:
> We don't really need a separate aix file. Can we just add a run line with the 
> aix triple to `llvm/test/CodeGen/PowerPC/lower-intrinsics-nofast-mass.ll`?
Done



Comment at: llvm/test/CodeGen/PowerPC/lower-scalar-mass-fast.ll:796
+; Without nnan ninf afn nsz flags on the call instruction
+define float @acosf_f32_nofast(float %a) {
+; CHECK-LABEL: acosf_f32_nofast

bmahjour wrote:
> shouldn't the tests starting from here move to a different file? This test 
> file is called  ...mass-fast.ll so one would expect it only contains tests 
> with fast-math flag on.
Done



Comment at: 
llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-fast.ll:246
+; CHECK-LNX-NEXT:lfs 2, .LCPI4_0@toc@l(3)
+; CHECK-LNX-NEXT:bl __xl_powf_finite
+; CHECK-LNX-NEXT:nop

bmahjour wrote:
> How come pow -> sqrt conversion didn't happen here? 
Honestly, I am not sure why the conversion is not happening in this case. But 
without this patch we will get `powf` call (the conversion is not happening 
again). So this is a separate issue that someone needs to look at independent 
of this patch.



Comment at: 
llvm/test/CodeGen/PowerPC/pow-025-075-nointrinsic-scalar-mass-fast.ll:22
+; CHECK-LNX-NEXT:lfs 2, .LCPI0_0@toc@l(3)
+; CHECK-LNX-NEXT:bl __xl_powf_finite
+; CHECK-LNX-NEXT:nop

bmahjour wrote:
> so pow->sqrt translation never happens for non-intrinsic `pow`. Is that 
> expected? If so, are we planning to recognize these patterns inside 
> PPCGenScalarMASSEntries in the future and do the translation as part of that 
> transform?
Correct, pow->sqrt translation is not happening for none intrinsic cases. It is 
the case independent of this patch. I guess the reason is DAGCombiner only 
apply this optimization on llvm intrinsics. This is an issue that either we 
need to handle it in DAGCombiner (same as intrinsic one) or in MASS pass. I 
feel DAGCombiner is a better option and I think this is also a separate issue. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101759

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


[PATCH] D114639: Raise the minimum Visual Studio version to VS2019

2022-01-28 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon updated this revision to Diff 404076.
RKSimon added a comment.

fix cut+paste typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114639

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/UsersManual.rst
  lldb/docs/resources/build.rst
  lldb/docs/resources/test.rst
  llvm/cmake/modules/CheckCompilerVersion.cmake
  llvm/docs/CMake.rst
  llvm/docs/GettingStarted.rst
  llvm/docs/GettingStartedVS.rst
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/Compiler.h

Index: llvm/include/llvm/Support/Compiler.h
===
--- llvm/include/llvm/Support/Compiler.h
+++ llvm/include/llvm/Support/Compiler.h
@@ -77,12 +77,21 @@
 /// * 1916: VS2017, version 15.9
 /// * 1920: VS2019, version 16.0
 /// * 1921: VS2019, version 16.1
+/// * 1922: VS2019, version 16.2
+/// * 1923: VS2019, version 16.3
+/// * 1924: VS2019, version 16.4
+/// * 1925: VS2019, version 16.5
+/// * 1926: VS2019, version 16.6
+/// * 1927: VS2019, version 16.7
+/// * 1928: VS2019, version 16.8 + 16.9
+/// * 1929: VS2019, version 16.10 + 16.11
+/// * 1930: VS2022, version 17.0
 #ifdef _MSC_VER
 #define LLVM_MSC_PREREQ(version) (_MSC_VER >= (version))
 
-// We require at least MSVC 2017.
-#if !LLVM_MSC_PREREQ(1910)
-#error LLVM requires at least MSVC 2017.
+// We require at least VS 2019.
+#if !LLVM_MSC_PREREQ(1920)
+#error LLVM requires at least VS 2019.
 #endif
 
 #else
@@ -94,12 +103,8 @@
 /// Sadly, this is separate from just rvalue reference support because GCC
 /// and MSVC implemented this later than everything else. This appears to be
 /// corrected in MSVC 2019 but not MSVC 2017.
-#if __has_feature(cxx_rvalue_references) || defined(__GNUC__) ||   \
-LLVM_MSC_PREREQ(1920)
+/// FIXME: Remove LLVM_HAS_RVALUE_REFERENCE_THIS macro
 #define LLVM_HAS_RVALUE_REFERENCE_THIS 1
-#else
-#define LLVM_HAS_RVALUE_REFERENCE_THIS 0
-#endif
 
 /// Expands to '&' if ref-qualifiers for *this are supported.
 ///
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -65,7 +65,7 @@
 Changes to building LLVM
 
 
-* ...
+* Building LLVM with Visual Studio now requires version 2019 or later.
 
 Changes to TableGen
 ---
Index: llvm/docs/GettingStartedVS.rst
===
--- llvm/docs/GettingStartedVS.rst
+++ llvm/docs/GettingStartedVS.rst
@@ -36,7 +36,7 @@
 
 Hardware
 
-Any system that can adequately run Visual Studio 2017 is fine. The LLVM
+Any system that can adequately run Visual Studio 2019 is fine. The LLVM
 source tree including the git index consumes approximately 3GB.
 Object files, libraries and executables consume approximately 5GB in
 Release mode and much more in Debug mode. SSD drive and >16GB RAM are
@@ -45,13 +45,14 @@
 
 Software
 
-You will need `Visual Studio `_ 2017 or
-higher, with the latest Update installed. Visual Studio Community Edition
+You will need `Visual Studio `_ 2019 or
+later, with the latest Update installed. Visual Studio Community Edition
 suffices.
 
 You will also need the `CMake `_ build system since it
 generates the project files you will use to build with. CMake is bundled with
-Visual Studio 2019 so separate installation is not required.
+Visual Studio 2019 so separate installation is not required. If you do install
+CMake separately, Visual Studio 2022 will require CMake Version 3.21 or later.
 
 If you would like to run the LLVM tests you will need `Python
 `_. Version 3.6 and newer are known to work. You can
Index: llvm/docs/GettingStarted.rst
===
--- llvm/docs/GettingStarted.rst
+++ llvm/docs/GettingStarted.rst
@@ -238,7 +238,7 @@
 * Clang 3.5
 * Apple Clang 6.0
 * GCC 5.1
-* Visual Studio 2017
+* Visual Studio 2019
 
 Anything older than these toolchains *may* work, but will require forcing the
 build system with a special option and is not really a supported host platform.
@@ -273,8 +273,8 @@
 This section mostly applies to Linux and older BSDs. On macOS, you should
 have a sufficiently modern Xcode, or you will likely need to upgrade until you
 do. Windows does not have a "system compiler", so you must install either Visual
-Studio 2017 or a recent version of mingw64. FreeBSD 10.0 and newer have a modern
-Clang as the system compiler.
+Studio 2019 (or later), or a recent version of mingw64. FreeBSD 10.0 and newer
+have a modern Clang as the system compiler.
 
 However, some Linux distributions and some other or older BSDs sometimes have
 extremely old versions of GCC. These steps attempt to help you upgrade you
Index: llvm/docs/CMake.rst

[PATCH] D118493: [WIP]Set rpath on openmp executables

2022-01-28 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Testing manually looks good, provided there's no command line argument 
involved. -rpath even composes sanely, so doing this plus passing -Wl,rpath= 
results in multiple embedded rpaths. At a loss as to why changing Options.td is 
working so poorly, though it may be relevant that ninja thinks there's no work 
to do when the file changes. Trying things like:

def fno_openmp_add_rpath: Flag<["-"], "fno-openmp-add-rpath">, 
Flags<[NoArgumentUnused]>,

  HelpText<"Do not add -rpath with architecture-specific resource directory to 
the linker flags">;

which is a direct copy of fno_rtlib_add_path, didn't even bother changing the 
help text, and it's still missing from the clang executable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118493

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


[PATCH] D118493: [WIP]Set rpath on openmp executables

2022-01-28 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, jhuber6, tianshilei1992, ye-luo.
Herald added subscribers: guansong, yaxunl.
JonChesterfield requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Openmp executables need to find libomp and libomptarget at runtime.
This currently requires LD_LIBRARY_PATH or the user to specify rpath. Change
that to set the expected location of the openmp libraries in the install tree.

WIP because adding command line override to this is not working.
Even copy of existing options in Options.td with a minor rename doesn't
introduce new options in clang, haven't been able to work out why yet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118493

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h


Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -106,6 +106,9 @@
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 
+void addOpenMPRuntimeSpecificRPath(const ToolChain ,
+   const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList );
 void addArchSpecificRPath(const ToolChain , const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 /// Returns true, if an OpenMP runtime has been added.
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -645,6 +645,18 @@
  /*IsLTO=*/true);
 }
 
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain ,
+  const ArgList ,
+  ArgStringList ) {
+  // Default to clang lib / lib64 folder, i.e. the same location as device
+  // runtime
+  SmallString<256> DefaultLibPath =
+  llvm::sys::path::parent_path(TC.getDriver().Dir);
+  llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
+  CmdArgs.push_back("-rpath");
+  CmdArgs.push_back(Args.MakeArgString(DefaultLibPath));
+}
+
 void tools::addArchSpecificRPath(const ToolChain , const ArgList ,
  ArgStringList ) {
   // Enable -frtlib-add-rpath by default for the case of VE.
@@ -697,6 +709,9 @@
   if (RTKind == Driver::OMPRT_GOMP && GompNeedsRT)
   CmdArgs.push_back("-lrt");
 
+  if (RTKind == Driver::OMPRT_OMP)
+addOpenMPRuntimeSpecificRPath(TC, Args, CmdArgs);
+
   if (IsOffloadingHost)
 CmdArgs.push_back("-lomptarget");
 


Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -106,6 +106,9 @@
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 
+void addOpenMPRuntimeSpecificRPath(const ToolChain ,
+   const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList );
 void addArchSpecificRPath(const ToolChain , const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 /// Returns true, if an OpenMP runtime has been added.
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -645,6 +645,18 @@
  /*IsLTO=*/true);
 }
 
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain ,
+  const ArgList ,
+  ArgStringList ) {
+  // Default to clang lib / lib64 folder, i.e. the same location as device
+  // runtime
+  SmallString<256> DefaultLibPath =
+  llvm::sys::path::parent_path(TC.getDriver().Dir);
+  llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
+  CmdArgs.push_back("-rpath");
+  CmdArgs.push_back(Args.MakeArgString(DefaultLibPath));
+}
+
 void tools::addArchSpecificRPath(const ToolChain , const ArgList ,
  ArgStringList ) {
   // Enable -frtlib-add-rpath by default for the case of VE.
@@ -697,6 +709,9 @@
   if (RTKind == Driver::OMPRT_GOMP && GompNeedsRT)
   CmdArgs.push_back("-lrt");
 
+  if (RTKind == Driver::OMPRT_OMP)
+addOpenMPRuntimeSpecificRPath(TC, Args, CmdArgs);
+
   if (IsOffloadingHost)
 CmdArgs.push_back("-lomptarget");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114639: Raise the minimum Visual Studio version to VS2019

2022-01-28 Thread Stella Stamenova via Phabricator via cfe-commits
stella.stamenova added inline comments.



Comment at: lldb/docs/resources/build.rst:296
 
-  $ cmake -G "Visual Studio 15 2017 Win64" -Thost=x64  
+  $ cmake -G "Visual Studio 16 2019" -A x64 -T host=x64 -Thost=x64  
 

You accidentally added `-T host=x64` twice now. It can be included with or 
without the space, but it's only needed once.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114639

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


[PATCH] D118477: [NFC][AIX]Disable new pcm tests on AIX

2022-01-28 Thread Steven Wan 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 rG760e69223d83: [NFC][AIX]Disable new pcm tests on AIX 
(authored by stevewan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118477

Files:
  clang/test/ClangScanDeps/modules-symlink.c


Index: clang/test/ClangScanDeps/modules-symlink.c
===
--- clang/test/ClangScanDeps/modules-symlink.c
+++ clang/test/ClangScanDeps/modules-symlink.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
-// UNSUPPORTED: system-windows
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: system-windows, aix
 
 //--- cdb_pch.json
 [


Index: clang/test/ClangScanDeps/modules-symlink.c
===
--- clang/test/ClangScanDeps/modules-symlink.c
+++ clang/test/ClangScanDeps/modules-symlink.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
-// UNSUPPORTED: system-windows
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: system-windows, aix
 
 //--- cdb_pch.json
 [
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 760e692 - [NFC][AIX]Disable new pcm tests on AIX

2022-01-28 Thread Steven Wan via cfe-commits

Author: Steven Wan
Date: 2022-01-28T12:39:09-05:00
New Revision: 760e69223d83860ed4758f86a0de4686a8d51fd7

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

LOG: [NFC][AIX]Disable new pcm tests on AIX

Same as D114481, the PCH reader looks for a `__clangast` section in the 
precompiled module file, which isn't present on AIX, and we don't support 
writing this custom section in XCOFF yet.

Reviewed By: Jake-Egan, daltenty, sfertile

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

Added: 


Modified: 
clang/test/ClangScanDeps/modules-symlink.c

Removed: 




diff  --git a/clang/test/ClangScanDeps/modules-symlink.c 
b/clang/test/ClangScanDeps/modules-symlink.c
index 46831b0a3fc00..5b628175560d2 100644
--- a/clang/test/ClangScanDeps/modules-symlink.c
+++ b/clang/test/ClangScanDeps/modules-symlink.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
-// UNSUPPORTED: system-windows
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: system-windows, aix
 
 //--- cdb_pch.json
 [



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


[PATCH] D109977: LLVM Driver Multicall tool

2022-01-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping @beanz


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D116542: [OpenMP] Add a flag for embedding a file into the module

2022-01-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 404047.
jhuber6 added a comment.

Changing the name to be the section name. This ensures that if the sections get 
merged we will get a linker error without failing silently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116542

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/CodeGen/BackendUtil.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/Frontend/embed-object.ll
  llvm/include/llvm/Bitcode/BitcodeWriter.h
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/Bitcode/Writer/CMakeLists.txt

Index: llvm/lib/Bitcode/Writer/CMakeLists.txt
===
--- llvm/lib/Bitcode/Writer/CMakeLists.txt
+++ llvm/lib/Bitcode/Writer/CMakeLists.txt
@@ -11,6 +11,7 @@
   Analysis
   Core
   MC
+  TransformUtils
   Object
   Support
   )
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -69,6 +69,7 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/SHA1.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/Utils/ModuleUtils.h"
 #include 
 #include 
 #include 
@@ -4973,3 +4974,22 @@
   llvm::ConstantArray::get(ATy, UsedArray), "llvm.compiler.used");
   NewUsed->setSection("llvm.metadata");
 }
+
+void llvm::EmbedBufferInModule(llvm::Module , llvm::MemoryBufferRef Buf,
+   StringRef SectionName) {
+  ArrayRef ModuleData =
+  ArrayRef(Buf.getBufferStart(), Buf.getBufferSize());
+
+  // Embed the buffer into the module. These sections are not supposed to be
+  // merged by the linker, so we set the variable name to prevent linking if
+  // they would otherwise be merged.
+  llvm::Constant *ModuleConstant =
+  llvm::ConstantDataArray::get(M.getContext(), ModuleData);
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+  M, ModuleConstant->getType(), true, llvm::GlobalValue::ExternalLinkage,
+  ModuleConstant, SectionName);
+  GV->setVisibility(GlobalValue::HiddenVisibility);
+  GV->setSection(SectionName);
+
+  appendToCompilerUsed(M, GV);
+}
Index: llvm/include/llvm/Bitcode/BitcodeWriter.h
===
--- llvm/include/llvm/Bitcode/BitcodeWriter.h
+++ llvm/include/llvm/Bitcode/BitcodeWriter.h
@@ -165,6 +165,11 @@
 bool EmbedCmdline,
 const std::vector );
 
+  /// Embeds the memory buffer \p Buf into the module \p M as a global using the
+  /// section name \p SectionName.
+  void EmbedBufferInModule(Module , MemoryBufferRef Buf,
+   StringRef SectionName);
+
 } // end namespace llvm
 
 #endif // LLVM_BITCODE_BITCODEWRITER_H
Index: clang/test/Frontend/embed-object.ll
===
--- /dev/null
+++ clang/test/Frontend/embed-object.ll
@@ -0,0 +1,15 @@
+; RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+; RUN:-fembed-offload-object=%S/Inputs/empty.h,section1 \
+; RUN:-fembed-offload-object=%S/Inputs/empty.h,section2 -x ir %s -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK
+
+; CHECK: @[[OBJECT1:.+]] = hidden constant [0 x i8] zeroinitializer, section ".llvm.offloading.section1"
+; CHECK: @[[OBJECT2:.+]] = hidden constant [0 x i8] zeroinitializer, section ".llvm.offloading.section2"
+; CHECK: @llvm.compiler.used = appending global [3 x i8*] [i8* @x, i8* getelementptr inbounds ([0 x i8], [0 x i8]* @[[OBJECT1]], i32 0, i32 0), i8* getelementptr inbounds ([0 x i8], [0 x i8]* @[[OBJECT2]], i32 0, i32 0)], section "llvm.metadata"
+
+@x = private constant i8 1
+@llvm.compiler.used = appending global [1 x i8*] [i8* @x], section "llvm.metadata"
+
+define i32 @foo() {
+  ret i32 0
+}
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -1134,6 +1134,7 @@
 TheModule->setTargetTriple(TargetOpts.Triple);
   }
 
+  EmbedObject(TheModule.get(), CodeGenOpts, Diagnostics);
   EmbedBitcode(TheModule.get(), CodeGenOpts, *MainFile);
 
   LLVMContext  = TheModule->getContext();
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1750,3 +1750,25 @@
   CGOpts.getEmbedBitcode() != CodeGenOptions::Embed_Bitcode,
   CGOpts.CmdArgs);
 }
+
+void clang::EmbedObject(llvm::Module *M, const CodeGenOptions ,
+DiagnosticsEngine ) {
+  if (CGOpts.OffloadObjects.empty())
+return;
+
+  for (StringRef OffloadObject : 

  1   2   >