[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-01 Thread Josh Haberman via Phabricator via cfe-commits
haberman added a comment.

I added tests for all the cases you mentioned. PTAL.




Comment at: clang/lib/CodeGen/CGCall.cpp:5315-5317
+// TODO(haberman): insert checks/assertions to verify that this early exit
+// is safe. We tried to verify this in Sema but we should double-check
+// here.

rsmith wrote:
> haberman wrote:
> > aaron.ballman wrote:
> > > Are you planning to handle this TODO in the patch? If not, can you switch 
> > > to a FIXME without a name associated with it?
> > I am interested in feedback on the best way to proceed here.
> > 
> >   - Is my assessment correct that we should have an assertion that 
> > validates this?
> >   - Is such an assertion reasonably feasible to implement?
> >   - Is it ok to defer with FIXME, or should I try to fix it in this patch?
> > 
> > I've changed it to a FIXME for now.
> Yes, I think we should validate this by an assertion if we can. We can check 
> this by walking the cleanup scope stack (walk from `CurrentCleanupScopeDepth` 
> to `EHScopeStack::stable_end()`) and making sure that there is no 
> "problematic" enclosing cleanup scope. Here, "problematic" would mean any 
> scope other than an `EHCleanupScope` containing only `CallLifetimeEnd` 
> cleanups.
> 
> Looking at the kinds of cleanups that we might encounter here, I think there 
> may be a few more things that Sema needs to check in order to not get in the 
> way of exception handling. In particular, I think we should reject if the 
> callee is potentially-throwing and the musttail call is inside a try block or 
> a function that's either noexcept or has a dynamic exception specification.
> 
> Oh, also, we should disallow musttail calls inside statement expressions, in 
> order to defend against cleanups that exist transiently within an expression.
I'm having trouble implementing the check because there doesn't appear to be 
any discriminator in `EHScopeStack::Cleanup` that will let you test if it is a 
`CallLifetimeEnd`. (The actual code just does virtual dispatch through 
`EHScopeStack::Cleanup::Emit()`.

I temporarily implemented this by adding an extra virtual function to act as 
discriminator. The check fires if a VLA is in scope:

```
int Func14(int x) {
  int vla[x];
  [[clang::musttail]] return Bar(x);
}
```

Do we need to forbid VLAs or do I need to refine the check?

It appears that `JumpDiagnostics.cpp` is already diagnosing statement 
expressions and `try`. However I could not get testing to work. I tried adding 
a test with `try`  but even with `-fexceptions` I am getting:

```
cannot use 'try' with exceptions disabled
```



Comment at: clang/lib/CodeGen/CGExpr.cpp:4828
  ReturnValueSlot ReturnValue) {
+  SaveAndRestore SaveMustTail(InMustTailCallExpr, E == MustTailCall);
+

rsmith wrote:
> The more I think about this, the more it makes me nervous: if any of the 
> `Emit*CallExpr` functions below incidentally emit a call on the way to 
> producing their results via the CGCall machinery, and do so without recursing 
> through this function, that incidental call will be emitted as a tail call 
> instead of the intended one. Specifically:
> 
> -- I could imagine a block call involving multiple function calls, depending 
> on the blocks ABI.
> -- I could imagine a member call performing a function call to convert from 
> derived to virtual base in some ABIs.
> -- A CUDA kernel call in general involves calling a setup function before the 
> actual function call happens (and it doesn't make sense for a CUDA kernel 
> call to be a tail call anyway...)
> -- A call to a builtin can result in any number of function calls.
> -- If any expression in the function arguments emits a call without calling 
> back into this function, we'll emit that call as a tail call instead of this 
> one. Eg, `[[clang::musttail]] return f(dynamic_cast(p));` might emit the 
> call to `__cxa_dynamic_cast` as the tail call instead of emitting the call to 
> `f` as the tail call, depending on whether the CGCall machinery is used when 
> emitting the `__cxa_dynamic_cast` call.
> 
> Is it feasible to sink this check into the `CodeGenFunction::EmitCall` 
> overload that takes a `CallExpr`, 
> `CodeGenFunction::EmitCXXMemberOrOperatorCall`, and 
> `CodeGenFunction::EmitCXXMemberPointerCallExpr`, after we've emitted the 
> callee and call args? It looks like we might be able to check this 
> immediately before calling the CGCall overload of `EmitCall`, so we could 
> pass in the 'musttail' information as a flag or similar instead of using 
> global state in the `CodeGenFunction` object; if so, it'd be much easier to 
> be confident that we're applying the attribute to the right call.
Done. It's feeling like `IsMustTail`, `callOrInvoke`, and `Loc` might want to 
get collapsed into an options struct, especially given the default parameters 
on the first two. Maybe could do as a follow up?




[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-01 Thread Josh Haberman via Phabricator via cfe-commits
haberman updated this revision to Diff 334890.
haberman marked 6 inline comments as done.
haberman added a comment.

- Addressed more comments for musttail.
- Reject constructors and destructors from musttail.
- Fixed a few bugs and fixed the tests.
- Added Obj-C test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/EHScopeStack.h
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/CodeGen/attr-musttail.cpp
  clang/test/Sema/attr-musttail.c
  clang/test/Sema/attr-musttail.cpp
  clang/test/Sema/attr-musttail.m

Index: clang/test/Sema/attr-musttail.m
===
--- /dev/null
+++ clang/test/Sema/attr-musttail.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+void TestObjcBlock(void) {
+  void (^x)(void) = ^(void) {
+__attribute__((musttail)) return TestObjcBlock(); // expected-error{{'musttail' attribute cannot be used from Objective-C blocks}}
+  };
+  __attribute__((musttail)) return x();
+}
Index: clang/test/Sema/attr-musttail.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-musttail.cpp
@@ -0,0 +1,189 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fms-extensions -fexceptions %s
+
+int ReturnsInt1();
+int Func1() {
+  [[clang::musttail]] ReturnsInt1();   // expected-error {{'musttail' attribute only applies to return statements}}
+  [[clang::musttail(1, 2)]] return ReturnsInt1(); // expected-error {{'musttail' attribute takes no arguments}}
+  [[clang::musttail]] return 5;// expected-error {{'musttail' attribute requires that the return value is the result of a function call}}
+  [[clang::musttail]] return ReturnsInt1();
+}
+
+[[clang::musttail]] static int int_val = ReturnsInt1(); // expected-error {{'musttail' attribute cannot be applied to a declaration}}
+
+void NoParams(); // expected-note {{target function has different number of parameters (expected 1 but has 0)}}
+void TestParamArityMismatch(int x) {
+  [[clang::musttail]] return NoParams(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+void LongParam(long x); // expected-note {{target function has type mismatch at 1st parameter (expected 'long' but has 'int')}}
+void TestParamTypeMismatch(int x) {
+  [[clang::musttail]] return LongParam(x); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+long ReturnsLong(); // expected-note {{target function has different return type ('int' expected but has 'long')}}
+int TestReturnTypeMismatch() {
+  [[clang::musttail]] return ReturnsLong(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+struct Struct1 {
+  void MemberFunction(); // expected-note {{target function is a member of different class (expected 'void' but has 'Struct1')}}
+};
+void TestNonMemberToMember() {
+  Struct1 st;
+  [[clang::musttail]] return st.MemberFunction(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+void ReturnsVoid(); // expected-note {{target function is a member of different class (expected 'Struct2' but has 'void')}}
+struct Struct2 {
+  void TestMemberToNonMember() {
+[[clang::musttail]] return ReturnsVoid(); // expected-error{{'musttail' attribute requires that caller and callee have compatible function signatures}}
+  }
+};
+
+class HasNonTrivialDestructor {
+public:
+  ~HasNonTrivialDestructor() {}
+  int ReturnsInt();
+};
+
+void ReturnsVoid2();
+void TestNonTrivialDestructorInScope() {
+  HasNonTrivialDestructor foo;  // expected-note {{jump exits scope of variable with non-trivial destructor}}
+  [[clang::musttail]] return ReturnsVoid(); // expected-error {{'musttail' attribute requires that all variables in scope are trivially destructible}}
+}
+
+int NonTrivialParam(HasNonTrivialDestructor x);
+int TestNonTrivialParam(HasNonTrivialDestructor x) {
+  [[clang::musttail]] return NonTrivialParam(x); // expected-error {{'musttail' attribute requires that the return value, all parameters, and any temporaries created by the expression are trivially destructible and do not require ARC}}
+}
+
+HasNonTrivialDestructor ReturnsNonTrivialValue();
+HasNonTrivialDestructor TestReturnsNonTrivialValue() 

[PATCH] D97669: [clang][AVR] Add avr-libc/include to clang system include paths

2021-04-01 Thread Ben Shi via Phabricator via cfe-commits
benshi001 marked an inline comment as done.
benshi001 added inline comments.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:356
 
+void AVRToolChain::AddClangSystemIncludeArgs(const ArgList ,
+ ArgStringList ) const {

Anastasia wrote:
> function name doesn't adhere to the coding style.
Not sure your concern ? Other platforms also use the same function name.

```
void RISCVToolChain::AddClangSystemIncludeArgs(const ArgList ,
   ArgStringList ) const {
void Linux::AddClangSystemIncludeArgs(const ArgList ,
  ArgStringList ) const {
void WebAssembly::AddClangSystemIncludeArgs(const ArgList ,
ArgStringList ) const {
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97669

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


[PATCH] D99658: [analyzer] Fix clang_analyzer_getExtent for heap regions

2021-04-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

What about `clang_analyzer_getExtent([2])` then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99658

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


[PATCH] D99659: [analyzer][taint] Extent of heap regions should get taint sometimes

2021-04-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

This will be obsoleted by D69726  because they 
are going to be the same symbol to begin with.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99659

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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2021-04-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

I don't see any further bugs so I think this is good to go!

I think you should separate out the NFC / debugging facility changes before 
committing.




Comment at: clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp:294
+
+  SmallString<128> Msg;
+  llvm::raw_svector_ostream Out(Msg);

128 is too much imho :)


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

https://reviews.llvm.org/D69726

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


[PATCH] D99237: [AVR][clang] Fix wrong calling convention in functions return struct type

2021-04-01 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 334885.

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

https://reviews.llvm.org/D99237

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/avr/struct.c


Index: clang/test/CodeGen/avr/struct.c
===
--- /dev/null
+++ clang/test/CodeGen/avr/struct.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm %s -o - | FileCheck %s
+
+// Structure that is more than 8 bytes.
+struct s10 {
+  int a, b, c, d, e;
+};
+
+// Structure that is less than 8 bytes.
+struct s06 {
+  int a, b, c;
+};
+
+struct s10 foo10(int a, int b, int c) {
+struct s10 a0;
+return a0;
+}
+
+struct s06 foo06(int a, int b, int c) {
+struct s06 a0;
+return a0;
+}
+
+// CHECK: %struct.s10 = type { i16, i16, i16, i16, i16 }
+// CHECK: %struct.s06 = type { i16, i16, i16 }
+// CHECK: define{{.*}} void @foo10(%struct.s10* {{.*}}, i16 %a, i16 %b, i16 %c)
+// CHECK: define{{.*}} %struct.s06 @foo06(i16 %a, i16 %b, i16 %c)
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8087,14 +8087,39 @@
 }
 
 
//===--===//
-// AVR ABI Implementation.
+// AVR ABI Implementation. Documented at
+// https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention
+// https://gcc.gnu.org/wiki/avr-gcc#Reduced_Tiny
 
//===--===//
 
 namespace {
+class AVRABIInfo : public DefaultABIInfo {
+public:
+  AVRABIInfo(CodeGenTypes ) : DefaultABIInfo(CGT) {}
+
+  ABIArgInfo classifyReturnType(QualType Ty) const {
+// A return struct with size less equal than 8 bytes is returned
+// directly via registers R18-R25.
+if (isAggregateTypeForABI(Ty) && getContext().getTypeSize(Ty) <= 64)
+  return ABIArgInfo::getDirect();
+else
+  return DefaultABIInfo::classifyReturnType(Ty);
+  }
+
+  // Just copy the original implementation of DefaultABIInfo::computeInfo(),
+  // since DefaultABIInfo::classify{Return,Argument}Type() are not virtual.
+  void computeInfo(CGFunctionInfo ) const override {
+if (!getCXXABI().classifyReturnType(FI))
+  FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+for (auto  : FI.arguments())
+  I.info = classifyArgumentType(I.type);
+  }
+};
+
 class AVRTargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   AVRTargetCodeGenInfo(CodeGenTypes )
-  : TargetCodeGenInfo(std::make_unique(CGT)) {}
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override {


Index: clang/test/CodeGen/avr/struct.c
===
--- /dev/null
+++ clang/test/CodeGen/avr/struct.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm %s -o - | FileCheck %s
+
+// Structure that is more than 8 bytes.
+struct s10 {
+  int a, b, c, d, e;
+};
+
+// Structure that is less than 8 bytes.
+struct s06 {
+  int a, b, c;
+};
+
+struct s10 foo10(int a, int b, int c) {
+struct s10 a0;
+return a0;
+}
+
+struct s06 foo06(int a, int b, int c) {
+struct s06 a0;
+return a0;
+}
+
+// CHECK: %struct.s10 = type { i16, i16, i16, i16, i16 }
+// CHECK: %struct.s06 = type { i16, i16, i16 }
+// CHECK: define{{.*}} void @foo10(%struct.s10* {{.*}}, i16 %a, i16 %b, i16 %c)
+// CHECK: define{{.*}} %struct.s06 @foo06(i16 %a, i16 %b, i16 %c)
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8087,14 +8087,39 @@
 }
 
 //===--===//
-// AVR ABI Implementation.
+// AVR ABI Implementation. Documented at
+// https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention
+// https://gcc.gnu.org/wiki/avr-gcc#Reduced_Tiny
 //===--===//
 
 namespace {
+class AVRABIInfo : public DefaultABIInfo {
+public:
+  AVRABIInfo(CodeGenTypes ) : DefaultABIInfo(CGT) {}
+
+  ABIArgInfo classifyReturnType(QualType Ty) const {
+// A return struct with size less equal than 8 bytes is returned
+// directly via registers R18-R25.
+if (isAggregateTypeForABI(Ty) && getContext().getTypeSize(Ty) <= 64)
+  return ABIArgInfo::getDirect();
+else
+  return DefaultABIInfo::classifyReturnType(Ty);
+  }
+
+  // Just copy the original implementation of DefaultABIInfo::computeInfo(),
+  // since DefaultABIInfo::classify{Return,Argument}Type() are not virtual.
+  void computeInfo(CGFunctionInfo ) const override {
+if (!getCXXABI().classifyReturnType(FI))
+  FI.getReturnInfo() = 

[PATCH] D99712: [RISCV] [2/2] Add intrinsic for Zbc extension

2021-04-01 Thread LevyHsu via Phabricator via cfe-commits
LevyHsu updated this revision to Diff 334883.
LevyHsu added a comment.

1. clang/lib/Headers/riscv_zbc_intrin.h
  - Renaming clmul_h clmul_r to clmulh clmulr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99712

Files:
  clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/riscv_zbc_intrin.h
  clang/lib/Headers/rvintrin.h
  clang/test/Headers/rvintrin.c

Index: clang/test/Headers/rvintrin.c
===
--- /dev/null
+++ clang/test/Headers/rvintrin.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple riscv32 -fsyntax-only \
+// RUN:   -target-feature +experimental-zbc %s
+// RUN: %clang_cc1 -triple riscv64 -fsyntax-only \
+// RUN:   -target-feature +experimental-zbc %s
+
+#include 
Index: clang/lib/Headers/rvintrin.h
===
--- /dev/null
+++ clang/lib/Headers/rvintrin.h
@@ -0,0 +1,26 @@
+/*=== rvintrin.h ---===
+ *
+ * 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
+ *
+ *===---===
+ */
+
+#ifndef __RVINTRIN_H
+#define __RVINTRIN_H
+
+#define int_xlen_t long
+#define uint_xlen_t unsigned int_xlen_t
+
+#define __DEFAULT_FN_ATTRS \
+  __attribute__((__always_inline__, __artificial__, __nodebug__))
+
+#if defined(__riscv_zbc)
+#include "riscv_zbc_intrin.h"
+#endif
+
+#undef __DEFAULT_FN_ATTRS
+#undef uint_xlen_t
+#undef int_xlen_t
+#endif // __RVINTRIN_H
Index: clang/lib/Headers/riscv_zbc_intrin.h
===
--- /dev/null
+++ clang/lib/Headers/riscv_zbc_intrin.h
@@ -0,0 +1,38 @@
+/*=== riscv_zbc_intrin.h ---===
+ *
+ * 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
+ *
+ *===---===
+ */
+
+#ifndef __RVINTRIN_H
+#error "Never use  directly;include  instead."
+#endif
+
+#ifndef __RISCV_ZBC_INTRIN_H
+#define __RISCV_ZBC_INTRIN_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+// Zbc
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_clmul(int_xlen_t rs1, int_xlen_t rs2) {
+  return __builtin_riscv_clmul(rs1, rs2);
+}
+
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_clmulh(int_xlen_t rs1, int_xlen_t rs2) {
+  return __builtin_riscv_clmulh(rs1, rs2);
+}
+
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_clmulr(int_xlen_t rs1, int_xlen_t rs2) {
+  return __builtin_riscv_clmulr(rs1, rs2);
+}
+
+#if defined(__cplusplus)
+}
+#endif // if defined(__cplusplus)
+
+#endif // __RISCV_ZBC_INTRIN_H
Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -97,6 +97,8 @@
   ptwriteintrin.h
   rdseedintrin.h
   rtmintrin.h
+  rvintrin.h
+  riscv_zbc_intrin.h
   serializeintrin.h
   sgxintrin.h
   s390intrin.h
Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -152,6 +152,8 @@
   {"include/prfchwintrin.h", ""},
   {"include/rdseedintrin.h", ""},
   {"include/rtmintrin.h", ""},
+  {"include/rvintrin.h", ""},
+  {"include/riscv_zbc_intrin.h", ""},
   {"include/shaintrin.h", ""},
   {"include/smmintrin.h", ""},
   {"include/stdalign.h", ""},
Index: clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
===
--- clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
+++ clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
@@ -57,6 +57,8 @@
   {"include/prfchwintrin.h$", ""},
   {"include/rdseedintrin.h$", ""},
   {"include/rtmintrin.h$", ""},
+  {"include/rvintrin.h$", ""},
+  {"include/riscv_zbc_intrin.h$", ""},
   {"include/shaintrin.h$", ""},
   {"include/smmintrin.h$", ""},
   {"include/stdalign.h$", ""},
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99711: [RISCV] [1/2] Add intrinsic for Zbc extension

2021-04-01 Thread LevyHsu via Phabricator via cfe-commits
LevyHsu updated this revision to Diff 334882.
LevyHsu marked 2 inline comments as done.
LevyHsu added a comment.

1. clang/include/clang/Basic/BuiltinsRISCV.def clang/lib/CodeGen/CGBuiltin.cpp 
llvm/include/llvm/IR/IntrinsicsRISCV.td 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbc.c
  - Renaming clmul_h clmul_r to clmulh clmulr

2. llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll 
llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll
  - Renaming clmul.h clmul.r to clmulh clmulr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99711

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbc.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoB.td
  llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll

Index: llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll
@@ -0,0 +1,53 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IB
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbc -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IBC
+
+declare i64 @llvm.riscv.clmul.i64(i64 %a, i64 %b)
+
+define i64 @clmul64(i64 %a, i64 %b) nounwind {
+; RV64IB-LABEL: clmul64:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:clmul a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBC-LABEL: clmul64:
+; RV64IBC:   # %bb.0:
+; RV64IBC-NEXT:clmul a0, a0, a1
+; RV64IBC-NEXT:ret
+  %tmp = call i64 @llvm.riscv.clmul.i64(i64 %a, i64 %b)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.clmulh.i64(i64 %a, i64 %b)
+
+define i64 @clmul64h(i64 %a, i64 %b) nounwind {
+; RV64IB-LABEL: clmul64h:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:clmulh a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBC-LABEL: clmul64h:
+; RV64IBC:   # %bb.0:
+; RV64IBC-NEXT:clmulh a0, a0, a1
+; RV64IBC-NEXT:ret
+  %tmp = call i64 @llvm.riscv.clmulh.i64(i64 %a, i64 %b)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.clmulr.i64(i64 %a, i64 %b)
+
+define i64 @clmul64r(i64 %a, i64 %b) nounwind {
+; RV64IB-LABEL: clmul64r:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:clmulr a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBC-LABEL: clmul64r:
+; RV64IBC:   # %bb.0:
+; RV64IBC-NEXT:clmulr a0, a0, a1
+; RV64IBC-NEXT:ret
+  %tmp = call i64 @llvm.riscv.clmulr.i64(i64 %a, i64 %b)
+ ret i64 %tmp
+}
Index: llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll
@@ -0,0 +1,53 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32IB
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbc -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32IBC
+
+declare i32 @llvm.riscv.clmul.i32(i32 %a, i32 %b)
+
+define i32 @clmul32(i32 %a, i32 %b) nounwind {
+; RV32IB-LABEL: clmul32:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:clmul a0, a0, a1
+; RV32IB-NEXT:ret
+;
+; RV32IBC-LABEL: clmul32:
+; RV32IBC:   # %bb.0:
+; RV32IBC-NEXT:clmul a0, a0, a1
+; RV32IBC-NEXT:ret
+  %tmp = call i32 @llvm.riscv.clmul.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.clmulh.i32(i32 %a, i32 %b)
+
+define i32 @clmul32h(i32 %a, i32 %b) nounwind {
+; RV32IB-LABEL: clmul32h:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:clmulh a0, a0, a1
+; RV32IB-NEXT:ret
+;
+; RV32IBC-LABEL: clmul32h:
+; RV32IBC:   # %bb.0:
+; RV32IBC-NEXT:clmulh a0, a0, a1
+; RV32IBC-NEXT:ret
+  %tmp = call i32 @llvm.riscv.clmulh.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.clmulr.i32(i32 %a, i32 %b)
+
+define i32 @clmul32r(i32 %a, i32 %b) nounwind {
+; RV32IB-LABEL: clmul32r:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:clmulr a0, a0, a1
+; RV32IB-NEXT:ret
+;
+; RV32IBC-LABEL: clmul32r:
+; RV32IBC:   # %bb.0:
+; RV32IBC-NEXT:clmulr a0, a0, a1
+; RV32IBC-NEXT:ret
+  %tmp = call i32 @llvm.riscv.clmulr.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
Index: llvm/lib/Target/RISCV/RISCVInstrInfoB.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -893,3 +893,9 @@
(srl (and GPR:$rs1, 0x), (i64 16,
   (PACKUW GPR:$rs1, 

[PATCH] D99711: [RISCV] [1/2] Add intrinsic for Zbc extension

2021-04-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsRISCV.def:22
+TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "experimental-zbc")
+TARGET_BUILTIN(__builtin_riscv_clmul_h, "LiLiLi", "nc", "experimental-zbc")
+TARGET_BUILTIN(__builtin_riscv_clmul_r, "LiLiLi", "nc", "experimental-zbc")

I think we should drop the underscore in clmul_h and clmul_r. The mnemonic 
doesn't have a period between them. So that's different than orc.b and crc32.w.



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:82
+def int_riscv_clmul : BitMan_GPRGPR_Intrinsics;
+def int_riscv_clmul_h : BitMan_GPRGPR_Intrinsics;
+def int_riscv_clmul_r : BitMan_GPRGPR_Intrinsics;

clmul_h -> clmulh
clmul_r -> clmulr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99711

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


[clang] f026e1f - [debug-info][XCOFF] set `-gno-column-info` by default for DBX

2021-04-01 Thread Chen Zheng via cfe-commits

Author: Chen Zheng
Date: 2021-04-01T21:29:11-04:00
New Revision: f026e1f5205562aad32e3d78b75140798b0dd60a

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

LOG: [debug-info][XCOFF] set `-gno-column-info` by default for DBX

For DBX, it does not handle column info well. Set -gno-column-info
by default for DBX.

Reviewed By: dblaikie

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/debug-options.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index ad5dca30e0f6a..30a0b090b6922 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3972,12 +3972,15 @@ static void renderDebugOptions(const ToolChain , 
const Driver ,
   // Column info is included by default for everything except SCE and
   // CodeView. Clang doesn't track end columns, just starting columns, which,
   // in theory, is fine for CodeView (and PDB).  In practice, however, the
-  // Microsoft debuggers don't handle missing end columns well, so it's better
-  // not to include any column info.
+  // Microsoft debuggers don't handle missing end columns well, and the AIX
+  // debugger DBX also doesn't handle the columns well, so it's better not to
+  // include any column info.
   if (const Arg *A = Args.getLastArg(options::OPT_gcolumn_info))
 (void)checkDebugInfoOption(A, Args, D, TC);
   if (!Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info,
-!EmitCodeView && DebuggerTuning != 
llvm::DebuggerKind::SCE))
+!EmitCodeView &&
+(DebuggerTuning != llvm::DebuggerKind::SCE &&
+ DebuggerTuning != llvm::DebuggerKind::DBX)))
 CmdArgs.push_back("-gno-column-info");
 
   // FIXME: Move backend command line options to the module.

diff  --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index d46ca8dd07263..00c748b1e936a 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -110,6 +110,16 @@
 // RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
 // RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DBX %s
 
+// On the AIX, -g defaults to -gno-column-info.
+// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=NOCI %s
+// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=NOCI %s
+// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff -gcolumn-info 2>&1 \
+// RUN: | FileCheck -check-prefix=CI %s
+// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff -gcolumn-info \
+// RUN: 2>&1 | FileCheck -check-prefix=CI %s
+
 // RUN: %clang -### -c -gdwarf-2 %s 2>&1 \
 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
 //



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


[PATCH] D98912: Fix -Winteger-overflow to diagnose regardless of the top-level syntactic form.

2021-04-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:972-973
 
+// Determine if we might warn that the given expression exhibits undefined
+// behavior.
+bool mightWarnOnUndefinedBehavior(const Expr *E) {

vsapsai wrote:
> I'm not entirely sure but it can be useful to make it explicit in the comment 
> the method doesn't deal with all the subexpressions recursively. Not 
> convinced it is useful because don't have a good wording and you can get that 
> information from the short method implementation. It is possible my 
> suggestion is caused by checking the patch top-to-bottom without seeing how 
> `mightWarnOnUndefinedBehavior` is used first, but that's not how developers 
> would read the code later.
Would renaming this to something like 
`shouldEvaluateForUndefinedBehaviorChecks` help? That still doesn't completely 
capture the non-recursive nature. I think improving the comment is a good idea 
regardless.



Comment at: clang/lib/AST/ExprConstant.cpp:8398-8399
 bool LValueExprEvaluator::VisitUnaryPreIncDec(const UnaryOperator *UO) {
-  if (!Info.getLangOpts().CPlusPlus14 && !Info.keepEvaluatingAfterFailure())
-return Error(UO);
 

vsapsai wrote:
> Just to confirm my understanding. There is no point in checking 
> `keepEvaluatingAfterFailure` here because we are not short-circuiting anymore 
> but can evaluate the expression in `VisitExpr(UO)`. And we still check 
> `keepEvaluatingAfterFailure` in `SubexpressionVisitor::Run` in 
> `EvaluateForDiagnostics`.
Yes, exactly.



Comment at: clang/lib/Sema/SemaExpr.cpp:7125-7126
   << DestTy;
-  return CK_IntegralCast;
+  Src = ExprError();
+  return CK_Dependent;
 case Type::STK_CPointer:

vsapsai wrote:
> What is the purpose of these changes to return `CK_Dependent`? Tests are 
> passing without them and it's not obvious to me why do you need to change 
> `CK_IntegralCast` to `CK_Dependent`.
It shouldn't matter what we return, because the caller should always bail out 
and ignore our return value if `Src` is set to an invalid expression. But in 
principle, `CK_IntegralCast` is wrong, because this situation doesn't meet the 
constraints for an integral cast. We use "dependent" to mean not only 
"dependent on a C++ template parameter" but also "dependent on an error", so 
that seemed like the least wrong cast kind for this situation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98912

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


[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-04-01 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a reviewer: dblaikie.
probinson added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1648
 
-  if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
+  if (Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))

I think we don't want this enabled by default at -O0.  It doesn't run any 
optimizations that should eliminate parameters, so this is going to increase 
debug info size for no real benefit to the debugging experience.


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

https://reviews.llvm.org/D99238

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


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

2021-04-01 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

FastISel is normally used only at -O0, I wouldn't expect any parameters to be 
optimized out at -O0.
The test is running llc with default optimization, which is -O2, and forcing 
fast-isel; this is not a usual combination and I wouldn't expect us to spend 
any effort making sure debug info works well with that combination.

If flang is forcing fast-isel even with optimization, that sounds like a 
problem for flang to solve, not LLVM.


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

https://reviews.llvm.org/D99160

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


[PATCH] D94355: [Passes] Add relative lookup table converter pass

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

> Would you be ok with reverting this change until I can sort that out, or can 
> we disable the pass for those targets until then?

I will disable the pass for those targets for now.
When the issue is resolved, I would like to enable it for those targets as well.




Comment at: llvm/test/Other/opt-O3-pipeline-enable-matrix.ll:322-323
 ; CHECK-NEXT:   Simplify the CFG
+; CHECK-NEXT: Relative Lookup Table Converter
+; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Annotation Remarks

aeubanks wrote:
> aeubanks wrote:
> > rnk wrote:
> > > Putting a ModulePass in the middle of the CodeGen pass pipeline creates a 
> > > "pass barrier": now instead of applying every pass to each function in 
> > > turn, the old pass manager will stop, run this whole-module pass, and 
> > > then run subseqeunt passes in the next function pass manager on each 
> > > function in turn. This isn't ideal. @aeubanks, can you follow-up to make 
> > > sure this is addressed?
> > > 
> > > We had the same issues with the SymbolRewriter pass, which if you grep 
> > > for "Rewrite Symbols" you can see has the same issue. I remember writing 
> > > a patch to fix it, but I guess I never landed it.
> > I see "Rewrite Symbols" in the codegen pipeline and yeah it's splitting the 
> > function pass manager.
> > 
> > For this patch, can we just not add the pass to the legacy PM pipeline? 
> > It's deprecated and the new PM is already the default for the optimization 
> > pipeline.
> (https://reviews.llvm.org/D99707 for anybody interested)
> For this patch, can we just not add the pass to the legacy PM pipeline? It's 
> deprecated and the new PM is already the default for the optimization 
> pipeline.
@rnk  @aeubanks
If it causes issues, I'm ok to remove it from the legacy PM pipeline.
When I land this patch, I'll only add it to new PM. 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[PATCH] D99661: [SemaObjC] Fix a -Wbridge-cast false-positive

2021-04-01 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

I agree with you. If it's not going to work, maybe there should have been a 
warning.


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

https://reviews.llvm.org/D99661

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2021-04-01 Thread Ten Tzen via Phabricator via cfe-commits
tentzen updated this revision to Diff 334855.
tentzen added a comment.

Removed some files (mostly for Part 2 of this feature) that were accidentally 
put in last revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/EHScopeStack.h
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
  clang/test/CodeGen/windows-seh-EHa-CppCondiTemps.cpp
  clang/test/CodeGen/windows-seh-EHa-CppDtors01.cpp
  clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/Verifier.cpp

Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -4223,6 +4223,10 @@
   Assert(
   !F->isIntrinsic() || isa(I) ||
   F->getIntrinsicID() == Intrinsic::donothing ||
+  F->getIntrinsicID() == Intrinsic::seh_try_begin ||
+  F->getIntrinsicID() == Intrinsic::seh_try_end ||
+  F->getIntrinsicID() == Intrinsic::seh_scope_begin ||
+  F->getIntrinsicID() == Intrinsic::seh_scope_end ||
   F->getIntrinsicID() == Intrinsic::coro_resume ||
   F->getIntrinsicID() == Intrinsic::coro_destroy ||
   F->getIntrinsicID() == Intrinsic::experimental_patchpoint_void ||
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -2789,6 +2789,10 @@
   llvm_unreachable("Cannot invoke this intrinsic");
 case Intrinsic::donothing:
   // Ignore invokes to @llvm.donothing: jump directly to the next BB.
+case Intrinsic::seh_try_begin:
+case Intrinsic::seh_scope_begin:
+case Intrinsic::seh_try_end:
+case Intrinsic::seh_scope_end:
   break;
 case Intrinsic::experimental_patchpoint_void:
 case Intrinsic::experimental_patchpoint_i64:
@@ -6583,6 +6587,10 @@
   lowerCallToExternalSymbol(I, FunctionName);
 return;
   case Intrinsic::donothing:
+  case Intrinsic::seh_try_begin:
+  case Intrinsic::seh_scope_begin:
+  case Intrinsic::seh_try_end:
+  case Intrinsic::seh_scope_end:
 // ignore
 return;
   case Intrinsic::experimental_stackmap:
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -456,6 +456,16 @@
  [llvm_ptr_ty, llvm_ptr_ty],
  [IntrNoMem]>;
 
+// To mark the beginning/end of a try-scope for Windows SEH -EHa
+//  calls/invokes to these intrinsics are placed to model control flows
+//caused by HW exceptions under option -EHa.
+//  calls/invokes to these intrinsics will be discarded during a codegen pass
+//   after EH tables are generated
+def int_seh_try_begin : Intrinsic<[], [], [IntrReadMem, IntrWriteMem, IntrWillReturn]>;
+def int_seh_try_end : Intrinsic<[], [], [IntrReadMem, IntrWriteMem, IntrWillReturn]>;
+def int_seh_scope_begin : Intrinsic<[], [], [IntrNoMem]>;
+def int_seh_scope_end : Intrinsic<[], [], [IntrNoMem]>;
+
 // Note: we treat stacksave/stackrestore as writemem because we don't otherwise
 // model their dependencies on allocas.
 def int_stacksave : Intrinsic<[llvm_ptr_ty]>,
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -11530,6 +11530,68 @@
 the escaped allocas are allocated, which would break attempts to use
 '``llvm.localrecover``'.
 
+'``llvm.seh.try.begin``' and '``llvm.seh.try.end``' Intrinsics
+^^
+
+Syntax:
+"""
+
+::
+
+  declare void @llvm.seh.try.begin()
+  declare void @llvm.seh.try.end()
+
+Overview:
+"
+
+The '``llvm.seh.try.begin``' and '``llvm.seh.try.end``' intrinsics mark
+the boundary of a _try region for Windows SEH Asynchrous Exception Handling.
+
+Semantics:
+""
+
+When a C-function is compiled 

[PATCH] D99775: [OpenMP, test] Fix use of undef VAR_PRIV FileCheck var

2021-04-01 Thread Thomas Preud'homme 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 rG2c3db73341ae: [OpenMP, test] Fix use of undef VAR_PRIV 
FileCheck var (authored by thopre).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99775

Files:
  clang/test/OpenMP/sections_reduction_codegen.cpp


Index: clang/test/OpenMP/sections_reduction_codegen.cpp
===
--- clang/test/OpenMP/sections_reduction_codegen.cpp
+++ clang/test/OpenMP/sections_reduction_codegen.cpp
@@ -210,7 +210,6 @@
 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** 
[[GTID_ADDR_ADDR]]
 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
 
-// CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
 // CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
 
 // CHECK: call void @__kmpc_for_static_init_4(


Index: clang/test/OpenMP/sections_reduction_codegen.cpp
===
--- clang/test/OpenMP/sections_reduction_codegen.cpp
+++ clang/test/OpenMP/sections_reduction_codegen.cpp
@@ -210,7 +210,6 @@
 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
 
-// CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
 // CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
 
 // CHECK: call void @__kmpc_for_static_init_4(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2c3db73 - [OpenMP, test] Fix use of undef VAR_PRIV FileCheck var

2021-04-01 Thread Thomas Preud'homme via cfe-commits

Author: Thomas Preud'homme
Date: 2021-04-02T00:39:21+01:00
New Revision: 2c3db73341aea084e44600400e9fe39690416923

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

LOG: [OpenMP, test] Fix use of undef VAR_PRIV FileCheck var

Remove the CHECK-NOT directive referring to as-of-yet undefined VAR_PRIV
variable since the pattern of the following CHECK-NOT in the same
CHECK-NOT block covers a superset of the case caught by the first
CHECK-NOT.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/test/OpenMP/sections_reduction_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/sections_reduction_codegen.cpp 
b/clang/test/OpenMP/sections_reduction_codegen.cpp
index 44e18c929b33..8154cac2aeb8 100644
--- a/clang/test/OpenMP/sections_reduction_codegen.cpp
+++ b/clang/test/OpenMP/sections_reduction_codegen.cpp
@@ -210,7 +210,6 @@ int main() {
 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** 
[[GTID_ADDR_ADDR]]
 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
 
-// CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
 // CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
 
 // CHECK: call void @__kmpc_for_static_init_4(



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


[PATCH] D99771: [OpenMP, test] Fix use of undef DECL FileCheck var

2021-04-01 Thread Thomas Preud'homme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG58e458935ba6: [OpenMP, test] Fix use of undef DECL FileCheck 
var (authored by thopre).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99771

Files:
  clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp


Index: clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
===
--- clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
+++ clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
@@ -29,7 +29,7 @@
   // CK1: store float* [[B_ADDR:%.+]], float** [[CBP]]
   // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
   // CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
-  // CK1-NOT: store float* [[VAL]], float** [[DECL]],
+  // CK1-NOT: store float* [[VAL]], float** {{%.+}},
   // CK1: store float* [[VAL]], float** [[PVT:%.+]],
   // CK1: [[TT:%.+]] = load float*, float** [[PVT]],
   // CK1: call i32 @__tgt_target{{.+}}[[MTYPE01]]


Index: clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
===
--- clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
+++ clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
@@ -29,7 +29,7 @@
   // CK1: store float* [[B_ADDR:%.+]], float** [[CBP]]
   // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
   // CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
-  // CK1-NOT: store float* [[VAL]], float** [[DECL]],
+  // CK1-NOT: store float* [[VAL]], float** {{%.+}},
   // CK1: store float* [[VAL]], float** [[PVT:%.+]],
   // CK1: [[TT:%.+]] = load float*, float** [[PVT]],
   // CK1: call i32 @__tgt_target{{.+}}[[MTYPE01]]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 58e4589 - [OpenMP, test] Fix use of undef DECL FileCheck var

2021-04-01 Thread Thomas Preud'homme via cfe-commits

Author: Thomas Preud'homme
Date: 2021-04-02T00:36:56+01:00
New Revision: 58e458935ba6debed11edd9baa98862db0a12651

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

LOG: [OpenMP, test] Fix use of undef DECL FileCheck var

OpenMP test target_data_use_device_ptr_if_codegen contains a CHECK-NOT
directive using an undefined DECL FileCheck variable. It seems copied
from target_data_use_device_ptr_codegen where there's a CHECK for a load
that defined the variable. Since there is no corresponding load in this
testcase, the simplest is to simply forbid any store and get rid of the
variable altogether.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp 
b/clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
index d423e212f05f..f25ca6babc11 100644
--- a/clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
+++ b/clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
@@ -29,7 +29,7 @@ void add_one(float *b, int dm)
   // CK1: store float* [[B_ADDR:%.+]], float** [[CBP]]
   // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
   // CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
-  // CK1-NOT: store float* [[VAL]], float** [[DECL]],
+  // CK1-NOT: store float* [[VAL]], float** {{%.+}},
   // CK1: store float* [[VAL]], float** [[PVT:%.+]],
   // CK1: [[TT:%.+]] = load float*, float** [[PVT]],
   // CK1: call i32 @__tgt_target{{.+}}[[MTYPE01]]



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


[PATCH] D99770: [OpenMP, test] Fix uses of undef S*VAR FileCheck var

2021-04-01 Thread Thomas Preud'homme 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 rGd222a07d3023: [OpenMP, test] Fix uses of undef S*VAR 
FileCheck var (authored by thopre).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99770

Files:
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_private_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/parallel_private_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  clang/test/OpenMP/sections_private_codegen.cpp
  clang/test/OpenMP/single_firstprivate_codegen.cpp
  clang/test/OpenMP/single_private_codegen.cpp
  clang/test/OpenMP/task_firstprivate_codegen.cpp
  clang/test/OpenMP/task_private_codegen.cpp
  clang/test/OpenMP/taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/taskloop_private_codegen.cpp
  clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/taskloop_simd_private_codegen.cpp

Index: clang/test/OpenMP/taskloop_simd_private_codegen.cpp
===
--- clang/test/OpenMP/taskloop_simd_private_codegen.cpp
+++ clang/test/OpenMP/taskloop_simd_private_codegen.cpp
@@ -93,6 +93,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
Index: clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
===
--- clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
+++ clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
@@ -101,6 +101,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
@@ -115,7 +116,7 @@
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
 // BLOCKS: store double 2.0{{.+}}, double*
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
-// BLOCKS-NOT: [[ISVAR]]{{[[^:word:]]}}
+// BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: store i{{[0-9]+}} 22, i{{[0-9]+}}*
 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: ret
Index: clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
+++ clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
@@ -102,6 +102,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
@@ -123,7 +124,7 @@
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
 // BLOCKS: store volatile double 2.0{{.+}}, double*
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
-// BLOCKS-NOT: [[ISVAR]]{{[[^:word:]]}}
+// BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: store i{{[0-9]+}} 22, i{{[0-9]+}}*
 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: ret
Index: clang/test/OpenMP/taskloop_private_codegen.cpp
===
--- clang/test/OpenMP/taskloop_private_codegen.cpp
+++ clang/test/OpenMP/taskloop_private_codegen.cpp
@@ -93,6 +93,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
Index: clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
===
--- clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
+++ clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
@@ -103,6 +103,7 @@
   return 0;
 #elif 

[clang] d222a07 - [OpenMP, test] Fix uses of undef S*VAR FileCheck var

2021-04-01 Thread Thomas Preud'homme via cfe-commits

Author: Thomas Preud'homme
Date: 2021-04-02T00:36:14+01:00
New Revision: d222a07d3023599b8090ed20ca9137b128f5af6c

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

LOG: [OpenMP, test] Fix uses of undef S*VAR FileCheck var

Fix the many cases of use of undefined SIVAR/SVAR/SFVAR in OpenMP
*private_codegen tests, due to a missing BLOCK directive to capture the
IR variable when it is declared. It also fixes a few typo in its use.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/test/OpenMP/for_firstprivate_codegen.cpp
clang/test/OpenMP/for_private_codegen.cpp
clang/test/OpenMP/master_taskloop_firstprivate_codegen.cpp
clang/test/OpenMP/master_taskloop_lastprivate_codegen.cpp
clang/test/OpenMP/master_taskloop_private_codegen.cpp
clang/test/OpenMP/master_taskloop_simd_firstprivate_codegen.cpp
clang/test/OpenMP/master_taskloop_simd_lastprivate_codegen.cpp
clang/test/OpenMP/master_taskloop_simd_private_codegen.cpp
clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_private_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_simd_private_codegen.cpp
clang/test/OpenMP/parallel_private_codegen.cpp
clang/test/OpenMP/sections_firstprivate_codegen.cpp
clang/test/OpenMP/sections_lastprivate_codegen.cpp
clang/test/OpenMP/sections_private_codegen.cpp
clang/test/OpenMP/single_firstprivate_codegen.cpp
clang/test/OpenMP/single_private_codegen.cpp
clang/test/OpenMP/task_firstprivate_codegen.cpp
clang/test/OpenMP/task_private_codegen.cpp
clang/test/OpenMP/taskloop_firstprivate_codegen.cpp
clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
clang/test/OpenMP/taskloop_private_codegen.cpp
clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
clang/test/OpenMP/taskloop_simd_private_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/for_firstprivate_codegen.cpp 
b/clang/test/OpenMP/for_firstprivate_codegen.cpp
index 510453afd2c7..d1fc55285044 100644
--- a/clang/test/OpenMP/for_firstprivate_codegen.cpp
+++ b/clang/test/OpenMP/for_firstprivate_codegen.cpp
@@ -147,6 +147,7 @@ int main() {
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global i{{[0-9]+}} 1212,
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{

diff  --git a/clang/test/OpenMP/for_private_codegen.cpp 
b/clang/test/OpenMP/for_private_codegen.cpp
index 63b7aab4e486..39052fb814a6 100644
--- a/clang/test/OpenMP/for_private_codegen.cpp
+++ b/clang/test/OpenMP/for_private_codegen.cpp
@@ -110,6 +110,8 @@ int main() {
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] = {{(dso_local )?}}global double
+  // BLOCKS: [[SVAR:@.+]] = internal global i{{[0-9]+}} 0,
+  // BLOCKS: [[SFVAR:@.+]] = internal global float 0.00e+00,
   // BLOCKS-LABEL: @main
   // BLOCKS: call {{.*}}void {{%.+}}(i8
   ^{

diff  --git a/clang/test/OpenMP/master_taskloop_firstprivate_codegen.cpp 
b/clang/test/OpenMP/master_taskloop_firstprivate_codegen.cpp
index 9aa1affc4bb5..35e7e4902be3 100644
--- a/clang/test/OpenMP/master_taskloop_firstprivate_codegen.cpp
+++ b/clang/test/OpenMP/master_taskloop_firstprivate_codegen.cpp
@@ -109,6 +109,7 @@ int main() {
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
@@ -137,7 +138,7 @@ int main() {
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
 // BLOCKS: store volatile double 2.0{{.+}}, double*
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
-// BLOCKS-NOT: [[ISVAR]]{{[[^:word:]]}}
+// BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: store i{{[0-9]+}} 22, i{{[0-9]+}}*
 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: ret

diff  --git a/clang/test/OpenMP/master_taskloop_lastprivate_codegen.cpp 
b/clang/test/OpenMP/master_taskloop_lastprivate_codegen.cpp
index a7d2d792af89..6fc76077d5b1 100644
--- a/clang/test/OpenMP/master_taskloop_lastprivate_codegen.cpp
+++ b/clang/test/OpenMP/master_taskloop_lastprivate_codegen.cpp
@@ -103,6 +103,7 @@ int main() {
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: 

[PATCH] D99775: [OpenMP, test] Fix use of undef VAR_PRIV FileCheck var

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

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99775

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


[PATCH] D99775: [OpenMP, test] Fix use of undef VAR_PRIV FileCheck var

2021-04-01 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre created this revision.
thopre added reviewers: ABataev, mikerice, jdoerfert, MaskRay.
Herald added subscribers: guansong, yaxunl.
thopre requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Remove the CHECK-NOT directive referring to as-of-yet undefined VAR_PRIV
variable since the pattern of the following CHECK-NOT in the same
CHECK-NOT block covers a superset of the case caught by the first
CHECK-NOT.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99775

Files:
  clang/test/OpenMP/sections_reduction_codegen.cpp


Index: clang/test/OpenMP/sections_reduction_codegen.cpp
===
--- clang/test/OpenMP/sections_reduction_codegen.cpp
+++ clang/test/OpenMP/sections_reduction_codegen.cpp
@@ -210,7 +210,6 @@
 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** 
[[GTID_ADDR_ADDR]]
 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
 
-// CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
 // CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
 
 // CHECK: call void @__kmpc_for_static_init_4(


Index: clang/test/OpenMP/sections_reduction_codegen.cpp
===
--- clang/test/OpenMP/sections_reduction_codegen.cpp
+++ clang/test/OpenMP/sections_reduction_codegen.cpp
@@ -210,7 +210,6 @@
 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
 
-// CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
 // CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
 
 // CHECK: call void @__kmpc_for_static_init_4(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99407: [clang][ItaniumMangle] Check SizeExpr for DependentSizedArrayType (PR49478)

2021-04-01 Thread Tommy Chiang via Phabricator via cfe-commits
oToToT updated this revision to Diff 334848.
oToToT added a comment.

Remove redundant trailing spaces.

Sorry for not checking this at the first time I submit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99407

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/unittests/AST/DeclTest.cpp


Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -104,3 +104,37 @@
   ASSERT_TRUE(0 == MangleF.compare("\x01" "foo"));
   ASSERT_TRUE(0 == MangleG.compare("goo"));
 }
+
+TEST(Decl, MangleDependentSizedArray) {
+  StringRef Code = R"(
+template 
+int A[] = {N...};
+
+template 
+struct S {
+  T B[N];
+};
+  )";
+  auto AST =
+  tooling::buildASTFromCodeWithArgs(Code, {"-target", 
"i386-apple-darwin"});
+  ASTContext  = AST->getASTContext();
+  assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
+ "Expected target to have a global prefix");
+  DiagnosticsEngine  = AST->getDiagnostics();
+
+  const auto *DeclA =
+  selectFirst("A", match(varDecl().bind("A"), Ctx));
+  const auto *DeclB =
+  selectFirst("B", match(fieldDecl().bind("B"), Ctx));
+
+  std::string MangleA, MangleB;
+  llvm::raw_string_ostream OS_A(MangleA), OS_B(MangleB);
+  std::unique_ptr MC(
+  ItaniumMangleContext::create(Ctx, Diags));
+
+  MC->mangleTypeName(DeclA->getType(), OS_A);
+  MC->mangleTypeName(DeclB->getType(), OS_B);
+
+  ASSERT_TRUE(0 == MangleA.compare("_ZTSA_i"));
+  ASSERT_TRUE(0 == MangleB.compare("_ZTSAT0__T_"));
+}
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3204,7 +3204,11 @@
 }
 void CXXNameMangler::mangleType(const DependentSizedArrayType *T) {
   Out << 'A';
-  mangleExpression(T->getSizeExpr());
+  // A DependentSizedArrayType might not have size expression as below
+  //
+  // template int arr[] = {N...};
+  if (T->getSizeExpr())
+mangleExpression(T->getSizeExpr());
   Out << '_';
   mangleType(T->getElementType());
 }


Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -104,3 +104,37 @@
   ASSERT_TRUE(0 == MangleF.compare("\x01" "foo"));
   ASSERT_TRUE(0 == MangleG.compare("goo"));
 }
+
+TEST(Decl, MangleDependentSizedArray) {
+  StringRef Code = R"(
+template 
+int A[] = {N...};
+
+template 
+struct S {
+  T B[N];
+};
+  )";
+  auto AST =
+  tooling::buildASTFromCodeWithArgs(Code, {"-target", "i386-apple-darwin"});
+  ASTContext  = AST->getASTContext();
+  assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
+ "Expected target to have a global prefix");
+  DiagnosticsEngine  = AST->getDiagnostics();
+
+  const auto *DeclA =
+  selectFirst("A", match(varDecl().bind("A"), Ctx));
+  const auto *DeclB =
+  selectFirst("B", match(fieldDecl().bind("B"), Ctx));
+
+  std::string MangleA, MangleB;
+  llvm::raw_string_ostream OS_A(MangleA), OS_B(MangleB);
+  std::unique_ptr MC(
+  ItaniumMangleContext::create(Ctx, Diags));
+
+  MC->mangleTypeName(DeclA->getType(), OS_A);
+  MC->mangleTypeName(DeclB->getType(), OS_B);
+
+  ASSERT_TRUE(0 == MangleA.compare("_ZTSA_i"));
+  ASSERT_TRUE(0 == MangleB.compare("_ZTSAT0__T_"));
+}
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3204,7 +3204,11 @@
 }
 void CXXNameMangler::mangleType(const DependentSizedArrayType *T) {
   Out << 'A';
-  mangleExpression(T->getSizeExpr());
+  // A DependentSizedArrayType might not have size expression as below
+  //
+  // template int arr[] = {N...};
+  if (T->getSizeExpr())
+mangleExpression(T->getSizeExpr());
   Out << '_';
   mangleType(T->getElementType());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cba4222 - [OpenMP51] Accept `primary` as proc bind affinity policy in Clang

2021-04-01 Thread via cfe-commits

Author: cchen
Date: 2021-04-01T18:07:12-05:00
New Revision: cba422264c7fdb7ba717144c94d48d46d72d8479

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

LOG: [OpenMP51] Accept `primary` as proc bind affinity policy in Clang

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/parallel_proc_bind_primary_codegen.cpp

Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/parallel_ast_print.cpp
clang/test/OpenMP/parallel_proc_bind_messages.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 48fe19e50ee7..4409df44d503 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -14133,10 +14133,21 @@ OMPClause 
*Sema::ActOnOpenMPProcBindClause(ProcBindKind Kind,
 Diag(KindKwLoc, diag::err_omp_unexpected_clause_value)
 << getListOfPossibleValues(OMPC_proc_bind,
/*First=*/unsigned(OMP_PROC_BIND_master),
-   /*Last=*/5)
+   /*Last=*/
+   unsigned(LangOpts.OpenMP > 50
+? OMP_PROC_BIND_primary
+: OMP_PROC_BIND_spread) +
+   1)
 << getOpenMPClauseName(OMPC_proc_bind);
 return nullptr;
   }
+  if (Kind == OMP_PROC_BIND_primary && LangOpts.OpenMP < 51)
+Diag(KindKwLoc, diag::err_omp_unexpected_clause_value)
+<< getListOfPossibleValues(OMPC_proc_bind,
+   /*First=*/unsigned(OMP_PROC_BIND_master),
+   /*Last=*/
+   unsigned(OMP_PROC_BIND_spread) + 1)
+<< getOpenMPClauseName(OMPC_proc_bind);
   return new (Context)
   OMPProcBindClause(Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
 }

diff  --git a/clang/test/OpenMP/parallel_ast_print.cpp 
b/clang/test/OpenMP/parallel_ast_print.cpp
index 0f309c0add05..3b055e9dfd56 100644
--- a/clang/test/OpenMP/parallel_ast_print.cpp
+++ b/clang/test/OpenMP/parallel_ast_print.cpp
@@ -5,6 +5,14 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only 
-verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -DOMP51 -verify -fopenmp -fopenmp-version=51 -ast-print %s 
| FileCheck -check-prefixes=CHECK,OMP51 %s
+// RUN: %clang_cc1 -DOMP51 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -DOMP51 -fopenmp -fopenmp-version=51 -std=c++11 
-include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck 
-check-prefixes=CHECK,OMP51 %s
+
+// RUN: %clang_cc1 -DOMP51 -verify -fopenmp-simd -fopenmp-version=51 
-ast-print %s | FileCheck -check-prefixes=CHECK,OMP51 %s
+// RUN: %clang_cc1 -DOMP51 -fopenmp-simd -fopenmp-version=51 -x c++ -std=c++11 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -DOMP51 -fopenmp-simd -fopenmp-version=51 -std=c++11 
-include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck 
-check-prefixes=CHECK,OMP51 %s
 // expected-no-diagnostics
 
 #ifndef HEADER
@@ -152,6 +160,10 @@ T tmain(T argc, T *argv) {
   a=2;
 #pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared 
(d) if (parallel:argc > 0) num_threads(C) copyin(S::TS, thrp) 
proc_bind(master) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10])
   foo();
+#ifdef OMP51
+#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared 
(d) if (parallel:argc > 0) num_threads(C) copyin(S::TS, thrp) 
proc_bind(primary) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10])
+  foo();
+#endif
 #pragma omp parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f, 
arr[0:C][:argc]) reduction(default, && : g) reduction(task,+:argc)
   foo();
   return 0;
@@ -166,6 +178,8 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) 
copyin(S::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) 
reduction(max: e,arr[:C][0:10])
 // CHECK-NEXT: foo()
+// OMP51-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) 
copyin(S::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) 
reduction(max: e,arr[:C][0:10])
+// OMP51-NEXT: foo()
 // CHECK-NEXT: #pragma omp parallel if(C) num_threads(s) proc_bind(close) 
reduction(^: e,f,arr[0:C][:argc]) 

[PATCH] D99622: [OpenMP51] Accept `primary` as proc bind affinity policy in Clang

2021-04-01 Thread Chi Chun Chen 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 rGcba422264c7f: [OpenMP51] Accept `primary` as proc bind 
affinity policy in Clang (authored by cchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99622

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_ast_print.cpp
  clang/test/OpenMP/parallel_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_proc_bind_primary_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -967,6 +967,7 @@
 __OMP_PROC_BIND_KIND(master, 2)
 __OMP_PROC_BIND_KIND(close, 3)
 __OMP_PROC_BIND_KIND(spread, 4)
+__OMP_PROC_BIND_KIND(primary, 5)
 __OMP_PROC_BIND_KIND(default, 6)
 __OMP_PROC_BIND_KIND(unknown, 7)
 
Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -103,13 +103,15 @@
 def OMP_PROC_BIND_master : ClauseVal<"master",2,1> {}
 def OMP_PROC_BIND_close : ClauseVal<"close",3,1> {}
 def OMP_PROC_BIND_spread : ClauseVal<"spread",4,1> {}
-def OMP_PROC_BIND_default : ClauseVal<"default",5,0> {}
-def OMP_PROC_BIND_unknown : ClauseVal<"unknown",6,0> { let isDefault = true; }
+def OMP_PROC_BIND_primary : ClauseVal<"primary",5,1> {}
+def OMP_PROC_BIND_default : ClauseVal<"default",6,0> {}
+def OMP_PROC_BIND_unknown : ClauseVal<"unknown",7,0> { let isDefault = true; }
 def OMPC_ProcBind : Clause<"proc_bind"> {
   let clangClass = "OMPProcBindClause";
   let flangClass = "OmpProcBindClause";
   let enumClauseValue = "ProcBindKind";
   let allowedClauseValues = [
+OMP_PROC_BIND_primary,
 OMP_PROC_BIND_master,
 OMP_PROC_BIND_close,
 OMP_PROC_BIND_spread,
Index: clang/test/OpenMP/parallel_proc_bind_primary_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/parallel_proc_bind_primary_codegen.cpp
@@ -0,0 +1,48 @@
+// expected-no-diagnostics
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+#ifndef HEADER
+#define HEADER
+
+typedef __INTPTR_TYPE__ intptr_t;
+
+// CHECK-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CHECK-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant [[IDENT_T_TY]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+void foo();
+
+template 
+T tmain() {
+#pragma omp parallel proc_bind(primary)
+  foo();
+  return T();
+}
+
+int main() {
+#pragma omp parallel proc_bind(primary)
+  foo();
+  return tmain();
+}
+
+// CHECK-LABEL: @main
+// CHECK:   [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEF_LOC_2]])
+// CHECK:   call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 5)
+// CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+
+// CHECK-LABEL: @{{.+}}tmain
+// CHECK:   [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEF_LOC_2]])
+// CHECK:   call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 5)
+// CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+// CHECK:   ret i32 0
+// CHECK-NEXT:  }
+
+#endif
+
Index: clang/test/OpenMP/parallel_proc_bind_messages.cpp
===
--- 

[PATCH] D99770: [OpenMP, test] Fix uses of undef S*VAR FileCheck var

2021-04-01 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre updated this revision to Diff 334846.
thopre added a comment.

Fix one more testcase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99770

Files:
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_private_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/parallel_private_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  clang/test/OpenMP/sections_private_codegen.cpp
  clang/test/OpenMP/single_firstprivate_codegen.cpp
  clang/test/OpenMP/single_private_codegen.cpp
  clang/test/OpenMP/task_firstprivate_codegen.cpp
  clang/test/OpenMP/task_private_codegen.cpp
  clang/test/OpenMP/taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/taskloop_private_codegen.cpp
  clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/taskloop_simd_private_codegen.cpp

Index: clang/test/OpenMP/taskloop_simd_private_codegen.cpp
===
--- clang/test/OpenMP/taskloop_simd_private_codegen.cpp
+++ clang/test/OpenMP/taskloop_simd_private_codegen.cpp
@@ -93,6 +93,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
Index: clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
===
--- clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
+++ clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
@@ -101,6 +101,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
@@ -115,7 +116,7 @@
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
 // BLOCKS: store double 2.0{{.+}}, double*
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
-// BLOCKS-NOT: [[ISVAR]]{{[[^:word:]]}}
+// BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: store i{{[0-9]+}} 22, i{{[0-9]+}}*
 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: ret
Index: clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
+++ clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
@@ -102,6 +102,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
@@ -123,7 +124,7 @@
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
 // BLOCKS: store volatile double 2.0{{.+}}, double*
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
-// BLOCKS-NOT: [[ISVAR]]{{[[^:word:]]}}
+// BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: store i{{[0-9]+}} 22, i{{[0-9]+}}*
 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: ret
Index: clang/test/OpenMP/taskloop_private_codegen.cpp
===
--- clang/test/OpenMP/taskloop_private_codegen.cpp
+++ clang/test/OpenMP/taskloop_private_codegen.cpp
@@ -93,6 +93,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
Index: clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
===
--- clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
+++ clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
@@ -103,6 +103,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // 

[PATCH] D99732: [AST] Pick last tentative definition as the acting definition

2021-04-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks, this makes sense.




Comment at: clang/lib/AST/Decl.cpp:2192
   DefinitionKind Kind = isThisDeclarationADefinition();
-  if (Kind != TentativeDefinition)
+  if (Kind != TentativeDefinition || hasDefinition())
 return nullptr;

Is there a good reason to switch from checking for a `Definition` in the loop 
to checking it ahead of time? This change means we'll do two passes over the 
redeclarations, and call `isThisDeclarationADefinition` twice for each, where 
the old approach only performed one pass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99732

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


[PATCH] D99622: [OpenMP51] Accept `primary` as proc bind affinity policy in Clang

2021-04-01 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 334844.
cchen added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99622

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_ast_print.cpp
  clang/test/OpenMP/parallel_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_proc_bind_primary_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -967,6 +967,7 @@
 __OMP_PROC_BIND_KIND(master, 2)
 __OMP_PROC_BIND_KIND(close, 3)
 __OMP_PROC_BIND_KIND(spread, 4)
+__OMP_PROC_BIND_KIND(primary, 5)
 __OMP_PROC_BIND_KIND(default, 6)
 __OMP_PROC_BIND_KIND(unknown, 7)
 
Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -103,13 +103,15 @@
 def OMP_PROC_BIND_master : ClauseVal<"master",2,1> {}
 def OMP_PROC_BIND_close : ClauseVal<"close",3,1> {}
 def OMP_PROC_BIND_spread : ClauseVal<"spread",4,1> {}
-def OMP_PROC_BIND_default : ClauseVal<"default",5,0> {}
-def OMP_PROC_BIND_unknown : ClauseVal<"unknown",6,0> { let isDefault = true; }
+def OMP_PROC_BIND_primary : ClauseVal<"primary",5,1> {}
+def OMP_PROC_BIND_default : ClauseVal<"default",6,0> {}
+def OMP_PROC_BIND_unknown : ClauseVal<"unknown",7,0> { let isDefault = true; }
 def OMPC_ProcBind : Clause<"proc_bind"> {
   let clangClass = "OMPProcBindClause";
   let flangClass = "OmpProcBindClause";
   let enumClauseValue = "ProcBindKind";
   let allowedClauseValues = [
+OMP_PROC_BIND_primary,
 OMP_PROC_BIND_master,
 OMP_PROC_BIND_close,
 OMP_PROC_BIND_spread,
Index: clang/test/OpenMP/parallel_proc_bind_primary_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/parallel_proc_bind_primary_codegen.cpp
@@ -0,0 +1,48 @@
+// expected-no-diagnostics
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+#ifndef HEADER
+#define HEADER
+
+typedef __INTPTR_TYPE__ intptr_t;
+
+// CHECK-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CHECK-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant [[IDENT_T_TY]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+void foo();
+
+template 
+T tmain() {
+#pragma omp parallel proc_bind(primary)
+  foo();
+  return T();
+}
+
+int main() {
+#pragma omp parallel proc_bind(primary)
+  foo();
+  return tmain();
+}
+
+// CHECK-LABEL: @main
+// CHECK:   [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEF_LOC_2]])
+// CHECK:   call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 5)
+// CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+
+// CHECK-LABEL: @{{.+}}tmain
+// CHECK:   [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEF_LOC_2]])
+// CHECK:   call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 5)
+// CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+// CHECK:   ret i32 0
+// CHECK-NEXT:  }
+
+#endif
+
Index: clang/test/OpenMP/parallel_proc_bind_messages.cpp
===
--- clang/test/OpenMP/parallel_proc_bind_messages.cpp
+++ clang/test/OpenMP/parallel_proc_bind_messages.cpp
@@ -1,16 +1,20 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s 

[PATCH] D99407: [clang][ItaniumMangle] Check SizeExpr for DependentSizedArrayType (PR49478)

2021-04-01 Thread Tommy Chiang via Phabricator via cfe-commits
oToToT updated this revision to Diff 334840.
oToToT added a comment.

Updated tests to check mangled type name.

However, I not sure whether it is proper to put the tests here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99407

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/unittests/AST/DeclTest.cpp


Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -104,3 +104,37 @@
   ASSERT_TRUE(0 == MangleF.compare("\x01" "foo"));
   ASSERT_TRUE(0 == MangleG.compare("goo"));
 }
+
+TEST(Decl, MangleDependentSizedArray) {
+  StringRef Code = R"(
+template 
+int A[] = {N...};
+
+template 
+struct S {
+  T B[N];
+};
+  )";
+  auto AST =
+  tooling::buildASTFromCodeWithArgs(Code, {"-target", 
"i386-apple-darwin"});
+  ASTContext  = AST->getASTContext();
+  assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
+ "Expected target to have a global prefix");
+  DiagnosticsEngine  = AST->getDiagnostics();
+
+  const auto *DeclA =
+  selectFirst("A", match(varDecl().bind("A"), Ctx));
+  const auto *DeclB =
+  selectFirst("B", match(fieldDecl().bind("B"), Ctx));
+
+  std::string MangleA, MangleB;
+  llvm::raw_string_ostream OS_A(MangleA), OS_B(MangleB);
+  std::unique_ptr MC(
+  ItaniumMangleContext::create(Ctx, Diags));
+
+  MC->mangleTypeName(DeclA->getType(), OS_A);
+  MC->mangleTypeName(DeclB->getType(), OS_B);
+
+  ASSERT_TRUE(0 == MangleA.compare("_ZTSA_i"));
+  ASSERT_TRUE(0 == MangleB.compare("_ZTSAT0__T_"));
+}
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3204,7 +3204,11 @@
 }
 void CXXNameMangler::mangleType(const DependentSizedArrayType *T) {
   Out << 'A';
-  mangleExpression(T->getSizeExpr());
+  // A DependentSizedArrayType might not have size expression as below
+  //
+  // template int arr[] = {N...};
+  if (T->getSizeExpr())
+mangleExpression(T->getSizeExpr());
   Out << '_';
   mangleType(T->getElementType());
 }


Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -104,3 +104,37 @@
   ASSERT_TRUE(0 == MangleF.compare("\x01" "foo"));
   ASSERT_TRUE(0 == MangleG.compare("goo"));
 }
+
+TEST(Decl, MangleDependentSizedArray) {
+  StringRef Code = R"(
+template 
+int A[] = {N...};
+
+template 
+struct S {
+  T B[N];
+};
+  )";
+  auto AST =
+  tooling::buildASTFromCodeWithArgs(Code, {"-target", "i386-apple-darwin"});
+  ASTContext  = AST->getASTContext();
+  assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
+ "Expected target to have a global prefix");
+  DiagnosticsEngine  = AST->getDiagnostics();
+
+  const auto *DeclA =
+  selectFirst("A", match(varDecl().bind("A"), Ctx));
+  const auto *DeclB =
+  selectFirst("B", match(fieldDecl().bind("B"), Ctx));
+
+  std::string MangleA, MangleB;
+  llvm::raw_string_ostream OS_A(MangleA), OS_B(MangleB);
+  std::unique_ptr MC(
+  ItaniumMangleContext::create(Ctx, Diags));
+
+  MC->mangleTypeName(DeclA->getType(), OS_A);
+  MC->mangleTypeName(DeclB->getType(), OS_B);
+
+  ASSERT_TRUE(0 == MangleA.compare("_ZTSA_i"));
+  ASSERT_TRUE(0 == MangleB.compare("_ZTSAT0__T_"));
+}
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3204,7 +3204,11 @@
 }
 void CXXNameMangler::mangleType(const DependentSizedArrayType *T) {
   Out << 'A';
-  mangleExpression(T->getSizeExpr());
+  // A DependentSizedArrayType might not have size expression as below
+  //
+  // template int arr[] = {N...};
+  if (T->getSizeExpr())
+mangleExpression(T->getSizeExpr());
   Out << '_';
   mangleType(T->getElementType());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

I am still concerned by the fact that this patch doesn't fix the issue 
mentionned in https://reviews.llvm.org/D96363#2650460
Was the intention to fix that issue? Will the fix be done in a subsequent patch?




Comment at: llvm/lib/Support/Windows/Path.inc:1087
+  if (Flags & OF_CRLF) {
+assert(Flags & OF_Text, "Flags set OF_CRLF without OF_Text");
 CrtOpenFlags |= _O_TEXT;

`s/,/ &&/`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99771: [OpenMP, test] Fix use of undef DECL FileCheck var

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

LG, thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99771

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


[PATCH] D99758: [index] Improve macro indexing support

2021-04-01 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir updated this revision to Diff 334837.
benlangmuir added a comment.

Fix clang-tidy warnings


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

https://reviews.llvm.org/D99758

Files:
  clang/include/clang/Index/DeclOccurrence.h
  clang/include/clang/Index/IndexingOptions.h
  clang/lib/Index/FileIndexRecord.cpp
  clang/lib/Index/FileIndexRecord.h
  clang/lib/Index/IndexingAction.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/lib/Index/IndexingContext.h
  clang/lib/Index/USRGeneration.cpp
  clang/test/Index/Core/Inputs/module/ModA.h
  clang/test/Index/Core/Inputs/module/SubModA.h
  clang/test/Index/Core/Inputs/sys/system-head.h
  clang/test/Index/Core/index-macros.c
  clang/test/Index/Core/index-with-module.m
  clang/tools/c-index-test/core_main.cpp
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -161,12 +161,41 @@
 }
 
 TEST(IndexTest, IndexPreprocessorMacros) {
-  std::string Code = "#define INDEX_MAC 1";
+  std::string Code = R"cpp(
+#define INDEX_MAC 1
+#define INDEX_MAC_UNDEF 1
+#undef INDEX_MAC_UNDEF
+#define INDEX_MAC_REDEF 1
+#undef INDEX_MAC_REDEF
+#define INDEX_MAC_REDEF 2
+  )cpp";
   auto Index = std::make_shared();
   IndexingOptions Opts;
   Opts.IndexMacrosInPreprocessor = true;
   tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
-  EXPECT_THAT(Index->Symbols, Contains(QName("INDEX_MAC")));
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("INDEX_MAC"), WrittenAt(Position(2, 13)),
+ DeclAt(Position(2, 13)),
+ HasRole(SymbolRole::Definition;
+  EXPECT_THAT(
+  Index->Symbols,
+  AllOf(Contains(AllOf(QName("INDEX_MAC_UNDEF"), WrittenAt(Position(3, 13)),
+   DeclAt(Position(3, 13)),
+   HasRole(SymbolRole::Definition))),
+Contains(AllOf(QName("INDEX_MAC_UNDEF"), WrittenAt(Position(4, 12)),
+   DeclAt(Position(3, 13)),
+   HasRole(SymbolRole::Undefinition);
+  EXPECT_THAT(
+  Index->Symbols,
+  AllOf(Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(5, 13)),
+   DeclAt(Position(5, 13)),
+   HasRole(SymbolRole::Definition))),
+Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(6, 12)),
+   DeclAt(Position(5, 13)),
+   HasRole(SymbolRole::Undefinition))),
+Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(7, 13)),
+   DeclAt(Position(7, 13)),
+   HasRole(SymbolRole::Definition);
 
   Opts.IndexMacrosInPreprocessor = false;
   Index->Symbols.clear();
Index: clang/tools/c-index-test/core_main.cpp
===
--- clang/tools/c-index-test/core_main.cpp
+++ clang/tools/c-index-test/core_main.cpp
@@ -63,6 +63,9 @@
 static cl::opt
 IncludeLocals("include-locals", cl::desc("Print local symbols"));
 
+static cl::opt IgnoreMacros("ignore-macros",
+  cl::desc("Skip indexing macros"));
+
 static cl::opt
 ModuleFilePath("module-file",
cl::desc("Path to module file to print symbols from"));
@@ -210,7 +213,8 @@
 
 static bool printSourceSymbols(const char *Executable,
ArrayRef Args,
-   bool dumpModuleImports, bool indexLocals) {
+   bool dumpModuleImports, bool indexLocals,
+   bool ignoreMacros) {
   SmallVector ArgsWithProgName;
   ArgsWithProgName.push_back(Executable);
   ArgsWithProgName.append(Args.begin(), Args.end());
@@ -224,6 +228,8 @@
   auto DataConsumer = std::make_shared(OS);
   IndexingOptions IndexOpts;
   IndexOpts.IndexFunctionLocals = indexLocals;
+  IndexOpts.IndexMacros = !ignoreMacros;
+  IndexOpts.IndexMacrosInPreprocessor = !ignoreMacros;
   std::unique_ptr IndexAction =
   createIndexingAction(DataConsumer, IndexOpts);
 
@@ -357,7 +363,7 @@
 }
 return printSourceSymbols(Executable.c_str(), CompArgs,
   options::DumpModuleImports,
-  options::IncludeLocals);
+  options::IncludeLocals, options::IgnoreMacros);
   }
 
   return 0;
Index: clang/test/Index/Core/index-with-module.m
===
--- clang/test/Index/Core/index-with-module.m
+++ clang/test/Index/Core/index-with-module.m
@@ -18,7 +18,10 @@
 }
 
 // CHECK:  Module ModA 
-// CHECK: 2:6 | function/C | ModA_func | c:@F@ModA_func | {{.*}} | Decl | rel: 0
+// CHECK-DAG: 3:9 | macro/C | MODA_MACRO | 

[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

In D99426#2664883 , 
@abhina.sreeskantharajan wrote:

> In D99426#2664841 , @MaskRay wrote:
>
>>   /// The file should be opened in text mode on platforms like z/OS that make
>>   /// this distinction.
>>   OF_Text = 1,
>>   F_Text = 1, // For compatibility
>>   
>>   /// The file should use a carriage linefeed '\r\n'.
>>   /// Only makes a difference on windows.
>>   OF_CRLF = 2,
>>   
>>   /// The file should be opened in text mode and use a carriage linefeed 
>> '\r\n'
>>   /// on platforms that make this distinction.
>>   OF_TextWithCRLF = OF_Text | OF_CRLF,
>>
>> `OF_TextWithCRLF` needs to say what platforms make a difference.
>>
>> Can you mention in the description for Windows and z/OS, how these flags 
>> make a difference, and how developers should use these flags for portability?
>> It's still a bit unclear to me.
>>
>> e.g. when I need to use `OF_CRLR` instead of `OF_Text`?
>
> So developers should use either the OF_Text or OF_TextWithCRLF for text files 
> and OF_None for binary files. If the developer doesn't want carriage returns 
> on Windows, they should use OF_Text, if they do want carriage returns on 
> Windows, they should use OF_TextWithCRLF.
>
> So this is the behaviour per platform with my patch:
>
> z/OS:
> OF_None: open in binary mode
> OF_Text : open in text mode
> OF_TextWithCRLF: open in text mode
>
> Windows:
> OF_None: open file with no carriage return
> OF_Text: open file with no carriage return
> OF_TextWithCRLF: open file with carriage return
>
> This is the old behaviour for comparison:
> z/OS:
> OF_None: open in binary mode
> OF_Text: open in text mode
>
> Windows:
> OF_None: open file with no carriage return
> OF_Text: open file with carriage return

Thanks for the information. LG.
Please update the summary to include the information.

If the patch also affects SystemZ, please adjust the `[Windows] ` tag in the 
subject.




Comment at: llvm/include/llvm/Support/FileSystem.h:752
+  /// Only makes a difference on windows.
+  OF_CRLF = 2,
+

Am I right that this is an implementation detail and should not be used 
directly by users (use OF_TextWithCRLF instead)?
If so, please add a comment.



Comment at: llvm/include/llvm/Support/FileSystem.h:771
+  /// Force files Atime to be updated on access. Only makes a difference on
+  /// windows.
+  OF_UpdateAtime = 32,

windows -> Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99771: [OpenMP, test] Fix use of undef DECL FileCheck var

2021-04-01 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre created this revision.
thopre added reviewers: cchen, ABataev, MaskRay.
Herald added subscribers: guansong, yaxunl.
thopre requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

OpenMP test target_data_use_device_ptr_if_codegen contains a CHECK-NOT
directive using an undefined DECL FileCheck variable. It seems copied
from target_data_use_device_ptr_codegen where there's a CHECK for a load
that defined the variable. Since there is no corresponding load in this
testcase, the simplest is to simply forbid any store and get rid of the
variable altogether.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99771

Files:
  clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp


Index: clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
===
--- clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
+++ clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
@@ -29,7 +29,7 @@
   // CK1: store float* [[B_ADDR:%.+]], float** [[CBP]]
   // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
   // CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
-  // CK1-NOT: store float* [[VAL]], float** [[DECL]],
+  // CK1-NOT: store float* [[VAL]], float** {{%.+}},
   // CK1: store float* [[VAL]], float** [[PVT:%.+]],
   // CK1: [[TT:%.+]] = load float*, float** [[PVT]],
   // CK1: call i32 @__tgt_target{{.+}}[[MTYPE01]]


Index: clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
===
--- clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
+++ clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
@@ -29,7 +29,7 @@
   // CK1: store float* [[B_ADDR:%.+]], float** [[CBP]]
   // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
   // CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
-  // CK1-NOT: store float* [[VAL]], float** [[DECL]],
+  // CK1-NOT: store float* [[VAL]], float** {{%.+}},
   // CK1: store float* [[VAL]], float** [[PVT:%.+]],
   // CK1: [[TT:%.+]] = load float*, float** [[PVT]],
   // CK1: call i32 @__tgt_target{{.+}}[[MTYPE01]]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99770: [OpenMP, test] Fix uses of undef S*VAR FileCheck var

2021-04-01 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre created this revision.
thopre added reviewers: ABataev, MaskRay, jdoerfert.
Herald added subscribers: guansong, yaxunl.
thopre requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Fix the many cases of use of undefined SIVAR/SVAR/SFVAR in OpenMP
*private_codegen tests, due to a missing BLOCK directive to capture the
IR variable when it is declared. It also fixes a few typo in its use.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99770

Files:
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_private_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  clang/test/OpenMP/sections_private_codegen.cpp
  clang/test/OpenMP/single_firstprivate_codegen.cpp
  clang/test/OpenMP/single_private_codegen.cpp
  clang/test/OpenMP/task_firstprivate_codegen.cpp
  clang/test/OpenMP/task_private_codegen.cpp
  clang/test/OpenMP/taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/taskloop_private_codegen.cpp
  clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/taskloop_simd_private_codegen.cpp

Index: clang/test/OpenMP/taskloop_simd_private_codegen.cpp
===
--- clang/test/OpenMP/taskloop_simd_private_codegen.cpp
+++ clang/test/OpenMP/taskloop_simd_private_codegen.cpp
@@ -93,6 +93,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
Index: clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
===
--- clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
+++ clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
@@ -101,6 +101,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
@@ -115,7 +116,7 @@
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
 // BLOCKS: store double 2.0{{.+}}, double*
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
-// BLOCKS-NOT: [[ISVAR]]{{[[^:word:]]}}
+// BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: store i{{[0-9]+}} 22, i{{[0-9]+}}*
 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: ret
Index: clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
+++ clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
@@ -102,6 +102,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
@@ -123,7 +124,7 @@
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
 // BLOCKS: store volatile double 2.0{{.+}}, double*
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
-// BLOCKS-NOT: [[ISVAR]]{{[[^:word:]]}}
+// BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: store i{{[0-9]+}} 22, i{{[0-9]+}}*
 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
 // BLOCKS: ret
Index: clang/test/OpenMP/taskloop_private_codegen.cpp
===
--- clang/test/OpenMP/taskloop_private_codegen.cpp
+++ clang/test/OpenMP/taskloop_private_codegen.cpp
@@ -93,6 +93,7 @@
   return 0;
 #elif defined(BLOCKS)
   // BLOCKS: [[G:@.+]] ={{.*}} global double
+  // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
   // BLOCKS-LABEL: @main
   // BLOCKS: call void {{%.+}}(i8
   ^{
Index: clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
===
--- 

[PATCH] D99556: Add support to -Wa,--version in clang

2021-04-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In the future, please include `Differential Revision: ` for relands so that the 
`Commits` line displays the associated commits :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99556

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


[clang] 6fe7de9 - [Driver] -nostdinc -nostdinc++: don't warn for -Wunused-command-line-argument

2021-04-01 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-04-01T14:37:34-07:00
New Revision: 6fe7de90b9e4e466a5c2baadafd5f72d3203651d

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

LOG: [Driver] -nostdinc -nostdinc++: don't warn for 
-Wunused-command-line-argument

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/nostdincxx.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 4a8a11a8d416..c08972f0d700 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2882,9 +2882,8 @@ void Generic_GCC::AddMultilibIncludeArgs(const ArgList 
,
 
 void Generic_GCC::AddClangCXXStdlibIncludeArgs(const ArgList ,
ArgStringList ) const {
-  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
-  DriverArgs.hasArg(options::OPT_nostdincxx) ||
-  DriverArgs.hasArg(options::OPT_nostdlibinc))
+  if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdincxx,
+options::OPT_nostdlibinc))
 return;
 
   switch (GetCXXStdlibType(DriverArgs)) {

diff  --git a/clang/test/Driver/nostdincxx.cpp 
b/clang/test/Driver/nostdincxx.cpp
index 3fc7a5e76842..c919c73fa126 100644
--- a/clang/test/Driver/nostdincxx.cpp
+++ b/clang/test/Driver/nostdincxx.cpp
@@ -1,6 +1,7 @@
 // RUN: not %clangxx -nostdinc %s 2>&1 | FileCheck %s
 // RUN: not %clangxx -nostdinc++ %s 2>&1 | FileCheck %s
 // RUN: not %clangxx -nostdlibinc %s 2>&1 | FileCheck %s
+// RUN: not %clangxx -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck 
/dev/null --implicit-check-not=-Wunused-command-line-argument
 // CHECK: file not found
 #include  
 



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


[PATCH] D99484: Use `GNUInstallDirs` to support custom installation dirs.

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



Comment at: polly/cmake/CMakeLists.txt:82-96
+set(POLLY_INSTALL_PREFIX "")
 set(POLLY_CONFIG_LLVM_CMAKE_DIR 
"${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
-set(POLLY_CONFIG_CMAKE_DIR 
"${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
-set(POLLY_CONFIG_LIBRARY_DIRS 
"${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
+set(POLLY_CONFIG_CMAKE_DIR 
"${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
+set(POLLY_CONFIG_LIBRARY_DIRS 
"${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
 if (POLLY_BUNDLED_ISL)
   set(POLLY_CONFIG_INCLUDE_DIRS
+"${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}"

Ericson2314 wrote:
> `POLLY_INSTALL_PREFIX`, like `COMPILER_RT_INSTALL_PATH`, I changed to be 
> empty by default. If the `COMPILER_RT_INSTALL_PATH` can be removed, maybe 
> `POLLY_INSTALL_PREFIX` can also be removed?
I don't have an overview atm on Polly's different paths, but could look into it 
if needed. Originally, this was derived from how Clang did it. If it works for 
COMPILER_RT_INSTALL_PATH, it should work for Polly as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99484

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


[PATCH] D99708: [X86] Enable compilation of user interrupt handlers.

2021-04-01 Thread H.J Lu via Phabricator via cfe-commits
hjl.tools added a comment.

In D99708#2664372 , @craig.topper 
wrote:

> In D99708#2664351 , @hjl.tools wrote:
>
>> In D99708#2664218 , @craig.topper 
>> wrote:
>>
>>> In D99708#2664164 , @hjl.tools 
>>> wrote:
>>>
 In D99708#2664076 , @LuoYuanke 
 wrote:

> In D99708#2663989 , 
> @craig.topper wrote:
>
>> A user interrupt is different than a regular interrupt right? It doesn't 
>> make sense that we would change the behavior of the interrupt calling 
>> convention just because the the user interrupt instructions are enabled. 
>> That would occur just from passing a -march for a newer CPU wouldn't it?
>
> Maybe need support another attribute "__attribute__ ((user_interrupt))" 
> for functions? However this is what gcc does 
> (https://gcc.godbolt.org/z/8ojTMG6bT).

 Since there won't be both user interrupt handler and kernel interrupt 
 handler in the source, there is no need for another
 attribute.   We discussed that kernel might need to use UINTR 
 instructions.  We decided that kernel could use inline asm
 statements if needed.
>>>
>>> So if write kernel code and compile with -march=haswell today, I get IRET. 
>>> If tomorrow I change my command line to -march=sapphirerapids, now my 
>>> kernel interrupt code generates user interrupt instructions. That seems 
>>> surprising.
>>
>> -mcmodel=kernel should disable uiret.:
>>
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99870
>
> That makes sense. Can we put that in this patch?

The feedback is that don't enable UINTR for kernel build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99708

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


[PATCH] D99755: Remove clang/runtime and `COMPILER_RT_INSTALL_PATH`

2021-04-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

@beanz do you know if `clang/runtime` is still being used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99755

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


[PATCH] D99663: [clang-cl] [Sema] Do not prefer integral conversion over floating-to-integral for MS compatibility 19.28 and higher.

2021-04-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

Slowly we will peel back the layers of compatibility hacks until both compilers 
conform. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99663

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


[PATCH] D99556: Add support to -Wa,--version in clang

2021-04-01 Thread Jian Cai via Phabricator via cfe-commits
jcai19 added a comment.

Relanded without -fno-initegrated-as case at 
https://reviews.llvm.org/rG76d9bc72784d88f4dd57b9939e52c73739438af5.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99556

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


[PATCH] D99758: [index] Improve macro indexing support

2021-04-01 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir updated this revision to Diff 334820.
benlangmuir added a comment.

Fix the incomplete type issue with PointerUnion in DeclOccurrence. h.  I'm not 
actually sure how that code compiles without error with other versions of clang.


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

https://reviews.llvm.org/D99758

Files:
  clang/include/clang/Index/DeclOccurrence.h
  clang/include/clang/Index/IndexingOptions.h
  clang/lib/Index/FileIndexRecord.cpp
  clang/lib/Index/FileIndexRecord.h
  clang/lib/Index/IndexingAction.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/lib/Index/IndexingContext.h
  clang/lib/Index/USRGeneration.cpp
  clang/test/Index/Core/Inputs/module/ModA.h
  clang/test/Index/Core/Inputs/module/SubModA.h
  clang/test/Index/Core/Inputs/sys/system-head.h
  clang/test/Index/Core/index-macros.c
  clang/test/Index/Core/index-with-module.m
  clang/tools/c-index-test/core_main.cpp
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -161,12 +161,41 @@
 }
 
 TEST(IndexTest, IndexPreprocessorMacros) {
-  std::string Code = "#define INDEX_MAC 1";
+  std::string Code = R"cpp(
+#define INDEX_MAC 1
+#define INDEX_MAC_UNDEF 1
+#undef INDEX_MAC_UNDEF
+#define INDEX_MAC_REDEF 1
+#undef INDEX_MAC_REDEF
+#define INDEX_MAC_REDEF 2
+  )cpp";
   auto Index = std::make_shared();
   IndexingOptions Opts;
   Opts.IndexMacrosInPreprocessor = true;
   tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
-  EXPECT_THAT(Index->Symbols, Contains(QName("INDEX_MAC")));
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("INDEX_MAC"), WrittenAt(Position(2, 13)),
+ DeclAt(Position(2, 13)),
+ HasRole(SymbolRole::Definition;
+  EXPECT_THAT(
+  Index->Symbols,
+  AllOf(Contains(AllOf(QName("INDEX_MAC_UNDEF"), WrittenAt(Position(3, 13)),
+   DeclAt(Position(3, 13)),
+   HasRole(SymbolRole::Definition))),
+Contains(AllOf(QName("INDEX_MAC_UNDEF"), WrittenAt(Position(4, 12)),
+   DeclAt(Position(3, 13)),
+   HasRole(SymbolRole::Undefinition);
+  EXPECT_THAT(
+  Index->Symbols,
+  AllOf(Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(5, 13)),
+   DeclAt(Position(5, 13)),
+   HasRole(SymbolRole::Definition))),
+Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(6, 12)),
+   DeclAt(Position(5, 13)),
+   HasRole(SymbolRole::Undefinition))),
+Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(7, 13)),
+   DeclAt(Position(7, 13)),
+   HasRole(SymbolRole::Definition);
 
   Opts.IndexMacrosInPreprocessor = false;
   Index->Symbols.clear();
Index: clang/tools/c-index-test/core_main.cpp
===
--- clang/tools/c-index-test/core_main.cpp
+++ clang/tools/c-index-test/core_main.cpp
@@ -63,6 +63,9 @@
 static cl::opt
 IncludeLocals("include-locals", cl::desc("Print local symbols"));
 
+static cl::opt IgnoreMacros("ignore-macros",
+  cl::desc("Skip indexing macros"));
+
 static cl::opt
 ModuleFilePath("module-file",
cl::desc("Path to module file to print symbols from"));
@@ -210,7 +213,8 @@
 
 static bool printSourceSymbols(const char *Executable,
ArrayRef Args,
-   bool dumpModuleImports, bool indexLocals) {
+   bool dumpModuleImports, bool indexLocals,
+   bool ignoreMacros) {
   SmallVector ArgsWithProgName;
   ArgsWithProgName.push_back(Executable);
   ArgsWithProgName.append(Args.begin(), Args.end());
@@ -224,6 +228,8 @@
   auto DataConsumer = std::make_shared(OS);
   IndexingOptions IndexOpts;
   IndexOpts.IndexFunctionLocals = indexLocals;
+  IndexOpts.IndexMacros = !ignoreMacros;
+  IndexOpts.IndexMacrosInPreprocessor = !ignoreMacros;
   std::unique_ptr IndexAction =
   createIndexingAction(DataConsumer, IndexOpts);
 
@@ -357,7 +363,7 @@
 }
 return printSourceSymbols(Executable.c_str(), CompArgs,
   options::DumpModuleImports,
-  options::IncludeLocals);
+  options::IncludeLocals, options::IgnoreMacros);
   }
 
   return 0;
Index: clang/test/Index/Core/index-with-module.m
===
--- clang/test/Index/Core/index-with-module.m
+++ clang/test/Index/Core/index-with-module.m
@@ -18,7 +18,10 @@
 }
 
 // CHECK:  Module ModA 
-// 

[clang] 76d9bc7 - Reland "Add support to -Wa,--version in clang""

2021-04-01 Thread Jian Cai via cfe-commits

Author: Jian Cai
Date: 2021-04-01T13:47:56-07:00
New Revision: 76d9bc72784d88f4dd57b9939e52c73739438af5

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

LOG: Reland "Add support to -Wa,--version in clang""

This relands commit 3cc3c0f8352ec33ca2f2636f94cb1d85fc57ac16 with fixed
test cases, which was reverted by commit
bf2479c347c8ca88fefdb144d8bae0a7a4231e2a.

Added: 
clang/test/Driver/as-version.s

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c9b44aa76b6b..ad5dca30e0f6 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2552,6 +2552,8 @@ static void CollectArgsForIntegratedAssembler(Compilation 
,
 // -fdebug-compilation-dir (without '=') here.
 CmdArgs.push_back("-fdebug-compilation-dir");
 CmdArgs.push_back(Value.data());
+  } else if (Value == "--version") {
+D.PrintVersion(C, llvm::outs());
   } else {
 D.Diag(diag::err_drv_unsupported_option_argument)
 << A->getOption().getName() << Value;

diff  --git a/clang/test/Driver/as-version.s b/clang/test/Driver/as-version.s
new file mode 100644
index ..e9e66563942f
--- /dev/null
+++ b/clang/test/Driver/as-version.s
@@ -0,0 +1,5 @@
+// Test version information.
+
+// RUN: %clang -Wa,--version -c -fintegrated-as %s -o /dev/null \
+// RUN:   | FileCheck --check-prefix=IAS %s
+// IAS: clang version



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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

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

In D99037#2665082 , @SaurabhJha wrote:

> Hi Florian and John,
>
> Thanks for the comments so far. I figure it would be easier for further 
> discussion if I have something concrete. Here's what I have right now:
>
> - A new CK_MatrixCast.
> - Sema code for C-style cast along with its tests.
> - My guess on places CK_MatrixCast will go in CodeGen. I have added a TODO in 
> CGExprScalar.cpp indicating where I think we should implement the code gen 
> for this conversion. There's a failing CodeGen test too.
> - I am not sure yet if we need to anything with 
> StaticAnalyzer/Core/ExprEngineC.cpp. I got a warning that CK_MatrixCast needs 
> handling there.
>
> My next step is to make it work for C style cast. Once that works, I can use 
> that learning to implement static_cast.

Depending on how much work implementing the other casts is, but you may want to 
start with getting everything work for a single type (e.g. C-style casts) and 
then submit that first (with codegen support). Once that is done, adding the 
additional checks for the other casts should be much less work. It's also 
easier to review if the patch is not too big & doing too much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-01 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha updated this revision to Diff 334815.
SaurabhJha added a comment.
Herald added a subscriber: martong.

Hi Florian and John,

Thanks for the comments so far. I figure it would be easier for further 
discussion if I have something concrete. Here's what I have right now:

- A new CK_MatrixCast.
- Sema code for C-style cast along with its tests.
- My guess on places CK_MatrixCast will go in CodeGen. I have added a TODO in 
CGExprScalar.cpp indicating where I think we should implement the code gen for 
this conversion. There's a failing CodeGen test too.
- I am not sure yet if we need to anything with 
StaticAnalyzer/Core/ExprEngineC.cpp. I got a warning that CK_MatrixCast needs 
handling there.

My next step is to make it work for C style cast. Once that works, I can use 
that learning to implement static_cast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Edit/RewriteObjCFoundationAPI.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/CodeGen/matrix-cast.c
  clang/test/Sema/matrix-cast.c

Index: clang/test/Sema/matrix-cast.c
===
--- /dev/null
+++ clang/test/Sema/matrix-cast.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fenable-matrix -fsyntax-only %s -verify
+
+typedef char cx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix4x4 __attribute__((matrix_type(4, 4)));
+typedef short sx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+
+void f1() {
+  cx4x4 m1;
+  ix4x4 m2;
+  sx4x4 m3;
+  ix5x5 m4;
+  fx5x5 m5;
+
+  m2 = (ix4x4)m1;
+  m3 = (sx4x4)m2;
+  m4 = (ix5x5)m3; // expected-error {{invalid conversion between matrix type \
+'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))') and 'sx4x4' \
+(aka 'short __attribute__((matrix_type(4, 4)))') of different size}}
+  m5 = (ix5x5)m4; // expected-error {{assigning to 'fx5x5' (aka \
+'float __attribute__((matrix_type(5, 5)))') from incompatible type 'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))')}}
+  m4 = (ix5x5)m5;
+}
+
+typedef float float2_8x8 __attribute__((matrix_type(8, 8)));
+typedef double double_10x10 __attribute__((matrix_type(10, 10)));
+typedef double double_8x8 __attribute__((matrix_type(8, 8)));
+typedef signed int signed_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_10x10 __attribute__((matrix_type(10, 10)));
+
+void f2() {
+  float2_8x8 m1;
+  double_10x10 m2;
+  double_8x8 m3;
+  signed_int_12x12 m4;
+  unsigned_int_12x12 m5;
+  unsigned_int_10x10 m6;
+
+  m2 = (double_10x10)m1; // expected-error {{invalid conversion between matrix type \
+'double_10x10' (aka 'double __attribute__((matrix_type(10, 10)))') and 'float2_8x8' \
+(aka 'float __attribute__((matrix_type(8, 8)))') of different size}}
+  m3 = (double_8x8)m1;
+
+  m5 = (unsigned_int_12x12)m4;
+  m4 = (signed_int_12x12)m5;
+  m6 = (unsigned_int_10x10)m4; // expected-error {{invalid conversion between matrix type \
+'unsigned_int_10x10' (aka 'unsigned int __attribute__((matrix_type(10, 10)))') and 'signed_int_12x12' \
+(aka 'int __attribute__((matrix_type(12, 12)))') of different size}}
+}
\ No newline at end of file
Index: clang/test/CodeGen/matrix-cast.c
===
--- /dev/null
+++ clang/test/CodeGen/matrix-cast.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef char cx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix4x4 __attribute__((matrix_type(4, 4)));
+
+void cast_char_matrix_to_int_same_size(cx4x4 c, ix4x4 i) {
+   c = (cx4x4)i;
+}
\ No newline at end of file
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -543,6 +543,9 @@
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
 continue;
   }
+  case CK_MatrixCast: {
+// TODO: Handle MatrixCast here.
+  }
 }
   }
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7312,6 +7312,19 @@
  

Re: [clang] 9320ac9 - [Clang] Only run test when X86 backend is built.

2021-04-01 Thread Florian Hahn via cfe-commits
On Thu, Apr 1, 2021 at 8:11 PM David Blaikie  wrote:

> On Thu, Apr 1, 2021 at 1:16 AM Florian Hahn  wrote:
> >
> > Hi,
> >
> > On Tue, Mar 30, 2021 at 7:52 PM David Blaikie 
> wrote:
> >>
> >> Is there a more reliable remark that could be tested for? (Clang
> shouldn't be testing all remarks - just that the remark infrastructure in
> general is wired up (specific remarks should be tested in llvm) - so
> picking some really stable remark would be great)
> >>
> >> maybe there's a remark for "this always_inline thing can't be inlined
> because it's recursive" for instance?
> >>
> >
> > That's a great point, there certainly are more stable remarks, e.g.
> inlining as you suggested or GVN. I can add a separate test for that, so we
> can still keep testing the vectorization remark. WDYT?
>
> Actually my goal was to stop testing the vectorization remark in
> clang, if it's not an especially stable remark - the remark should be
> tested in LLVM in any case (even if it's also tested in Clang). So
> ideally we'd test some really simple, stable, reliable remark in clang
> that validates that the remark infrastructure works with clang - and
> we'd test all the nitty gritty specific remarks down in LLVM only.
>

Ah, got it!

I think this test specifically tests the vectorization remark, because
Clang adds some extra information to the remark. I'm not really familiar
with the code myself, but the suggestion about using the pragma is Clang
specific I think. Some of the relevant code should be
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenAction.cpp#L751
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

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

In D99037#2665030 , @SaurabhJha wrote:

> Hey, elementary question about arcanist. I followed the steps here 
> https://llvm.org/docs/Contributing.html#how-to-submit-a-patch and did
>
>   arc diff --edit --verbatim
>
> on my current branch. Probably one mistake I did was to do a `git reset 
> HEAD~1` and create a new commit. Now its trying to create a new revision. Is 
> that okay to create a new revision and abandoning this one?

You can't add multiple commits to the same review on Phabricator. If you have 
multiple commits that you want to update this review with, you can squash them 
into the commit you used to create this patch and then upload the updated 
commit. If you have multiple commit but only want to upload the latest, you can 
use `arc diff HEAD^`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99758: [index] Improve macro indexing support

2021-04-01 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir updated this revision to Diff 334808.
benlangmuir added a comment.

Fixed clang-format issue.


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

https://reviews.llvm.org/D99758

Files:
  clang/include/clang/Index/DeclOccurrence.h
  clang/include/clang/Index/IndexingOptions.h
  clang/lib/Index/FileIndexRecord.cpp
  clang/lib/Index/FileIndexRecord.h
  clang/lib/Index/IndexingAction.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/lib/Index/IndexingContext.h
  clang/lib/Index/USRGeneration.cpp
  clang/test/Index/Core/Inputs/module/ModA.h
  clang/test/Index/Core/Inputs/module/SubModA.h
  clang/test/Index/Core/Inputs/sys/system-head.h
  clang/test/Index/Core/index-macros.c
  clang/test/Index/Core/index-with-module.m
  clang/tools/c-index-test/core_main.cpp
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -161,12 +161,41 @@
 }
 
 TEST(IndexTest, IndexPreprocessorMacros) {
-  std::string Code = "#define INDEX_MAC 1";
+  std::string Code = R"cpp(
+#define INDEX_MAC 1
+#define INDEX_MAC_UNDEF 1
+#undef INDEX_MAC_UNDEF
+#define INDEX_MAC_REDEF 1
+#undef INDEX_MAC_REDEF
+#define INDEX_MAC_REDEF 2
+  )cpp";
   auto Index = std::make_shared();
   IndexingOptions Opts;
   Opts.IndexMacrosInPreprocessor = true;
   tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
-  EXPECT_THAT(Index->Symbols, Contains(QName("INDEX_MAC")));
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("INDEX_MAC"), WrittenAt(Position(2, 13)),
+ DeclAt(Position(2, 13)),
+ HasRole(SymbolRole::Definition;
+  EXPECT_THAT(
+  Index->Symbols,
+  AllOf(Contains(AllOf(QName("INDEX_MAC_UNDEF"), WrittenAt(Position(3, 13)),
+   DeclAt(Position(3, 13)),
+   HasRole(SymbolRole::Definition))),
+Contains(AllOf(QName("INDEX_MAC_UNDEF"), WrittenAt(Position(4, 12)),
+   DeclAt(Position(3, 13)),
+   HasRole(SymbolRole::Undefinition);
+  EXPECT_THAT(
+  Index->Symbols,
+  AllOf(Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(5, 13)),
+   DeclAt(Position(5, 13)),
+   HasRole(SymbolRole::Definition))),
+Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(6, 12)),
+   DeclAt(Position(5, 13)),
+   HasRole(SymbolRole::Undefinition))),
+Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(7, 13)),
+   DeclAt(Position(7, 13)),
+   HasRole(SymbolRole::Definition);
 
   Opts.IndexMacrosInPreprocessor = false;
   Index->Symbols.clear();
Index: clang/tools/c-index-test/core_main.cpp
===
--- clang/tools/c-index-test/core_main.cpp
+++ clang/tools/c-index-test/core_main.cpp
@@ -63,6 +63,9 @@
 static cl::opt
 IncludeLocals("include-locals", cl::desc("Print local symbols"));
 
+static cl::opt IgnoreMacros("ignore-macros",
+  cl::desc("Skip indexing macros"));
+
 static cl::opt
 ModuleFilePath("module-file",
cl::desc("Path to module file to print symbols from"));
@@ -210,7 +213,8 @@
 
 static bool printSourceSymbols(const char *Executable,
ArrayRef Args,
-   bool dumpModuleImports, bool indexLocals) {
+   bool dumpModuleImports, bool indexLocals,
+   bool ignoreMacros) {
   SmallVector ArgsWithProgName;
   ArgsWithProgName.push_back(Executable);
   ArgsWithProgName.append(Args.begin(), Args.end());
@@ -224,6 +228,8 @@
   auto DataConsumer = std::make_shared(OS);
   IndexingOptions IndexOpts;
   IndexOpts.IndexFunctionLocals = indexLocals;
+  IndexOpts.IndexMacros = !ignoreMacros;
+  IndexOpts.IndexMacrosInPreprocessor = !ignoreMacros;
   std::unique_ptr IndexAction =
   createIndexingAction(DataConsumer, IndexOpts);
 
@@ -357,7 +363,7 @@
 }
 return printSourceSymbols(Executable.c_str(), CompArgs,
   options::DumpModuleImports,
-  options::IncludeLocals);
+  options::IncludeLocals, options::IgnoreMacros);
   }
 
   return 0;
Index: clang/test/Index/Core/index-with-module.m
===
--- clang/test/Index/Core/index-with-module.m
+++ clang/test/Index/Core/index-with-module.m
@@ -18,7 +18,10 @@
 }
 
 // CHECK:  Module ModA 
-// CHECK: 2:6 | function/C | ModA_func | c:@F@ModA_func | {{.*}} | Decl | rel: 0
+// CHECK-DAG: 3:9 | macro/C | MODA_MACRO | 

[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-01 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added a comment.

Hey, elementary question about arcanist. I followed the steps here 
https://llvm.org/docs/Contributing.html#how-to-submit-a-patch and did

  arc diff --edit --verbatim

on my current branch. Probably one mistake I did was to do a `git reset HEAD~1` 
and create a new commit. Now its trying to create a new revision. Is that okay 
to create a new revision and abandoning this one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99455: [AST] Store regular ValueDecl* in BindingDecl

2021-04-01 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Ping @rsmith.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99455

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


[PATCH] D99765: [Matrix] Implement explicit type conversions for matrix types

2021-04-01 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added a comment.

Sorry, this revision was created by mistake. I just wanted to update 
https://reviews.llvm.org/D99037


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99765

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


[PATCH] D99765: [Matrix] Implement explicit type conversions for matrix types

2021-04-01 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha created this revision.
Herald added subscribers: martong, tschuett.
SaurabhJha requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[Matrix] Implement explicit type conversions for MatrixType.
Bugzilla ticket is here: https://bugs.llvm.org/show_bug.cgi?id=47141


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99765

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Edit/RewriteObjCFoundationAPI.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/CodeGen/matrix-cast.c
  clang/test/Sema/matrix-cast.c

Index: clang/test/Sema/matrix-cast.c
===
--- /dev/null
+++ clang/test/Sema/matrix-cast.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fenable-matrix -fsyntax-only %s -verify
+
+typedef char cx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix4x4 __attribute__((matrix_type(4, 4)));
+typedef short sx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+
+void f1() {
+  cx4x4 m1;
+  ix4x4 m2;
+  sx4x4 m3;
+  ix5x5 m4;
+  fx5x5 m5;
+
+  m2 = (ix4x4)m1;
+  m3 = (sx4x4)m2;
+  m4 = (ix5x5)m3; // expected-error {{invalid conversion between matrix type \
+'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))') and 'sx4x4' \
+(aka 'short __attribute__((matrix_type(4, 4)))') of different size}}
+  m5 = (ix5x5)m4; // expected-error {{assigning to 'fx5x5' (aka \
+'float __attribute__((matrix_type(5, 5)))') from incompatible type 'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))')}}
+  m4 = (ix5x5)m5;
+}
+
+typedef float float2_8x8 __attribute__((matrix_type(8, 8)));
+typedef double double_10x10 __attribute__((matrix_type(10, 10)));
+typedef double double_8x8 __attribute__((matrix_type(8, 8)));
+typedef signed int signed_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_10x10 __attribute__((matrix_type(10, 10)));
+
+void f2() {
+  float2_8x8 m1;
+  double_10x10 m2;
+  double_8x8 m3;
+  signed_int_12x12 m4;
+  unsigned_int_12x12 m5;
+  unsigned_int_10x10 m6;
+
+  m2 = (double_10x10)m1; // expected-error {{invalid conversion between matrix type \
+'double_10x10' (aka 'double __attribute__((matrix_type(10, 10)))') and 'float2_8x8' \
+(aka 'float __attribute__((matrix_type(8, 8)))') of different size}}
+  m3 = (double_8x8)m1;
+
+  m5 = (unsigned_int_12x12)m4;
+  m4 = (signed_int_12x12)m5;
+  m6 = (unsigned_int_10x10)m4; // expected-error {{invalid conversion between matrix type \
+'unsigned_int_10x10' (aka 'unsigned int __attribute__((matrix_type(10, 10)))') and 'signed_int_12x12' \
+(aka 'int __attribute__((matrix_type(12, 12)))') of different size}}
+}
\ No newline at end of file
Index: clang/test/CodeGen/matrix-cast.c
===
--- /dev/null
+++ clang/test/CodeGen/matrix-cast.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef char cx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix4x4 __attribute__((matrix_type(4, 4)));
+
+void cast_char_matrix_to_int_same_size(cx4x4 c, ix4x4 i) {
+   c = (cx4x4)i;
+}
\ No newline at end of file
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -543,6 +543,9 @@
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
 continue;
   }
+  case CK_MatrixCast: {
+// TODO: Handle MatrixCast here.
+  }
 }
   }
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7312,6 +7312,19 @@
  ValidScalableConversion(destTy, srcTy);
 }
 
+/// Are the two types matrix types and do they have the same dimensions i.e.
+/// and do they both have the same dimensions i.e. do they have the same number
+/// of rows and the same number of columns?
+bool Sema::areMatrixTypesOfTheSameDimension(QualType srcTy, QualType destTy) {
+  assert(destTy->isMatrixType() && srcTy->isMatrixType());
+
+  const ConstantMatrixType *matSrcType = srcTy->getAs();
+  const ConstantMatrixType *matDestType = destTy->getAs();
+
+  return (matSrcType->getNumRows() == matDestType->getNumRows() 

[PATCH] D99703: [debug-info][XCOFF] set `-gno-column-info` by default for DBX

2021-04-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Sounds good to me




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3974
+  // Microsoft debuggers don't handle missing end columns well, and the AIX
+  // debugger DBX also doesn't handle the columns well, so it's bettre not to
+  // include any column info.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99703

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


[PATCH] D99681: [OpenMP] Pass mapping names to add components in a user defined mapper

2021-04-01 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG69ca50bd7dfd: [OpenMP] Pass mapping names to add components 
in a user defined mapper (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99681

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/test/OpenMP/target_map_names.cpp


Index: clang/test/OpenMP/target_map_names.cpp
===
--- clang/test/OpenMP/target_map_names.cpp
+++ clang/test/OpenMP/target_map_names.cpp
@@ -203,4 +203,10 @@
 // CHECK: call void @__tgt_target_data_end_nowait_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* {{.+}}, i64* {{.+}}, 
i8** null, i8** {{.+}})
 // CHECK: call void @__tgt_target_data_update_nowait_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* {{.+}}, i64* {{.+}}, 
i8** null, i8** {{.+}})
 
+
+// DEBUG: void @.omp_mapper._ZTS2S3.id(i8* {{.*}}, i8* {{.*}}, i8* {{.*}}, i64 
{{.*}}, i64 {{.*}}, i8* [[NAME_ARG:%.+]])
+// DEBUG: store i8* [[NAME_ARG]], i8** [[NAME_STACK:%.+]]
+// DEBUG: [[MAPPER_NAME:%.+]] = load i8*, i8** [[NAME_STACK]]
+// DEBUG: call void @__tgt_push_mapper_component(i8* %{{.*}}, i8* %{{.*}}, i8* 
%{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i8* [[MAPPER_NAME]])
+
 #endif
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -824,7 +824,8 @@
   void emitUDMapperArrayInitOrDel(CodeGenFunction ,
   llvm::Value *Handle, llvm::Value *BasePtr,
   llvm::Value *Ptr, llvm::Value *Size,
-  llvm::Value *MapType, CharUnits ElementSize,
+  llvm::Value *MapType, llvm::Value *MapName,
+  CharUnits ElementSize,
   llvm::BasicBlock *ExitBB, bool IsInit);
 
   struct TaskResultTy {
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9267,7 +9267,6 @@
 SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(FileName, ExprName.c_str(),
 Line, Column);
   }
-
   return SrcLocStr;
 }
 
@@ -9745,12 +9744,15 @@
   llvm::Value *MapType = MapperCGF.EmitLoadOfScalar(
   MapperCGF.GetAddrOfLocalVar(), /*Volatile=*/false,
   C.getPointerType(Int64Ty), Loc);
+  llvm::Value *MapName = MapperCGF.EmitLoadOfScalar(
+  MapperCGF.GetAddrOfLocalVar(),
+  /*Volatile=*/false, C.getPointerType(C.VoidPtrTy), Loc);
 
   // Emit array initiation if this is an array section and \p MapType indicates
   // that memory allocation is required.
   llvm::BasicBlock *HeadBB = MapperCGF.createBasicBlock("omp.arraymap.head");
   emitUDMapperArrayInitOrDel(MapperCGF, Handle, BaseIn, BeginIn, Size, MapType,
- ElementSize, HeadBB, /*IsInit=*/true);
+ MapName, ElementSize, HeadBB, /*IsInit=*/true);
 
   // Emit a for loop to iterate through SizeArg of elements and map all of 
them.
 
@@ -9907,7 +9909,7 @@
   // Emit array deletion if this is an array section and \p MapType indicates
   // that deletion is required.
   emitUDMapperArrayInitOrDel(MapperCGF, Handle, BaseIn, BeginIn, Size, MapType,
- ElementSize, DoneBB, /*IsInit=*/false);
+ MapName, ElementSize, DoneBB, /*IsInit=*/false);
 
   // Emit the function exit block.
   MapperCGF.EmitBlock(DoneBB, /*IsFinished=*/true);
@@ -9928,7 +9930,8 @@
 void CGOpenMPRuntime::emitUDMapperArrayInitOrDel(
 CodeGenFunction , llvm::Value *Handle, llvm::Value *Base,
 llvm::Value *Begin, llvm::Value *Size, llvm::Value *MapType,
-CharUnits ElementSize, llvm::BasicBlock *ExitBB, bool IsInit) {
+llvm::Value *MapName, CharUnits ElementSize, llvm::BasicBlock *ExitBB,
+bool IsInit) {
   StringRef Prefix = IsInit ? ".init" : ".del";
 
   // Evaluate if this is an array section.
@@ -9974,12 +9977,11 @@
   MapperCGF.Builder.getInt64(~(MappableExprsHandler::OMP_MAP_TO |
MappableExprsHandler::OMP_MAP_FROM |
MappableExprsHandler::OMP_MAP_MEMBER_OF)));
-  llvm::Value *MapNameArg = llvm::ConstantPointerNull::get(CGM.VoidPtrTy);
 
   // Call the runtime API __tgt_push_mapper_component to fill up the runtime
   // data structure.
   llvm::Value *OffloadingArgs[] = {Handle,Base,   Begin,
-   ArraySize, MapTypeArg, MapNameArg};
+   ArraySize, MapTypeArg, MapName};
   

[clang] 69ca50b - [OpenMP] Pass mapping names to add components in a user defined mapper

2021-04-01 Thread via cfe-commits

Author: Joseph Huber
Date: 2021-04-01T15:51:03-04:00
New Revision: 69ca50bd7dfdb54aab8b0b262df635e25cf6baf0

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

LOG: [OpenMP] Pass mapping names to add components in a user defined mapper

Summary:
Currently the mapping names are not passed to the mapper components that set up
the array region. This means array mappings will not have their names availible
in the runtime. This patch fixes this by passing the argument name to the region
correctly. This means that the mapped variable's name will be the declared
mapper that placed it on the device.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/test/OpenMP/target_map_names.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 4ec216a421884..37146989e2522 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9267,7 +9267,6 @@ emitMappingInformation(CodeGenFunction , 
llvm::OpenMPIRBuilder ,
 SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(FileName, ExprName.c_str(),
 Line, Column);
   }
-
   return SrcLocStr;
 }
 
@@ -9745,12 +9744,15 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const 
OMPDeclareMapperDecl *D,
   llvm::Value *MapType = MapperCGF.EmitLoadOfScalar(
   MapperCGF.GetAddrOfLocalVar(), /*Volatile=*/false,
   C.getPointerType(Int64Ty), Loc);
+  llvm::Value *MapName = MapperCGF.EmitLoadOfScalar(
+  MapperCGF.GetAddrOfLocalVar(),
+  /*Volatile=*/false, C.getPointerType(C.VoidPtrTy), Loc);
 
   // Emit array initiation if this is an array section and \p MapType indicates
   // that memory allocation is required.
   llvm::BasicBlock *HeadBB = MapperCGF.createBasicBlock("omp.arraymap.head");
   emitUDMapperArrayInitOrDel(MapperCGF, Handle, BaseIn, BeginIn, Size, MapType,
- ElementSize, HeadBB, /*IsInit=*/true);
+ MapName, ElementSize, HeadBB, /*IsInit=*/true);
 
   // Emit a for loop to iterate through SizeArg of elements and map all of 
them.
 
@@ -9907,7 +9909,7 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const 
OMPDeclareMapperDecl *D,
   // Emit array deletion if this is an array section and \p MapType indicates
   // that deletion is required.
   emitUDMapperArrayInitOrDel(MapperCGF, Handle, BaseIn, BeginIn, Size, MapType,
- ElementSize, DoneBB, /*IsInit=*/false);
+ MapName, ElementSize, DoneBB, /*IsInit=*/false);
 
   // Emit the function exit block.
   MapperCGF.EmitBlock(DoneBB, /*IsFinished=*/true);
@@ -9928,7 +9930,8 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const 
OMPDeclareMapperDecl *D,
 void CGOpenMPRuntime::emitUDMapperArrayInitOrDel(
 CodeGenFunction , llvm::Value *Handle, llvm::Value *Base,
 llvm::Value *Begin, llvm::Value *Size, llvm::Value *MapType,
-CharUnits ElementSize, llvm::BasicBlock *ExitBB, bool IsInit) {
+llvm::Value *MapName, CharUnits ElementSize, llvm::BasicBlock *ExitBB,
+bool IsInit) {
   StringRef Prefix = IsInit ? ".init" : ".del";
 
   // Evaluate if this is an array section.
@@ -9974,12 +9977,11 @@ void CGOpenMPRuntime::emitUDMapperArrayInitOrDel(
   MapperCGF.Builder.getInt64(~(MappableExprsHandler::OMP_MAP_TO |
MappableExprsHandler::OMP_MAP_FROM |
MappableExprsHandler::OMP_MAP_MEMBER_OF)));
-  llvm::Value *MapNameArg = llvm::ConstantPointerNull::get(CGM.VoidPtrTy);
 
   // Call the runtime API __tgt_push_mapper_component to fill up the runtime
   // data structure.
   llvm::Value *OffloadingArgs[] = {Handle,Base,   Begin,
-   ArraySize, MapTypeArg, MapNameArg};
+   ArraySize, MapTypeArg, MapName};
   MapperCGF.EmitRuntimeCall(
   OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
 
OMPRTL___tgt_push_mapper_component),

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.h 
b/clang/lib/CodeGen/CGOpenMPRuntime.h
index b8bb6d85f0050..541904aa3988b 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -824,7 +824,8 @@ class CGOpenMPRuntime {
   void emitUDMapperArrayInitOrDel(CodeGenFunction ,
   llvm::Value *Handle, llvm::Value *BasePtr,
   llvm::Value *Ptr, llvm::Value *Size,
-  llvm::Value *MapType, CharUnits ElementSize,
+  llvm::Value 

[PATCH] D99661: [SemaObjC] Fix a -Wbridge-cast false-positive

2021-04-01 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 334801.
erik.pilkington added a comment.

In D99661#2662601 , @ahatanak wrote:

> Should we try to restore the behavior prior to 
> https://reviews.llvm.org/rG09abecef7bbfda18d34f046954eaa4d491062839 as much 
> as we can? Or that's not important?

Sure, the new patch starts iterating through the redeclarations starting at the 
most recent declaration, which should mimic the old behaviour. I'm not sure it 
matters, having multiple `objc_bridge` attributes has never actually worked 
(`objc_bridge` attributes appearing earlier get "shadowed" by the most recent 
one), i.e. in your testcase `CFStringGetLength((__bridge CFStringRef)(NSError 
*)0);` has always lead to a -Wbridge-cast diagnostic.


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

https://reviews.llvm.org/D99661

Files:
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/SemaObjCXX/bridge-cast-redecl.mm


Index: clang/test/SemaObjCXX/bridge-cast-redecl.mm
===
--- /dev/null
+++ clang/test/SemaObjCXX/bridge-cast-redecl.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=gnu++17 -verify %s
+
+// expected-no-diagnostics
+
+typedef const struct __CFString * CFStringRef;
+
+extern "C" {
+  typedef const struct __attribute__((objc_bridge(NSString))) __CFString * 
CFStringRef;
+  typedef struct __attribute__((objc_bridge_mutable(NSMutableString))) 
__CFString * CFMutableStringRef;
+}
+
+@interface NSString @end
+@interface NSMutableString : NSString @end
+
+void CFStringGetLength(CFStringRef theString);
+
+int main() {
+  CFStringGetLength((__bridge CFStringRef)(NSString *)0);
+}
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -3847,9 +3847,12 @@
   QualType QT = TDNDecl->getUnderlyingType();
   if (QT->isPointerType()) {
 QT = QT->getPointeeType();
-if (const RecordType *RT = QT->getAs())
-  if (RecordDecl *RD = RT->getDecl()->getMostRecentDecl())
-return RD->getAttr();
+if (const RecordType *RT = QT->getAs()) {
+  for (auto *Redecl : RT->getDecl()->getMostRecentDecl()->redecls()) {
+if (auto *attr = Redecl->getAttr())
+  return attr;
+  }
+}
   }
   return nullptr;
 }


Index: clang/test/SemaObjCXX/bridge-cast-redecl.mm
===
--- /dev/null
+++ clang/test/SemaObjCXX/bridge-cast-redecl.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=gnu++17 -verify %s
+
+// expected-no-diagnostics
+
+typedef const struct __CFString * CFStringRef;
+
+extern "C" {
+  typedef const struct __attribute__((objc_bridge(NSString))) __CFString * CFStringRef;
+  typedef struct __attribute__((objc_bridge_mutable(NSMutableString))) __CFString * CFMutableStringRef;
+}
+
+@interface NSString @end
+@interface NSMutableString : NSString @end
+
+void CFStringGetLength(CFStringRef theString);
+
+int main() {
+  CFStringGetLength((__bridge CFStringRef)(NSString *)0);
+}
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -3847,9 +3847,12 @@
   QualType QT = TDNDecl->getUnderlyingType();
   if (QT->isPointerType()) {
 QT = QT->getPointeeType();
-if (const RecordType *RT = QT->getAs())
-  if (RecordDecl *RD = RT->getDecl()->getMostRecentDecl())
-return RD->getAttr();
+if (const RecordType *RT = QT->getAs()) {
+  for (auto *Redecl : RT->getDecl()->getMostRecentDecl()->redecls()) {
+if (auto *attr = Redecl->getAttr())
+  return attr;
+  }
+}
   }
   return nullptr;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99762: [OPENMP]Fix PR49777: Clang should not try to specialize orphaned directives in device codegen.

2021-04-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

Compiler supports generic code emission, but in some cases may
erroneously consider the function context as SPMD context or Non-SPMD
parallel context. Need to clear/restore context upon entrance/exit
to/from function to avoid incorrect codegen.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99762

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c

Index: clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
===
--- clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
+++ clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
@@ -44,4 +44,4 @@
 }
 
 // expected-remark@* {{OpenMP runtime call __kmpc_global_thread_num moved to}}
-// expected-remark@* {{OpenMP runtime call __kmpc_global_thread_num deduplicated}}
+// expected-remark@* 2 {{OpenMP runtime call __kmpc_global_thread_num deduplicated}}
Index: clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
===
--- clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
+++ clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
@@ -98,5 +98,5 @@
   }
 }
 
-// all-remark@* 3 {{OpenMP runtime call __kmpc_global_thread_num moved to}}
-// all-remark@* 3 {{OpenMP runtime call __kmpc_global_thread_num deduplicated}}
+// all-remark@* 5 {{OpenMP runtime call __kmpc_global_thread_num moved to}}
+// all-remark@* 12 {{OpenMP runtime call __kmpc_global_thread_num deduplicated}}
Index: clang/test/OpenMP/declare_target_codegen_globalization.cpp
===
--- clang/test/OpenMP/declare_target_codegen_globalization.cpp
+++ clang/test/OpenMP/declare_target_codegen_globalization.cpp
@@ -37,11 +37,14 @@
 // CHECK: define {{.*}}[[BAR]]()
 // CHECK: alloca i32,
 // CHECK: [[A_LOCAL_ADDR:%.+]] = alloca i32,
+// CHECK: [[PL:%.+]] = call i16 @__kmpc_parallel_level(
+// CHECK: [[IS_IN_PARALLEL:%.+]] = icmp eq i16 [[PL]], 0
 // CHECK: [[RES:%.+]] = call i8 @__kmpc_is_spmd_exec_mode()
 // CHECK: [[IS_SPMD:%.+]] = icmp ne i8 [[RES]], 0
 // CHECK: br i1 [[IS_SPMD]], label
 // CHECK: br label
-// CHECK: [[RES:%.+]] = call i8* @__kmpc_data_sharing_coalesced_push_stack(i64 128, i16 0)
+// CHECK: [[SZ:%.+]] = select i1 [[IS_IN_PARALLEL]], i64 4, i64 128
+// CHECK: [[RES:%.+]] = call i8* @__kmpc_data_sharing_coalesced_push_stack(i64 [[SZ]], i16 0)
 // CHECK: [[GLOBALS:%.+]] = bitcast i8* [[RES]] to [[GLOBAL_ST:%.+]]*
 // CHECK: br label
 // CHECK: [[ITEMS:%.+]] = phi [[GLOBAL_ST]]* [ null, {{.+}} ], [ [[GLOBALS]], {{.+}} ]
@@ -49,7 +52,9 @@
 // CHECK: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
 // CHECK: [[LID:%.+]] = and i32 [[TID]], 31
 // CHECK: [[A_GLOBAL_ADDR:%.+]] = getelementptr inbounds [32 x i32], [32 x i32]* [[A_ADDR]], i32 0, i32 [[LID]]
-// CHECK: [[A_ADDR:%.+]] = select i1 [[IS_SPMD]], i32* [[A_LOCAL_ADDR]], i32* [[A_GLOBAL_ADDR]]
+// CHECK: [[A_GLOBAL_PARALLEL_ADDR:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 0
+// CHECK: [[A_PARALLEL_ADDR:%.+]] = select i1 [[IS_IN_PARALLEL]], i32* [[A_GLOBAL_PARALLEL_ADDR]], i32* [[A_GLOBAL_ADDR]]
+// CHECK: [[A_ADDR:%.+]] = select i1 [[IS_SPMD]], i32* [[A_LOCAL_ADDR]], i32* [[A_PARALLEL_ADDR]]
 // CHECK: call {{.*}}[[FOO]](i32* nonnull align {{[0-9]+}} dereferenceable{{.*}} [[A_ADDR]])
 // CHECK: br i1 [[IS_SPMD]], label
 // CHECK: [[BC:%.+]] = bitcast [[GLOBAL_ST]]* [[ITEMS]] to i8*
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
@@ -427,6 +427,20 @@
   /// true if we're definitely in the parallel region.
   bool IsInParallelRegion = false;
 
+  struct StateMode {
+ExecutionMode SavedExecutionMode = EM_Unknown;
+bool SavedIsInTargetMasterThreadRegion = false;
+bool SavedIsInTTDRegion = false;
+bool SavedIsInParallelRegion = false;
+StateMode(ExecutionMode SavedExecutionMode,
+  bool SavedIsInTargetMasterThreadRegion, bool SavedIsInTTDRegion,
+  bool SavedIsInParallelRegion)
+: SavedExecutionMode(SavedExecutionMode),
+  SavedIsInTargetMasterThreadRegion(SavedIsInTargetMasterThreadRegion),
+  SavedIsInTTDRegion(SavedIsInTTDRegion),
+  SavedIsInParallelRegion(SavedIsInParallelRegion) {}
+  };
+  llvm::DenseMap, StateMode> SavedExecutionModes;
   /// Map between an 

[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I've tried to think of some more exotic corner cases. I'd like to see a test 
for this:

  void f(); struct A { ~A() { [[clang::musttail]] return f(); } };

... even though we reject that for a reason unrelated to musttail. We should 
also reject this:

  struct B {};
  void f(B b) { [[clang::musttail]] return b.~B(); }

... because the calling convention for a destructor can be different from the 
calling convention for a regular function (eg, destructors sometimes implicitly 
return `this` and sometimes have secret extra parameters).

Please also make sure we reject

  struct A {}; void f(A a) { [[clang::musttail]] return a.A::A(); }

(which we would accept without the attribute under `-fms-extensions`): 
constructors, like destructors, have unusual calling conventions.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2845
+"target function "
+"%select{has different class%diff{ (expected $ but has $)|}1,2"
+"|has different number of parameters (expected %1 but has %2)"

Might be clearer?



Comment at: clang/lib/CodeGen/CGCall.cpp:5315-5317
+// TODO(haberman): insert checks/assertions to verify that this early exit
+// is safe. We tried to verify this in Sema but we should double-check
+// here.

haberman wrote:
> aaron.ballman wrote:
> > Are you planning to handle this TODO in the patch? If not, can you switch 
> > to a FIXME without a name associated with it?
> I am interested in feedback on the best way to proceed here.
> 
>   - Is my assessment correct that we should have an assertion that validates 
> this?
>   - Is such an assertion reasonably feasible to implement?
>   - Is it ok to defer with FIXME, or should I try to fix it in this patch?
> 
> I've changed it to a FIXME for now.
Yes, I think we should validate this by an assertion if we can. We can check 
this by walking the cleanup scope stack (walk from `CurrentCleanupScopeDepth` 
to `EHScopeStack::stable_end()`) and making sure that there is no "problematic" 
enclosing cleanup scope. Here, "problematic" would mean any scope other than an 
`EHCleanupScope` containing only `CallLifetimeEnd` cleanups.

Looking at the kinds of cleanups that we might encounter here, I think there 
may be a few more things that Sema needs to check in order to not get in the 
way of exception handling. In particular, I think we should reject if the 
callee is potentially-throwing and the musttail call is inside a try block or a 
function that's either noexcept or has a dynamic exception specification.

Oh, also, we should disallow musttail calls inside statement expressions, in 
order to defend against cleanups that exist transiently within an expression.



Comment at: clang/lib/CodeGen/CGExpr.cpp:4828
  ReturnValueSlot ReturnValue) {
+  SaveAndRestore SaveMustTail(InMustTailCallExpr, E == MustTailCall);
+

The more I think about this, the more it makes me nervous: if any of the 
`Emit*CallExpr` functions below incidentally emit a call on the way to 
producing their results via the CGCall machinery, and do so without recursing 
through this function, that incidental call will be emitted as a tail call 
instead of the intended one. Specifically:

-- I could imagine a block call involving multiple function calls, depending on 
the blocks ABI.
-- I could imagine a member call performing a function call to convert from 
derived to virtual base in some ABIs.
-- A CUDA kernel call in general involves calling a setup function before the 
actual function call happens (and it doesn't make sense for a CUDA kernel call 
to be a tail call anyway...)
-- A call to a builtin can result in any number of function calls.
-- If any expression in the function arguments emits a call without calling 
back into this function, we'll emit that call as a tail call instead of this 
one. Eg, `[[clang::musttail]] return f(dynamic_cast(p));` might emit the 
call to `__cxa_dynamic_cast` as the tail call instead of emitting the call to 
`f` as the tail call, depending on whether the CGCall machinery is used when 
emitting the `__cxa_dynamic_cast` call.

Is it feasible to sink this check into the `CodeGenFunction::EmitCall` overload 
that takes a `CallExpr`, `CodeGenFunction::EmitCXXMemberOrOperatorCall`, and 
`CodeGenFunction::EmitCXXMemberPointerCallExpr`, after we've emitted the callee 
and call args? It looks like we might be able to check this immediately before 
calling the CGCall overload of `EmitCall`, so we could pass in the 'musttail' 
information as a flag or similar instead of using global state in the 
`CodeGenFunction` object; if so, it'd be much easier to be confident that we're 
applying the attribute to the right call.



Comment at: clang/lib/Sema/SemaStmt.cpp:581
+if (EWC->cleanupsHaveSideEffects()) {
+  Diag(St->getBeginLoc(), 

[clang] d4e9fe8 - [OpenCL][Docs] Update links to the C++ for OpenCL documentation

2021-04-01 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-04-01T20:38:24+01:00
New Revision: d4e9fe813f4fabc260f8e859cf2846cb34e0ad3b

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

LOG: [OpenCL][Docs] Update links to the C++ for OpenCL documentation

Added: 


Modified: 
clang/docs/OpenCLSupport.rst
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst
index 7ecc4f2bed0a..71200364c746 100644
--- a/clang/docs/OpenCLSupport.rst
+++ b/clang/docs/OpenCLSupport.rst
@@ -321,7 +321,7 @@ C++ for OpenCL Implementation Status
 
 Clang implements language version 1.0 published in `the official
 release of C++ for OpenCL Documentation
-`_.
+`_.
 
 Limited support of experimental C++ libraries is described in the 
:ref:`experimental features `.
 

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index c7b7f580ad93..9053398c937a 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3210,9 +3210,9 @@ Clang currently supports C++ for OpenCL v1.0.
 For detailed information about this language refer to the C++ for OpenCL
 Programming Language Documentation available
 in `the latest build
-`_
+`_
 or in `the official release
-`_.
+`_.
 
 To enable the C++ for OpenCL mode, pass one of following command line options 
when
 compiling ``.cl`` file ``-cl-std=clc++``, ``-cl-std=CLC++``, ``-std=clc++`` or



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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-01 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D99426#2664841 , @MaskRay wrote:

>   /// The file should be opened in text mode on platforms like z/OS that make
>   /// this distinction.
>   OF_Text = 1,
>   F_Text = 1, // For compatibility
>   
>   /// The file should use a carriage linefeed '\r\n'.
>   /// Only makes a difference on windows.
>   OF_CRLF = 2,
>   
>   /// The file should be opened in text mode and use a carriage linefeed 
> '\r\n'
>   /// on platforms that make this distinction.
>   OF_TextWithCRLF = OF_Text | OF_CRLF,
>
> `OF_TextWithCRLF` needs to say what platforms make a difference.
>
> Can you mention in the description for Windows and z/OS, how these flags make 
> a difference, and how developers should use these flags for portability?
> It's still a bit unclear to me.
>
> e.g. when I need to use `OF_CRLR` instead of `OF_Text`?

So developers should use either the OF_Text or OF_TextWithCRLF for text files 
and OF_None for binary files. If the developer doesn't want carriage returns on 
Windows, they should use OF_Text, if they do want carriage returns on Windows, 
they should use OF_TextWithCRLF.

So this is the behaviour per platform with my patch:

z/OS:
OF_None: open in binary mode
OF_Text : open in text mode
OF_TextWithCRLF: open in text mode

Windows:
OF_None: open file with no carriage return
OF_Text: open file with no carriage return
OF_TextWithCRLF: open file with carriage return

This is the old behaviour for comparison:
z/OS:
OF_None: open in binary mode
OF_Text: open in text mode

Windows:
OF_None: open file with no carriage return
OF_Text: open file with carriage return


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

Update comment in FileSystem.h for OF_TextWithCRLF


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@
 bool TempFile::writeAssembly(const Module ) const {
   LLVM_DEBUG(dbgs() << " - write assembly\n");
   std::error_code EC;
-  raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+  raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
   if (EC) {
 errs() << "verify-uselistorder: error: " << EC.message() << "\n";
 return true;
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@
   OutputFilename = "-";
 
 std::error_code EC;
-sys::fs::OpenFlags Flags = OutputAssembly ? sys::fs::OF_Text
-  : sys::fs::OF_None;
+sys::fs::OpenFlags Flags =
+OutputAssembly ? sys::fs::OF_TextWithCRLF : sys::fs::OF_None;
 Out.reset(new ToolOutputFile(OutputFilename, EC, Flags));
 

Re: [clang] 9320ac9 - [Clang] Only run test when X86 backend is built.

2021-04-01 Thread David Blaikie via cfe-commits
On Thu, Apr 1, 2021 at 1:16 AM Florian Hahn  wrote:
>
> Hi,
>
> On Tue, Mar 30, 2021 at 7:52 PM David Blaikie  wrote:
>>
>> Is there a more reliable remark that could be tested for? (Clang shouldn't 
>> be testing all remarks - just that the remark infrastructure in general is 
>> wired up (specific remarks should be tested in llvm) - so picking some 
>> really stable remark would be great)
>>
>> maybe there's a remark for "this always_inline thing can't be inlined 
>> because it's recursive" for instance?
>>
>
> That's a great point, there certainly are more stable remarks, e.g. inlining 
> as you suggested or GVN. I can add a separate test for that, so we can still 
> keep testing the vectorization remark. WDYT?

Actually my goal was to stop testing the vectorization remark in
clang, if it's not an especially stable remark - the remark should be
tested in LLVM in any case (even if it's also tested in Clang). So
ideally we'd test some really simple, stable, reliable remark in clang
that validates that the remark infrastructure works with clang - and
we'd test all the nitty gritty specific remarks down in LLVM only.

- Dave

>
> Cheers,
> Florian
>>
>> On Mon, Mar 29, 2021 at 9:29 AM Florian Hahn via cfe-commits 
>>  wrote:
>>>
>>>
>>> Author: Florian Hahn
>>> Date: 2021-03-29T17:27:01+01:00
>>> New Revision: 9320ac9b4965d769632398b620ca3e4af9b56b12
>>>
>>> URL: 
>>> https://github.com/llvm/llvm-project/commit/9320ac9b4965d769632398b620ca3e4af9b56b12
>>> DIFF: 
>>> https://github.com/llvm/llvm-project/commit/9320ac9b4965d769632398b620ca3e4af9b56b12.diff
>>>
>>> LOG: [Clang] Only run test when X86 backend is built.
>>>
>>> After c773d0f97304 the remark is only emitted if the loop is profitable
>>> to vectorize, but cannot be vectorized. Hence, it depends on
>>> X86-specific cost-modeling.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/test/Frontend/optimization-remark-options.c
>>>
>>> Removed:
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/test/Frontend/optimization-remark-options.c 
>>> b/clang/test/Frontend/optimization-remark-options.c
>>> index 38dbbfbaccec0..f222eff37a5ef 100644
>>> --- a/clang/test/Frontend/optimization-remark-options.c
>>> +++ b/clang/test/Frontend/optimization-remark-options.c
>>> @@ -1,3 +1,4 @@
>>> +// REQUIRES: x86-registered-target
>>>  // RUN: %clang -O1 -fvectorize -target x86_64-unknown-unknown 
>>> -Rpass-analysis=loop-vectorize -emit-llvm -S %s -o - 2>&1 | FileCheck %s
>>>
>>>  // CHECK: {{.*}}:9:11: remark: loop not vectorized: cannot prove it is 
>>> safe to reorder floating-point operations; allow reordering by specifying 
>>> '#pragma clang loop vectorize(enable)' before the loop or by providing the 
>>> compiler option '-ffast-math'.
>>>
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
> --
>
> http://www.fhahn.com/
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99758: [index] Improve macro indexing support

2021-04-01 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: akyrtzi, sammccall.
Herald added a subscriber: arphaman.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The major change here is to index macro occurrences in more places than
before, specifically

- In non-expansion references such as `#if`, `#ifdef`, etc.
- When the macro is a reference to a builtin macro such as __LINE__.
- When using the preprocessor state instead of callbacks, we now include all 
definition locations and undefinitions instead of just the latest one (which 
may also have had the wrong location previously).
- When indexing an existing module file (.pcm), we now include module macros, 
and we no longer report unrelated preprocessor macros during indexing the 
module, which could have caused duplication.

Additionally, we now correctly obey the system symbol filter for macros,
so by default in system headers only definition/undefinition occurrences
are reported, but it can be configured to report references as well if
desired.

  

Extends FileIndexRecord to support occurrences of macros. Since the
design of this type is to keep a single list of entities organized by
source location, we incorporate macros into the existing DeclOccurrence
struct.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99758

Files:
  clang/include/clang/Index/DeclOccurrence.h
  clang/include/clang/Index/IndexingOptions.h
  clang/lib/Index/FileIndexRecord.cpp
  clang/lib/Index/FileIndexRecord.h
  clang/lib/Index/IndexingAction.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/lib/Index/IndexingContext.h
  clang/lib/Index/USRGeneration.cpp
  clang/test/Index/Core/Inputs/module/ModA.h
  clang/test/Index/Core/Inputs/module/SubModA.h
  clang/test/Index/Core/Inputs/sys/system-head.h
  clang/test/Index/Core/index-macros.c
  clang/test/Index/Core/index-with-module.m
  clang/tools/c-index-test/core_main.cpp
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -161,12 +161,41 @@
 }
 
 TEST(IndexTest, IndexPreprocessorMacros) {
-  std::string Code = "#define INDEX_MAC 1";
+  std::string Code = R"cpp(
+#define INDEX_MAC 1
+#define INDEX_MAC_UNDEF 1
+#undef INDEX_MAC_UNDEF
+#define INDEX_MAC_REDEF 1
+#undef INDEX_MAC_REDEF
+#define INDEX_MAC_REDEF 2
+  )cpp";
   auto Index = std::make_shared();
   IndexingOptions Opts;
   Opts.IndexMacrosInPreprocessor = true;
   tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
-  EXPECT_THAT(Index->Symbols, Contains(QName("INDEX_MAC")));
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("INDEX_MAC"), WrittenAt(Position(2, 13)),
+ DeclAt(Position(2, 13)),
+ HasRole(SymbolRole::Definition;
+  EXPECT_THAT(
+  Index->Symbols,
+  AllOf(Contains(AllOf(QName("INDEX_MAC_UNDEF"), WrittenAt(Position(3, 13)),
+   DeclAt(Position(3, 13)),
+   HasRole(SymbolRole::Definition))),
+Contains(AllOf(QName("INDEX_MAC_UNDEF"), WrittenAt(Position(4, 12)),
+   DeclAt(Position(3, 13)),
+   HasRole(SymbolRole::Undefinition);
+  EXPECT_THAT(
+  Index->Symbols,
+  AllOf(Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(5, 13)),
+   DeclAt(Position(5, 13)),
+   HasRole(SymbolRole::Definition))),
+Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(6, 12)),
+   DeclAt(Position(5, 13)),
+   HasRole(SymbolRole::Undefinition))),
+Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(7, 13)),
+   DeclAt(Position(7, 13)),
+   HasRole(SymbolRole::Definition);
 
   Opts.IndexMacrosInPreprocessor = false;
   Index->Symbols.clear();
Index: clang/tools/c-index-test/core_main.cpp
===
--- clang/tools/c-index-test/core_main.cpp
+++ clang/tools/c-index-test/core_main.cpp
@@ -63,6 +63,9 @@
 static cl::opt
 IncludeLocals("include-locals", cl::desc("Print local symbols"));
 
+static cl::opt IgnoreMacros("ignore-macros",
+  cl::desc("Skip indexing macros"));
+
 static cl::opt
 ModuleFilePath("module-file",
cl::desc("Path to module file to print symbols from"));
@@ -210,7 +213,8 @@
 
 static bool printSourceSymbols(const char *Executable,
ArrayRef Args,
-   bool dumpModuleImports, bool indexLocals) {
+   bool dumpModuleImports, bool indexLocals,
+   

[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

  /// The file should be opened in text mode on platforms like z/OS that make
  /// this distinction.
  OF_Text = 1,
  F_Text = 1, // For compatibility
  
  /// The file should use a carriage linefeed '\r\n'.
  /// Only makes a difference on windows.
  OF_CRLF = 2,
  
  /// The file should be opened in text mode and use a carriage linefeed '\r\n'
  /// on platforms that make this distinction.
  OF_TextWithCRLF = OF_Text | OF_CRLF,

`OF_TextWithCRLF` needs to say what platforms make a difference.

Can you mention in the description for Windows and z/OS, how these flags make a 
difference.
It's still a bit unclear to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-01 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

@MaskRay is there still any confusion about the problem this patch is trying to 
solve and concerns about the renaming?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

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

In D99037#2662414 , @fhahn wrote:

> In D99037#2659477 , @SaurabhJha 
> wrote:
>
>>> What code do you want to get out of this?  Are there e.g. vectorized 
>>> float->double conversions we can use, or is the operation basically doomed 
>>> to break the matrix apart and put it back together again?
>>
>> I think because matrices are vectors underneath, we should try vectorised 
>> conversions.
>
> I think there should be vector versions of common conversions in most modern 
> vector instruction sets, e.g. both ARM64 and X86 (with varying levels of 
> support, depending on the supported vector extensions) have vector 
> instructions for sign extend i32 -> i64 and floating point extension float -> 
> double: https://godbolt.org/z/jx4Ya4PP5. John, please let me know if you were 
> referring to something else, but IIUC then it would be best to emit vector 
> conversion for the full vector (that should also be the easiest in terms of 
> codegen).

Okay.  In that caae, this may be somewhat verbose because you'll have to 
analyze the element types in IRGen and ask the matrix-lowering code to do the 
appropriate conversion.  Not tricky, just verbose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99755: Remove clang/runtime and `COMPILER_RT_INSTALL_PATH`

2021-04-01 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 334780.
Ericson2314 added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Also remove `clang/runtime` from a TODO comment elsewhere in the tree

I put `runtimes` in there as it's evidentially its spiritual successor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99755

Files:
  clang/runtime/CMakeLists.txt
  clang/runtime/compiler-rt/clang_linux_test_input.c
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/include/CMakeLists.txt
  compiler-rt/lib/dfsan/CMakeLists.txt
  llvm/runtimes/CMakeLists.txt

Index: llvm/runtimes/CMakeLists.txt
===
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -1,6 +1,6 @@
 # TODO: This file assumes the Clang toolchain so it'd be better if it lived in
-# Clang, except there already is clang/runtime directory which contains
-# similar although simpler functionality. We should figure out how to merge
+# Clang, except there already is runtimes directory which contains
+# similar functionality. We should figure out how to merge
 # the two files.
 
 # TODO: Selecting runtimes should be always performed inside the runtimes
Index: compiler-rt/lib/dfsan/CMakeLists.txt
===
--- compiler-rt/lib/dfsan/CMakeLists.txt
+++ compiler-rt/lib/dfsan/CMakeLists.txt
@@ -62,4 +62,4 @@
DEPENDS done_abilist.txt libc_ubuntu1404_abilist.txt)
 add_dependencies(dfsan dfsan_abilist)
 install(FILES ${dfsan_abilist_filename}
-DESTINATION ${COMPILER_RT_INSTALL_PATH}/share)
+DESTINATION share)
Index: compiler-rt/include/CMakeLists.txt
===
--- compiler-rt/include/CMakeLists.txt
+++ compiler-rt/include/CMakeLists.txt
@@ -69,22 +69,22 @@
 install(FILES ${SANITIZER_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/sanitizer)
+  DESTINATION include/sanitizer)
 # Install fuzzer headers.
 install(FILES ${FUZZER_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/fuzzer)
+  DESTINATION include/fuzzer)
 # Install xray headers.
 install(FILES ${XRAY_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/xray)
+  DESTINATION include/xray)
 # Install profile headers.
 install(FILES ${PROFILE_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/profile)
+  DESTINATION include/profile)
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDEs.
   add_custom_target(install-compiler-rt-headers
Index: compiler-rt/cmake/base-config-ix.cmake
===
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -92,12 +92,12 @@
   set(COMPILER_RT_LIBRARY_OUTPUT_DIR
 ${COMPILER_RT_OUTPUT_DIR})
   set(COMPILER_RT_LIBRARY_INSTALL_DIR
-${COMPILER_RT_INSTALL_PATH})
+"")
 else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
   set(COMPILER_RT_LIBRARY_OUTPUT_DIR
 ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
   set(COMPILER_RT_LIBRARY_INSTALL_DIR
-${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
+lib/${COMPILER_RT_OS_DIR})
 endif()
 
 if(APPLE)
Index: compiler-rt/cmake/Modules/CompilerRTUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -386,7 +386,7 @@
 function(get_compiler_rt_install_dir arch install_dir)
   if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
 get_compiler_rt_target(${arch} target)
-set(${install_dir} ${COMPILER_RT_INSTALL_PATH}/lib/${target} PARENT_SCOPE)
+set(${install_dir} lib/${target} PARENT_SCOPE)
   else()
 set(${install_dir} ${COMPILER_RT_LIBRARY_INSTALL_DIR} PARENT_SCOPE)
   endif()
Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -508,7 +508,7 @@
 set(DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR
   ${COMPILER_RT_OUTPUT_DIR}/lib/macho_embedded)
 set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR
-  ${COMPILER_RT_INSTALL_PATH}/lib/macho_embedded)
+  lib/macho_embedded)
   
 

[PATCH] D99484: Use `GNUInstallDirs` to support custom installation dirs.

2021-04-01 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added inline comments.



Comment at: compiler-rt/cmake/Modules/CompilerRTUtils.cmake:389
 get_compiler_rt_target(${arch} target)
-set(${install_dir} ${COMPILER_RT_INSTALL_PATH}/lib/${target} PARENT_SCOPE)
+set(${install_dir} 
${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_LIBDIR}/${target} PARENT_SCOPE)
   else()

Ericson2314 wrote:
> phosek wrote:
> > Ericson2314 wrote:
> > > ldionne wrote:
> > > > lebedev.ri wrote:
> > > > > This looks suspect
> > > > Yeah, I don't understand why this isn't just `CMAKE_INSTALL_LIBDIR` 
> > > > like elsewhere.
> > > See the non-line comment I responded to @lebidev.ri with. In sort if
> > > 
> > > ```
> > > ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_LIBDIR}/${target}
> > > ```
> > > 
> > > is a relative path, then we end up with
> > > 
> > > ```
> > > ${CMAKE_INSTALL_PREFIX}/${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_LIBDIR}/${target}
> > > ```
> > > 
> > > instead of 
> > > 
> > > ```
> > > ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${target}
> > > ```
> > > 
> > > as we do with the other per-package prefixes. Also if 
> > > `CMAKE_INSTALL_LIBDIR` is already an absolute path, then
> > > ```
> > > ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_LIBDIR}/${target}
> > > ```
> > > is the same thing, and closer to the second than the first.
> > I'm not sure if that's desirable. I'm not sure if we still need 
> > `COMPILER_RT_INSTALL_PATH`. That variable is only used by 
> > `clang/runtime/CMakeLists.txt` which predates `runtimes/CMakeLists.txt` and 
> > was AFAIK only ever used by Apple. I think we should consider removing 
> > `COMPILER_RT_INSTALL_PATH`. We'll need to check if 
> > `clang/runtime/CMakeLists.txt` is still being used or not.
> With D99697 now all approved (thanks again!) it looks like this is the next 
> step? Would be very nice if this could be removed!
I went ahead and opened https://reviews.llvm.org/D99755 with @phosek's 
tentative proposal; I figured it would be easier for others to discuss in a 
dedicated patch than there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99484

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


[PATCH] D99755: Remove clang/runtime and `COMPILER_RT_INSTALL_PATH`

2021-04-01 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added inline comments.



Comment at: compiler-rt/cmake/base-config-ix.cmake:95
   set(COMPILER_RT_LIBRARY_INSTALL_DIR
-${COMPILER_RT_INSTALL_PATH})
+"")
 else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)

I'm a bit confused we'd ever want too install libs directly in 
`${CMAKE_INSTALL_PREFIX}`, but that is technically the existing behavior, with 
the default value for `COMPILER_RT_INSTALL_PATH`, so I kept it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99755

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


[PATCH] D99755: Remove clang/runtime and `COMPILER_RT_INSTALL_PATH`

2021-04-01 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 created this revision.
Herald added a subscriber: mgorny.
Ericson2314 requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

This patch removes those in order to simplify things for D99484 
.

As @phosek said in https://reviews.llvm.org/D99484#2662806

> I'm not sure if we still need `COMPILER_RT_INSTALL_PATH`. That
> variable is only used by `clang/runtime/CMakeLists.txt` which
> predates `runtimes/CMakeLists.txt` and was AFAIK only ever used by
> Apple. I think  we should consider removing
> `COMPILER_RT_INSTALL_PATH`. We'll need to check if
> `clang/runtime/CMakeLists.txt` is still being used or not.

I think it's easiest to have that conversation in a dedicated patch, so
I went and opened this right away.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99755

Files:
  clang/runtime/CMakeLists.txt
  clang/runtime/compiler-rt/clang_linux_test_input.c
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/include/CMakeLists.txt
  compiler-rt/lib/dfsan/CMakeLists.txt

Index: compiler-rt/lib/dfsan/CMakeLists.txt
===
--- compiler-rt/lib/dfsan/CMakeLists.txt
+++ compiler-rt/lib/dfsan/CMakeLists.txt
@@ -62,4 +62,4 @@
DEPENDS done_abilist.txt libc_ubuntu1404_abilist.txt)
 add_dependencies(dfsan dfsan_abilist)
 install(FILES ${dfsan_abilist_filename}
-DESTINATION ${COMPILER_RT_INSTALL_PATH}/share)
+DESTINATION share)
Index: compiler-rt/include/CMakeLists.txt
===
--- compiler-rt/include/CMakeLists.txt
+++ compiler-rt/include/CMakeLists.txt
@@ -69,22 +69,22 @@
 install(FILES ${SANITIZER_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/sanitizer)
+  DESTINATION include/sanitizer)
 # Install fuzzer headers.
 install(FILES ${FUZZER_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/fuzzer)
+  DESTINATION include/fuzzer)
 # Install xray headers.
 install(FILES ${XRAY_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/xray)
+  DESTINATION include/xray)
 # Install profile headers.
 install(FILES ${PROFILE_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/profile)
+  DESTINATION include/profile)
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDEs.
   add_custom_target(install-compiler-rt-headers
Index: compiler-rt/cmake/base-config-ix.cmake
===
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -92,12 +92,12 @@
   set(COMPILER_RT_LIBRARY_OUTPUT_DIR
 ${COMPILER_RT_OUTPUT_DIR})
   set(COMPILER_RT_LIBRARY_INSTALL_DIR
-${COMPILER_RT_INSTALL_PATH})
+"")
 else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
   set(COMPILER_RT_LIBRARY_OUTPUT_DIR
 ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
   set(COMPILER_RT_LIBRARY_INSTALL_DIR
-${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
+lib/${COMPILER_RT_OS_DIR})
 endif()
 
 if(APPLE)
Index: compiler-rt/cmake/Modules/CompilerRTUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -386,7 +386,7 @@
 function(get_compiler_rt_install_dir arch install_dir)
   if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
 get_compiler_rt_target(${arch} target)
-set(${install_dir} ${COMPILER_RT_INSTALL_PATH}/lib/${target} PARENT_SCOPE)
+set(${install_dir} lib/${target} PARENT_SCOPE)
   else()
 set(${install_dir} ${COMPILER_RT_LIBRARY_INSTALL_DIR} PARENT_SCOPE)
   endif()
Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -508,7 +508,7 @@
 set(DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR
   ${COMPILER_RT_OUTPUT_DIR}/lib/macho_embedded)
 set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR
-  ${COMPILER_RT_INSTALL_PATH}/lib/macho_embedded)
+  lib/macho_embedded)
   
 set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi")
 set(CFLAGS_i386 "-march=pentium")
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake

[PATCH] D99488: [SYCL][Doc] Add address space handling section to SYCL documentation

2021-04-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/docs/SYCLSupport.md:830
+Similar to other single-source C++-based GPU programming modes like
+OpenMP/CUDA/HIP, SYCL uses clang's "default" address space for types with no
+address space attributes. This design has two important features: keeps the 
type system consistent with C++ on one hand and enable tools for emitting 
device code aligned with SPIR memory model (and other GPU targets).

bader wrote:
> Anastasia wrote:
> > Is this explained somewhere would you be able to add any reference?
> I wasn't able to find documentation for this implementation detail, but we 
> should be able to confirm that by printing AST for example.
> 
> Here is the documentation I found for CUDA in llvm project:
>  - https://llvm.org/docs/CompileCudaWithLLVM.html
>  - https://llvm.org/docs/NVPTXUsage.html - defines LLVM IR representation for 
> NVPTX.
> 
> NVIDIA documentation - 
> https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#variable-memory-space-specifiers.
> It says that memory space is assigned using "variable specifiers" rather than 
> type qualifiers.
Btw I don't know if it is outdated - do you plan to use any of the conversion 
intrinsics https://llvm.org/docs/NVPTXUsage.html#address-space-conversion or do 
you plan to use `addrspacecast` instruction like OpenCL and some other 
languages?

> NVIDIA documentation - 
> https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#variable-memory-space-specifiers.
> It says that memory space is assigned using "variable specifiers" rather than 
> type qualifiers.

Yeah it seems like it is some sort of embedded C flavor but not quite the same 
concept though.

> An automatic variable declared in device code without any of the __device__, 
> __shared__ and __constant__ memory space specifiers described in this section 
> generally resides in a register. However in some cases the compiler might 
> choose to place it in local memory, which can have adverse performance 
> consequences as detailed in Device Memory Accesses. 

It might have been better to introduce a separate attribute instead of using 
embedded C's address spaces for this or introduce a different address space 
entry. In OpenCL we do so because generic also has a different flavor from emb 
C. I guess the original design didn't assume wide usage so it has not flagged 
up. It was clearly something custom for a particular vendor with some 
separation of concerns i.e. you wouln't compile CUDA to an arbitrary CPU that 
also needs to compile C or C++. So towards popularizing this approach it is not 
unreasonable that its better understanding and some adjustments might be 
required.

If you plan to use the CUDA approach in a straight-forward way it is reasonable 
to leave this undocumented for now and see if we can provide some details about 
the exact semantics while refining the implementation. 

Since in this model the automatic objects are not allocated in the 
"default"/"generic" address space in contrast to embedded C and C++ just like 
in OpenCL btw, we should at least highlight that fact for now. It is probably 
good to refer to SYCL spec s3.8.2.1 here where object allocation is explained.





Comment at: clang/docs/SYCLSupport.md:851
+
+Changing variable type has massive and destructive effect in C++. For instance
+this does not compile in C++ for OpenCL mode:

bader wrote:
> Anastasia wrote:
> > aaron.ballman wrote:
> > > 
> > > This example demonstrates the problem with compiling C++ code when 
> > > address space type qualifiers are inferred.
> > > 
> > > The example compiles in accordance with OpenCL language semantic...
> > > 
> > > https://godbolt.org/z/9jzxK5xc4 - ToT clang doesn't compile this example.
> > 
> > I am still not clear what message you are trying to convey here? In OpenCL 
> > kernel languages any object is always in some address space so if you write 
> > the following `decltype(p)`, it will always have address space attribute in 
> > a type. OpenCL spec is very explicit about this:
> > 
> > https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#addr-spaces-inference
> > 
> > So if you compare a type not attributed by an address space with an 
> > attributed one they will never compare as equal because according to C++ 
> > rules if the qualifiers differ the types will differ. You need to use a 
> > special type trait to remove an address space if you need to compare types 
> > not qualified by an address space. What is important to highlight however 
> > is that address space inference is where OpenCL differs to C or C++. But of 
> > course, neither C nor C++ have address spaces so it is hard to compare.
> > 
> > In relation to your documentation, it is not clear what you are trying to 
> > achieve with this paragraph?
> >  
> > In relation to your documentation, it is not clear what you are trying to 
> > achieve with 

[PATCH] D99683: [HIP] Support ThinLTO

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

I haven't looked extensively yet, but why import noinline functions? Also, 
please add a patch description.


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

https://reviews.llvm.org/D99683

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


[PATCH] D99681: [OpenMP] Pass mapping names to add components in a user defined mapper

2021-04-01 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.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99681

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


[PATCH] D99681: [OpenMP] Pass mapping names to add components in a user defined mapper

2021-04-01 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 334768.
jhuber6 added a comment.

Adding test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99681

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/test/OpenMP/target_map_names.cpp


Index: clang/test/OpenMP/target_map_names.cpp
===
--- clang/test/OpenMP/target_map_names.cpp
+++ clang/test/OpenMP/target_map_names.cpp
@@ -203,4 +203,10 @@
 // CHECK: call void @__tgt_target_data_end_nowait_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* {{.+}}, i64* {{.+}}, 
i8** null, i8** {{.+}})
 // CHECK: call void @__tgt_target_data_update_nowait_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* {{.+}}, i64* {{.+}}, 
i8** null, i8** {{.+}})
 
+
+// DEBUG: void @.omp_mapper._ZTS2S3.id(i8* {{.*}}, i8* {{.*}}, i8* {{.*}}, i64 
{{.*}}, i64 {{.*}}, i8* [[NAME_ARG:%.+]])
+// DEBUG: store i8* [[NAME_ARG]], i8** [[NAME_STACK:%.+]]
+// DEBUG: [[MAPPER_NAME:%.+]] = load i8*, i8** [[NAME_STACK]]
+// DEBUG: call void @__tgt_push_mapper_component(i8* %{{.*}}, i8* %{{.*}}, i8* 
%{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i8* [[MAPPER_NAME]])
+
 #endif
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -824,7 +824,8 @@
   void emitUDMapperArrayInitOrDel(CodeGenFunction ,
   llvm::Value *Handle, llvm::Value *BasePtr,
   llvm::Value *Ptr, llvm::Value *Size,
-  llvm::Value *MapType, CharUnits ElementSize,
+  llvm::Value *MapType, llvm::Value *MapName,
+  CharUnits ElementSize,
   llvm::BasicBlock *ExitBB, bool IsInit);
 
   struct TaskResultTy {
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9267,7 +9267,6 @@
 SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(FileName, ExprName.c_str(),
 Line, Column);
   }
-
   return SrcLocStr;
 }
 
@@ -9745,12 +9744,15 @@
   llvm::Value *MapType = MapperCGF.EmitLoadOfScalar(
   MapperCGF.GetAddrOfLocalVar(), /*Volatile=*/false,
   C.getPointerType(Int64Ty), Loc);
+  llvm::Value *MapName = MapperCGF.EmitLoadOfScalar(
+  MapperCGF.GetAddrOfLocalVar(),
+  /*Volatile=*/false, C.getPointerType(C.VoidPtrTy), Loc);
 
   // Emit array initiation if this is an array section and \p MapType indicates
   // that memory allocation is required.
   llvm::BasicBlock *HeadBB = MapperCGF.createBasicBlock("omp.arraymap.head");
   emitUDMapperArrayInitOrDel(MapperCGF, Handle, BaseIn, BeginIn, Size, MapType,
- ElementSize, HeadBB, /*IsInit=*/true);
+ MapName, ElementSize, HeadBB, /*IsInit=*/true);
 
   // Emit a for loop to iterate through SizeArg of elements and map all of 
them.
 
@@ -9907,7 +9909,7 @@
   // Emit array deletion if this is an array section and \p MapType indicates
   // that deletion is required.
   emitUDMapperArrayInitOrDel(MapperCGF, Handle, BaseIn, BeginIn, Size, MapType,
- ElementSize, DoneBB, /*IsInit=*/false);
+ MapName, ElementSize, DoneBB, /*IsInit=*/false);
 
   // Emit the function exit block.
   MapperCGF.EmitBlock(DoneBB, /*IsFinished=*/true);
@@ -9928,7 +9930,8 @@
 void CGOpenMPRuntime::emitUDMapperArrayInitOrDel(
 CodeGenFunction , llvm::Value *Handle, llvm::Value *Base,
 llvm::Value *Begin, llvm::Value *Size, llvm::Value *MapType,
-CharUnits ElementSize, llvm::BasicBlock *ExitBB, bool IsInit) {
+llvm::Value *MapName, CharUnits ElementSize, llvm::BasicBlock *ExitBB,
+bool IsInit) {
   StringRef Prefix = IsInit ? ".init" : ".del";
 
   // Evaluate if this is an array section.
@@ -9974,12 +9977,11 @@
   MapperCGF.Builder.getInt64(~(MappableExprsHandler::OMP_MAP_TO |
MappableExprsHandler::OMP_MAP_FROM |
MappableExprsHandler::OMP_MAP_MEMBER_OF)));
-  llvm::Value *MapNameArg = llvm::ConstantPointerNull::get(CGM.VoidPtrTy);
 
   // Call the runtime API __tgt_push_mapper_component to fill up the runtime
   // data structure.
   llvm::Value *OffloadingArgs[] = {Handle,Base,   Begin,
-   ArraySize, MapTypeArg, MapNameArg};
+   ArraySize, MapTypeArg, MapName};
   MapperCGF.EmitRuntimeCall(
   OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
 

[PATCH] D99484: Use `GNUInstallDirs` to support custom installation dirs.

2021-04-01 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 334765.
Ericson2314 added a comment.

Rebase now that previous diff landed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99484

Files:
  clang-tools-extra/clang-doc/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/modularize/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  clang/lib/Headers/CMakeLists.txt
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/clang-format/CMakeLists.txt
  clang/tools/clang-rename/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt
  clang/utils/hmaptool/CMakeLists.txt
  compiler-rt/CMakeLists.txt
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/include/CMakeLists.txt
  compiler-rt/lib/dfsan/CMakeLists.txt
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  flang/tools/f18/CMakeLists.txt
  flang/tools/flang-driver/CMakeLists.txt
  libc/CMakeLists.txt
  libc/lib/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/cmake/Modules/HandleLibCXXABI.cmake
  libcxx/include/CMakeLists.txt
  libcxx/src/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/src/CMakeLists.txt
  lld/CMakeLists.txt
  lld/cmake/modules/AddLLD.cmake
  lld/tools/lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/tools/intel-features/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddOCaml.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/include/llvm/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  openmp/CMakeLists.txt
  openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
  openmp/libomptarget/plugins/ve/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt
  openmp/tools/multiplex/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt
  polly/cmake/polly_macros.cmake
  polly/lib/External/CMakeLists.txt
  pstl/CMakeLists.txt

Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -7,6 +7,8 @@
 #===--===##
 cmake_minimum_required(VERSION 3.13.4)
 
+include(GNUInstallDirs)
+
 set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h")
 file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$")
 string(REGEX REPLACE "#define _PSTL_VERSION (.*)$" "\\1" PARALLELSTL_VERSION_SOURCE "${PARALLELSTL_VERSION_SOURCE}")
@@ -81,15 +83,15 @@
 install(EXPORT ParallelSTLTargets
 FILE ParallelSTLTargets.cmake
 NAMESPACE pstl::
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL)
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake"
   "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL)
 install(DIRECTORY include/
-DESTINATION include
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
 PATTERN "*.in" EXCLUDE)
 install(FILES "${PSTL_CONFIG_SITE_PATH}"
-DESTINATION include)
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 add_custom_target(install-pstl
   COMMAND "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" -DCOMPONENT=ParallelSTL)
Index: polly/lib/External/CMakeLists.txt
===
--- polly/lib/External/CMakeLists.txt
+++ polly/lib/External/CMakeLists.txt
@@ -275,7 +275,7 @@
 install(DIRECTORY
   ${ISL_SOURCE_DIR}/include/
   ${ISL_BINARY_DIR}/include/
-  DESTINATION include/polly
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly
   FILES_MATCHING
   PATTERN "*.h"
   PATTERN "CMakeFiles" EXCLUDE
Index: polly/cmake/polly_macros.cmake
===
--- polly/cmake/polly_macros.cmake
+++ polly/cmake/polly_macros.cmake
@@ -44,8 +44,8 @@
   if (NOT 

[PATCH] D99740: Avoid calling ParseCommandLineOptions in BackendUtil if possible

2021-04-01 Thread Raphael Isemann 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 rG60854c328d87: Avoid calling ParseCommandLineOptions in 
BackendUtil if possible (authored by teemperor).
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99740

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -871,7 +871,15 @@
 BackendArgs.push_back("-limit-float-precision");
 BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
   }
+  // Check for the default "clang" invocation that won't set any cl::opt 
values.
+  // Skip trying to parse the command line invocation to avoid the issues
+  // described below.
+  if (BackendArgs.size() == 1)
+return;
   BackendArgs.push_back(nullptr);
+  // FIXME: The command line parser below is not thread-safe and shares a 
global
+  // state, so this call might crash or overwrite the options of another Clang
+  // instance in the same process.
   llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
 BackendArgs.data());
 }


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -871,7 +871,15 @@
 BackendArgs.push_back("-limit-float-precision");
 BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
   }
+  // Check for the default "clang" invocation that won't set any cl::opt values.
+  // Skip trying to parse the command line invocation to avoid the issues
+  // described below.
+  if (BackendArgs.size() == 1)
+return;
   BackendArgs.push_back(nullptr);
+  // FIXME: The command line parser below is not thread-safe and shares a global
+  // state, so this call might crash or overwrite the options of another Clang
+  // instance in the same process.
   llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
 BackendArgs.data());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 60854c3 - Avoid calling ParseCommandLineOptions in BackendUtil if possible

2021-04-01 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2021-04-01T19:41:16+02:00
New Revision: 60854c328d8729b2ef10b9bb4dcbcc282f43c5e7

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

LOG: Avoid calling ParseCommandLineOptions in BackendUtil if possible

Calling `ParseCommandLineOptions` should only be called from `main` as the
CommandLine setup code isn't thread-safe. As BackendUtil is part of the
generic Clang FrontendAction logic, a process which has several threads 
executing
Clang FrontendActions will randomly crash in the unsafe setup code.

This patch avoids calling the function unless either the debug-pass option or
limit-float-precision option is set. Without these two options set the
`ParseCommandLineOptions` call doesn't do anything beside parsing
the command line `clang` which doesn't set any options.

See also D99652 where LLDB received a workaround for this crash.

Reviewed By: JDevlieghere

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 41eafd13d97c3..00d92e7beadd4 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -871,7 +871,15 @@ static void setCommandLineOpts(const CodeGenOptions 
) {
 BackendArgs.push_back("-limit-float-precision");
 BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
   }
+  // Check for the default "clang" invocation that won't set any cl::opt 
values.
+  // Skip trying to parse the command line invocation to avoid the issues
+  // described below.
+  if (BackendArgs.size() == 1)
+return;
   BackendArgs.push_back(nullptr);
+  // FIXME: The command line parser below is not thread-safe and shares a 
global
+  // state, so this call might crash or overwrite the options of another Clang
+  // instance in the same process.
   llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
 BackendArgs.data());
 }



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


[PATCH] D99320: [RISCV] [1/2] Add intrinsic for Zbb extension

2021-04-01 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

Created an issue for continue discuses on riscv-c-api-doc
https://github.com/riscv/riscv-c-api-doc/issues/19


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99320

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


[PATCH] D99683: [HIP] Support ThinLTO

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

LGTM in general. Please give LTO folks some time to chime in case they have any 
feedback.

@tejohnson: Just a FYI that we're tinkering with LTO on GPUs here.




Comment at: clang/include/clang/Driver/Options.td:1904-1907
+def foffload_lto : Flag<["-"], "foffload-lto">, Flags<[CoreOption]>, 
Group,
+  HelpText<"Enable LTO in 'full' mode for offload compilation">;
+def fno_offload_lto : Flag<["-"], "fno-offload-lto">, Flags<[CoreOption]>, 
Group,
+  HelpText<"Disable LTO mode (default) for offload compilation">;

Should it be `BoolFOption` ? 



Comment at: clang/lib/Driver/Driver.cpp:623
 
+  llvm::errs() << LTOName << '\n';
   LTOMode = llvm::StringSwitch(LTOName)

Leftover debug printout?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4420
 
-// Device-side jobs do not support LTO.
-bool isDeviceOffloadAction = !(JA.isDeviceOffloading(Action::OFK_None) ||
-   JA.isDeviceOffloading(Action::OFK_Host));
-
-if (D.isUsingLTO() && !isDeviceOffloadAction) {
+// Device-side jobs do not support LTO, except AMDGPU
+if (IsUsingLTO && (!IsDeviceOffloadAction || Triple.isAMDGPU())) {

Nit: rephrase it as `Only AMDGPU supports device-side LTO` ?



Comment at: llvm/test/Transforms/FunctionImport/noinline.ll:4
+; RUN: opt -module-summary %p/Inputs/noinline.ll -o %t2.bc
+; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
+

I'd add a meaningful suffix to the binaries we'll use to run the checks on. E.g 
`%t3` -> `%t.lto.bc`, `%t2` -> `%t.inputs.noinline.bc`, `%t` -> `%t.main.bc`.


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

https://reviews.llvm.org/D99683

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


[PATCH] D93095: Introduce -Wreserved-identifier

2021-04-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D93095#2663639 , @serge-sans-paille 
wrote:

> Warn on friend functions. I failed to support friend classes, but they are 
> only declared and not defined, so that should be fine, right?

They can still conflict, so I think we should warn. For example:

  // user code
  struct A { friend struct _b; };
  // system header
  enum _b {}; // error




Comment at: clang/include/clang/AST/Decl.h:81-82
 
+inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
+ ReservedIdentifierStatus Status) {
+  return DB << static_cast(Status);

This should be declared with the definition of `ReservedIdentifierStatus` -- or 
simply removed. We usually include the cast at the diagnostic emission site, 
which I find makes it locally clear that we're making an assumption about the 
numerical values of the enumerators.



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:798
+
+def ReservedIdAsSymbol : DiagGroup<"reserved-extern-identifier">;
+def ReservedIdentifier : DiagGroup<"reserved-identifier",

Some of the uses of this warning are for non-external identifiers.  It'd also 
be nice for the diagnostics in this area to have consistent names. Currently we 
have: `-Wreserved-id-macro`, `-Wreserved-extern-identifier`, 
`-Wreserved-identifier`. I'd like to see either consistent use of "identifier" 
or consistent use of "id' (preferably "identifier") and consistent word order.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4051-4052
   if (const auto *Id = CalleeDecl->getIdentifier())
-if (Id->isReservedName())
+if (Id->isReserved(CGM.getLangOpts()) !=
+ReservedIdentifierStatus::NotReserved)
   return;

aaron.ballman wrote:
> There's a slight functionality change here in that the code used to allow 
> identifiers that start with a single underscore followed by a lowercase 
> letter and that now early returns. Is that expected (and tested)?
Should we instead be asking whether `CalleeDecl` has a reserved name, now that 
we can?



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:746
 
+  ReservedIdentifierStatus Status = Id->isReserved(SemaRef.getLangOpts());
   // Ignore reserved names for compiler provided decls.

Should we be using `ND->isReserved` here?



Comment at: clang/lib/Sema/SemaDecl.cpp:5564-5565
+  ReservedIdentifierStatus Status = D->isReserved(getLangOpts());
+  if (Status != ReservedIdentifierStatus::NotReserved)
+if (Context.getSourceManager().isInMainFile(D->getLocation()))
+  Diag(D->getLocation(), diag::warn_reserved_extern_symbol) << D << Status;

aaron.ballman wrote:
> 
I'm surprised we don't warn in user headers. Is that intentional?


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

https://reviews.llvm.org/D93095

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


[PATCH] D99681: [OpenMP] Pass mapping names to add components in a user defined mapper

2021-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

A test please.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99681

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


[PATCH] D99556: Add support to -Wa,--version in clang

2021-04-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D99556#2664426 , @nickdesaulniers 
wrote:

> In D99556#2662990 , @jcai19 wrote:
>
>> We can probably remove the -fno-integraetd-as case.
>
> Or split it out into a separate test file with `// REQUIRES: linux`.  Either 
> actually is fine by me.

No, we should reduce reliance on the host system. Printing `as` is fine 
(with `-B`), but invoking it to get the output is not something we should do in 
isolated tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99556

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


[PATCH] D99556: Add support to -Wa,--version in clang

2021-04-01 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D99556#2662990 , @jcai19 wrote:

> We can probably remove the -fno-integraetd-as case.

Or split it out into a separate test file with `// REQUIRES: linux`.  Either 
actually is fine by me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99556

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


[PATCH] D93822: [clang-tidy] Add check for implicit widening of multiplication result

2021-04-01 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri marked an inline comment as done.
lebedev.ri added a comment.

In D93822#2664157 , @aaron.ballman 
wrote:

> The CI is showing build failures and there are some clang-tidy nits to be 
> addressed as well.

Thank you for taking a look!




Comment at: 
clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp:32
+  if (!BO || BO->getOpcode() != BO_Mul)
+// FIXME: what about:  long r = int(x) + (int(y) * int(z));  ?
+return nullptr;

aaron.ballman wrote:
> I think that could be handled in a follow-up if we find the need, WDYT?
Sure.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp:75
+  else if (Ty->isSignedIntegerType()) {
+assert(ETy->isUnsignedIntegerType() &&
+   "Expected source type to be signed.");

aaron.ballman wrote:
> Might be worth it to have tests around `signed char`, `unsigned char`, and 
> `char` explicitly, as that gets awkward.
Are you asking for test coverage, or for explicit handling of those types?
I'll add tests.



Comment at: clang/lib/AST/ASTContext.cpp:10158
+  if (const auto *ETy = T->getAs())
+T = ETy->getDecl()->getIntegerType();
+

aaron.ballman wrote:
> This looks to be getting the same value as in the 
> `getCorrespondingUnsignedType()` call?
Yep. Are both of them incorrect?
I'm not sure what should be returned here.



Comment at: clang/lib/AST/ASTContext.cpp:10204
+return SatLongFractTy;
+  default:
+llvm_unreachable("Unexpected unsigned integer or fixed point type");

aaron.ballman wrote:
> It looks like `_ExtInt` is missing from both this function and the 
> corresponding unsigned one.
Likewise, i'm not sure what should be returned for that.
Just the original `_ExtInt`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93822

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


[PATCH] D99484: Use `GNUInstallDirs` to support custom installation dirs.

2021-04-01 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 334713.
Ericson2314 added a comment.

Rebase on newer version of previous diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99484

Files:
  clang-tools-extra/clang-doc/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/modularize/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  clang/lib/Headers/CMakeLists.txt
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/clang-format/CMakeLists.txt
  clang/tools/clang-rename/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt
  clang/utils/hmaptool/CMakeLists.txt
  compiler-rt/CMakeLists.txt
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/include/CMakeLists.txt
  compiler-rt/lib/dfsan/CMakeLists.txt
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  flang/tools/f18/CMakeLists.txt
  flang/tools/flang-driver/CMakeLists.txt
  libc/CMakeLists.txt
  libc/lib/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/cmake/Modules/HandleLibCXXABI.cmake
  libcxx/include/CMakeLists.txt
  libcxx/src/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/src/CMakeLists.txt
  lld/CMakeLists.txt
  lld/cmake/modules/AddLLD.cmake
  lld/tools/lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/tools/intel-features/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddOCaml.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/include/llvm/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  openmp/CMakeLists.txt
  openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
  openmp/libomptarget/plugins/ve/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt
  openmp/tools/multiplex/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt
  polly/cmake/polly_macros.cmake
  polly/lib/External/CMakeLists.txt
  pstl/CMakeLists.txt

Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -7,6 +7,8 @@
 #===--===##
 cmake_minimum_required(VERSION 3.13.4)
 
+include(GNUInstallDirs)
+
 set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h")
 file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$")
 string(REGEX REPLACE "#define _PSTL_VERSION (.*)$" "\\1" PARALLELSTL_VERSION_SOURCE "${PARALLELSTL_VERSION_SOURCE}")
@@ -81,15 +83,15 @@
 install(EXPORT ParallelSTLTargets
 FILE ParallelSTLTargets.cmake
 NAMESPACE pstl::
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL)
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake"
   "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL)
 install(DIRECTORY include/
-DESTINATION include
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
 PATTERN "*.in" EXCLUDE)
 install(FILES "${PSTL_CONFIG_SITE_PATH}"
-DESTINATION include)
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 add_custom_target(install-pstl
   COMMAND "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" -DCOMPONENT=ParallelSTL)
Index: polly/lib/External/CMakeLists.txt
===
--- polly/lib/External/CMakeLists.txt
+++ polly/lib/External/CMakeLists.txt
@@ -275,7 +275,7 @@
 install(DIRECTORY
   ${ISL_SOURCE_DIR}/include/
   ${ISL_BINARY_DIR}/include/
-  DESTINATION include/polly
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly
   FILES_MATCHING
   PATTERN "*.h"
   PATTERN "CMakeFiles" EXCLUDE
Index: polly/cmake/polly_macros.cmake
===
--- polly/cmake/polly_macros.cmake
+++ polly/cmake/polly_macros.cmake
@@ -44,8 +44,8 @@
   if (NOT 

[PATCH] D99708: [X86] Enable compilation of user interrupt handlers.

2021-04-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D99708#2664351 , @hjl.tools wrote:

> In D99708#2664218 , @craig.topper 
> wrote:
>
>> In D99708#2664164 , @hjl.tools 
>> wrote:
>>
>>> In D99708#2664076 , @LuoYuanke 
>>> wrote:
>>>
 In D99708#2663989 , @craig.topper 
 wrote:

> A user interrupt is different than a regular interrupt right? It doesn't 
> make sense that we would change the behavior of the interrupt calling 
> convention just because the the user interrupt instructions are enabled. 
> That would occur just from passing a -march for a newer CPU wouldn't it?

 Maybe need support another attribute "__attribute__ ((user_interrupt))" 
 for functions? However this is what gcc does 
 (https://gcc.godbolt.org/z/8ojTMG6bT).
>>>
>>> Since there won't be both user interrupt handler and kernel interrupt 
>>> handler in the source, there is no need for another
>>> attribute.   We discussed that kernel might need to use UINTR instructions. 
>>>  We decided that kernel could use inline asm
>>> statements if needed.
>>
>> So if write kernel code and compile with -march=haswell today, I get IRET. 
>> If tomorrow I change my command line to -march=sapphirerapids, now my kernel 
>> interrupt code generates user interrupt instructions. That seems surprising.
>
> -mcmodel=kernel should disable uiret.:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99870

That makes sense. Can we put that in this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99708

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


[PATCH] D99708: [X86] Enable compilation of user interrupt handlers.

2021-04-01 Thread H.J Lu via Phabricator via cfe-commits
hjl.tools added a comment.

In D99708#2664218 , @craig.topper 
wrote:

> In D99708#2664164 , @hjl.tools wrote:
>
>> In D99708#2664076 , @LuoYuanke 
>> wrote:
>>
>>> In D99708#2663989 , @craig.topper 
>>> wrote:
>>>
 A user interrupt is different than a regular interrupt right? It doesn't 
 make sense that we would change the behavior of the interrupt calling 
 convention just because the the user interrupt instructions are enabled. 
 That would occur just from passing a -march for a newer CPU wouldn't it?
>>>
>>> Maybe need support another attribute "__attribute__ ((user_interrupt))" for 
>>> functions? However this is what gcc does 
>>> (https://gcc.godbolt.org/z/8ojTMG6bT).
>>
>> Since there won't be both user interrupt handler and kernel interrupt 
>> handler in the source, there is no need for another
>> attribute.   We discussed that kernel might need to use UINTR instructions.  
>> We decided that kernel could use inline asm
>> statements if needed.
>
> So if write kernel code and compile with -march=haswell today, I get IRET. If 
> tomorrow I change my command line to -march=sapphirerapids, now my kernel 
> interrupt code generates user interrupt instructions. That seems surprising.

-mcmodel=kernel should disable uiret.:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99870


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99708

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


[PATCH] D99688: [CUDA][HIP] rename -fcuda-flush-denormals-to-zero

2021-04-01 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Driver/cuda-flush-denormals-to-zero.cu:2
 // Checks that cuda compilation does the right thing when passed
-// -fcuda-flush-denormals-to-zero. This should be translated to
+// -fgpu-flush-denormals-to-zero. This should be translated to
 // -fdenormal-fp-math-f32=preserve-sign

It would be good to add a couple of tests to verify that 
`-fcuda-flush-denormals-to-zero` still work as we still need them for existing 
users.


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

https://reviews.llvm.org/D99688

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


[PATCH] D99738: [HIP] remove overloaded abs in header

2021-04-01 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 rG85ff35a9529a: [HIP] remove overloaded abs in header 
(authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99738

Files:
  clang/lib/Headers/__clang_hip_cmath.h


Index: clang/lib/Headers/__clang_hip_cmath.h
===
--- clang/lib/Headers/__clang_hip_cmath.h
+++ clang/lib/Headers/__clang_hip_cmath.h
@@ -312,7 +312,6 @@
   }
 #endif
 
-__HIP_OVERLOAD1(double, abs)
 __HIP_OVERLOAD1(double, acos)
 __HIP_OVERLOAD1(double, acosh)
 __HIP_OVERLOAD1(double, asin)


Index: clang/lib/Headers/__clang_hip_cmath.h
===
--- clang/lib/Headers/__clang_hip_cmath.h
+++ clang/lib/Headers/__clang_hip_cmath.h
@@ -312,7 +312,6 @@
   }
 #endif
 
-__HIP_OVERLOAD1(double, abs)
 __HIP_OVERLOAD1(double, acos)
 __HIP_OVERLOAD1(double, acosh)
 __HIP_OVERLOAD1(double, asin)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 85ff35a - [HIP] remove overloaded abs in header

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

Author: Yaxun (Sam) Liu
Date: 2021-04-01T12:23:29-04:00
New Revision: 85ff35a9529a1ea9ed7ab8cda10761d66705d518

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

LOG: [HIP] remove overloaded abs in header

This function seems to be introduced by accident by
https://github.com/llvm/llvm-project/commit/aa2b593f1495a972a4a592952760ec9d5f7c01f1

Such overloaded abs function did not exist before
the refactoring, and does not exist in
https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/__clang_cuda_cmath.h

Conceptually it also does not make sense, since it adds something like

double abs(int x) {
  return ::abs((double)x);
}

It caused regressions in CuPy.

Reviewed by: Aaron Enye Shi, Artem Belevich

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

Added: 


Modified: 
clang/lib/Headers/__clang_hip_cmath.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_cmath.h 
b/clang/lib/Headers/__clang_hip_cmath.h
index cd22a2df954bc..18871e63bfa0f 100644
--- a/clang/lib/Headers/__clang_hip_cmath.h
+++ b/clang/lib/Headers/__clang_hip_cmath.h
@@ -312,7 +312,6 @@ class __promote : public __promote_imp<_A1, _A2, _A3> {};
   }
 #endif
 
-__HIP_OVERLOAD1(double, abs)
 __HIP_OVERLOAD1(double, acos)
 __HIP_OVERLOAD1(double, acosh)
 __HIP_OVERLOAD1(double, asin)



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


[PATCH] D99668: [RISCV][Clang] Add some RVV Floating-Point intrinsic functions.

2021-04-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D99668/new/

https://reviews.llvm.org/D99668

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


[PATCH] D99708: [X86] Enable compilation of user interrupt handlers.

2021-04-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D99708#2664164 , @hjl.tools wrote:

> In D99708#2664076 , @LuoYuanke wrote:
>
>> In D99708#2663989 , @craig.topper 
>> wrote:
>>
>>> A user interrupt is different than a regular interrupt right? It doesn't 
>>> make sense that we would change the behavior of the interrupt calling 
>>> convention just because the the user interrupt instructions are enabled. 
>>> That would occur just from passing a -march for a newer CPU wouldn't it?
>>
>> Maybe need support another attribute "__attribute__ ((user_interrupt))" for 
>> functions? However this is what gcc does 
>> (https://gcc.godbolt.org/z/8ojTMG6bT).
>
> Since there won't be both user interrupt handler and kernel interrupt handler 
> in the source, there is no need for another
> attribute.   We discussed that kernel might need to use UINTR instructions.  
> We decided that kernel could use inline asm
> statements if needed.

So if write kernel code and compile with -march=haswell today, I get IRET. If 
tomorrow I change my command line to -march=sapphirerapids, now my kernel 
interrupt code generates user interrupt instructions. That seems surprising.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99708

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


[clang] 56b39af - [OpenMP51][DOCS] Mark "add present modifier in defaultmap clause" as

2021-04-01 Thread via cfe-commits

Author: cchen
Date: 2021-04-01T11:02:23-05:00
New Revision: 56b39afb58627507ffbc7eaa749781a30b750c03

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

LOG: [OpenMP51][DOCS] Mark "add present modifier in defaultmap clause" as
done, NFC.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index e66d9a64a93f..6e15716f3bb4 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -272,7 +272,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | device extension | 'present' motion modifier 
   | :good:`done` | D84711, D84712  
  |
 
+--+--+--+---+
-| device extension | 'present' in defaultmap clause
   | :part:`worked on`| D92427  
  |
+| device extension | 'present' in defaultmap clause
   | :good:`done` | D92427  
  |
 
+--+--+--+---+
 | device extension | map clause reordering reordering based on 
'present' modifier | :none:`unclaimed`| 
  |
 
+--+--+--+---+



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


[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-04-01 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

In D99580#2660040 , @kamleshbhalui 
wrote:

> In D99580#2659858 , @amccarth wrote:
>
>> It looks like the code change is for everyone, but the new test is specific 
>> to mingw.
>
> For Linux like platform it does not create problem because input file  path 
> is already in POSIX style, so having a test case will not test the change 
> because even without the change it will pass.

The fix is on the code path for all platforms, so running the test on all 
platforms could help catch future regressions.  There could also be unusual 
cases, such as cross compiling for Linux on Windows, and thus you could have 
Windows-style paths even though the target is Posix.  Or someone might further 
refine the fix to make more cases work correctly for mingw but inadvertently 
cause problems for other platforms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

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


[PATCH] D99738: [HIP] remove overloaded abs in header

2021-04-01 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 accepted this revision.
ashi1 added a comment.
This revision is now accepted and ready to land.

LGTM, thank you.


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

https://reviews.llvm.org/D99738

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


[PATCH] D99622: [OpenMP51] Accept `primary` as proc bind affinity policy in Clang

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

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99622

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


  1   2   >