[clang] 9d0e5e7 - [RISCV] Reserve X18 by default for Android

2023-03-14 Thread via cfe-commits

Author: AdityaK
Date: 2023-03-14T23:35:05-07:00
New Revision: 9d0e5e79b0f355218b2a64f0d54507b96adb71eb

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

LOG: [RISCV] Reserve X18 by default for Android

Reserve X18 even when -fsanitize=shadow-call-stack is not enabled.

Based on: https://reviews.llvm.org/D143355

Reviewed by: asb, samitolvanen, phosek, MaskRay

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

Added: 


Modified: 
clang/test/Driver/sanitizer-ld.c
llvm/lib/TargetParser/RISCVTargetParser.cpp
llvm/test/CodeGen/RISCV/reserved-regs.ll

Removed: 




diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index 910b0ed4ff0de..0778a96ae2350 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -743,6 +743,10 @@
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-LINUX-RISCV64 %s
 // CHECK-SHADOWCALLSTACK-LINUX-RISCV64: '-fsanitize=shadow-call-stack' only 
allowed with '-ffixed-x18'
 
+// RUN: %clang -target riscv64-linux-android -fsanitize=shadow-call-stack %s 
-### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-SHADOWCALLSTACK-ANDROID-RISCV64
+// CHECK-SHADOWCALLSTACK-ANDROID-RISCV64-NOT: error:
+
 // RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
 // RUN: --target=riscv64-unknown-fuchsia -fuse-ld=ld \
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-FUCHSIA-RISCV64 %s

diff  --git a/llvm/lib/TargetParser/RISCVTargetParser.cpp 
b/llvm/lib/TargetParser/RISCVTargetParser.cpp
index 933a82b7c6cb2..3445e339ac606 100644
--- a/llvm/lib/TargetParser/RISCVTargetParser.cpp
+++ b/llvm/lib/TargetParser/RISCVTargetParser.cpp
@@ -103,7 +103,7 @@ bool getCPUFeaturesExceptStdExt(CPUKind Kind,
 
 bool isX18ReservedByDefault(const Triple &TT) {
   // X18 is reserved for the ShadowCallStack ABI (even when not enabled).
-  return TT.isOSFuchsia();
+  return TT.isOSFuchsia() || TT.isAndroid();
 }
 
 } // namespace RISCV

diff  --git a/llvm/test/CodeGen/RISCV/reserved-regs.ll 
b/llvm/test/CodeGen/RISCV/reserved-regs.ll
index da549c0ad3033..68c6a6558eccc 100644
--- a/llvm/test/CodeGen/RISCV/reserved-regs.ll
+++ b/llvm/test/CodeGen/RISCV/reserved-regs.ll
@@ -58,6 +58,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+reserve-x31 -verify-machineinstrs < %s | 
FileCheck %s -check-prefix=X31
 
 ; RUN: llc -mtriple=riscv64-fuchsia -verify-machineinstrs < %s | FileCheck %s 
-check-prefix=X18
+; RUN: llc -mtriple=riscv64-linux-android -verify-machineinstrs < %s | 
FileCheck %s -check-prefix=X18
 
 ; This program is free to use all registers, but needs a stack pointer for
 ; spill values, so do not test for reserving the stack pointer.



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


[PATCH] D145999: [RISCV] Reserve X18 by default for Android

2023-03-14 Thread 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 rG9d0e5e79b0f3: [RISCV] Reserve X18 by default for Android 
(authored by AdityaK <1894981+hiradi...@users.noreply.github.com>).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145999

Files:
  clang/test/Driver/sanitizer-ld.c
  llvm/lib/TargetParser/RISCVTargetParser.cpp
  llvm/test/CodeGen/RISCV/reserved-regs.ll


Index: llvm/test/CodeGen/RISCV/reserved-regs.ll
===
--- llvm/test/CodeGen/RISCV/reserved-regs.ll
+++ llvm/test/CodeGen/RISCV/reserved-regs.ll
@@ -58,6 +58,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+reserve-x31 -verify-machineinstrs < %s | 
FileCheck %s -check-prefix=X31
 
 ; RUN: llc -mtriple=riscv64-fuchsia -verify-machineinstrs < %s | FileCheck %s 
-check-prefix=X18
+; RUN: llc -mtriple=riscv64-linux-android -verify-machineinstrs < %s | 
FileCheck %s -check-prefix=X18
 
 ; This program is free to use all registers, but needs a stack pointer for
 ; spill values, so do not test for reserving the stack pointer.
Index: llvm/lib/TargetParser/RISCVTargetParser.cpp
===
--- llvm/lib/TargetParser/RISCVTargetParser.cpp
+++ llvm/lib/TargetParser/RISCVTargetParser.cpp
@@ -103,7 +103,7 @@
 
 bool isX18ReservedByDefault(const Triple &TT) {
   // X18 is reserved for the ShadowCallStack ABI (even when not enabled).
-  return TT.isOSFuchsia();
+  return TT.isOSFuchsia() || TT.isAndroid();
 }
 
 } // namespace RISCV
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -743,6 +743,10 @@
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-LINUX-RISCV64 %s
 // CHECK-SHADOWCALLSTACK-LINUX-RISCV64: '-fsanitize=shadow-call-stack' only 
allowed with '-ffixed-x18'
 
+// RUN: %clang -target riscv64-linux-android -fsanitize=shadow-call-stack %s 
-### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-SHADOWCALLSTACK-ANDROID-RISCV64
+// CHECK-SHADOWCALLSTACK-ANDROID-RISCV64-NOT: error:
+
 // RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
 // RUN: --target=riscv64-unknown-fuchsia -fuse-ld=ld \
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-FUCHSIA-RISCV64 %s


Index: llvm/test/CodeGen/RISCV/reserved-regs.ll
===
--- llvm/test/CodeGen/RISCV/reserved-regs.ll
+++ llvm/test/CodeGen/RISCV/reserved-regs.ll
@@ -58,6 +58,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+reserve-x31 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X31
 
 ; RUN: llc -mtriple=riscv64-fuchsia -verify-machineinstrs < %s | FileCheck %s -check-prefix=X18
+; RUN: llc -mtriple=riscv64-linux-android -verify-machineinstrs < %s | FileCheck %s -check-prefix=X18
 
 ; This program is free to use all registers, but needs a stack pointer for
 ; spill values, so do not test for reserving the stack pointer.
Index: llvm/lib/TargetParser/RISCVTargetParser.cpp
===
--- llvm/lib/TargetParser/RISCVTargetParser.cpp
+++ llvm/lib/TargetParser/RISCVTargetParser.cpp
@@ -103,7 +103,7 @@
 
 bool isX18ReservedByDefault(const Triple &TT) {
   // X18 is reserved for the ShadowCallStack ABI (even when not enabled).
-  return TT.isOSFuchsia();
+  return TT.isOSFuchsia() || TT.isAndroid();
 }
 
 } // namespace RISCV
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -743,6 +743,10 @@
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-LINUX-RISCV64 %s
 // CHECK-SHADOWCALLSTACK-LINUX-RISCV64: '-fsanitize=shadow-call-stack' only allowed with '-ffixed-x18'
 
+// RUN: %clang -target riscv64-linux-android -fsanitize=shadow-call-stack %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-SHADOWCALLSTACK-ANDROID-RISCV64
+// CHECK-SHADOWCALLSTACK-ANDROID-RISCV64-NOT: error:
+
 // RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
 // RUN: --target=riscv64-unknown-fuchsia -fuse-ld=ld \
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-FUCHSIA-RISCV64 %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145965: [C++20][Modules] Fix incorrect visibilities in implementation units.

2023-03-14 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

I filed another issue (https://github.com/llvm/llvm-project/issues/61427) to 
reflect [basic.lookup.general]p2.3. So there are multiple issues. Let's handle 
them in multiple patches too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145965

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


[PATCH] D143479: [Clang] Emit error when caller cannot meet target feature requirement from always-inlining callee

2023-03-14 Thread Qiu Chaofan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG608212a0ff2f: [Clang] Check feature requirement from inlined 
callee (authored by qiucf).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143479

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/Sema/ppc-attr-target-inline.c


Index: clang/test/Sema/ppc-attr-target-inline.c
===
--- /dev/null
+++ clang/test/Sema/ppc-attr-target-inline.c
@@ -0,0 +1,14 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64le -target-feature +htm -fsyntax-only 
-emit-llvm %s -verify
+
+__attribute__((always_inline))
+int test1(int *x) {
+  *x = __builtin_ttest();
+  return *x;
+}
+
+__attribute__((target("no-htm")))
+int test2(int *x) {
+  *x = test1(x); // expected-error {{always_inline function 'test1' requires 
target feature 'htm', but would be inlined into function 'test2' that is 
compiled without support for 'htm'}}
+  return 0;
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2612,6 +2612,16 @@
 }))
   CGM.getDiags().Report(Loc, diag::err_function_needs_feature)
   << FD->getDeclName() << TargetDecl->getDeclName() << MissingFeature;
+  } else if (!FD->isMultiVersion() && FD->hasAttr()) {
+llvm::StringMap CalleeFeatureMap;
+CGM.getContext().getFunctionFeatureMap(CalleeFeatureMap, TargetDecl);
+
+for (const auto &F : CalleeFeatureMap) {
+  if (F.getValue() && (!CallerFeatureMap.lookup(F.getKey()) ||
+   !CallerFeatureMap.find(F.getKey())->getValue()))
+CGM.getDiags().Report(Loc, diag::err_function_needs_feature)
+<< FD->getDeclName() << TargetDecl->getDeclName() << F.getKey();
+}
   }
 }
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -4802,7 +4802,8 @@
 // the proper cpu features (and it won't cause code generation issues due 
to
 // function based code generation).
 if (TargetDecl->hasAttr() &&
-TargetDecl->hasAttr())
+(TargetDecl->hasAttr() ||
+ (CurFuncDecl && CurFuncDecl->hasAttr(
   checkTargetFeatures(Loc, FD);
 
 // Some architectures (such as x86-64) have the ABI changed based on


Index: clang/test/Sema/ppc-attr-target-inline.c
===
--- /dev/null
+++ clang/test/Sema/ppc-attr-target-inline.c
@@ -0,0 +1,14 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64le -target-feature +htm -fsyntax-only -emit-llvm %s -verify
+
+__attribute__((always_inline))
+int test1(int *x) {
+  *x = __builtin_ttest();
+  return *x;
+}
+
+__attribute__((target("no-htm")))
+int test2(int *x) {
+  *x = test1(x); // expected-error {{always_inline function 'test1' requires target feature 'htm', but would be inlined into function 'test2' that is compiled without support for 'htm'}}
+  return 0;
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2612,6 +2612,16 @@
 }))
   CGM.getDiags().Report(Loc, diag::err_function_needs_feature)
   << FD->getDeclName() << TargetDecl->getDeclName() << MissingFeature;
+  } else if (!FD->isMultiVersion() && FD->hasAttr()) {
+llvm::StringMap CalleeFeatureMap;
+CGM.getContext().getFunctionFeatureMap(CalleeFeatureMap, TargetDecl);
+
+for (const auto &F : CalleeFeatureMap) {
+  if (F.getValue() && (!CallerFeatureMap.lookup(F.getKey()) ||
+   !CallerFeatureMap.find(F.getKey())->getValue()))
+CGM.getDiags().Report(Loc, diag::err_function_needs_feature)
+<< FD->getDeclName() << TargetDecl->getDeclName() << F.getKey();
+}
   }
 }
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -4802,7 +4802,8 @@
 // the proper cpu features (and it won't cause code generation issues due to
 // function based code generation).
 if (TargetDecl->hasAttr() &&
-TargetDecl->hasAttr())
+(TargetDecl->hasAttr() ||
+ (CurFuncDecl && CurFuncDecl->hasAttr(
   checkTargetFeatures(Loc, FD);
 
 // Some architectures (such as x86-64) have the ABI changed based on
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 608212a - [Clang] Check feature requirement from inlined callee

2023-03-14 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2023-03-15T14:21:52+08:00
New Revision: 608212a0ff2f9e9a2cee8b5b0fa206fd15eb6472

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

LOG: [Clang] Check feature requirement from inlined callee

Currently clang emits error when both always_inline and target
attributes are on callee, but caller doesn't have some feature.

This patch makes clang emit error when caller cannot meet target feature
requirements from an always-inlined callee.

Reviewed By: erichkeane

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

Added: 
clang/test/Sema/ppc-attr-target-inline.c

Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenFunction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index dd8bd2bb82a5..aaa5d4e70d7d 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4802,7 +4802,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
 // the proper cpu features (and it won't cause code generation issues due 
to
 // function based code generation).
 if (TargetDecl->hasAttr() &&
-TargetDecl->hasAttr())
+(TargetDecl->hasAttr() ||
+ (CurFuncDecl && CurFuncDecl->hasAttr(
   checkTargetFeatures(Loc, FD);
 
 // Some architectures (such as x86-64) have the ABI changed based on

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index af60b3166d75..a5cbf7223ad6 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2612,6 +2612,16 @@ void CodeGenFunction::checkTargetFeatures(SourceLocation 
Loc,
 }))
   CGM.getDiags().Report(Loc, diag::err_function_needs_feature)
   << FD->getDeclName() << TargetDecl->getDeclName() << MissingFeature;
+  } else if (!FD->isMultiVersion() && FD->hasAttr()) {
+llvm::StringMap CalleeFeatureMap;
+CGM.getContext().getFunctionFeatureMap(CalleeFeatureMap, TargetDecl);
+
+for (const auto &F : CalleeFeatureMap) {
+  if (F.getValue() && (!CallerFeatureMap.lookup(F.getKey()) ||
+   !CallerFeatureMap.find(F.getKey())->getValue()))
+CGM.getDiags().Report(Loc, diag::err_function_needs_feature)
+<< FD->getDeclName() << TargetDecl->getDeclName() << F.getKey();
+}
   }
 }
 

diff  --git a/clang/test/Sema/ppc-attr-target-inline.c 
b/clang/test/Sema/ppc-attr-target-inline.c
new file mode 100644
index ..07ed00682265
--- /dev/null
+++ b/clang/test/Sema/ppc-attr-target-inline.c
@@ -0,0 +1,14 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64le -target-feature +htm -fsyntax-only 
-emit-llvm %s -verify
+
+__attribute__((always_inline))
+int test1(int *x) {
+  *x = __builtin_ttest();
+  return *x;
+}
+
+__attribute__((target("no-htm")))
+int test2(int *x) {
+  *x = test1(x); // expected-error {{always_inline function 'test1' requires 
target feature 'htm', but would be inlined into function 'test2' that is 
compiled without support for 'htm'}}
+  return 0;
+}



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


[PATCH] D145999: [RISCV] Reserve X18 by default for Android

2023-03-14 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya updated this revision to Diff 505378.
hiraditya added a comment.

Folded D145979  here


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

https://reviews.llvm.org/D145999

Files:
  clang/test/Driver/sanitizer-ld.c
  llvm/lib/TargetParser/RISCVTargetParser.cpp
  llvm/test/CodeGen/RISCV/reserved-regs.ll


Index: llvm/test/CodeGen/RISCV/reserved-regs.ll
===
--- llvm/test/CodeGen/RISCV/reserved-regs.ll
+++ llvm/test/CodeGen/RISCV/reserved-regs.ll
@@ -58,6 +58,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+reserve-x31 -verify-machineinstrs < %s | 
FileCheck %s -check-prefix=X31
 
 ; RUN: llc -mtriple=riscv64-fuchsia -verify-machineinstrs < %s | FileCheck %s 
-check-prefix=X18
+; RUN: llc -mtriple=riscv64-linux-android -verify-machineinstrs < %s | 
FileCheck %s -check-prefix=X18
 
 ; This program is free to use all registers, but needs a stack pointer for
 ; spill values, so do not test for reserving the stack pointer.
Index: llvm/lib/TargetParser/RISCVTargetParser.cpp
===
--- llvm/lib/TargetParser/RISCVTargetParser.cpp
+++ llvm/lib/TargetParser/RISCVTargetParser.cpp
@@ -103,7 +103,7 @@
 
 bool isX18ReservedByDefault(const Triple &TT) {
   // X18 is reserved for the ShadowCallStack ABI (even when not enabled).
-  return TT.isOSFuchsia();
+  return TT.isOSFuchsia() || TT.isAndroid();
 }
 
 } // namespace RISCV
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -743,6 +743,10 @@
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-LINUX-RISCV64 %s
 // CHECK-SHADOWCALLSTACK-LINUX-RISCV64: '-fsanitize=shadow-call-stack' only 
allowed with '-ffixed-x18'
 
+// RUN: %clang -target riscv64-linux-android -fsanitize=shadow-call-stack %s 
-### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-SHADOWCALLSTACK-ANDROID-RISCV64
+// CHECK-SHADOWCALLSTACK-ANDROID-RISCV64-NOT: error:
+
 // RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
 // RUN: --target=riscv64-unknown-fuchsia -fuse-ld=ld \
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-FUCHSIA-RISCV64 %s


Index: llvm/test/CodeGen/RISCV/reserved-regs.ll
===
--- llvm/test/CodeGen/RISCV/reserved-regs.ll
+++ llvm/test/CodeGen/RISCV/reserved-regs.ll
@@ -58,6 +58,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+reserve-x31 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X31
 
 ; RUN: llc -mtriple=riscv64-fuchsia -verify-machineinstrs < %s | FileCheck %s -check-prefix=X18
+; RUN: llc -mtriple=riscv64-linux-android -verify-machineinstrs < %s | FileCheck %s -check-prefix=X18
 
 ; This program is free to use all registers, but needs a stack pointer for
 ; spill values, so do not test for reserving the stack pointer.
Index: llvm/lib/TargetParser/RISCVTargetParser.cpp
===
--- llvm/lib/TargetParser/RISCVTargetParser.cpp
+++ llvm/lib/TargetParser/RISCVTargetParser.cpp
@@ -103,7 +103,7 @@
 
 bool isX18ReservedByDefault(const Triple &TT) {
   // X18 is reserved for the ShadowCallStack ABI (even when not enabled).
-  return TT.isOSFuchsia();
+  return TT.isOSFuchsia() || TT.isAndroid();
 }
 
 } // namespace RISCV
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -743,6 +743,10 @@
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-LINUX-RISCV64 %s
 // CHECK-SHADOWCALLSTACK-LINUX-RISCV64: '-fsanitize=shadow-call-stack' only allowed with '-ffixed-x18'
 
+// RUN: %clang -target riscv64-linux-android -fsanitize=shadow-call-stack %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-SHADOWCALLSTACK-ANDROID-RISCV64
+// CHECK-SHADOWCALLSTACK-ANDROID-RISCV64-NOT: error:
+
 // RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
 // RUN: --target=riscv64-unknown-fuchsia -fuse-ld=ld \
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-FUCHSIA-RISCV64 %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145999: [RISCV] Reserve X18 by default for Android

2023-03-14 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added inline comments.



Comment at: clang/test/Driver/riscv-fixed-x-register.c:343
+
+// Check that x18 is reserved on Android by default
+// RUN: %clang --target=riscv64-linux-android -### %s 2> %t

MaskRay wrote:
> MaskRay wrote:
> > asb wrote:
> > > samitolvanen wrote:
> > > > This seems redundant. Isn't the LLVM codegen test sufficient here?
> > > I think testing that the `+reserve-x18` target feature is added by the 
> > > frontend probably has some value.
> > > 
> > > I think it would better match the rest of this file to just do 
> > > `--check-prefix=CHECK-FIXED-X18` (I _think_ that works, but it is the end 
> > > of the day so I may be missing something obvious...).
> > > 
> > > Please do try to remember to generate patches with full context 
> > > (`-U99` or similar).
> > I prefer shared CHECK prefixes `--check-prefix=CHECK-FIXED-X18` as well. We 
> > do that for many other tests.
> `/// Check that x18 is reserved on Android by default.`
@samitolvanen correct, this test isn't possible because llvm implicitly 
reserves the register so clang -cc1 never gets the `"-target-feature" 
"+reserve-x18"` parameter.  I'll remove this test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145999

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


[PATCH] D145767: [Verifier][NFC] Refactor check for associated metadata to allow multiple operands on AIX

2023-03-14 Thread Ting Wang via Phabricator via cfe-commits
tingwang added inline comments.



Comment at: clang/test/CodeGen/PowerPC/aix-init-ref-null.cpp:2
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -emit-llvm -O3 -x c++ < %s 
| FileCheck %s
+// XFAIL: *
+// This function should fail until .ref is support on AIX.

arsenm wrote:
> A test run with not and a specific error message check is more reliable 
Thank you Matt! Currently there is no error message for this case, so I moved 
the XFAIL to CHECK lines. Hope that is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145767

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


[PATCH] D145767: [Verifier][NFC] Refactor check for associated metadata to allow multiple operands on AIX

2023-03-14 Thread Ting Wang via Phabricator via cfe-commits
tingwang updated this revision to Diff 505372.
tingwang added a comment.

Address comments:
(1) Duplicated associated test cases to make copies for AIX XCOFF, and added 
`multiple operands` and `null operand` as legal cases.
(2) Updated verifier logic to check for AIX target.
(3) Moved XFAIL check to specific lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145767

Files:
  clang/test/CodeGen/PowerPC/aix-init-ref-null.cpp
  clang/test/CodeGen/PowerPC/aix-ref-static-var.cpp
  clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  llvm/docs/LangRef.rst
  llvm/lib/IR/Verifier.cpp
  llvm/test/Assembler/associated-metadata-aix-xcoff.ll
  llvm/test/Linker/Inputs/associated-global-aix-xcoff.ll
  llvm/test/Linker/associated-global-aix-xcoff.ll
  llvm/test/Verifier/associated-metadata-aix-xcoff.ll

Index: llvm/test/Verifier/associated-metadata-aix-xcoff.ll
===
--- /dev/null
+++ llvm/test/Verifier/associated-metadata-aix-xcoff.ll
@@ -0,0 +1,31 @@
+; RUN: not llvm-as -disable-output < %s -o /dev/null 2>&1 | FileCheck %s
+
+target triple = "unknown-unknown-aix-xcoff"
+
+; CHECK: associated value must be pointer typed
+; CHECK-NEXT: ptr addrspace(1) @associated.int
+; CHECK-NEXT: !0 = !{i32 1}
+@associated.int = external addrspace(1) constant [8 x i8], !associated !0
+
+; CHECK: associated value must be pointer typed
+; CHECK-NEXT: ptr addrspace(1) @associated.float
+; CHECK-NEXT: !1 = !{float 1.00e+00}
+@associated.float = external addrspace(1) constant [8 x i8], !associated !1
+
+; CHECK: global values should not associate to themselves
+; CHECK-NEXT: ptr @associated.self
+; CHECK-NEXT: !2 = !{ptr @associated.self}
+@associated.self = external constant [8 x i8], !associated !2
+
+; CHECK: associated metadata must be ValueAsMetadata
+; CHECK-NEXT: ptr @associated.string
+; CHECK-NEXT: !3 = !{!"string"}
+@associated.string = external constant [8 x i8], !associated !3
+
+@gv.decl0 = external constant [8 x i8]
+@gv.decl1 = external constant [8 x i8]
+
+!0 = !{i32 1}
+!1 = !{float 1.00e+00}
+!2 = !{ptr @associated.self}
+!3 = !{!"string"}
Index: llvm/test/Linker/associated-global-aix-xcoff.ll
===
--- /dev/null
+++ llvm/test/Linker/associated-global-aix-xcoff.ll
@@ -0,0 +1,33 @@
+; RUN: llvm-link -S %s %S/Inputs/associated-global-aix-xcoff.ll | FileCheck %s
+
+target triple = "unknown-unknown-aix-xcoff"
+
+; CHECK: @c = internal global i32 1, !associated !0
+; CHECK: @d = global i32 0, !associated !1
+; CHECK: @f = global i32 0, !associated !2
+; CHECK: @a = global i32 0, !associated !3
+; CHECK: @b = global i32 0, !associated !4
+; CHECK: @c.3 = internal global i32 1, !associated !5
+; CHECK: @e = global i32 0, !associated !6
+; CHECK: @g = global i32 0, !associated !7
+
+; CHECK: !0 = !{ptr @d}
+; CHECK: !1 = !{ptr @c}
+; CHECK: !2 = !{ptr @a, ptr @b}
+; CHECK: !3 = !{ptr @b}
+; CHECK: !4 = !{ptr @a}
+; CHECK: !5 = !{ptr @e}
+; CHECK: !6 = !{ptr @c.3}
+; CHECK: !7 = distinct !{null}
+
+@a = external global i32, !associated !0
+@b = global i32 0, !associated !1
+@c = internal global i32 1, !associated !2
+@d = global i32 0, !associated !3
+@f = global i32 0, !associated !4
+
+!0 = !{ptr @b}
+!1 = !{ptr @a}
+!2 = !{ptr @d}
+!3 = !{ptr @c}
+!4 = !{ptr @a, ptr @b}
Index: llvm/test/Linker/Inputs/associated-global-aix-xcoff.ll
===
--- /dev/null
+++ llvm/test/Linker/Inputs/associated-global-aix-xcoff.ll
@@ -0,0 +1,13 @@
+target triple = "unknown-unknown-aix-xcoff"
+
+@a = global i32 0, !associated !0
+@b = external global i32, !associated !1
+@c = internal global i32 1, !associated !2
+@e = global i32 0, !associated !3
+@g = global i32 0, !associated !4
+
+!0 = !{ptr @b}
+!1 = !{ptr @a}
+!2 = !{ptr @e}
+!3 = !{ptr @c}
+!4 = distinct !{null}
Index: llvm/test/Assembler/associated-metadata-aix-xcoff.ll
===
--- /dev/null
+++ llvm/test/Assembler/associated-metadata-aix-xcoff.ll
@@ -0,0 +1,103 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+target triple = "unknown-unknown-aix-xcoff"
+
+@gv.decl = external constant [8 x i8]
+@gv.def = constant [8 x i8] zeroinitializer
+
+@gv.associated.func.decl = external addrspace(1) constant [8 x i8], !associated !0
+@gv.associated.func.def = external addrspace(1) constant [8 x i8], !associated !1
+
+@gv.associated.gv.decl = external addrspace(1) constant [8 x i8], !associated !2
+@gv.associated.gv.def = external addrspace(1) constant [8 x i8], !associated !3
+
+@alias = alias i32, ptr @gv.def
+
+@gv.associated.alias.gv.def = external addrspace(1) constant [8 x i8], !associated !4
+
+@gv.associated.alias.addrspacecast = external add

[PATCH] D145883: [Flang][RISCV] Emit target features for RISC-V

2023-03-14 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce updated this revision to Diff 505363.
sunshaoce added a comment.

Address @MaskRay's comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145883

Files:
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/test/Driver/code-gen-rv64.f90
  flang/test/Driver/target-cpu-features-invalid.f90
  flang/test/Driver/target-cpu-features.f90


Index: flang/test/Driver/target-cpu-features.f90
===
--- flang/test/Driver/target-cpu-features.f90
+++ flang/test/Driver/target-cpu-features.f90
@@ -1,5 +1,3 @@
-! REQUIRES: aarch64-registered-target, x86-registered-target
-
 ! Test that -mcpu/march are used and that the -target-cpu and -target-features
 ! are also added to the fc1 command.
 
@@ -22,14 +20,8 @@
 ! RUN: %flang --target=x86_64h-linux-gnu -c %s -### 2>&1 \
 ! RUN: | FileCheck %s -check-prefix=CHECK-X86_64H
 
-
-! Test that invalid cpu and features are ignored.
-
-! RUN: %flang_fc1 -triple aarch64-linux-gnu -target-cpu supercpu \
-! RUN: -o /dev/null -S %s 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID-CPU
-
-! RUN: %flang_fc1 -triple aarch64-linux-gnu -target-feature +superspeed \
-! RUN: -o /dev/null -S %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-INVALID-FEATURE
+! RUN: %flang --target=riscv64-linux-gnu -c %s -### 2>&1 \
+! RUN: | FileCheck %s -check-prefix=CHECK-RV64
 
 
 ! CHECK-A57: "-fc1" "-triple" "aarch64-unknown-linux-gnu"
@@ -52,5 +44,5 @@
 ! CHECK-X86_64H: "-fc1" "-triple" "x86_64h-unknown-linux-gnu"
 ! CHECK-X86_64H-SAME: "-target-cpu" "x86-64" "-target-feature" "-rdrnd" 
"-target-feature" "-aes" "-target-feature" "-pclmul" "-target-feature" "-rtm" 
"-target-feature" "-fsgsbase"
 
-! CHECK-INVALID-CPU: 'supercpu' is not a recognized processor for this target 
(ignoring processor)
-! CHECK-INVALID-FEATURE: '+superspeed' is not a recognized feature for this 
target (ignoring feature)
+! CHECK-RV64: "-fc1" "-triple" "riscv64-unknown-linux-gnu"
+! CHECK-RV64-SAME: "-target-cpu" "generic-rv64" "-target-feature" "+m" 
"-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" 
"-target-feature" "+c"
Index: flang/test/Driver/target-cpu-features-invalid.f90
===
--- /dev/null
+++ flang/test/Driver/target-cpu-features-invalid.f90
@@ -0,0 +1,13 @@
+! REQUIRES: aarch64-registered-target
+
+! Test that invalid cpu and features are ignored.
+
+! RUN: %flang_fc1 -triple aarch64-linux-gnu -target-cpu supercpu \
+! RUN:   -o /dev/null -S %s 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID-CPU
+
+! RUN: %flang_fc1 -triple aarch64-linux-gnu -target-feature +superspeed \
+! RUN:   -o /dev/null -S %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-INVALID-FEATURE
+
+
+! CHECK-INVALID-CPU: 'supercpu' is not a recognized processor for this target 
(ignoring processor)
+! CHECK-INVALID-FEATURE: '+superspeed' is not a recognized feature for this 
target (ignoring feature)
Index: flang/test/Driver/code-gen-rv64.f90
===
--- /dev/null
+++ flang/test/Driver/code-gen-rv64.f90
@@ -0,0 +1,17 @@
+! Test -emit-obj (RISC-V 64)
+
+! REQUIRES: riscv-registered-target
+
+! RUN: rm -f %t.o
+! RUN: %flang_fc1 -triple riscv64-unknown-linux-gnu \
+! RUN:   -target-feature +d -target-feature +c -emit-obj %s -o %t.o
+! RUN: llvm-readelf -h %t.o | FileCheck %s
+
+! RUN: rm -f %t.o
+! RUN: %flang --target=riscv64-unknown-linux-gnu -c %s -o %t.o
+! RUN: llvm-readelf -h %t.o | FileCheck %s
+
+! If Flang failed to emit target-feature info, then Flags will be 0x0.
+! 0x5 means set EF_RISCV_RVC (0x1) and EF_RISCV_FLOAT_ABI_DOUBLE (0x4)
+! CHECK: Flags: 0x5, RVC, double-float ABI
+end program
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -105,7 +105,7 @@
   default:
 break;
   case llvm::Triple::aarch64:
-[[fallthrough]];
+  case llvm::Triple::riscv64:
   case llvm::Triple::x86_64:
 getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);
 break;


Index: flang/test/Driver/target-cpu-features.f90
===
--- flang/test/Driver/target-cpu-features.f90
+++ flang/test/Driver/target-cpu-features.f90
@@ -1,5 +1,3 @@
-! REQUIRES: aarch64-registered-target, x86-registered-target
-
 ! Test that -mcpu/march are used and that the -target-cpu and -target-features
 ! are also added to the fc1 command.
 
@@ -22,14 +20,8 @@
 ! RUN: %flang --target=x86_64h-linux-gnu -c %s -### 2>&1 \
 ! RUN: | FileCheck %s -check-prefix=CHECK-X86_64H
 
-
-! Test that invalid cpu and features are ignored.
-
-! RUN: %flang_fc1 -triple aarch64-linux-gnu -target-cpu supercpu \
-! RUN: -o /dev/null -S %s 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID-CPU
-
-! RUN: %flang_fc1 -t

[PATCH] D145151: clang: Handle MatrixType in hasFloatingRepresentation

2023-03-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

ffe12e765cb9ba77dc30ccec89fb163234b98541 



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

https://reviews.llvm.org/D145151

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


[PATCH] D145150: clang: Emit nofpclass(nan inf) for -ffinite-math-only

2023-03-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

dd8181055494d8f973dfaaba282bb1ae6eab4d40 





Comment at: clang/lib/CodeGen/CGCall.cpp:3052
+AI->addAttrs(
+llvm::AttrBuilder(getLLVMContext()).addNoFPClassAttr(Mask));
+  }

efriedma wrote:
> What cases does this cover that aren't already covered by the code in 
> CodeGenModule::ConstructAttributeList?
Nothing apparently


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

https://reviews.llvm.org/D145150

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


[clang] dd81810 - clang: Emit nofpclass(nan inf) for -ffinite-math-only

2023-03-14 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-03-15T01:13:08-04:00
New Revision: dd8181055494d8f973dfaaba282bb1ae6eab4d40

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

LOG: clang: Emit nofpclass(nan inf) for -ffinite-math-only

Set this on any source level floating-point type argument,
return value, call return or outgoing parameter which is lowered
to a valid IR type for the attribute. Currently this isn't
applied to emitted intrinsics since those don't go through
ABI code.

Added: 
llvm/test/Linker/Inputs/nofpclass.ll
llvm/test/Linker/nofpclass.ll

Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/complex-math.c
clang/test/CodeGen/fp-function-attrs.cpp
clang/test/CodeGen/fp-options-to-fast-math-flags.c
clang/test/CodeGen/func-attr.c
clang/test/CodeGen/matrix-type-operators-fast-math.c
clang/test/CodeGen/nofpclass.c
llvm/include/llvm/IR/Attributes.h
llvm/lib/IR/Attributes.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 319a9b448d513..dd8bd2bb82a51 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2106,6 +2106,39 @@ static bool IsArgumentMaybeUndef(const Decl *TargetDecl,
   return false;
 }
 
+/// Test if it's legal to apply nofpclass for the given parameter type and it's
+/// lowered IR type.
+static bool canApplyNoFPClass(const ABIArgInfo &AI, QualType ParamType,
+  bool IsReturn) {
+  // Should only apply to FP types in the source, not ABI promoted.
+  if (!ParamType->hasFloatingRepresentation())
+return false;
+
+  // The promoted-to IR type also needs to support nofpclass.
+  llvm::Type *IRTy = AI.getCoerceToType();
+  if (llvm::AttributeFuncs::isNoFPClassCompatibleType(IRTy))
+return true;
+
+  if (llvm::StructType *ST = dyn_cast(IRTy)) {
+return !IsReturn && AI.getCanBeFlattened() &&
+   llvm::all_of(ST->elements(), [](llvm::Type *Ty) {
+ return llvm::AttributeFuncs::isNoFPClassCompatibleType(Ty);
+   });
+  }
+
+  return false;
+}
+
+/// Return the nofpclass mask that can be applied to floating-point parameters.
+static llvm::FPClassTest getNoFPClassTestMask(const LangOptions &LangOpts) {
+  llvm::FPClassTest Mask = llvm::fcNone;
+  if (LangOpts.NoHonorInfs)
+Mask |= llvm::fcInf;
+  if (LangOpts.NoHonorNaNs)
+Mask |= llvm::fcNan;
+  return Mask;
+}
+
 /// Construct the IR attribute list of a function or call.
 ///
 /// When adding an attribute, please consider where it should be handled:
@@ -2373,6 +2406,10 @@ void CodeGenModule::ConstructAttributeList(StringRef 
Name,
   case ABIArgInfo::Direct:
 if (RetAI.getInReg())
   RetAttrs.addAttribute(llvm::Attribute::InReg);
+
+if (canApplyNoFPClass(RetAI, RetTy, true))
+  RetAttrs.addNoFPClassAttr(getNoFPClassTestMask(getLangOpts()));
+
 break;
   case ABIArgInfo::Ignore:
 break;
@@ -2511,8 +2548,10 @@ void CodeGenModule::ConstructAttributeList(StringRef 
Name,
   else if (AI.getInReg())
 Attrs.addAttribute(llvm::Attribute::InReg);
   Attrs.addStackAlignmentAttr(llvm::MaybeAlign(AI.getDirectAlign()));
-  break;
 
+  if (canApplyNoFPClass(AI, ParamType, false))
+Attrs.addNoFPClassAttr(getNoFPClassTestMask(getLangOpts()));
+  break;
 case ABIArgInfo::Indirect: {
   if (AI.getInReg())
 Attrs.addAttribute(llvm::Attribute::InReg);

diff  --git a/clang/test/CodeGen/complex-math.c 
b/clang/test/CodeGen/complex-math.c
index 8f26658cac14d..d5af6db809534 100644
--- a/clang/test/CodeGen/complex-math.c
+++ b/clang/test/CodeGen/complex-math.c
@@ -136,7 +136,7 @@ float _Complex div_float_rc(float a, float _Complex b) {
   // SPIR: call spir_func {{.*}} @__divsc3(
 
   // a / b = (A+iB) / (C+iD) = ((AC+BD)/(CC+DD)) + i((BC-AD)/(CC+DD))
-  // AARCH64-FASTMATH-LABEL: @div_float_rc(float noundef %a, [2 x float] 
noundef %b.coerce)
+  // AARCH64-FASTMATH-LABEL: @div_float_rc(float noundef nofpclass(nan inf) 
%a, [2 x float] noundef nofpclass(nan inf) %b.coerce)
   // A = a
   // B = 0
   //
@@ -165,7 +165,7 @@ float _Complex div_float_cc(float _Complex a, float 
_Complex b) {
   // SPIR: call spir_func {{.*}} @__divsc3(
 
   // a / b = (A+iB) / (C+iD) = ((AC+BD)/(CC+DD)) + i((BC-AD)/(CC+DD))
-  // AARCH64-FASTMATH-LABEL: @div_float_cc([2 x float] noundef %a.coerce, [2 x 
float] noundef %b.coerce)
+  // AARCH64-FASTMATH-LABEL: @div_float_cc([2 x float] noundef nofpclass(nan 
inf) %a.coerce, [2 x float] noundef nofpclass(nan inf) %b.coerce)
   //
   // AARCH64-FASTMATH: [[AC:%.*]] = fmul fast float
   // AARCH64-FASTMATH: [[BD:%.*]] = fmul fast float
@@ -313,7 +313,7 @@ double _Complex div_double_rc(double a, double _Complex b) {
   // SPIR: call spir_func {{.*}} @__divdc3(
 
   

[clang] ffe12e7 - clang: Handle MatrixType in hasFloatingRepresentation

2023-03-14 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-03-15T01:13:08-04:00
New Revision: ffe12e765cb9ba77dc30ccec89fb163234b98541

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

LOG: clang: Handle MatrixType in hasFloatingRepresentation

Allows applying nofpclass to matrix arguments.

Added: 


Modified: 
clang/lib/AST/Type.cpp
clang/test/CodeGen/matrix-type-operators-fast-math.c
clang/test/CodeGen/nofpclass.c

Removed: 




diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 96e611968ca18..71a098c254244 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2154,8 +2154,9 @@ bool Type::isFloatingType() const {
 bool Type::hasFloatingRepresentation() const {
   if (const auto *VT = dyn_cast(CanonicalType))
 return VT->getElementType()->isFloatingType();
-  else
-return isFloatingType();
+  if (const auto *MT = dyn_cast(CanonicalType))
+return MT->getElementType()->isFloatingType();
+  return isFloatingType();
 }
 
 bool Type::isRealFloatingType() const {

diff  --git a/clang/test/CodeGen/matrix-type-operators-fast-math.c 
b/clang/test/CodeGen/matrix-type-operators-fast-math.c
index f71faa63f4e70..724b282830286 100644
--- a/clang/test/CodeGen/matrix-type-operators-fast-math.c
+++ b/clang/test/CodeGen/matrix-type-operators-fast-math.c
@@ -8,7 +8,7 @@ typedef unsigned long long ullx4x2_t 
__attribute__((matrix_type(4, 2)));
 // Floating point matrix/scalar additions.
 
 void add_matrix_matrix_double(dx5x5_t a, dx5x5_t b, dx5x5_t c) {
-  // CHECK-LABEL: define{{.*}} void @add_matrix_matrix_double(<25 x double> 
noundef %a, <25 x double> noundef %b, <25 x double> noundef %c)
+  // CHECK-LABEL: define{{.*}} void @add_matrix_matrix_double(<25 x double> 
noundef nofpclass(nan inf) %a, <25 x double> noundef nofpclass(nan inf) %b, <25 
x double> noundef nofpclass(nan inf) %c)
   // CHECK:   [[B:%.*]] = load <25 x double>, ptr {{.*}}, align 8
   // CHECK-NEXT:  [[C:%.*]] = load <25 x double>, ptr {{.*}}, align 8
   // CHECK-NEXT:  [[RES:%.*]] = fadd reassoc nnan ninf nsz arcp afn <25 x 
double> [[B]], [[C]]
@@ -18,7 +18,7 @@ void add_matrix_matrix_double(dx5x5_t a, dx5x5_t b, dx5x5_t 
c) {
 }
 
 void add_compound_assign_matrix_double(dx5x5_t a, dx5x5_t b) {
-  // CHECK-LABEL: define{{.*}} void @add_compound_assign_matrix_double(<25 x 
double> noundef %a, <25 x double> noundef %b)
+  // CHECK-LABEL: define{{.*}} void @add_compound_assign_matrix_double(<25 x 
double> noundef nofpclass(nan inf) %a, <25 x double> noundef nofpclass(nan inf) 
%b)
   // CHECK:   [[B:%.*]] = load <25 x double>, ptr {{.*}}, align 8
   // CHECK-NEXT:  [[A:%.*]] = load <25 x double>, ptr {{.*}}, align 8
   // CHECK-NEXT:  [[RES:%.*]] = fadd reassoc nnan ninf nsz arcp afn <25 x 
double> [[A]], [[B]]
@@ -28,7 +28,7 @@ void add_compound_assign_matrix_double(dx5x5_t a, dx5x5_t b) {
 }
 
 void subtract_compound_assign_matrix_double(dx5x5_t a, dx5x5_t b) {
-  // CHECK-LABEL: define{{.*}} void 
@subtract_compound_assign_matrix_double(<25 x double> noundef %a, <25 x double> 
noundef %b)
+  // CHECK-LABEL: define{{.*}} void 
@subtract_compound_assign_matrix_double(<25 x double> noundef nofpclass(nan 
inf) %a, <25 x double> noundef nofpclass(nan inf) %b)
   // CHECK:   [[B:%.*]] = load <25 x double>, ptr {{.*}}, align 8
   // CHECK-NEXT:  [[A:%.*]] = load <25 x double>, ptr {{.*}}, align 8
   // CHECK-NEXT:  [[RES:%.*]] = fsub reassoc nnan ninf nsz arcp afn <25 x 
double> [[A]], [[B]]
@@ -38,7 +38,7 @@ void subtract_compound_assign_matrix_double(dx5x5_t a, 
dx5x5_t b) {
 }
 
 void add_matrix_scalar_double_float(dx5x5_t a, float vf) {
-  // CHECK-LABEL: define{{.*}} void @add_matrix_scalar_double_float(<25 x 
double> noundef %a, float noundef nofpclass(nan inf) %vf)
+  // CHECK-LABEL: define{{.*}} void @add_matrix_scalar_double_float(<25 x 
double> noundef nofpclass(nan inf) %a, float noundef nofpclass(nan inf) %vf)
   // CHECK:   [[MATRIX:%.*]] = load <25 x double>, ptr {{.*}}, align 8
   // CHECK-NEXT:  [[SCALAR:%.*]] = load float, ptr %vf.addr, align 4
   // CHECK-NEXT:  [[SCALAR_EXT:%.*]] = fpext float [[SCALAR]] to double
@@ -51,7 +51,7 @@ void add_matrix_scalar_double_float(dx5x5_t a, float vf) {
 }
 
 void add_compound_matrix_scalar_double_float(dx5x5_t a, float vf) {
-  // CHECK-LABEL: define{{.*}} void 
@add_compound_matrix_scalar_double_float(<25 x double> noundef %a, float 
noundef nofpclass(nan inf) %vf)
+  // CHECK-LABEL: define{{.*}} void 
@add_compound_matrix_scalar_double_float(<25 x double> noundef nofpclass(nan 
inf) %a, float noundef nofpclass(nan inf) %vf)
   // CHECK:  [[SCALAR:%.*]] = load float, ptr %vf.addr, align 4
   // CHECK-NEXT:  [[SCALAR_EXT:%.*]] = fpext float [[SCALAR]] to double
   // CHECK-NEXT:  [[MATRIX:%.*]] = load <25 x double>, ptr {{.*}}, a

[PATCH] D143334: [clang][Interp] Fix diagnosing uninitialized ctor record arrays

2023-03-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/Interp/Interp.cpp:390
 
-  if (isa(ElemType.getTypePtr())) {
+  if (ElemType->isRecordType()) {
 const Record *R = BasePtr.getElemRecord();

aaron.ballman wrote:
> The difference between these two is that `isRecordType()` is looking at the 
> canonical type whereas `isa<>` is looking at the type under inspection rather 
> than the canonical type. I'd expect these to have the same behavior in most 
> cases, but only matter for cases involving typedefs.
> 
> I think you're correct about the test case below not needing these particular 
> changes -- at least, I'm not seeing what's changed that should impact the 
> test. Should this be split into two changes? 1) Expose the test, 2) Make this 
> functional change + add a new test where the canonical type is different to 
> demonstrate the fix.
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143334

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


[PATCH] D142617: [clang][Interp] Check This pointer without creating InterpFrame

2023-03-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

LGTM


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

https://reviews.llvm.org/D142617

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


[clang-tools-extra] 15aa965 - [clang-tools-extra] Use *{Set,Map}::contains (NFC)

2023-03-14 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-03-14T21:30:29-07:00
New Revision: 15aa965363df5cf3a021b3841bcafbced3756ea2

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

LOG: [clang-tools-extra] Use *{Set,Map}::contains (NFC)

Added: 


Modified: 
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp
clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
clang-tools-extra/clangd/FileDistance.cpp
clang-tools-extra/clangd/Headers.cpp
clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
clang-tools-extra/include-cleaner/lib/Record.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index b61780ca4d971..d2466857e5110 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -866,7 +866,7 @@ HTMLGenerator::generateDocs(StringRef RootDir,
 llvm::SmallString<128> Path;
 llvm::sys::path::native(RootDir, Path);
 llvm::sys::path::append(Path, Info->getRelativeFilePath(""));
-if (CreatedDirs.find(Path) == CreatedDirs.end()) {
+if (!CreatedDirs.contains(Path)) {
   if (std::error_code Err = llvm::sys::fs::create_directories(Path);
   Err != std::error_code()) {
 return llvm::createStringError(Err, "Failed to create directory '%s'.",

diff  --git a/clang-tools-extra/clang-doc/MDGenerator.cpp 
b/clang-tools-extra/clang-doc/MDGenerator.cpp
index 8261e14c3efb0..2f56fd99b7bdc 100644
--- a/clang-tools-extra/clang-doc/MDGenerator.cpp
+++ b/clang-tools-extra/clang-doc/MDGenerator.cpp
@@ -387,7 +387,7 @@ MDGenerator::generateDocs(StringRef RootDir,
 llvm::SmallString<128> Path;
 llvm::sys::path::native(RootDir, Path);
 llvm::sys::path::append(Path, Info->getRelativeFilePath(""));
-if (CreatedDirs.find(Path) == CreatedDirs.end()) {
+if (!CreatedDirs.contains(Path)) {
   if (std::error_code Err = llvm::sys::fs::create_directories(Path);
   Err != std::error_code()) {
 return llvm::createStringError(Err, "Failed to create directory '%s'.",

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
index ae874210afc1a..f578f7ea71c08 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
@@ -147,7 +147,7 @@ void 
ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit() {
   }
   // Check if a definition in another namespace exists.
   const auto DeclName = CurDecl->getName();
-  if (DeclNameToDefinitions.find(DeclName) == DeclNameToDefinitions.end()) 
{
+  if (!DeclNameToDefinitions.contains(DeclName)) {
 continue; // No definition in this translation unit, we can skip it.
   }
   // Make a warning for each definition with the same name (in other

diff  --git 
a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp 
b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp
index 8ffcf476457db..c5bd6055072aa 100644
--- 
a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp
@@ -24,7 +24,7 @@ constexpr llvm::StringLiteral KDisabledTestPrefix = 
"DISABLED_";
 static bool isGoogletestTestMacro(StringRef MacroName) {
   static const llvm::StringSet<> MacroNames = {"TEST", "TEST_F", "TEST_P",
"TYPED_TEST", "TYPED_TEST_P"};
-  return MacroNames.find(MacroName) != MacroNames.end();
+  return MacroNames.contains(MacroName);
 }
 
 namespace {

diff  --git a/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp 
b/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
index 903fd42d12ab1..5abe4f77d6598 100644
--- a/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
+++ b/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
@@ -75,7 +75,7 @@ static bool isStandardMPIDatatype(StringRef MPIDatatype) {
"MPI_CXX_DOUBLE_COMPLEX",
"MPI_CXX_LONG_DOUBLE_COMPLEX"};
 
-  return AllTypes.find(MPIDatatype) != AllTypes.end();
+  return AllTypes.contains(MPIDatatype);
 }
 
 /// Check if a BuiltinType matches the MPI datat

[PATCH] D145737: PR60985: Fix merging of lambda closure types across modules.

2023-03-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:7364
   ReadingKindTracker ReadingKind(Read_Decl, *this);
+  Deserializing D(this);
 

Curious, why do we need this here and below.



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:2192
   if (WasDefinition)
-ReadCXXRecordDefinition(D, /*Update*/false);
+ReadCXXRecordDefinition(D, /*Update*/ false, LambdaContext,
+IndexInLambdaContext);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145737

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


[PATCH] D144844: [C++20] [Modules] Offer -fno-import-inter-module-function-defs to avoid duplicated compilation in modules

2023-03-14 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu planned changes to this revision.
ChuanqiXu added a comment.

It should be "Plan Changed" instead of "Abandoned".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144844

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


[PATCH] D145765: Add __builtin_set_flt_rounds

2023-03-14 Thread xiongji90 via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
xiongji90 marked an inline comment as not done.
Closed by commit rGb38aa2971711: Add __builtin_set_flt_rounds (authored by 
xiongji90).

Changed prior to commit:
  https://reviews.llvm.org/D145765?vs=504957&id=505353#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145765

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin_set_flt_rounds.c
  clang/test/Sema/builtin_set_flt_rounds.c


Index: clang/test/Sema/builtin_set_flt_rounds.c
===
--- /dev/null
+++ clang/test/Sema/builtin_set_flt_rounds.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux -fsyntax-only %s 
-verify=expected,unsupported
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -fsyntax-only %s -verify
+struct S {int a;};
+void test_builtin_set_flt_rounds() {
+  __builtin_set_flt_rounds(1); // unsupported-error {{builtin is not supported 
on this target}}
+  struct S s;
+  __builtin_set_flt_rounds(s); // expected-error {{passing 'struct S' to 
parameter of incompatible type}}
+}
Index: clang/test/CodeGen/builtin_set_flt_rounds.c
===
--- /dev/null
+++ clang/test/CodeGen/builtin_set_flt_rounds.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-gnu-linux %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc %s -emit-llvm -o - | FileCheck 
%s
+// RUN: %clang_cc1 -triple aarch64-gnu-linux %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-windows-msvc %s -emit-llvm -o - | FileCheck 
%s
+void test_builtin_set_flt_rounds() {
+  __builtin_set_flt_rounds(1);
+  // CHECK: call void @llvm.set.rounding(i32 1)
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2146,6 +2146,14 @@
   return ExprError();
 break;
 
+  case Builtin::BI__builtin_set_flt_rounds:
+if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
+  {llvm::Triple::x86, llvm::Triple::x86_64,
+   llvm::Triple::arm, llvm::Triple::thumb,
+   llvm::Triple::aarch64}))
+  return ExprError();
+break;
+
   case Builtin::BI__builtin_isgreater:
   case Builtin::BI__builtin_isgreaterequal:
   case Builtin::BI__builtin_isless:
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -3381,6 +3381,14 @@
 return RValue::get(Result);
   }
 
+  case Builtin::BI__builtin_set_flt_rounds: {
+Function *F = CGM.getIntrinsic(Intrinsic::set_rounding);
+
+Value *V = EmitScalarExpr(E->getArg(0));
+Builder.CreateCall(F, V);
+return RValue::get(nullptr);
+  }
+
   case Builtin::BI__builtin_fpclassify: {
 CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
 // FIXME: for strictfp/IEEE-754 we need to not trap on SNaN here.
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -397,6 +397,7 @@
 
 // Access to floating point environment
 BUILTIN(__builtin_flt_rounds, "i", "n")
+BUILTIN(__builtin_set_flt_rounds, "vi", "n")
 
 // C99 complex builtins
 BUILTIN(__builtin_cabs, "dXd", "Fne")
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -304,6 +304,7 @@
 - Add ``__builtin_elementwise_log2`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp2`` builtin for floating point types only.
+- Add ``__builtin_set_flt_rounds`` builtin for X86, x86_64, Arm and AArch64 
only.
 
 AST Matchers
 


Index: clang/test/Sema/builtin_set_flt_rounds.c
===
--- /dev/null
+++ clang/test/Sema/builtin_set_flt_rounds.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux -fsyntax-only %s -verify=expected,unsupported
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -fsyntax-only %s -verify
+struct S {int a;};
+void test_builtin_set_flt_rounds() {
+  __builtin_set_flt_rounds(1); // unsupported-error {{builtin is not supported on this target}}
+  struct S s;
+  __builtin_set_flt_rounds(s); // expected-error {{passing 'struct S' to parameter of incompatible type}}
+}
Index: clang/

[clang] b38aa29 - Add __builtin_set_flt_rounds

2023-03-14 Thread via cfe-commits

Author: jinge90
Date: 2023-03-15T11:13:55+08:00
New Revision: b38aa297171134cee3fbec3c9e1e4d64b2ec3e22

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

LOG: Add __builtin_set_flt_rounds

This builtin will be converted to llvm.set.rounding intrinsic
in IR level and should be work with "#pragma STDC FENV_ACCESS ON"
since it changes default FP environment. Users can change rounding
mode via this builtin without introducing libc dependency.

Reviewed by: andrew.w.kaylor, rjmccall, sepavloff, aaron.ballman
Differential Revision: https://reviews.llvm.org/D145765
Signed-off-by: jinge90 

Added: 
clang/test/CodeGen/builtin_set_flt_rounds.c
clang/test/Sema/builtin_set_flt_rounds.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 68890e287f67..4a214e04ec6b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -304,6 +304,7 @@ Floating Point Support in Clang
 - Add ``__builtin_elementwise_log2`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp2`` builtin for floating point types only.
+- Add ``__builtin_set_flt_rounds`` builtin for X86, x86_64, Arm and AArch64 
only.
 
 AST Matchers
 

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 814461636729..957375eccb84 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -397,6 +397,7 @@ BUILTIN(__builtin_truncf16, "hh", "Fnc")
 
 // Access to floating point environment
 BUILTIN(__builtin_flt_rounds, "i", "n")
+BUILTIN(__builtin_set_flt_rounds, "vi", "n")
 
 // C99 complex builtins
 BUILTIN(__builtin_cabs, "dXd", "Fne")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 0f9c5acf9e71..9424f0f95f7f 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3381,6 +3381,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 return RValue::get(Result);
   }
 
+  case Builtin::BI__builtin_set_flt_rounds: {
+Function *F = CGM.getIntrinsic(Intrinsic::set_rounding);
+
+Value *V = EmitScalarExpr(E->getArg(0));
+Builder.CreateCall(F, V);
+return RValue::get(nullptr);
+  }
+
   case Builtin::BI__builtin_fpclassify: {
 CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
 // FIXME: for strictfp/IEEE-754 we need to not trap on SNaN here.

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 01f73f6aeb47..be71d862a490 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2146,6 +2146,14 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   return ExprError();
 break;
 
+  case Builtin::BI__builtin_set_flt_rounds:
+if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
+  {llvm::Triple::x86, llvm::Triple::x86_64,
+   llvm::Triple::arm, llvm::Triple::thumb,
+   llvm::Triple::aarch64}))
+  return ExprError();
+break;
+
   case Builtin::BI__builtin_isgreater:
   case Builtin::BI__builtin_isgreaterequal:
   case Builtin::BI__builtin_isless:

diff  --git a/clang/test/CodeGen/builtin_set_flt_rounds.c 
b/clang/test/CodeGen/builtin_set_flt_rounds.c
new file mode 100644
index ..fc483fcc232a
--- /dev/null
+++ b/clang/test/CodeGen/builtin_set_flt_rounds.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-gnu-linux %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc %s -emit-llvm -o - | FileCheck 
%s
+// RUN: %clang_cc1 -triple aarch64-gnu-linux %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-windows-msvc %s -emit-llvm -o - | FileCheck 
%s
+void test_builtin_set_flt_rounds() {
+  __builtin_set_flt_rounds(1);
+  // CHECK: call void @llvm.set.rounding(i32 1)
+}

diff  --git a/clang/test/Sema/builtin_set_flt_rounds.c 
b/clang/test/Sema/builtin_set_flt_rounds.c
new file mode 100644
index ..144e4a2a72df
--- /dev/null
+++ b/clang/test/Sema/builtin_set_flt_rounds.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux -fsyntax-only %s 
-verify=expected,unsupported
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -fsyntax-only %s -verify
+struct S {int a;};
+void test_builtin_set_flt_rounds() {
+  __builtin_set_flt_rounds(1); // unsupported-error {{builtin is not supported 
on this target}}
+  struct S s;
+  __builtin_set

[clang] f3b9912 - [clang-offload-bundler] Fix error with regex in bundler test

2023-03-14 Thread Jacob Lambert via cfe-commits

Author: Jacob Lambert
Date: 2023-03-14T19:51:26-07:00
New Revision: f3b9912026894ecca8925c974dd7ca16b0f1e265

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

LOG: [clang-offload-bundler] Fix error with regex in bundler test

Fix recently introduced error and further generalize
pattern matching for accepted HOST string

Added: 


Modified: 
clang/test/Driver/clang-offload-bundler.c

Removed: 




diff  --git a/clang/test/Driver/clang-offload-bundler.c 
b/clang/test/Driver/clang-offload-bundler.c
index 949748c0112f..7d0b6b27a60a 100644
--- a/clang/test/Driver/clang-offload-bundler.c
+++ b/clang/test/Driver/clang-offload-bundler.c
@@ -300,7 +300,7 @@
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o 
-DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix 
CK-OBJ-CMD-INPUTS
-// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]"
 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude"
 "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST:.+]]={{.*}}" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]"
 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude"
 "--" "[[INOBJ1]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o
 // RUN: clang-offload-bundler -type=o -input=%t.bundle3.o -list | FileCheck 
-check-prefix=CKLST %s



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


[PATCH] D144844: [C++20] [Modules] Offer -fno-import-inter-module-function-defs to avoid duplicated compilation in modules

2023-03-14 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu abandoned this revision.
ChuanqiXu added a comment.

Got your points. Let's postpone this one.

But I want to emphasize that this patch (and the thin PCM) will decrease the 
performance. While LTO can save the regression, LTO is not widely used. 
(ThinLTO can only mitigate this.) I mean the default behavior shouldn't cause 
performance regression. We can offer a new alternative  for the users but we 
can't enable that by default simply now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144844

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


[PATCH] D141098: [clang-format][NFC] Set LineEnding to LF in config files

2023-03-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D141098#4192785 , @mehdi_amini 
wrote:

> In D141098#4111809 , @owenpan wrote:
>
>> Can we just fix the buildbot so that it runs git-clang-format with 
>> `--binary`? Using clang-format-15 to format a patch to clang-format-16 
>> source still looks wrong to me.
>
> The general principle is that developers of LLVM 16 should be able to use 
> clang-format from the previous release (that is: one where we have prebuilt 
> binaries available) to format patches in general.
> It does not seem reasonable to me that we should need to build clang-format 
> ourselves for the purpose of writing patches to LLVM.

Agreed, except for the clang-format source, which its `.clang-format` files are 
part of.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141098

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


[PATCH] D145965: [C++20][Modules] Fix incorrect visibilities in implementation units.

2023-03-14 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D145965#4194514 , @iains wrote:

> In D145965#4192051 , @iains wrote:
>
>> 
>
>
>
>> I was thinking at one stage to add an 'Implementation' module Kind, but at 
>> the moment I do not think it is worth extending the size of the ModuleKind 
>> enum bit field for this (since we now have used up all the entries with the 
>> new 'ExplicitGlobalModuleFragment' case).  That also has a large impact also 
>> for relatively few uses.
>
> I have changed my mind here.
> It seems that we are getting confusing decl context entries without having a 
> proper module for the implementation (even though we will never write such a 
> module to a PCM, since it is not importable).
>
> I was wondering if it would be possible to avoid having separate values for 
> PartitionInterface/Implementation (since they both have a BMI - it is only a 
> question of whether that can be re-exported).  We would have to add one bit 
> to the PCM to deal with that, so that we might as well extend the ModuleKind 
> enum to 4 bits.
>
> So .. please wait for one or two days, I will try to refresh the 
> implementation patch (D126959 ) and see if 
> that resolves some of the issues I am seeing with `P1815`
>
> (this does not alter the situation that you are going to revisit the 
> `isModuleUnitOfCurrentTU` if that is needed - but it might not be; since 
> having a separate module for the impl. will avoid some of the ambiguities 
> anyway).
>
> Additional Note:  we also have a situation in the lookups for dependent names 
> during template instantiation that the visibility of decls can need to be 
> assessed in a different module context from the current module.  So that we 
> might also need to have a `areTheseModulesFromTheSameTU(Module *A. Module *B)`

Yeah. What I had in mind is to remove `ModulePartitionInterface` and 
`ModulePartitionImplementation` in ModuleKinds and rename `ModuleInterfaceUnit` 
to `NamedModules`. And we can introduce 2 bits for IsPartition and 
IsImplementation. Then we can introduce ImplementationUnit without any loss.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145965

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


[PATCH] D125171: Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-03-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D125171#4193996 , @jrmolin wrote:

> In D125171#4167866 , @owenpan wrote:
>
>> Please see 
>> https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options.
>
> I am doing this for my team, which writes the security endpoint for Elastic 
> Defend. The code is currently private, though the binaries are free to 
> download and run. The number of contributors is around 30, and the lines of 
> code is in the 100Ks (around 500K). I have not found a way to accomplish what 
> this does with the available options. I am adding tests and am happy to 
> maintain this. It is a rather small addition, so it is quite simple to keep 
> updated.

Do you "have a publicly accessible style guide"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

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


[clang] ea9d404 - [clang] Use *{Set,Map}::contains (NFC)

2023-03-14 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-03-14T19:17:18-07:00
New Revision: ea9d404032be1541e82e965bada82935629a98c8

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

LOG: [clang] Use *{Set,Map}::contains (NFC)

Added: 


Modified: 
clang/include/clang/Basic/SourceManager.h
clang/include/clang/Basic/TargetCXXABI.h
clang/lib/ARCMigrate/ObjCMT.cpp
clang/lib/Analysis/ExprMutationAnalyzer.cpp
clang/lib/Analysis/ThreadSafety.cpp
clang/lib/Basic/OpenCLOptions.cpp
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/Multilib.cpp
clang/lib/Driver/OffloadBundler.cpp
clang/lib/Format/BreakableToken.cpp
clang/lib/Format/MacroExpander.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index a877308f0412..48c6b6611219 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -992,8 +992,7 @@ class SourceManager : public RefCountedBase {
 if (OverriddenFilesInfo) {
   if (OverriddenFilesInfo->OverriddenFilesWithBuffer.count(File))
 return true;
-  if (OverriddenFilesInfo->OverriddenFiles.find(File) !=
-  OverriddenFilesInfo->OverriddenFiles.end())
+  if (OverriddenFilesInfo->OverriddenFiles.contains(File))
 return true;
 }
 return false;
@@ -1686,7 +1685,7 @@ class SourceManager : public 
RefCountedBase {
   fileinfo_iterator fileinfo_begin() const { return FileInfos.begin(); }
   fileinfo_iterator fileinfo_end() const { return FileInfos.end(); }
   bool hasFileInfo(const FileEntry *File) const {
-return FileInfos.find(File) != FileInfos.end();
+return FileInfos.contains(File);
   }
 
   /// Print statistics to stderr.

diff  --git a/clang/include/clang/Basic/TargetCXXABI.h 
b/clang/include/clang/Basic/TargetCXXABI.h
index 14451359581d..c113a6a048ad 100644
--- a/clang/include/clang/Basic/TargetCXXABI.h
+++ b/clang/include/clang/Basic/TargetCXXABI.h
@@ -60,9 +60,7 @@ class TargetCXXABI {
   static const auto &getSpelling(Kind ABIKind) {
 return getSpellingMap().find(ABIKind)->second;
   }
-  static bool isABI(StringRef Name) {
-return getABIMap().find(Name) != getABIMap().end();
-  }
+  static bool isABI(StringRef Name) { return getABIMap().contains(Name); }
 
   // Return true if this target should use the relative vtables C++ ABI by
   // default.

diff  --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index ce1decd3ba3e..c76efd78976a 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -153,8 +153,7 @@ class ObjCMigrateASTConsumer : public ASTConsumer {
   bool canModifyFile(StringRef Path) {
 if (AllowListFilenames.empty())
   return true;
-return AllowListFilenames.find(llvm::sys::path::filename(Path)) !=
-   AllowListFilenames.end();
+return AllowListFilenames.contains(llvm::sys::path::filename(Path));
   }
   bool canModifyFile(OptionalFileEntryRef FE) {
 if (!FE)

diff  --git a/clang/lib/Analysis/ExprMutationAnalyzer.cpp 
b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
index c876eaa6358a..2f2997b82302 100644
--- a/clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -605,7 +605,7 @@ FunctionParmMutationAnalyzer::FunctionParmMutationAnalyzer(
 for (const CXXCtorInitializer *Init : Ctor->inits()) {
   ExprMutationAnalyzer InitAnalyzer(*Init->getInit(), Context);
   for (const ParmVarDecl *Parm : Ctor->parameters()) {
-if (Results.find(Parm) != Results.end())
+if (Results.contains(Parm))
   continue;
 if (const Stmt *S = InitAnalyzer.findMutation(Parm))
   Results[Parm] = S;

diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index 899c6018895e..9041000b0ff7 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1163,7 +1163,7 @@ void BeforeSet::checkBeforeAfter(const ValueDecl* StartVd,
   }
   // Transitively search other before sets, and warn on cycles.
   if (traverse(Vdb)) {
-if (CycMap.find(Vd) == CycMap.end()) {
+if (!CycMap.contains(Vd)) {
   CycMap.insert(std::make_pair(Vd, true));
   StringRef L1 = Vd->getName();
   Analyzer.Handler.handleBeforeAfterCycle(L1, Vd->getLocation());

diff  --git a/clang/lib/Basic/OpenCLOptions.cpp 
b/clang/lib/Basic/OpenCLOptions.cpp
index 44edf5402540..d39686

[PATCH] D146042: [clang-format] Fix numerous issues with "LambdaBodyIndentation: OuterScope" option

2023-03-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

> The previous implementation of the option involved a hack which corrupted the 
> parenthesis state stack.

Can you link the review (e.g. `Dnn`) of the previous implementation in the 
summary?

> Specifically, this change fixes github issues #55708, #53212, #52846 and 
> #59954.

Please link the issues (e.g. https://github.com/llvm/llvm-project/issues/n).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146042

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


[clang] 65fb636 - [clang-offload-bundler] Fix test failures and document typo

2023-03-14 Thread Jacob Lambert via cfe-commits

Author: Jacob Lambert
Date: 2023-03-14T19:14:42-07:00
New Revision: 65fb636bd462687980935979f2f36ec992e15c84

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

LOG: [clang-offload-bundler] Fix test failures and document typo

The recent bundler patch (e48ae0d) introduced a few errors
in two clang/Driver tests, and in the bundler documentation

Added: 


Modified: 
clang/docs/ClangOffloadBundler.rst
clang/test/Driver/clang-offload-bundler-standardize.c
clang/test/Driver/clang-offload-bundler.c

Removed: 




diff  --git a/clang/docs/ClangOffloadBundler.rst 
b/clang/docs/ClangOffloadBundler.rst
index 52981d6e1dbc..d08bf4b97781 100644
--- a/clang/docs/ClangOffloadBundler.rst
+++ b/clang/docs/ClangOffloadBundler.rst
@@ -175,7 +175,7 @@ Where:
 
 **target-triple**
 The target triple of the code object. See `Target Triple
-.
+`_.
 
 The bundler accepts target triples with or without the optional environment
 field:

diff  --git a/clang/test/Driver/clang-offload-bundler-standardize.c 
b/clang/test/Driver/clang-offload-bundler-standardize.c
index e599271342d5..6a24968c30ef 100644
--- a/clang/test/Driver/clang-offload-bundler-standardize.c
+++ b/clang/test/Driver/clang-offload-bundler-standardize.c
@@ -1,4 +1,5 @@
 // REQUIRES: x86-registered-target
+// REQUIRES: asserts
 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
 // REQUIRES: asserts
 

diff  --git a/clang/test/Driver/clang-offload-bundler.c 
b/clang/test/Driver/clang-offload-bundler.c
index e75af52c3b8b..949748c0112f 100644
--- a/clang/test/Driver/clang-offload-bundler.c
+++ b/clang/test/Driver/clang-offload-bundler.c
@@ -1,6 +1,5 @@
 // REQUIRES: x86-registered-target
 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
-// XFAIL: target={{.*-ps(4|5)}}
 
 //
 // Generate all the types of files we can bundle.
@@ -297,11 +296,11 @@
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o 
-DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix 
CK-OBJ-CMD
-// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]"
 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude"
 "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST:.+]]={{.*}}" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]"
 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude"
 "--" "[[INOBJ1]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o 
-DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix 
CK-OBJ-CMD-INPUTS
-// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]"
 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude"
 "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]"
 
"--set-section-flags=__CLANG_OFFL

[PATCH] D146101: [clang-format] Add DesignatedInitializerIndentWidth option.

2023-03-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Please see 
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options.
 Is there a way to fix the issue without adding a new option?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

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


[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-14 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D145770#4195018 , @dyung wrote:

> @lamb-j the test clang-offload-bundler.c is failing on the PS4 linux builder, 
> can you take a look?
>
> https://lab.llvm.org/buildbot/#/builders/139/builds/37475
>
> I don't know if it matters, but this bot only builds the x86_64 target.

To unblock our bots, I've marked the test as XFAIL for PS4/PS5 in 
768211f48f2d52fdd555a07f3dae8fbf1def88cc 
, please 
investigate when you can.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145770

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


[clang] 768211f - Mark test modified in e48ae0d as XFAIL for PS4/PS5 until the author can investigate.

2023-03-14 Thread Douglas Yung via cfe-commits

Author: Douglas Yung
Date: 2023-03-14T18:33:55-07:00
New Revision: 768211f48f2d52fdd555a07f3dae8fbf1def88cc

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

LOG: Mark test modified in e48ae0d as XFAIL for PS4/PS5 until the author can 
investigate.

The test is failing on the PS4/PS5 bots:
https://lab.llvm.org/buildbot/#/builders/139/builds/37475
https://lab.llvm.org/buildbot/#/builders/216/builds/18354

Added: 


Modified: 
clang/test/Driver/clang-offload-bundler.c

Removed: 




diff  --git a/clang/test/Driver/clang-offload-bundler.c 
b/clang/test/Driver/clang-offload-bundler.c
index 4b59ac0bf216..e75af52c3b8b 100644
--- a/clang/test/Driver/clang-offload-bundler.c
+++ b/clang/test/Driver/clang-offload-bundler.c
@@ -1,5 +1,6 @@
 // REQUIRES: x86-registered-target
 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
+// XFAIL: target={{.*-ps(4|5)}}
 
 //
 // Generate all the types of files we can bundle.



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


[PATCH] D145591: [clang][HIP][OpenMP] Add warning if mixed HIP / OpenMP offloading

2023-03-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8634
+def warn_hip_omp_target_directives : Warning<
+  "HIP does not support OpenMP target directives; directive has been ignored">,
+  InGroup;

jdoerfert wrote:
> yaxunl wrote:
> > jdoerfert wrote:
> > > mhalk wrote:
> > > > jdoerfert wrote:
> > > > > I doubt the ignored part very much.
> > > > I just re-checked the LLVM IR of an example.
> > > > With -x c++ there are __kmpc_target_(de)init calls; with -x hip there 
> > > > are none.
> > > > https://godbolt.org/z/fhds46Pvc
> > > > 
> > > > From my point of view, "effectively", target directives seem to have 
> > > > been ignored.
> > > > Maybe this is a coincidence (there's definitely some uncertainty) or I 
> > > > am misinterpreting the IR.
> > > > I would be glad if you could shed some light on this, if possible / you 
> > > > find the time to do so.
> > > Line 512 in the HIP output: https://godbolt.org/z/n5s5jz7j9.
> > If I remove --offload-arch for the C++ program, I got the same result as 
> > for HIP:
> > 
> > https://godbolt.org/z/4TMzxdfj6
> > 
> > Does that mean we should emit the same error for C++ too?
> I honestly do not follow your logic.
> 
> As I said in the beginning: I doubt the directive is ignored.
> 
> My link showed you that it doesn't ignore the pragma, e.g., the code w/ and 
> w/o the pragma have different results.
> This is also true for C++, but that doesn't make the warning any more 
> accurate.
> 
I understand that the directive is not ignored and incorrect IR are emitted.

What I mean is that compiling "omp target" with HIP is equivalent to compiling 
C++ containing "omp target" without -fopenmp-targets specified in clang FE, 
therefore the error should be emitted in a more generic case. That is:

if "omp target" is compiled without -fopenmp-targets specified in FE, an error 
should be emitted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145591

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


[PATCH] D146104: Use *{Map,Set}::contains (NFC)

2023-03-14 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added subscribers: PiotrZSL, Moerafaat, zero9178, steakhal, bzcheeseman, 
ayermolo, sdasgup3, carlosgalvezp, wenzhicui, wrengr, cota, teijeong, 
rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, martong, Joonsoo, 
liufengdb, aartbik, mgester, arpith-jacob, csigg, antiagainst, shauheen, 
rriddle, mehdi_amini, thopre, hiraditya.
Herald added a reviewer: bondhugula.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a reviewer: ThomasRaoux.
Herald added a reviewer: NoQ.
Herald added a reviewer: njames93.
Herald added a project: All.
kazu requested review of this revision.
Herald added a reviewer: nicolasvasilache.
Herald added subscribers: cfe-commits, llvm-commits, yota9, 
stephenneuendorffer, nicolasvasilache.
Herald added a reviewer: herhut.
Herald added a reviewer: dcaballe.
Herald added projects: clang, MLIR, LLVM, clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146104

Files:
  bolt/include/bolt/Core/BinaryFunction.h
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/Transforms/Scalar/GVNSink.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
  mlir/lib/AsmParser/Parser.cpp
  mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
  mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp

Index: mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
===
--- mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
+++ mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
@@ -152,7 +152,7 @@
   // Find all iteration variables among `minOp`'s operands add constrain them.
   for (Value operand : op->getOperands()) {
 // Skip duplicate ivs.
-if (llvm::is_contained(allIvs, operand))
+if (allIvs.contains(operand))
   continue;
 
 // If `operand` is an iteration variable: Find corresponding loop
Index: mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
===
--- mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
+++ mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
@@ -115,7 +115,7 @@
 
   DenseSet seen;
   for (Attribute map : forallOp.getMapping()->getValue()) {
-if (llvm::is_contained(seen, map)) {
+if (seen.contains(map)) {
   return failureHelper(transformOp, forallOp,
"duplicated attribute, cannot map different loops "
"to the same processor");
Index: mlir/lib/AsmParser/Parser.cpp
===
--- mlir/lib/AsmParser/Parser.cpp
+++ mlir/lib/AsmParser/Parser.cpp
@@ -389,7 +389,7 @@
 const char *bufBegin = state.lex.getBufferBegin();
 const char *it = loc.getPointer() - 1;
 for (; it > bufBegin && *it != '\n'; --it)
-  if (!llvm::is_contained(StringRef(" \t\r"), *it))
+  if (!StringRef(" \t\r").contains(*it))
 return true;
 return false;
   };
Index: llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
===
--- llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
+++ llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
@@ -361,9 +361,8 @@
 char32_t Codepoint = Entry.first;
 const std::string &Name = Entry.second;
 // Ignore names which are not valid.
-if (Name.empty() || !llvm::all_of(Name, [](char C) {
-  return llvm::is_contained(Letters, C);
-})) {
+if (Name.empty() ||
+!llvm::all_of(Name, [](char C) { return Letters.contains(C); })) {
   continue;
 }
 printf("%06x: %s\n", static_cast(Codepoint), Name.c_str());
Index: llvm/tools/llvm-exegesis/lib/Analysis.cpp
===
--- llvm/tools/llvm-exegesis/lib/Analysis.cpp
+++ llvm/tools/llvm-exegesis/lib/Analysis.cpp
@@ -28,7 +28,7 @@
 template  void writeEscaped(raw_ostream &OS, const StringRef S);
 
 template <> void writeEscaped(raw_ostream &OS, const StringRef S) {
-  if (!llvm::is_contained(S, kCsvSep)) {
+  if (!S.contains(kCsvSep)) {
 OS << S;
   } else {
 // Needs escaping.
Index: llvm/lib/Transforms/Scalar/GVNSink.cpp
===
--- llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -154,7 +154,7 @@
 
   void restrictToBlocks(SmallSetVector &Blocks) {
 for (auto II = Insts.begin(); II != Insts.end();) {
-  if (!llvm::is_contained(Blocks, (*II)->getParen

[PATCH] D142490: [Clang] Fix ClassifyImplicitMemberAccess to handle cases where the access in an unevaluated context is not within a CXXRecordDecl or CXXMethodDecl

2023-03-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc41be8fc741d: [Clang] Fix ClassifyImplicitMemberAccess to 
handle cases where the access in an… (authored by shafik).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142490

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
  clang/test/SemaCXX/statements.cpp


Index: clang/test/SemaCXX/statements.cpp
===
--- clang/test/SemaCXX/statements.cpp
+++ clang/test/SemaCXX/statements.cpp
@@ -52,3 +52,14 @@
   int a = test7(1);
   double b = test7(2.0);
 }
+
+namespace GH48405 {
+void foo() {
+  struct S {
+int i;
+int j = ({i;}); // expected-error {{invalid use of non-static data member 
'i'}}
+// expected-error@-1 {{cannot initialize a member 
subobject of type 'int' with an rvalue of type 'void'}}
+   // expected-warning@-2 {{use of GNU statement expression 
extension}}
+  };
+}
+}
Index: clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
===
--- clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
+++ clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
@@ -1026,3 +1026,11 @@
   void *v = x(f); // expected-error {{cannot initialize a variable of type 
'void *' with an rvalue of type 'int'}}
   void *w = y(f); // expected-error {{cannot initialize a variable of type 
'void *' with an rvalue of type 'int'}}
 }
+
+namespace GH37792 {
+struct A { int x; };
+
+void f() {
+  [](auto t) -> decltype(decltype(t)::x) { return 0; }(A());
+}
+}
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -161,10 +161,13 @@
   }
 
   CXXRecordDecl *contextClass;
-  if (CXXMethodDecl *MD = dyn_cast(DC))
+  if (auto *MD = dyn_cast(DC))
 contextClass = MD->getParent()->getCanonicalDecl();
-  else
+  else if (auto *RD = dyn_cast(DC))
 contextClass = cast(DC);
+  else
+return AbstractInstanceResult ? AbstractInstanceResult
+  : IMA_Error_StaticContext;
 
   // [class.mfct.non-static]p3:
   // ...is used in the body of a non-static member function of class X,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -202,6 +202,10 @@
   of `CWG2699 _` being accepted by WG21.
 - Fix crash when parsing fold expression containing a delayed typo correction.
   (`#61326 `_)
+- Fix crash when dealing with some member accesses outside of class or member
+  function context.
+  (`#37792 `_) and
+  (`#48405 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/statements.cpp
===
--- clang/test/SemaCXX/statements.cpp
+++ clang/test/SemaCXX/statements.cpp
@@ -52,3 +52,14 @@
   int a = test7(1);
   double b = test7(2.0);
 }
+
+namespace GH48405 {
+void foo() {
+  struct S {
+int i;
+int j = ({i;}); // expected-error {{invalid use of non-static data member 'i'}}
+// expected-error@-1 {{cannot initialize a member subobject of type 'int' with an rvalue of type 'void'}}
+		// expected-warning@-2 {{use of GNU statement expression extension}}
+  };
+}
+}
Index: clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
===
--- clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
+++ clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
@@ -1026,3 +1026,11 @@
   void *v = x(f); // expected-error {{cannot initialize a variable of type 'void *' with an rvalue of type 'int'}}
   void *w = y(f); // expected-error {{cannot initialize a variable of type 'void *' with an rvalue of type 'int'}}
 }
+
+namespace GH37792 {
+struct A { int x; };
+
+void f() {
+  [](auto t) -> decltype(decltype(t)::x) { return 0; }(A());
+}
+}
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -161,10 +161,13 @@
   }
 
   CXXRecordDecl *contextClass;
-  if (CXXMethodDecl *MD = dyn_cast(DC))
+  if (auto *MD = dyn_cast(DC))
 contextClass = MD->getParent()->getCanonicalDecl();
-  else
+  else if (auto *RD = dyn_cast(DC))
 contextClass = cast(DC);
+  else
+return AbstractInstanceResult ? AbstractInstanceResult
+  : IMA_Error_StaticContext;
 
   // [class.mfct.

[clang] c41be8f - [Clang] Fix ClassifyImplicitMemberAccess to handle cases where the access in an unevaluated context is not within a CXXRecordDecl or CXXMethodDecl

2023-03-14 Thread Shafik Yaghmour via cfe-commits

Author: Shafik Yaghmour
Date: 2023-03-14T16:37:58-07:00
New Revision: c41be8fc741dec82e6c628d0cad742285be293f6

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

LOG: [Clang] Fix ClassifyImplicitMemberAccess to handle cases where the access 
in an unevaluated context is not within a CXXRecordDecl or CXXMethodDecl

ClassifyImplicitMemberAccess assumes that if we are not in a static context then
the DeclContext must be a CXXRecordDecl or a CXXMethodDecl. In the case of the
unevaluated context this may not be true.

This will lead to a crash because contextClass will remain a nullptr.

Fixes: https://github.com/llvm/llvm-project/issues/37792
Fixes: https://github.com/llvm/llvm-project/issues/48405

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExprMember.cpp
clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
clang/test/SemaCXX/statements.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 06e4cd23db7a4..68890e287f674 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -202,6 +202,10 @@ Bug Fixes in This Version
   of `CWG2699 _` being accepted by WG21.
 - Fix crash when parsing fold expression containing a delayed typo correction.
   (`#61326 `_)
+- Fix crash when dealing with some member accesses outside of class or member
+  function context.
+  (`#37792 `_) and
+  (`#48405 `_)
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index a3420ac6fdd2d..667a17e05f930 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -161,10 +161,13 @@ static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef,
   }
 
   CXXRecordDecl *contextClass;
-  if (CXXMethodDecl *MD = dyn_cast(DC))
+  if (auto *MD = dyn_cast(DC))
 contextClass = MD->getParent()->getCanonicalDecl();
-  else
+  else if (auto *RD = dyn_cast(DC))
 contextClass = cast(DC);
+  else
+return AbstractInstanceResult ? AbstractInstanceResult
+  : IMA_Error_StaticContext;
 
   // [class.mfct.non-static]p3:
   // ...is used in the body of a non-static member function of class X,

diff  --git a/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp 
b/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
index 463e077ce934c..61dfd654f6d65 100644
--- a/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
+++ b/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
@@ -1026,3 +1026,11 @@ namespace PR46637 {
   void *v = x(f); // expected-error {{cannot initialize a variable of type 
'void *' with an rvalue of type 'int'}}
   void *w = y(f); // expected-error {{cannot initialize a variable of type 
'void *' with an rvalue of type 'int'}}
 }
+
+namespace GH37792 {
+struct A { int x; };
+
+void f() {
+  [](auto t) -> decltype(decltype(t)::x) { return 0; }(A());
+}
+}

diff  --git a/clang/test/SemaCXX/statements.cpp 
b/clang/test/SemaCXX/statements.cpp
index 75ed983ba84b2..48f178dd9a8b3 100644
--- a/clang/test/SemaCXX/statements.cpp
+++ b/clang/test/SemaCXX/statements.cpp
@@ -52,3 +52,14 @@ void test8() {
   int a = test7(1);
   double b = test7(2.0);
 }
+
+namespace GH48405 {
+void foo() {
+  struct S {
+int i;
+int j = ({i;}); // expected-error {{invalid use of non-static data member 
'i'}}
+// expected-error@-1 {{cannot initialize a member 
subobject of type 'int' with an rvalue of type 'void'}}
+   // expected-warning@-2 {{use of GNU statement expression 
extension}}
+  };
+}
+}



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


[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-14 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

@lamb-j the test clang-offload-bundler.c is failing on the PS4 linux builder, 
can you take a look?

https://lab.llvm.org/buildbot/#/builders/139/builds/37475

I don't know if it matters, but this bot only builds the x86_64 target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145770

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


[PATCH] D146042: [clang-format] Fix numerous issues with "LambdaBodyIndentation: OuterScope" option

2023-03-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added inline comments.
This revision now requires changes to proceed.



Comment at: clang/docs/ClangFormatStyleOptions.rst:3540
 
+   someMethod(someOtherMethod(
+   [](SomeReallyLongLambdaSignatureArgument foo) {

This code may come from Format.h



Comment at: clang/unittests/Format/FormatTest.cpp:21916
 
   // Lambdas with different indentation styles.
+  Style = getLLVMStyleWithColumns(60);

Why are you changing existing tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146042

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


[PATCH] D146101: [clang-format] Add DesignatedInitializerIndentWidth option.

2023-03-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added inline comments.
This revision now requires changes to proceed.



Comment at: clang/include/clang/Format/Format.h:2031
+  /// };
+  ///   }
+  unsigned DesignatedInitializerIndentWidth;

Endcode



Comment at: clang/lib/Format/Format.cpp:905
 IO.mapOptional("DerivePointerAlignment", Style.DerivePointerAlignment);
+IO.mapOptional("DesignatedInitializerIndentWidth",
+   Style.DesignatedInitializerIndentWidth);

Needs a parse test



Comment at: clang/unittests/Format/FormatTest.cpp:4828
+   ".yy = 2,\n"
+   ".zz = 3};\n",
+   Style);

Can we fix the brace positioning too


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

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


[PATCH] D125171: Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-03-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added inline comments.
This revision now requires changes to proceed.



Comment at: clang/docs/ClangFormatStyleOptions.rst:1372
+.. _AlwaysBreakBeforeFunctionParameters:
+
+**AlwaysBreakBeforeFunctionParameters** (``Boolean``) 
:versionbadge:`clang-format 16.0`

Regererate



Comment at: clang/docs/ClangFormatStyleOptions.rst:1376
+
+  This flag is meant to align function parameters starting on the line 
following
+  a function declaration or definition. Thus, it will only take effect if a 
function

Ok you wrote this by hand it’s auto generated from format.h



Comment at: clang/lib/Format/Format.cpp:872
 IO.mapOptional("AlwaysBreakBeforeMultilineStrings",
Style.AlwaysBreakBeforeMultilineStrings);
+IO.mapOptional("AlwaysBreakBeforeFunctionParameters",

Needs a parse test



Comment at: clang/unittests/Format/FormatTest.cpp:25357
+  // verify that there is no break by default
+  verifyFormat("int function1(int param1, int param2, int param3);\n"
+   "int function2();\n",

Please write it out long form


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

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


[clang] d4a4d0d - clang/test/Driver/clang-offload-bundler-standardize.c REQUIRES asserts. (fixup D145770)

2023-03-14 Thread NAKAMURA Takumi via cfe-commits

Author: NAKAMURA Takumi
Date: 2023-03-15T08:08:51+09:00
New Revision: d4a4d0d7912796aa02878e2cd51da4d1fe8ce930

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

LOG: clang/test/Driver/clang-offload-bundler-standardize.c REQUIRES asserts. 
(fixup D145770)

Added: 


Modified: 
clang/test/Driver/clang-offload-bundler-standardize.c

Removed: 




diff  --git a/clang/test/Driver/clang-offload-bundler-standardize.c 
b/clang/test/Driver/clang-offload-bundler-standardize.c
index 397164464560..e599271342d5 100644
--- a/clang/test/Driver/clang-offload-bundler-standardize.c
+++ b/clang/test/Driver/clang-offload-bundler-standardize.c
@@ -1,5 +1,6 @@
 // REQUIRES: x86-registered-target
 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
+// REQUIRES: asserts
 
 // Generate the file we can bundle.
 // RUN: %clang -O0 -target %itanium_abi_triple %s -c -o %t.o



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


[PATCH] D145150: clang: Emit nofpclass(nan inf) for -ffinite-math-only

2023-03-14 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


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

https://reviews.llvm.org/D145150

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


[PATCH] D146101: [clang-format] Add DesignatedInitializerIndentWidth option.

2023-03-14 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2704
+
+**DesignatedInitializerIndentWidth** (``Unsigned``)
+  The number of columns to use to indent designated initializers that start on 
a new line.

Perhaps it would be better to make this a signed integer and default to `-1` 
which would cause `ContinuationIndentWidth` to be used (i.e. current behaviour)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

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


[PATCH] D146101: [clang-format] Add DesignatedInitializerIndentWidth option.

2023-03-14 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 updated this revision to Diff 505302.
jp4a50 added a comment.

Apply clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4820,6 +4820,26 @@
"[3] = cc,\n"
"[4] = dd,\n"
"[5] = ee};");
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  verifyFormat("auto s = SomeStruct{\n"
+   ".xx = 1,\n"
+   ".yy = 2,\n"
+   ".zz = 3};\n",
+   Style);
+  Style.DesignatedInitializerIndentWidth = 2;
+  verifyFormat("auto s = SomeStruct{\n"
+   "  .xx = 1,\n"
+   "  .yy = 2,\n"
+   "  .zz = 3};\n",
+   Style);
+  verifyFormat("auto s = someFunctionCall(\n"
+   ", ,\n"
+   "SomeStruct{\n"
+   "  .xx = 1,\n"
+   "  .yy = 2,\n"
+   "  .zz = 3});\n",
+   Style);
 }
 
 TEST_F(FormatTest, NestedStaticInitializers) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -902,6 +902,8 @@
 IO.mapOptional("ContinuationIndentWidth", Style.ContinuationIndentWidth);
 IO.mapOptional("Cpp11BracedListStyle", Style.Cpp11BracedListStyle);
 IO.mapOptional("DerivePointerAlignment", Style.DerivePointerAlignment);
+IO.mapOptional("DesignatedInitializerIndentWidth",
+   Style.DesignatedInitializerIndentWidth);
 IO.mapOptional("DisableFormat", Style.DisableFormat);
 IO.mapOptional("EmptyLineAfterAccessModifier",
Style.EmptyLineAfterAccessModifier);
@@ -1367,6 +1369,7 @@
   LLVMStyle.ContinuationIndentWidth = 4;
   LLVMStyle.Cpp11BracedListStyle = true;
   LLVMStyle.DerivePointerAlignment = false;
+  LLVMStyle.DesignatedInitializerIndentWidth = 4;
   LLVMStyle.DisableFormat = false;
   LLVMStyle.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never;
   LLVMStyle.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1656,13 +1656,16 @@
 CurrentState.NestedBlockIndent);
   if (Current.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) ||
   opensProtoMessageField(Current, Style)) {
+const FormatToken *NextNoComment = Current.getNextNonComment();
 if (Current.opensBlockOrBlockTypeList(Style)) {
   NewIndent = Style.IndentWidth +
   std::min(State.Column, CurrentState.NestedBlockIndent);
+} else if (NextNoComment->is(TT_DesignatedInitializerPeriod)) {
+  NewIndent =
+  CurrentState.LastSpace + Style.DesignatedInitializerIndentWidth;
 } else {
   NewIndent = CurrentState.LastSpace + Style.ContinuationIndentWidth;
 }
-const FormatToken *NextNoComment = Current.getNextNonComment();
 bool EndsInComma = Current.MatchingParen &&
Current.MatchingParen->Previous &&
Current.MatchingParen->Previous->is(tok::comma);
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2020,6 +2020,17 @@
   /// \version 3.7
   bool DerivePointerAlignment;
 
+  /// The number of columns to use to indent designated initializers that start
+  /// on a new line. \code
+  ///   void f() {
+  /// auto s = SomeStruct{
+  ///   .foo = "foo",
+  ///   .bar = "bar",
+  ///   .baz = "baz",
+  /// };
+  ///   }
+  unsigned DesignatedInitializerIndentWidth;
+
   /// Disables formatting completely.
   /// \version 3.7
   bool DisableFormat;
@@ -4236,6 +4247,8 @@
ContinuationIndentWidth == R.ContinuationIndentWidth &&
Cpp11BracedListStyle == R.Cpp11BracedListStyle &&
DerivePointerAlignment == R.DerivePointerAlignment &&
+   DesignatedInit

[PATCH] D146101: [clang-format] Add DesignatedInitializerIndentWidth option.

2023-03-14 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 created this revision.
Herald added a project: All.
jp4a50 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The option allows users to specify how many columns to use to indent
designated initializers that start on a new line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146101

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4820,6 +4820,25 @@
"[3] = cc,\n"
"[4] = dd,\n"
"[5] = ee};");
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  verifyFormat("auto s = SomeStruct{\n"
+   ".xx = 1,\n"
+   ".yy = 2,\n"
+   ".zz = 3};\n",
+   Style);
+  Style.DesignatedInitializerIndentWidth = 2;
+  verifyFormat("auto s = SomeStruct{\n"
+   "  .xx = 1,\n"
+   "  .yy = 2,\n"
+   "  .zz = 3};\n",
+   Style);
+  verifyFormat("auto s = someFunctionCall(\n"
+   ", ,\n"
+   "SomeStruct{\n"
+   "  .xx = 1,\n"
+   "  .yy = 2,\n"
+   "  .zz = 3});\n", Style);
 }
 
 TEST_F(FormatTest, NestedStaticInitializers) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -902,6 +902,7 @@
 IO.mapOptional("ContinuationIndentWidth", Style.ContinuationIndentWidth);
 IO.mapOptional("Cpp11BracedListStyle", Style.Cpp11BracedListStyle);
 IO.mapOptional("DerivePointerAlignment", Style.DerivePointerAlignment);
+IO.mapOptional("DesignatedInitializerIndentWidth", Style.DesignatedInitializerIndentWidth);
 IO.mapOptional("DisableFormat", Style.DisableFormat);
 IO.mapOptional("EmptyLineAfterAccessModifier",
Style.EmptyLineAfterAccessModifier);
@@ -1367,6 +1368,7 @@
   LLVMStyle.ContinuationIndentWidth = 4;
   LLVMStyle.Cpp11BracedListStyle = true;
   LLVMStyle.DerivePointerAlignment = false;
+  LLVMStyle.DesignatedInitializerIndentWidth = 4;
   LLVMStyle.DisableFormat = false;
   LLVMStyle.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never;
   LLVMStyle.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1656,13 +1656,15 @@
 CurrentState.NestedBlockIndent);
   if (Current.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) ||
   opensProtoMessageField(Current, Style)) {
+const FormatToken *NextNoComment = Current.getNextNonComment();
 if (Current.opensBlockOrBlockTypeList(Style)) {
   NewIndent = Style.IndentWidth +
   std::min(State.Column, CurrentState.NestedBlockIndent);
+} else if (NextNoComment->is(TT_DesignatedInitializerPeriod)) {
+  NewIndent = CurrentState.LastSpace + Style.DesignatedInitializerIndentWidth;
 } else {
   NewIndent = CurrentState.LastSpace + Style.ContinuationIndentWidth;
 }
-const FormatToken *NextNoComment = Current.getNextNonComment();
 bool EndsInComma = Current.MatchingParen &&
Current.MatchingParen->Previous &&
Current.MatchingParen->Previous->is(tok::comma);
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2020,6 +2020,17 @@
   /// \version 3.7
   bool DerivePointerAlignment;
 
+  /// The number of columns to use to indent designated initializers that start on a new line.
+  /// \code
+  ///   void f() {
+  /// auto s = SomeStruct{
+  ///   .foo = "foo",
+  ///   .bar = "bar",
+  ///   .baz = "baz",
+  /// };
+  ///   }
+  unsigned DesignatedInitializerIndentWidth;
+
   /// Disables formatting completely.
   /// \version 3.7
   bool DisableFormat;
@@ -4236,6 +4247,7 @@
ContinuationIndentWidth == R.ContinuationIndentWidth &&
Cpp11BracedListStyle == R.Cpp11BracedListStyle &&

[PATCH] D143587: [Docs] Multilib design

2023-03-14 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 505293.
michaelplatings added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143587

Files:
  clang/docs/Multilib.rst
  clang/docs/index.rst
  clang/include/clang/Driver/Multilib.h

Index: clang/include/clang/Driver/Multilib.h
===
--- clang/include/clang/Driver/Multilib.h
+++ clang/include/clang/Driver/Multilib.h
@@ -72,6 +72,8 @@
   /// options and look similar to them, and others can be defined by a
   /// particular multilib.yaml. A multilib is considered compatible if its flags
   /// are a subset of the flags derived from the Clang command line options.
+  /// See clang/docs/Multilib.rst for further explanation of how flags may be
+  /// generated and used.
   const flags_list &flags() const { return Flags; }
 
   /// Returns the options that should be used for clang -print-multi-lib
Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -100,6 +100,7 @@
CodeOwners
InternalsManual
DriverInternals
+   Multilib
OffloadingDesign
PCHInternals
ItaniumMangleAbiTags
Index: clang/docs/Multilib.rst
===
--- /dev/null
+++ clang/docs/Multilib.rst
@@ -0,0 +1,327 @@
+
+Multilib
+
+
+Introduction
+
+
+This document describes how multilib is implemented in Clang.
+
+What is multilib and why might you care?
+If you're :doc:`cross compiling` then you can't use native
+system headers and libraries. To address this, you can use a combination of
+``--sysroot``, ``-isystem`` and ``-L`` options to point Clang at suitable
+directories for your target.
+However, when there are many possible directories to choose from, it's not
+necessarily obvious which one to pick.
+Multilib allows a toolchain designer to imbue the toolchain with the ability to
+pick a suitable directory automatically, based on the options the user provides
+to Clang. For example, if the user specifies
+``--target=arm-none-eabi -mcpu=cortex-m4`` the toolchain can choose a directory
+containing headers and libraries suitable for Armv7E-M, because it knows that's
+a suitable architecture for Arm Cortex-M4.
+Multilib can also choose between libraries for the same architecture based on
+other options. For example if the user specifies ``-fno-exceptions`` then a
+toolchain could select libraries built without exception support, thereby
+reducing the size of the resulting binary.
+
+Design
+==
+
+Clang supports GCC's ``-print-multi-lib`` and ``-print-multi-directory``
+options. These are described in
+`GCC Developer Options `_.
+
+There are two ways to configure multilib in Clang: hard-coded or via a
+configuration file.
+
+Hard-coded Multilib
+===
+
+The available libraries can be hard-coded in Clang. Typically this is done
+using the ``MultilibBuilder`` interface in
+``clang/include/clang/Driver/MultilibBuilder.h``.
+There are many examples of this in ``lib/Driver/ToolChains/Gnu.cpp``.
+The remainder of this document will not focus on this type of multilib.
+
+EXPERIMENTAL Multilib via configuration file
+
+
+Some Clang toolchains support loading multilib configuration from a
+``multilib.yaml`` configuration file.
+
+A ``multilib.yaml`` configuration file specifies which multilib variants are
+available, their relative location, what compilation options were used to build
+them, and the criteria by which they are selected.
+
+Multilib processing
+===
+
+Clang goes through the following steps to use multilib from a configuration
+file:
+#. Convert command line options to flags. Clang can accept the same
+   information via different options - for example,
+   ``--target=arm-none-eabi -march=armv7-m`` and
+   ``--target=armv7m-none-eabi`` are equivalent. Clang can also accept many
+   independent pieces of information within a single option - for example
+   ``-march=armv8.1m.main+fp+mve`` specifies the architecture and two
+   extensions in a single command line option.
+   To make it easier for the multilib system, Clang converts the command line
+   options into a standard set of simpler "flags". In many cases these flags
+   will look like a command line option with the leading ``-`` stripped off,
+   but where a suitable form for the flag doesn't exist in command line
+   options then its form will be different. For example, an Arm architecture
+   extension is represented like ``march=+mve`` since there's no way to specify
+   it in isolation in a command line option.
+   To see what flags are emitted for a given set of command line options, use
+   the ``-print-multi-selection-flags-experimen

[PATCH] D143075: BareMetal ToolChain multilib layering

2023-03-14 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 505290.
michaelplatings added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143075

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/test/Driver/baremetal-multilib.yaml

Index: clang/test/Driver/baremetal-multilib.yaml
===
--- clang/test/Driver/baremetal-multilib.yaml
+++ clang/test/Driver/baremetal-multilib.yaml
@@ -25,6 +25,23 @@
 # RUN:   | FileCheck --check-prefix=CHECK-PRINT-MULTI-DIRECTORY %s
 # CHECK-PRINT-MULTI-DIRECTORY: arm-none-eabi/thumb/v8-m.main/fp
 
+# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \
+# RUN: --target=thumbv8.1m.main-none-eabihf -fno-exceptions --sysroot= \
+# RUN:   | FileCheck -DSYSROOT=%T/baremetal_multilib --check-prefix=CHECK-LAYERED-MULTILIB %s
+# CHECK-LAYERED-MULTILIB:  "-cc1" "-triple" "thumbv8.1m.main-none-unknown-eabihf"
+# CHECK-LAYERED-MULTILIB-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8.1-m.main/fp/noexcept/include/c++/v1"
+# CHECK-LAYERED-MULTILIB-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8.1-m.main/fp/include/c++/v1"
+# CHECK-LAYERED-MULTILIB-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8.1-m.main/fp/noexcept/include"
+# CHECK-LAYERED-MULTILIB-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8.1-m.main/fp/include"
+# CHECK-LAYERED-MULTILIB-NEXT: "-L[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8.1-m.main/fp/noexcept/lib"
+# CHECK-LAYERED-MULTILIB-SAME: "-L[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8.1-m.main/fp/lib"
+
+# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \
+# RUN: --target=thumbv8.1m.main-none-eabihf -fno-exceptions --sysroot= \
+# RUN:   | FileCheck --check-prefix=CHECK-LAYERED-PRINT-MULTI-DIRECTORY %s
+# CHECK-LAYERED-PRINT-MULTI-DIRECTORY:  arm-none-eabi/thumb/v8.1-m.main/fp
+# CHECK-LAYERED-PRINT-MULTI-DIRECTORY-NEXT: arm-none-eabi/thumb/v8.1-m.main/fp/noexcept
+
 # RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -print-multi-lib 2>&1 \
 # RUN: --target=arm-none-eabi --sysroot= \
 # RUN:   | FileCheck --check-prefix=CHECK-PRINT-MULTI-LIB %s
@@ -38,6 +55,7 @@
 # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8-m.main/fp;@-target=thumbv8m.main-none-eabihf
 # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8.1-m.main/fp;@-target=thumbv8.1m.main-none-eabihf
 # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8.1-m.main/nofp/mve;@-target=arm-none-eabihf@march=armv8.1m.main+nofp+mve
+# CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8.1-m.main/fp/noexcept;@-target=thumbv8.1m.main-none-eabihf@fno-exceptions
 
 # RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x assembler -mexecute-only \
 # RUN: --target=arm-none-eabi --sysroot= %s -c -### 2>&1 \
@@ -117,6 +135,14 @@
   Flags: [target=thumbv8.1m.main-none-unknown-eabihf, march=+mve]
   PrintOptions: [--target=arm-none-eabihf, -march=armv8.1m.main+nofp+mve]
 
+# A specialisation of v8.1-m.main/fp without exceptions.
+# This layers over the top of the regular v8.1-m.main/fp so it doesn't
+# need to have its own include directory or C library, thereby saving
+# disk space.
+- Dir: arm-none-eabi/thumb/v8.1-m.main/fp/noexcept
+  Flags: [target=thumbv8.1m.main-none-unknown-eabihf, hasfpu, fno-exceptions]
+  PrintOptions: [--target=thumbv8.1m.main-none-eabihf, -fno-exceptions]
+
 
 # The second section of the file is a map from auto-detected flags
 # to custom flags. The auto-detected flags can be printed out
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- clang/lib/Driver/ToolChains/BareMetal.h
+++ clang/lib/Driver/ToolChains/BareMetal.h
@@ -71,6 +71,9 @@
   void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs) const;
   std::string computeSysRoot() const override;
+
+private:
+  llvm::SmallVector getOrderedMultilibs() const;
 };
 
 } // namespace toolchains
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -103,9 +103,12 @@
   findMultilibs(D, Triple, Args);
   SmallString<128> SysRoot(computeSysRoot());
   if (!SysRoot.empty()) {
-llvm::sys::path::append(SysRoot, "lib");
-getFilePaths().push_back(std::string(SysRoot));
-getLibraryPaths().push_back(std::string(SysRoot));
+for (const Multilib &M : getOrderedMultilibs()) {
+  SmallString<128> Dir(SysRoot);
+  llvm::sys::path::append(Dir, M.osSuffix(), "lib");
+  getFileP

[PATCH] D143059: [Driver] Enable selecting multiple multilibs

2023-03-14 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 505288.
michaelplatings added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143059

Files:
  clang/include/clang/Driver/Multilib.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/Multilib.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/CSKYToolChain.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/MipsLinux.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/test/Driver/fuchsia.cpp
  clang/unittests/Driver/MultilibBuilderTest.cpp
  clang/unittests/Driver/MultilibTest.cpp

Index: clang/unittests/Driver/MultilibTest.cpp
===
--- clang/unittests/Driver/MultilibTest.cpp
+++ clang/unittests/Driver/MultilibTest.cpp
@@ -154,18 +154,18 @@
   Multilib("/bar", {}, {}, {"+bar"}),
   });
   Multilib::flags_list Flags1 = {"+foo", "-bar"};
-  Multilib Selection1;
+  llvm::SmallVector Selection1;
   ASSERT_TRUE(MS.select(Flags1, Selection1))
   << "Flag set was {\"+foo\"}, but selection not found";
-  ASSERT_TRUE(Selection1.gccSuffix() == "/foo")
-  << "Selection picked " << Selection1 << " which was not expected";
+  ASSERT_TRUE(Selection1.back().gccSuffix() == "/foo")
+  << "Selection picked " << Selection1.back() << " which was not expected";
 
   Multilib::flags_list Flags2 = {"+foo", "+bar"};
-  Multilib Selection2;
+  llvm::SmallVector Selection2;
   ASSERT_TRUE(MS.select(Flags2, Selection2))
   << "Flag set was {\"+bar\"}, but selection not found";
-  ASSERT_TRUE(Selection2.gccSuffix() == "/bar")
-  << "Selection picked " << Selection2 << " which was not expected";
+  ASSERT_TRUE(Selection2.back().gccSuffix() == "/bar")
+  << "Selection picked " << Selection2.back() << " which was not expected";
 }
 
 TEST(MultilibTest, SelectMultiple) {
@@ -173,17 +173,17 @@
   Multilib("/a", {}, {}, {"x"}),
   Multilib("/b", {}, {}, {"y"}),
   });
-  std::vector Selection;
+  llvm::SmallVector Selection;
 
-  Selection = MS.select({"x"});
+  ASSERT_TRUE(MS.select({"x"}, Selection));
   ASSERT_EQ(1u, Selection.size());
   EXPECT_EQ("/a", Selection[0].gccSuffix());
 
-  Selection = MS.select({"y"});
+  ASSERT_TRUE(MS.select({"y"}, Selection));
   ASSERT_EQ(1u, Selection.size());
   EXPECT_EQ("/b", Selection[0].gccSuffix());
 
-  Selection = MS.select({"y", "x"});
+  ASSERT_TRUE(MS.select({"y", "x"}, Selection));
   ASSERT_EQ(2u, Selection.size());
   EXPECT_EQ("/a", Selection[0].gccSuffix());
   EXPECT_EQ("/b", Selection[1].gccSuffix());
@@ -367,7 +367,7 @@
 
 TEST(MultilibTest, SelectSoft) {
   MultilibSet MS;
-  Multilib Selected;
+  llvm::SmallVector Selected;
   ASSERT_TRUE(parseYaml(MS, YAML_PREAMBLE R"(
 Variants:
 - Dir: s
@@ -386,7 +386,7 @@
 
 TEST(MultilibTest, SelectSoftFP) {
   MultilibSet MS;
-  Multilib Selected;
+  llvm::SmallVector Selected;
   ASSERT_TRUE(parseYaml(MS, YAML_PREAMBLE R"(
 Variants:
 - Dir: f
@@ -402,7 +402,7 @@
   // If hard float is all that's available then select that only if compiling
   // with hard float.
   MultilibSet MS;
-  Multilib Selected;
+  llvm::SmallVector Selected;
   ASSERT_TRUE(parseYaml(MS, YAML_PREAMBLE R"(
 Variants:
 - Dir: h
@@ -416,7 +416,7 @@
 
 TEST(MultilibTest, SelectFloatABI) {
   MultilibSet MS;
-  Multilib Selected;
+  llvm::SmallVector Selected;
   ASSERT_TRUE(parseYaml(MS, YAML_PREAMBLE R"(
 Variants:
 - Dir: s
@@ -437,18 +437,18 @@
   NoMatchFlags: [hasfp]
 )"));
   MS.select({"mfloat-abi=soft"}, Selected);
-  EXPECT_EQ("/s", Selected.gccSuffix());
+  EXPECT_EQ("/s", Selected.back().gccSuffix());
   MS.select({"mfloat-abi=softfp"}, Selected);
-  EXPECT_EQ("/f", Selected.gccSuffix());
+  EXPECT_EQ("/f", Selected.back().gccSuffix());
   MS.select({"mfloat-abi=hard"}, Selected);
-  EXPECT_EQ("/h", Selected.gccSuffix());
+  EXPECT_EQ("/h", Selected.back().gccSuffix());
 }
 
 TEST(MultilibTest, SelectFloatABIReversed) {
   // If soft is specified after softfp then softfp will never be
   // selected because soft is compatible with softfp and last wins.
   MultilibSet MS;
-  Multilib Selected;
+  llvm::SmallVector Selected;
   ASSERT_TRUE(parseYaml(MS, YAML_PREAMBLE R"(
 Variants:
 - Dir: h
@@ -469,11 +469,11 @@
   NoMatchFlags: [hasfp]
 )"));
   MS.select({"mfloat-abi=soft"}, Selected);
-  EXPECT_EQ("/s", Selected.gccSuffix());
+  EXPECT_EQ("/s", Selected.back().gccSuffix());
   MS.select({"mfloat-abi=softfp"}, Selected);
-  EXPECT_EQ("/s", Selected.gccSuffix());
+  EXPECT_EQ("/s", Selected.back().gccSuffix());
   MS.select({"mfloat-abi=hard"}, Selected);
-  EXPECT_EQ("/h", Selected.gccSuffix

[PATCH] D142986: Enable multilib.yaml in the BareMetal ToolChain

2023-03-14 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings added inline comments.



Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:184
+  SmallString<128> MultilibPath(SysRootDir);
+  llvm::sys::path::append(MultilibPath, MULTILIB_YAML_FILENAME);
+

phosek wrote:
> Rather than hardcoding the filename and the location, which is inflexible, 
> could we instead provide a command line option to specify the file to use?
I'm not opposed to that in principle but I'd rather leave that as an option for 
a future change. At this point, for LLVM Embedded Toolchain for Arm our intent 
is that users will specify `--sysroot` if they want to use a separate set of 
multilibs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142986

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


[PATCH] D142986: Enable multilib.yaml in the BareMetal ToolChain

2023-03-14 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 505286.
michaelplatings added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142986

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal-multilib.yaml
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/lit.local.cfg

Index: clang/test/Driver/lit.local.cfg
===
--- clang/test/Driver/lit.local.cfg
+++ clang/test/Driver/lit.local.cfg
@@ -1,7 +1,7 @@
 from lit.llvm import llvm_config
 
 config.suffixes = ['.c', '.cpp', '.cppm', '.h', '.m', '.mm', '.S', '.s', '.f90', '.F90', '.f95',
-   '.cu', '.rs', '.cl', '.clcpp', '.hip', '.hipi', '.hlsl']
+   '.cu', '.rs', '.cl', '.clcpp', '.hip', '.hipi', '.hlsl', '.yaml']
 config.substitutions = list(config.substitutions)
 config.substitutions.insert(0,
 ('%clang_cc1',
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -118,9 +118,9 @@
 // Verify that the bare metal driver does not include any host system paths:
 // CHECK-AARCH64-NO-HOST-INC: InstalledDir: [[INSTALLEDDIR:.+]]
 // CHECK-AARCH64-NO-HOST-INC: "-resource-dir" "[[RESOURCE:[^"]+]]"
-// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}aarch64-none-elf{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+[^"]*}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[RESOURCE]]{{[/\\]+}}include"
-// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}aarch64-none-elf{{[/\\]+}}include"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+[^"]*}}include"
 
 // RUN: %clang %s -### --target=riscv64-unknown-elf -o %t.out -L some/directory/user/asked/for \
 // RUN: --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
Index: clang/test/Driver/baremetal-multilib.yaml
===
--- /dev/null
+++ clang/test/Driver/baremetal-multilib.yaml
@@ -0,0 +1,142 @@
+# REQUIRES: shell
+# UNSUPPORTED: system-windows
+
+# RUN: rm -rf %T/baremetal_multilib
+# RUN: mkdir -p %T/baremetal_multilib/bin
+# RUN: mkdir -p %T/baremetal_multilib/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib
+# RUN: touch %T/baremetal_multilib/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib/libclang_rt.builtins.a
+# RUN: ln -s %clang %T/baremetal_multilib/bin/clang
+# RUN: ln -s %s %T/baremetal_multilib/lib/clang-runtimes/multilib.yaml
+
+# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \
+# RUN: --target=thumbv8m.main-none-eabihf --sysroot= \
+# RUN:   | FileCheck -DSYSROOT=%T/baremetal_multilib %s
+# CHECK:  "-cc1" "-triple" "thumbv8m.main-none-unknown-eabihf"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/include/c++/v1"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/include"
+# CHECK-SAME: "-x" "c++" "{{.*}}baremetal-multilib.yaml"
+# CHECK-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
+# CHECK-SAME: "-L[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib"
+# CHECK-SAME: "-lc" "-lm" "-lclang_rt.builtins"
+# CHECK-SAME: "-o" "{{.*}}.tmp.out"
+
+# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \
+# RUN: --target=thumbv8m.main-none-eabihf --sysroot= \
+# RUN:   | FileCheck --check-prefix=CHECK-PRINT-MULTI-DIRECTORY %s
+# CHECK-PRINT-MULTI-DIRECTORY: arm-none-eabi/thumb/v8-m.main/fp
+
+# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -print-multi-lib 2>&1 \
+# RUN: --target=arm-none-eabi --sysroot= \
+# RUN:   | FileCheck --check-prefix=CHECK-PRINT-MULTI-LIB %s
+# CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v6-m/nofp;@-target=thumbv6m-none-eabi@mfloat-abi=soft
+# CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v7-m/nofp;@-target=thumbv7m-none-eabi@mfloat-abi=soft
+# CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v7e-m/nofp;@-target=thumbv7em-none-eabi@mfloat-abi=soft@mfpu=none
+# CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8-m.main/nofp;@-target=arm-none-eabi@mfloat-abi=soft@march=armv8m.main+nofp
+# CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8.1-m.main/nofp/nomve;@-target=arm-none-eabi@mfloat-abi=soft@march=armv8.1m.main+nofp+nomve

[PATCH] D143587: [Docs] Multilib design

2023-03-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: clang/docs/Multilib.rst:241
+
+multilib.yaml and -print-multi-selection-flags-experimental are new interfaces
+to Clang. In order for them to be usable over time and across LLVM versions

Add quotes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143587

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


[PATCH] D142933: Add -print-multi-selection-flags-experimental option

2023-03-14 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 505284.
michaelplatings added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142933

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/test/Driver/print-multi-selection-flags.c

Index: clang/test/Driver/print-multi-selection-flags.c
===
--- /dev/null
+++ clang/test/Driver/print-multi-selection-flags.c
@@ -0,0 +1,54 @@
+// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-linux -fc++-abi=itanium -fsanitize=address | FileCheck --check-prefix=CHECK-LINUX %s
+// CHECK-LINUX: fc++-abi=itanium
+// CHECK-LINUX: fexceptions
+// CHECK-LINUX: frtti
+// CHECK-LINUX: fsanitize=address
+// CHECK-LINUX: target=aarch64-unknown-linux
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-fuchsia -fsanitize=hwaddress | FileCheck --check-prefix=CHECK-FUCHSIA %s
+// CHECK-FUCHSIA: fsanitize=hwaddress
+// CHECK-FUCHSIA: target=aarch64-unknown-fuchsia
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -mfloat-abi=soft -fno-exceptions -fno-rtti | FileCheck --check-prefix=CHECK-ARMV4T %s
+// CHECK-ARMV4T: fno-exceptions
+// CHECK-ARMV4T: fno-rtti
+// CHECK-ARMV4T: mfloat-abi=soft
+// CHECK-ARMV4T: mfpu=none
+// CHECK-ARMV4T: target=armv4t-none-unknown-eabi
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=armv7em-none-eabi -mfloat-abi=softfp | FileCheck --check-prefix=CHECK-SOFTFP %s
+// CHECK-SOFTFP: mfloat-abi=softfp
+// CHECK-SOFTFP: mfpu=fpv4-sp-d16
+// CHECK-SOFTFP: target=thumbv7em-none-unknown-eabi
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabihf -march=armv7em -mfpu=fpv5-d16 | FileCheck --check-prefix=CHECK-HARD %s
+// CHECK-HARD: mfloat-abi=hard
+// CHECK-HARD: mfpu=fpv5-d16
+// CHECK-HARD: target=thumbv7em-none-unknown-eabihf
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -mfloat-abi=soft -march=armv8-m.main+nofp | FileCheck --check-prefix=CHECK-V8MMAIN-NOFP %s
+// CHECK-V8MMAIN-NOFP: mfloat-abi=soft
+// CHECK-V8MMAIN-NOFP: mfpu=none
+// CHECK-V8MMAIN-NOFP: target=thumbv8m.main-none-unknown-eabi
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -mfloat-abi=hard -march=armv8.1m.main+mve.fp | FileCheck --check-prefix=CHECK-MVE %s
+// CHECK-MVE: march=+mve
+// CHECK-MVE: march=+mve.fp
+// CHECK-MVE: mfloat-abi=hard
+// CHECK-MVE: mfpu=fp-armv8-fullfp16-sp-d16
+// CHECK-MVE: target=thumbv8.1m.main-none-unknown-eabihf
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -march=armv8.1m.main+mve+nofp | FileCheck --check-prefix=CHECK-MVENOFP %s
+// CHECK-MVENOFP: march=+mve
+// CHECK-MVENOFP-NOT: march=+mve.fp
+// CHECK-MVENOFP: mfpu=none
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-none-elf -march=armv8-a+lse | FileCheck --check-prefix=CHECK-LSE %s
+// CHECK-LSE: march=+lse
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-none-elf -march=armv8.5-a+sve+sve2 | FileCheck --check-prefix=CHECK-SVE2 %s
+// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-none-elf -march=armv9-a| FileCheck --check-prefix=CHECK-SVE2 %s
+// CHECK-SVE2: march=+simd
+// CHECK-SVE2: march=+sve
+// CHECK-SVE2: march=+sve2
+// CHECK-SVE2: target=aarch64-none-unknown-elf
Index: clang/lib/Driver/ToolChains/Arch/ARM.h
===
--- clang/lib/Driver/ToolChains/Arch/ARM.h
+++ clang/lib/Driver/ToolChains/Arch/ARM.h
@@ -63,9 +63,11 @@
 void getARMArchCPUFromArgs(const llvm::opt::ArgList &Args,
llvm::StringRef &Arch, llvm::StringRef &CPU,
bool FromAs = false);
+// Optionally returns the FPUKind
 void getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
-  std::vector &Features, bool ForAS);
+  std::vector &Features, bool ForAS,
+  unsigned *OutFPUKind = nullptr);
 int getARMSubArchVersionNumber(const llvm::Triple &Triple);
 bool isARMMProfile(const llvm::Triple &Triple);
 bool isARMAProfile(const llvm::Triple &Triple);
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -437,7 +437,8 @@
 
 void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args,
- 

[PATCH] D142932: Multilib YAML parsing

2023-03-14 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 505283.
michaelplatings marked 2 inline comments as done.
michaelplatings added a comment.

Decouple multilib versioning scheme from the Clang version


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142932

Files:
  clang/include/clang/Driver/Multilib.h
  clang/lib/Driver/Multilib.cpp
  clang/unittests/Driver/MultilibTest.cpp

Index: clang/unittests/Driver/MultilibTest.cpp
===
--- clang/unittests/Driver/MultilibTest.cpp
+++ clang/unittests/Driver/MultilibTest.cpp
@@ -13,6 +13,7 @@
 #include "clang/Driver/Multilib.h"
 #include "../../lib/Driver/ToolChains/CommonArgs.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/Version.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -187,3 +188,392 @@
   EXPECT_EQ("/a", Selection[0].gccSuffix());
   EXPECT_EQ("/b", Selection[1].gccSuffix());
 }
+
+static void diagnosticCallback(const llvm::SMDiagnostic &D, void *Out) {
+  *reinterpret_cast(Out) = D.getMessage();
+}
+
+static bool parseYaml(MultilibSet &MS, std::string &Diagnostic,
+  const char *Data) {
+  return MS.parseYaml(llvm::MemoryBufferRef(Data, "TEST"), diagnosticCallback,
+  &Diagnostic);
+}
+
+static bool parseYaml(MultilibSet &MS, const char *Data) {
+  return MS.parseYaml(llvm::MemoryBufferRef(Data, "TEST"));
+}
+
+// When updating this version also update MultilibVersionCurrent in Multilib.cpp
+#define YAML_PREAMBLE "MultilibVersion: 1.0\n"
+
+TEST(MultilibTest, ParseInvalid) {
+  std::string Diagnostic;
+
+  MultilibSet MS;
+
+  EXPECT_FALSE(parseYaml(MS, Diagnostic, R"(
+Variants: []
+)"));
+  EXPECT_TRUE(
+  StringRef(Diagnostic).contains("missing required key 'MultilibVersion'"))
+  << Diagnostic;
+
+  // Reject files with a different major version
+  EXPECT_FALSE(parseYaml(MS, Diagnostic,
+ R"(
+MultilibVersion: 2.0
+Variants: []
+)"));
+  EXPECT_TRUE(
+  StringRef(Diagnostic).contains("Multilib version 2.0 is unsupported"))
+  << Diagnostic;
+  EXPECT_FALSE(parseYaml(MS, Diagnostic,
+ R"(
+MultilibVersion: 0.1
+Variants: []
+)"));
+  EXPECT_TRUE(
+  StringRef(Diagnostic).contains("Multilib version 0.1 is unsupported"))
+  << Diagnostic;
+
+  // Reject files with a later minor version
+  EXPECT_FALSE(parseYaml(MS, Diagnostic,
+ R"(
+MultilibVersion: 1.9
+Variants: []
+)"));
+  EXPECT_TRUE(
+  StringRef(Diagnostic).contains("Multilib version 1.9 is unsupported"))
+  << Diagnostic;
+
+  // Accept files with the same major version and the same or earlier minor
+  // version
+  EXPECT_TRUE(parseYaml(MS, Diagnostic, R"(
+MultilibVersion: 1.0
+Variants: []
+)")) << Diagnostic;
+
+  EXPECT_FALSE(parseYaml(MS, Diagnostic, YAML_PREAMBLE));
+  EXPECT_TRUE(StringRef(Diagnostic).contains("missing required key 'Variants'"))
+  << Diagnostic;
+
+  EXPECT_FALSE(parseYaml(MS, Diagnostic, YAML_PREAMBLE R"(
+Variants:
+- Dir: /abc
+  Flags: []
+  PrintOptions: []
+)"));
+  EXPECT_TRUE(StringRef(Diagnostic).contains("paths must be relative"))
+  << Diagnostic;
+
+  EXPECT_FALSE(parseYaml(MS, Diagnostic, YAML_PREAMBLE R"(
+Variants:
+- Flags: []
+  PrintOptions: []
+)"));
+  EXPECT_TRUE(StringRef(Diagnostic).contains("missing required key 'Dir'"))
+  << Diagnostic;
+
+  EXPECT_FALSE(parseYaml(MS, Diagnostic, YAML_PREAMBLE R"(
+Variants:
+- Dir: .
+  PrintOptions: []
+)"));
+  EXPECT_TRUE(StringRef(Diagnostic).contains("missing required key 'Flags'"))
+  << Diagnostic;
+
+  EXPECT_FALSE(parseYaml(MS, Diagnostic, YAML_PREAMBLE R"(
+Variants:
+- Dir: .
+  Flags: []
+)"));
+  EXPECT_TRUE(
+  StringRef(Diagnostic).contains("missing required key 'PrintOptions'"))
+  << Diagnostic;
+
+  EXPECT_FALSE(parseYaml(MS, Diagnostic, YAML_PREAMBLE R"(
+Variants: []
+FlagMap:
+- Regex: abc
+)"));
+  EXPECT_TRUE(
+  StringRef(Diagnostic)
+  .contains("value required for 'MatchFlags' or 'NoMatchFlags'"))
+  << Diagnostic;
+
+  EXPECT_FALSE(parseYaml(MS, Diagnostic, YAML_PREAMBLE R"(
+Variants: []
+FlagMap:
+- Dir: .
+  Regex: '('
+  PrintOptions: []
+)"));
+  EXPECT_TRUE(StringRef(Diagnostic).contains("parentheses not balanced"))
+  << Diagnostic;
+}
+
+TEST(MultilibTest, Parse) {
+  MultilibSet MS;
+  EXPECT_TRUE(parseYaml(MS, YAML_PREAMBLE R"(
+Variants:
+- Dir: .
+  Flags: []
+  PrintOptions: []
+)"));
+  EXPECT_EQ(1U, MS.size());
+  EXPECT_EQ("", MS.begin()->gccSuffix());
+
+  EXPECT_TRUE(parseYaml(MS, YAML_PREAMBLE R"(
+Variants:
+- Dir: abc
+  Flags: []
+  PrintOptions: []
+)"));
+  EXPECT_EQ(1U, MS.size());
+  EXPECT_EQ("/abc", MS.begin()->gccSuffix());
+
+  EXPECT_TRUE(parseYaml(MS, YAML_PREAMBLE R"(
+Variants:
+- Dir: pqr
+  Flags: []
+  PrintOptions: [-mfloat-abi=soft]
+)"));
+  EXPECT_EQ

[PATCH] D142905: [Driver] Change multilib selection algorithm

2023-03-14 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 505279.
michaelplatings marked an inline comment as done.
michaelplatings added a comment.

Calculate the output for -print-multi-lib lazily.
This necessitated returning to using std::vector to store flags to avoid 
reordering them.
In theory the big-O time to select a multilib is larger now but in practise the 
number of flags is small enough that in practice this is about 2 microseconds 
faster per clang invocation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142905

Files:
  clang/include/clang/Driver/Multilib.h
  clang/include/clang/Driver/MultilibBuilder.h
  clang/lib/Driver/Multilib.cpp
  clang/lib/Driver/MultilibBuilder.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/unittests/Driver/MultilibBuilderTest.cpp
  clang/unittests/Driver/MultilibTest.cpp

Index: clang/unittests/Driver/MultilibTest.cpp
===
--- clang/unittests/Driver/MultilibTest.cpp
+++ clang/unittests/Driver/MultilibTest.cpp
@@ -33,14 +33,14 @@
 }
 
 TEST(MultilibTest, OpEqReflexivity3) {
-  Multilib M1({}, {}, {}, 0, {"+foo"});
-  Multilib M2({}, {}, {}, 0, {"+foo"});
+  Multilib M1({}, {}, {}, {"+foo"});
+  Multilib M2({}, {}, {}, {"+foo"});
   ASSERT_TRUE(M1 == M2) << "Multilibs with the same flag should be the same";
 }
 
 TEST(MultilibTest, OpEqInequivalence1) {
-  Multilib M1({}, {}, {}, 0, {"+foo"});
-  Multilib M2({}, {}, {}, 0, {"-foo"});
+  Multilib M1({}, {}, {}, {"+foo"});
+  Multilib M2({}, {}, {}, {"-foo"});
   ASSERT_FALSE(M1 == M2) << "Multilibs with conflicting flags are not the same";
   ASSERT_FALSE(M2 == M1)
   << "Multilibs with conflicting flags are not the same (commuted)";
@@ -48,7 +48,7 @@
 
 TEST(MultilibTest, OpEqInequivalence2) {
   Multilib M1;
-  Multilib M2({}, {}, {}, 0, {"+foo"});
+  Multilib M2({}, {}, {}, {"+foo"});
   ASSERT_FALSE(M1 == M2) << "Flags make Multilibs different";
 }
 
@@ -124,7 +124,7 @@
 }
 
 TEST(MultilibTest, Construction3) {
-  Multilib M({}, {}, {}, 0, {"+f1", "+f2", "-f3"});
+  Multilib M({}, {}, {}, {"+f1", "+f2", "-f3"});
   for (Multilib::flags_list::const_iterator I = M.flags().begin(),
 E = M.flags().end();
I != E; ++I) {
@@ -149,8 +149,8 @@
 
 TEST(MultilibTest, SetPriority) {
   MultilibSet MS({
-  Multilib("/foo", {}, {}, 1, {"+foo"}),
-  Multilib("/bar", {}, {}, 2, {"+bar"}),
+  Multilib("/foo", {}, {}, {"+foo"}),
+  Multilib("/bar", {}, {}, {"+bar"}),
   });
   Multilib::flags_list Flags1 = {"+foo", "-bar"};
   Multilib Selection1;
@@ -166,3 +166,24 @@
   ASSERT_TRUE(Selection2.gccSuffix() == "/bar")
   << "Selection picked " << Selection2 << " which was not expected";
 }
+
+TEST(MultilibTest, SelectMultiple) {
+  MultilibSet MS({
+  Multilib("/a", {}, {}, {"x"}),
+  Multilib("/b", {}, {}, {"y"}),
+  });
+  std::vector Selection;
+
+  Selection = MS.select({"x"});
+  ASSERT_EQ(1u, Selection.size());
+  EXPECT_EQ("/a", Selection[0].gccSuffix());
+
+  Selection = MS.select({"y"});
+  ASSERT_EQ(1u, Selection.size());
+  EXPECT_EQ("/b", Selection[0].gccSuffix());
+
+  Selection = MS.select({"y", "x"});
+  ASSERT_EQ(2u, Selection.size());
+  EXPECT_EQ("/a", Selection[0].gccSuffix());
+  EXPECT_EQ("/b", Selection[1].gccSuffix());
+}
Index: clang/unittests/Driver/MultilibBuilderTest.cpp
===
--- clang/unittests/Driver/MultilibBuilderTest.cpp
+++ clang/unittests/Driver/MultilibBuilderTest.cpp
@@ -207,3 +207,14 @@
 << "Selection picked " << Selection << " which was not expected ";
   }
 }
+
+TEST(MultilibBuilderTest, PrintOptions) {
+  Multilib M = MultilibBuilder()
+   .flag("+x")
+   .flag("-y")
+   .flag("+a")
+   .flag("-b")
+   .flag("+c")
+   .makeMultilib();
+  ASSERT_EQ(Multilib::flags_list({"-x", "-a", "-c"}), M.getPrintOptions());
+}
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -263,33 +263,33 @@
 
   Multilibs.push_back(Multilib());
   // Use the noexcept variant with -fno-exceptions to avoid the extra overhead.
-  Multilibs.push_back(MultilibBuilder("noexcept", {}, {}, 1)
+  Multilibs.push_back(MultilibBuilder("noexcept", {}, {})
   .flag("-fexceptions")
   .flag("+fno-exceptions")
   .makeMultilib());
   // ASan has higher priority because we always want the instrumentated version.
-  Multilibs.push_back(MultilibBuilder("asan", {}, {}, 2)
+  Multilibs.push_back(MultilibBuilder("asan", {}, {})
   .flag("+fsanitize=address")
   .makeMultilib());
  

[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-03-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 505274.
arsenm marked an inline comment as done.
arsenm added a comment.

Update doxygen comment


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

https://reviews.llvm.org/D142907

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/denormalfpmode-f32.c
  clang/test/CodeGen/denormalfpmode.c
  clang/test/CodeGenCUDA/Inputs/ocml-sample.cl
  clang/test/CodeGenCUDA/link-builtin-bitcode-denormal-fp-mode.cu
  clang/test/Driver/denormal-fp-math.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/ADT/FloatingPointMode.h
  llvm/include/llvm/Analysis/ConstantFolding.h
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/Function.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/Target/AMDGPU/SIModeRegisterDefaults.h
  llvm/test/CodeGen/Generic/denormal-fp-math-cl-opt.ll
  llvm/test/CodeGen/X86/sqrt-fastmath.ll
  llvm/test/Transforms/Inline/AMDGPU/inline-denormal-fp-math.ll
  llvm/test/Transforms/InstSimplify/canonicalize.ll
  llvm/test/Transforms/InstSimplify/constant-fold-fp-denormal.ll
  llvm/unittests/ADT/FloatingPointMode.cpp
  llvm/utils/TableGen/Attributes.cpp

Index: llvm/utils/TableGen/Attributes.cpp
===
--- llvm/utils/TableGen/Attributes.cpp
+++ llvm/utils/TableGen/Attributes.cpp
@@ -55,6 +55,7 @@
   // Emit attribute enums in the same order llvm::Attribute::operator< expects.
   Emit({"EnumAttr", "TypeAttr", "IntAttr"}, "ATTRIBUTE_ENUM");
   Emit({"StrBoolAttr"}, "ATTRIBUTE_STRBOOL");
+  Emit({"ComplexStrAttr"}, "ATTRIBUTE_COMPLEXSTR");
 
   OS << "#undef ATTRIBUTE_ALL\n";
   OS << "#endif\n\n";
Index: llvm/unittests/ADT/FloatingPointMode.cpp
===
--- llvm/unittests/ADT/FloatingPointMode.cpp
+++ llvm/unittests/ADT/FloatingPointMode.cpp
@@ -20,6 +20,8 @@
 parseDenormalFPAttributeComponent("preserve-sign"));
   EXPECT_EQ(DenormalMode::PositiveZero,
 parseDenormalFPAttributeComponent("positive-zero"));
+  EXPECT_EQ(DenormalMode::Dynamic,
+parseDenormalFPAttributeComponent("dynamic"));
   EXPECT_EQ(DenormalMode::Invalid, parseDenormalFPAttributeComponent("foo"));
 }
 
@@ -27,6 +29,7 @@
   EXPECT_EQ("ieee", denormalModeKindName(DenormalMode::IEEE));
   EXPECT_EQ("preserve-sign", denormalModeKindName(DenormalMode::PreserveSign));
   EXPECT_EQ("positive-zero", denormalModeKindName(DenormalMode::PositiveZero));
+  EXPECT_EQ("dynamic", denormalModeKindName(DenormalMode::Dynamic));
   EXPECT_EQ("", denormalModeKindName(DenormalMode::Invalid));
 }
 
@@ -54,6 +57,10 @@
   EXPECT_EQ(DenormalMode(DenormalMode::PositiveZero, DenormalMode::PositiveZero),
 parseDenormalFPAttribute("positive-zero,positive-zero"));
 
+  EXPECT_EQ(DenormalMode(DenormalMode::Dynamic, DenormalMode::Dynamic),
+parseDenormalFPAttribute("dynamic"));
+  EXPECT_EQ(DenormalMode(DenormalMode::Dynamic, DenormalMode::Dynamic),
+parseDenormalFPAttribute("dynamic,dynamic"));
 
   EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::PositiveZero),
 parseDenormalFPAttribute("ieee,positive-zero"));
@@ -65,6 +72,10 @@
   EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::PreserveSign),
 parseDenormalFPAttribute("ieee,preserve-sign"));
 
+  EXPECT_EQ(DenormalMode(DenormalMode::Dynamic, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("dynamic,preserve-sign"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::Dynamic),
+parseDenormalFPAttribute("preserve-sign,dynamic"));
 
   EXPECT_EQ(DenormalMode(DenormalMode::Invalid, DenormalMode::Invalid),
 parseDenormalFPAttribute("foo"));
@@ -102,6 +113,13 @@
   EXPECT_EQ(
 "preserve-sign,positive-zero",
 DenormalMode(DenormalMode::PreserveSign, DenormalMode::PositiveZero).str());
+
+  EXPECT_EQ("dynamic,dynamic",
+DenormalMode(DenormalMode::Dynamic, DenormalMode::Dynamic).str());
+  EXPECT_EQ("ieee,dynamic",
+DenormalMode(DenormalMode::IEEE, DenormalMode::Dynamic).str());
+  EXPECT_EQ("dynamic,ieee",
+DenormalMode(DenormalMode::Dynamic, DenormalMode::IEEE).str());
 }
 
 TEST(FloatingPointModeTest, DenormalModeIsSimple) {
@@ -110,6 +128,10 @@
 DenormalMode::Invalid).isSimple());
   EXPECT_FALSE(DenormalMode(DenormalMode::PreserveSign,
 DenormalMode::PositiveZero).isSimple());
+  EXPECT_FALSE(DenormalMode(DenormalMode::PreserveSign, DenormalMode::Dynamic)
+   .isSimple());
+  EXPECT_FALSE(DenormalMode(DenormalMode::Dynamic, DenormalMode::PreserveSign)
+   .isSimple());
 }
 
 TEST(FloatingPointModeTest, DenormalModeIsValid) {

[PATCH] D145883: [Flang][RISCV] Emit target features for RISC-V

2023-03-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:108
   case llvm::Triple::aarch64:
 [[fallthrough]];
+  case llvm::Triple::riscv64:

Remove `[[fallthrough]]` and just list the 3 `case` consecutively.



Comment at: flang/test/Driver/target-cpu-features-invalid.f90:6
+! RUN: %flang_fc1 -triple aarch64-linux-gnu -target-cpu supercpu \
+! RUN: -o /dev/null -S %s 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID-CPU
+

`! RUN:   -o`
For other subprojects, we prefer to indent continuation lines. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145883

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


[PATCH] D145591: [clang][HIP][OpenMP] Add warning if mixed HIP / OpenMP offloading

2023-03-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8634
+def warn_hip_omp_target_directives : Warning<
+  "HIP does not support OpenMP target directives; directive has been ignored">,
+  InGroup;

yaxunl wrote:
> jdoerfert wrote:
> > mhalk wrote:
> > > jdoerfert wrote:
> > > > I doubt the ignored part very much.
> > > I just re-checked the LLVM IR of an example.
> > > With -x c++ there are __kmpc_target_(de)init calls; with -x hip there are 
> > > none.
> > > https://godbolt.org/z/fhds46Pvc
> > > 
> > > From my point of view, "effectively", target directives seem to have been 
> > > ignored.
> > > Maybe this is a coincidence (there's definitely some uncertainty) or I am 
> > > misinterpreting the IR.
> > > I would be glad if you could shed some light on this, if possible / you 
> > > find the time to do so.
> > Line 512 in the HIP output: https://godbolt.org/z/n5s5jz7j9.
> If I remove --offload-arch for the C++ program, I got the same result as for 
> HIP:
> 
> https://godbolt.org/z/4TMzxdfj6
> 
> Does that mean we should emit the same error for C++ too?
I honestly do not follow your logic.

As I said in the beginning: I doubt the directive is ignored.

My link showed you that it doesn't ignore the pragma, e.g., the code w/ and w/o 
the pragma have different results.
This is also true for C++, but that doesn't make the warning any more accurate.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145591

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


[PATCH] D146090: [Clang] Updating handling of defaulted comparison operators to reflect changes from P2448R2

2023-03-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Please also update the P2448  row in 
cxx_status.html and add release notes.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9410-9421
+def ext_incorrect_defaulted_comparison_constexpr : Extension<
   "defaulted definition of %select{%sub{select_defaulted_comparison_kind}1|"
   "three-way comparison operator}0 "
-  "cannot be declared %select{constexpr|consteval}2 because "
+  "declared %select{constexpr|consteval}2 but "
   "%select{it|the corresponding implicit 'operator=='}0 "
-  "invokes a non-constexpr comparison function">;
+  "invokes a non-constexpr comparison function are a C++2b extension">, 
InGroup;
+def warn_cxx2b_incorrect_defaulted_comparison_constexpr : Warning<

The grammar of these diagnostics looks a bit peculiar. Suggested an 
alternative, but it's still a bit awkward ("...but for which..."), maybe you 
can find something better.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9416
+  "invokes a non-constexpr comparison function are a C++2b extension">, 
InGroup;
+def warn_cxx2b_incorrect_defaulted_comparison_constexpr : Warning<
+  "defaulted definition of %select{%sub{select_defaulted_comparison_kind}1|"

We usually spell these `CXXabCompat` diagnostics `warn_cxxab_compat_...`



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:8799-8806
   // C++2a [dcl.fct.def.default]p3 [P2002R0]:
   //   An explicitly-defaulted function that is not defined as deleted may be
   //   declared constexpr or consteval only if it is constexpr-compatible.
   // C++2a [class.compare.default]p3 [P2002R0]:
   //   A defaulted comparison function is constexpr-compatible if it satisfies
   //   the requirements for a constexpr function [...]
   // The only relevant requirements are that the parameter and return types are

Would be good to mention the change in C++23 here.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:8808-8809
   if (FD->isConstexpr()) {
 if (CheckConstexprReturnType(*this, FD, CheckConstexprKind::Diagnose) &&
 CheckConstexprParameterTypes(*this, FD, CheckConstexprKind::Diagnose) 
&&
 !Info.Constexpr) {

We'll also be getting diagnostics here if the parameter and return types are 
not literal types. You can pass `...::CheckValid` instead of `...::Diagnose` to 
find out if there would be an error, but we should probably instead make the 
`CheckConstexpr...` functions produce warnings (`ExtWarn` prior to C++23) 
rather than errors in general. That's a much larger change, though -- there's 
probably half a dozen diagnostics in the `CheckConstexpr*` functions that will 
need to be updated to properly support P2448R2. If you just want to implement 
this one part of P2448 for now and leave the rest for a later change, that 
seems fine to me.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:8813
+ (getLangOpts().CPlusPlus2b ? 
diag::warn_cxx2b_incorrect_defaulted_comparison_constexpr :
+
diag::ext_incorrect_defaulted_comparison_constexpr ))
   << FD->isImplicit() << (int)DCK << FD->isConsteval();

Don't need the parens around this. This layout is a little unusual, what does 
clang-format do here?



Comment at: clang/test/CXX/class/class.compare/class.compare.default/p3.cpp:132
   A b;
-  friend constexpr bool operator==(const E&, const E&) = default; // 
expected-error {{cannot be declared constexpr because it invokes a 
non-constexpr comparison function}}
+  friend constexpr bool operator==(const E&, const E&) = default;
   friend constexpr bool operator!=(const E&, const E&) = default;

Can we test these both ways, like you did in p4?


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

https://reviews.llvm.org/D146090

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


[PATCH] D146042: [clang-format] Fix numerous issues with "LambdaBodyIndentation: OuterScope" option

2023-03-14 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 updated this revision to Diff 505264.
jp4a50 added a comment.

Add new code sample to demonstrate behaviour of "LambdaBodyIndentation: 
OuterScope"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146042

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -21914,60 +21914,61 @@
LLVMWithBeforeLambdaBody);
 
   // Lambdas with different indentation styles.
-  Style = getLLVMStyleWithColumns(100);
-  EXPECT_EQ("SomeResult doSomething(SomeObject promise) {\n"
-"  return promise.then(\n"
-"  [this, &someVariable, someObject = "
-"std::mv(s)](std::vector evaluated) mutable {\n"
-"return someObject.startAsyncAction().then(\n"
-"[this, &someVariable](AsyncActionResult result) "
-"mutable { result.processMore(); });\n"
-"  });\n"
-"}\n",
-format("SomeResult doSomething(SomeObject promise) {\n"
-   "  return promise.then([this, &someVariable, someObject = "
-   "std::mv(s)](std::vector evaluated) mutable {\n"
-   "return someObject.startAsyncAction().then([this, "
-   "&someVariable](AsyncActionResult result) mutable {\n"
-   "  result.processMore();\n"
-   "});\n"
-   "  });\n"
-   "}\n",
-   Style));
+  Style = getLLVMStyleWithColumns(60);
+  verifyFormat("Result doSomething(Promise promise) {\n"
+   "  return promise.then(\n"
+   "  [this, obj = std::move(s)](int evaluated) mutable {\n"
+   "return someObject.startAsyncAction().then(\n"
+   "[this, &obj](Result result) mutable {\n"
+   "  result.processMore();\n"
+   "});\n"
+   "  });\n"
+   "}\n",
+   Style);
   Style.LambdaBodyIndentation = FormatStyle::LBI_OuterScope;
-  verifyFormat("test() {\n"
-   "  ([]() -> {\n"
+  verifyFormat("Result doSomething(Promise promise) {\n"
+   "  return promise.then(\n"
+   "  [this, obj = std::move(s)](int bar) mutable {\n"
+   "return obj.startAsyncAction().then(\n"
+   "[this, &obj](Result result) mutable {\n"
+   "  result.processMore();\n"
+   "});\n"
+   "  });\n"
+   "}\n",
+   Style);
+  verifyFormat("void test() {\n"
+   "  ([]() -> auto {\n"
"int b = 32;\n"
"return 3;\n"
"  }).foo();\n"
"}",
Style);
-  verifyFormat("test() {\n"
-   "  []() -> {\n"
+  verifyFormat("void test() {\n"
+   "  []() -> auto {\n"
"int b = 32;\n"
"return 3;\n"
"  }\n"
"}",
Style);
-  verifyFormat("std::sort(v.begin(), v.end(),\n"
-   "  [](const auto &someLongArgumentName, const auto "
-   "&someOtherLongArgumentName) {\n"
-   "  return someLongArgumentName.someMemberVariable < "
-   "someOtherLongArgumentName.someMemberVariable;\n"
-   "});",
+  verifyFormat("void test() {\n"
+   "  std::sort(v.begin(), v.end(),\n"
+   "[](const auto &foo, const auto &bar) {\n"
+   "return foo.baz < bar.baz;\n"
+   "  });\n"
+   "}\n",
Style);
-  verifyFormat("test() {\n"
+  verifyFormat("void test() {\n"
"  (\n"
-   "  []() -> {\n"
-   "int b = 32;\n"
-   "return 3;\n"
-   "  },\n"
+   "  []() -> auto {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  },\n"
"  foo, bar)\n"
"  .foo();\n"
"}",
Style);
-  verifyFormat("test() {\n"
-   "  ([]() -> {\n"
+  verifyFormat("void test() {\n"
+   "  ([]() -> auto {\n"
"int b = 32;\n"
"return 3;\n"
"  })\n"
@@ -21975,54 +21976,82 @@
"  .bar();\n"
"}",
Style);
-  EXPECT_EQ("SomeResult doSomething(SomeObject promise) {\n"
-"  return promise.then(\n"
-"  [this, &someVaria

[PATCH] D145999: [RISCV] Reserve X18 by default for Android

2023-03-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: clang/test/Driver/riscv-fixed-x-register.c:343
+
+// Check that x18 is reserved on Android by default
+// RUN: %clang --target=riscv64-linux-android -### %s 2> %t

asb wrote:
> samitolvanen wrote:
> > This seems redundant. Isn't the LLVM codegen test sufficient here?
> I think testing that the `+reserve-x18` target feature is added by the 
> frontend probably has some value.
> 
> I think it would better match the rest of this file to just do 
> `--check-prefix=CHECK-FIXED-X18` (I _think_ that works, but it is the end of 
> the day so I may be missing something obvious...).
> 
> Please do try to remember to generate patches with full context (`-U99` 
> or similar).
I prefer shared CHECK prefixes `--check-prefix=CHECK-FIXED-X18` as well. We do 
that for many other tests.



Comment at: clang/test/Driver/riscv-fixed-x-register.c:343
+
+// Check that x18 is reserved on Android by default
+// RUN: %clang --target=riscv64-linux-android -### %s 2> %t

MaskRay wrote:
> asb wrote:
> > samitolvanen wrote:
> > > This seems redundant. Isn't the LLVM codegen test sufficient here?
> > I think testing that the `+reserve-x18` target feature is added by the 
> > frontend probably has some value.
> > 
> > I think it would better match the rest of this file to just do 
> > `--check-prefix=CHECK-FIXED-X18` (I _think_ that works, but it is the end 
> > of the day so I may be missing something obvious...).
> > 
> > Please do try to remember to generate patches with full context (`-U99` 
> > or similar).
> I prefer shared CHECK prefixes `--check-prefix=CHECK-FIXED-X18` as well. We 
> do that for many other tests.
`/// Check that x18 is reserved on Android by default.`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145999

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


[PATCH] D145820: [Clang][OpenMP] Insert alloca for kernel args at function entry block instead of the launch point.

2023-03-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG, make sure all tests pass, this one seems to fail according to build kite: 
OpenMP/target_map_codegen_hold.cpp




Comment at: clang/test/OpenMP/target_map_codegen_hold.cpp:211
+// CHECK-NOUSE-I386: @llvm.global_ctors = appending global [1 x { i32, ptr, 
ptr }] [{ i32, ptr, ptr } { i32 0, ptr @.omp_offloading.requires_reg, ptr null 
}]
+//.
 // CHECK-USE-PPC64LE-LABEL: define {{[^@]+}}@_Z20explicit_maps_singlei

The hash is hardcoded. I recommend removing this part and putting the old check 
lines in again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145820

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


[PATCH] D145715: Remove -lower-global-dtors-via-cxa-atexit flag

2023-03-14 Thread Julian Lettner 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 rGe6a789ef9bb2: Remove -lower-global-dtors-via-cxa-atexit flag 
(authored by yln).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145715

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/test/CodeGen/ARM/ctors_dtors.ll

Index: llvm/test/CodeGen/ARM/ctors_dtors.ll
===
--- llvm/test/CodeGen/ARM/ctors_dtors.ll
+++ llvm/test/CodeGen/ARM/ctors_dtors.ll
@@ -1,5 +1,4 @@
 ; RUN: llc < %s -mtriple=arm-apple-darwin  | FileCheck %s -check-prefix=DARWIN
-; RUN: llc < %s -mtriple=arm-apple-darwin -lower-global-dtors-via-cxa-atexit=false  | FileCheck %s -check-prefix=DARWIN-OLD
 ; RUN: llc < %s -mtriple=arm-linux-gnu -target-abi=apcs  | FileCheck %s -check-prefix=ELF
 ; RUN: llc < %s -mtriple=arm-linux-gnueabi | FileCheck %s -check-prefix=GNUEABI
 
@@ -8,9 +7,6 @@
 ; DARWIN: .section	__DATA,__mod_init_func,mod_init_funcs
 ; DARWIN-NOT: __mod_term_func
 
-; DARWIN-OLD: .section	__DATA,__mod_init_func,mod_init_funcs
-; DARWIN-OLD: .section	__DATA,__mod_term_func,mod_term_funcs
-
 ; ELF: .section .ctors,"aw",%progbits
 ; ELF: .section .dtors,"aw",%progbits
 
Index: llvm/lib/CodeGen/TargetPassConfig.cpp
===
--- llvm/lib/CodeGen/TargetPassConfig.cpp
+++ llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -878,8 +878,7 @@
 
   // For MachO, lower @llvm.global_dtors into @llvm.global_ctors with
   // __cxa_atexit() calls to avoid emitting the deprecated __mod_term_func.
-  if (TM->getTargetTriple().isOSBinFormatMachO() &&
-  TM->Options.LowerGlobalDtorsViaCxaAtExit)
+  if (TM->getTargetTriple().isOSBinFormatMachO())
 addPass(createLowerGlobalDtorsLegacyPass());
 
   // Make sure that no unreachable blocks are instruction selected.
Index: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===
--- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1202,11 +1202,7 @@
 
 MCSection *TargetLoweringObjectFileMachO::getStaticDtorSection(
 unsigned Priority, const MCSymbol *KeySym) const {
-  // TODO(yln): Remove -lower-global-dtors-via-cxa-atexit fallback flag
-  // (LowerGlobalDtorsViaCxaAtExit) and always issue a fatal error here.
-  if (TM->Options.LowerGlobalDtorsViaCxaAtExit)
-report_fatal_error("@llvm.global_dtors should have been lowered already");
-  return StaticDtorSection;
+  report_fatal_error("@llvm.global_dtors should have been lowered already");
 }
 
 void TargetLoweringObjectFileMachO::emitModuleMetadata(MCStreamer &Streamer,
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -81,7 +81,6 @@
 CGOPT(bool, StackRealign)
 CGOPT(std::string, TrapFuncName)
 CGOPT(bool, UseCtors)
-CGOPT(bool, LowerGlobalDtorsViaCxaAtExit)
 CGOPT(bool, RelaxELFRelocations)
 CGOPT_EXP(bool, DataSections)
 CGOPT_EXP(bool, FunctionSections)
@@ -349,12 +348,6 @@
 cl::init(false));
   CGBINDOPT(UseCtors);
 
-  static cl::opt LowerGlobalDtorsViaCxaAtExit(
-  "lower-global-dtors-via-cxa-atexit",
-  cl::desc("Lower llvm.global_dtors (global destructors) via __cxa_atexit"),
-  cl::init(true));
-  CGBINDOPT(LowerGlobalDtorsViaCxaAtExit);
-
   static cl::opt RelaxELFRelocations(
   "relax-elf-relocations",
   cl::desc(
@@ -538,7 +531,6 @@
   Options.GuaranteedTailCallOpt = getEnableGuaranteedTailCallOpt();
   Options.StackSymbolOrdering = getStackSymbolOrdering();
   Options.UseInitArray = !getUseCtors();
-  Options.LowerGlobalDtorsViaCxaAtExit = getLowerGlobalDtorsViaCxaAtExit();
   Options.RelaxELFRelocations = getRelaxELFRelocations();
   Options.DataSections =
   getExplicitDataSections().value_or(TheTriple.hasDefaultDataSections());
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -130,7 +130,7 @@
   HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
   EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
-  LowerGlobalDtorsViaCxaAtExit(false), DisableIntegratedAS(false),
+  DisableIntegratedAS(false),
   RelaxELFRelocations(true), FunctionSections

[clang] e6a789e - Remove -lower-global-dtors-via-cxa-atexit flag

2023-03-14 Thread Julian Lettner via cfe-commits

Author: Julian Lettner
Date: 2023-03-14T14:18:11-07:00
New Revision: e6a789ef9bb28222c91816a2cf00cfd6f706efd4

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

LOG: Remove -lower-global-dtors-via-cxa-atexit flag

Remove the `-lower-global-dtors-via-cxa-atexit` escape hatch introduced
in D121736 [1], which switched the default lowering of global
destructors on MachO to use `__cxa_atexit()` to avoid emitting
deprecated `__mod_term_func` sections.

I added this flag as an escape hatch in case the switch causes any
problems.  We didn't discover any problems so now we can remove it.

[1] https://reviews.llvm.org/D121736

rdar://90277838

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/CodeGen/CommandFlags.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/test/CodeGen/ARM/ctors_dtors.ll

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4a5d3f8199682..06e4cd23db7a4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -132,6 +132,9 @@ Removed Compiler Flags
   or higher to use standard C++ modules instead.
 - The deprecated flag `-fcoroutines-ts` is removed. Please use ``-std=c++20``
   or higher to use standard C++ coroutines instead.
+- The CodeGen flag `-lower-global-dtors-via-cxa-atexit` which affects how 
global
+  destructors are lowered for MachO is removed without replacement. The default
+  of `-lower-global-dtors-via-cxa-atexit=true` is now the only supported way.
 
 Attribute Changes in Clang
 --

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index b03d326dd0654..fffaeb8a6ff79 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -367,8 +367,6 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   Options.BinutilsVersion =
   llvm::TargetMachine::parseBinutilsVersion(CodeGenOpts.BinutilsVersion);
   Options.UseInitArray = CodeGenOpts.UseInitArray;
-  Options.LowerGlobalDtorsViaCxaAtExit =
-  CodeGenOpts.RegisterGlobalDtorsWithAtExit;
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
   Options.CompressDebugSections = CodeGenOpts.getCompressDebugSections();
   Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;

diff  --git a/llvm/include/llvm/CodeGen/CommandFlags.h 
b/llvm/include/llvm/CodeGen/CommandFlags.h
index 7b1ef60912f1a..475d87bdd5b13 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.h
+++ b/llvm/include/llvm/CodeGen/CommandFlags.h
@@ -94,8 +94,6 @@ std::string getTrapFuncName();
 
 bool getUseCtors();
 
-bool getLowerGlobalDtorsViaCxaAtExit();
-
 bool getRelaxELFRelocations();
 
 bool getDataSections();

diff  --git a/llvm/include/llvm/Target/TargetOptions.h 
b/llvm/include/llvm/Target/TargetOptions.h
index d8a4159189394..22e811653c6d4 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -130,7 +130,7 @@ namespace llvm {
   HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
   EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
-  LowerGlobalDtorsViaCxaAtExit(false), DisableIntegratedAS(false),
+  DisableIntegratedAS(false),
   RelaxELFRelocations(true), FunctionSections(false),
   DataSections(false), IgnoreXCOFFVisibility(false),
   XCOFFTracebackTable(true), UniqueSectionNames(true),
@@ -247,10 +247,6 @@ namespace llvm {
 /// constructors.
 unsigned UseInitArray : 1;
 
-/// Use __cxa_atexit to register global destructors; determines how
-/// llvm.global_dtors is lowered.
-unsigned LowerGlobalDtorsViaCxaAtExit : 1;
-
 /// Disable the integrated assembler.
 unsigned DisableIntegratedAS : 1;
 

diff  --git a/llvm/lib/CodeGen/CommandFlags.cpp 
b/llvm/lib/CodeGen/CommandFlags.cpp
index 73521ac46df45..51d259cea41b8 100644
--- a/llvm/lib/CodeGen/CommandFlags.cpp
+++ b/llvm/lib/CodeGen/CommandFlags.cpp
@@ -81,7 +81,6 @@ CGOPT(bool, StackSymbolOrdering)
 CGOPT(bool, StackRealign)
 CGOPT(std::string, TrapFuncName)
 CGOPT(bool, UseCtors)
-CGOPT(bool, LowerGlobalDtorsViaCxaAtExit)
 CGOPT(bool, RelaxELFRelocations)
 CGOPT_EXP(bool, DataSections)
 CGOPT_EXP(bool, FunctionSections)
@@ -349,12 +348,6 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
 cl::init(false));
   CGBINDOPT(UseCtors);
 
-  static cl::opt LowerGlobalDtorsViaCxaAtExit(
-

[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-14 Thread Jacob Lambert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe48ae0dbd80d: [clang-offload-bundler] Standardize TargetID 
field for bundler (authored by lamb-j).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145770

Files:
  clang/docs/ClangOffloadBundler.rst
  clang/lib/Driver/OffloadBundler.cpp
  clang/test/Driver/clang-offload-bundler-asserts-on.c
  clang/test/Driver/clang-offload-bundler-standardize.c
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -313,6 +313,8 @@
   llvm::DenseSet ParsedTargets;
   // Map {offload-kind}-{triple} to target IDs.
   std::map> TargetIDs;
+  // Standardize target names to include env field
+  std::vector StandardizedTargetNames;
   for (StringRef Target : TargetNames) {
 if (ParsedTargets.contains(Target)) {
   reportError(createStringError(errc::invalid_argument,
@@ -324,6 +326,8 @@
 bool KindIsValid = OffloadInfo.isOffloadKindValid();
 bool TripleIsValid = OffloadInfo.isTripleValid();
 
+StandardizedTargetNames.push_back(OffloadInfo.str());
+
 if (!KindIsValid || !TripleIsValid) {
   SmallVector Buf;
   raw_svector_ostream Msg(Buf);
@@ -348,6 +352,9 @@
 
 ++Index;
   }
+
+  BundlerConfig.TargetNames = StandardizedTargetNames;
+
   for (const auto &TargetID : TargetIDs) {
 if (auto ConflictingTID =
 clang::getConflictTargetIDCombination(TargetID.second)) {
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -1,5 +1,4 @@
 // REQUIRES: x86-registered-target
-// REQUIRES: powerpc-registered-target
 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
 
 //
@@ -297,11 +296,11 @@
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD
-// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD-INPUTS
-// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_

[clang] e48ae0d - [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-14 Thread Jacob Lambert via cfe-commits

Author: Jacob Lambert
Date: 2023-03-14T14:12:31-07:00
New Revision: e48ae0dbd80d58ce8eded9e55f0b1262d52517af

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

LOG: [clang-offload-bundler] Standardize TargetID field for bundler

The bundler accepts both of the following for the --target option:
  hip-amdgcn-amd-amdhsa-gfx900(no env field)
  hip-amdgcn-amd-amdhsa--gfx900   (blank env field)

The environment field is defined as optional for Triples
in Triple.h. However, in this patch we update the bundler to
internally standardize to include the env field. While users
aren't required to specify an env field when listing targets on
the commandline, bundles generated by the offload-bundler will
include the ABI field.

This standardization simplifies things for APIs that deal with
bundles generated by the clang-offload-bundler tool.

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

Added: 
clang/test/Driver/clang-offload-bundler-standardize.c

Modified: 
clang/docs/ClangOffloadBundler.rst
clang/lib/Driver/OffloadBundler.cpp
clang/test/Driver/clang-offload-bundler-asserts-on.c
clang/test/Driver/clang-offload-bundler.c
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Removed: 




diff  --git a/clang/docs/ClangOffloadBundler.rst 
b/clang/docs/ClangOffloadBundler.rst
index 997948a8217e5..52981d6e1dbce 100644
--- a/clang/docs/ClangOffloadBundler.rst
+++ b/clang/docs/ClangOffloadBundler.rst
@@ -174,7 +174,20 @@ Where:
   = 
==
 
 **target-triple**
-The target triple of the code object.
+The target triple of the code object. See `Target Triple
+.
+
+The bundler accepts target triples with or without the optional environment
+field:
+
+``--``, or
+``---``
+
+However, in order to standardize outputs for tools that consume bitcode
+bundles, bundles written by the bundler internally use only the 4-field
+target triple:
+
+``---``
 
 **target-id**
   The canonical target ID of the code object. Present only if the target

diff  --git a/clang/lib/Driver/OffloadBundler.cpp 
b/clang/lib/Driver/OffloadBundler.cpp
index 0145e0311145f..de7799f1435c8 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -72,12 +72,22 @@ OffloadTargetInfo::OffloadTargetInfo(const StringRef Target,
   if (clang::StringToCudaArch(TripleOrGPU.second) != clang::CudaArch::UNKNOWN) 
{
 auto KindTriple = TripleOrGPU.first.split('-');
 this->OffloadKind = KindTriple.first;
-this->Triple = llvm::Triple(KindTriple.second);
+
+// Enforce optional env field to standardize bundles
+llvm::Triple t = llvm::Triple(KindTriple.second);
+this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
+t.getOSName(), t.getEnvironmentName());
+
 this->TargetID = Target.substr(Target.find(TripleOrGPU.second));
   } else {
 auto KindTriple = TargetFeatures.first.split('-');
 this->OffloadKind = KindTriple.first;
-this->Triple = llvm::Triple(KindTriple.second);
+
+// Enforce optional env field to standardize bundles
+llvm::Triple t = llvm::Triple(KindTriple.second);
+this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
+t.getOSName(), t.getEnvironmentName());
+
 this->TargetID = "";
   }
 }

diff  --git a/clang/test/Driver/clang-offload-bundler-asserts-on.c 
b/clang/test/Driver/clang-offload-bundler-asserts-on.c
index aceda09f7bfa1..db99e31d568b9 100644
--- a/clang/test/Driver/clang-offload-bundler-asserts-on.c
+++ b/clang/test/Driver/clang-offload-bundler-asserts-on.c
@@ -21,12 +21,12 @@
 
 // Tests to check compatibility between Bundle Entry ID formats i.e. between 
presence/absence of extra hyphen in case of missing environment field
 // RUN: clang-offload-bundler -unbundle -type=a 
-targets=openmp-amdgcn-amd-amdhsa--gfx906,openmp-amdgcn-amd-amdhsa-gfx908 
-input=%t.input-archive.a -output=%t-archive-gfx906-simple.a 
-output=%t-archive-gfx908-simple.a -debug-only=CodeObjectCompatibility 2>&1 | 
FileCheck %s -check-prefix=BUNDLECOMPATIBILITY
-// BUNDLECOMPATIBILITY: Compatible: Exact match:[CodeObject: 
openmp-amdgcn-amd-amdhsa-gfx906]   :   [Target: 
openmp-amdgcn-amd-amdhsa--gfx906]
-// BUNDLECOMPATIBILITY: Compatible: Exact match:[CodeObject: 
openmp-amdgcn-amd-amdhsa--gfx908]  :   [Target: 
openmp-amdgcn-amd-amdhsa-gfx908]
+// BUNDLECOMPATIBILITY: Compatible: Exact match:[CodeObject: 
openmp-amdgcn-amd-amdhsa--gfx906]  :   [Target: 
openmp-amdgcn-amd-amdhsa--gfx906]
+// BUNDLECOMPATIBILITY: Compatible: Exact match: 

[PATCH] D146003: [StandardInstrumentations] Verify function doesn't change if analyses are preserved

2023-03-14 Thread Nikita Popov via Phabricator via cfe-commits
nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.

nontrivial-unswitch-markloopasdeleted.ll failure looks legit.




Comment at: llvm/lib/Passes/StandardInstrumentations.cpp:1127
+if (!PassPA.allAnalysesInSetPreserved>())
   return;
 

Hm, aren't we going to skip the CFG check below if only CFGAnalyses are 
preserved (but not AllAnalyses)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146003

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


[PATCH] D140275: [clangd] Tweak to add doxygen comment to the function declaration

2023-03-14 Thread Oleg Skoromnik via Phabricator via cfe-commits
tupos added a comment.

Hi,

sorry for the long delay, but actually in this particular moment I was working 
on addressing the comments.

Therefore, I will push the updated patch soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140275

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


[PATCH] D145150: clang: Emit nofpclass(nan inf) for -ffinite-math-only

2023-03-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 505253.
arsenm marked an inline comment as done.
arsenm added a comment.

Drop unnecessary part


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

https://reviews.llvm.org/D145150

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/complex-math.c
  clang/test/CodeGen/fp-function-attrs.cpp
  clang/test/CodeGen/fp-options-to-fast-math-flags.c
  clang/test/CodeGen/func-attr.c
  clang/test/CodeGen/matrix-type-operators-fast-math.c
  clang/test/CodeGen/nofpclass.c
  llvm/include/llvm/IR/Attributes.h
  llvm/lib/IR/Attributes.cpp
  llvm/test/Linker/Inputs/nofpclass.ll
  llvm/test/Linker/nofpclass.ll

Index: llvm/test/Linker/nofpclass.ll
===
--- /dev/null
+++ llvm/test/Linker/nofpclass.ll
@@ -0,0 +1,30 @@
+; RUN: llvm-link %s %S/Inputs/nofpclass.ll -S -o - | FileCheck -check-prefix=ORDER1 %s
+; RUN: llvm-link %S/Inputs/nofpclass.ll %s -S -o - | FileCheck -check-prefix=ORDER2 %s
+
+; Make sure nofpclass is dropped if the function was declared as
+; nofpclass, but not defined with nofpclass.
+
+; ORDER1: define float @caller(float %arg) {
+; ORDER1-NEXT: %result = call float @declared_as_nonan(float %arg)
+; ORDER1-NEXT: ret float %result
+
+; ORDER1: define float @declared_as_nonan(float %arg) {
+; ORDER1-NEXT: %add = fadd float %arg, 1.00e+00
+; ORDER1-NEXT: ret float %add
+
+
+; ORDER2: define float @declared_as_nonan(float %arg) {
+; ORDER2-NEXT: %add = fadd float %arg, 1.00e+00
+; ORDER2-NEXT: ret float %add
+
+; ORDER2: define float @caller(float %arg) {
+; ORDER2-NEXT: %result = call float @declared_as_nonan(float %arg)
+; ORDER2-NEXT: ret float %result
+
+
+declare nofpclass(nan) float @declared_as_nonan(float nofpclass(nan))
+
+define float @caller(float %arg) {
+  %result = call float @declared_as_nonan(float %arg)
+  ret float %result
+}
Index: llvm/test/Linker/Inputs/nofpclass.ll
===
--- /dev/null
+++ llvm/test/Linker/Inputs/nofpclass.ll
@@ -0,0 +1,4 @@
+define float @declared_as_nonan(float %arg) {
+  %add = fadd float %arg, 1.0
+  ret float %add
+}
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -266,16 +266,6 @@
   .Default(false);
 }
 
-/// Returns true if this is a type legal for the 'nofpclass' attribute. This
-/// follows the same type rules as FPMathOperator.
-///
-/// TODO: Consider relaxing to any FP type struct fields.
-static bool isNoFPClassCompatibleType(Type *Ty) {
-  while (ArrayType *ArrTy = dyn_cast(Ty))
-Ty = ArrTy->getElementType();
-  return Ty->isFPOrFPVectorTy();
-}
-
 //===--===//
 // Attribute Accessor Methods
 //===--===//
@@ -1850,6 +1840,9 @@
 }
 
 AttrBuilder &AttrBuilder::addNoFPClassAttr(FPClassTest Mask) {
+  if (Mask == fcNone)
+return *this;
+
   return addRawIntAttr(Attribute::NoFPClass, Mask);
 }
 
@@ -1935,6 +1928,16 @@
 // AttributeFuncs Function Defintions
 //===--===//
 
+/// Returns true if this is a type legal for the 'nofpclass' attribute. This
+/// follows the same type rules as FPMathOperator.
+///
+/// TODO: Consider relaxing to any FP type struct fields.
+bool AttributeFuncs::isNoFPClassCompatibleType(Type *Ty) {
+  while (ArrayType *ArrTy = dyn_cast(Ty))
+Ty = ArrTy->getElementType();
+  return Ty->isFPOrFPVectorTy();
+}
+
 /// Which attributes cannot be applied to a type.
 AttributeMask AttributeFuncs::typeIncompatible(Type *Ty,
AttributeSafetyKind ASK) {
Index: llvm/include/llvm/IR/Attributes.h
===
--- llvm/include/llvm/IR/Attributes.h
+++ llvm/include/llvm/IR/Attributes.h
@@ -1265,6 +1265,10 @@
   ASK_ALL = ASK_SAFE_TO_DROP | ASK_UNSAFE_TO_DROP,
 };
 
+/// Returns true if this is a type legal for the 'nofpclass' attribute. This
+/// follows the same type rules as FPMathOperator.
+bool isNoFPClassCompatibleType(Type *Ty);
+
 /// Which attributes cannot be applied to a type. The argument \p ASK indicates,
 /// if only attributes that are known to be safely droppable are contained in
 /// the mask; only attributes that might be unsafe to drop (e.g., ABI-related
Index: clang/test/CodeGen/nofpclass.c
===
--- clang/test/CodeGen/nofpclass.c
+++ clang/test/CodeGen/nofpclass.c
@@ -27,8 +27,8 @@
 
 
 // CFINITEONLY: Function Attrs: noinline nounwind optnone
-// CFINITEONLY-LABEL: define dso_local float @defined_func_f32
-// CFINITEONLY-SAME: (float noundef [[A:%.*]], float noundef [[B:%.*]], float noundef [[C:%.*]]) #[[ATTR0:[0-9]+]] {
+// CFINITEONLY-LABEL: defin

[PATCH] D142490: [Clang] Fix ClassifyImplicitMemberAccess to handle cases where the access in an unevaluated context is not within a CXXRecordDecl or CXXMethodDecl

2023-03-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/SemaCXX/statements.cpp:60-61
+int i;
+int j = ({i;}); // expected-error {{invalid use of non-static data member 
'i'}}
+// expected-error@-1 {{cannot initialize a member 
subobject of type 'int' with an rvalue of type 'void'}}
+   // expected-warning@-2 {{use of GNU statement expression 
extension}}

aaron.ballman wrote:
> This diagnostic isn't entirely unreasonable, but I think GCC gives a better 
> diagnostic: https://godbolt.org/z/T4dbhnoo7
Yeah, probably worth filing a bug for this after I land this.


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

https://reviews.llvm.org/D142490

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


[PATCH] D142490: [Clang] Fix ClassifyImplicitMemberAccess to handle cases where the access in an unevaluated context is not within a CXXRecordDecl or CXXMethodDecl

2023-03-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 505252.
shafik marked 2 inline comments as done.
shafik added a comment.

- Switched to using auto in two if statements
- Added Release notes


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

https://reviews.llvm.org/D142490

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
  clang/test/SemaCXX/statements.cpp


Index: clang/test/SemaCXX/statements.cpp
===
--- clang/test/SemaCXX/statements.cpp
+++ clang/test/SemaCXX/statements.cpp
@@ -52,3 +52,14 @@
   int a = test7(1);
   double b = test7(2.0);
 }
+
+namespace GH48405 {
+void foo() {
+  struct S {
+int i;
+int j = ({i;}); // expected-error {{invalid use of non-static data member 
'i'}}
+// expected-error@-1 {{cannot initialize a member 
subobject of type 'int' with an rvalue of type 'void'}}
+   // expected-warning@-2 {{use of GNU statement expression 
extension}}
+  };
+}
+}
Index: clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
===
--- clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
+++ clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
@@ -1026,3 +1026,11 @@
   void *v = x(f); // expected-error {{cannot initialize a variable of type 
'void *' with an rvalue of type 'int'}}
   void *w = y(f); // expected-error {{cannot initialize a variable of type 
'void *' with an rvalue of type 'int'}}
 }
+
+namespace GH37792 {
+struct A { int x; };
+
+void f() {
+  [](auto t) -> decltype(decltype(t)::x) { return 0; }(A());
+}
+}
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -161,10 +161,13 @@
   }
 
   CXXRecordDecl *contextClass;
-  if (CXXMethodDecl *MD = dyn_cast(DC))
+  if (auto *MD = dyn_cast(DC))
 contextClass = MD->getParent()->getCanonicalDecl();
-  else
+  else if (auto *RD = dyn_cast(DC))
 contextClass = cast(DC);
+  else
+return AbstractInstanceResult ? AbstractInstanceResult
+  : IMA_Error_StaticContext;
 
   // [class.mfct.non-static]p3:
   // ...is used in the body of a non-static member function of class X,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -199,6 +199,10 @@
   of `CWG2699 _` being accepted by WG21.
 - Fix crash when parsing fold expression containing a delayed typo correction.
   (`#61326 `_)
+- Fix crash when dealing with some member accesses outside of class or member
+  function context.
+  (`#37792 `_) and
+  (`#48405 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/statements.cpp
===
--- clang/test/SemaCXX/statements.cpp
+++ clang/test/SemaCXX/statements.cpp
@@ -52,3 +52,14 @@
   int a = test7(1);
   double b = test7(2.0);
 }
+
+namespace GH48405 {
+void foo() {
+  struct S {
+int i;
+int j = ({i;}); // expected-error {{invalid use of non-static data member 'i'}}
+// expected-error@-1 {{cannot initialize a member subobject of type 'int' with an rvalue of type 'void'}}
+		// expected-warning@-2 {{use of GNU statement expression extension}}
+  };
+}
+}
Index: clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
===
--- clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
+++ clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
@@ -1026,3 +1026,11 @@
   void *v = x(f); // expected-error {{cannot initialize a variable of type 'void *' with an rvalue of type 'int'}}
   void *w = y(f); // expected-error {{cannot initialize a variable of type 'void *' with an rvalue of type 'int'}}
 }
+
+namespace GH37792 {
+struct A { int x; };
+
+void f() {
+  [](auto t) -> decltype(decltype(t)::x) { return 0; }(A());
+}
+}
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -161,10 +161,13 @@
   }
 
   CXXRecordDecl *contextClass;
-  if (CXXMethodDecl *MD = dyn_cast(DC))
+  if (auto *MD = dyn_cast(DC))
 contextClass = MD->getParent()->getCanonicalDecl();
-  else
+  else if (auto *RD = dyn_cast(DC))
 contextClass = cast(DC);
+  else
+return AbstractInstanceResult ? AbstractInstanceResult
+  : IMA_Error_StaticContext;
 
   // [class.mfct.non-static]p3:
   // ...is used in the body of a non-static member function of class X,
Index: clang/

[PATCH] D145965: [C++20][Modules] Fix incorrect visibilities in implementation units.

2023-03-14 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

In D145965#4192051 , @iains wrote:

> 



> I was thinking at one stage to add an 'Implementation' module Kind, but at 
> the moment I do not think it is worth extending the size of the ModuleKind 
> enum bit field for this (since we now have used up all the entries with the 
> new 'ExplicitGlobalModuleFragment' case).  That also has a large impact also 
> for relatively few uses.

I have changed my mind here.
It seems that we are getting confusing decl context entries without having a 
proper module for the implementation (even though we will never write such a 
module to a PCM, since it is not importable).

I was wondering if it would be possible to avoid having separate values for 
PartitionInterface/Implementation (since they both have a BMI - it is only a 
question of whether that can be re-exported).  We would have to add one bit to 
the PCM to deal with that, so that we might as well extend the ModuleKind enum 
to 4 bits.

So .. please wait for one or two days, I will try to refresh the implementation 
patch (D126959 ) and see if that resolves 
some of the issues I am seeing with `P1815`

(this does not alter the situation that you are going to revisit the 
`isModuleUnitOfCurrentTU` if that is needed - but it might not be; since having 
a separate module for the impl. will avoid some of the ambiguities anyway).

Additional Note:  we also have a situation in the lookups for dependent names 
during template instantiation that the visibility of decls can need to be 
assessed in a different module context from the current module.  So that we 
might also need to have a `areTheseModulesFromTheSameTU(Module *A. Module *B)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145965

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


[PATCH] D146090: [Clang] Updating handling of defaulted comparison operators to reflect changes from P2448R2

2023-03-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: rsmith, aaron.ballman, erichkeane.
Herald added a project: All.
shafik requested review of this revision.

Prior to P2448R2  we were more aggressive in 
diagnosing ill-formed `constexpr` functions. Many of these restrictions were 
relaxed and now it is not required for defaulted comparison operators to call 
`constexpr` functions.

This behavior is extended to before C++23 and diagnostic for it's use can be 
enabled w/ `-pedantic` or `-Wc++2b-default-comp-relaxed-constexpr`

This fixes: https://github.com/llvm/llvm-project/issues/61238


https://reviews.llvm.org/D146090

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p3.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p4.cpp

Index: clang/test/CXX/class/class.compare/class.compare.default/p4.cpp
===
--- clang/test/CXX/class/class.compare/class.compare.default/p4.cpp
+++ clang/test/CXX/class/class.compare/class.compare.default/p4.cpp
@@ -1,7 +1,9 @@
 // RUN: %clang_cc1 -std=c++2a -verify %s
+// RUN: %clang_cc1 -std=c++2a -Wc++2b-default-comp-relaxed-constexpr -verify=expected,extension %s
 
 // This test is for [class.compare.default]p3 as modified and renumbered to p4
 // by P2002R0.
+// Also covers modifications made by P2448R2 and extension warnings
 
 namespace std {
   struct strong_ordering {
@@ -76,14 +78,13 @@
 }
 
 struct H {
-  bool operator==(const H&) const; // expected-note {{here}}
+  bool operator==(const H&) const; // extension-note {{non-constexpr comparison function declared here}}
   constexpr std::strong_ordering operator<=>(const H&) const { return std::strong_ordering::equal; }
 };
 
 struct I {
-  H h; // expected-note {{used to compare}}
-  // expected-error@+1 {{defaulted definition of three-way comparison operator cannot be declared constexpr because the corresponding implicit 'operator==' invokes a non-constexpr comparison function}}
-  constexpr std::strong_ordering operator<=>(const I&) const = default;
+  H h; // extension-note {{non-constexpr comparison function would be used to compare member 'h'}}
+  constexpr std::strong_ordering operator<=>(const I&) const = default; // extension-warning {{implicit 'operator==' invokes a non-constexpr comparison function are a C++2b extension}}
 };
 
 struct J {
@@ -144,3 +145,19 @@
   };
   bool test_d = D() == D();
 }
+
+namespace GH61238 {
+template  struct my_struct {
+A value; // extension-note {{non-constexpr comparison function would be used to compare member 'value'}}
+
+constexpr friend bool operator==(const my_struct &, const my_struct &) noexcept = default; // no diagnostic extension-warning {{declared constexpr but it invokes a non-constexpr comparison function are a C++2b extension}}
+};
+
+struct non_constexpr_type {
+friend bool operator==(non_constexpr_type, non_constexpr_type) noexcept { // extension-note {{non-constexpr comparison function declared here}}
+return false;
+}
+};
+
+my_struct obj; // extension-note {{in instantiation of template class 'GH61238::my_struct' requested here}}
+}
Index: clang/test/CXX/class/class.compare/class.compare.default/p3.cpp
===
--- clang/test/CXX/class/class.compare/class.compare.default/p3.cpp
+++ clang/test/CXX/class/class.compare/class.compare.default/p3.cpp
@@ -80,10 +80,10 @@
 };
 
 struct C {
-  friend bool operator==(const C&, const C&); // expected-note {{previous}} expected-note 2{{here}}
+  friend bool operator==(const C&, const C&); // expected-note {{previous}}
   friend bool operator!=(const C&, const C&) = default; // expected-note {{previous}}
 
-  friend std::strong_ordering operator<=>(const C&, const C&); // expected-note {{previous}} expected-note 2{{here}}
+  friend std::strong_ordering operator<=>(const C&, const C&); // expected-note {{previous}}
   friend bool operator<(const C&, const C&) = default; // expected-note {{previous}}
   friend bool operator<=(const C&, const C&) = default; // expected-note {{previous}}
   friend bool operator>(const C&, const C&) = default; // expected-note {{previous}}
@@ -127,23 +127,23 @@
 
 struct E {
   A a;
-  C c; // expected-note 2{{non-constexpr comparison function would be used to compare member 'c'}}
+  C c;
   A b;
-  friend constexpr bool operator==(const E&, const E&) = default; // expected-error {{cannot be declared constexpr because it invokes a non-constexpr comparison function}}
+  friend constexpr bool operator==(const E&, const E&) = default;
   friend constexpr bool operator!=(const E&, const E&) = default;
 
-  friend constexpr std::strong_ordering operator<=>(const E&, const E&) = default; // expected-error {{cannot be declared constexpr because it invokes a non-constexpr c

[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-14 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 505249.
craig.topper added a comment.

Add a test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

Files:
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/Sema/attr-alwaysinline.cpp


Index: clang/test/Sema/attr-alwaysinline.cpp
===
--- clang/test/Sema/attr-alwaysinline.cpp
+++ clang/test/Sema/attr-alwaysinline.cpp
@@ -25,3 +25,13 @@
 }
 
 [[clang::always_inline]] static int i = bar(); // expected-warning 
{{'always_inline' attribute only applies to functions and statements}}
+
+// This used to crash the compiler.
+template
+int foo(int x) {
+if constexpr (D > 1)
+[[clang::always_inline]] return foo(x + 1);
+else
+return x;
+}
+
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -259,7 +259,7 @@
 
   for (const auto *CallExpr : CEF.getCallExprs()) {
 const Decl *Decl = CallExpr->getCalleeDecl();
-if (Decl->hasAttr() || Decl->hasAttr())
+if (Decl && (Decl->hasAttr() || 
Decl->hasAttr()))
   S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
   << A << (Decl->hasAttr() ? 2 : 1);
   }


Index: clang/test/Sema/attr-alwaysinline.cpp
===
--- clang/test/Sema/attr-alwaysinline.cpp
+++ clang/test/Sema/attr-alwaysinline.cpp
@@ -25,3 +25,13 @@
 }
 
 [[clang::always_inline]] static int i = bar(); // expected-warning {{'always_inline' attribute only applies to functions and statements}}
+
+// This used to crash the compiler.
+template
+int foo(int x) {
+if constexpr (D > 1)
+[[clang::always_inline]] return foo(x + 1);
+else
+return x;
+}
+
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -259,7 +259,7 @@
 
   for (const auto *CallExpr : CEF.getCallExprs()) {
 const Decl *Decl = CallExpr->getCalleeDecl();
-if (Decl->hasAttr() || Decl->hasAttr())
+if (Decl && (Decl->hasAttr() || Decl->hasAttr()))
   S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
   << A << (Decl->hasAttr() ? 2 : 1);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145227: [LLVM][OHOS] Clang toolchain and targets

2023-03-14 Thread Daniel Thornburgh via Phabricator via cfe-commits
mysterymath added a comment.

It looks like these tests don't pass when LLVM_ENABLE_LINKER_BUILD_ID is set; 
I've issued a revert until this can be fixed to unblock the Fuchsia toolchain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145227

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


[clang] d505d20 - Revert "[LLVM][OHOS] Clang toolchain and targets"

2023-03-14 Thread Daniel Thornburgh via cfe-commits

Author: Daniel Thornburgh
Date: 2023-03-14T13:46:21-07:00
New Revision: d505d20a62f4838d8ecb9385af8b8ccce9db67da

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

LOG: Revert "[LLVM][OHOS] Clang toolchain and targets"

This change had tests that break whenever LLVM_ENABLE_LINKER_BUILD_ID is
set, as is the case in the Fuchsia target.

This reverts commits:
f81317a54586dbcef0c14cf512a0770e8ecaab3d
72474afa27570a0a1307f3260f0187b703aa6d84

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Driver/ToolChain.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets.cpp
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/ABIInfo.h
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/CMakeLists.txt
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/CodeGen/aarch64-fix-cortex-a53-835769.c

Removed: 
clang/lib/Driver/ToolChains/OHOS.cpp
clang/lib/Driver/ToolChains/OHOS.h
clang/test/Driver/Inputs/ohos_native_tree/llvm/bin/.keep
clang/test/Driver/Inputs/ohos_native_tree/llvm/include/c++/v1/.keep

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/arm-liteos-ohos/a7_hard_neon-vfpv4/libc++.so

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/arm-liteos-ohos/a7_soft/libc++.so

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/arm-liteos-ohos/a7_softfp_neon-vfpv4/libc++.so

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/arm-liteos-ohos/c++/a7_hard_neon-vfpv4/libc++.so

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/arm-liteos-ohos/c++/a7_soft/libc++.so

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/arm-liteos-ohos/c++/a7_softfp_neon-vfpv4/libc++.so
clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/arm-liteos-ohos/libc++.so

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/.keep

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_hard_neon-vfpv4/.keep

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_hard_neon-vfpv4/clang_rt.crtbegin.o

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_hard_neon-vfpv4/clang_rt.crtend.o

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_hard_neon-vfpv4/libclang_rt.builtins.a

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_hard_neon-vfpv4/libclang_rt.profile.a

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_soft/.keep

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_soft/clang_rt.crtbegin.o

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_soft/clang_rt.crtend.o

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_soft/libclang_rt.builtins.a

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_soft/libclang_rt.profile.a

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_softfp_neon-vfpv4/.keep

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_softfp_neon-vfpv4/clang_rt.crtbegin.o

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_softfp_neon-vfpv4/clang_rt.crtend.o

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_softfp_neon-vfpv4/libclang_rt.builtins.a

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/a7_softfp_neon-vfpv4/libclang_rt.profile.a

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/clang_rt.crtbegin.o

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/clang_rt.crtend.o

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/libclang_rt.builtins.a

clang/test/Driver/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z/lib/arm-liteos-ohos/libclang_rt.profile.a
clang/test/Driver/Inputs/ohos_native_tree/sysroot/usr/include/.keep

clang/test/Driver/Inputs/ohos_native_tree/sysroot/usr/include/arm-liteos-ohos/.keep
clang/test/Driver/Inputs/ohos_native_tree/sysroot/usr/lib/.keep

clang/test/Driver/Inputs/ohos_native_tree/sysroot/usr/lib/arm-liteos-ohos/.keep

clang/test/Driver/Inputs/ohos_native_tree/sysroot/usr/lib/arm-liteos-ohos/a7_hard_neon-vfpv4/.keep

clang/test/Driver/Inputs/ohos_native_tree/sysroot/usr/lib/arm-liteos-ohos/a7_

[PATCH] D145715: Remove -lower-global-dtors-via-cxa-atexit flag

2023-03-14 Thread Julian Lettner via Phabricator via cfe-commits
yln added a comment.

I will land this later today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145715

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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-14 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: aaron.ballman, erichkeane.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: clang.

It's possible for `getCalleeDecl()` to return a null pointer.

This was encountered by a user of our downstream compiler.

The case involved a DependentScopeDeclRefExpr.

Since this seems to only be for a warning diagnostic, I skipped
the diagnostic check if it returned null. But mabye there's a
different way to fix this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146089

Files:
  clang/lib/Sema/SemaStmtAttr.cpp


Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -259,7 +259,7 @@
 
   for (const auto *CallExpr : CEF.getCallExprs()) {
 const Decl *Decl = CallExpr->getCalleeDecl();
-if (Decl->hasAttr() || Decl->hasAttr())
+if (Decl && (Decl->hasAttr() || 
Decl->hasAttr()))
   S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
   << A << (Decl->hasAttr() ? 2 : 1);
   }


Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -259,7 +259,7 @@
 
   for (const auto *CallExpr : CEF.getCallExprs()) {
 const Decl *Decl = CallExpr->getCalleeDecl();
-if (Decl->hasAttr() || Decl->hasAttr())
+if (Decl && (Decl->hasAttr() || Decl->hasAttr()))
   S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
   << A << (Decl->hasAttr() ? 2 : 1);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505243.
francii added a comment.

Wildcard check for `-l`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,18 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1703,6 +1703,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,50 +232,52 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
-  // Add directory to library search path.
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+CmdArgs.push_back("-lpthreads")

[PATCH] D144844: [C++20] [Modules] Offer -fno-import-inter-module-function-defs to avoid duplicated compilation in modules

2023-03-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D144844#4193727 , @iains wrote:

> In D144844#4193568 , @dblaikie 
> wrote:
>
>> Seem to recall @iains and others were concerned about the number of modules 
>> flags - this one I'd be inclined to suggest we shouldn't add if possible. If 
>> one way or the other is generally better - we should, at least initially, 
>> dictate that behavior entirely until someone can demonstrate divergent use 
>> cases that seem reasonable to support but must have different behavior here.
>
> Agreed, [IMO, at least] we have a very large set of modules options, and 
> expanding that should only be done if no sensible alternative can be found 
> (we are already seeing users getting confused about which ones apply in each 
> case).
>
> A second point here - that (once we have the ability to generate object and 
> PCM in the same compilation) that we will move to elide the function bodies 
> for non-inline and non-dependent cases from the PCM, so that this problem 
> will magically "go away" (to restore the current behaviour, we'd then be 
> using some optimisation control to avoid the elision, I suppose).

Yeah, this seems like the simplest concrete point to suggest we just change the 
defaults here - that's the plan moving forward, and I don't think it's worth 
trying to maintain two codepaths/supports here - people can write the functions 
as explicitly `inline` when they want cross-module inlining & we can let 
non-inline functions be the same as they were before modules.

If, years from now, someone wants to prototype some stronger optimization 
opportunities in modules - let's do that later/then?

>> The performance of cross-module inlining could be achieved with something 
>> like ThinLTO if we were to lean in favor of not allowing cross-module 
>> inlining by default, for instance.
>
> +1 this seems exactly what LTO is intended for (also there are folks who seem 
> to have an expectation that the BMI somehow magically contains an optimised 
> representation of the source - which again is the province of LTO).

There's some advantages (build system complexity, time, etc) to doing it at 
compile-time, rather than link-time, but I don't think we have enough data to 
be worth the complexity for now - I'd vote for letting the feature go/removing 
it for now, and folks can try to bring it back with data/measurements later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144844

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


[PATCH] D145737: PR60985: Fix merging of lambda closure types across modules.

2023-03-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:1778-1780
+  void setLambdaNumbering(Decl *ContextDecl, unsigned IndexInContext,
+  unsigned ManglingNumber,
+  unsigned DeviceManglingNumber,

aaron.ballman wrote:
> My kingdom for a strong typedef so we can differentiate between the various 
> indices here within the type system. (It probably isn't worth the extra 
> effort, but I do have some slight concerns about how easy it is to 
> accidentally pass the wrong number.)
I've moved `Sema::LambdaNumbering` here and used it more broadly, which should 
help us avoid errors from getting the argument order wrong.



Comment at: clang/include/clang/AST/MangleNumberingContext.h:65
+  // sequence number and is not ABI-dependent.
+  unsigned getNextLambdaIndex() { return LambdaIndex++; }
 };

aaron.ballman wrote:
> Does the index `0` mean "perhaps not-yet-assigned" when deserializing? 
> Assuming I have that correct, perhaps we want to return `++LambdaIndex` 
> instead?
`0` has no special meaning. Every lambda that we parse locally gets an index 
assigned when we give it a context declaration, and every lambda that we import 
has this field filled in when the struct containing the field is loaded. 
There's no window where the lambda has a context declaration but doesn't have a 
numbering within that context.



Comment at: clang/lib/AST/ASTContext.cpp:6724-6725
+  // their types. Assume the types will end up being the same.
+  if (VarX->getType().isNull() || VarY->getType().isNull())
+return true;
+

aaron.ballman wrote:
> Do we have to worry about the case where this function is not called during 
> deserialization, but some other time when the variable had an error regarding 
> its type? Or do we recover in that situation (usually with an int type) 
> sufficiently that this shouldn't result in surprises?
The type being null is a violation of AST invariants, so that should never be 
observed here except while deserializing.

[It's unfortunate that this function got moved out of the AST reader. That's 
inviting bugs, because deserialization can't rely on AST invariants holding, 
and in particular can't call arbitrary AST functions. I've added some words of 
caution at the start of this function at least, but we should look at whether 
we can move this back into the AST reader. It looks like there aren't many 
dependencies on it and they're only using a very small part of the  
functionality here.]



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:574-576
+  } else if (auto *VD = dyn_cast(D)) {
+ReadVarDeclInit(VD);
   }

aaron.ballman wrote:
> Do we need to do anything for structured bindings?
Hmm. Great question ;-)

So, the type of a `BindingDecl` can involve a lambda closure type, and the 
`BindingDecl` will be deserialized with the `DecompositionDecl`, before we had 
a chance to merge the lambda. Eg:

```
template struct wrap {
  T v;
};
inline auto [x] = wrap{[]{}};
```

... won't merge properly across modules.

This is probably not hard to fix -- I think we can defer initializing the 
mapping from a `DecompositionDecl` to its `BindingDecl`s until we've otherwise 
finished deserialization, and maybe we could make the `BindingDecl` pointers in 
a `DecompositionDecl` be lazy pointers for good measure. But this patch is 
already pretty big; mind if I do that as a follow-up change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145737

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


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-14 Thread wael yehia via Phabricator via cfe-commits
w2yehia accepted this revision.
w2yehia added a comment.
This revision is now accepted and ready to land.

LGTM. Would be nice to get @daltenty 's approval too.




Comment at: clang/test/Driver/aix-ld.c:1094
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-lc++"
+// CHECK-RELOCATABLE-NOT: "-lc++abi"

is there a way to check that `-l` is not present?
I'm thinking it's more future-proof ((1) detects if new libraries get added and 
(2) avoids having to update the testcase).. not sure what the disadvantages of 
adding the wildcard is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145899

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


[PATCH] D145737: PR60985: Fix merging of lambda closure types across modules.

2023-03-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 505240.
rsmith marked 6 inline comments as done.
rsmith added a comment.

- Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145737

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/ExternalASTSource.h
  clang/include/clang/AST/MangleNumberingContext.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Sema/ExternalSemaSource.h
  clang/include/clang/Sema/MultiplexExternalSemaSource.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/Sema/MultiplexExternalSemaSource.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/Modules/lambda-in-variable.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp

Index: clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
===
--- clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
+++ clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
@@ -1457,11 +1457,31 @@
 // CHECK2-NEXT:ret void
 //
 //
-// CHECK2-LABEL: define {{[^@]+}}@_ZN1SC2Ei
+// CHECK2-LABEL: define {{[^@]+}}@__cxx_global_var_init
+// CHECK2-SAME: () #[[ATTR6]] section "__TEXT,__StaticInit,regular,pure_instructions" {
+// CHECK2-NEXT:  entry:
+// CHECK2-NEXT:call void @_ZN1SC1Ei(ptr noundef nonnull align 4 dereferenceable(4) @s, i32 noundef 1)
+// CHECK2-NEXT:ret void
+//
+//
+// CHECK2-LABEL: define {{[^@]+}}@_ZN1SC1Ei
 // CHECK2-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], i32 noundef [[C:%.*]]) unnamed_addr #[[ATTR8:[0-9]+]] align 2 {
 // CHECK2-NEXT:  entry:
 // CHECK2-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK2-NEXT:[[C_ADDR:%.*]] = alloca i32, align 4
+// CHECK2-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
+// CHECK2-NEXT:store i32 [[C]], ptr [[C_ADDR]], align 4
+// CHECK2-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
+// CHECK2-NEXT:[[TMP0:%.*]] = load i32, ptr [[C_ADDR]], align 4
+// CHECK2-NEXT:call void @_ZN1SC2Ei(ptr noundef nonnull align 4 dereferenceable(4) [[THIS1]], i32 noundef [[TMP0]])
+// CHECK2-NEXT:ret void
+//
+//
+// CHECK2-LABEL: define {{[^@]+}}@_ZN1SC2Ei
+// CHECK2-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], i32 noundef [[C:%.*]]) unnamed_addr #[[ATTR8]] align 2 {
+// CHECK2-NEXT:  entry:
+// CHECK2-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
+// CHECK2-NEXT:[[C_ADDR:%.*]] = alloca i32, align 4
 // CHECK2-NEXT:[[DOTCAPTURE_EXPR_:%.*]] = alloca i8, align 1
 // CHECK2-NEXT:[[DOTCAPTURE_EXPR__CASTED:%.*]] = alloca i64, align 8
 // CHECK2-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
@@ -1650,26 +1670,6 @@
 // CHECK2-NEXT:ret i32 0
 //
 //
-// CHECK2-LABEL: define {{[^@]+}}@_ZN1SC1Ei
-// CHECK2-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], i32 noundef [[C:%.*]]) unnamed_addr #[[ATTR8]] align 2 {
-// CHECK2-NEXT:  entry:
-// CHECK2-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
-// CHECK2-NEXT:[[C_ADDR:%.*]] = alloca i32, align 4
-// CHECK2-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
-// CHECK2-NEXT:store i32 [[C]], ptr [[C_ADDR]], align 4
-// CHECK2-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
-// CHECK2-NEXT:[[TMP0:%.*]] = load i32, ptr [[C_ADDR]], align 4
-// CHECK2-NEXT:call void @_ZN1SC2Ei(ptr noundef nonnull align 4 dereferenceable(4) [[THIS1]], i32 noundef [[TMP0]])
-// CHECK2-NEXT:ret void
-//
-//
-// CHECK2-LABEL: define {{[^@]+}}@__cxx_global_var_init
-// CHECK2-SAME: () #[[ATTR6]] section "__TEXT,__StaticInit,regular,pure_instructions" {
-// CHECK2-NEXT:  entry:
-// CHECK2-NEXT:call void @_ZN1SC1Ei(ptr noundef nonnull align 4 dereferenceable(4) @s, i32 noundef 1)
-// CHECK2-NEXT:ret void
-//
-//
 // CHECK2-LABEL: define {{[^@]+}}@_GLOBAL__sub_I_parallel_master_taskloop_simd_codegen.cpp
 // CHECK2-SAME: () #[[ATTR6]] section "__TEXT,__StaticInit,regular,pure_instructions" {
 // CHECK2-NEXT:  entry:
@@ -3111,8 +3111,28 @@
 // CHECK6-NEXT:ret i32 [[TMP48]]
 //
 //
+// CHECK6-LABEL: define {{[^@]+}}@__cxx_global_var_init
+// CHECK6-SAME: () #[[ATTR2:[0-9]+]] section "__TEXT,__StaticInit,regular,pure_instructions" {
+// CHECK6-NEXT:  entry:
+// CHECK6-NEXT:call void @_ZN1SC1Ei(ptr noundef nonnull align 4 dereferenceab

[PATCH] D140275: [clangd] Tweak to add doxygen comment to the function declaration

2023-03-14 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.
Herald added a subscriber: ChuanqiXu.

Hey, are you still planning to work on this? Otherwise, is it okay if I take 
over this patch to implement this feature?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140275

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


[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-14 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 505227.
lamb-j added a comment.

Updating commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145770

Files:
  clang/docs/ClangOffloadBundler.rst
  clang/lib/Driver/OffloadBundler.cpp
  clang/test/Driver/clang-offload-bundler-asserts-on.c
  clang/test/Driver/clang-offload-bundler-standardize.c
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -313,6 +313,8 @@
   llvm::DenseSet ParsedTargets;
   // Map {offload-kind}-{triple} to target IDs.
   std::map> TargetIDs;
+  // Standardize target names to include env field
+  std::vector StandardizedTargetNames;
   for (StringRef Target : TargetNames) {
 if (ParsedTargets.contains(Target)) {
   reportError(createStringError(errc::invalid_argument,
@@ -324,6 +326,8 @@
 bool KindIsValid = OffloadInfo.isOffloadKindValid();
 bool TripleIsValid = OffloadInfo.isTripleValid();
 
+StandardizedTargetNames.push_back(OffloadInfo.str());
+
 if (!KindIsValid || !TripleIsValid) {
   SmallVector Buf;
   raw_svector_ostream Msg(Buf);
@@ -348,6 +352,9 @@
 
 ++Index;
   }
+
+  BundlerConfig.TargetNames = StandardizedTargetNames;
+
   for (const auto &TargetID : TargetIDs) {
 if (auto ConflictingTID =
 clang::getConflictTargetIDCombination(TargetID.second)) {
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -1,5 +1,4 @@
 // REQUIRES: x86-registered-target
-// REQUIRES: powerpc-registered-target
 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
 
 //
@@ -297,11 +296,11 @@
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD
-// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD-INPUTS
-// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDL

[PATCH] D145564: [clang][docs] Clarify the semantics of -fexceptions

2023-03-14 Thread Alex Bradbury 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 rGf47404b012d6: [clang][docs] Clarify the semantics of 
-fexceptions (authored by asb).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145564

Files:
  clang/docs/CommandGuide/clang.rst


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -473,8 +473,10 @@
 
 .. option:: -fexceptions
 
-  Enable generation of unwind information. This allows exceptions to be thrown
-  through Clang compiled stack frames.  This is on by default in x86-64.
+  Allow exceptions to be thrown through Clang compiled stack frames (on many
+  targets, this will enable unwind information for functions that might have
+  an exception thrown through them). For most targets, this is enabled by
+  default for C++.
 
 .. option:: -ftrapv
 


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -473,8 +473,10 @@
 
 .. option:: -fexceptions
 
-  Enable generation of unwind information. This allows exceptions to be thrown
-  through Clang compiled stack frames.  This is on by default in x86-64.
+  Allow exceptions to be thrown through Clang compiled stack frames (on many
+  targets, this will enable unwind information for functions that might have
+  an exception thrown through them). For most targets, this is enabled by
+  default for C++.
 
 .. option:: -ftrapv
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f47404b - [clang][docs] Clarify the semantics of -fexceptions

2023-03-14 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2023-03-14T19:52:32Z
New Revision: f47404b012d66ed0b411a2b3742931a14e85c80b

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

LOG: [clang][docs] Clarify the semantics of -fexceptions

As noted in , the
documentation for -fexceptions appears to imply that unwind information
is always generated, which isn't the case.

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

Added: 


Modified: 
clang/docs/CommandGuide/clang.rst

Removed: 




diff  --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index 7fae1b5cec53c..e076818697eb1 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -473,8 +473,10 @@ Code Generation Options
 
 .. option:: -fexceptions
 
-  Enable generation of unwind information. This allows exceptions to be thrown
-  through Clang compiled stack frames.  This is on by default in x86-64.
+  Allow exceptions to be thrown through Clang compiled stack frames (on many
+  targets, this will enable unwind information for functions that might have
+  an exception thrown through them). For most targets, this is enabled by
+  default for C++.
 
 .. option:: -ftrapv
 



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


[PATCH] D145150: clang: Emit nofpclass(nan inf) for -ffinite-math-only

2023-03-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Looks fine from a codegen perspective, assuming these are the semantics we want 
for -ffinite-math-only.




Comment at: clang/lib/CodeGen/CGCall.cpp:3052
+AI->addAttrs(
+llvm::AttrBuilder(getLLVMContext()).addNoFPClassAttr(Mask));
+  }

What cases does this cover that aren't already covered by the code in 
CodeGenModule::ConstructAttributeList?


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

https://reviews.llvm.org/D145150

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


[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Please update the description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145770

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


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505221.
francii added a comment.

Update test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,22 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-lc++"
+// CHECK-RELOCATABLE-NOT: "-lc++abi"
+// CHECK-RELOCATABLE-NOT: "-lunwind"
+// CHECK-RELOCATABLE-NOT: "-lm"
+// CHECK-RELOCATABLE-NOT: "-lc"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1703,6 +1703,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,50 +232,52 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
-  // Add directory to library search path.
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if 

[PATCH] D129689: [limits.h] USHRT_MAX fix for 16 bit architectures

2023-03-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D129689#4194096 , @SebastianPerta 
wrote:

> @cor3ntin can I close it?

You can abandon this PR, it was handled by 
0fecac18ffad476b5a4682770f6d8b1f0f176b40 
.


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

https://reviews.llvm.org/D129689

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


[PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-14 Thread Aryan Godara via Phabricator via cfe-commits
AryanGodara added a comment.

In D146041#4193172 , @junaire wrote:

> I'm not certain if it's bad to say 'sorry', IMHO it's fine?
>
> Anyway, you can't just simply delete those words (in diagnostic messages and 
> regression tests), that doesn't work. To verify the patch is good, you can 
> run `ninja check-all` to make sure the testsuite passes.

This was one of the issues for Outreachy '23, and I asked my outreachy mentor 
to work on this issue.
I'm looking for any help to make the patch more meaningful, and get guidance 
along the way.

I'll run `ninja check-all`, before pushing the next commit for revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


[PATCH] D145737: PR60985: Fix merging of lambda closure types across modules.

2023-03-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this Richard, that is a pretty subtle issue! I'm still 
wrapping my head around the changes (which mostly look reasonable to me), but I 
did have a few questions I ran into.




Comment at: clang/include/clang/AST/DeclCXX.h:1778-1780
+  void setLambdaNumbering(Decl *ContextDecl, unsigned IndexInContext,
+  unsigned ManglingNumber,
+  unsigned DeviceManglingNumber,

My kingdom for a strong typedef so we can differentiate between the various 
indices here within the type system. (It probably isn't worth the extra effort, 
but I do have some slight concerns about how easy it is to accidentally pass 
the wrong number.)



Comment at: clang/include/clang/AST/ExternalASTSource.h:387
+// Ensure the integer is in pointer form.
+get(Source);
+return reinterpret_cast(&Ptr);

I think this helps make it clear that the function is only being called for its 
side effects.



Comment at: clang/include/clang/AST/MangleNumberingContext.h:65
+  // sequence number and is not ABI-dependent.
+  unsigned getNextLambdaIndex() { return LambdaIndex++; }
 };

Does the index `0` mean "perhaps not-yet-assigned" when deserializing? Assuming 
I have that correct, perhaps we want to return `++LambdaIndex` instead?



Comment at: clang/lib/AST/ASTContext.cpp:6724-6725
+  // their types. Assume the types will end up being the same.
+  if (VarX->getType().isNull() || VarY->getType().isNull())
+return true;
+

Do we have to worry about the case where this function is not called during 
deserialization, but some other time when the variable had an error regarding 
its type? Or do we recover in that situation (usually with an int type) 
sufficiently that this shouldn't result in surprises?



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:574-576
+  } else if (auto *VD = dyn_cast(D)) {
+ReadVarDeclInit(VD);
   }

Do we need to do anything for structured bindings?



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:876
   // function.
-  if (isa(VD))
+  if (isa(VD) || isa(VD))
 DeferredTypeID = Record.getGlobalTypeID(Record.readInt());





Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:1604-1608
+  if (HasDeducedType) {
+Reader.PendingDeducedVarTypes.push_back({VD, DeferredTypeID});
+  } else {
+VD->setType(Reader.GetType(DeferredTypeID));
+  }





Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:1967-1969
+if (unsigned DeviceManglingNumber = Record.readInt()) {
+  Reader.getContext().DeviceLambdaManglingNumbers[D] = 
DeviceManglingNumber;
+}





Comment at: clang/lib/Serialization/ASTWriter.cpp:5330
+} else if (HasAddedVarDefinition) {
+  const VarDecl *VD = cast(D);
+  Record.push_back(UPD_CXX_ADDED_VAR_DEFINITION);





Comment at: clang/lib/Serialization/ASTWriterDecl.cpp:299-301
+  if (VarDecl *VD = dyn_cast(D)) {
+Record.AddVarDeclInit(VD);
+  }





Comment at: clang/test/Modules/lambda-in-variable.cpp:94
+#endif
+
+static_assert(MultipleLambdas() == 2);

Should we add a test for structured bindings as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145737

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


[PATCH] D145851: [Clang][Sema] Fix incorrect deletion of default constructors for some unions

2023-03-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

In D145851#4194154 , @royjacobson 
wrote:

> Fix the codegen test, add a standard ref to the comment.

No worries, there is definitely somewhat of an art to writing a codegen test 
that won't be fragile/overspecified, I've made a few more suggestions to make 
it more clear/easier, else this LGTM.  Feel free to put the rest of the codegen 
test suggestions up for further review, but if you're comfortable with them, 
you may commit instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145851

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


[PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-14 Thread Aryan Godara via Phabricator via cfe-commits
AryanGodara added a comment.

In D146041#4193045 , @DavidSpickett 
wrote:

> Is there some standard for writing warning messages? For llvm that is, it 
> would be worth looking through the getting started guides to see. I think the 
> majority of warnings are "formal" in that sense so this seems fine.
>
> Personally I agree with making the warnings more succinct but aside from that 
> I don't see the need to change comments or testing scripts.
>
> You may consider splitting this change into 2. One that only changes warnings 
> and errors (a less controversial change) and the rest (that is up to the 
> reviewers of each bit).

I will do go through the changes I made, and first make sure to change only 
warnings and errors.

Since this is my first commit to such a large repository(and project), can you 
please guide me with this  @DavidSpickett !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


[PATCH] D145851: [Clang][Sema] Fix incorrect deletion of default constructors for some unions

2023-03-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/CodeGen/union-non-trivial-member.cpp:23
+
+// CHECK:  define dso_local void @_Z1fv() {{.*}} {
+// CHECK-NEXT: entry:





Comment at: clang/test/CodeGen/union-non-trivial-member.cpp:24
+// CHECK:  define dso_local void @_Z1fv() {{.*}} {
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN8UnionIntC1Ev{{.*}}

Don't need the `entry:` line,



Comment at: clang/test/CodeGen/union-non-trivial-member.cpp:25
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN8UnionIntC1Ev{{.*}}
+// CHECK-NEXT:   call void @_ZN15UnionNonTrivialC1Ev{{.*}}

Wildcards are implicit at the end of a line.



Comment at: clang/test/CodeGen/union-non-trivial-member.cpp:26
+// CHECK:call void @_ZN8UnionIntC1Ev{{.*}}
+// CHECK-NEXT:   call void @_ZN15UnionNonTrivialC1Ev{{.*}}
+// CHECK-NEXT:   ret void





Comment at: clang/test/CodeGen/union-non-trivial-member.cpp:27
+// CHECK-NEXT:   call void @_ZN15UnionNonTrivialC1Ev{{.*}}
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }

This and the line after it aren't really necessary/valuable, particularly in 
case we get debug info/builtin/etc added later.



Comment at: clang/test/CodeGen/union-non-trivial-member.cpp:30
+
+// CHECK:  define {{.*}} void @_ZN8UnionIntC1Ev{{.*}}
+// CHECK-NEXT: entry:

I typically suggest not requiring a space either before or after a `{{.*}}` 
block, since that wont match 'empty'.



Comment at: clang/test/CodeGen/union-non-trivial-member.cpp:31
+// CHECK:  define {{.*}} void @_ZN8UnionIntC1Ev{{.*}}
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN8UnionIntC2Ev{{.*}}

Same here, skip the entry , ret, and closing curley brace line.



Comment at: clang/test/CodeGen/union-non-trivial-member.cpp:32
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN8UnionIntC2Ev{{.*}}
+// CHECK-NEXT:   ret void

same advise as above on the following ones too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145851

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


[PATCH] D145851: [Clang][Sema] Fix incorrect deletion of default constructors for some unions

2023-03-14 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson marked 2 inline comments as done.
royjacobson added inline comments.



Comment at: clang/test/CodeGen/union-non-trivial-member.cpp:30
+// CHECK-NEXT: 
+// CHECK-NEXT: define linkonce_odr dso_local void @_ZN2UnionIntC2Ev(ptr 
noundef nonnull align 4 dereferenceable(4) %this) unnamed_addr #1 comdat align 
2 {
+// CHECK-NEXT: entry:

erichkeane wrote:
> Looking more closely, this test is a little over specific.  First, you can 
> just do CHECK: to start each function, that way you don't have the blank 
> lines.
> 
> In the top function, all we care about is the `call void `s, so the 
> rest of the lines can go away.  Since you're checking function's define line, 
> you can count on ordering that way rather than check-next.
> 
> This middle function should use more wildcard/placeholders, checking fully 
> specific names like `this` or `this.addr` is a mistake, as those aren't 
> guaranteed to be there.  Also, all the 'align' checks are likely to make this 
> fail in post-commit.
> 
> on the last function, we don't even care about the parameters list, so you 
> just need the `call void ` part.
removed the non-essential parts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145851

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


[PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-14 Thread Aryan Godara via Phabricator via cfe-commits
AryanGodara added a comment.

In D146041#4192816 , @mehdi_amini 
wrote:

> You should look into the title and description of the commit: 
> https://cbea.ms/git-commit/

Is the title and description appropriate now?
I can add more details to the description, as required


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


[PATCH] D145851: [Clang][Sema] Fix incorrect deletion of default constructors for some unions

2023-03-14 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

Oops, sorry for the bad codegen test and thanks for the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145851

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


[PATCH] D145851: [Clang][Sema] Fix incorrect deletion of default constructors for some unions

2023-03-14 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 505216.
royjacobson added a comment.

Fix the codegen test, add a standard ref to the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145851

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGen/union-non-trivial-member.cpp
  clang/test/SemaCXX/cxx0x-nontrivial-union.cpp

Index: clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
===
--- clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
+++ clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
@@ -144,3 +144,47 @@
 
   Test2 t2x;  // expected-error {{call to implicitly-deleted default constructor of 'Test2'}}
 }
+
+namespace GH48416 {
+
+struct non_trivial_constructor {
+constexpr non_trivial_constructor() : x(100) {}
+int x;
+};
+
+
+union U1 {
+int a;
+non_trivial_constructor b; // expected-note {{has a non-trivial default constructor}}
+};
+
+union U2 {
+int a{1000};
+non_trivial_constructor b;
+};
+
+union U3 {
+int a;
+non_trivial_constructor b{};
+};
+
+union U4 {
+int a{}; // expected-note {{previous initialization is here}}
+non_trivial_constructor b{}; // expected-error {{initializing multiple members of union}}
+};
+
+U1 u1; // expected-error {{call to implicitly-deleted default constructor}}
+U2 u2;
+U3 u3;
+U4 u4;
+
+static_assert(U2().a == 1000, "");
+static_assert(U3().a == 1000, "");
+// expected-error@-1 {{static assertion expression is not an integral constant expression}}
+// expected-note@-2 {{read of member 'a' of union with active member 'b'}}
+static_assert(U2().b.x == 100, "");
+// expected-error@-1 {{static assertion expression is not an integral constant expression}}
+// expected-note@-2 {{read of member 'b' of union with active member 'a'}}
+static_assert(U3().b.x == 100, "");
+
+} // namespace GH48416
Index: clang/test/CodeGen/union-non-trivial-member.cpp
===
--- /dev/null
+++ clang/test/CodeGen/union-non-trivial-member.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 --std=c++17 -emit-llvm %s -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+struct non_trivial_constructor {
+constexpr non_trivial_constructor() : x(100) { }
+int x;
+};
+
+union UnionInt {
+int a{1000};
+non_trivial_constructor b;
+};
+
+union UnionNonTrivial {
+int a;
+non_trivial_constructor b{};
+};
+
+void f() {
+UnionInt u1;
+UnionNonTrivial u2;
+}
+
+// CHECK:  define dso_local void @_Z1fv() {{.*}} {
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN8UnionIntC1Ev{{.*}}
+// CHECK-NEXT:   call void @_ZN15UnionNonTrivialC1Ev{{.*}}
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }
+
+// CHECK:  define {{.*}} void @_ZN8UnionIntC1Ev{{.*}}
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN8UnionIntC2Ev{{.*}}
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }
+
+// CHECK:  define {{.*}} void @_ZN15UnionNonTrivialC1Ev{{.*}}
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN15UnionNonTrivialC2Ev{{.*}}
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }
+
+// CHECK:  define {{.*}} void @_ZN8UnionIntC2Ev{{.*}}
+// CHECK-NEXT: entry:
+// CHECK:store i32 1000{{.*}}
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }
+
+// CHECK:  define {{.*}} void @_ZN15UnionNonTrivialC2Ev{{.*}}
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN23non_trivial_constructorC1Ev{{.*}}
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -9157,7 +9157,18 @@
 // must be accessible and non-deleted, but need not be trivial. Such a
 // destructor is never actually called, but is semantically checked as
 // if it were.
-DiagKind = 4;
+if (CSM == Sema::CXXDefaultConstructor) {
+  // [class.default.ctor]p2:
+  //   A defaulted default constructor for class X is defined as deleted if
+  //   - X is a union that has a variant member with a non-trivial default
+  // constructor and no variant member of X has a default member
+  // initializer
+  const auto *RD = cast(Field->getParent());
+  if (!RD->hasInClassInitializer())
+DiagKind = 4;
+} else {
+  DiagKind = 4;
+}
   }
 
   if (DiagKind == -1)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -202,6 +202,8 @@
 - Fix crash when evaluating consteval constructor of derived class whose base
   has more than one field.
   (`#60166 `_)
+- Fix incorrect deletion of the default constructor of unions in some
+  cases. (`#48416 

[PATCH] D145726: Fix assembler error when -g and -gdwarf-* is passed with -fno-integrated-as.

2023-03-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:978-986
+  if (Arg *A = Args.getLastArg(options::OPT_g_Flag, options::OPT_gN_Group,
+   options::OPT_gdwarf_2, 
options::OPT_gdwarf_3,
+   options::OPT_gdwarf_4, 
options::OPT_gdwarf_5,
+   options::OPT_gdwarf))
+if (!A->getOption().matches(options::OPT_g0)) {
+  Args.AddLastArg(CmdArgs, options::OPT_g_Flag);
+  unsigned DwarfVersion = getDwarfVersion(getToolChain(), Args);

nickdesaulniers wrote:
> garvitgupta08 wrote:
> > nickdesaulniers wrote:
> > > Isn't this potentially going to add `-gdwarf-` repeatedly if there's many 
> > > inputs?
> > > 
> > > Wouldn't it be better to scan the inputs to see if there's any .S or .s 
> > > files, then add the flags once?
> > Let me know if this is fine.
> I don't think the current implementation addresses my point.  Having 
> `CmdArgs.push_back` be called in a loop on the number of inputs will 
> potentially add the arg repeatedly.
> 
> I think you should simply check if the `InputType` is asm or asm-with-cpp in 
> the loop, potentially setting a boolean scoped outside the loop. Then, after 
> the loop, decide whether to add the cmd arg.
Specifically, if `llvm::any_of` the inputs are asm or asm-with-cpp, then we 
might want to modify the command line flags passed to the external assembler.

We don't want to pass additional flags per input.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145726

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


  1   2   3   >