[PATCH] D105135: [Internalize] Preserve variables externally initialized.

2021-06-30 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 355764.
hliao added a comment.

Fix typo. Kindly PING for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105135

Files:
  clang/test/CodeGenCUDA/host-used-device-var.cu
  clang/test/CodeGenCUDA/unused-global-var.cu
  llvm/lib/Transforms/IPO/Internalize.cpp
  llvm/test/Transforms/Internalize/externally-initialized.ll


Index: llvm/test/Transforms/Internalize/externally-initialized.ll
===
--- /dev/null
+++ llvm/test/Transforms/Internalize/externally-initialized.ll
@@ -0,0 +1,7 @@
+; RUN: opt < %s -internalize -S | FileCheck %s
+; RUN: opt < %s -passes=internalize -S | FileCheck %s
+
+; CHECK: @G0
+; CHECK-NOT: internal
+; CHECK-SAME: global i32
+@G0 = protected externally_initialized global i32 0, align 4
Index: llvm/lib/Transforms/IPO/Internalize.cpp
===
--- llvm/lib/Transforms/IPO/Internalize.cpp
+++ llvm/lib/Transforms/IPO/Internalize.cpp
@@ -101,6 +101,12 @@
   if (GV.hasDLLExportStorageClass())
 return true;
 
+  // As the name suggests, externally initialized variables need preserving as
+  // they would be initialized elsewhere externally.
+  if (const auto *G = dyn_cast())
+if (G->isExternallyInitialized())
+  return true;
+
   // Already local, has nothing to do.
   if (GV.hasLocalLinkage())
 return false;
Index: clang/test/CodeGenCUDA/unused-global-var.cu
===
--- clang/test/CodeGenCUDA/unused-global-var.cu
+++ clang/test/CodeGenCUDA/unused-global-var.cu
@@ -17,12 +17,6 @@
 
 // Check unused device/constant variables are eliminated.
 
-// NEGCHK-NOT: @v1
-__device__ int v1;
-
-// NEGCHK-NOT: @v2
-__constant__ int v2;
-
 // NEGCHK-NOT: @_ZL2v3
 constexpr int v3 = 1;
 
Index: clang/test/CodeGenCUDA/host-used-device-var.cu
===
--- clang/test/CodeGenCUDA/host-used-device-var.cu
+++ clang/test/CodeGenCUDA/host-used-device-var.cu
@@ -17,12 +17,6 @@
 
 // Check device variables used by neither host nor device functioins are not 
kept.
 
-// DEV-NEG-NOT: @v1
-__device__ int v1;
-
-// DEV-NEG-NOT: @v2
-__constant__ int v2;
-
 // DEV-NEG-NOT: @_ZL2v3
 static __device__ int v3;
 


Index: llvm/test/Transforms/Internalize/externally-initialized.ll
===
--- /dev/null
+++ llvm/test/Transforms/Internalize/externally-initialized.ll
@@ -0,0 +1,7 @@
+; RUN: opt < %s -internalize -S | FileCheck %s
+; RUN: opt < %s -passes=internalize -S | FileCheck %s
+
+; CHECK: @G0
+; CHECK-NOT: internal
+; CHECK-SAME: global i32
+@G0 = protected externally_initialized global i32 0, align 4
Index: llvm/lib/Transforms/IPO/Internalize.cpp
===
--- llvm/lib/Transforms/IPO/Internalize.cpp
+++ llvm/lib/Transforms/IPO/Internalize.cpp
@@ -101,6 +101,12 @@
   if (GV.hasDLLExportStorageClass())
 return true;
 
+  // As the name suggests, externally initialized variables need preserving as
+  // they would be initialized elsewhere externally.
+  if (const auto *G = dyn_cast())
+if (G->isExternallyInitialized())
+  return true;
+
   // Already local, has nothing to do.
   if (GV.hasLocalLinkage())
 return false;
Index: clang/test/CodeGenCUDA/unused-global-var.cu
===
--- clang/test/CodeGenCUDA/unused-global-var.cu
+++ clang/test/CodeGenCUDA/unused-global-var.cu
@@ -17,12 +17,6 @@
 
 // Check unused device/constant variables are eliminated.
 
-// NEGCHK-NOT: @v1
-__device__ int v1;
-
-// NEGCHK-NOT: @v2
-__constant__ int v2;
-
 // NEGCHK-NOT: @_ZL2v3
 constexpr int v3 = 1;
 
Index: clang/test/CodeGenCUDA/host-used-device-var.cu
===
--- clang/test/CodeGenCUDA/host-used-device-var.cu
+++ clang/test/CodeGenCUDA/host-used-device-var.cu
@@ -17,12 +17,6 @@
 
 // Check device variables used by neither host nor device functioins are not kept.
 
-// DEV-NEG-NOT: @v1
-__device__ int v1;
-
-// DEV-NEG-NOT: @v2
-__constant__ int v2;
-
 // DEV-NEG-NOT: @_ZL2v3
 static __device__ int v3;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105052: [clang][darwin] add support for Mac Catalyst availability

2021-06-30 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Thanks for the feedback, I'll update this patch tomorrow.


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

https://reviews.llvm.org/D105052

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


[PATCH] D105257: [clang][darwin] add support for remapping macOS availability to Mac Catalyst availability

2021-06-30 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: dexonsmith, Bigcheese, dcoughlin.
Herald added a subscriber: ributzka.
Herald added a reviewer: aaron.ballman.
arphaman requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: llvm-commits.

This patch adds supports for clang to remap macOS availability attributes that 
have introduced, deprecated or obsoleted versions to appropriate Mac Catalyst 
availability attributes. This mapping is done using the version mapping 
provided in the macOS SDK, in the `SDKSettings.json` file. The mappings in the 
SDKSettings json file will also be used in the clang driver for the driver Mac 
Catalyst patch, and they could also be used in the future for other platforms 
as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105257

Files:
  clang/include/clang/Basic/DarwinSDKInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Basic/DarwinSDKInfo.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Driver/Inputs/MacOSX10.14.sdk/SDKSettings.json
  clang/test/Driver/Inputs/WatchOS6.0.sdk/SDKSettings.json
  clang/test/Driver/Inputs/iPhoneOS13.0.sdk/SDKSettings.json
  clang/test/Sema/Inputs/MacOSX11.0.sdk/SDKSettings.json
  clang/test/Sema/attr-availability-iosmac-infer-from-macos.c
  llvm/include/llvm/Support/VersionTuple.h

Index: llvm/include/llvm/Support/VersionTuple.h
===
--- llvm/include/llvm/Support/VersionTuple.h
+++ llvm/include/llvm/Support/VersionTuple.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_SUPPORT_VERSIONTUPLE_H
 #define LLVM_SUPPORT_VERSIONTUPLE_H
 
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/Optional.h"
 #include 
@@ -95,6 +96,20 @@
 return *this;
   }
 
+  /// Return a version tuple that contains only components that are non-zero.
+  VersionTuple normalize() const {
+VersionTuple Result = *this;
+if (Result.Build == 0) {
+  Result.HasBuild = false;
+  if (Result.Subminor == 0) {
+Result.HasSubminor = false;
+if (Result.Minor == 0)
+  Result.HasMinor = false;
+  }
+}
+return Result;
+  }
+
   /// Determine if two version numbers are equivalent. If not
   /// provided, minor and subminor version numbers are considered to be zero.
   friend bool operator==(const VersionTuple , const VersionTuple ) {
@@ -161,5 +176,28 @@
 /// Print a version number.
 raw_ostream <<(raw_ostream , const VersionTuple );
 
+// Provide DenseMapInfo for version tuples.
+template <> struct DenseMapInfo {
+  static inline VersionTuple getEmptyKey() { return VersionTuple(0x7FFF); }
+  static inline VersionTuple getTombstoneKey() {
+return VersionTuple(0x7FFE);
+  }
+  static unsigned getHashValue(const VersionTuple ) {
+unsigned result = value.getMajor();
+if (auto minor = value.getMinor())
+  result = detail::combineHashValue(result, *minor);
+if (auto subminor = value.getSubminor())
+  result = detail::combineHashValue(result, *subminor);
+if (auto build = value.getBuild())
+  result = detail::combineHashValue(result, *build);
+
+return result;
+  }
+
+  static bool isEqual(const VersionTuple , const VersionTuple ) {
+return lhs == rhs;
+  }
+};
+
 } // end namespace llvm
 #endif // LLVM_SUPPORT_VERSIONTUPLE_H
Index: clang/test/Sema/attr-availability-iosmac-infer-from-macos.c
===
--- /dev/null
+++ clang/test/Sema/attr-availability-iosmac-infer-from-macos.c
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios13.1-macabi" -isysroot %S/Inputs/MacOSX11.0.sdk -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios14-macabi" -isysroot %S/Inputs/MacOSX11.0.sdk -DIOS14 -fsyntax-only -verify %s
+
+void f0(void) __attribute__((availability(macOS, introduced = 10.11)));
+void f1(void) __attribute__((availability(macOS, introduced = 10.15)));
+void f2(void) __attribute__(( // expected-note {{'f2' has been explicitly marked deprecated here}}
+availability(macOS, introduced = 10.11,
+ deprecated = 10.12)));
+void f3(void)
+__attribute__((availability(macOS, introduced = 10.11, deprecated = 10.14)))
+__attribute__((availability(iOS, introduced = 11.0)));
+
+void f4(void)
+__attribute__((availability(macOS, introduced = 10, deprecated = 10)));
+
+void fAvail() __attribute__((availability(macOS, unavailable)));
+
+void f16() __attribute__((availability(macOS, introduced = 11.0)));
+#ifndef IOS14
+// expected-note@-2 {{here}}
+#endif
+
+void fObs() __attribute__((availability(macOS, introduced = 10.11, obsoleted = 10.15))); // expected-note {{'fObs' has been explicitly marked unavailable here}}
+
+void fAPItoDepr() __attribute__((availability(macOS, introduced = 10.11, deprecated = 10)));
+
+void dontRemapFutureVers() 

[PATCH] D105254: [RISCV] Support machine constraint "S"

2021-06-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D105254#2851889 , @jrtc27 wrote:

> Hm, AArch64 handles ExternalSymbolSDNode too, but I don't see how you could 
> ever end up with one...

It can't and the code path is untested. I already deleted it from aarch64.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105254

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


[PATCH] D105097: [clang][AArch64][SVE] Handle PRValue under VLAT <-> VLST cast

2021-06-30 Thread JunMa via Phabricator via cfe-commits
junparser added inline comments.



Comment at: clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c:108
+// CHECK-128-NEXT:[[CASTFIXEDSVE:%.*]] = bitcast <2 x i8>* [[SAVED_VALUE]] 
to *
+// CHECK-128-NEXT:[[TMP1:%.*]] = load , * [[CASTFIXEDSVE]], align 16, !tbaa [[TBAA6]]
+// CHECK-128-NEXT:ret  [[TMP1]]

efriedma wrote:
> Oh, hmm, this is the case where we can't optimize.
> 
> We could probably teach instcombine to convert this pattern into a load 
> directly from the global, if it matters.
yep, we can also convert to bitcast + vector.insert when without vscale_range . 
I'll check the codegen of rvv see whether it has any difference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105097

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


[PATCH] D105254: [RISCV] Support machine constraint "S"

2021-06-30 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll:24
+; RV64-NEXT:ret
+entry:
+  %0 = tail call i8* asm "lui $0, %hi($1)\0Aaddi $0,$0,%lo($1)", "=r,S"(i32* 
nonnull @var)

MaskRay wrote:
> jrtc27 wrote:
> > Label isn't needed
> Omitting the entry label is allowed but having a label is canonical. Without 
> it `%0` needs to be `%1`.
TIL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105254

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


[PATCH] D104616: [analyzer] Model comparision methods of std::unique_ptr

2021-06-30 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:443-446
+  auto RetVal = C.getSValBuilder().evalBinOp(
+  State, BOK, FirstPtrVal, SecondPtrVal, Call.getResultType());
+  State = State->BindExpr(Call.getOriginExpr(), C.getLocationContext(), 
RetVal);
+  C.addTransition(State);

RedDocMD wrote:
> NoQ wrote:
> > Because these operators are pure boolean functions, a state split would be 
> > justified. It's pointless to call the operator unless both return values 
> > are feasible. I think you should do an `assume()` and transition into both 
> > states.
> > 
> > It might also make sense to consult `-analyzer-config eagerly-assume=` 
> > before doing it but it sounds like this option will stays true forever and 
> > we might as well remove it.
> > 
> > The spaceship operator is obviously an exceptional case. Invocation of the 
> > spaceship operator isn't a good indication that all three return values are 
> > feasible, might be only two.
> I think this comment has got displaced from its original location from 
> subsequent updates. Could you please clarify?
You can always go back in time by clicking the `|<<` button in the top-left 
corner of the comment ;)

I'm trying to say that you should introduce a state split while evaluating the 
operators, not wait for the control flow operators to do that for you, exactly 
like the static analyzer currently does for the raw comparison operators.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104616

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


[PATCH] D105254: [RISCV] Support machine constraint "S"

2021-06-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll:24
+; RV64-NEXT:ret
+entry:
+  %0 = tail call i8* asm "lui $0, %hi($1)\0Aaddi $0,$0,%lo($1)", "=r,S"(i32* 
nonnull @var)

jrtc27 wrote:
> Label isn't needed
Omitting the entry label is allowed but having a label is canonical. Without it 
`%0` needs to be `%1`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105254

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


[PATCH] D105254: [RISCV] Support machine constraint "S"

2021-06-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 355749.
MaskRay marked 6 inline comments as done.
MaskRay added a comment.

scrub labels/comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105254

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/CodeGen/RISCV/riscv-inline-asm.c
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll

Index: llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll
@@ -0,0 +1,54 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s --check-prefix=RV32
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --check-prefix=RV64
+
+@var = external dso_local global i32, align 4
+
+define dso_local i8* @constraint_S() {
+; RV32-LABEL: constraint_S:
+; RV32:   # %bb.0:
+; RV32-NEXT:#APP
+; RV32-NEXT:lui a0, %hi(var)
+; RV32-NEXT:addi a0, a0, %lo(var)
+; RV32-NEXT:#NO_APP
+; RV32-NEXT:ret
+;
+; RV64-LABEL: constraint_S:
+; RV64:   # %bb.0:
+; RV64-NEXT:#APP
+; RV64-NEXT:lui a0, %hi(var)
+; RV64-NEXT:addi a0, a0, %lo(var)
+; RV64-NEXT:#NO_APP
+; RV64-NEXT:ret
+  %ret = tail call i8* asm "lui $0, %hi($1)\0Aaddi $0, $0, %lo($1)", "=r,S"(i32* nonnull @var)
+  ret i8* %ret
+}
+
+; Function Attrs: nofree nosync nounwind readnone
+define dso_local i8* @constraint_S_label() {
+; RV32-LABEL: constraint_S_label:
+; RV32:   # %bb.0: # %entry
+; RV32-NEXT:  .Ltmp0: # Block address taken
+; RV32-NEXT:  # %bb.1: # %L1
+; RV32-NEXT:#APP
+; RV32-NEXT:lui a0, %hi(.Ltmp0)
+; RV32-NEXT:addi a0, a0, %lo(.Ltmp0)
+; RV32-NEXT:#NO_APP
+; RV32-NEXT:ret
+;
+; RV64-LABEL: constraint_S_label:
+; RV64:   # %bb.0: # %entry
+; RV64-NEXT:  .Ltmp0: # Block address taken
+; RV64-NEXT:  # %bb.1: # %L1
+; RV64-NEXT:#APP
+; RV64-NEXT:lui a0, %hi(.Ltmp0)
+; RV64-NEXT:addi a0, a0, %lo(.Ltmp0)
+; RV64-NEXT:#NO_APP
+; RV64-NEXT:ret
+entry:
+  br label %L1
+
+L1:
+  %ret = tail call i8* asm "lui $0, %hi($1)\0Aaddi $0, $0, %lo($1)", "=r,S"(i8* blockaddress(@constraint_S_label, %L1))
+  ret i8* %ret
+}
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -8240,6 +8240,8 @@
   return C_Immediate;
 case 'A':
   return C_Memory;
+case 'S': // A symbolic address
+  return C_Other;
 }
   }
   return TargetLowering::getConstraintType(Constraint);
@@ -8469,6 +8471,16 @@
   DAG.getTargetConstant(CVal, SDLoc(Op), Subtarget.getXLenVT()));
   }
   return;
+case 'S':
+  if (const GlobalAddressSDNode *GA = dyn_cast(Op)) {
+Ops.push_back(DAG.getTargetGlobalAddress(GA->getGlobal(), SDLoc(Op),
+ GA->getValueType(0)));
+  } else if (const BlockAddressSDNode *BA =
+ dyn_cast(Op)) {
+Ops.push_back(DAG.getTargetBlockAddress(BA->getBlockAddress(),
+BA->getValueType(0)));
+  }
+  return;
 default:
   break;
 }
Index: clang/test/CodeGen/RISCV/riscv-inline-asm.c
===
--- clang/test/CodeGen/RISCV/riscv-inline-asm.c
+++ clang/test/CodeGen/RISCV/riscv-inline-asm.c
@@ -44,3 +44,9 @@
 // CHECK: call void asm sideeffect "", "*A"(i32* %p)
   asm volatile("" :: "A"(*p));
 }
+
+void test_S() {
+// CHECK-LABEL: define{{.*}} void @test_S()
+// CHECK: call void asm sideeffect "", "S"(float* nonnull @f)
+  asm volatile("" :: "S"());
+}
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -87,6 +87,9 @@
 // An address that is held in a general-purpose register.
 Info.setAllowsMemory();
 return true;
+  case 'S': // A symbolic address
+Info.setAllowsRegister();
+return true;
   case 'v':
 // A vector register.
 if (Name[1] == 'r' || Name[1] == 'm') {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105097: [clang][AArch64][SVE] Handle PRValue under VLAT <-> VLST cast

2021-06-30 Thread JunMa via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3afbf898044a: [clang][AArch64][SVE] Handle PRValue under 
VLAT - VLST cast (authored by junparser).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105097

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c

Index: clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
===
--- clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
+++ clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
@@ -22,13 +22,13 @@
 // CHECK-128-LABEL: @write_global_i64(
 // CHECK-128-NEXT:  entry:
 // CHECK-128-NEXT:[[CASTFIXEDSVE:%.*]] = call <2 x i64> @llvm.experimental.vector.extract.v2i64.nxv2i64( [[V:%.*]], i64 0)
-// CHECK-128-NEXT:store <2 x i64> [[CASTFIXEDSVE]], <2 x i64>* @global_i64, align 16, [[TBAA6:!tbaa !.*]]
+// CHECK-128-NEXT:store <2 x i64> [[CASTFIXEDSVE]], <2 x i64>* @global_i64, align 16, !tbaa [[TBAA6:![0-9]+]]
 // CHECK-128-NEXT:ret void
 //
 // CHECK-512-LABEL: @write_global_i64(
 // CHECK-512-NEXT:  entry:
 // CHECK-512-NEXT:[[CASTFIXEDSVE:%.*]] = call <8 x i64> @llvm.experimental.vector.extract.v8i64.nxv2i64( [[V:%.*]], i64 0)
-// CHECK-512-NEXT:store <8 x i64> [[CASTFIXEDSVE]], <8 x i64>* @global_i64, align 16, [[TBAA6:!tbaa !.*]]
+// CHECK-512-NEXT:store <8 x i64> [[CASTFIXEDSVE]], <8 x i64>* @global_i64, align 16, !tbaa [[TBAA6:![0-9]+]]
 // CHECK-512-NEXT:ret void
 //
 void write_global_i64(svint64_t v) { global_i64 = v; }
@@ -36,33 +36,33 @@
 // CHECK-128-LABEL: @write_global_bf16(
 // CHECK-128-NEXT:  entry:
 // CHECK-128-NEXT:[[CASTFIXEDSVE:%.*]] = call <8 x bfloat> @llvm.experimental.vector.extract.v8bf16.nxv8bf16( [[V:%.*]], i64 0)
-// CHECK-128-NEXT:store <8 x bfloat> [[CASTFIXEDSVE]], <8 x bfloat>* @global_bf16, align 16, [[TBAA6]]
+// CHECK-128-NEXT:store <8 x bfloat> [[CASTFIXEDSVE]], <8 x bfloat>* @global_bf16, align 16, !tbaa [[TBAA6]]
 // CHECK-128-NEXT:ret void
 //
 // CHECK-512-LABEL: @write_global_bf16(
 // CHECK-512-NEXT:  entry:
 // CHECK-512-NEXT:[[CASTFIXEDSVE:%.*]] = call <32 x bfloat> @llvm.experimental.vector.extract.v32bf16.nxv8bf16( [[V:%.*]], i64 0)
-// CHECK-512-NEXT:store <32 x bfloat> [[CASTFIXEDSVE]], <32 x bfloat>* @global_bf16, align 16, [[TBAA6]]
+// CHECK-512-NEXT:store <32 x bfloat> [[CASTFIXEDSVE]], <32 x bfloat>* @global_bf16, align 16, !tbaa [[TBAA6]]
 // CHECK-512-NEXT:ret void
 //
 void write_global_bf16(svbfloat16_t v) { global_bf16 = v; }
 
 // CHECK-128-LABEL: @write_global_bool(
 // CHECK-128-NEXT:  entry:
-// CHECK-128-NEXT:[[V_ADDR:%.*]] = alloca , align 16
-// CHECK-128-NEXT:store  [[V:%.*]], * [[V_ADDR]], align 16, [[TBAA9:!tbaa !.*]]
-// CHECK-128-NEXT:[[TMP0:%.*]] = bitcast * [[V_ADDR]] to <2 x i8>*
-// CHECK-128-NEXT:[[TMP1:%.*]] = load <2 x i8>, <2 x i8>* [[TMP0]], align 16, [[TBAA6]]
-// CHECK-128-NEXT:store <2 x i8> [[TMP1]], <2 x i8>* @global_bool, align 2, [[TBAA6]]
+// CHECK-128-NEXT:[[SAVED_VALUE:%.*]] = alloca , align 16
+// CHECK-128-NEXT:store  [[V:%.*]], * [[SAVED_VALUE]], align 16, !tbaa [[TBAA9:![0-9]+]]
+// CHECK-128-NEXT:[[CASTFIXEDSVE:%.*]] = bitcast * [[SAVED_VALUE]] to <2 x i8>*
+// CHECK-128-NEXT:[[TMP0:%.*]] = load <2 x i8>, <2 x i8>* [[CASTFIXEDSVE]], align 16, !tbaa [[TBAA6]]
+// CHECK-128-NEXT:store <2 x i8> [[TMP0]], <2 x i8>* @global_bool, align 2, !tbaa [[TBAA6]]
 // CHECK-128-NEXT:ret void
 //
 // CHECK-512-LABEL: @write_global_bool(
 // CHECK-512-NEXT:  entry:
-// CHECK-512-NEXT:[[V_ADDR:%.*]] = alloca , align 16
-// CHECK-512-NEXT:store  [[V:%.*]], * [[V_ADDR]], align 16, [[TBAA9:!tbaa !.*]]
-// CHECK-512-NEXT:[[TMP0:%.*]] = bitcast * [[V_ADDR]] to <8 x i8>*
-// CHECK-512-NEXT:[[TMP1:%.*]] = load <8 x i8>, <8 x i8>* [[TMP0]], align 16, [[TBAA6]]
-// CHECK-512-NEXT:store <8 x i8> [[TMP1]], <8 x i8>* @global_bool, align 2, [[TBAA6]]
+// CHECK-512-NEXT:[[SAVED_VALUE:%.*]] = alloca , align 16
+// CHECK-512-NEXT:store  [[V:%.*]], * [[SAVED_VALUE]], align 16, !tbaa [[TBAA9:![0-9]+]]
+// CHECK-512-NEXT:[[CASTFIXEDSVE:%.*]] = bitcast * [[SAVED_VALUE]] to <8 x i8>*
+// CHECK-512-NEXT:[[TMP0:%.*]] = load <8 x i8>, <8 x i8>* [[CASTFIXEDSVE]], align 16, !tbaa [[TBAA6]]
+// CHECK-512-NEXT:store <8 x i8> [[TMP0]], <8 x i8>* @global_bool, align 2, !tbaa [[TBAA6]]
 // CHECK-512-NEXT:ret void
 //
 void write_global_bool(svbool_t v) { global_bool = v; }
@@ -73,13 +73,13 @@
 
 // CHECK-128-LABEL: @read_global_i64(
 // CHECK-128-NEXT:  entry:
-// CHECK-128-NEXT:[[TMP0:%.*]] = load <2 x i64>, <2 x i64>* @global_i64, align 16, [[TBAA6]]
+// 

[clang] 3afbf89 - [clang][AArch64][SVE] Handle PRValue under VLAT <-> VLST cast

2021-06-30 Thread Jun Ma via cfe-commits

Author: Jun Ma
Date: 2021-07-01T10:09:47+08:00
New Revision: 3afbf898044aa5839ed75273fa38a897abe9d3d4

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

LOG: [clang][AArch64][SVE] Handle PRValue under VLAT <-> VLST cast

This change fixes the crash that PRValue cannot be handled by
EmitLValue.

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index d299a1d38e0eb..92015c8efda0a 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2095,24 +2095,11 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
  isa(DstTy)) ||
 (isa(SrcTy) &&
  isa(DstTy))) {
-  if (const CallExpr *CE = dyn_cast(E)) {
-// Call expressions can't have a scalar return unless the return type
-// is a reference type so an lvalue can't be emitted. Create a temp
-// alloca to store the call, bitcast the address then load.
-QualType RetTy = CE->getCallReturnType(CGF.getContext());
-Address Addr =
-CGF.CreateDefaultAlignTempAlloca(SrcTy, "saved-call-rvalue");
-LValue LV = CGF.MakeAddrLValue(Addr, RetTy);
-CGF.EmitStoreOfScalar(Src, LV);
-Addr = Builder.CreateElementBitCast(Addr, 
CGF.ConvertTypeForMem(DestTy),
-"castFixedSve");
-LValue DestLV = CGF.MakeAddrLValue(Addr, DestTy);
-DestLV.setTBAAInfo(TBAAAccessInfo::getMayAliasInfo());
-return EmitLoadOfLValue(DestLV, CE->getExprLoc());
-  }
-
-  Address Addr = EmitLValue(E).getAddress(CGF);
-  Addr = Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(DestTy));
+  Address Addr = CGF.CreateDefaultAlignTempAlloca(SrcTy, "saved-value");
+  LValue LV = CGF.MakeAddrLValue(Addr, E->getType());
+  CGF.EmitStoreOfScalar(Src, LV);
+  Addr = Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(DestTy),
+  "castFixedSve");
   LValue DestLV = CGF.MakeAddrLValue(Addr, DestTy);
   DestLV.setTBAAInfo(TBAAAccessInfo::getMayAliasInfo());
   return EmitLoadOfLValue(DestLV, CE->getExprLoc());

diff  --git a/clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c 
b/clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
index 73ac3f49cf3bd..278cc930610bd 100644
--- a/clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
+++ b/clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
@@ -30,21 +30,21 @@ DEFINE_STRUCT(bool)
 // CHECK-128-LABEL: @read_int64(
 // CHECK-128-NEXT:  entry:
 // CHECK-128-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds 
[[STRUCT_STRUCT_INT64:%.*]], %struct.struct_int64* [[S:%.*]], i64 0, i32 1, i64 0
-// CHECK-128-NEXT:[[TMP0:%.*]] = load <2 x i64>, <2 x i64>* [[ARRAYIDX]], 
align 16, [[TBAA6:!tbaa !.*]]
+// CHECK-128-NEXT:[[TMP0:%.*]] = load <2 x i64>, <2 x i64>* [[ARRAYIDX]], 
align 16, !tbaa [[TBAA6:![0-9]+]]
 // CHECK-128-NEXT:[[CASTSCALABLESVE:%.*]] = call  
@llvm.experimental.vector.insert.nxv2i64.v2i64( undef, <2 x 
i64> [[TMP0]], i64 0)
 // CHECK-128-NEXT:ret  [[CASTSCALABLESVE]]
 //
 // CHECK-256-LABEL: @read_int64(
 // CHECK-256-NEXT:  entry:
 // CHECK-256-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds 
[[STRUCT_STRUCT_INT64:%.*]], %struct.struct_int64* [[S:%.*]], i64 0, i32 1, i64 0
-// CHECK-256-NEXT:[[TMP0:%.*]] = load <4 x i64>, <4 x i64>* [[ARRAYIDX]], 
align 16, [[TBAA6:!tbaa !.*]]
+// CHECK-256-NEXT:[[TMP0:%.*]] = load <4 x i64>, <4 x i64>* [[ARRAYIDX]], 
align 16, !tbaa [[TBAA6:![0-9]+]]
 // CHECK-256-NEXT:[[CASTSCALABLESVE:%.*]] = call  
@llvm.experimental.vector.insert.nxv2i64.v4i64( undef, <4 x 
i64> [[TMP0]], i64 0)
 // CHECK-256-NEXT:ret  [[CASTSCALABLESVE]]
 //
 // CHECK-512-LABEL: @read_int64(
 // CHECK-512-NEXT:  entry:
 // CHECK-512-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds 
[[STRUCT_STRUCT_INT64:%.*]], %struct.struct_int64* [[S:%.*]], i64 0, i32 1, i64 0
-// CHECK-512-NEXT:[[TMP0:%.*]] = load <8 x i64>, <8 x i64>* [[ARRAYIDX]], 
align 16, [[TBAA6:!tbaa !.*]]
+// CHECK-512-NEXT:[[TMP0:%.*]] = load <8 x i64>, <8 x i64>* [[ARRAYIDX]], 
align 16, !tbaa [[TBAA6:![0-9]+]]
 // CHECK-512-NEXT:[[CASTSCALABLESVE:%.*]] = call  
@llvm.experimental.vector.insert.nxv2i64.v8i64( undef, <8 x 
i64> [[TMP0]], i64 0)
 // CHECK-512-NEXT:ret  [[CASTSCALABLESVE]]
 //
@@ -56,21 +56,21 @@ svint64_t 

[PATCH] D104852: [AArch64][SVEIntrinsicOpts] Convect cntb/h/w/d to vscale intrinsic or constant.

2021-06-30 Thread JunMa via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae5433945f91: [AArch64][SVEIntrinsicOpts] Convect cntb/h/w/d 
to vscale intrinsic or constant. (authored by junparser).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104852

Files:
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-counting-elems.ll

Index: llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-counting-elems.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-counting-elems.ll
@@ -0,0 +1,247 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -instcombine < %s | FileCheck %s
+
+target triple = "aarch64-unknown-linux-gnu"
+
+;
+; CNTB
+;
+
+define i64 @cntb_vl1() {
+; CHECK-LABEL: @cntb_vl1(
+; CHECK-NEXT:ret i64 1
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 1)
+  ret i64 %out
+}
+
+define i64 @cntb_vl2() {
+; CHECK-LABEL: @cntb_vl2(
+; CHECK-NEXT:ret i64 2
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 2)
+  ret i64 %out
+}
+
+define i64 @cntb_vl4() {
+; CHECK-LABEL: @cntb_vl4(
+; CHECK-NEXT:ret i64 4
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 4)
+  ret i64 %out
+}
+
+define i64 @cntb_mul3() {
+; CHECK-LABEL: @cntb_mul3(
+; CHECK-NEXT:ret i64 24
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntb(i32 8)
+  %out = mul i64 %cnt, 3
+  ret i64 %out
+}
+
+define i64 @cntb_mul4() {
+; CHECK-LABEL: @cntb_mul4(
+; CHECK-NEXT:ret i64 64
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntb(i32 9)
+  %out = mul i64 %cnt, 4
+  ret i64 %out
+}
+
+define i64 @cntb_all() {
+; CHECK-LABEL: @cntb_all(
+; CHECK-NEXT:[[TMP1:%.*]] = call i64 @llvm.vscale.i64()
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[TMP1]], 4
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 31)
+  ret i64 %out
+}
+
+;
+; CNTH
+;
+
+define i64 @cnth_vl1() {
+; CHECK-LABEL: @cnth_vl1(
+; CHECK-NEXT:ret i64 1
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 1)
+  ret i64 %out
+}
+
+define i64 @cnth_vl2() {
+; CHECK-LABEL: @cnth_vl2(
+; CHECK-NEXT:ret i64 2
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 2)
+  ret i64 %out
+}
+
+define i64 @cnth_vl4() {
+; CHECK-LABEL: @cnth_vl4(
+; CHECK-NEXT:ret i64 4
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 4)
+  ret i64 %out
+}
+
+define i64 @cnth_mul3() {
+; CHECK-LABEL: @cnth_mul3(
+; CHECK-NEXT:ret i64 24
+;
+  %cnt = call i64 @llvm.aarch64.sve.cnth(i32 8)
+  %out = mul i64 %cnt, 3
+  ret i64 %out
+}
+
+define i64 @cnth_mul4() {
+; CHECK-LABEL: @cnth_mul4(
+; CHECK-NEXT:[[CNT:%.*]] = call i64 @llvm.aarch64.sve.cnth(i32 9)
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[CNT]], 2
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %cnt = call i64 @llvm.aarch64.sve.cnth(i32 9)
+  %out = mul i64 %cnt, 4
+  ret i64 %out
+}
+
+define i64 @cnth_all() {
+; CHECK-LABEL: @cnth_all(
+; CHECK-NEXT:[[TMP1:%.*]] = call i64 @llvm.vscale.i64()
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[TMP1]], 3
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 31)
+  ret i64 %out
+}
+
+;
+; CNTW
+;
+
+define i64 @cntw_vl1() {
+; CHECK-LABEL: @cntw_vl1(
+; CHECK-NEXT:ret i64 1
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 1)
+  ret i64 %out
+}
+
+define i64 @cntw_vl2() {
+; CHECK-LABEL: @cntw_vl2(
+; CHECK-NEXT:ret i64 2
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 2)
+  ret i64 %out
+}
+
+define i64 @cntw_vl4() {
+; CHECK-LABEL: @cntw_vl4(
+; CHECK-NEXT:ret i64 4
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 4)
+  ret i64 %out
+}
+
+define i64 @cntw_mul3() {
+; CHECK-LABEL: @cntw_mul3(
+; CHECK-NEXT:[[CNT:%.*]] = call i64 @llvm.aarch64.sve.cntw(i32 8)
+; CHECK-NEXT:[[OUT:%.*]] = mul i64 [[CNT]], 3
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntw(i32 8)
+  %out = mul i64 %cnt, 3
+  ret i64 %out
+}
+
+define i64 @cntw_mul4() {
+; CHECK-LABEL: @cntw_mul4(
+; CHECK-NEXT:[[CNT:%.*]] = call i64 @llvm.aarch64.sve.cntw(i32 9)
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[CNT]], 2
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntw(i32 9)
+  %out = mul i64 %cnt, 4
+  ret i64 %out
+}
+
+define i64 @cntw_all() {
+; CHECK-LABEL: @cntw_all(
+; CHECK-NEXT:[[TMP1:%.*]] = call i64 @llvm.vscale.i64()
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[TMP1]], 2
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 31)
+  ret i64 %out
+}
+
+
+;
+; CNTD
+;
+
+define i64 @cntd_vl1() {
+; CHECK-LABEL: @cntd_vl1(
+; CHECK-NEXT: 

[clang] ae54339 - [AArch64][SVEIntrinsicOpts] Convect cntb/h/w/d to vscale intrinsic or constant.

2021-06-30 Thread Jun Ma via cfe-commits

Author: Jun Ma
Date: 2021-07-01T10:09:47+08:00
New Revision: ae5433945f915c2f0e39f8a026166cbdc8b0469c

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

LOG: [AArch64][SVEIntrinsicOpts] Convect cntb/h/w/d to vscale intrinsic or 
constant.

As is mentioned above

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

Added: 

llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-counting-elems.ll

Modified: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
index 22fb8a2e39f1a..9e4326e312c54 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
@@ -7,8 +7,9 @@
 uint64_t test_svcntb()
 {
   // CHECK-LABEL: test_svcntb
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntb(i32 31)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.vscale.i64()
+  // CHECK-NEXT: %[[RET:.*]] = shl i64 %[[INTRINSIC]], 4
+  // CHECK: ret i64 %[[RET]]
   return svcntb();
 }
 
@@ -23,72 +24,63 @@ uint64_t test_svcntb_pat()
 uint64_t test_svcntb_pat_1()
 {
   // CHECK-LABEL: test_svcntb_pat_1
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntb(i32 1)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: ret i64 1
   return svcntb_pat(SV_VL1);
 }
 
 uint64_t test_svcntb_pat_2()
 {
   // CHECK-LABEL: test_svcntb_pat_2
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntb(i32 2)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: ret i64 2
   return svcntb_pat(SV_VL2);
 }
 
 uint64_t test_svcntb_pat_3()
 {
   // CHECK-LABEL: test_svcntb_pat_3
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntb(i32 3)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: ret i64 3
   return svcntb_pat(SV_VL3);
 }
 
 uint64_t test_svcntb_pat_4()
 {
   // CHECK-LABEL: test_svcntb_pat_4
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntb(i32 4)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: ret i64 4
   return svcntb_pat(SV_VL4);
 }
 
 uint64_t test_svcntb_pat_5()
 {
   // CHECK-LABEL: test_svcntb_pat_5
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntb(i32 5)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: ret i64 5
   return svcntb_pat(SV_VL5);
 }
 
 uint64_t test_svcntb_pat_6()
 {
   // CHECK-LABEL: test_svcntb_pat_6
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntb(i32 6)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: ret i64 6
   return svcntb_pat(SV_VL6);
 }
 
 uint64_t test_svcntb_pat_7()
 {
   // CHECK-LABEL: test_svcntb_pat_7
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntb(i32 7)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: ret i64 7
   return svcntb_pat(SV_VL7);
 }
 
 uint64_t test_svcntb_pat_8()
 {
   // CHECK-LABEL: test_svcntb_pat_8
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntb(i32 8)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: ret i64 8
   return svcntb_pat(SV_VL8);
 }
 
 uint64_t test_svcntb_pat_9()
 {
   // CHECK-LABEL: test_svcntb_pat_9
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntb(i32 9)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: ret i64 16
   return svcntb_pat(SV_VL16);
 }
 
@@ -143,7 +135,8 @@ uint64_t test_svcntb_pat_15()
 uint64_t test_svcntb_pat_16()
 {
   // CHECK-LABEL: test_svcntb_pat_16
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntb(i32 31)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.vscale.i64()
+  // CHECK-NEXT: %[[RET:.*]] = shl i64 %[[INTRINSIC]], 4
+  // CHECK: ret i64 %[[RET]]
   return svcntb_pat(SV_ALL);
 }

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
index 86108629d94ab..9880968bae9b0 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
@@ -7,8 +7,9 @@
 uint64_t test_svcntd()
 {
   // CHECK-LABEL: test_svcntd
-  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 31)
-  // CHECK: ret i64 %[[INTRINSIC]]
+  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.vscale.i64()
+  // CHECK-NEXT: %[[RET:.*]] = shl i64 %[[INTRINSIC]], 1
+  // CHECK: ret i64 %[[RET]]
   return svcntd();
 }
 
@@ -23,16 +24,14 @@ uint64_t test_svcntd_pat()
 uint64_t test_svcntd_pat_1()
 {
   // CHECK-LABEL: test_svcntd_pat_1
-  // 

[PATCH] D105254: [RISCV] Support machine constraint "S"

2021-06-30 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Hm, AArch64 handles ExternalSymbolSDNode too, but I don't see how you could 
ever end up with one...




Comment at: llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll:7
+
+; Function Attrs: nofree nosync nounwind readnone
+define dso_local i8* @constraint_S() #1 {

These should be stripped



Comment at: llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll:8
+; Function Attrs: nofree nosync nounwind readnone
+define dso_local i8* @constraint_S() #1 {
+; RV32-LABEL: constraint_S:

`#1` doesn't exist



Comment at: llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll:24
+; RV64-NEXT:ret
+entry:
+  %0 = tail call i8* asm "lui $0, %hi($1)\0Aaddi $0,$0,%lo($1)", "=r,S"(i32* 
nonnull @var)

Label isn't needed



Comment at: llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll:25
+entry:
+  %0 = tail call i8* asm "lui $0, %hi($1)\0Aaddi $0,$0,%lo($1)", "=r,S"(i32* 
nonnull @var)
+  ret i8* %0

for consistency



Comment at: llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll:53
+
+L1:   ; preds = %entry
+  %0 = tail call i8* asm "lui $0, %hi($1)\0Aaddi $0,$0,%lo($1)", "=r,S"(i8* 
blockaddress(@constraint_S_label, %L1))

Don't need the comment



Comment at: llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll:54
+L1:   ; preds = %entry
+  %0 = tail call i8* asm "lui $0, %hi($1)\0Aaddi $0,$0,%lo($1)", "=r,S"(i8* 
blockaddress(@constraint_S_label, %L1))
+  ret i8* %0

Ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105254

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


[PATCH] D105112: [clang] Add -fdump-record-layouts-canonical option

2021-06-30 Thread David Tenty via Phabricator via cfe-commits
daltenty added a comment.

In D105112#2850990 , @stevewan wrote:

> I'm not familiar with `getCanonicalType()`, can you confirm whether it sees 
> through nested typedef's?

Add a test case that hopefully will cover the case you intend


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105112

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


[PATCH] D105112: [clang] Add -fdump-record-layouts-canonical option

2021-06-30 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 355741.
daltenty added a comment.

- Update test case with nested typedef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105112

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/dump-canonical.cpp


Index: clang/test/Layout/dump-canonical.cpp
===
--- /dev/null
+++ clang/test/Layout/dump-canonical.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm-only -fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -fdump-record-layouts-canonical %s | 
FileCheck %s -check-prefix CANONICAL
+
+typedef long foo_t;
+
+
+struct a {
+  foo_t x;
+} b;
+
+struct c {
+  typedef foo_t bar_t;
+  bar_t x;
+} d;
+
+// CHECK:  0 | foo_t
+// CHECK:  0 | c::bar_t
+// CANONICAL-NOT:  0 | foo_t
+// CANONICAL-NOT:  0 | c::bar_t
+// CANONICAL:  0 | long
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -3577,7 +3577,10 @@
 } else {
   PrintOffset(OS, FieldOffset, IndentLevel);
 }
-OS << Field.getType().getAsString() << ' ' << Field << '\n';
+const QualType  = C.getLangOpts().DumpRecordLayoutsCanonical
+? Field.getType().getCanonicalType()
+: Field.getType();
+OS << FieldType.getAsString() << ' ' << Field << '\n';
   }
 
   // Dump virtual bases.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5381,13 +5381,16 @@
 def fdump_record_layouts_simple : Flag<["-"], "fdump-record-layouts-simple">,
   HelpText<"Dump record layout information in a simple form used for testing">,
   MarshallingInfoFlag>;
+def fdump_record_layouts_canonical : Flag<["-"], 
"fdump-record-layouts-canonical">,
+  HelpText<"Dump record layout information with canonical field types">,
+  MarshallingInfoFlag>;
 def fdump_record_layouts_complete : Flag<["-"], 
"fdump-record-layouts-complete">,
   HelpText<"Dump record layout information for all complete types">,
   MarshallingInfoFlag>;
 def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">,
   HelpText<"Dump record layout information">,
   MarshallingInfoFlag>,
-  ImpliedByAnyOf<[fdump_record_layouts_simple.KeyPath, 
fdump_record_layouts_complete.KeyPath]>;
+  ImpliedByAnyOf<[fdump_record_layouts_simple.KeyPath, 
fdump_record_layouts_complete.KeyPath, fdump_record_layouts_canonical.KeyPath]>;
 def fix_what_you_can : Flag<["-"], "fix-what-you-can">,
   HelpText<"Apply fix-it advice even in the presence of unfixable errors">,
   MarshallingInfoFlag>;
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -265,6 +265,7 @@
 BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
 BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd 
records")
 BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd 
records in a simple form")
+BENIGN_LANGOPT(DumpRecordLayoutsCanonical , 1, 0, "dumping the AST layout of 
records using canonical field types")
 BENIGN_LANGOPT(DumpRecordLayoutsComplete , 1, 0, "dumping the AST layout of 
all complete records")
 BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted 
vtables")
 LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings")


Index: clang/test/Layout/dump-canonical.cpp
===
--- /dev/null
+++ clang/test/Layout/dump-canonical.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm-only -fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -fdump-record-layouts-canonical %s | FileCheck %s -check-prefix CANONICAL
+
+typedef long foo_t;
+
+
+struct a {
+  foo_t x;
+} b;
+
+struct c {
+  typedef foo_t bar_t;
+  bar_t x;
+} d;
+
+// CHECK:  0 | foo_t
+// CHECK:  0 | c::bar_t
+// CANONICAL-NOT:  0 | foo_t
+// CANONICAL-NOT:  0 | c::bar_t
+// CANONICAL:  0 | long
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -3577,7 +3577,10 @@
 } else {
   PrintOffset(OS, FieldOffset, IndentLevel);
 }
-OS << Field.getType().getAsString() << ' ' << Field << '\n';
+const QualType  = C.getLangOpts().DumpRecordLayoutsCanonical
+? 

[PATCH] D105236: [PowerPC] Implament Atomic Load and Stores Builtins

2021-06-30 Thread Kai Luo via Phabricator via cfe-commits
lkail added a comment.

The wording might be inaccurate. It's better to rephrase to 'Load and Reserve 
and Store Conditional'.




Comment at: llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1724
+
+let Predicates = [HasP8Altivec] in {
+  def : Pat<(int_ppc_stdcx xoaddr:$dst, g8rc:$A),

IIRC, `l(w|d)arx`, `st(w|d)cx` are supported very early and don't need altivec 
support.



Comment at: 
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-atomicLoadStore-64-only.ll:7
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK
+

Is `-mcpu=pwr9` necessary?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105236

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


[PATCH] D105254: [RISCV] Support machine constraint "S"

2021-06-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
Herald added subscribers: vkmr, frasercrmck, evandro, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Similar to D46745 , "S" represents an absolute 
symbolic operand, which
can be used to specify the access models, e.g.

  extern int var;
  void *addr_via_asm() {
void *ret;
asm("lui %0, %%hi(%1)\naddi %0,%0,%%lo(%1)" : "=r"(ret) : "S"());
return ret;
  }

We need 'S' to be documented on GCC: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101275


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105254

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/CodeGen/RISCV/riscv-inline-asm.c
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll

Index: llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll
@@ -0,0 +1,56 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s --check-prefix=RV32
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --check-prefix=RV64
+
+@var = external dso_local global i32, align 4
+
+; Function Attrs: nofree nosync nounwind readnone
+define dso_local i8* @constraint_S() #1 {
+; RV32-LABEL: constraint_S:
+; RV32:   # %bb.0: # %entry
+; RV32-NEXT:#APP
+; RV32-NEXT:lui a0, %hi(var)
+; RV32-NEXT:addi a0, a0, %lo(var)
+; RV32-NEXT:#NO_APP
+; RV32-NEXT:ret
+;
+; RV64-LABEL: constraint_S:
+; RV64:   # %bb.0: # %entry
+; RV64-NEXT:#APP
+; RV64-NEXT:lui a0, %hi(var)
+; RV64-NEXT:addi a0, a0, %lo(var)
+; RV64-NEXT:#NO_APP
+; RV64-NEXT:ret
+entry:
+  %0 = tail call i8* asm "lui $0, %hi($1)\0Aaddi $0,$0,%lo($1)", "=r,S"(i32* nonnull @var)
+  ret i8* %0
+}
+
+; Function Attrs: nofree nosync nounwind readnone
+define dso_local i8* @constraint_S_label() #1 {
+; RV32-LABEL: constraint_S_label:
+; RV32:   # %bb.0: # %entry
+; RV32-NEXT:  .Ltmp0: # Block address taken
+; RV32-NEXT:  # %bb.1: # %L1
+; RV32-NEXT:#APP
+; RV32-NEXT:lui a0, %hi(.Ltmp0)
+; RV32-NEXT:addi a0, a0, %lo(.Ltmp0)
+; RV32-NEXT:#NO_APP
+; RV32-NEXT:ret
+;
+; RV64-LABEL: constraint_S_label:
+; RV64:   # %bb.0: # %entry
+; RV64-NEXT:  .Ltmp0: # Block address taken
+; RV64-NEXT:  # %bb.1: # %L1
+; RV64-NEXT:#APP
+; RV64-NEXT:lui a0, %hi(.Ltmp0)
+; RV64-NEXT:addi a0, a0, %lo(.Ltmp0)
+; RV64-NEXT:#NO_APP
+; RV64-NEXT:ret
+entry:
+  br label %L1
+
+L1:   ; preds = %entry
+  %0 = tail call i8* asm "lui $0, %hi($1)\0Aaddi $0,$0,%lo($1)", "=r,S"(i8* blockaddress(@constraint_S_label, %L1))
+  ret i8* %0
+}
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -8240,6 +8240,8 @@
   return C_Immediate;
 case 'A':
   return C_Memory;
+case 'S': // A symbolic address
+  return C_Other;
 }
   }
   return TargetLowering::getConstraintType(Constraint);
@@ -8469,6 +8471,16 @@
   DAG.getTargetConstant(CVal, SDLoc(Op), Subtarget.getXLenVT()));
   }
   return;
+case 'S':
+  if (const GlobalAddressSDNode *GA = dyn_cast(Op)) {
+Ops.push_back(DAG.getTargetGlobalAddress(GA->getGlobal(), SDLoc(Op),
+ GA->getValueType(0)));
+  } else if (const BlockAddressSDNode *BA =
+ dyn_cast(Op)) {
+Ops.push_back(DAG.getTargetBlockAddress(BA->getBlockAddress(),
+BA->getValueType(0)));
+  }
+  return;
 default:
   break;
 }
Index: clang/test/CodeGen/RISCV/riscv-inline-asm.c
===
--- clang/test/CodeGen/RISCV/riscv-inline-asm.c
+++ clang/test/CodeGen/RISCV/riscv-inline-asm.c
@@ -44,3 +44,9 @@
 // CHECK: call void asm sideeffect "", "*A"(i32* %p)
   asm volatile("" :: "A"(*p));
 }
+
+void test_S() {
+// CHECK-LABEL: define{{.*}} void @test_S()
+// CHECK: call void asm sideeffect "", "S"(float* nonnull @f)
+  asm volatile("" :: "S"());
+}
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -87,6 +87,9 @@
 // An address that is held in a general-purpose register.
 Info.setAllowsMemory();
 return 

[clang] e95106f - Add a target triple to fix failures on MS build bots.

2021-06-30 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-06-30T17:27:26-07:00
New Revision: e95106f50190d7a25dfad57adf0317ca6cfa9a4f

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

LOG: Add a target triple to fix failures on MS build bots.

-ast-dump=json tries to mangle every declaration, and under the MS ABI
there are still a few things we can't mangle, which caused this test to
assert.

Added: 


Modified: 
clang/test/Coverage/ast-printing.cpp

Removed: 




diff  --git a/clang/test/Coverage/ast-printing.cpp 
b/clang/test/Coverage/ast-printing.cpp
index c1ce70478d74..97279e47b55c 100644
--- a/clang/test/Coverage/ast-printing.cpp
+++ b/clang/test/Coverage/ast-printing.cpp
@@ -4,7 +4,7 @@
 // RUN: 
diff  %t.1.cpp %t.2.cpp
 // RUN: %clang_cc1 -std=c++20 -ast-dump %s
 // RUN: %clang_cc1 -std=c++20 -ast-dump-all %s
-// RUN: %clang_cc1 -std=c++20 -ast-dump=json %s
+// RUN: %clang_cc1 -std=c++20 -ast-dump=json -triple=x86_64-linux-gnu %s
 // RUN: %clang_cc1 -std=c++20 -fdump-record-layouts %s
 
 #include "cxx-language-features.inc"



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


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:1491
+def err_constexpr_if_condition_expression_is_not_constant : Error<
+  "constexpr if condition is not a constant expression convertible to bool">;
 def err_static_assert_failed : Error<"static_assert failed%select{ %1|}0">;

mizvekov wrote:
> cor3ntin wrote:
> > mizvekov wrote:
> > > Looks a bit easier to parse the english there.
> > I would rather not change that, to remain consistent with existing 
> > diagnostics involving `constexpr if`
> > But I agree it might be good to change them all
> I see, yeah agreed.
Would it be reasonable to drop the "convertible to bool" part here? We know the 
problem is that the (converted) expression is not a constant expression, not 
that the expression can't be converted to bool, because we handle the 
conversion to bool separately before we get to this diagnostic; I think the 
diagnostic would be clearer if it didn't mention the conversion.



Comment at: clang/www/cxx_status.html:1299
   https://wg21.link/P1401R5;>P1401R5
-  No
+  Clang 13
 

cor3ntin wrote:
> rsmith wrote:
> > This should be class `unreleased` (yellow) for now so that people can 
> > easily tell what's in the most recent Clang release versus what's 
> > implemented but not released; we convert all the `class="unreleased"` to 
> > `class="full"` when we cut a release.
> Would you prefer I mark it partial for the explicit bool case?
If you're not planning on working on `explicit(bool)` yourself, then I think 
marking it as "partial" might be useful as a reminder that we should go back 
and look at that paper again. Otherwise, I have no strong preference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


[clang-tools-extra] 5b8ddd2 - Fix test following Clang change ef227b3.

2021-06-30 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-06-30T17:11:55-07:00
New Revision: 5b8ddd2ccceb8de04bd020f286bc3ca38638ecb1

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

LOG: Fix test following Clang change ef227b3.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 67dcb574d500a..bccf98ee07ab4 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -464,7 +464,7 @@ TEST_F(TargetDeclTest, Concept) {
   )cpp";
   EXPECT_DECLS(
   "ConceptSpecializationExpr",
-  {"template  concept Fooable = requires (T t) { t.foo(); 
};"});
+  {"template  concept Fooable = requires (T t) { t.foo(); }"});
 
   // trailing requires clause
   Code = R"cpp(
@@ -475,7 +475,7 @@ TEST_F(TargetDeclTest, Concept) {
   void foo() requires [[Fooable]];
   )cpp";
   EXPECT_DECLS("ConceptSpecializationExpr",
-   {"template  concept Fooable = true;"});
+   {"template  concept Fooable = true"});
 
   // constrained-parameter
   Code = R"cpp(
@@ -486,7 +486,7 @@ TEST_F(TargetDeclTest, Concept) {
 void bar(T t);
   )cpp";
   EXPECT_DECLS("ConceptSpecializationExpr",
-   {"template  concept Fooable = true;"});
+   {"template  concept Fooable = true"});
 
   // partial-concept-id
   Code = R"cpp(
@@ -497,7 +497,7 @@ TEST_F(TargetDeclTest, Concept) {
 void bar(T t);
   )cpp";
   EXPECT_DECLS("ConceptSpecializationExpr",
-   {"template  concept Fooable = true;"});
+   {"template  concept Fooable = true"});
 }
 
 TEST_F(TargetDeclTest, FunctionTemplate) {



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


[PATCH] D105099: [clang-format] Add an option to put one constructor initializer per line

2021-06-30 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

>>   Else:
>> ...
>
> Is there anything else in the "Else:" part above? Is there an option that we 
> forgot?

No, it's just what you called "one other enum value for the default case 
without special handling."

> I'm not sure if I understand you correctly. Is your point that an enum option 
> would be hard to find by the users?
> But if the doc of each currently existing option pointed to this enum option 
> it would be pretty easy, no?

An enum makes it easier for the user to find all related options, but my point 
is that in this case it would be harder for the user to relate the enum names 
to the behaviors because of the nested `If`.

> Or does backward compatibility seem difficult to achieve? It should be a 
> straightforward mapping.

Part of backward compatibility is not breaking/changing existing unit tests, 
which may be difficult to do.

> Also, I find that having option that are mutually exclusive (or one that 
> doesn't change anything when another is enabled) is a smell that tells us to 
> use an enum.

You are not suggesting using two enums, one for the outer `If` and the other 
for the nested `If`, right?

If we didn't have `AllOnOneLineOrOnePerLine`, we could simply use an enum for 
`ConstructorInitializer` with three values:

- `OnePerLine` (i.e., `AlwaysOnePerLine = true`)
- `BinPack` (i.e., `AllOnOneLineOrOnePerLine = OnNextLine = true`)
- `Neither` (i.e., `AlwaysOnePerLine = AllOnOneLineOrOnePerLine = false`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105099

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


[PATCH] D98710: [clang-tidy] Add --skip-headers, part 1 (use setTraversalScope)

2021-06-30 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

I reproduced the ClangdTests::TargetDeclTest.Concept failure locally without 
this change,
using llvm git commit 0c400e8953 
. Will 
wait for upstream fix of the failed tests.


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

https://reviews.llvm.org/D98710

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


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 355720.
cor3ntin added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
  clang/test/SemaCXX/static-assert.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1296,7 +1296,7 @@
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5;>P1401R5
-  No
+  Clang 13
 
 
   Trimming whitespaces before line splicing
Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -188,3 +188,14 @@
 }
 void callFoo4() { foo4(42); }
 // expected-note@-1{{in instantiation of function template specialization 'foo4' requested here}}
+
+static_assert(42, "message");
+static_assert(42.0, "message"); // expected-warning {{implicit conversion from 'double' to 'bool' changes value from 42 to true}}
+constexpr int *p = 0;
+static_assert(p, "message"); // expected-error {{static_assert failed}}
+
+struct NotBool {
+} notBool;
+constexpr NotBool constexprNotBool;
+static_assert(notBool, "message");  // expected-error {{value of type 'struct NotBool' is not contextually convertible to 'bool'}}
+static_assert(constexprNotBool, "message"); // expected-error {{value of type 'const NotBool' is not contextually convertible to 'bool'}}
\ No newline at end of file
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
===
--- clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
@@ -38,18 +38,38 @@
 }
 #else
 namespace ccce {
+
+struct S {
+} s;
   void f() {
 if (5) {}
-if constexpr (5) {} // expected-error {{cannot be narrowed}}
+if constexpr (5) {
+}
   }
   template void g() {
-if constexpr (N) {} // expected-error {{cannot be narrowed}}
+if constexpr (N) {
+}
   }
-  template void g<5>(); // expected-note {{instantiation of}}
+  template void g<5>();
   void h() {
-if constexpr (4.3) {} // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (4.3) { //expected-warning {{implicit conversion from 'double' to 'bool' changes value}}
+}
 constexpr void *p = nullptr;
-if constexpr (p) {} // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (p) {
+}
+  }
+
+  void not_constant(int b, S s) { //  expected-note 2{{declared here}}
+if constexpr (bool(b)) {  // expected-error {{constexpr if condition is not a constant expression}} expected-note {{cannot be used in a constant expression}}
+}
+if constexpr (b) { // expected-error {{constexpr if condition is not a constant expression}} expected-note {{cannot be used in a constant expression}}
+}
+if constexpr (s) { // expected-error {{value of type 'ccce::S' is not contextually convertible to 'bool'}}
+}
+
+constexpr S constexprS;
+if constexpr (constexprS) { // expected-error {{value of type 'const ccce::S' is not contextually convertible to 'bool'}}
+}
   }
 }
 
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5634,12 +5634,8 @@
   //  implicitly converted to type T, where the converted
   //  expression is a constant expression and the implicit conversion
   //  sequence contains only [... list of conversions ...].
-  // C++1z [stmt.if]p2:
-  //  If the if statement is of the form if constexpr, the value of the
-  //  condition shall be a contextually converted constant expression of type
-  //  bool.
   ImplicitConversionSequence ICS =
-  CCE == Sema::CCEK_ConstexprIf || CCE == Sema::CCEK_ExplicitBool
+  CCE == Sema::CCEK_ExplicitBool
   ? TryContextuallyConvertToBool(S, From)
   : TryCopyInitialization(S, From, T,
   /*SuppressUserConversions=*/false,
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -3911,7 +3911,7 @@
 
 /// CheckCXXBooleanCondition - Returns true if a conversion to bool is invalid.
 ExprResult Sema::CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr) {
-  // C++ 6.4p4:
+  // C++11 6.4p4:
   // The value of a 

[PATCH] D104871: [Docs] use -fprofile-generate for IR PGO and -fprofile-instr-generate for code coverage

2021-06-30 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 355718.
zequanwu marked 4 inline comments as done.
zequanwu added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104871

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/UsersManual.rst

Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -1876,14 +1876,14 @@
 Although both techniques are used for similar purposes, there are important
 differences between the two:
 
-1. Profile data generated with one cannot be used by the other, and there is no
-   conversion tool that can convert one to the other. So, a profile generated
-   via ``-fprofile-instr-generate`` must be used with ``-fprofile-instr-use``.
-   Similarly, sampling profiles generated by external profilers must be
+1. For profile guided optimizations, we recommend using IR PGO, aka using 
+   ``-fprofile-generate`` with ``-fprofile-use``.
+   Sampling profiles generated by external profilers must be
converted and used with ``-fprofile-sample-use``.
 
-2. Instrumentation profile data can be used for code coverage analysis and
-   optimization.
+2. Instrumentation profile data generated via ``-fprofile-generate`` can be used 
+   for optimization and data generated via 
+   ``-fprofile-instr-generate`` can be used for code coverage analysis.
 
 3. Sampling profiles can only be used for optimization. They cannot be used for
code coverage analysis. Although it would be technically possible to use
@@ -2120,20 +2120,20 @@
 sampling profiler. It also provides reproducible results, at least to the
 extent that the code behaves consistently across runs.
 
-Here are the steps for using profile guided optimization with
+Here are the steps for using profile guided optimization with LLVM IR
 instrumentation:
 
 1. Build an instrumented version of the code by compiling and linking with the
-   ``-fprofile-instr-generate`` option.
+   ``-fprofile-generate`` option.
 
.. code-block:: console
 
- $ clang++ -O2 -fprofile-instr-generate code.cc -o code
+ $ clang++ -O2 -fprofile-generate code.cc -o code
 
 2. Run the instrumented executable with inputs that reflect the typical usage.
By default, the profile data will be written to a ``default.profraw`` file
in the current directory. You can override that default by using option
-   ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE`` 
+   ``-fprofile-generate=`` or by setting the ``LLVM_PROFILE_FILE`` 
environment variable to specify an alternate file. If non-default file name
is specified by both the environment variable and the command line option,
the environment variable takes precedence. The file name pattern specified
@@ -2185,29 +2185,32 @@
Note that this step is necessary even when there is only one "raw" profile,
since the merge operation also changes the file format.
 
-4. Build the code again using the ``-fprofile-instr-use`` option to specify the
+4. Build the code again using the ``-fprofile-use`` option to specify the
collected profile data.
 
.. code-block:: console
 
- $ clang++ -O2 -fprofile-instr-use=code.profdata code.cc -o code
+ $ clang++ -O2 -fprofile-use=code.profdata code.cc -o code
 
You can repeat step 4 as often as you like without regenerating the
profile. As you make changes to your code, clang may no longer be able to
use the profile data. It will warn you when this happens.
 
 Profile generation using an alternative instrumentation method can be
-controlled by the GCC-compatible flags ``-fprofile-generate`` and
-``-fprofile-use``. Although these flags are semantically equivalent to
-their GCC counterparts, they *do not* handle GCC-compatible profiles.
-They are only meant to implement GCC's semantics with respect to
+controlled by ``-fprofile-instr-generate``, which is the AST-based 
+instrumentation used for code coverage analysis 
+(:doc:`source based code coverage `). 
+
+Although the flags ``-fprofile-generate`` and ``-fprofile-use`` are semantically
+equivalent to their GCC counterparts, they *do not* handle GCC-compatible 
+profiles. They are only meant to implement GCC's semantics with respect to
 profile creation and use. Flag ``-fcs-profile-generate`` also instruments
 programs using the same instrumentation method as ``-fprofile-generate``.
 
 .. option:: -fprofile-generate[=]
 
   The ``-fprofile-generate`` and ``-fprofile-generate=`` flags will use
-  an alternative instrumentation method for profile generation. When
+  an instrumentation method for profile generation. When
   given a directory name, it generates the profile file
   ``default_%m.profraw`` in the directory named ``dirname`` if specified.
   If ``dirname`` does not exist, it will be created at runtime. ``%m`` specifier
@@ -2326,7 +2329,7 

[PATCH] D104500: [clang] Apply P1825 as Defect Report from C++11 up to C++20.

2021-06-30 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 355714.
mizvekov added a comment.

- fix test diagnostic expectation using regular expressions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104500

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/SemaCXX/P1155.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/warn-return-std-move.cpp
  clang/test/SemaObjCXX/block-capture.mm

Index: clang/test/SemaObjCXX/block-capture.mm
===
--- clang/test/SemaObjCXX/block-capture.mm
+++ clang/test/SemaObjCXX/block-capture.mm
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx20_2b,cxx2b %s
-// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx20_2b   %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx98_11   %s
-// RUN: %clang_cc1 -std=c++98 -fsyntax-only -fobjc-arc -fblocks -Wno-c++11-extensions -verify=cxx98_2b,cxx98_11   %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b,cxx2b %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b   %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b   %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -fobjc-arc -fblocks -Wno-c++11-extensions -verify=cxx98_2b,cxx98  %s
 
 #define TEST(T) void test_##T() { \
   __block T x;\
@@ -14,54 +14,68 @@
 };
 TEST(CopyOnly); // cxx2b-error {{no matching constructor}}
 
+struct ConstCopyOnly {
+  ConstCopyOnly();
+  ConstCopyOnly(ConstCopyOnly &) = delete; // cxx98-note {{marked deleted here}}
+  ConstCopyOnly(const ConstCopyOnly &);
+};
+TEST(ConstCopyOnly); // cxx98-error {{call to deleted constructor}}
+
+struct NonConstCopyOnly {
+  NonConstCopyOnly();
+  NonConstCopyOnly(NonConstCopyOnly &);
+  NonConstCopyOnly(const NonConstCopyOnly &) = delete; // cxx11_2b-note {{marked deleted here}}
+};
+TEST(NonConstCopyOnly); // cxx11_2b-error {{call to deleted constructor}}
+
 struct CopyNoMove {
   CopyNoMove();
   CopyNoMove(CopyNoMove &);
-  CopyNoMove(CopyNoMove &&) = delete; // cxx98_2b-note {{marked deleted here}}
+  CopyNoMove(CopyNoMove &&) = delete; // cxx11_2b-note {{marked deleted here}}
 };
-TEST(CopyNoMove); // cxx98_2b-error {{call to deleted constructor}}
+TEST(CopyNoMove); // cxx11_2b-error {{call to deleted constructor}}
 
 struct MoveOnly {
   MoveOnly();
-  MoveOnly(MoveOnly &) = delete;
+  MoveOnly(MoveOnly &) = delete; // cxx98-note {{marked deleted here}}
   MoveOnly(MoveOnly &&);
 };
-TEST(MoveOnly);
+TEST(MoveOnly); // cxx98-error {{call to deleted constructor}}
 
 struct NoCopyNoMove {
   NoCopyNoMove();
-  NoCopyNoMove(NoCopyNoMove &) = delete;
-  NoCopyNoMove(NoCopyNoMove &&) = delete; // cxx98_2b-note {{marked deleted here}}
+  NoCopyNoMove(NoCopyNoMove &) = delete;  // cxx98-note {{marked deleted here}}
+  NoCopyNoMove(NoCopyNoMove &&) = delete; // cxx11_2b-note {{marked deleted here}}
 };
 TEST(NoCopyNoMove); // cxx98_2b-error {{call to deleted constructor}}
 
 struct ConvertingRVRef {
   ConvertingRVRef();
-  ConvertingRVRef(ConvertingRVRef &) = delete; // cxx98_11-note {{marked deleted here}}
+  ConvertingRVRef(ConvertingRVRef &) = delete; // cxx98-note {{marked deleted here}}
 
   struct X {};
   ConvertingRVRef(X &&);
   operator X() const & = delete;
   operator X() &&;
 };
-TEST(ConvertingRVRef); // cxx98_11-error {{call to deleted constructor}}
+TEST(ConvertingRVRef); // cxx98-error {{call to deleted constructor}}
 
 struct ConvertingCLVRef {
   ConvertingCLVRef();
   ConvertingCLVRef(ConvertingCLVRef &);
 
   struct X {};
-  ConvertingCLVRef(X &&); // cxx20_2b-note {{passing argument to parameter here}}
+  ConvertingCLVRef(X &&); // cxx11_2b-note {{passing argument to parameter here}}
   operator X() const &;
-  operator X() && = delete; // cxx20_2b-note {{marked deleted here}}
+  operator X() && = delete; // cxx11_2b-note {{marked deleted here}}
 };
-TEST(ConvertingCLVRef); // cxx20_2b-error {{invokes a deleted function}}
+TEST(ConvertingCLVRef); // cxx11_2b-error {{invokes a deleted function}}
 
 struct SubSubMove {};
 struct SubMove : SubSubMove {
   SubMove();
-  SubMove(SubMove &) = delete; // cxx98_11-note {{marked deleted here}}
+  SubMove(SubMove &) = delete; // cxx98-note {{marked deleted here}}
 
   SubMove(SubSubMove &&);
 };
-TEST(SubMove); // cxx98_11-error {{call to deleted constructor}}
+TEST(SubMove); // cxx98-error {{call to deleted constructor}}
Index: 

[PATCH] D105242: [clang] Don't emit uninstantiated templates with -fdump-record-layouts-complete

2021-06-30 Thread David Tenty via Phabricator via cfe-commits
daltenty created this revision.
daltenty added a reviewer: stevewan.
daltenty requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A follow on to D104484 , this blocks the 
emitting of some template cases
where we would hit an assert because though the type was complete,
the class template wasn't fully specialized and adds a test case for the
corresponding test case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105242

Files:
  clang/lib/AST/Decl.cpp
  clang/test/Layout/dump-complete.cpp


Index: clang/test/Layout/dump-complete.cpp
===
--- clang/test/Layout/dump-complete.cpp
+++ clang/test/Layout/dump-complete.cpp
@@ -12,7 +12,23 @@
 
 class d;
 
+template 
+struct B : public A {};
+
+template 
+struct D : public C {};
+
+template<> struct D;
+
+template 
+struct F : public E {};
+
+F bar;
+
 // CHECK:  0 | struct a
 // CHECK:  0 | struct b
 // CHECK:  0 | class c
 // CHECK-NOT:  0 | class d
+// CHECK-NOT:  0 | struct B
+// CHECK-NOT:  0 | struct D
+// CHECK : 0 | struct F
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -4585,7 +4585,9 @@
 
   // Layouts are dumped when computed, so if we are dumping for all complete
   // types, we need to force usage to get types that wouldn't be used 
elsewhere.
-  if (Ctx.getLangOpts().DumpRecordLayoutsComplete)
+  if (Ctx.getLangOpts().DumpRecordLayoutsComplete &&
+  (!isa(this) ||
+   !cast(this)->getDescribedClassTemplate()))
 (void)Ctx.getASTRecordLayout(this);
 }
 


Index: clang/test/Layout/dump-complete.cpp
===
--- clang/test/Layout/dump-complete.cpp
+++ clang/test/Layout/dump-complete.cpp
@@ -12,7 +12,23 @@
 
 class d;
 
+template 
+struct B : public A {};
+
+template 
+struct D : public C {};
+
+template<> struct D;
+
+template 
+struct F : public E {};
+
+F bar;
+
 // CHECK:  0 | struct a
 // CHECK:  0 | struct b
 // CHECK:  0 | class c
 // CHECK-NOT:  0 | class d
+// CHECK-NOT:  0 | struct B
+// CHECK-NOT:  0 | struct D
+// CHECK : 0 | struct F
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -4585,7 +4585,9 @@
 
   // Layouts are dumped when computed, so if we are dumping for all complete
   // types, we need to force usage to get types that wouldn't be used elsewhere.
-  if (Ctx.getLangOpts().DumpRecordLayoutsComplete)
+  if (Ctx.getLangOpts().DumpRecordLayoutsComplete &&
+  (!isa(this) ||
+   !cast(this)->getDescribedClassTemplate()))
 (void)Ctx.getASTRecordLayout(this);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 355706.
cor3ntin added a comment.

- Apply the change to all C++ version
- Add more tests for static_assert


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
  clang/test/SemaCXX/static-assert.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1296,7 +1296,7 @@
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5;>P1401R5
-  No
+  Clang 13
 
 
   Trimming whitespaces before line splicing
Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -188,3 +188,14 @@
 }
 void callFoo4() { foo4(42); }
 // expected-note@-1{{in instantiation of function template specialization 'foo4' requested here}}
+
+
+static_assert(42, "message");
+static_assert(42.0, "message"); // expected-warning {{implicit conversion from 'double' to 'bool' changes value from 42 to true}}
+constexpr int* p = 0;
+static_assert(p, "message"); // expected-error {{static_assert failed}}
+
+struct NotBool {} notBool;
+constexpr NotBool constexprNotBool;
+static_assert(notBool, "message"); // expected-error {{value of type 'struct NotBool' is not contextually convertible to 'bool'}}
+static_assert(constexprNotBool, "message"); // expected-error {{value of type 'const NotBool' is not contextually convertible to 'bool'}}
\ No newline at end of file
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
===
--- clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
@@ -38,18 +38,38 @@
 }
 #else
 namespace ccce {
+
+  struct S {
+  } s;
   void f() {
 if (5) {}
-if constexpr (5) {} // expected-error {{cannot be narrowed}}
+if constexpr (5) {
+}
   }
   template void g() {
-if constexpr (N) {} // expected-error {{cannot be narrowed}}
+if constexpr (N) {
+}
   }
-  template void g<5>(); // expected-note {{instantiation of}}
+  template void g<5>();
   void h() {
-if constexpr (4.3) {} // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (4.3) { //expected-warning {{implicit conversion from 'double' to 'bool' changes value}}
+}
 constexpr void *p = nullptr;
-if constexpr (p) {} // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (p) {
+}
+  }
+
+  void not_constant(int b, S s) { //  expected-note 2{{declared here}}
+if constexpr (bool(b)) {  // expected-error {{constexpr if condition is not a constant expression}} expected-note {{cannot be used in a constant expression}}
+}
+if constexpr (b) { // expected-error {{constexpr if condition is not a constant expression}} expected-note {{cannot be used in a constant expression}}
+}
+if constexpr (s) { // expected-error {{value of type 'ccce::S' is not contextually convertible to 'bool'}}
+}
+
+constexpr S constexprS;
+if constexpr (constexprS) { // expected-error {{value of type 'const ccce::S' is not contextually convertible to 'bool'}}
+}
   }
 }
 
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5634,12 +5634,7 @@
   //  implicitly converted to type T, where the converted
   //  expression is a constant expression and the implicit conversion
   //  sequence contains only [... list of conversions ...].
-  // C++1z [stmt.if]p2:
-  //  If the if statement is of the form if constexpr, the value of the
-  //  condition shall be a contextually converted constant expression of type
-  //  bool.
-  ImplicitConversionSequence ICS =
-  CCE == Sema::CCEK_ConstexprIf || CCE == Sema::CCEK_ExplicitBool
+  ImplicitConversionSequence ICS =  CCE == Sema::CCEK_ExplicitBool
   ? TryContextuallyConvertToBool(S, From)
   : TryCopyInitialization(S, From, T,
   /*SuppressUserConversions=*/false,
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -3911,7 +3911,7 @@
 
 /// CheckCXXBooleanCondition - Returns true if a conversion to bool is invalid.
 ExprResult Sema::CheckCXXBooleanCondition(Expr 

[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/www/cxx_status.html:1299
   https://wg21.link/P1401R5;>P1401R5
-  No
+  Clang 13
 

rsmith wrote:
> This should be class `unreleased` (yellow) for now so that people can easily 
> tell what's in the most recent Clang release versus what's implemented but 
> not released; we convert all the `class="unreleased"` to `class="full"` when 
> we cut a release.
Would you prefer I mark it partial for the explicit bool case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


[PATCH] D98710: [clang-tidy] Add --skip-headers, part 1 (use setTraversalScope)

2021-06-30 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 355699.
chh edited the summary of this revision.
chh added a comment.

Move almost all changes to MatchFinder into ClangTidy.cpp.


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

https://reviews.llvm.org/D98710

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header2.h
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-interfaces-global-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-objc-function-naming.m
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvm-prefer-register-over-unsigned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-return.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-members.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
  clang/include/clang/ASTMatchers/ASTMatchFinder.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp

Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -1306,6 +1306,10 @@
MatchFinder::ParsingDoneTestCallback *ParsingDone)
   : Finder(Finder), ParsingDone(ParsingDone) {}
 
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+return Finder->HandleTopLevelDecl(DG);
+  }
+
 private:
   void HandleTranslationUnit(ASTContext ) override {
 if (ParsingDone != nullptr) {
@@ -1434,6 +1438,10 @@
   Visitor.match(Node);
 }
 
+bool MatchFinder::HandleTopLevelDecl(DeclGroupRef) {
+  return true;
+}
+
 void MatchFinder::matchAST(ASTContext ) {
   internal::MatchASTVisitor Visitor(, Options);
   Visitor.set_active_ast_context();
Index: clang/include/clang/ASTMatchers/ASTMatchFinder.h
===
--- clang/include/clang/ASTMatchers/ASTMatchFinder.h
+++ clang/include/clang/ASTMatchers/ASTMatchFinder.h
@@ -141,7 +141,10 @@
   };
 
   MatchFinder(MatchFinderOptions Options = MatchFinderOptions());
-  ~MatchFinder();
+  virtual ~MatchFinder();
+
+  /// Inside a MatchASTConsumer, handles all top level Decl.
+  virtual bool HandleTopLevelDecl(DeclGroupRef DG);
 
   /// Adds a matcher to execute when running over the AST.
   ///
@@ -196,7 +199,7 @@
   /// @}
 
   /// Finds all matches in the given AST.
-  void matchAST(ASTContext );
+  virtual void matchAST(ASTContext );
 
   /// Registers a callback to notify the end of parsing.
   ///
Index: clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
@@ -0,0 +1,54 @@
+// Test --skip-headers, --show-all-warnings, and --header-filter.
+// TODO: when skip-headers implementation is complete, add back
+//  -implicit-check-not="{{warning|error}}:"
+// and use no_hint instead of hint
+//
+// Default shows no warning in .h files, and give HINT to use --header-filter
+// RUN: clang-tidy %s -checks='*' -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,MAIN,HINT
+// later:-implicit-check-not="{{warning|error}}:"
+//
+// --skip-headers skips included files; finds only warnings in the main file.
+// RUN: clang-tidy %s -checks='*' --skip-headers -- \
+// RUN: 2>&1 | FileCheck %s 

[PATCH] D105236: [PowerPC] Implament Atomic Load and Stores Builtins

2021-06-30 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Herald added subscribers: steven.zhang, shchenz, jfb, kbarton, hiraditya, 
nemanjai.
Conanap requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

  This patch implaments the atomic load and store builtins

for the PowerPC target, in order to have feature parody with
xlC on AIX.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105236

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-atomicLoadStore.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-atomicLoadStore-64-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-atomicLoadStore.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-atomicLoadStore.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-atomicLoadStore.ll
@@ -0,0 +1,49 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-64
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-64
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-32
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-64
+
+declare i32 @llvm.ppc.lwarx(i8*)
+define dso_local signext i32 @test_lwarx(i32* readnone %a) local_unnamed_addr #0 {
+; CHECK-64-LABEL: test_lwarx:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:lwarx 3, 0, 3
+; CHECK-64-NEXT:extsw 3, 3
+; CHECK-64-NEXT:blr
+;
+; CHECK-32-LABEL: test_lwarx:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:lwarx 3, 0, 3
+; CHECK-32-NEXT:blr
+entry:
+  %0 = bitcast i32* %a to i8*
+  %1 = tail call i32 @llvm.ppc.lwarx(i8* %0)
+  ret i32 %1
+}
+
+declare i32 @llvm.ppc.stwcx(i8*, i32)
+define dso_local signext i32 @test_stwcx(i32* %a, i32 signext %b) local_unnamed_addr #0 {
+; CHECK-64-LABEL: test_stwcx:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:stwcx. 4, 0, 3
+; CHECK-64-NEXT:mfocrf 3, 128
+; CHECK-64-NEXT:srwi 3, 3, 28
+; CHECK-64-NEXT:extsw 3, 3
+; CHECK-64-NEXT:blr
+;
+; CHECK-32-LABEL: test_stwcx:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:stwcx. 4, 0, 3
+; CHECK-32-NEXT:mfocrf 3, 128
+; CHECK-32-NEXT:srwi 3, 3, 28
+; CHECK-32-NEXT:blr
+entry:
+  %0 = bitcast i32* %a to i8*
+  %1 = tail call i32 @llvm.ppc.stwcx(i8* %0, i32 %b)
+  ret i32 %1
+}
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-atomicLoadStore-64-only.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-atomicLoadStore-64-only.ll
@@ -0,0 +1,35 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK
+
+declare i64 @llvm.ppc.ldarx(i8*)
+define dso_local i64 @test_ldarx(i64* readnone %a) local_unnamed_addr #0 {
+; CHECK-LABEL: test_ldarx:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:ldarx 3, 0, 3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast i64* %a to i8*
+  %1 = tail call i64 @llvm.ppc.ldarx(i8* %0)
+  ret i64 %1
+}
+
+declare i32 @llvm.ppc.stdcx(i8*, i64)
+define dso_local i64 @test(i64* %a, i64 %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stdcx. 4, 0, 3
+; CHECK-NEXT:mfocrf 3, 128
+; CHECK-NEXT:srwi 3, 3, 28
+; CHECK-NEXT:extsw 3, 3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast i64* %a to i8*
+  %1 = tail call i32 @llvm.ppc.stdcx(i8* %0, i64 %b)
+  %conv = sext i32 %1 to i64
+  ret i64 %conv
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -2836,3 +2836,10 @@
 def : Pat<(v2i64 (PPCvecinsertelt v2i64:$vDi, i64:$rA, (i64 i))),
   (VINSD $vDi, !mul(i, 8), $rA)>;
 }
+
+let Predicates = [HasP8Altivec] in {
+  def : Pat<(int_ppc_lwarx xoaddr:$dst),
+(LWARX xoaddr:$dst)>;
+  def : Pat<(int_ppc_stwcx xoaddr:$dst, gprc:$A),
+

[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin marked 2 inline comments as done.
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:3929
+
+  if (IsConstexpr && !LangOpts.CPlusPlus2b && !CondExpr->isValueDependent()) {
+llvm::APSInt Value(/*BitWidth*/ 1);

rsmith wrote:
> I think we should apply this retroactively, even though it wasn't moved as a 
> DR. All other implementations already behave this way across all language 
> modes, and it's just not reasonable to reject conversions in the condition of 
> an `if constexpr` that are accepted in the condition of an `if` -- this seems 
> like an obvious language defect even if the C++ committee haven't officially 
> voted it to be one yet.
> 
> Separately I've asked on the committee reflectors if we can officially treat 
> this as a DR, given the implementation consensus.
I'll do that - it might take me a few days to get to it though


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 355698.
cor3ntin added a comment.

Replace !isUsable() by isInvalid()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1296,7 +1296,7 @@
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5;>P1401R5
-  No
+  Clang 13
 
 
   Trimming whitespaces before line splicing
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
===
--- clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -std=c++1z -verify %s
-// RUN: %clang_cc1 -std=c++1z -verify %s -DUNDEFINED
+// RUN: %clang_cc1 -std=c++1z -verify=expected,cxx17 %s
+// RUN: %clang_cc1 -std=c++1z -verify=expected,cxx17 %s -DUNDEFINED
+// RUN: %clang_cc1 -std=c++2b -verify=expected,cxx2b %s
+// RUN: %clang_cc1 -std=c++2b -verify=expected,cxx2b %s -DUNDEFINED
 
 #ifdef UNDEFINED
 // "used but not defined" errors don't get produced if we have more interesting
@@ -38,18 +40,43 @@
 }
 #else
 namespace ccce {
+
+  struct S {
+  } s;
   void f() {
 if (5) {}
-if constexpr (5) {} // expected-error {{cannot be narrowed}}
+if constexpr (5) { // cxx17-error {{cannot be narrowed}}
+}
   }
   template void g() {
-if constexpr (N) {} // expected-error {{cannot be narrowed}}
+if constexpr (N) { // cxx17-error {{cannot be narrowed}}
+}
   }
-  template void g<5>(); // expected-note {{instantiation of}}
+  template void g<5>(); //cxx17-note  {{instantiation of}}
   void h() {
-if constexpr (4.3) {} // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (4.3) { //  cxx17-error {{conversion from 'double' to 'bool' is not allowed in a converted constant expression}}
+  // cxx2b-warning@-1 {{implicit conversion from 'double' to 'bool' changes value}}
+}
 constexpr void *p = nullptr;
-if constexpr (p) {} // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (p) { // cxx17-error {{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}}
+}
+  }
+
+  void not_constant(int b, S s) { //  expected-note 2{{declared here}}
+if constexpr (bool(b)) {  // expected-error {{constexpr if condition is not a constant expression}} expected-note {{cannot be used in a constant expression}}
+}
+if constexpr (b) { // expected-error {{constexpr if condition is not a constant expression}} expected-note {{cannot be used in a constant expression}}
+}
+if constexpr (s) {
+  // cxx17-error@-1 {{value of type 'ccce::S' is not implicitly convertible to 'bool'}}
+  // cxx2b-error@-2 {{value of type 'ccce::S' is not contextually convertible to 'bool'}}
+}
+
+constexpr S constexprS;
+if constexpr (constexprS) {
+  //cxx17-error@-1 {{value of type 'const ccce::S' is not implicitly convertible to 'bool'}}
+  //cxx2b-error@-2 {{value of type 'const ccce::S' is not contextually convertible to 'bool'}}
+}
   }
 }
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -3911,7 +3911,7 @@
 
 /// CheckCXXBooleanCondition - Returns true if a conversion to bool is invalid.
 ExprResult Sema::CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr) {
-  // C++ 6.4p4:
+  // C++11 6.4p4:
   // The value of a condition that is an initialized declaration in a statement
   // other than a switch statement is the value of the declared variable
   // implicitly converted to type bool. If that conversion is ill-formed, the
@@ -3919,12 +3919,27 @@
   // The value of a condition that is an expression is the value of the
   // expression, implicitly converted to bool.
   //
+  // C++2b 8.5.2p2
+  // If the if statement is of the form if constexpr, the value of the condition
+  // is contextually converted to bool and the converted expression shall be
+  // a constant expression
+  //
   // FIXME: Return this value to the caller so they don't need to recompute it.
-  llvm::APSInt Value(/*BitWidth*/1);
-  return (IsConstexpr && !CondExpr->isValueDependent())
- ? CheckConvertedConstantExpression(CondExpr, Context.BoolTy, Value,
-CCEK_ConstexprIf)
- : 

[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 355697.
cor3ntin added a comment.

Mark the feature as unreleased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1296,7 +1296,7 @@
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5;>P1401R5
-  No
+  Clang 13
 
 
   Trimming whitespaces before line splicing
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
===
--- clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -std=c++1z -verify %s
-// RUN: %clang_cc1 -std=c++1z -verify %s -DUNDEFINED
+// RUN: %clang_cc1 -std=c++1z -verify=expected,cxx17 %s
+// RUN: %clang_cc1 -std=c++1z -verify=expected,cxx17 %s -DUNDEFINED
+// RUN: %clang_cc1 -std=c++2b -verify=expected,cxx2b %s
+// RUN: %clang_cc1 -std=c++2b -verify=expected,cxx2b %s -DUNDEFINED
 
 #ifdef UNDEFINED
 // "used but not defined" errors don't get produced if we have more interesting
@@ -38,18 +40,43 @@
 }
 #else
 namespace ccce {
+
+  struct S {
+  } s;
   void f() {
 if (5) {}
-if constexpr (5) {} // expected-error {{cannot be narrowed}}
+if constexpr (5) { // cxx17-error {{cannot be narrowed}}
+}
   }
   template void g() {
-if constexpr (N) {} // expected-error {{cannot be narrowed}}
+if constexpr (N) { // cxx17-error {{cannot be narrowed}}
+}
   }
-  template void g<5>(); // expected-note {{instantiation of}}
+  template void g<5>(); //cxx17-note  {{instantiation of}}
   void h() {
-if constexpr (4.3) {} // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (4.3) { //  cxx17-error {{conversion from 'double' to 'bool' is not allowed in a converted constant expression}}
+  // cxx2b-warning@-1 {{implicit conversion from 'double' to 'bool' changes value}}
+}
 constexpr void *p = nullptr;
-if constexpr (p) {} // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (p) { // cxx17-error {{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}}
+}
+  }
+
+  void not_constant(int b, S s) { //  expected-note 2{{declared here}}
+if constexpr (bool(b)) {  // expected-error {{constexpr if condition is not a constant expression}} expected-note {{cannot be used in a constant expression}}
+}
+if constexpr (b) { // expected-error {{constexpr if condition is not a constant expression}} expected-note {{cannot be used in a constant expression}}
+}
+if constexpr (s) {
+  // cxx17-error@-1 {{value of type 'ccce::S' is not implicitly convertible to 'bool'}}
+  // cxx2b-error@-2 {{value of type 'ccce::S' is not contextually convertible to 'bool'}}
+}
+
+constexpr S constexprS;
+if constexpr (constexprS) {
+  //cxx17-error@-1 {{value of type 'const ccce::S' is not implicitly convertible to 'bool'}}
+  //cxx2b-error@-2 {{value of type 'const ccce::S' is not contextually convertible to 'bool'}}
+}
   }
 }
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -3911,7 +3911,7 @@
 
 /// CheckCXXBooleanCondition - Returns true if a conversion to bool is invalid.
 ExprResult Sema::CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr) {
-  // C++ 6.4p4:
+  // C++11 6.4p4:
   // The value of a condition that is an initialized declaration in a statement
   // other than a switch statement is the value of the declared variable
   // implicitly converted to type bool. If that conversion is ill-formed, the
@@ -3919,12 +3919,27 @@
   // The value of a condition that is an expression is the value of the
   // expression, implicitly converted to bool.
   //
+  // C++2b 8.5.2p2
+  // If the if statement is of the form if constexpr, the value of the condition
+  // is contextually converted to bool and the converted expression shall be
+  // a constant expression
+  //
   // FIXME: Return this value to the caller so they don't need to recompute it.
-  llvm::APSInt Value(/*BitWidth*/1);
-  return (IsConstexpr && !CondExpr->isValueDependent())
- ? CheckConvertedConstantExpression(CondExpr, Context.BoolTy, Value,
-CCEK_ConstexprIf)
- : PerformContextuallyConvertToBool(CondExpr);
+

[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/www/cxx_status.html:1299
   https://wg21.link/P1401R5;>P1401R5
-  No
+  Clang 13
 

This should be class `unreleased` (yellow) for now so that people can easily 
tell what's in the most recent Clang release versus what's implemented but not 
released; we convert all the `class="unreleased"` to `class="full"` when we cut 
a release.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D105127#2851443 , @rsmith wrote:

> P1401R5 points out that we get `noexcept(bool)` wrong in the opposite 
> direction, permitting conversions to `bool` that we are supposed to reject. 
> While that rule didn't change as part of P1401R5, it'd be nice to handle it 
> as part of dealing with that paper.

To be clear: doing that as a separate change is completely fine, but we should 
make sure we don't forget about it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Would we benefit from any more test coverage for the `static_assert` side of 
this paper, or is our (formerly wrong and now correct) behavior already 
well-covered by existing tests? (Similarly for `explicit(bool)`, do we already 
have good test coverage for the distinction between "contextually converted 
constant expression of type `bool`" and the various other possible rules?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

P1401R5 points out that we get `noexcept(bool)` wrong in the opposite 
direction, permitting conversions to `bool` that we are supposed to reject. 
While that rule didn't change as part of P1401R5, it'd be nice to handle it as 
part of dealing with that paper.




Comment at: clang/lib/Sema/SemaExprCXX.cpp:3929
+
+  if (IsConstexpr && !LangOpts.CPlusPlus2b && !CondExpr->isValueDependent()) {
+llvm::APSInt Value(/*BitWidth*/ 1);

I think we should apply this retroactively, even though it wasn't moved as a 
DR. All other implementations already behave this way across all language 
modes, and it's just not reasonable to reject conversions in the condition of 
an `if constexpr` that are accepted in the condition of an `if` -- this seems 
like an obvious language defect even if the C++ committee haven't officially 
voted it to be one yet.

Separately I've asked on the committee reflectors if we can officially treat 
this as a DR, given the implementation consensus.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:3935
+  ExprResult E = PerformContextuallyConvertToBool(CondExpr);
+  if (!IsConstexpr || !E.isUsable() || E.get()->isValueDependent())
+return E;

Please use `E.isInvalid()` instead of `!E.isUsable()` unless you anticipate and 
intend to handle the valid-but-null case (which is unusable but not invalid).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


[PATCH] D104680: [clang] Eliminate relational function pointer comparisons in all C++ modes

2021-06-30 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Is there any reason for breaking C++03 code here? I don't see the advantage to 
that at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104680

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


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

LGTM!

Since you submitted this quite recently, I would wait some more time before 
landing, for any other people who might want to review this.
Maybe wait for it to be a week old, ping anyone else you might want to get a 
review from, and wait a couple of days for them to respond.




Comment at: clang/lib/Sema/SemaExprCXX.cpp:3930
+  ExprResult E = PerformContextuallyConvertToBool(CondExpr);
+  if (!IsConstexpr || CondExpr->isValueDependent())
+return E;

mizvekov wrote:
> Minor nit: I think it would be a tiny bit clearer if you factored out this 
> condition, since you repeat it:
> ```
> bool IsConstexprNonValueDependent = IsConstexpr  && 
> !CondExpr->isValueDependent();
> if (!LangOpts.CPlusPlus2b && IsConstexprNonValueDependent) {
> 
> if (!IsConstexprNonValueDependent)
> ```
By the way you fixed this by reverting back to the original form 
pre-refactoring, so my tip above applies again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


[PATCH] D105226: [Clang] allow overriding -fbasic-block-sections

2021-06-30 Thread Artem Belevich 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 rGcab5f89cfd9e: [Clang] allow overriding 
-fbasic-block-sections (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105226

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fbasic-block-sections.c


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -3,11 +3,18 @@
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LIST %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LABELS %s
 // RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s 
-S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all 
-fbasic-block-sections=none %s -S 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOOPT %s
 // RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all 
%s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=alll %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-INVALID-VALUE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-INVALID-VALUE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list= %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-NULL-LIST %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=none %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -x cuda -nocudainc -nocudalib -target x86_64 
-fbasic-block-sections=all %s -c 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-CUDA %s
+
 //
+// CHECK-NOOPT-NOT:  -fbasic-block-sections=
 // CHECK-OPT-NONE:   "-fbasic-block-sections=none"
 // CHECK-OPT-ALL:"-fbasic-block-sections=all"
 // CHECK-OPT-LIST:   "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
@@ -15,3 +22,9 @@
 // CHECK-TRIPLE: error: unsupported option '-fbasic-block-sections=all' 
for target
 // CHECK-INVALID-VALUE: error: invalid value {{[^ ]*}} in 
'-fbasic-block-sections={{.*}}'
 // CHECK-OPT-NULL-LIST: "-fbasic-block-sections=list="
+
+// GPU-side compilations should have no -fbasic-block-sections. It should only
+// be passed to the host compilation
+// CHECK-CUDA-NOT:  -fbasic-block-sections=
+// CHECK-CUDA: "-cc1" "-triple" "x86_64"
+// CHECK-CUDA-SAME: "-fbasic-block-sections=all"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5274,15 +5274,20 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
+StringRef Val = A->getValue();
 if (Triple.isX86() && Triple.isOSBinFormatELF()) {
-  StringRef Val = A->getValue();
   if (Val != "all" && Val != "labels" && Val != "none" &&
   !Val.startswith("list="))
 D.Diag(diag::err_drv_invalid_value)
 << A->getAsString(Args) << A->getValue();
   else
 A->render(Args, CmdArgs);
-} else {
+} else if (Triple.isNVPTX()) {
+  // Do not pass the option to the GPU compilation. We still want it 
enabled
+  // for the host-side compilation, so seeing it here is not an error.
+} else if (Val != "none") {
+  // =none is allowed everywhere. It's useful for overriding the option
+  // and is the same as not specifying the option.
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -3,11 +3,18 @@
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LIST %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
 // RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all -fbasic-block-sections=none %s -S 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOOPT %s
 // RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=alll %s -S 2>&1 | FileCheck -check-prefix=CHECK-INVALID-VALUE %s
 // RUN: %clang -### -target 

[clang] cab5f89 - [Clang] allow overriding -fbasic-block-sections

2021-06-30 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2021-06-30T14:32:08-07:00
New Revision: cab5f89cfd9efa9166e1362972e460323b8254ef

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

LOG: [Clang] allow overriding -fbasic-block-sections

We should not error out on non-x86 targets if `-fbasic-block-sections=none` is 
in effect.

Also, filter it out for GPU-side compilations, as we do with other options not
supported on the GPU.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/fbasic-block-sections.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 98023334d880..9c0922c8497c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5274,15 +5274,20 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
+StringRef Val = A->getValue();
 if (Triple.isX86() && Triple.isOSBinFormatELF()) {
-  StringRef Val = A->getValue();
   if (Val != "all" && Val != "labels" && Val != "none" &&
   !Val.startswith("list="))
 D.Diag(diag::err_drv_invalid_value)
 << A->getAsString(Args) << A->getValue();
   else
 A->render(Args, CmdArgs);
-} else {
+} else if (Triple.isNVPTX()) {
+  // Do not pass the option to the GPU compilation. We still want it 
enabled
+  // for the host-side compilation, so seeing it here is not an error.
+} else if (Val != "none") {
+  // =none is allowed everywhere. It's useful for overriding the option
+  // and is the same as not specifying the option.
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }

diff  --git a/clang/test/Driver/fbasic-block-sections.c 
b/clang/test/Driver/fbasic-block-sections.c
index 6aa030bf27ca..60889fb11530 100644
--- a/clang/test/Driver/fbasic-block-sections.c
+++ b/clang/test/Driver/fbasic-block-sections.c
@@ -3,11 +3,18 @@
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LIST %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LABELS %s
 // RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s 
-S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all 
-fbasic-block-sections=none %s -S 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOOPT %s
 // RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all 
%s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=alll %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-INVALID-VALUE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-INVALID-VALUE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list= %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-NULL-LIST %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=none %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -x cuda -nocudainc -nocudalib -target x86_64 
-fbasic-block-sections=all %s -c 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-CUDA %s
+
 //
+// CHECK-NOOPT-NOT:  -fbasic-block-sections=
 // CHECK-OPT-NONE:   "-fbasic-block-sections=none"
 // CHECK-OPT-ALL:"-fbasic-block-sections=all"
 // CHECK-OPT-LIST:   "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
@@ -15,3 +22,9 @@
 // CHECK-TRIPLE: error: unsupported option '-fbasic-block-sections=all' 
for target
 // CHECK-INVALID-VALUE: error: invalid value {{[^ ]*}} in 
'-fbasic-block-sections={{.*}}'
 // CHECK-OPT-NULL-LIST: "-fbasic-block-sections=list="
+
+// GPU-side compilations should have no -fbasic-block-sections. It should only
+// be passed to the host compilation
+// CHECK-CUDA-NOT:  -fbasic-block-sections=
+// CHECK-CUDA: "-cc1" "-triple" "x86_64"
+// CHECK-CUDA-SAME: "-fbasic-block-sections=all"



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


[clang] ef227b3 - Add dumping support for RequiresExpr.

2021-06-30 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-06-30T14:27:19-07:00
New Revision: ef227b32b63c53ca81ebd410c7fbd5af8fc22ec5

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

LOG: Add dumping support for RequiresExpr.

In passing, fix an ast-print bug that inserted a spurious extra `;`
after a concept definition.

Added: 


Modified: 
clang/include/clang/AST/ASTNodeTraverser.h
clang/include/clang/AST/JSONNodeDumper.h
clang/include/clang/AST/TextNodeDumper.h
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/test/Coverage/ast-printing.cpp
clang/test/Coverage/cxx-language-features.inc

Removed: 




diff  --git a/clang/include/clang/AST/ASTNodeTraverser.h 
b/clang/include/clang/AST/ASTNodeTraverser.h
index c4f0355b352e..18e7f491f222 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -53,6 +53,7 @@ struct {
   void Visit(const OMPClause *C);
   void Visit(const BlockDecl::Capture );
   void Visit(const GenericSelectionExpr::ConstAssociation );
+  void Visit(const concepts::Requirement *R);
   void Visit(const APValue , QualType Ty);
 };
 */
@@ -141,7 +142,8 @@ class ASTNodeTraverser
   ConstStmtVisitor::Visit(S);
 
   // Some statements have custom mechanisms for dumping their children.
-  if (isa(S) || isa(S))
+  if (isa(S) || isa(S) ||
+  isa(S))
 return;
 
   if (Traversal == TK_IgnoreUnlessSpelledInSource &&
@@ -228,6 +230,28 @@ class ASTNodeTraverser
 });
   }
 
+  void Visit(const concepts::Requirement *R) {
+getNodeDelegate().AddChild([=] {
+  getNodeDelegate().Visit(R);
+  if (!R)
+return;
+  if (auto *TR = dyn_cast(R)) {
+if (!TR->isSubstitutionFailure())
+  Visit(TR->getType()->getType().getTypePtr());
+  } else if (auto *ER = dyn_cast(R)) {
+if (!ER->isExprSubstitutionFailure())
+  Visit(ER->getExpr());
+if (!ER->getReturnTypeRequirement().isEmpty())
+  Visit(ER->getReturnTypeRequirement()
+.getTypeConstraint()
+->getImmediatelyDeclaredConstraint());
+  } else if (auto *NR = dyn_cast(R)) {
+if (!NR->isSubstitutionFailure())
+  Visit(NR->getConstraintExpr());
+  }
+});
+  }
+
   void Visit(const APValue , QualType Ty) {
 getNodeDelegate().AddChild([=] { getNodeDelegate().Visit(Value, Ty); });
   }
@@ -689,6 +713,13 @@ class ASTNodeTraverser
 }
   }
 
+  void VisitRequiresExpr(const RequiresExpr *E) {
+for (auto *D : E->getLocalParameters())
+  Visit(D);
+for (auto *R : E->getRequirements())
+  Visit(R);
+  }
+
   void VisitLambdaExpr(const LambdaExpr *Node) {
 if (Traversal == TK_IgnoreUnlessSpelledInSource) {
   for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {

diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 1f3585910a40..a96e21993e20 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -21,6 +21,7 @@
 #include "clang/AST/AttrVisitor.h"
 #include "clang/AST/CommentCommandTraits.h"
 #include "clang/AST/CommentVisitor.h"
+#include "clang/AST/ExprConcepts.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/Type.h"
@@ -204,6 +205,7 @@ class JSONNodeDumper
   void Visit(const OMPClause *C);
   void Visit(const BlockDecl::Capture );
   void Visit(const GenericSelectionExpr::ConstAssociation );
+  void Visit(const concepts::Requirement *R);
   void Visit(const APValue , QualType Ty);
 
   void VisitTypedefType(const TypedefType *TT);
@@ -290,6 +292,7 @@ class JSONNodeDumper
   void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *BTE);
   void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *MTE);
   void VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *ME);
+  void VisitRequiresExpr(const RequiresExpr *RE);
 
   void VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE);
   void VisitObjCMessageExpr(const ObjCMessageExpr *OME);

diff  --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 4dc68d5237b4..0eb0031de11f 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -19,6 +19,7 @@
 #include "clang/AST/CommentCommandTraits.h"
 #include "clang/AST/CommentVisitor.h"
 #include "clang/AST/DeclVisitor.h"
+#include "clang/AST/ExprConcepts.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/TemplateArgumentVisitor.h"
@@ -188,6 +189,8 @@ class TextNodeDumper
 
   void Visit(const GenericSelectionExpr::ConstAssociation );
 
+  void 

[PATCH] D93525: [clang-offload-bundler] Add unbundling of archives containing bundled object files into device specific archives

2021-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/test/Driver/clang-offload-bundler.c:390
+// RUN: clang-offload-bundler -unbundle -type=a 
-targets=openmp-amdgcn-amd-amdhsa--gfx906,openmp-amdgcn-amd-amdhsa--gfx908 
-inputs=%t.input-archive.a 
-outputs=%t-archive-gfx906-simple.a,%t-archive-gfx908-simple.a
+// RUN: llvm-ar t %t-archive-gfx906-simple.a | FileCheck %s 
-check-prefix=GFX906
+// GFX906: simple-openmp-amdgcn-amd-amdhsa--gfx906

This test does not depend on `llvm-ar`, and this change causes `check-clang` to 
fail in the case where `llvm-ar` has not previously been built. Please can you 
fix? (Might need some changes to the build rules to add a dependency on 
`llvm-ar`, if you can't avoid depending on it for this test.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93525

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


[PATCH] D104500: [clang] Apply P1825 as Defect Report from C++11 up to C++20.

2021-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp:435
+};
+A test1(B x) { return x; } // cxx98-error {{conversion}} {{is ambiguous}}
+

The "{{is ambiguous}}" here is not part of the expected-error and will be 
ignored. If you want to ignore the text in between those two strings, you can 
do that with `// cxx98-error-re {{conversion {{.*}} is ambiguous}}` or similar. 
(The `-re` enables regular expression checking, and the nested `{{...}}` 
switches to regular expression matching rather than literal matching.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104500

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


[PATCH] D105226: [Clang] allow overriding -fbasic-block-sections

2021-06-30 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 355681.
tra edited the summary of this revision.
tra added a comment.

comment typo fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105226

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fbasic-block-sections.c


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -3,11 +3,18 @@
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LIST %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LABELS %s
 // RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s 
-S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all 
-fbasic-block-sections=none %s -S 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOOPT %s
 // RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all 
%s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=alll %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-INVALID-VALUE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-INVALID-VALUE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list= %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-NULL-LIST %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=none %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -x cuda -nocudainc -nocudalib -target x86_64 
-fbasic-block-sections=all %s -c 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-CUDA %s
+
 //
+// CHECK-NOOPT-NOT:  -fbasic-block-sections=
 // CHECK-OPT-NONE:   "-fbasic-block-sections=none"
 // CHECK-OPT-ALL:"-fbasic-block-sections=all"
 // CHECK-OPT-LIST:   "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
@@ -15,3 +22,9 @@
 // CHECK-TRIPLE: error: unsupported option '-fbasic-block-sections=all' 
for target
 // CHECK-INVALID-VALUE: error: invalid value {{[^ ]*}} in 
'-fbasic-block-sections={{.*}}'
 // CHECK-OPT-NULL-LIST: "-fbasic-block-sections=list="
+
+// GPU-side compilations should have no -fbasic-block-sections. It should only
+// be passed to the host compilation
+// CHECK-CUDA-NOT:  -fbasic-block-sections=
+// CHECK-CUDA: "-cc1" "-triple" "x86_64"
+// CHECK-CUDA-SAME: "-fbasic-block-sections=all"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5269,15 +5269,20 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
+StringRef Val = A->getValue();
 if (Triple.isX86() && Triple.isOSBinFormatELF()) {
-  StringRef Val = A->getValue();
   if (Val != "all" && Val != "labels" && Val != "none" &&
   !Val.startswith("list="))
 D.Diag(diag::err_drv_invalid_value)
 << A->getAsString(Args) << A->getValue();
   else
 A->render(Args, CmdArgs);
-} else {
+} else if (Triple.isNVPTX()) {
+  // Do not pass the option to the GPU compilation. We still want it 
enabled
+  // for the host-side compilation, so seeing it here is not an error.
+} else if (Val != "none") {
+  // =none is allowed everywhere. It's useful for overriding the option
+  // and is the same as not specifying the option.
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -3,11 +3,18 @@
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LIST %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
 // RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all -fbasic-block-sections=none %s -S 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOOPT %s
 // RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=alll %s -S 2>&1 | FileCheck -check-prefix=CHECK-INVALID-VALUE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list %s -S 2>&1 | FileCheck -check-prefix=CHECK-INVALID-VALUE %s
 // RUN: %clang 

[PATCH] D103929: [clang] P2085R0: Consistent defaulted comparisons

2021-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks!

I think you may be missing an implementation of this rule:

> A definition of a comparison operator as defaulted that appears in a class 
> shall be the first declaration of that function.

In particular, this is now invalid:

  struct A;
  bool operator==(A, A);
  struct A {
friend bool operator==(A, A) = default; // error, not first declaration
  };

As a subtle detail, I'm also not sure whether we handle the following rule 
properly, and I'd like to see some tests:

> A comparison operator function for class C that is defaulted on its first 
> declaration and is not defined as deleted is implicitly defined when it is 
> odr-used or needed for constant evaluation.

In particular, a comparison function that's defaulted on its first declaration 
is defined when it's used, but if it's defaulted on a second or subsequent 
declaration then it's immediately defined:

  template struct Broken {
template bool operator==(Broken, Broken) { return 
T::result; }
  };
  
  struct A { Broken<'A'> b; };
  bool operator==(A, A) = default; // ok, does not try to define the function 
until it's used
  
  struct B { Broken<'B'> b; };
  bool operator==(B, B);
  bool operator==(B, B) = default; // error, immediately defined, resulting in 
instantiation of Broken<'B'>::operator==, resulting in a hard error




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:8368-8373
+  CXXRecordDecl *RD =
+  dyn_cast(FD->getCanonicalDecl()->getLexicalDeclContext());
 
-  CXXRecordDecl *RD = dyn_cast(FD->getLexicalDeclContext());
-  assert(RD && "defaulted comparison is not defaulted in a class");
+  if (!RD) {
+RD = dyn_cast(FD->getLexicalDeclContext());
+  }

I don't think you can do the "member or friend" check this way. P2085R0 doesn't 
require either the defaulted declaration or the first declaration to be within 
the class, and it doesn't matter which class contains the first declaration, if 
any. For example, this is valid:

```
struct A;
class B {
  friend bool operator==(A, A); // first declaration not in class A
  bool operator==(B);
};
class A {
  friend bool operator==(A, A);
  B b;
};
// ok, can access both A::b and B::operator==.
bool operator==(A, A) = default; // defaulted declaration not in class A
```

I think there are two reasonable options here:
1) First work out the class type for which we're defaulting a comparison and 
then traverse the list of redeclarations of the function looking for one that's 
lexically within the class, or
2) First work out the class type for which we're defaulting a comparison and 
then check that the function is either a member of that class or is in the list 
of that class's friends.
Either approach seems fine to me.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:8614-8615
+
+CXXRecordDecl *RD =
+cast(FD->getCanonicalDecl()->getLexicalDeclContext());
 SourceLocation BodyLoc =

This is not necessarily the right class. The first declaration might not 
lexically be in a class at all, in a case like:
```
struct A;
bool operator==(A, A);
struct A {
  friend bool operator==(A, A);
};
bool operator==(A, A) = default;
```



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:765
+   diag::note_comparison_synthesized_at)
+  << (int)DFK.asComparison() << FD;
+}

Passing in a function declaration here doesn't seem appropriate; this will 
diagnose "in defaulted equality comparison operator for 'operator==' first 
required here", when we wanted to say "in defaulted equality comparison 
operator for 'T' first required here". You'll presumably need some mechanism to 
determine the type being compared (something like 
`FD->getParamDecl(0)->getType().getNonReferenceType().getUnqualifiedType()`, 
though maybe you can share some code with `CheckExplicitlyDefaultedComparison`).



Comment at: clang/test/CXX/class/class.compare/class.compare.default/p6.cpp:1
+// RUN: %clang_cc1 -std=c++2a -verify %s
+

The file names here indicate the paragraph within the standard that's being 
tested; p6 would be tests for paragraph 6 of [class.compare.default]. This test 
doesn't appear to have anything to do with [class.compare.default] paragraph 6; 
it appears to be testing paragraph 1. Please can you move these tests to p1.cpp 
as appropriate?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103929

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


[PATCH] D105226: [Clang] allow overriding -fbasic-block-sections

2021-06-30 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram accepted this revision.
tmsriram 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/D105226/new/

https://reviews.llvm.org/D105226

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


[clang-tools-extra] a62579f - [clangd][nfc] Show more information in logs when compiler instance prepare fails

2021-06-30 Thread Aleksandr Platonov via cfe-commits

Author: Aleksandr Platonov
Date: 2021-06-30T21:58:33+01:00
New Revision: a62579fc008e22b6c9e1544788644f5fceef15ce

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

LOG: [clangd][nfc] Show more information in logs when compiler instance prepare 
fails

Without this patch clangd silently process compiler instance prepare failure 
and only LSP errors "Invalid AST" could be found in logs.
E.g. the reason of the problem https://github.com/clangd/clangd/issues/734 is 
impossible to understand without verbose logs or with disabled background index.
This patch adds more information into logs to help understand the reason of 
such failures.

Logs without this patch:
```
E[...] Could not build a preamble for file test.cpp version 1
```

Logs with this patch:
```
E[...] Could not build a preamble for file test.cpp version 1: 
CreateTargetInfo() return null
..
E[...] Failed to prepare a compiler instance: unknown target ABI 'lp64'
```

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/Preamble.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index 0d7e4631d660..cb8ad5a8fa9f 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -289,8 +289,15 @@ ParsedAST::build(llvm::StringRef Filename, const 
ParseInputs ,
   std::move(CI), PreamblePCH,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
   ASTDiags);
-  if (!Clang)
+  if (!Clang) {
+// The last diagnostic contains information about the reason of this
+// failure.
+std::vector Diags(ASTDiags.take());
+elog("Failed to prepare a compiler instance: {0}",
+ !Diags.empty() ? static_cast(Diags.back()).Message
+: "unknown error");
 return None;
+  }
 
   auto Action = std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs[0];

diff  --git a/clang-tools-extra/clangd/Preamble.cpp 
b/clang-tools-extra/clangd/Preamble.cpp
index e003af6e0dfa..9173dcda513a 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -390,8 +390,8 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
 SerializedDeclsCollector.takeMacros(), std::move(StatCache),
 SerializedDeclsCollector.takeCanonicalIncludes());
   } else {
-elog("Could not build a preamble for file {0} version {1}", FileName,
- Inputs.Version);
+elog("Could not build a preamble for file {0} version {1}: {2}", FileName,
+ Inputs.Version, BuiltPreamble.getError().message());
 return nullptr;
   }
 }



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


[PATCH] D104056: [clangd][nfc] Show more information in logs when compiler instance prepare fails

2021-06-30 Thread Aleksandr Platonov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa62579fc008e: [clangd][nfc] Show more information in logs 
when compiler instance prepare fails (authored by ArcsinX).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104056

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -390,8 +390,8 @@
 SerializedDeclsCollector.takeMacros(), std::move(StatCache),
 SerializedDeclsCollector.takeCanonicalIncludes());
   } else {
-elog("Could not build a preamble for file {0} version {1}", FileName,
- Inputs.Version);
+elog("Could not build a preamble for file {0} version {1}: {2}", FileName,
+ Inputs.Version, BuiltPreamble.getError().message());
 return nullptr;
   }
 }
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -289,8 +289,15 @@
   std::move(CI), PreamblePCH,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
   ASTDiags);
-  if (!Clang)
+  if (!Clang) {
+// The last diagnostic contains information about the reason of this
+// failure.
+std::vector Diags(ASTDiags.take());
+elog("Failed to prepare a compiler instance: {0}",
+ !Diags.empty() ? static_cast(Diags.back()).Message
+: "unknown error");
 return None;
+  }
 
   auto Action = std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs[0];


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -390,8 +390,8 @@
 SerializedDeclsCollector.takeMacros(), std::move(StatCache),
 SerializedDeclsCollector.takeCanonicalIncludes());
   } else {
-elog("Could not build a preamble for file {0} version {1}", FileName,
- Inputs.Version);
+elog("Could not build a preamble for file {0} version {1}: {2}", FileName,
+ Inputs.Version, BuiltPreamble.getError().message());
 return nullptr;
   }
 }
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -289,8 +289,15 @@
   std::move(CI), PreamblePCH,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
   ASTDiags);
-  if (!Clang)
+  if (!Clang) {
+// The last diagnostic contains information about the reason of this
+// failure.
+std::vector Diags(ASTDiags.take());
+elog("Failed to prepare a compiler instance: {0}",
+ !Diags.empty() ? static_cast(Diags.back()).Message
+: "unknown error");
 return None;
+  }
 
   auto Action = std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs[0];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105226: [Clang] allow overriding -fbasic-block-sections

2021-06-30 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added reviewers: tmsriram, jlebar.
Herald added subscribers: pengfei, bixia.
tra requested review of this revision.
Herald added a project: clang.

We should not error out on non-x86 targets if `-fbasic-block-sections=none` is 
in effect.

Also, filter it out for GPU-side compilations, as we do with other options not
supported on the GPU.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105226

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fbasic-block-sections.c


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -3,11 +3,18 @@
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LIST %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LABELS %s
 // RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s 
-S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all 
-fbasic-block-sections=none %s -S 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOOPT %s
 // RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all 
%s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=alll %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-INVALID-VALUE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-INVALID-VALUE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list= %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-NULL-LIST %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=none %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -x cuda -nocudainc -nocudalib -target x86_64 
-fbasic-block-sections=all %s -c 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-CUDA %s
+
 //
+// CHECK-NOOPT-NOT:  -fbasic-block-sections=
 // CHECK-OPT-NONE:   "-fbasic-block-sections=none"
 // CHECK-OPT-ALL:"-fbasic-block-sections=all"
 // CHECK-OPT-LIST:   "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
@@ -15,3 +22,9 @@
 // CHECK-TRIPLE: error: unsupported option '-fbasic-block-sections=all' 
for target
 // CHECK-INVALID-VALUE: error: invalid value {{[^ ]*}} in 
'-fbasic-block-sections={{.*}}'
 // CHECK-OPT-NULL-LIST: "-fbasic-block-sections=list="
+
+// GPU-side compilations should have no -fbasic-block-sections. It should only
+// be passed to the host compilation
+// CHECK-CUDA-NOT:  -fbasic-block-sections=
+// CHECK-CUDA: "-cc1" "-triple" "x86_64"
+// CHECK-CUDA-SAME: "-fbasic-block-sections=all"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5269,15 +5269,20 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
+StringRef Val = A->getValue();
 if (Triple.isX86() && Triple.isOSBinFormatELF()) {
-  StringRef Val = A->getValue();
   if (Val != "all" && Val != "labels" && Val != "none" &&
   !Val.startswith("list="))
 D.Diag(diag::err_drv_invalid_value)
 << A->getAsString(Args) << A->getValue();
   else
 A->render(Args, CmdArgs);
-} else {
+} else if (Triple.isNVPTX()) {
+  // Do not pass the option to the GPU compilation. We still want it 
enabled
+  // for the host-side compilation, so seeing it here is not an error.
+} else if (Val != "none") {
+  // =none is allowed everywhere  it's useful for overriding the option
+  // and is the same as not specifying the option.
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -3,11 +3,18 @@
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LIST %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
 // RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all -fbasic-block-sections=none %s -S 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOOPT %s
 // RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 // RUN: %clang -### -target x86_64 -fbasic-block-sections=alll %s -S 2>&1 | 

[PATCH] D103986: [PowerPC] Floating Point Builtins for XL Compat.

2021-06-30 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added inline comments.



Comment at: llvm/test/CodeGen/builtins-ppc-xlcompat-fp.ll:18
+
+define dso_local double @test_fsel(double %a, double %b, double %c) 
local_unnamed_addr #0 {
+; CHECK-PWR7-LABEL: test_fsel 

you can remove  `#0`, `#1` and `#2`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103986

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


[PATCH] D103986: [PowerPC] Floating Point Builtins for XL Compat.

2021-06-30 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added a comment.

Overall looks good. Some nits as below.




Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-fp.c:9
+// RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+
+double test_fric(double a) {

- You can define three extern variables for all the bulitins.
```
extern double a;
extern float bï¼›
extern float cï¼›
```
- You can auto update the test case with utils/update_cc_test_checks.py



Comment at: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:4990
   case ISD::INTRINSIC_WO_CHAIN: {
+
+if (N->getConstantOperandVal(0) == Intrinsic::ppc_fsels) {

you can delete blank line and better add comments for the operation below.



Comment at: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:4992
+if (N->getConstantOperandVal(0) == Intrinsic::ppc_fsels) {
+  SDValue ops[] = {N->getOperand(1), N->getOperand(2), N->getOperand(3)};
+  CurDAG->SelectNodeTo(N, PPC::FSELS, MVT::f32, ops);

Please use `Ops` as the variable name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103986

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


[PATCH] D105148: [CMake] Don't use -Bsymbolic-functions for MinGW targets

2021-06-30 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbf6770f9bd60: [CMake] Dont use -Bsymbolic-functions 
for MinGW targets (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105148

Files:
  clang/tools/clang-shlib/CMakeLists.txt
  llvm/tools/llvm-shlib/CMakeLists.txt


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -50,11 +50,13 @@
   # Solaris ld does not accept global: *; so there is no way to version 
*all* global symbols
   set(LIB_NAMES 
-Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
 ${LIB_NAMES})
 endif()
-# Optimize function calls for default visibility definitions to avoid PLT 
and
-# reduce dynamic relocations.
-# Note: for -fno-pic default, the address of a function may be different 
from
-# inside and outside libLLVM.so.
-target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
+if (NOT MINGW)
+  # Optimize function calls for default visibility definitions to avoid 
PLT and
+  # reduce dynamic relocations.
+  # Note: for -fno-pic default, the address of a function may be different 
from
+  # inside and outside libLLVM.so.
+  target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
+endif()
   elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
   endif()
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -50,6 +50,6 @@
   ${_DEPS})
 # Optimize function calls for default visibility definitions to avoid PLT and
 # reduce dynamic relocations.
-if (NOT APPLE)
+if (NOT APPLE AND NOT MINGW)
   target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
 endif()


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -50,11 +50,13 @@
   # Solaris ld does not accept global: *; so there is no way to version *all* global symbols
   set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
 endif()
-# Optimize function calls for default visibility definitions to avoid PLT and
-# reduce dynamic relocations.
-# Note: for -fno-pic default, the address of a function may be different from
-# inside and outside libLLVM.so.
-target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
+if (NOT MINGW)
+  # Optimize function calls for default visibility definitions to avoid PLT and
+  # reduce dynamic relocations.
+  # Note: for -fno-pic default, the address of a function may be different from
+  # inside and outside libLLVM.so.
+  target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
+endif()
   elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
   endif()
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -50,6 +50,6 @@
   ${_DEPS})
 # Optimize function calls for default visibility definitions to avoid PLT and
 # reduce dynamic relocations.
-if (NOT APPLE)
+if (NOT APPLE AND NOT MINGW)
   target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bf6770f - [CMake] Don't use -Bsymbolic-functions for MinGW targets

2021-06-30 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-06-30T22:54:26+03:00
New Revision: bf6770f9bd606643c8ea8a7ab03da5da5960e98e

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

LOG: [CMake] Don't use -Bsymbolic-functions for MinGW targets

This is an ELF specific option which isn't supported for Windows/MinGW
targets, even if the MinGW linker otherwise uses an ld.bfd like linker
interface.

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

Added: 


Modified: 
clang/tools/clang-shlib/CMakeLists.txt
llvm/tools/llvm-shlib/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/clang-shlib/CMakeLists.txt 
b/clang/tools/clang-shlib/CMakeLists.txt
index d08cf89383282..9c1f8ea452b36 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -50,6 +50,6 @@ add_clang_library(clang-cpp
   ${_DEPS})
 # Optimize function calls for default visibility definitions to avoid PLT and
 # reduce dynamic relocations.
-if (NOT APPLE)
+if (NOT APPLE AND NOT MINGW)
   target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
 endif()

diff  --git a/llvm/tools/llvm-shlib/CMakeLists.txt 
b/llvm/tools/llvm-shlib/CMakeLists.txt
index 03e1383ec8b4f..76b9a25cbbcdc 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -50,11 +50,13 @@ if(LLVM_BUILD_LLVM_DYLIB)
   # Solaris ld does not accept global: *; so there is no way to version 
*all* global symbols
   set(LIB_NAMES 
-Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
 ${LIB_NAMES})
 endif()
-# Optimize function calls for default visibility definitions to avoid PLT 
and
-# reduce dynamic relocations.
-# Note: for -fno-pic default, the address of a function may be 
diff erent from
-# inside and outside libLLVM.so.
-target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
+if (NOT MINGW)
+  # Optimize function calls for default visibility definitions to avoid 
PLT and
+  # reduce dynamic relocations.
+  # Note: for -fno-pic default, the address of a function may be 
diff erent from
+  # inside and outside libLLVM.so.
+  target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
+endif()
   elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
   endif()



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


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 355666.
cor3ntin added a comment.

Fix Formatting in tests.

Do not return early for value dependent expressions
as PerformContextuallyConvertToBool performs checks that
are expected to occur down the line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1296,7 +1296,7 @@
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5;>P1401R5
-  No
+  Clang 13
 
 
   Trimming whitespaces before line splicing
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
===
--- clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -std=c++1z -verify %s
-// RUN: %clang_cc1 -std=c++1z -verify %s -DUNDEFINED
+// RUN: %clang_cc1 -std=c++1z -verify=expected,cxx17 %s
+// RUN: %clang_cc1 -std=c++1z -verify=expected,cxx17 %s -DUNDEFINED
+// RUN: %clang_cc1 -std=c++2b -verify=expected,cxx2b %s
+// RUN: %clang_cc1 -std=c++2b -verify=expected,cxx2b %s -DUNDEFINED
 
 #ifdef UNDEFINED
 // "used but not defined" errors don't get produced if we have more interesting
@@ -38,18 +40,43 @@
 }
 #else
 namespace ccce {
+
+  struct S {
+  } s;
   void f() {
 if (5) {}
-if constexpr (5) {} // expected-error {{cannot be narrowed}}
+if constexpr (5) { // cxx17-error {{cannot be narrowed}}
+}
   }
   template void g() {
-if constexpr (N) {} // expected-error {{cannot be narrowed}}
+if constexpr (N) { // cxx17-error {{cannot be narrowed}}
+}
   }
-  template void g<5>(); // expected-note {{instantiation of}}
+  template void g<5>(); //cxx17-note  {{instantiation of}}
   void h() {
-if constexpr (4.3) {} // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (4.3) { //  cxx17-error {{conversion from 'double' to 'bool' is not allowed in a converted constant expression}}
+  // cxx2b-warning@-1 {{implicit conversion from 'double' to 'bool' changes value}}
+}
 constexpr void *p = nullptr;
-if constexpr (p) {} // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (p) { // cxx17-error {{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}}
+}
+  }
+
+  void not_constant(int b, S s) { //  expected-note 2{{declared here}}
+if constexpr (bool(b)) {  // expected-error {{constexpr if condition is not a constant expression}} expected-note {{cannot be used in a constant expression}}
+}
+if constexpr (b) { // expected-error {{constexpr if condition is not a constant expression}} expected-note {{cannot be used in a constant expression}}
+}
+if constexpr (s) {
+  // cxx17-error@-1 {{value of type 'ccce::S' is not implicitly convertible to 'bool'}}
+  // cxx2b-error@-2 {{value of type 'ccce::S' is not contextually convertible to 'bool'}}
+}
+
+constexpr S constexprS;
+if constexpr (constexprS) {
+  //cxx17-error@-1 {{value of type 'const ccce::S' is not implicitly convertible to 'bool'}}
+  //cxx2b-error@-2 {{value of type 'const ccce::S' is not contextually convertible to 'bool'}}
+}
   }
 }
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -3911,7 +3911,7 @@
 
 /// CheckCXXBooleanCondition - Returns true if a conversion to bool is invalid.
 ExprResult Sema::CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr) {
-  // C++ 6.4p4:
+  // C++11 6.4p4:
   // The value of a condition that is an initialized declaration in a statement
   // other than a switch statement is the value of the declared variable
   // implicitly converted to type bool. If that conversion is ill-formed, the
@@ -3919,12 +3919,27 @@
   // The value of a condition that is an expression is the value of the
   // expression, implicitly converted to bool.
   //
+  // C++2b 8.5.2p2
+  // If the if statement is of the form if constexpr, the value of the condition
+  // is contextually converted to bool and the converted expression shall be
+  // a constant expression
+  //
   // FIXME: Return this value to the caller so they don't need to recompute it.
-  llvm::APSInt Value(/*BitWidth*/1);
-  return (IsConstexpr && !CondExpr->isValueDependent())
- ? CheckConvertedConstantExpression(CondExpr, 

[PATCH] D103929: [clang] P2085R0: Consistent defaulted comparisons

2021-06-30 Thread Alexandru Octavian Buțiu via Phabricator via cfe-commits
predator5047 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103929

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


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D105127#2850975 , @mizvekov wrote:

> So I read the paper, downloaded this patch, played around with it a little 
> bit, tried some different tests, like expressions with dependent types,
> classes with regular/explicit user-defined conversions, function names and 
> some other examples that are mentioned in the paper.
> It works fine on these.
>
> However, I confirm that the failures in `CXX/except/except.spec/p1.cpp` 
> detected by the buildbots are real.
> It fails for me with this DR, works on parent revision.

Yep, I need to look at that. I've ran the entire test suite locally without 
issue initially but maybe I broke something!

In D105127#2851049 , @mizvekov wrote:

> Its unfortunate the buildbot does not have debug symbols.
>
> If you have not managed to reproduce it locally, here is the backtrace I got:

Thanks.
I think my local build had `NDEBUG` defined, so an assert was not firing
My current guess is that early exiting on value-dependent expressions bypasses 
check expected down the line, so I'll confirm that, fix it and update the PR!
Thanks for your help!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


[PATCH] D105091: [RISCV] Pass -u to linker correctly.

2021-06-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

> -u is a linker option used to pretend a symbol is undefined, this option are 
> common used for force pull-in weak symbol.

for forcing archive member extraction.

weak symbols are somewhat orthogonal.




Comment at: clang/test/Driver/riscv-args.c:5
 // RUN: %clang -### -target riscv32 \
 // RUN:   --gcc-toolchain= -Xlinker --defsym=FOO=10 -T a.lds %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LD %s

Just place all linker options on one run line.

It decreases the number of RUN lines and additionally checks the order (though 
usually unimportant).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105091

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


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

Its unfortunate the buildbot does not have debug symbols.

If you have not managed to reproduce it locally, here is the backtrace I got:

  FAIL: Clang :: CXX/except/except.spec/p1.cpp (1 of 1)
   TEST 'Clang :: CXX/except/except.spec/p1.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   c:\users\mizve\source\llvm\build\dbg\bin\clang.exe -cc1 
-internal-isystem c:\users\mizve\source\llvm\build\dbg\lib\clang\13.0.0\include 
-nostdsysteminc -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify 
C:\Users\mizve\source\llvm\clang\test\CXX\except\except.spec\p1.cpp
  --
  Exit Code: 2147483651
  
  Command Output (stdout):
  --
  $ ":" "RUN: at line 1"
  $ "c:\users\mizve\source\llvm\build\dbg\bin\clang.exe" "-cc1" 
"-internal-isystem" 
"c:\users\mizve\source\llvm\build\dbg\lib\clang\13.0.0\include" 
"-nostdsysteminc" "-std=c++11" "-fexceptions" "-fcxx-exceptions" 
"-fsyntax-only" "-verify" 
"C:\Users\mizve\source\llvm\clang\test\CXX\except\except.spec\p1.cpp"
  # command stderr:
  Assertion failed: (NoexceptExpr->isTypeDependent() || 
NoexceptExpr->getType()->getCanonicalTypeUnqualified() == Context.BoolTy) && 
"Parser should have made sure that the expression is boolean", file 
C:\Users\mizve\source\llvm\clang\lib\Sema\SemaDeclCXX.cpp, line 17947
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.  Program arguments: 
c:\\users\\mizve\\source\\llvm\\build\\dbg\\bin\\clang.exe -cc1 
-internal-isystem 
c:\\users\\mizve\\source\\llvm\\build\\dbg\\lib\\clang\\13.0.0\\include 
-nostdsysteminc -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify 
C:\\Users\\mizve\\source\\llvm\\clang\\test\\CXX\\except\\except.spec\\p1.cpp
  1.   parser at end of file
  2.  
C:\Users\mizve\source\llvm\clang\test\CXX\except\except.spec\p1.cpp:75:1: 
parsing namespace 'PR11084'
  3.  
C:\Users\mizve\source\llvm\clang\test\CXX\except\except.spec\p1.cpp:76:19: 
parsing struct/union/class body 'PR11084::A'
   #0 0x7ff72b447a6c HandleAbort 
C:\Users\mizve\source\llvm\llvm\lib\Support\Windows\Signals.inc:408:0
   #1 0x7838bc31 (C:\Windows\SYSTEM32\ucrtbased.dll+0x6bc31)
   #2 0x7838d889 (C:\Windows\SYSTEM32\ucrtbased.dll+0x6d889)
   #3 0x783930bf (C:\Windows\SYSTEM32\ucrtbased.dll+0x730bf)
   #4 0x78391091 (C:\Windows\SYSTEM32\ucrtbased.dll+0x71091)
   #5 0x78393a1f (C:\Windows\SYSTEM32\ucrtbased.dll+0x73a1f)
   #6 0x7ff72fe2bf2a clang::Sema::checkExceptionSpecification(bool, enum 
clang::ExceptionSpecificationType, class llvm::ArrayRef>, class llvm::ArrayRef, class clang::Expr *, class llvm::SmallVectorImpl &, struct clang::FunctionProtoType::ExceptionSpecInfo &) 
C:\Users\mizve\source\llvm\clang\lib\Sem #7 0x7ff72fe2c0ee 
clang::Sema::actOnDelayedExceptionSpecification(class clang::Decl *, enum 
clang::ExceptionSpecificationType, class clang::SourceRange, class 
llvm::ArrayRef>, class 
llvm::ArrayRef, class clang::Expr *) 
C:\Users\mizve\source\llvm\clang\lib\Sema\SemaDeclCXX.cpp:17983:0
   #8 0x7ff72fb16bd9 clang::Parser::ParseLexedMethodDeclaration(struct 
clang::Parser::LateParsedMethodDeclaration &) 
C:\Users\mizve\source\llvm\clang\lib\Parse\ParseCXXInlineMethods.cpp:489:0
  ng\lib\Parse\ParseCXXInlineMethods.cpp:257:0
  #10 0x7ff72fb15eb6 clang::Parser::ParseLexedMethodDeclarations(struct 
clang::Parser::ParsingClass &) 
C:\Users\mizve\source\llvm\clang\lib\Parse\ParseCXXInlineMethods.cpp:325:0
  #11 0x7ff72fb96995 clang::Parser::ParseCXXMemberSpecification(class 
clang::SourceLocation, class clang::SourceLocation, struct 
clang::ParsedAttributesWithRange &, unsigned int, class clang::Decl *) 
C:\Users\mizve\source\llvm\clang\lib\Parse\ParseDeclCXX.cpp:35#12 
0x7ff72fb95153 clang::Parser::ParseClassSpecifier(enum 
clang::tok::TokenKind, class clang::SourceLocation, class clang::DeclSpec &, 
struct clang::Parser::ParsedTemplateInfo const &, enum clang::AccessSpecifier, 
bool, enum clang::Parser::DeclSpecContext, struct 
clang::ParsedAttributesWithRange &) 
C:\Users\mizve\source\llvm\clang\lib\Parse\ParseDeclCXX.cpp:2030:0
  #13 0x7ff72fad24d2 clang::Parser::ParseDeclarationSpecifiers(class 
clang::DeclSpec &, struct clang::Parser::ParsedTemplateInfo const &, enum 
clang::AccessSpecifier, enum clang::Parser::DeclSpecContext, class 
clang::Parser::LateParsedAttrList *) 
C:\Users\mizve\source\llvm\clang\lib\Parse\ParseDecl.cpp:3989:0
  #14 0x7ff72fb07c7f 
clang::Parser::ParseSingleDeclarationAfterTemplate(enum 
clang::DeclaratorContext, struct clang::Parser::ParsedTemplateInfo const &, 
class clang::ParsingDeclRAIIObject &, class clang::SourceLocation &, class 
clang::ParsedAttributes &, enum clang::AccessSpecifier) 
C:\Users\mizve\source\llvm\clang\lib\Parse\ParseTemplate.cpp:225:0
  #15 0x7ff72fb078fa 

[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D105127#2850975 , @mizvekov wrote:

> So I read the paper, downloaded this patch, played around with it a little 
> bit, tried some different tests, like expressions with dependent types,
> classes with regular/explicit user-defined conversions, function names and 
> some other examples that are mentioned in the paper.
> It works fine on these.
>
> However, I confirm that the failures in `CXX/except/except.spec/p1.cpp` 
> detected by the buildbots are real.
> It fails for me with this DR, works on parent revision.

Yep, I need to look at that. I've ran the entire test suite locally without 
issue initially but maybe I broke something!




Comment at: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp:43
 namespace ccce {
+struct S {
+} s;

mizvekov wrote:
> cor3ntin wrote:
> > mizvekov wrote:
> > > This is not consistently indented.
> > Unfortunately, it was put there by clang-format, should I move it manually?
> In general you should respect the formatting tips you get from the non-test 
> code, as these will fail the pre-merge checks.
> But in the test code, our buildbot produces the clang-format patch but this 
> is not really enforced when merging.
> 
> I think what you are doing here, keeping the existing style, is reasonable so 
> you should disregard this particular tip from the format patch.
> The other option would be to format everything in a pre-work NFC commit. This 
> should be fine for pure semantic tests like these, but you have to be careful 
> with parser tests.
This is unfortunate, but I'll fix it, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


[PATCH] D105112: [clang] Add -fdump-record-layouts-canonical option

2021-06-30 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

I'm not familiar with `getCanonicalType()`, can you confirm whether it sees 
through nested typedef's?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105112

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


[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-30 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:2001
 
-if ((Shape.ABI == coro::ABI::Async || Shape.ABI == coro::ABI::Retcon ||
- Shape.ABI == coro::ABI::RetconOnce) &&
-!Shape.CoroSuspends.empty()) {
-  // Run the CGSCC pipeline on the newly split functions.
-  // All clones will be in the same RefSCC, so choose a random clone.
-  UR.RCWorklist.insert(CG.lookupRefSCC(CG.get(*Clones[0])));
+if (!Shape.CoroSuspends.empty()) {
+  // Run the CGSCC pipeline on the original and newly split functions.

lxfind wrote:
> ychen wrote:
> > aeubanks wrote:
> > > ChuanqiXu wrote:
> > > > I am not familiar with the Shape.ABI other than coro::ABI:switch. But 
> > > > the diff line seems strange, it looks like that condition gets weaker.
> > > I believe that's intentional, and a big part of this patch. We want to 
> > > re-add the current SCC (and the split SCCs) any time we split an SCC. 
> > > Before we weren't properly doing that.
> > I got your point. So "// All clones will be in the same RefSCC " : this 
> > is not accurate I think?
> Note that previously this is done only for Async, Retcon and RetconOnce ABIs, 
> not for the Switch ABI.
> I guess that's accurate for those ABIs? But for Switch ABI this is not true.
> And before we were not adding back the split functions to the pipeline to be 
> properly optimized. Now we are dong that. This should help improve the 
> performance of the post-split functions.
I missed the ABI condition. Thanks for the explanation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

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


[PATCH] D105127: Implement P1401R5

2021-06-30 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov requested changes to this revision.
mizvekov added a comment.
This revision now requires changes to proceed.

So I read the paper, downloaded this patch, played around with it a little bit, 
tried some different tests, like expressions with dependent types,
classes with regular/explicit user-defined conversions, function names and some 
other examples that are mentioned in the paper.
It works fine on these.

However, I confirm that the failures in `CXX/except/except.spec/p1.cpp` 
detected by the buildbots are real.
It fails for me with this DR, works on parent revision.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:1491
+def err_constexpr_if_condition_expression_is_not_constant : Error<
+  "constexpr if condition is not a constant expression convertible to bool">;
 def err_static_assert_failed : Error<"static_assert failed%select{ %1|}0">;

cor3ntin wrote:
> mizvekov wrote:
> > Looks a bit easier to parse the english there.
> I would rather not change that, to remain consistent with existing 
> diagnostics involving `constexpr if`
> But I agree it might be good to change them all
I see, yeah agreed.



Comment at: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp:43
 namespace ccce {
+struct S {
+} s;

cor3ntin wrote:
> mizvekov wrote:
> > This is not consistently indented.
> Unfortunately, it was put there by clang-format, should I move it manually?
In general you should respect the formatting tips you get from the non-test 
code, as these will fail the pre-merge checks.
But in the test code, our buildbot produces the clang-format patch but this is 
not really enforced when merging.

I think what you are doing here, keeping the existing style, is reasonable so 
you should disregard this particular tip from the format patch.
The other option would be to format everything in a pre-work NFC commit. This 
should be fine for pure semantic tests like these, but you have to be careful 
with parser tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


[PATCH] D105221: [openmp][nfc] Simplify macros guarding math complex headers

2021-06-30 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a reviewer: ronlieb.
JonChesterfield added a comment.

this unblocks the hazard I am concerned about for D104904 
, namely it stops us defining `__CUDA__` when 
compiling amdgcn code that includes complex.h




Comment at: clang/lib/Headers/__clang_cuda_complex_builtins.h:21
 #pragma omp declare target
 #define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
 #else

bit weird that these are weak, but not changing that here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105221

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


[PATCH] D105221: [openmp][nfc] Simplify macros guarding math complex headers

2021-06-30 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, tianshilei1992, pdhaliwal.
Herald added subscribers: guansong, kristof.beyls, tpr, yaxunl.
JonChesterfield requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

[openmp][nfc] Simplify macros guarding math complex headers

The __CUDA__ macro is already defined for openmp/nvptx and is not used by
__clang_cuda_complex_builtins.h, so dropping that macro slightly simplifies
nvptx and avoids defining it on amdgcn (where it is likely to be harmful).

The cuda_complex_builtins file has already been updated to work with amdgcn.
Using _OPENMP instead of __OPENMP_NVPTX__ there means one fewer macro to define
and it will work on amdgpu openmp when the rest of math is enabled.

Finally dropped a cplusplus test from a C++ header as compilation will have
failed on cmath earlier if it was included from C.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105221

Files:
  clang/lib/Headers/__clang_cuda_complex_builtins.h
  clang/lib/Headers/openmp_wrappers/complex
  clang/lib/Headers/openmp_wrappers/complex.h


Index: clang/lib/Headers/openmp_wrappers/complex.h
===
--- clang/lib/Headers/openmp_wrappers/complex.h
+++ clang/lib/Headers/openmp_wrappers/complex.h
@@ -17,10 +17,8 @@
 // We require math functions in the complex builtins below.
 #include 
 
-#define __CUDA__
-#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
-#undef __OPENMP_NVPTX__
+
 #endif
 
 // Grab the host header too.
Index: clang/lib/Headers/openmp_wrappers/complex
===
--- clang/lib/Headers/openmp_wrappers/complex
+++ clang/lib/Headers/openmp_wrappers/complex
@@ -17,18 +17,12 @@
 // We require std::math functions in the complex builtins below.
 #include 
 
-#define __CUDA__
-#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
-#undef __OPENMP_NVPTX__
 #endif
 
 // Grab the host header too.
 #include_next 
 
-
-#ifdef __cplusplus
-
 // If we are compiling against libc++, the macro _LIBCPP_STD_VER should be set
 // after including  above. Since the complex header we use is a
 // simplified version of the libc++, we don't need it in this case. If we
@@ -48,5 +42,3 @@
 #pragma omp end declare variant
 
 #endif
-
-#endif
Index: clang/lib/Headers/__clang_cuda_complex_builtins.h
===
--- clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -16,7 +16,7 @@
 // to work with CUDA and OpenMP target offloading [in C and C++ mode].)
 
 #pragma push_macro("__DEVICE__")
-#ifdef __OPENMP_NVPTX__
+#ifdef _OPENMP
 #pragma omp declare target
 #define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
 #else
@@ -26,7 +26,7 @@
 // To make the algorithms available for C and C++ in CUDA and OpenMP we select
 // different but equivalent function versions. TODO: For OpenMP we currently
 // select the native builtins as the overload support for templates is lacking.
-#if !defined(__OPENMP_NVPTX__)
+#if !defined(_OPENMP)
 #define _ISNANd std::isnan
 #define _ISNANf std::isnan
 #define _ISINFd std::isinf
@@ -276,7 +276,7 @@
 #undef _fmaxd
 #undef _fmaxf
 
-#ifdef __OPENMP_NVPTX__
+#ifdef _OPENMP
 #pragma omp end declare target
 #endif
 


Index: clang/lib/Headers/openmp_wrappers/complex.h
===
--- clang/lib/Headers/openmp_wrappers/complex.h
+++ clang/lib/Headers/openmp_wrappers/complex.h
@@ -17,10 +17,8 @@
 // We require math functions in the complex builtins below.
 #include 
 
-#define __CUDA__
-#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
-#undef __OPENMP_NVPTX__
+
 #endif
 
 // Grab the host header too.
Index: clang/lib/Headers/openmp_wrappers/complex
===
--- clang/lib/Headers/openmp_wrappers/complex
+++ clang/lib/Headers/openmp_wrappers/complex
@@ -17,18 +17,12 @@
 // We require std::math functions in the complex builtins below.
 #include 
 
-#define __CUDA__
-#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
-#undef __OPENMP_NVPTX__
 #endif
 
 // Grab the host header too.
 #include_next 
 
-
-#ifdef __cplusplus
-
 // If we are compiling against libc++, the macro _LIBCPP_STD_VER should be set
 // after including  above. Since the complex header we use is a
 // simplified version of the libc++, we don't need it in this case. If we
@@ -48,5 +42,3 @@
 #pragma omp end declare variant
 
 #endif
-
-#endif
Index: clang/lib/Headers/__clang_cuda_complex_builtins.h
===
--- clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -16,7 +16,7 @@
 // to work with CUDA and 

[PATCH] D103668: [PowerPC] Implement trap and conversion builtins for XL compatibility

2021-06-30 Thread Victor Huang via Phabricator via cfe-commits
NeHuang requested changes to this revision.
NeHuang added inline comments.
This revision now requires changes to proceed.



Comment at: clang/include/clang/Basic/BuiltinsPPC.def:32
 
-// builtins for compatibility with the XL compiler
+// XL Compatibility built-ins
 BUILTIN(__builtin_ppc_popcntb, "ULiULi", "")

seems like rebase issue that comments got overwritten.



Comment at: clang/include/clang/Basic/BuiltinsPPC.def:50
 BUILTIN(__builtin_ppc_compare_and_swaplp, "iLiD*Li*Li", "")
+BUILTIN(__builtin_ppc_tdw, "vLLiLLiIi", "")
+BUILTIN(__builtin_ppc_tw, "viiIi", "")

definition here not matching prototype in document 
```
void __tdw ( long a, long b, unsigned int TO);
```



Comment at: clang/include/clang/Basic/BuiltinsPPC.def:51
+BUILTIN(__builtin_ppc_tdw, "vLLiLLiIi", "")
+BUILTIN(__builtin_ppc_tw, "viiIi", "")
+BUILTIN(__builtin_ppc_trap, "vi", "")

prototype 
```
void __tw (int a, int b, unsigned int TO);
```
why not using `Ui` for the last arg?  



Comment at: clang/lib/Sema/SemaChecking.cpp:3347
+  case PPC::BI__builtin_ppc_tw:
+return SemaBuiltinConstantArgRange(TheCall, 2, 1, 31);
+  case PPC::BI__builtin_ppc_tdw:

range suppose to be 0 to 31 based on document.



Comment at: clang/lib/Sema/SemaChecking.cpp:3349
+  case PPC::BI__builtin_ppc_tdw:
+return SemaBuiltinConstantArgRange(TheCall, 2, 1, 31);
 #define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \

same as above.



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c:2
+// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
+// RUN: %clang_cc1 -O2 -triple powerpc64le-unknown-unknown \

are these builtins all pwr9 only? 
- If yes, please rename the file. 
- If not, please use pwr8 for LE test and pwr7 for BE cases.



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c:9
+// RUN:   -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
+
+double test_fcfid(double a) {

you can define extern variables here for the bulitins.



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-error.c:16
+#ifdef __PPC64__
+  __tdw(lla, llb, 50); //expected-error {{argument value 50 is outside the 
valid range [1, 31]}}
+#endif

range should be 0 to 31 as described in document.
```
TO A value of 0 to 31 inclusive. Each bit position, if set, indicates one or 
more of
the following possible conditions:
```



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-error.c:18
+#endif
+  __tw(ia, ib, 50); //expected-error {{argument value 50 is outside the valid 
range [1, 31]}}
+}

same as above 



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-trap.c:2
+// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr9 | \
+// RUN:  FileCheck %s --check-prefixes=CHECK64,CHECK

same as above.



Comment at: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-conversionfunc.ll:3
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-64
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \

32 bit and 64 bit results look identical, you do not need prefixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103668

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


[clang] 822b92a - [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-30 Thread Xun Li via cfe-commits

Author: Xun Li
Date: 2021-06-30T11:38:14-07:00
New Revision: 822b92aae439c4ba2946980c8a27bd2c8a62d90c

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

LOG: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue 
after CoroSplit actually happened

Relevant discussion can be found at: 
https://lists.llvm.org/pipermail/llvm-dev/2021-January/148197.html
In the existing design, An SCC that contains a coroutine will go through the 
folloing passes:
Inliner -> CoroSplitPass (fake) -> FunctionSimplificationPipeline -> Inliner -> 
CoroSplitPass (real) -> FunctionSimplificationPipeline

The first CoroSplitPass doesn't do anything other than putting the SCC back to 
the queue so that the entire pipeline can repeat.
As you can see, we run Inliner twice on the SCC consecutively without doing any 
real split, which is unnecessary and likely unintended.
What we really wanted is this:
Inliner -> FunctionSimplificationPipeline -> CoroSplitPass -> 
FunctionSimplificationPipeline
(note that we don't really need to run Inliner again on the ramp function after 
split).

Hence the way we do it here is to move CoroSplitPass to the end of the CGSCC 
pipeline, make it once for real, insert the newly generated SCCs (the clones) 
back to the pipeline so that they can be optimized, and also add a function 
simplification pipeline after CoroSplit to optimize the post-split ramp 
function.

This approach also conforms to how the new pass manager works instead of 
relying on an adhoc post split cleanup, making it ready for full switch to new 
pass manager eventually.

By looking at some of the changes to the tests, we can already observe that 
this changes allows for more optimizations applied to coroutines.

Reviewed By: aeubanks, ChuanqiXu

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

Added: 


Modified: 
clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/test/Transforms/Coroutines/ArgAddr.ll
llvm/test/Transforms/Coroutines/coro-alloc-with-param-O0.ll
llvm/test/Transforms/Coroutines/coro-alloc-with-param-O2.ll
llvm/test/Transforms/Coroutines/coro-alloca-01.ll
llvm/test/Transforms/Coroutines/coro-alloca-02.ll
llvm/test/Transforms/Coroutines/coro-alloca-03.ll
llvm/test/Transforms/Coroutines/coro-alloca-04.ll
llvm/test/Transforms/Coroutines/coro-alloca-05.ll
llvm/test/Transforms/Coroutines/coro-alloca-06.ll
llvm/test/Transforms/Coroutines/coro-alloca-07.ll
llvm/test/Transforms/Coroutines/coro-alloca-08.ll
llvm/test/Transforms/Coroutines/coro-async.ll
llvm/test/Transforms/Coroutines/coro-byval-param.ll
llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll
llvm/test/Transforms/Coroutines/coro-catchswitch.ll
llvm/test/Transforms/Coroutines/coro-debug.ll
llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-00.ll
llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-01.ll
llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-02.ll
llvm/test/Transforms/Coroutines/coro-frame-arrayalloca.ll
llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-00.ll
llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-01.ll
llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-02.ll
llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-03.ll
llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-04.ll
llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-05.ll
llvm/test/Transforms/Coroutines/coro-frame-unreachable.ll
llvm/test/Transforms/Coroutines/coro-frame.ll
llvm/test/Transforms/Coroutines/coro-materialize.ll
llvm/test/Transforms/Coroutines/coro-padding.ll
llvm/test/Transforms/Coroutines/coro-param-copy.ll
llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
llvm/test/Transforms/Coroutines/coro-retcon-frame.ll
llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
llvm/test/Transforms/Coroutines/coro-retcon-resume-values2.ll
llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
llvm/test/Transforms/Coroutines/coro-retcon-value.ll
llvm/test/Transforms/Coroutines/coro-retcon.ll
llvm/test/Transforms/Coroutines/coro-spill-after-phi.ll
llvm/test/Transforms/Coroutines/coro-spill-corobegin.ll
llvm/test/Transforms/Coroutines/coro-spill-defs-before-corobegin.ll
llvm/test/Transforms/Coroutines/coro-spill-promise.ll
llvm/test/Transforms/Coroutines/coro-split-00.ll
llvm/test/Transforms/Coroutines/coro-split-02.ll
llvm/test/Transforms/Coroutines/coro-split-alloc.ll
llvm/test/Transforms/Coroutines/coro-split-dbg.ll

[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-30 Thread Xun Li 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 rG822b92aae439: [Coroutines] Add the newly generated SCCs back 
to the CGSCC work queue after… (authored by lxfind).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

Files:
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/test/Transforms/Coroutines/ArgAddr.ll
  llvm/test/Transforms/Coroutines/coro-alloc-with-param-O0.ll
  llvm/test/Transforms/Coroutines/coro-alloc-with-param-O2.ll
  llvm/test/Transforms/Coroutines/coro-alloca-01.ll
  llvm/test/Transforms/Coroutines/coro-alloca-02.ll
  llvm/test/Transforms/Coroutines/coro-alloca-03.ll
  llvm/test/Transforms/Coroutines/coro-alloca-04.ll
  llvm/test/Transforms/Coroutines/coro-alloca-05.ll
  llvm/test/Transforms/Coroutines/coro-alloca-06.ll
  llvm/test/Transforms/Coroutines/coro-alloca-07.ll
  llvm/test/Transforms/Coroutines/coro-alloca-08.ll
  llvm/test/Transforms/Coroutines/coro-async.ll
  llvm/test/Transforms/Coroutines/coro-byval-param.ll
  llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll
  llvm/test/Transforms/Coroutines/coro-catchswitch.ll
  llvm/test/Transforms/Coroutines/coro-debug.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-00.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-01.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-02.ll
  llvm/test/Transforms/Coroutines/coro-frame-arrayalloca.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-00.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-01.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-02.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-03.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-04.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-05.ll
  llvm/test/Transforms/Coroutines/coro-frame-unreachable.ll
  llvm/test/Transforms/Coroutines/coro-frame.ll
  llvm/test/Transforms/Coroutines/coro-materialize.ll
  llvm/test/Transforms/Coroutines/coro-padding.ll
  llvm/test/Transforms/Coroutines/coro-param-copy.ll
  llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
  llvm/test/Transforms/Coroutines/coro-retcon-frame.ll
  llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values2.ll
  llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
  llvm/test/Transforms/Coroutines/coro-retcon-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon.ll
  llvm/test/Transforms/Coroutines/coro-spill-after-phi.ll
  llvm/test/Transforms/Coroutines/coro-spill-corobegin.ll
  llvm/test/Transforms/Coroutines/coro-spill-defs-before-corobegin.ll
  llvm/test/Transforms/Coroutines/coro-spill-promise.ll
  llvm/test/Transforms/Coroutines/coro-split-00.ll
  llvm/test/Transforms/Coroutines/coro-split-02.ll
  llvm/test/Transforms/Coroutines/coro-split-alloc.ll
  llvm/test/Transforms/Coroutines/coro-split-dbg.ll
  llvm/test/Transforms/Coroutines/coro-split-eh-00.ll
  llvm/test/Transforms/Coroutines/coro-split-eh-01.ll
  llvm/test/Transforms/Coroutines/coro-split-hidden.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail1.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail2.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail3.ll
  llvm/test/Transforms/Coroutines/coro-split-recursive.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-01.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-02.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-03.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-04.ll
  llvm/test/Transforms/Coroutines/coro-swifterror.ll
  llvm/test/Transforms/Coroutines/coro-zero-alloca.ll
  llvm/test/Transforms/Coroutines/no-suspend.ll
  llvm/test/Transforms/Coroutines/restart-trigger.ll
  llvm/test/Transforms/Coroutines/smoketest.ll

Index: llvm/test/Transforms/Coroutines/smoketest.ll
===
--- llvm/test/Transforms/Coroutines/smoketest.ll
+++ llvm/test/Transforms/Coroutines/smoketest.ll
@@ -10,12 +10,16 @@
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
 ; RUN: -debug-pass-manager 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -debug-pass-manager \
-; RUN: -passes='function(coro-early),cgscc(coro-split),function(coro-elide,coro-cleanup)' 2>&1 \
+; RUN: -passes='function(coro-early),function(coro-elide),cgscc(coro-split),function(coro-cleanup)' 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 
+; note that we 

[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-30 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/Headers/openmp_wrappers/math.h:41
 #pragma omp begin declare variant match(   
\
 device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
 

tianshilei1992 wrote:
> JonChesterfield wrote:
> > @jdoerfert do you know why we have match_any here? wondering if the amdgcn 
> > variant below should have the same
> Because `nvptx` and `nvptx64` share the same implementation. They just emit 
> different IRs. If AMDGCN only has one architecture, it doesn't need to use 
> `match_any`.
ah, right - thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D105145: [clang][Fuchsia] Remove relative-vtables multilibs

2021-06-30 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b0ddc2662ad: [clang][Fuchsia] Remove relative-vtables 
multilibs (authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105145

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -222,41 +222,15 @@
 set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE 
BOOL "")
 set(RUNTIMES_${target}+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE 
BOOL "")
 
-set(RUNTIMES_${target}+relative-vtables_LLVM_BUILD_COMPILER_RT OFF CACHE 
BOOL "")
-set(RUNTIMES_${target}+relative-vtables_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-set(RUNTIMES_${target}+relative-vtables+asan_LLVM_BUILD_COMPILER_RT OFF 
CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan_LLVM_USE_SANITIZER "Address" 
CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+asan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-set(RUNTIMES_${target}+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+noexcept_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LLVM_USE_SANITIZER 
"Address" CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan+noexcept_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;compat;asan+noexcept;relative-vtables;relative-vtables+noexcept;relative-vtables+asan;relative-vtables+asan+noexcept"
 CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;compat;asan+noexcept" CACHE STRING 
"")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_compat_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -222,41 +222,15 @@
 set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
 set(RUNTIMES_${target}+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
 
-set(RUNTIMES_${target}+relative-vtables_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables_CMAKE_CXX_FLAGS "${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-  

[clang] 9b0ddc2 - [clang][Fuchsia] Remove relative-vtables multilibs

2021-06-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-06-30T11:21:37-07:00
New Revision: 9b0ddc2662addaa563b632c577996e515e1a7802

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

LOG: [clang][Fuchsia] Remove relative-vtables multilibs

As of D102374, relative vtables is enabled on Fuchsia by default, so we don't 
need any of the RV multilibs.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index eb001ef6579ce..c031465002cca 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -222,41 +222,15 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE 
BOOL "")
 set(RUNTIMES_${target}+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE 
BOOL "")
 
-set(RUNTIMES_${target}+relative-vtables_LLVM_BUILD_COMPILER_RT OFF CACHE 
BOOL "")
-set(RUNTIMES_${target}+relative-vtables_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-set(RUNTIMES_${target}+relative-vtables+asan_LLVM_BUILD_COMPILER_RT OFF 
CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan_LLVM_USE_SANITIZER "Address" 
CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+asan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-set(RUNTIMES_${target}+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+noexcept_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LLVM_USE_SANITIZER 
"Address" CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan+noexcept_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;compat;asan+noexcept;relative-vtables;relative-vtables+noexcept;relative-vtables+asan;relative-vtables+asan+noexcept"
 CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;compat;asan+noexcept" CACHE STRING 
"")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_compat_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")



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


[PATCH] D104085: [compiler-rt][hwasan] Setup hwasan thread handling on Fuchsia

2021-06-30 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 355637.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104085

Files:
  compiler-rt/lib/hwasan/CMakeLists.txt
  compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
  compiler-rt/lib/hwasan/hwasan_thread.cpp

Index: compiler-rt/lib/hwasan/hwasan_thread.cpp
===
--- compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -46,7 +46,12 @@
 heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
 
   InitStackAndTls(state);
+#if !SANITIZER_FUCHSIA
+  // Do not initialize the stack ring buffer just yet on Fuchsia. Threads will
+  // be initialized before we enter the thread itself, so we will instead call
+  // this later.
   InitStackRingBuffer(stack_buffer_start, stack_buffer_size);
+#endif
 }
 
 void Thread::InitStackRingBuffer(uptr stack_buffer_start,
Index: compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
===
--- /dev/null
+++ compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
@@ -0,0 +1,159 @@
+//===-- hwasan_fuchsia.cpp --*- C++ -*-===//
+//
+// 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
+//
+//===--===//
+///
+/// \file
+/// This file is a part of HWAddressSanitizer and contains Fuchsia-specific
+/// code.
+///
+//===--===//
+
+#include "sanitizer_common/sanitizer_fuchsia.h"
+#if SANITIZER_FUCHSIA
+
+#include "hwasan.h"
+#include "hwasan_interface_internal.h"
+#include "hwasan_report.h"
+#include "hwasan_thread.h"
+#include "hwasan_thread_list.h"
+
+// This TLS variable contains the location of the stack ring buffer and can be
+// used to always find the hwasan thread object associated with the current
+// running thread.
+[[gnu::tls_model("initial-exec")]]
+SANITIZER_INTERFACE_ATTRIBUTE
+THREADLOCAL uptr __hwasan_tls;
+
+namespace __hwasan {
+
+// These are known parameters passed to the hwasan runtime on thread creation.
+struct Thread::InitState {
+  uptr stack_bottom, stack_top;
+};
+
+static void FinishThreadInitialization(Thread *thread);
+
+void InitThreads() {
+  // This is the minimal alignment needed for the storage where hwasan threads
+  // and their stack ring buffers are placed. This alignment is necessary so the
+  // stack ring buffer can perform a simple calculation to get the next element
+  // in the RB. The instructions for this calculation are emitted by the
+  // compiler. (Full explanation in hwasan_thread_list.h.)
+  uptr alloc_size = UINT64_C(1) << kShadowBaseAlignment;
+  uptr thread_start = reinterpret_cast(
+  MmapAlignedOrDieOnFatalError(alloc_size, alloc_size, __func__));
+
+  InitThreadList(thread_start, alloc_size);
+
+  // Create the hwasan thread object for the current (main) thread. Stack info
+  // for this thread is known from information passed via
+  // __sanitizer_startup_hook.
+  const Thread::InitState state = {
+  .stack_bottom = __sanitizer::MainThreadStackBase,
+  .stack_top =
+  __sanitizer::MainThreadStackBase + __sanitizer::MainThreadStackSize,
+  };
+  FinishThreadInitialization(hwasanThreadList().CreateCurrentThread());
+}
+
+uptr *GetCurrentThreadLongPtr() { return &__hwasan_tls; }
+
+// This is called from the parent thread before the new thread is created. Here
+// we can propagate known info like the stack bounds to Thread::Init before
+// jumping into the thread. We cannot initialize the stack ring buffer yet since
+// we have not entered the new thread.
+static void *BeforeThreadCreateHook(uptr user_id, bool detached,
+const char *name, uptr stack_bottom,
+uptr stack_size) {
+  const Thread::InitState state = {
+  .stack_bottom = stack_bottom,
+  .stack_top = stack_bottom + stack_size,
+  };
+  return hwasanThreadList().CreateCurrentThread();
+}
+
+// This sets the stack top and bottom according to the InitState passed to
+// CreateCurrentThread above.
+void Thread::InitStackAndTls(const InitState *state) {
+  CHECK_NE(state->stack_bottom, 0);
+  CHECK_NE(state->stack_top, 0);
+  stack_bottom_ = state->stack_bottom;
+  stack_top_ = state->stack_top;
+  tls_end_ = tls_begin_ = 0;
+}
+
+// This is called after creating a new thread with the pointer returned by
+// BeforeThreadCreateHook. We are still in the creating thread and should check
+// if it was actually created correctly.
+static void ThreadCreateHook(void *hook, bool aborted) {
+  Thread *thread = static_cast(hook);
+  if (!aborted) {
+// The thread was created successfully.
+// ThreadStartHook can 

[PATCH] D104388: [clang-format] PR50727 C# Invoke Lamda Expression indentation incorrect

2021-06-30 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 355627.
MyDeveloperDay marked 3 inline comments as done.
MyDeveloperDay added a comment.

Correct a couple of Nits prior to commit. (just updating patch for completeness)


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

https://reviews.llvm.org/D104388

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -640,6 +640,122 @@
 };
 })",
MicrosoftStyle);
+
+  verifyFormat("void bar()\n"
+   "{\n"
+   "Function(Val, (Action)(() =>\n"
+   "   {\n"
+   "   lock (mylock)\n"
+   "   {\n"
+   "   if (true)\n"
+   "   {\n"
+   "   A.Remove(item);\n"
+   "   }\n"
+   "   }\n"
+   "   }));\n"
+   "}",
+   MicrosoftStyle);
+
+  verifyFormat("void baz()\n"
+   "{\n"
+   "Function(Val, (Action)(() =>\n"
+   "   {\n"
+   "   using (var a = new Lock())\n"
+   "   {\n"
+   "   if (true)\n"
+   "   {\n"
+   "   A.Remove(item);\n"
+   "   }\n"
+   "   }\n"
+   "   }));\n"
+   "}",
+   MicrosoftStyle);
+
+  verifyFormat("void baz()\n"
+   "{\n"
+   "Function(Val, (Action)(() =>\n"
+   "   {\n"
+   "   if (true)\n"
+   "   {\n"
+   "   A.Remove(item);\n"
+   "   }\n"
+   "   }));\n"
+   "}",
+   MicrosoftStyle);
+
+  verifyFormat("void baz()\n"
+   "{\n"
+   "Function(Val, (Action)(() =>\n"
+   "   {\n"
+   "   do\n"
+   "   {\n"
+   "   A.Remove(item);\n"
+   "   } while (true)\n"
+   "   }));\n"
+   "}",
+   MicrosoftStyle);
+
+  verifyFormat("void baz()\n"
+   "{\n"
+   "Function(Val, (Action)(() =>\n"
+   "   { A.Remove(item); }));\n"
+   "}",
+   MicrosoftStyle);
+
+  verifyFormat("void bar()\n"
+   "{\n"
+   "Function(Val, (() =>\n"
+   "   {\n"
+   "   lock (mylock)\n"
+   "   {\n"
+   "   if (true)\n"
+   "   {\n"
+   "   A.Remove(item);\n"
+   "   }\n"
+   "   }\n"
+   "   }));\n"
+   "}",
+   MicrosoftStyle);
+  verifyFormat("void bar()\n"
+   "{\n"
+   "Function((() =>\n"
+   "  {\n"
+   "  lock (mylock)\n"
+   "  {\n"
+   "  if (true)\n"
+   "  {\n"
+   "  A.Remove(item);\n"
+   "  }\n"
+   "  }\n"
+   "  }));\n"
+   "}",
+   MicrosoftStyle);
+
+  MicrosoftStyle.IndentWidth = 2;
+  verifyFormat("void bar()\n"
+   "{\n"
+   "  Function((() =>\n"
+   "{\n"
+   "  lock (mylock)\n"
+   "  {\n"
+   "if (true)\n"
+   "{\n"
+   "  A.Remove(item);\n"
+   "}\n"
+   "  }\n"
+   "}));\n"
+  

Re: [PATCH] D100553: [clangd] Log feature configuration (linux+asan+grpc) of the clangd build

2021-06-30 Thread Sam McCall via cfe-commits
Doh, thank you Nico!

On Wed, 30 Jun 2021, 18:54 Nico Weber via Phabricator, <
revi...@reviews.llvm.org> wrote:

> thakis added a comment.
>
> (fyi: this broke mac builds. i fixed that in
> b56e5f8a10c1ec4fd3750bdd269fbad778820326 <
> https://reviews.llvm.org/rGb56e5f8a10c1ec4fd3750bdd269fbad778820326>)
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D100553/new/
>
> https://reviews.llvm.org/D100553
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98799: [UniqueLinkageName] Use consistent checks when mangling symbo linkage name and debug linkage name.

2021-06-30 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D98799#2850682 , @ahatanak wrote:

> I think I've fixed all the places in CodeGen that create fake `FunctionDecl`s 
> and would cause clang to crash.

Thanks, I really appreciate it! I'll have a go at unifying this mangled V 
unique internal linkage name stuff soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98799

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-30 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/lib/Headers/openmp_wrappers/math.h:41
 #pragma omp begin declare variant match(   
\
 device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
 

JonChesterfield wrote:
> @jdoerfert do you know why we have match_any here? wondering if the amdgcn 
> variant below should have the same
Because `nvptx` and `nvptx64` share the same implementation. They just emit 
different IRs. If AMDGCN only has one architecture, it doesn't need to use 
`match_any`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D98799: [UniqueLinkageName] Use consistent checks when mangling symbo linkage name and debug linkage name.

2021-06-30 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.
Herald added a subscriber: modimo.

I think I've fixed all the places in CodeGen that create fake `FunctionDecl`s 
and would cause clang to crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98799

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-30 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

tagged request changes because I think we should ifdef around complex before 
(or while) landing this, as defining `__CUDA__`, even transiently, is a user 
hostile thing to do from amdgpu openmp

It is *really* ugly that we have cuda and hip implementations of cmath. Opening 
them in diff it looks very likely that the hip one was create by copying and 
pasting the cuda one then hacking on it a bit. This means we have openmp 
specific fixes already done in the cuda one and VS2019 workarounds in the hip 
one. It also means there are a bunch of differences that might be important or 
might be spurious, like whether a function calls ::scalbln or std::scalbln. 
This is particularly frustrating because we should be able isolate essentially 
all the differences between __nv and __ocml functions in math.h.




Comment at: clang/lib/Headers/openmp_wrappers/cmath:30
 
 #pragma omp begin declare variant match(   
\
 device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any, 
allow_templates)})

this declare variant will not match amdgcn



Comment at: clang/lib/Headers/openmp_wrappers/cmath:43
 
 __DEVICE__ float acosh(float __x) { return ::acoshf(__x); }
 __DEVICE__ float asinh(float __x) { return ::asinhf(__x); }

which means that amdgcn is not going to pick up any of these overloads, but 
that looks like it's actually OK because clang_hip_cmath does define them (I 
think, there are a lot of macros involved)



Comment at: clang/lib/Headers/openmp_wrappers/math.h:41
 #pragma omp begin declare variant match(   
\
 device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
 

@jdoerfert do you know why we have match_any here? wondering if the amdgcn 
variant below should have the same


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D104388: [clang-format] PR50727 C# Invoke Lamda Expression indentation incorrect

2021-06-30 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

> I implemented a good fraction of the C# support and am confident that these 
> changes are an improvement.

Thank you.

I've been very grateful to you all (which is why I included you as reviewers) 
for filling in the gaps in the C# formatting, but I'm super grateful we've been 
able to get to the point where its very usable, because I use C# in my personal 
projects and C#/C++ for my work, but I tend not to push the envelop on the 
latest language features.


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

https://reviews.llvm.org/D104388

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


[PATCH] D105099: [clang-format] Add an option to put one constructor initializer per line

2021-06-30 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

> is a smell that tells us to use an enum.

I totally agree

> Personally I find it harder to finder multiple options that concern the same 
> aspect of the code style rather than a single option.

To be honest, I think we know the options some of the best (apart of course 
from @djasper and @klimek), and most of the time I'm totally confused, as to 
which options do which, it ends up being trail and error. This way bugs creep 
in.

Yes I feel that way too this should have been

ConstructorInitializer:  Compact

or

ConstructorInitializer:  OnePerLine

It would make


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105099

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


[PATCH] D102782: Add support for Warning Flag "-Wstack-usage="

2021-06-30 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-06-30 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 355614.
sepavloff added a comment.

Missed optimization in X86 codegen proposed by Craig


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/strictfp_builtins.c
  clang/test/CodeGen/aarch64-strictfp-builtins.c
  clang/test/CodeGen/strictfp_builtins.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/AArch64/aarch64-fpclass.ll
  llvm/test/CodeGen/PowerPC/ppc-fpclass.ll
  llvm/test/CodeGen/X86/x86-fpclass.ll
  llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll

Index: llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll
@@ -0,0 +1,28 @@
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+define i1 @isnan_01() {
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float 0x7FF8)
+  ret i1 %0
+}
+; CHECK-LABEL: isnan_01
+; CHECK:   ret i1 true 
+
+define i1 @isnan_02() {
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float 0x7FF0)
+  ret i1 %0
+}
+; CHECK-LABEL: isnan_02
+; CHECK:   ret i1 false 
+
+define <4 x i1> @isnan_03() {
+entry:
+  %0 = tail call <4 x i1> @llvm.isnan.v4f32(<4 x float>)
+  ret <4 x i1> %0
+}
+; CHECK-LABEL: isnan_03
+; CHECK:   ret <4 x i1> 
+
+declare i1 @llvm.isnan.f32(float)
+declare <4 x i1> @llvm.isnan.v4f32(<4 x float>)
Index: llvm/test/CodeGen/X86/x86-fpclass.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/x86-fpclass.ll
@@ -0,0 +1,655 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686 | FileCheck %s -check-prefix=CHECK-32
+; RUN: llc < %s -mtriple=x86_64 | FileCheck %s -check-prefix=CHECK-64
+
+define i1 @isnan_float(float %x) {
+; CHECK-32-LABEL: isnan_float:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:flds {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fucomp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:# kill: def $ah killed $ah killed $ax
+; CHECK-32-NEXT:sahf
+; CHECK-32-NEXT:setp %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_float:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:ucomiss %xmm0, %xmm0
+; CHECK-64-NEXT:setp %al
+; CHECK-64-NEXT:retq
+; NOSSE-32-LABEL: isnan_float:
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float %x)
+  ret i1 %0
+}
+
+define i1 @isnan_double(double %x) {
+; CHECK-32-LABEL: isnan_double:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:fldl {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fucomp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:# kill: def $ah killed $ah killed $ax
+; CHECK-32-NEXT:sahf
+; CHECK-32-NEXT:setp %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_double:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:ucomisd %xmm0, %xmm0
+; CHECK-64-NEXT:setp %al
+; CHECK-64-NEXT:retq
+entry:
+  %0 = tail call i1 @llvm.isnan.f64(double %x)
+  ret i1 %0
+}
+
+define i1 @isnan_ldouble(x86_fp80 %x) {
+; CHECK-32-LABEL: isnan_ldouble:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:fldt {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fxam
+; CHECK-32-NEXT:fstp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:andb $69, %ah
+; CHECK-32-NEXT:cmpb $1, %ah
+; CHECK-32-NEXT:sete %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_ldouble:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:fldt {{[0-9]+}}(%rsp)
+; CHECK-64-NEXT:fxam
+; CHECK-64-NEXT:fstp %st(0)
+; CHECK-64-NEXT:fnstsw %ax
+; CHECK-64-NEXT:andb $69, %ah
+; CHECK-64-NEXT:cmpb $1, %ah
+; CHECK-64-NEXT:sete %al
+; CHECK-64-NEXT:retq
+entry:
+  %0 = tail call i1 @llvm.isnan.f80(x86_fp80 %x)
+  ret i1 %0
+}
+
+define i1 @isnan_float_strictfp(float %x) strictfp {
+; CHECK-32-LABEL: isnan_float_strictfp:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:movl $2147483647, %eax # imm = 0x7FFF
+; CHECK-32-NEXT:andl {{[0-9]+}}(%esp), %eax
+; CHECK-32-NEXT:cmpl $2139095040, %eax # imm = 0x7F80
+; CHECK-32-NEXT:setne %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_float_strictfp:
+; CHECK-64: 

[PATCH] D105097: [clang][AArch64][SVE] Handle PRValue under VLAT <-> VLST cast

2021-06-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c:108
+// CHECK-128-NEXT:[[CASTFIXEDSVE:%.*]] = bitcast <2 x i8>* [[SAVED_VALUE]] 
to *
+// CHECK-128-NEXT:[[TMP1:%.*]] = load , * [[CASTFIXEDSVE]], align 16, !tbaa [[TBAA6]]
+// CHECK-128-NEXT:ret  [[TMP1]]

Oh, hmm, this is the case where we can't optimize.

We could probably teach instcombine to convert this pattern into a load 
directly from the global, if it matters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105097

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


[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-30 Thread Xun Li via Phabricator via cfe-commits
lxfind added inline comments.



Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:2001
 
-if ((Shape.ABI == coro::ABI::Async || Shape.ABI == coro::ABI::Retcon ||
- Shape.ABI == coro::ABI::RetconOnce) &&
-!Shape.CoroSuspends.empty()) {
-  // Run the CGSCC pipeline on the newly split functions.
-  // All clones will be in the same RefSCC, so choose a random clone.
-  UR.RCWorklist.insert(CG.lookupRefSCC(CG.get(*Clones[0])));
+if (!Shape.CoroSuspends.empty()) {
+  // Run the CGSCC pipeline on the original and newly split functions.

ychen wrote:
> aeubanks wrote:
> > ChuanqiXu wrote:
> > > I am not familiar with the Shape.ABI other than coro::ABI:switch. But the 
> > > diff line seems strange, it looks like that condition gets weaker.
> > I believe that's intentional, and a big part of this patch. We want to 
> > re-add the current SCC (and the split SCCs) any time we split an SCC. 
> > Before we weren't properly doing that.
> I got your point. So "// All clones will be in the same RefSCC " : this 
> is not accurate I think?
Note that previously this is done only for Async, Retcon and RetconOnce ABIs, 
not for the Switch ABI.
I guess that's accurate for those ABIs? But for Switch ABI this is not true.
And before we were not adding back the split functions to the pipeline to be 
properly optimized. Now we are dong that. This should help improve the 
performance of the post-split functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-30 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Weird pre-existing stuff in cuda_complex_builtins. It has an #ifdef AMDGCN 
macro in it, despite 'cuda' in the name. I note there is no corresponding 'hip' 
complex builtins.

The ifdef logic for stubbing out some functions (which is done with macros...) 
isn't ideal, it's:

  #if !defined (_OPENMP_NVPTX)
  // use std:: functions from cmath.h, which isn't included, though math.h is 
included from openmp before it
  #else 
  #ifdef __AMDGCN__
  // use ocml functions
  #else
  // use nv functions
  #end
  #end

None of this uses `#define __CUDA__` so we could drop that from the openmp 
wrapper. Or, as far as I can tell, we could drop all the macro obfuscation in 
that header and just call the libm functions directly, which will already 
resolve to the appropriate platform specific thing.

Instead of revising that as part of this patch, how about we wrap the 
openmp_wrappers/complex.h logic in `#ifndef __AMDGCN__`, which will cut it from 
the graph for openmp while leaving nvptx openmp untouched?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D105185: [AIX] Add _AIX73 version macro

2021-06-30 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan updated this revision to Diff 355613.
Jake-Egan added a comment.

Fixed formatting to be consistent with the other macro definitions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105185

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init-ppc.c

Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -585,6 +585,20 @@
 // PPC-AIX:#define __powerpc__ 1
 // PPC-AIX:#define __ppc__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.3.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX73 %s
+//
+// PPC-AIX73:#define _AIX32 1
+// PPC-AIX73:#define _AIX41 1
+// PPC-AIX73:#define _AIX43 1
+// PPC-AIX73:#define _AIX50 1
+// PPC-AIX73:#define _AIX51 1
+// PPC-AIX73:#define _AIX52 1
+// PPC-AIX73:#define _AIX53 1
+// PPC-AIX73:#define _AIX61 1
+// PPC-AIX73:#define _AIX71 1
+// PPC-AIX73:#define _AIX72 1
+// PPC-AIX73:#define _AIX73 1
+
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.2.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX72 %s
 //
 // PPC-AIX72:#define _AIX32 1
@@ -597,6 +611,7 @@
 // PPC-AIX72:#define _AIX61 1
 // PPC-AIX72:#define _AIX71 1
 // PPC-AIX72:#define _AIX72 1
+// PPC-AIX72-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX71 %s
 //
@@ -610,6 +625,7 @@
 // PPC-AIX71:#define _AIX61 1
 // PPC-AIX71:#define _AIX71 1
 // PPC-AIX71-NOT:#define _AIX72 1
+// PPC-AIX71-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix6.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX61 %s
 //
@@ -623,6 +639,7 @@
 // PPC-AIX61:#define _AIX61 1
 // PPC-AIX61-NOT:#define _AIX71 1
 // PPC-AIX61-NOT:#define _AIX72 1
+// PPC-AIX61-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.3.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX53 %s
 // PPC-AIX53:#define _AIX32 1
@@ -635,6 +652,7 @@
 // PPC-AIX53-NOT:#define _AIX61 1
 // PPC-AIX53-NOT:#define _AIX71 1
 // PPC-AIX53-NOT:#define _AIX72 1
+// PPC-AIX53-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.2.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX52 %s
 // PPC-AIX52:#define _AIX32 1
@@ -647,6 +665,7 @@
 // PPC-AIX52-NOT:#define _AIX61 1
 // PPC-AIX52-NOT:#define _AIX71 1
 // PPC-AIX52-NOT:#define _AIX72 1
+// PPC-AIX52-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX51 %s
 // PPC-AIX51:#define _AIX32 1
@@ -659,6 +678,7 @@
 // PPC-AIX51-NOT:#define _AIX61 1
 // PPC-AIX51-NOT:#define _AIX71 1
 // PPC-AIX51-NOT:#define _AIX72 1
+// PPC-AIX51-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.0.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX50 %s
 // PPC-AIX50:#define _AIX32 1
@@ -671,6 +691,7 @@
 // PPC-AIX50-NOT:#define _AIX61 1
 // PPC-AIX50-NOT:#define _AIX71 1
 // PPC-AIX50-NOT:#define _AIX72 1
+// PPC-AIX50-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix4.3.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX43 %s
 // PPC-AIX43:#define _AIX32 1
@@ -683,6 +704,7 @@
 // PPC-AIX43-NOT:#define _AIX61 1
 // PPC-AIX43-NOT:#define _AIX71 1
 // PPC-AIX43-NOT:#define _AIX72 1
+// PPC-AIX43-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix4.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX41 %s
 // PPC-AIX41:#define _AIX32 1
@@ -695,6 +717,7 @@
 // PPC-AIX41-NOT:#define _AIX61 1
 // PPC-AIX41-NOT:#define _AIX71 1
 // PPC-AIX41-NOT:#define _AIX72 1
+// PPC-AIX41-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix3.2.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX32 %s
 // PPC-AIX32:#define _AIX32 1
@@ -707,6 +730,7 @@
 // PPC-AIX32-NOT:#define _AIX61 1
 // PPC-AIX32-NOT:#define _AIX71 1
 // PPC-AIX32-NOT:#define _AIX72 1
+// PPC-AIX32-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-CXX %s
 //
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -700,6 +700,7 @@
 if (OsVersion >= std::make_pair(6, 1)) Builder.defineMacro("_AIX61");
 if (OsVersion >= std::make_pair(7, 1)) Builder.defineMacro("_AIX71");
 if (OsVersion >= std::make_pair(7, 2)) 

[PATCH] D104946: [AMDGPU] Add builtin functions image_bvh_intersect_ray

2021-06-30 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG434bd5bf5479: [AMDGPU] Add builtin functions 
image_bvh_intersect_ray (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104946

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn-raytracing.cl

Index: clang/test/CodeGenOpenCL/builtins-amdgcn-raytracing.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-raytracing.cl
@@ -0,0 +1,61 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1030 -S \
+// RUN:   -emit-llvm -cl-std=CL2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1030 -S \
+// RUN:   -cl-std=CL2.0 -o - %s | FileCheck -check-prefix=ISA %s
+
+// Test llvm.amdgcn.image.bvh.intersect.ray intrinsic.
+
+// The clang builtin functions __builtin_amdgcn_image_bvh_intersect_ray* use
+// postfixes to indicate the types of the 1st, 4th, and 5th arguments.
+// By default, the 1st argument is i32, the 4/5-th arguments are float4.
+// Postfix l indicates the 1st argument is i64 and postfix h indicates
+// the 4/5-th arguments are half4.
+
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef double double4 __attribute__((ext_vector_type(4)));
+typedef half half4 __attribute__((ext_vector_type(4)));
+typedef uint uint4 __attribute__((ext_vector_type(4)));
+
+// CHECK: call <4 x i32> @llvm.amdgcn.image.bvh.intersect.ray.i32.v4f32
+// ISA: image_bvh_intersect_ray
+void test_image_bvh_intersect_ray(global uint4* out, uint node_ptr,
+  float ray_extent, float4 ray_origin, float4 ray_dir, float4 ray_inv_dir,
+  uint4 texture_descr)
+{
+  *out = __builtin_amdgcn_image_bvh_intersect_ray(node_ptr, ray_extent,
+   ray_origin, ray_dir, ray_inv_dir, texture_descr);
+}
+
+// CHECK: call <4 x i32> @llvm.amdgcn.image.bvh.intersect.ray.i32.v4f16
+// ISA: image_bvh_intersect_ray
+void test_image_bvh_intersect_ray_h(global uint4* out, uint node_ptr,
+  float ray_extent, float4 ray_origin, half4 ray_dir, half4 ray_inv_dir,
+  uint4 texture_descr)
+{
+  *out = __builtin_amdgcn_image_bvh_intersect_ray_h(node_ptr, ray_extent,
+   ray_origin, ray_dir, ray_inv_dir, texture_descr);
+}
+
+// CHECK: call <4 x i32> @llvm.amdgcn.image.bvh.intersect.ray.i64.v4f32
+// ISA: image_bvh_intersect_ray
+void test_image_bvh_intersect_ray_l(global uint4* out, ulong node_ptr,
+  float ray_extent, float4 ray_origin, float4 ray_dir, float4 ray_inv_dir,
+  uint4 texture_descr)
+{
+  *out = __builtin_amdgcn_image_bvh_intersect_ray_l(node_ptr, ray_extent,
+   ray_origin, ray_dir, ray_inv_dir, texture_descr);
+}
+
+// CHECK: call <4 x i32> @llvm.amdgcn.image.bvh.intersect.ray.i64.v4f16
+// ISA: image_bvh_intersect_ray
+void test_image_bvh_intersect_ray_lh(global uint4* out, ulong node_ptr,
+  float ray_extent, float4 ray_origin, half4 ray_dir, half4 ray_inv_dir,
+  uint4 texture_descr)
+{
+  *out = __builtin_amdgcn_image_bvh_intersect_ray_lh(node_ptr, ray_extent,
+   ray_origin, ray_dir, ray_inv_dir, texture_descr);
+}
+
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -15850,6 +15850,23 @@
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray:
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_h:
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_l:
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_lh: {
+llvm::Value *NodePtr = EmitScalarExpr(E->getArg(0));
+llvm::Value *RayExtent = EmitScalarExpr(E->getArg(1));
+llvm::Value *RayOrigin = EmitScalarExpr(E->getArg(2));
+llvm::Value *RayDir = EmitScalarExpr(E->getArg(3));
+llvm::Value *RayInverseDir = EmitScalarExpr(E->getArg(4));
+llvm::Value *TextureDescr = EmitScalarExpr(E->getArg(5));
+
+Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_image_bvh_intersect_ray,
+   {NodePtr->getType(), RayDir->getType()});
+return Builder.CreateCall(F, {NodePtr, RayExtent, RayOrigin, RayDir,
+  RayInverseDir, TextureDescr});
+  }
+
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:
 return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_x, 0, 1024);
Index: clang/include/clang/Basic/BuiltinsAMDGPU.def
===
--- clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -215,6 +215,17 @@
 

[clang] 434bd5b - [AMDGPU] Add builtin functions image_bvh_intersect_ray

2021-06-30 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-06-30T13:10:47-04:00
New Revision: 434bd5bf5479615ea42e64a80ff994059f31f5f4

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

LOG: [AMDGPU] Add builtin functions image_bvh_intersect_ray

Reviewed by: Stanislav Mekhanoshin, Matt Arsenault

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

Added: 
clang/test/CodeGenOpenCL/builtins-amdgcn-raytracing.cl

Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index f9d079accb56f..3570431d952cb 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -215,6 +215,17 @@ TARGET_BUILTIN(__builtin_amdgcn_permlane16, 
"UiUiUiUiUiIbIb", "nc", "gfx10-insts
 TARGET_BUILTIN(__builtin_amdgcn_permlanex16, "UiUiUiUiUiIbIb", "nc", 
"gfx10-insts")
 TARGET_BUILTIN(__builtin_amdgcn_mov_dpp8, "UiUiIUi", "nc", "gfx10-insts")
 
+//===--===//
+// Raytracing builtins.
+// By default the 1st argument is i32 and the 4/5-th arguments are float4.
+// Postfix l indicates the 1st argument is i64.
+// Postfix h indicates the 4/5-th arguments are half4.
+//===--===//
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray, 
"V4UiUifV4fV4fV4fV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_h, 
"V4UiUifV4fV4hV4hV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_l, 
"V4UiWUifV4fV4fV4fV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_lh, 
"V4UiWUifV4fV4hV4hV4Ui", "nc", "gfx10-insts")
+
 
//===--===//
 // Special builtins.
 
//===--===//

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 0e13b55b0cc57..9061abceab3a0 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -15850,6 +15850,23 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray:
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_h:
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_l:
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_lh: {
+llvm::Value *NodePtr = EmitScalarExpr(E->getArg(0));
+llvm::Value *RayExtent = EmitScalarExpr(E->getArg(1));
+llvm::Value *RayOrigin = EmitScalarExpr(E->getArg(2));
+llvm::Value *RayDir = EmitScalarExpr(E->getArg(3));
+llvm::Value *RayInverseDir = EmitScalarExpr(E->getArg(4));
+llvm::Value *TextureDescr = EmitScalarExpr(E->getArg(5));
+
+Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_image_bvh_intersect_ray,
+   {NodePtr->getType(), RayDir->getType()});
+return Builder.CreateCall(F, {NodePtr, RayExtent, RayOrigin, RayDir,
+  RayInverseDir, TextureDescr});
+  }
+
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:
 return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_x, 0, 1024);

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-raytracing.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-raytracing.cl
new file mode 100644
index 0..805d17a392b31
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-raytracing.cl
@@ -0,0 +1,61 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1030 -S \
+// RUN:   -emit-llvm -cl-std=CL2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1030 -S \
+// RUN:   -cl-std=CL2.0 -o - %s | FileCheck -check-prefix=ISA %s
+
+// Test llvm.amdgcn.image.bvh.intersect.ray intrinsic.
+
+// The clang builtin functions __builtin_amdgcn_image_bvh_intersect_ray* use
+// postfixes to indicate the types of the 1st, 4th, and 5th arguments.
+// By default, the 1st argument is i32, the 4/5-th arguments are float4.
+// Postfix l indicates the 1st argument is i64 and postfix h indicates
+// the 4/5-th arguments are half4.
+
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef double double4 __attribute__((ext_vector_type(4)));
+typedef half half4 __attribute__((ext_vector_type(4)));
+typedef uint uint4 __attribute__((ext_vector_type(4)));
+
+// CHECK: call <4 x i32> @llvm.amdgcn.image.bvh.intersect.ray.i32.v4f32

[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-30 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:2115
+  << "\n");
 F.removeFnAttr(CORO_PRESPLIT_ATTR);
 

drive-by nit: would it be better to move it up near `Coroutines.push_back();`?



Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:2001
 
-if ((Shape.ABI == coro::ABI::Async || Shape.ABI == coro::ABI::Retcon ||
- Shape.ABI == coro::ABI::RetconOnce) &&
-!Shape.CoroSuspends.empty()) {
-  // Run the CGSCC pipeline on the newly split functions.
-  // All clones will be in the same RefSCC, so choose a random clone.
-  UR.RCWorklist.insert(CG.lookupRefSCC(CG.get(*Clones[0])));
+if (!Shape.CoroSuspends.empty()) {
+  // Run the CGSCC pipeline on the original and newly split functions.

aeubanks wrote:
> ChuanqiXu wrote:
> > I am not familiar with the Shape.ABI other than coro::ABI:switch. But the 
> > diff line seems strange, it looks like that condition gets weaker.
> I believe that's intentional, and a big part of this patch. We want to re-add 
> the current SCC (and the split SCCs) any time we split an SCC. Before we 
> weren't properly doing that.
I got your point. So "// All clones will be in the same RefSCC " : this is 
not accurate I think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-30 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Good spot. I've been feeding the following to various toolchains:

  // permute
  //#include 
  //#include 
  //#include 
  
  #ifndef _OPENMP
  #error "OpenMP should be defined
  #endif
  
  #ifdef __CUDA__
  #error "Cuda should not be defined"
  #endif
  
  #ifdef __HIP__
  #error "HIP should not be defined"
  #endif
  
  int main() {}

Currently, trunk passes that with any of the headers uncommented. Rocm is ok 
for math and cmath, but defines CUDA for complex.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-30 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/Headers/__clang_hip_cmath.h:96
+__DEVICE__ __CONSTEXPR__ bool isnan(float __x) { return ::__isnanf(__x); }
+__DEVICE__ __CONSTEXPR__ bool isnan(double __x) { return ::__isnan(__x); }
 

pdhaliwal wrote:
> jdoerfert wrote:
> > ^ This is how OpenMP resolves the overload issue wrt. different return 
> > types.
> I tried the exact same way. The lit tests compile and run fine. I could not 
> get the runtime tests compile without the errors. It might be that I am not 
> using match patterns correctly. I also tried some other combinations of the 
> match selector but none of them worked.
Not sure what to say. If we want it to work in the wild, I doubt there is much 
we can do but to make this work. Not sure what your errors were or why they 
were caused, I'd recommend to determine that instead of punting and hoping 
nobody will run into this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D82317: [Clang/Test]: Update tests where `noundef` attribute is necessary

2021-06-30 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

I asked @hyeongyukim (who is a participant of google summer of code) to rebase 
this patch and make an updated version.
I thought it was a good goal for him to target, as the validity of the 
enable-noundef flag is already reviewed and the changes are syntactic updates 
to the existing tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82317

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


RE: [PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-30 Thread Lieberman, Ron via cfe-commits
[AMD Official Use Only]

It maybe that the patch does not expose __CUDA__ directly.
Rather the patch works so well we finally see the pre-existing issue in 
complex.h

./clang/lib/Headers/openmp_wrappers/complex.h

-Original Message-
From: Jon Chesterfield via Phabricator  
Sent: Wednesday, June 30, 2021 12:33 PM
To: Singh, Pushpinder ; 
jonathanchesterfi...@gmail.com; xw111lu...@gmail.com; Lieberman, Ron 
; greg63...@gmail.com; jdoerf...@anl.gov; Liu, Yaxun 
(Sam) ; Chan, SiuChi ; Sumner, Brian 
; jhub...@vols.utk.edu; tianshilei1...@gmail.com
Cc: Shi, Aaron En Ye ; estewar...@gmail.com; 
stefomeis...@gmail.com; cfe-commits@lists.llvm.org; 
jv...@scarletmail.rutgers.edu; zhang.guans...@gmail.com; Kumar N, Bhuvanendra 
; mlek...@skidmore.edu; blitzrak...@gmail.com; 
shen...@google.com; t...@google.com; kuh...@google.com
Subject: [PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

[CAUTION: External Email]

JonChesterfield added a comment.

@ronlieb reports that this change means __CUDA__ is defined for openmp amdgcn 
compilation. I'm going to try to verify that


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD104904%2Fnew%2Fdata=04%7C01%7Cron.lieberman%40amd.com%7C30a5efe76bea490b3ca008d93be4a84d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637606675525170968%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=G75Ey7JiNVDx74nF6x0VeCazDx6nngKoYzufecJdCok%3Dreserved=0

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD104904data=04%7C01%7Cron.lieberman%40amd.com%7C30a5efe76bea490b3ca008d93be4a84d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637606675525170968%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=LSZRpI6r4KqgKR5ZREXDlLH5kJPUJr20vgK79wC0dCU%3Dreserved=0
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103040: Print default template argument if manually specified in typedef declaration.

2021-06-30 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/test/SemaTemplate/class-template-id.cpp:12-14
+return ptr2; // expected-error{{cannot initialize return object of type 
'A *' (aka 'A *') with an lvalue of type 'const A 
*'}}
   else {
+return ptr3; // expected-error{{cannot initialize return object of type 
'A *' (aka 'A *') with an lvalue of type 'A *'}}

dblaikie wrote:
> FWIW, looks like this was a reduction in quality - printing the value of the 
> default argument in these error messages, when omitting it was probably 
> desirable?
> 
> & doesn't seem to be a necessary consequence of the patch description's goals.
Nevermind - I was looking at the parameter types, not the return type. I see 
the return type is written out more explicitly, so it makes sense that that 
fuller name be rendered in the message too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103040

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


[PATCH] D100553: [clangd] Log feature configuration (linux+asan+grpc) of the clangd build

2021-06-30 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(fyi: this broke mac builds. i fixed that in 
b56e5f8a10c1ec4fd3750bdd269fbad778820326 
)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100553

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


[clang-tools-extra] b56e5f8 - [clangd] Unbreak mac build after 0c96a92d8666b8

2021-06-30 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-06-30T12:53:38-04:00
New Revision: b56e5f8a10c1ec4fd3750bdd269fbad778820326

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

LOG: [clangd] Unbreak mac build after 0c96a92d8666b8

That commit removed the include of Features.inc from ClangdLSPServer.h,
but ClangdMain.cpp relied on this include to pull in Features.inc for
the #if at the bottom of Transport.h.

Since the include is needed in Transport.h, just add it to there
directly.

Added: 


Modified: 
clang-tools-extra/clangd/Transport.h

Removed: 




diff  --git a/clang-tools-extra/clangd/Transport.h 
b/clang-tools-extra/clangd/Transport.h
index ae6da722d91b..b3db4eba85f9 100644
--- a/clang-tools-extra/clangd/Transport.h
+++ b/clang-tools-extra/clangd/Transport.h
@@ -18,6 +18,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H_
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H_
 
+#include "Features.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/raw_ostream.h"



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


[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-30 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 355607.
lxfind added a comment.

fix warning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

Files:
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/test/Transforms/Coroutines/ArgAddr.ll
  llvm/test/Transforms/Coroutines/coro-alloc-with-param-O0.ll
  llvm/test/Transforms/Coroutines/coro-alloc-with-param-O2.ll
  llvm/test/Transforms/Coroutines/coro-alloca-01.ll
  llvm/test/Transforms/Coroutines/coro-alloca-02.ll
  llvm/test/Transforms/Coroutines/coro-alloca-03.ll
  llvm/test/Transforms/Coroutines/coro-alloca-04.ll
  llvm/test/Transforms/Coroutines/coro-alloca-05.ll
  llvm/test/Transforms/Coroutines/coro-alloca-06.ll
  llvm/test/Transforms/Coroutines/coro-alloca-07.ll
  llvm/test/Transforms/Coroutines/coro-alloca-08.ll
  llvm/test/Transforms/Coroutines/coro-async.ll
  llvm/test/Transforms/Coroutines/coro-byval-param.ll
  llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll
  llvm/test/Transforms/Coroutines/coro-catchswitch.ll
  llvm/test/Transforms/Coroutines/coro-debug.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-00.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-01.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-02.ll
  llvm/test/Transforms/Coroutines/coro-frame-arrayalloca.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-00.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-01.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-02.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-03.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-04.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-05.ll
  llvm/test/Transforms/Coroutines/coro-frame-unreachable.ll
  llvm/test/Transforms/Coroutines/coro-frame.ll
  llvm/test/Transforms/Coroutines/coro-materialize.ll
  llvm/test/Transforms/Coroutines/coro-padding.ll
  llvm/test/Transforms/Coroutines/coro-param-copy.ll
  llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
  llvm/test/Transforms/Coroutines/coro-retcon-frame.ll
  llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values2.ll
  llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
  llvm/test/Transforms/Coroutines/coro-retcon-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon.ll
  llvm/test/Transforms/Coroutines/coro-spill-after-phi.ll
  llvm/test/Transforms/Coroutines/coro-spill-corobegin.ll
  llvm/test/Transforms/Coroutines/coro-spill-defs-before-corobegin.ll
  llvm/test/Transforms/Coroutines/coro-spill-promise.ll
  llvm/test/Transforms/Coroutines/coro-split-00.ll
  llvm/test/Transforms/Coroutines/coro-split-02.ll
  llvm/test/Transforms/Coroutines/coro-split-alloc.ll
  llvm/test/Transforms/Coroutines/coro-split-dbg.ll
  llvm/test/Transforms/Coroutines/coro-split-eh-00.ll
  llvm/test/Transforms/Coroutines/coro-split-eh-01.ll
  llvm/test/Transforms/Coroutines/coro-split-hidden.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail1.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail2.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail3.ll
  llvm/test/Transforms/Coroutines/coro-split-recursive.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-01.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-02.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-03.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-04.ll
  llvm/test/Transforms/Coroutines/coro-swifterror.ll
  llvm/test/Transforms/Coroutines/coro-zero-alloca.ll
  llvm/test/Transforms/Coroutines/no-suspend.ll
  llvm/test/Transforms/Coroutines/restart-trigger.ll
  llvm/test/Transforms/Coroutines/smoketest.ll

Index: llvm/test/Transforms/Coroutines/smoketest.ll
===
--- llvm/test/Transforms/Coroutines/smoketest.ll
+++ llvm/test/Transforms/Coroutines/smoketest.ll
@@ -10,12 +10,16 @@
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
 ; RUN: -debug-pass-manager 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -debug-pass-manager \
-; RUN: -passes='function(coro-early),cgscc(coro-split),function(coro-elide,coro-cleanup)' 2>&1 \
+; RUN: -passes='function(coro-early),function(coro-elide),cgscc(coro-split),function(coro-cleanup)' 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 
+; note that we run CoroElidePass before CoroSplitPass. This is because CoroElidePass is part of
+; function simplification pipeline, which runs before CoroSplitPass. And since @foo is not
+; a 

[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-30 Thread Xun Li via Phabricator via cfe-commits
lxfind added inline comments.



Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:2112-2114
 StringRef Value = Attr.getValueAsString();
 LLVM_DEBUG(dbgs() << "CoroSplit: Processing coroutine '" << F.getName()
   << "' state: " << Value << "\n");

ChuanqiXu wrote:
> Refactor this into:
> ```
> LLVM_DEBUG(dbgs() << "CoroSplit: Processing coroutine '" << F.getName()
>   << "' state: " << Attr.getValueAsString() << "\n");
> ```
> could erase an warning in release build.
Good catch. How did you catch this? It seems like I don't see warning on my Mac 
by default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

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


[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-06-30 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp:130
 TT.isArch64Bit()
-? "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"
-: "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1",
+? (hasReferenceTypes(FS)
+   ? 
"e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20"

pmatos wrote:
> tlively wrote:
> > pmatos wrote:
> > > tlively wrote:
> > > > `hasReferenceTypes` should also be taking the CPU into account, not 
> > > > just the feature string. Normally this would be done via 
> > > > `getSubtargetImpl`, but I guess we probably can't call that this early 
> > > > in the construction of the `WebAssemblyTargetMachine`. Would anything 
> > > > break if we just unconditionally added the reference types address 
> > > > spaces to the data layout string?
> > > Regarding this change, I don't quite understand why referencetypes should 
> > > take the CPU into account. Are there CPU variants for the wasm backend? I 
> > > haven't touched the conditional because that would mean touching the 
> > > several tests that don't enable reference types and use the old data 
> > > layout string. However, I would think that if that's the path we want to 
> > > follow here, we could do it and change all wasm tests to use the layout 
> > > string with reference types.
> > > 
> > Yes, there are CPU variants defined here: 
> > https://github.com/llvm/llvm-project/blob/7ac0442fe59dbe0f9127e79e8786a7dd6345c537/llvm/lib/Target/WebAssembly/WebAssembly.td#L89-L100.
> >  Note that the CPU may enable reference types even if the feature string 
> > does not. If it doesn't break anything, then unconditionally updating the 
> > layout string sounds like the best option.
> Interesting - had not come accross it. Bleeding edge does not seem to include 
> reference-types. What's the reason for this? 
We don't have a well-defined process for adding features to bleeding-edge, but 
I think typically they're added once they're mostly stable and usable in the 
tools.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

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


  1   2   >