[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-07-24 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n added a comment.

In D155824#4530474 , @SixWeining 
wrote:

> @xen0n Do you have any inputs? I think supporting these options can improve 
> compatibility with gcc (although there is no ScheduleModel difference among 
> currently supported processors) and I hope it can be merged into LLVM17.

Sorry for the late reply (busy with rewriting the doc comments for D138135 
). I'm in support of adding those flags, and 
for now I think defaulting to LA464 values would suffice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

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


[PATCH] D155798: [X86] Support -march=graniterapids-d and update -march=graniterapids

2023-07-24 Thread Freddy, Ye 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 rG6d23a3faa4e6: [X86] Support -march=graniterapids-d and 
update -march=graniterapids (authored by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155798

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/X86.cpp
  clang/test/CodeGen/attr-cpuspecific-cpus.c
  clang/test/CodeGen/attr-target-mv.c
  clang/test/CodeGen/target-builtin-noerror.c
  clang/test/Driver/x86-march.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/predefined-arch-macros.c
  compiler-rt/lib/builtins/cpu_model.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/Host.cpp
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -30,6 +30,7 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=sierraforest 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=grandridge 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=graniterapids-d 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=emeraldrapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -88,6 +89,7 @@
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=sierraforest 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=grandridge 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=graniterapids-d 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 define void @foo() {
   ret void
Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -210,8 +210,7 @@
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG;
 constexpr FeatureBitset FeaturesGraniteRapids =
-FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI |
-FeatureAMX_COMPLEX;
+FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI;
 
 // Intel Atom processors.
 // Bonnell has feature parity with Core2 and adds MOVBE.
@@ -429,6 +428,9 @@
   { {"grandridge"}, CK_Grandridge, FEATURE_AVX2, FeaturesGrandridge, 'p', false },
   // Granite Rapids microarchitecture based processors.
   { {"graniterapids"}, CK_Graniterapids, FEATURE_AVX512BF16, FeaturesGraniteRapids, 'n', false },
+  // Granite Rapids D microarchitecture based processors.
+  { {"graniterapids-d"}, CK_GraniterapidsD, FEATURE_AVX512BF16, FeaturesGraniteRapids | FeatureAMX_COMPLEX, '\0', false },
+  { {"graniterapids_d"}, CK_GraniterapidsD, FEATURE_AVX512BF16, FeaturesGraniteRapids | FeatureAMX_COMPLEX, 'n', true },
   // Emerald Rapids microarchitecture based processors.
   { {"emeraldrapids"}, CK_Emeraldrapids, FEATURE_AVX512BF16, FeaturesSapphireRapids, 'n', false },
   // Knights Landing processor.
Index: llvm/lib/TargetParser/Host.cpp
===
--- llvm/lib/TargetParser/Host.cpp
+++ llvm/lib/TargetParser/Host.cpp
@@ -833,13 +833,19 @@
   break;
 
 // Graniterapids:
-case 0xae:
 case 0xad:
   CPU = "graniterapids";
   *Type = X86::INTEL_COREI7;
   *Subtype = X86::INTEL_COREI7_GRANITERAPIDS;
   break;
 
+// Granite Rapids D:
+case 0xae:
+  CPU = "graniterapids-d";
+  *Type = X86::INTEL_COREI7;
+  *Subtype = X86::INTEL_COREI7_GRANITERAPIDS_D;
+  break;
+
 // Icelake Xeon:
 case 0x6a:
 case 0x6c:
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -1078,11 +1078,15 @@
 
   // Graniterapids
   list GNRAdditionalFeatures = 

[PATCH] D155798: [X86] Support -march=graniterapids-d and update -march=graniterapids

2023-07-24 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 543826.
FreddyYe added a comment.

rebase and fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155798

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/X86.cpp
  clang/test/CodeGen/attr-cpuspecific-cpus.c
  clang/test/CodeGen/attr-target-mv.c
  clang/test/CodeGen/target-builtin-noerror.c
  clang/test/Driver/x86-march.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/predefined-arch-macros.c
  compiler-rt/lib/builtins/cpu_model.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/Host.cpp
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -30,6 +30,7 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=sierraforest 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=grandridge 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=graniterapids-d 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=emeraldrapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -88,6 +89,7 @@
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=sierraforest 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=grandridge 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=graniterapids-d 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 define void @foo() {
   ret void
Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -210,8 +210,7 @@
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG;
 constexpr FeatureBitset FeaturesGraniteRapids =
-FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI |
-FeatureAMX_COMPLEX;
+FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI;
 
 // Intel Atom processors.
 // Bonnell has feature parity with Core2 and adds MOVBE.
@@ -429,6 +428,9 @@
   { {"grandridge"}, CK_Grandridge, FEATURE_AVX2, FeaturesGrandridge, 'p', false },
   // Granite Rapids microarchitecture based processors.
   { {"graniterapids"}, CK_Graniterapids, FEATURE_AVX512BF16, FeaturesGraniteRapids, 'n', false },
+  // Granite Rapids D microarchitecture based processors.
+  { {"graniterapids-d"}, CK_GraniterapidsD, FEATURE_AVX512BF16, FeaturesGraniteRapids | FeatureAMX_COMPLEX, '\0', false },
+  { {"graniterapids_d"}, CK_GraniterapidsD, FEATURE_AVX512BF16, FeaturesGraniteRapids | FeatureAMX_COMPLEX, 'n', true },
   // Emerald Rapids microarchitecture based processors.
   { {"emeraldrapids"}, CK_Emeraldrapids, FEATURE_AVX512BF16, FeaturesSapphireRapids, 'n', false },
   // Knights Landing processor.
Index: llvm/lib/TargetParser/Host.cpp
===
--- llvm/lib/TargetParser/Host.cpp
+++ llvm/lib/TargetParser/Host.cpp
@@ -833,13 +833,19 @@
   break;
 
 // Graniterapids:
-case 0xae:
 case 0xad:
   CPU = "graniterapids";
   *Type = X86::INTEL_COREI7;
   *Subtype = X86::INTEL_COREI7_GRANITERAPIDS;
   break;
 
+// Granite Rapids D:
+case 0xae:
+  CPU = "graniterapids-d";
+  *Type = X86::INTEL_COREI7;
+  *Subtype = X86::INTEL_COREI7_GRANITERAPIDS_D;
+  break;
+
 // Icelake Xeon:
 case 0x6a:
 case 0x6c:
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -1078,11 +1078,15 @@
 
   // Graniterapids
   list GNRAdditionalFeatures = [FeatureAMXFP16,
-  FeaturePREFETCHI,
-  FeatureAMXCOMPLEX];
+ 

[PATCH] D156205: wasm: link crt1 even in case of -shared

2023-07-24 Thread YAMAMOTO Takashi via Phabricator via cfe-commits
yamt created this revision.
Herald added subscribers: pmatos, asb, sunfish, jgravelle-google, sbc100, 
dschuff.
Herald added a project: All.
yamt requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, aheejin.
Herald added a project: clang.

This allows -mexec-model=reactor -shared produces a library module
with _initialize entrypoint, which is preferrable over __wasm_call_ctors.

This partially reverts https://reviews.llvm.org/D153293

Discussion: https://github.com/dicej/component-linking-demo/issues/3


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156205

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -101,7 +101,7 @@
   << CM << A->getOption().getName();
 }
   }
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, 
options::OPT_shared))
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1)));
   if (Entry) {
 CmdArgs.push_back(Args.MakeArgString("--entry"));


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -101,7 +101,7 @@
   << CM << A->getOption().getName();
 }
   }
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, options::OPT_shared))
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1)));
   if (Entry) {
 CmdArgs.push_back(Args.MakeArgString("--entry"));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6cf8179 - Don't perform dynamic_cast optimization at -O0.

2023-07-24 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2023-07-24T22:24:33-07:00
New Revision: 6cf8179661997f8d512cdf944f4f4c0c01cb37c1

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

LOG: Don't perform dynamic_cast optimization at -O0.

It seems preferable to avoid this optimization under -O0, and we're not
set up to emit speculative references to vtables at -O0 in general
anyway.

For #64088.

Added: 


Modified: 
clang/lib/CodeGen/CGExprCXX.cpp
clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp
clang/test/CodeGenCXX/dynamic-cast-exact.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 6df5e37d9af940..4d3f3e9603d942 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -2276,6 +2276,7 @@ llvm::Value *CodeGenFunction::EmitDynamicCast(Address 
ThisAddr,
   // If the destination is effectively final, the cast succeeds if and only
   // if the dynamic type of the pointer is exactly the destination type.
   bool IsExact = !IsDynamicCastToVoid &&
+ CGM.getCodeGenOpts().OptimizationLevel > 0 &&
  DestRecordTy->getAsCXXRecordDecl()->isEffectivelyFinal() &&
  CGM.getCXXABI().shouldEmitExactDynamicCast(DestRecordTy);
 

diff  --git a/clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp 
b/clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp
index 453337d372b499..9a8ce1997a7f96 100644
--- a/clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp
+++ b/clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -std=c++11 
-o - | FileCheck %s --check-prefixes=CHECK,EXACT
-// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -fvisibility=hidden 
-emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
-// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -fapple-kext 
-emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
-// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 
-fno-assume-unique-vtables -emit-llvm -std=c++11 -o - | FileCheck %s 
--check-prefixes=CHECK,INEXACT
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -O1 -emit-llvm 
-std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,EXACT
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -O0 -emit-llvm 
-std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -O1 
-fvisibility=hidden -emit-llvm -std=c++11 -o - | FileCheck %s 
--check-prefixes=CHECK,INEXACT
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -O1 -fapple-kext 
-emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -O1 
-fno-assume-unique-vtables -emit-llvm -std=c++11 -o - | FileCheck %s 
--check-prefixes=CHECK,INEXACT
 
 struct A { virtual ~A(); };
 struct B final : A { };

diff  --git a/clang/test/CodeGenCXX/dynamic-cast-exact.cpp 
b/clang/test/CodeGenCXX/dynamic-cast-exact.cpp
index b1a81db69115eb..676aa975a72686 100644
--- a/clang/test/CodeGenCXX/dynamic-cast-exact.cpp
+++ b/clang/test/CodeGenCXX/dynamic-cast-exact.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm 
-fcxx-exceptions -fexceptions -std=c++11 -o - | FileCheck %s 
--implicit-check-not='call {{.*}} @__dynamic_cast'
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm 
-fcxx-exceptions -fexceptions -std=c++11 -o - -O1 -disable-llvm-passes | 
FileCheck %s --implicit-check-not='call {{.*}} @__dynamic_cast'
 struct Offset { virtual ~Offset(); };
 struct A { virtual ~A(); };
 struct B final : Offset, A { };



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


[PATCH] D155544: [AIX][TLS][clang] Add -maix-small-local-exec-tls clang option.

2023-07-24 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 543818.
amyk marked 5 inline comments as done.
amyk added a comment.

Address review comments from Hubert and update this patch to be only the clang 
portion of the option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155544

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/aix-small-local-exec-tls.c
  clang/test/OpenMP/target_data_map_codegen_hold.cpp

Index: clang/test/OpenMP/target_data_map_codegen_hold.cpp
===
--- clang/test/OpenMP/target_data_map_codegen_hold.cpp
+++ clang/test/OpenMP/target_data_map_codegen_hold.cpp
@@ -517,7 +517,7 @@
 
 #endif
 //.
-// CHECK-PPC64LE: attributes #[[ATTR0:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="-altivec,-bpermd,-crbits,-crypto,-direct-move,-extdiv,-htm,-isa-v206-instructions,-isa-v207-instructions,-isa-v30-instructions,-power8-vector,-power9-vector,-privileged,-quadword-atomics,-rop-protect,-spe,-vsx" }
+// CHECK-PPC64LE: attributes #[[ATTR0:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="-aix-small-local-exec-tls,-altivec,-bpermd,-crbits,-crypto,-direct-move,-extdiv,-htm,-isa-v206-instructions,-isa-v207-instructions,-isa-v30-instructions,-power8-vector,-power9-vector,-privileged,-quadword-atomics,-rop-protect,-spe,-vsx" }
 // CHECK-PPC64LE: attributes #[[ATTR1:[0-9]+]] = { nounwind }
 // CHECK-PPC64LE: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
 //.
Index: clang/test/Driver/aix-small-local-exec-tls.c
===
--- /dev/null
+++ clang/test/Driver/aix-small-local-exec-tls.c
@@ -0,0 +1,30 @@
+// RUN: %clang -target powerpc64-unknown-aix -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target powerpc-unknown-aix -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
+
+// RUN: %clang -target powerpc64-unknown-aix -maix-small-local-exec-tls -S -emit-llvm \
+// RUN:%s -o - | FileCheck %s --check-prefix=CHECK-AIX_SMALL_LOCALEXEC_TLS
+
+// RUN: not %clang -target powerpc-unknown-aix -maix-small-local-exec-tls \
+// RUN:-fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-AIX32 %s
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -maix-small-local-exec-tls \
+// RUN:-fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-LINUX %s
+// RUN: not %clang -target powerpc64-unknown-linux-gnu -maix-small-local-exec-tls \
+// RUN:-fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-LINUX %s
+
+int test(void) {
+  return 0;
+}
+
+// CHECK: test() #0 {
+// CHECK: attributes #0 = {
+// CHECK-SAME: -aix-small-local-exec-tls
+
+// CHECK-UNSUPPORTED-AIX32: option '-maix-small-local-exec-tls' cannot be specified on this target
+// CHECK-UNSUPPORTED-LINUX: option '-maix-small-local-exec-tls' cannot be specified on this target
+
+// CHECK-AIX_SMALL_LOCALEXEC_TLS: test() #0 {
+// CHECK-AIX_SMALL_LOCALEXEC_TLS: attributes #0 = {
+// CHECK-AIX_SMALL_LOCALEXEC_TLS-SAME: +aix-small-local-exec-tls
+
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -60,6 +60,7 @@
   bool HasMMA = false;
   bool HasROPProtect = false;
   bool HasPrivileged = false;
+  bool HasAIXSmallLocalExecTLS = false;
   bool HasVSX = false;
   bool UseCRBits = false;
   bool HasP8Vector = false;
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -77,6 +77,8 @@
   HasROPProtect = true;
 } else if (Feature == "+privileged") {
   HasPrivileged = true;
+} else if (Feature == "+aix-small-local-exec-tls") {
+  HasAIXSmallLocalExecTLS = true;
 } else if (Feature == "+isa-v206-instructions") {
   IsISA2_06 = true;
 } else if (Feature == "+isa-v207-instructions") {
@@ -541,6 +543,10 @@
   // Privileged instructions are off by default.
   Features["privileged"] = false;
 
+  // The code generated by the -maix-small-local-exec-tls option is turned
+  // off by default.
+  Features["aix-small-local-exec-tls"] = false;
+
   Features["spe"] = llvm::StringSwitch(CPU)
 .Case("8548", true)
 .Case("e500", true)
@@ -635,6 +641,14 @@
 return false;
   }
 
+  if (llvm::is_contained(FeaturesVec, 

[PATCH] D156184: [OpenMP] Add the `ompx_attribute` clause for target directives

2023-07-24 Thread Johannes Doerfert 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 rGef9ec4bbcca2: [OpenMP] Add the `ompx_attribute` clause for 
target directives (authored by jdoerfert).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D156184?vs=543738=543817#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156184

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/ompx_attributes_codegen.cpp
  clang/test/OpenMP/ompx_attributes_messages.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -448,6 +448,10 @@
   let clangClass = "OMPDoacrossClause";
 }
 
+def OMPC_OMPX_Attribute : Clause<"ompx_attribute"> {
+  let clangClass = "OMPXAttributeClause";
+}
+
 //===--===//
 // Definition of OpenMP directives
 //===--===//
@@ -460,7 +464,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
   let allowedOnceClauses = [
 VersionedClause,
@@ -645,7 +650,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
   let allowedOnceClauses = [
 VersionedClause,
@@ -661,7 +667,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
   let allowedOnceClauses = [
 VersionedClause,
@@ -744,7 +751,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
   let allowedOnceClauses = [
 VersionedClause,
@@ -779,7 +787,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
   let allowedOnceClauses = [
 VersionedClause,
@@ -844,7 +853,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
 }
 def OMP_ParallelDo : Directive<"parallel do"> {
@@ -889,7 +899,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
 }
 def OMP_ParallelDoSimd : Directive<"parallel do simd"> {
@@ -929,7 +940,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
 }
 def OMP_ParallelMasked : Directive<"parallel masked"> {
@@ -944,7 +956,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
 }
 def OMP_ParallelSections : Directive<"parallel sections"> {
@@ -958,7 +971,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
   let allowedOnceClauses = [
 VersionedClause
@@ -1127,7 +1141,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
 }
 def OMP_DistributeParallelDo : Directive<"distribute parallel do"> {
@@ -1174,7 +1189,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
 }
 def OMP_DistributeParallelDoSimd : Directive<"distribute parallel do simd"> {
@@ -1256,7 +1272,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
   let allowedOnceClauses = [
 VersionedClause,
@@ -1309,7 +1326,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause,
   ];
   let allowedOnceClauses = [
 

[clang] ef9ec4b - [OpenMP] Add the `ompx_attribute` clause for target directives

2023-07-24 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2023-07-24T22:04:45-07:00
New Revision: ef9ec4bbcca2fa4f64df47bc426f1d1c59ea47e2

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

LOG: [OpenMP] Add the `ompx_attribute` clause for target directives

CUDA and HIP have kernel attributes to tune the code generation (in the
backend). To reuse this functionality for OpenMP target regions we
introduce the `ompx_attribute` clause that takes these kernel
attributes and emits code as if they had been attached to the kernel
fuction (which is implicitly generated).

To limit the impact, we only support three kernel attributes:
`amdgpu_waves_per_eu`, for AMDGPU
`amdgpu_flat_work_group_size`, for AMDGPU
`launch_bounds`, for NVPTX

The existing implementations of those attributes are used for error
checking and code generation. `ompx_attribute` can be attached to any
executable target region and it can hold more than one kernel attribute.

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

Added: 
clang/test/OpenMP/ompx_attributes_codegen.cpp
clang/test/OpenMP/ompx_attributes_messages.cpp

Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/Targets/AMDGPU.cpp
clang/lib/CodeGen/Targets/NVPTX.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 0bea21270692cf..31ae3d42e232fc 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -9172,6 +9172,54 @@ class OMPDoacrossClause final
   }
 };
 
+/// This represents 'ompx_attribute' clause in a directive that might generate
+/// an outlined function. An example is given below.
+///
+/// \code
+/// #pragma omp target [...] ompx_attribute(flatten)
+/// \endcode
+class OMPXAttributeClause
+: public OMPNoChildClause {
+  friend class OMPClauseReader;
+
+  /// Location of '('.
+  SourceLocation LParenLoc;
+
+  /// The parsed attributes (clause arguments)
+  SmallVector Attrs;
+
+public:
+  /// Build 'ompx_attribute' clause.
+  ///
+  /// \param Attrs The parsed attributes (clause arguments)
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param EndLoc Ending location of the clause.
+  OMPXAttributeClause(ArrayRef Attrs, SourceLocation StartLoc,
+  SourceLocation LParenLoc, SourceLocation EndLoc)
+  : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Attrs(Attrs) 
{
+  }
+
+  /// Build an empty clause.
+  OMPXAttributeClause() : OMPNoChildClause() {}
+
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+
+  /// Returns the location of '('.
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+
+  /// Returned the attributes parsed from this clause.
+  ArrayRef getAttrs() const { return Attrs; }
+
+private:
+  /// Replace the attributes with \p NewAttrs.
+  void setAttrs(ArrayRef NewAttrs) {
+Attrs.clear();
+Attrs.append(NewAttrs.begin(), NewAttrs.end());
+  }
+};
+
 } // namespace clang
 
 #endif // LLVM_CLANG_AST_OPENMPCLAUSE_H

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 604875cd6337a4..fc2d1ff708bf7a 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3875,6 +3875,12 @@ bool 
RecursiveASTVisitor::VisitOMPDoacrossClause(
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPXAttributeClause(
+OMPXAttributeClause *C) {
+  return true;
+}
+
 // FIXME: look at the following tricky-seeming exprs to see if we
 // need to recurse on anything.  These are ones that have methods
 // returning decls or qualtypes or nestednamespecifier -- though I'm

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 7b4d415bf06494..6a0a01e4a981a4 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1278,9 +1278,10 @@ def OpenMPMapping : 

[PATCH] D156201: [ASTImporter] Fix two cases on fields circular refs

2023-07-24 Thread Ding Fei via Phabricator via cfe-commits
danix800 created this revision.
danix800 added a project: clang.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: All.
danix800 requested review of this revision.
Herald added a subscriber: cfe-commits.

Fixes two cases on fields circular refs:

1. Field in-class initializer is deferred until all fields are imported. No 
reordering for fields is needed. For final lexical order, see 
https://reviews.llvm.org/D156093
2. UnaryOperator(&)'s creation might need layout of some records whose fields 
importation are still on fly, the layout is incorrectly computed and cached. 
Clients relying on this will not work properly or crash direclty (e.g 
StaticAnalyzer's MemRegion.cpp (calculateOffset)). Use 
UnaryOperator::CreateEmpty() instead of UnaryOperator::Create() to avoid this 
computation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156201

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/AST/RecordLayout.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/SmallVectorMemoryBuffer.h"
@@ -1539,6 +1540,83 @@
   Verifier.match(To, cxxRecordDecl(hasFieldOrder({"a", "b", "c"};
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, FieldCircularRef) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  R"s(
+struct declToImport {
+  int a{a};
+  int b = c;
+  int c = b + c + a;
+};
+  )s",
+  Lang_CXX11, "", Lang_CXX11);
+
+  auto FieldBWithInit = has(fieldDecl(
+  hasName("b"),
+  hasInClassInitializer(ignoringImpCasts(memberExpr(
+  hasObjectExpression(cxxThisExpr()), member(hasName("c")));
+  auto FieldCWithInit = has(fieldDecl(
+  hasName("c"),
+  hasInClassInitializer(binaryOperator(hasLHS(binaryOperator());
+  auto Pattern = cxxRecordDecl(FieldBWithInit, FieldCWithInit,
+   hasFieldOrder({"a", "b", "c"}));
+  MatchVerifier Verifier;
+  ASSERT_TRUE(Verifier.match(From, Pattern));
+  EXPECT_TRUE(Verifier.match(To, Pattern));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportFieldDirectlyWithInitializerContainingCircularRef) {
+  auto Code = R"s(
+struct declToImport {
+  int a{a};
+  int b = c;
+  int c = b + c + a;
+};
+  )s";
+
+  auto *FromField = FirstDeclMatcher().match(
+  getTuDecl(Code, Lang_CXX11), fieldDecl(hasName("b")));
+  auto *ToField = Import(FromField, Lang_CXX11);
+
+  auto Pattern = fieldDecl(
+  hasName("b"),
+  hasInClassInitializer(ignoringImpCasts(memberExpr(
+  hasObjectExpression(cxxThisExpr()), member(hasName("c"));
+
+  MatchVerifier Verifier;
+  ASSERT_TRUE(Verifier.match(FromField, Pattern));
+  EXPECT_TRUE(Verifier.match(ToField, Pattern));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, FieldCircularIndirectRef) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  R"s(
+static int ref_A();
+static int ref_B();
+struct A {
+  int a = ref_B();
+};
+struct B {
+  int b = ref_A();
+};
+int ref_B() { B b; return b.b; }
+int ref_A() { A a; return a.a; }
+  )s",
+  Lang_CXX11, "", Lang_CXX11, "A");
+
+  auto InitByRefB =
+  hasInClassInitializer(callExpr(callee(functionDecl(hasName("ref_B");
+  auto FieldAWithInit = has(fieldDecl(hasName("a"), InitByRefB));
+  auto Pattern =
+  cxxRecordDecl(hasName("A"), FieldAWithInit, hasFieldOrder({"a"}));
+  MatchVerifier Verifier;
+  ASSERT_TRUE(Verifier.match(From, Pattern));
+  EXPECT_TRUE(Verifier.match(To, Pattern));
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
CXXRecordDeclFieldAndIndirectFieldOrder) {
   Decl *From, *To;
@@ -8028,6 +8106,45 @@
   Import(FromF, Lang_CXX11);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportCirularRefFieldsWithoutCorruptedRecordLayoutCacheTest) {
+  // Import sequence: A => A.b => B => B.f() => ... => UnaryOperator(&) => ...
+  //
+  // UnaryOperator(&) force computing RecordLayout of 'A' while it's still not
+  // completely imported.
+  auto Code =
+  R"(
+  class B;
+  class A {
+B* b;
+int c;
+  };
+  class B {
+A *f() { return &((B *)0)->a; }
+A a;
+  };
+  )";
+
+  auto *FromR = FirstDeclMatcher().match(
+  getTuDecl(Code, Lang_CXX11), cxxRecordDecl(hasName("A")));
+  FromR = FromR->getDefinition();
+  auto  = FromR->getASTContext();
+  auto *ToR = Import(FromR, Lang_CXX11);
+  auto  = 

[PATCH] D142327: [clang][RISCV] Fix ABI handling of empty structs with hard FP calling conventions in C++

2023-07-24 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added inline comments.



Comment at: clang/lib/CodeGen/Targets/RISCV.cpp:178
   return false;
-if (isEmptyRecord(getContext(), Ty, true))
+if (isEmptyRecord(getContext(), Ty, true, true))
   return true;

asb wrote:
> rogfer01 wrote:
> > I've observed (based on manually added tracing) that we may return true 
> > here with `Field1Ty == nullptr` and `Field2Ty == nullptr`.
> > 
> > Then `RISCVABIInfo::coerceAndExpandFPCCEligibleStruct` receives these two 
> > types and appends `Field1Ty` it into `UnpaddedCoerceElts` and then if 
> > `Field2Ty == nullptr` it calls `ABIArgInfo::getCoerceAndExpand` (around 
> > line 280 of `clang/lib/CodeGen/Targets/RISCV.cpp`) which then tries to do a 
> > `dyn_cast` on a null value and then an assertion fires (around line 256 of 
> > `clang/include/clang/CodeGen/CGFunctionInfo.h`)
> > 
> > I can reproduce this with the llvm-testsuite. Apologies that I have not 
> > managed to create a small reproducer yet.
> Thank you, I've reverted until this can be investigated and fixed.
LoongArch has the same issue and I write a reproducer:
```
$ cat test.cpp
#include 
#include 

static bool check(int i) {
  return i == 2;
}

int main()
{
  std::vector v{1, 2, 3, 2, 2};
  //return std::count_if(v.begin(), v.end(), check); // ok
  return std::count_if(v.begin(), v.end(), [](int i) { return i == 2; }); // 
error
}
```

Let's investigate how to fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142327

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


[PATCH] D154324: [C++20] [Modules] [ODRHash] Use CanonicalType for base classes

2023-07-24 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@alexfh Thanks for your reproducer! I've reverted the commit. @rsmith thanks 
for your very detailed suggestion too! I'll try to address them in a separate 
review page.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154324

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


[clang] 8a86f85 - Revert "[C++20] [Modules] Use CanonicalType for base classes"

2023-07-24 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-07-25T11:03:57+08:00
New Revision: 8a86f85ab1e65fb5c148d7a645197b4634a2e2fc

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

LOG: Revert "[C++20] [Modules] Use CanonicalType for base classes"

Close https://github.com/llvm/llvm-project/issues/64091

This reverts commit f82df0b285acd8a7115f0bfc55ce44474251c2d1 and add a
test from https://github.com/llvm/llvm-project/issues/64091

Added: 
clang/test/Modules/pr64091.cpp

Modified: 
clang/lib/AST/ODRHash.cpp

Removed: 
clang/test/Modules/pr63595.cppm



diff  --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index 40d68a310dd2a8..507fb0b49f8ad3 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -593,7 +593,7 @@ void ODRHash::AddCXXRecordDecl(const CXXRecordDecl *Record) 
{
   ID.AddInteger(Record->getNumBases());
   auto Bases = Record->bases();
   for (const auto  : Bases) {
-AddQualType(Base.getType().getCanonicalType());
+AddQualType(Base.getType());
 ID.AddInteger(Base.isVirtual());
 ID.AddInteger(Base.getAccessSpecifierAsWritten());
   }

diff  --git a/clang/test/Modules/pr63595.cppm b/clang/test/Modules/pr63595.cppm
deleted file mode 100644
index d1729da490e565..00
--- a/clang/test/Modules/pr63595.cppm
+++ /dev/null
@@ -1,46 +0,0 @@
-// RUN: rm -rf %t
-// RUN: mkdir %t
-// RUN: split-file %s %t
-//
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module1.cppm -o 
%t/module1.pcm
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module2.cppm -o 
%t/module2.pcm
-// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/merge.cpp -verify 
-fsyntax-only
-
-//--- header.h
-namespace NS {
-template 
-class A {
-};
-
-template  class T>
-class B {
-};
-}
-
-//--- module1.cppm
-// inside NS, using C = B
-module;
-#include "header.h"
-export module module1;
-
-namespace NS {
-using C = B;
-}
-export struct D : NS::C {};
-
-//--- module2.cppm
-// inside NS, using C = B
-module;
-#include "header.h"
-export module module2;
-
-namespace NS {
-using C = B;
-}
-export struct D : NS::C {};
-
-//--- merge.cpp
-// expected-no-diagnostics
-import module1;
-import module2;
-D d;

diff  --git a/clang/test/Modules/pr64091.cpp b/clang/test/Modules/pr64091.cpp
new file mode 100644
index 00..6ff45e3c41ae6c
--- /dev/null
+++ b/clang/test/Modules/pr64091.cpp
@@ -0,0 +1,194 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-name=c \
+// RUN: -fmodule-map-file=c.cppmap -xc++ c.cppmap -emit-module -o c.pcm
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-name=a \
+// RUN: -fmodule-map-file=a.cppmap -fmodule-map-file=c.cppmap -xc++ 
a.cppmap \
+// RUN: -emit-module -o a.pcm
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-name=b \
+// RUN: -fmodule-map-file=b.cppmap -fmodule-map-file=c.cppmap -xc++ 
b.cppmap \
+// RUN: -emit-module -o b.pcm
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-name=test \
+// RUN: -fmodule-map-file=test.cppmap -fmodule-map-file=a.cppmap \
+// RUN: -fmodule-map-file=b.cppmap -fmodule-file=a.pcm -fmodule-file=b.pcm 
-xc++ \
+// RUN: test.cc -S -emit-llvm -o - | FileCheck test.cc
+
+//--- a.cppmap
+module "a" {
+  export *
+  module "a.h" {
+export *
+header "a.h"
+  }
+  use "c"
+}
+
+//--- b.cppmap
+module "b" {
+  export *
+  module "b.h" {
+export *
+header "b.h"
+  }
+  use "c"
+}
+
+//--- c.cppmap
+module "c" {
+  export *
+  module "c1.h" {
+export *
+textual header "c1.h"
+  }
+  module "c2.h" {
+export *
+textual header "c2.h"
+  }
+  module "c3.h" {
+export *
+textual header "c3.h"
+  }
+}
+
+//--- test.cppmap
+module "test" {
+  export *
+  use "a"
+  use "b"
+}
+
+//--- a.h
+#ifndef A_H_
+#define A_H_
+
+#include "c1.h"
+
+namespace q {
+template ::value>::type>
+class X {};
+}  // namespace q
+
+#include "c3.h"
+
+#endif  // A_H_
+
+//--- b.h
+#ifndef B_H_
+#define B_H_
+
+#include "c2.h"
+
+#endif  // B_H_
+
+//--- c1.h
+#ifndef C1_H_
+#define C1_H_
+
+namespace std {
+template 
+struct integral_constant {
+  static constexpr const _Tp value = __v;
+  typedef _Tp value_type;
+  typedef integral_constant type;
+  constexpr operator value_type() const noexcept { return value; }
+  constexpr value_type operator()() const noexcept { return value; }
+};
+
+template 
+constexpr const _Tp integral_constant<_Tp, __v>::value;
+
+typedef integral_constant true_type;
+typedef integral_constant false_type;
+
+template 
+struct enable_if {};
+template 
+struct enable_if {
+  typedef _Tp type;
+};
+}  // namespace std
+
+namespace p {
+template 
+struct P : ::std::false_type {};
+}
+
+#endif  // 

[PATCH] D155784: [X86] Update features for sierraforest, grandridge

2023-07-24 Thread Freddy, Ye 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 rG5cc4b1059b28: [X86] Update features for sierraforest, 
grandridge (authored by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155784

Files:
  clang/test/Preprocessor/predefined-arch-macros.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/X86TargetParser.cpp

Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -234,8 +234,8 @@
 FeatureCLDEMOTE | FeatureMOVDIR64B | FeatureMOVDIRI | FeatureWAITPKG |
 FeatureAVXVNNI | FeatureHRESET | FeatureWIDEKL;
 constexpr FeatureBitset FeaturesSierraforest =
-FeaturesAlderlake | FeatureCMPCCXADD | FeatureAVXIFMA |
-FeatureAVXNECONVERT | FeatureAVXVNNIINT8;
+FeaturesAlderlake | FeatureCMPCCXADD | FeatureAVXIFMA | FeatureUINTR |
+FeatureENQCMD | FeatureAVXNECONVERT | FeatureAVXVNNIINT8;
 constexpr FeatureBitset FeaturesGrandridge =
 FeaturesSierraforest | FeatureRAOINT;
 
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -1200,6 +1200,8 @@
   list SRFAdditionalFeatures = [FeatureCMPCCXADD,
   FeatureAVXIFMA,
   FeatureAVXNECONVERT,
+  FeatureENQCMD,
+  FeatureUINTR,
   FeatureAVXVNNIINT8];
   list SRFFeatures =
 !listconcat(ADLFeatures, SRFAdditionalFeatures);
Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -2455,6 +2455,9 @@
 // RUN: %clang -march=sierraforest -m32 -E -dM %s -o - 2>&1 \
 // RUN: --target=i386 \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SRF_M32
+// RUN: %clang -march=grandridge -m32 -E -dM %s -o - 2>&1 \
+// RUN: --target=i386 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefixes=CHECK_SRF_M32,CHECK_GRR_M32
 // CHECK_SRF_M32: #define __ADX__ 1
 // CHECK_SRF_M32: #define __AES__ 1
 // CHECK_SRF_M32: #define __AVX2__ 1
@@ -2470,6 +2473,7 @@
 // CHECK_SRF_M32: #define __CLFLUSHOPT__ 1
 // CHECK_SRF_M32: #define __CLWB__ 1
 // CHECK_SRF_M32: #define __CMPCCXADD__ 1
+// CHECK_SRF_M32: #define __ENQCMD__ 1
 // CHECK_SRF_M32: #define __F16C__ 1
 // CHECK_SRF_M32: #define __FMA__ 1
 // CHECK_SRF_M32: #define __FSGSBASE__ 1
@@ -2489,6 +2493,8 @@
 // CHECK_SRF_M32: #define __POPCNT__ 1
 // CHECK_SRF_M32: #define __PRFCHW__ 1
 // CHECK_SRF_M32: #define __PTWRITE__ 1
+// CHECK_SRF_M32-NOT: #define __RAOINT__ 1
+// CHECK_GRR_M32: #define __RAOINT__ 1
 // CHECK_SRF_M32: #define __RDPID__ 1
 // CHECK_SRF_M32: #define __RDRND__ 1
 // CHECK_SRF_M32: #define __RDSEED__ 1
@@ -2503,6 +2509,7 @@
 // CHECK_SRF_M32: #define __SSE_MATH__ 1
 // CHECK_SRF_M32: #define __SSE__ 1
 // CHECK_SRF_M32: #define __SSSE3__ 1
+// CHECK_SRF_M32: #define __UINTR__ 1
 // CHECK_SRF_M32: #define __VAES__ 1
 // CHECK_SRF_M32: #define __VPCLMULQDQ__ 1
 // CHECK_SRF_M32: #define __WAITPKG__ 1
@@ -2521,6 +2528,9 @@
 // RUN: %clang -march=sierraforest -m64 -E -dM %s -o - 2>&1 \
 // RUN: --target=i386 \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SRF_M64
+// RUN: %clang -march=grandridge -m64 -E -dM %s -o - 2>&1 \
+// RUN: --target=i386 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefixes=CHECK_SRF_M64,CHECK_GRR_M64
 // CHECK_SRF_M64: #define __ADX__ 1
 // CHECK_SRF_M64: #define __AES__ 1
 // CHECK_SRF_M64: #define __AVX2__ 1
@@ -2536,6 +2546,7 @@
 // CHECK_SRF_M64: #define __CLFLUSHOPT__ 1
 // CHECK_SRF_M64: #define __CLWB__ 1
 // CHECK_SRF_M64: #define __CMPCCXADD__ 1
+// CHECK_SRF_M64: #define __ENQCMD__ 1
 // CHECK_SRF_M64: #define __F16C__ 1
 // CHECK_SRF_M64: #define __FMA__ 1
 // CHECK_SRF_M64: #define __FSGSBASE__ 1
@@ -2555,6 +2566,8 @@
 // CHECK_SRF_M64: #define __POPCNT__ 1
 // CHECK_SRF_M64: #define __PRFCHW__ 1
 // CHECK_SRF_M64: #define __PTWRITE__ 1
+// CHECK_SRF_M64-NOT: #define __RAOINT__ 1
+// CHECK_GRR_M64: #define __RAOINT__ 1
 // CHECK_SRF_M64: #define __RDPID__ 1
 // CHECK_SRF_M64: #define __RDRND__ 1
 // CHECK_SRF_M64: #define __RDSEED__ 1
@@ -2570,6 +2583,7 @@
 // CHECK_SRF_M64: #define __SSE_MATH__ 1
 // CHECK_SRF_M64: #define __SSE__ 1
 // CHECK_SRF_M64: #define __SSSE3__ 1
+// CHECK_SRF_M64: #define __UINTR__ 1
 // CHECK_SRF_M64: #define __VAES__ 1
 // CHECK_SRF_M64: #define __VPCLMULQDQ__ 1
 // CHECK_SRF_M64: #define __WAITPKG__ 1
@@ 

[clang] 5cc4b10 - [X86] Update features for sierraforest, grandridge

2023-07-24 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2023-07-25T11:00:41+08:00
New Revision: 5cc4b1059b2842418514a54599a37900b8c608a0

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

LOG: [X86] Update features for sierraforest, grandridge

Reviewed By: pengfei

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

Added: 


Modified: 
clang/test/Preprocessor/predefined-arch-macros.c
llvm/lib/Target/X86/X86.td
llvm/lib/TargetParser/X86TargetParser.cpp

Removed: 




diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index 03d60c528e8e5f..17ea99f91e9ffb 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -2455,6 +2455,9 @@
 // RUN: %clang -march=sierraforest -m32 -E -dM %s -o - 2>&1 \
 // RUN: --target=i386 \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SRF_M32
+// RUN: %clang -march=grandridge -m32 -E -dM %s -o - 2>&1 \
+// RUN: --target=i386 \
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_SRF_M32,CHECK_GRR_M32
 // CHECK_SRF_M32: #define __ADX__ 1
 // CHECK_SRF_M32: #define __AES__ 1
 // CHECK_SRF_M32: #define __AVX2__ 1
@@ -2470,6 +2473,7 @@
 // CHECK_SRF_M32: #define __CLFLUSHOPT__ 1
 // CHECK_SRF_M32: #define __CLWB__ 1
 // CHECK_SRF_M32: #define __CMPCCXADD__ 1
+// CHECK_SRF_M32: #define __ENQCMD__ 1
 // CHECK_SRF_M32: #define __F16C__ 1
 // CHECK_SRF_M32: #define __FMA__ 1
 // CHECK_SRF_M32: #define __FSGSBASE__ 1
@@ -2489,6 +2493,8 @@
 // CHECK_SRF_M32: #define __POPCNT__ 1
 // CHECK_SRF_M32: #define __PRFCHW__ 1
 // CHECK_SRF_M32: #define __PTWRITE__ 1
+// CHECK_SRF_M32-NOT: #define __RAOINT__ 1
+// CHECK_GRR_M32: #define __RAOINT__ 1
 // CHECK_SRF_M32: #define __RDPID__ 1
 // CHECK_SRF_M32: #define __RDRND__ 1
 // CHECK_SRF_M32: #define __RDSEED__ 1
@@ -2503,6 +2509,7 @@
 // CHECK_SRF_M32: #define __SSE_MATH__ 1
 // CHECK_SRF_M32: #define __SSE__ 1
 // CHECK_SRF_M32: #define __SSSE3__ 1
+// CHECK_SRF_M32: #define __UINTR__ 1
 // CHECK_SRF_M32: #define __VAES__ 1
 // CHECK_SRF_M32: #define __VPCLMULQDQ__ 1
 // CHECK_SRF_M32: #define __WAITPKG__ 1
@@ -2521,6 +2528,9 @@
 // RUN: %clang -march=sierraforest -m64 -E -dM %s -o - 2>&1 \
 // RUN: --target=i386 \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SRF_M64
+// RUN: %clang -march=grandridge -m64 -E -dM %s -o - 2>&1 \
+// RUN: --target=i386 \
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_SRF_M64,CHECK_GRR_M64
 // CHECK_SRF_M64: #define __ADX__ 1
 // CHECK_SRF_M64: #define __AES__ 1
 // CHECK_SRF_M64: #define __AVX2__ 1
@@ -2536,6 +2546,7 @@
 // CHECK_SRF_M64: #define __CLFLUSHOPT__ 1
 // CHECK_SRF_M64: #define __CLWB__ 1
 // CHECK_SRF_M64: #define __CMPCCXADD__ 1
+// CHECK_SRF_M64: #define __ENQCMD__ 1
 // CHECK_SRF_M64: #define __F16C__ 1
 // CHECK_SRF_M64: #define __FMA__ 1
 // CHECK_SRF_M64: #define __FSGSBASE__ 1
@@ -2555,6 +2566,8 @@
 // CHECK_SRF_M64: #define __POPCNT__ 1
 // CHECK_SRF_M64: #define __PRFCHW__ 1
 // CHECK_SRF_M64: #define __PTWRITE__ 1
+// CHECK_SRF_M64-NOT: #define __RAOINT__ 1
+// CHECK_GRR_M64: #define __RAOINT__ 1
 // CHECK_SRF_M64: #define __RDPID__ 1
 // CHECK_SRF_M64: #define __RDRND__ 1
 // CHECK_SRF_M64: #define __RDSEED__ 1
@@ -2570,6 +2583,7 @@
 // CHECK_SRF_M64: #define __SSE_MATH__ 1
 // CHECK_SRF_M64: #define __SSE__ 1
 // CHECK_SRF_M64: #define __SSSE3__ 1
+// CHECK_SRF_M64: #define __UINTR__ 1
 // CHECK_SRF_M64: #define __VAES__ 1
 // CHECK_SRF_M64: #define __VPCLMULQDQ__ 1
 // CHECK_SRF_M64: #define __WAITPKG__ 1
@@ -2586,142 +2600,6 @@
 // CHECK_SRF_M64: #define __x86_64 1
 // CHECK_SRF_M64: #define __x86_64__ 1
 
-// RUN: %clang -march=grandridge -m32 -E -dM %s -o - 2>&1 \
-// RUN: --target=i386 \
-// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_GRR_M32
-// CHECK_GRR_M32: #define __ADX__ 1
-// CHECK_GRR_M32: #define __AES__ 1
-// CHECK_GRR_M32: #define __AVX2__ 1
-// CHECK_GRR_M32-NOT: AVX512
-// CHECK_GRR_M32: #define __AVXIFMA__ 1
-// CHECK_GRR_M32: #define __AVXNECONVERT__ 1
-// CHECK_GRR_M32: #define __AVXVNNIINT8__ 1
-// CHECK_GRR_M32: #define __AVXVNNI__ 1
-// CHECK_GRR_M32: #define __AVX__ 1
-// CHECK_GRR_M32: #define __BMI2__ 1
-// CHECK_GRR_M32: #define __BMI__ 1
-// CHECK_GRR_M32: #define __CLDEMOTE__ 1
-// CHECK_GRR_M32: #define __CLFLUSHOPT__ 1
-// CHECK_GRR_M32: #define __CLWB__ 1
-// CHECK_GRR_M32: #define __CMPCCXADD__ 1
-// CHECK_GRR_M32: #define __F16C__ 1
-// CHECK_GRR_M32: #define __FMA__ 1
-// CHECK_GRR_M32: #define __FSGSBASE__ 1
-// CHECK_GRR_M32: #define __FXSR__ 1
-// CHECK_GRR_M32: #define __GFNI__ 1
-// CHECK_GRR_M32: #define __HRESET__ 1
-// CHECK_GRR_M32: #define __INVPCID__ 1
-// CHECK_GRR_M32: #define __KL__ 1
-// 

[PATCH] D154784: [clang] Fix crash caused by PseudoObjectExprBitfields::NumSubExprs overflow

2023-07-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:596-597
 
-// These don't need to be particularly wide, because they're
-// strictly limited by the forms of expressions we permit.
-unsigned NumSubExprs : 8;
-unsigned ResultIndex : 32 - 8 - NumExprBits;
+unsigned NumSubExprs : 16;
+unsigned ResultIndex : 16;
   };

Could/should we add some error checking in the ctor to assert that we don't 
overflow these longer values/just hit the bug later on?

(& could we use `unsigned short` here rather than bitfields?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154784

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


[PATCH] D155798: [X86] Support -march=graniterapids-d and update -march=graniterapids

2023-07-24 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 543797.
FreddyYe marked an inline comment as done.
FreddyYe added a comment.

address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155798

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/X86.cpp
  clang/test/CodeGen/attr-cpuspecific-cpus.c
  clang/test/CodeGen/attr-target-mv.c
  clang/test/CodeGen/target-builtin-noerror.c
  clang/test/Driver/x86-march.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/predefined-arch-macros.c
  compiler-rt/lib/builtins/cpu_model.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/Host.cpp
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -30,6 +30,7 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=sierraforest 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=grandridge 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=graniterapids-d 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=emeraldrapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -88,6 +89,7 @@
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=sierraforest 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=grandridge 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=graniterapids-d 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 define void @foo() {
   ret void
Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -210,8 +210,7 @@
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG;
 constexpr FeatureBitset FeaturesGraniteRapids =
-FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI |
-FeatureAMX_COMPLEX;
+FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI;
 
 // Intel Atom processors.
 // Bonnell has feature parity with Core2 and adds MOVBE.
@@ -429,6 +428,9 @@
   { {"grandridge"}, CK_Grandridge, FEATURE_AVX2, FeaturesGrandridge, 'p', false },
   // Granite Rapids microarchitecture based processors.
   { {"graniterapids"}, CK_Graniterapids, FEATURE_AVX512BF16, FeaturesGraniteRapids, 'n', false },
+  // Granite Rapids D microarchitecture based processors.
+  { {"graniterapids-d"}, CK_GraniterapidsD, FEATURE_AVX512BF16, FeaturesGraniteRapids | FeatureAMX_COMPLEX, '\0', false },
+  { {"graniterapids_d"}, CK_GraniterapidsD, FEATURE_AVX512BF16, FeaturesGraniteRapids | FeatureAMX_COMPLEX, 'n', true },
   // Emerald Rapids microarchitecture based processors.
   { {"emeraldrapids"}, CK_Emeraldrapids, FEATURE_AVX512BF16, FeaturesSapphireRapids, 'n', false },
   // Knights Landing processor.
Index: llvm/lib/TargetParser/Host.cpp
===
--- llvm/lib/TargetParser/Host.cpp
+++ llvm/lib/TargetParser/Host.cpp
@@ -833,13 +833,19 @@
   break;
 
 // Graniterapids:
-case 0xae:
 case 0xad:
   CPU = "graniterapids";
   *Type = X86::INTEL_COREI7;
   *Subtype = X86::INTEL_COREI7_GRANITERAPIDS;
   break;
 
+// Granite Rapids D:
+case 0xae:
+  CPU = "graniterapids-d";
+  *Type = X86::INTEL_COREI7;
+  *Subtype = X86::INTEL_COREI7_GRANITERAPIDS_D;
+  break;
+
 // Icelake Xeon:
 case 0x6a:
 case 0x6c:
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -1078,11 +1078,15 @@
 
   // Graniterapids
   list GNRAdditionalFeatures = [FeatureAMXFP16,
-  FeaturePREFETCHI,
-

[clang] cead149 - Add new option -fkeep-persistent-storage-variables to Clang release notes

2023-07-24 Thread Hubert Tong via cfe-commits

Author: Zheng Qian
Date: 2023-07-24T22:56:18-04:00
New Revision: cead1497ae0c1d57ee6883500c7c205f83798440

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

LOG: Add new option -fkeep-persistent-storage-variables to Clang release notes

This patch updates the Clang release notes with the new option
-fkeep-persistent-storage-variables added in bb6ab91b1dcd.

Reviewed By: hubert.reinterpretcast

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b69e1c7e60e177..89707a658f46bd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -274,6 +274,11 @@ New Compiler Flags
 - ``-fcaret-diagnostics-max-lines=`` has been added as a driver options, which
   lets users control the maximum number of source lines printed for a
   caret diagnostic.
+- ``-fkeep-persistent-storage-variables`` has been implemented to keep all
+  variables that have a persistent storage duration—including global, static
+  and thread-local variables—to guarantee that they can be directly addressed.
+  Since this inhibits the merging of the affected variables, the number of
+  individual relocations in the program will generally increase.
 
 Deprecated Compiler Flags
 -



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


[PATCH] D155501: Add new option -fkeep-persistent-storage-variables to Clang release notes

2023-07-24 Thread Hubert Tong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcead1497ae0c: Add new option 
-fkeep-persistent-storage-variables to Clang release notes (authored by 
qianzhen, committed by hubert.reinterpretcast).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155501

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -274,6 +274,11 @@
 - ``-fcaret-diagnostics-max-lines=`` has been added as a driver options, which
   lets users control the maximum number of source lines printed for a
   caret diagnostic.
+- ``-fkeep-persistent-storage-variables`` has been implemented to keep all
+  variables that have a persistent storage duration—including global, static
+  and thread-local variables—to guarantee that they can be directly addressed.
+  Since this inhibits the merging of the affected variables, the number of
+  individual relocations in the program will generally increase.
 
 Deprecated Compiler Flags
 -


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -274,6 +274,11 @@
 - ``-fcaret-diagnostics-max-lines=`` has been added as a driver options, which
   lets users control the maximum number of source lines printed for a
   caret diagnostic.
+- ``-fkeep-persistent-storage-variables`` has been implemented to keep all
+  variables that have a persistent storage duration—including global, static
+  and thread-local variables—to guarantee that they can be directly addressed.
+  Since this inhibits the merging of the affected variables, the number of
+  individual relocations in the program will generally increase.
 
 Deprecated Compiler Flags
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154366: [clang][ExprConstant] Print template arguments when describing stack frame

2023-07-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

@hazohelet can you commit this yourself, or do you need someone to commit it on 
your behalf? (& if so, what name/email address would you like to be credited)


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

https://reviews.llvm.org/D154366

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


[PATCH] D155239: [clang-format] Add SpacesInParens with SpacesInParensOptions

2023-07-24 Thread Owen Pan 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 rGc669541c969c: [clang-format] Add SpacesInParens with 
SpacesInParensOptions (authored by gedare, committed by owenpan).

Changed prior to commit:
  https://reviews.llvm.org/D155239?vs=543727=543789#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155239

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

Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -807,7 +807,8 @@
"  if (x)\n"
"x = x;",
Style);
-  Style.SpacesInConditionalStatement = true;
+  Style.SpacesInParens = FormatStyle::SIPO_Custom;
+  Style.SpacesInParensOptions.InConditionalStatements = true;
   verifyFormat("if ( x )\n"
"  x = x;\n"
"else if ( x )\n"
@@ -903,7 +904,8 @@
   verifyFormat("repeat (x) begin\n"
"end");
   auto Style = getDefaultStyle();
-  Style.SpacesInConditionalStatement = true;
+  Style.SpacesInParens = FormatStyle::SIPO_Custom;
+  Style.SpacesInParensOptions.InConditionalStatements = true;
   verifyFormat("foreach ( x[x] )\n"
"  x = x;",
Style);
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11031,14 +11031,16 @@
   verifyFormat("template  void operator=(T) && {}", AlignMiddle);
 
   FormatStyle Spaces = getLLVMStyle();
-  Spaces.SpacesInCStyleCastParentheses = true;
+  Spaces.SpacesInParens = FormatStyle::SIPO_Custom;
+  Spaces.SpacesInParensOptions = {};
+  Spaces.SpacesInParensOptions.InCStyleCasts = true;
   verifyFormat("Deleted =(const Deleted &) & = default;", Spaces);
   verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;", Spaces);
   verifyFormat("Deleted =(const Deleted &) &;", Spaces);
   verifyFormat("SomeType MemberFunction(const Deleted &) &;", Spaces);
 
-  Spaces.SpacesInCStyleCastParentheses = false;
-  Spaces.SpacesInParentheses = true;
+  Spaces.SpacesInParensOptions.InCStyleCasts = false;
+  Spaces.SpacesInParensOptions.Other = true;
   verifyFormat("Deleted =( const Deleted & ) & = default;", Spaces);
   verifyFormat("SomeType MemberFunction( const Deleted & ) & = delete;",
Spaces);
@@ -13674,7 +13676,8 @@
 
   FormatStyle SpaceBetweenBraces = getLLVMStyle();
   SpaceBetweenBraces.SpacesInAngles = FormatStyle::SIAS_Always;
-  SpaceBetweenBraces.SpacesInParentheses = true;
+  SpaceBetweenBraces.SpacesInParens = FormatStyle::SIPO_Custom;
+  SpaceBetweenBraces.SpacesInParensOptions.Other = true;
   SpaceBetweenBraces.SpacesInSquareBrackets = true;
   verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
   verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces);
@@ -13697,7 +13700,8 @@
 "};",
 format("vectorx{1,2,3,4,};", SpaceBetweenBraces));
   verifyFormat("vector< int > x{};", SpaceBetweenBraces);
-  SpaceBetweenBraces.SpaceInEmptyParentheses = true;
+  SpaceBetweenBraces.SpacesInParens = FormatStyle::SIPO_Custom;
+  SpaceBetweenBraces.SpacesInParensOptions.InEmptyParentheses = true;
   verifyFormat("vector< int > x{ };", SpaceBetweenBraces);
 }
 
@@ -16707,10 +16711,43 @@
   verifyFormat("! ! x", Spaces);
 }
 
-TEST_F(FormatTest, ConfigurableSpacesInParentheses) {
+TEST_F(FormatTest, ConfigurableSpacesInParens) {
   FormatStyle Spaces = getLLVMStyle();
 
-  Spaces.SpacesInParentheses = true;
+  verifyFormat("do_something(::globalVar);", Spaces);
+  verifyFormat("call(x, y, z);", Spaces);
+  verifyFormat("call();", Spaces);
+  verifyFormat("std::function callback;", Spaces);
+  verifyFormat("void inFunction() { std::function fct; }",
+   Spaces);
+  verifyFormat("while ((bool)1)\n"
+   "  continue;",
+   Spaces);
+  verifyFormat("for (;;)\n"
+   "  continue;",
+   Spaces);
+  verifyFormat("if (true)\n"
+   "  f();\n"
+   "else if (true)\n"
+   "  f();",
+   Spaces);
+  verifyFormat("do {\n"
+   "  do_something((int)i);\n"
+   "} while (something());",
+   Spaces);
+  verifyFormat("switch (x) {\n"
+   "default:\n"
+   "  break;\n"
+   "}",
+   Spaces);
+  verifyFormat("SomeType 

[clang] c669541 - [clang-format] Add SpacesInParens with SpacesInParensOptions

2023-07-24 Thread Owen Pan via cfe-commits

Author: Gedare Bloom
Date: 2023-07-24T19:27:23-07:00
New Revision: c669541c969c70190933b4a16384c60de80242c0

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

LOG: [clang-format] Add SpacesInParens with SpacesInParensOptions

This is a refactoring of:
- SpacesInConditionalStatement
- SpacesInCStyleCastParentheses
- SpaceInEmptyParentheses
- SpacesInParentheses

These are now options under the new Style Option: SpacesInParens. The
existing options are maintained for backward compatibility.

Within SpacesInParens, there are currently options for:
- Never
- Custom

The currently available options for Custom are:
- InConditionalStatements
- InCStyleCasts
- InEmptyParentheses
- Other

Setting InConditionalStatements and Other to true enables the same space
additions as SpacesInParentheses.

This refactoring does not add or remove any existing features, but it makes
it possible to more easily extend and maintain the addition of spaces within
parentheses.

Related to #55428.

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestVerilog.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index e85b8c0b1edc26..6f02a436b0ac81 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5215,16 +5215,8 @@ the configuration (without a prefix: ``Auto``).
 
 **SpaceInEmptyParentheses** (``Boolean``) :versionbadge:`clang-format 3.7` 
:ref:`¶ `
   If ``true``, spaces may be inserted into ``()``.
-
-  .. code-block:: c++
-
- true:false:
- void f( ) {vs.   void f() {
-   int x[] = {foo( ), bar( )};  int x[] = {foo(), bar()};
-   if (true) {  if (true) {
- f( );f();
-   }}
- }}
+  This option is **deprecated**. See ``InEmptyParentheses`` of
+  ``SpacesInParensOptions``.
 
 .. _SpacesBeforeTrailingComments:
 
@@ -5281,23 +5273,16 @@ the configuration (without a prefix: ``Auto``).
 
 **SpacesInCStyleCastParentheses** (``Boolean``) :versionbadge:`clang-format 
3.7` :ref:`¶ `
   If ``true``, spaces may be inserted into C style casts.
-
-  .. code-block:: c++
-
- true:  false:
- x = ( int32 )y vs. x = (int32)y
+  This option is **deprecated**. See ``InCStyleCasts`` of
+  ``SpacesInParensOptions``.
 
 .. _SpacesInConditionalStatement:
 
 **SpacesInConditionalStatement** (``Boolean``) :versionbadge:`clang-format 10` 
:ref:`¶ `
   If ``true``, spaces will be inserted around if/for/switch/while
   conditions.
-
-  .. code-block:: c++
-
- true:  false:
- if ( a )  { ... }  vs. if (a) { ... }
- while ( i < 5 )  { ... }   while (i < 5) { ... }
+  This option is **deprecated**. See ``InConditionalStatements`` of
+  ``SpacesInParensOptions``.
 
 .. _SpacesInContainerLiterals:
 
@@ -5358,15 +5343,104 @@ the configuration (without a prefix: ``Auto``).
   * ``unsigned Maximum`` The maximum number of spaces at the start of the 
comment.
 
 
-.. _SpacesInParentheses:
+.. _SpacesInParens:
 
-**SpacesInParentheses** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ 
`
-  If ``true``, spaces will be inserted after ``(`` and before ``)``.
+**SpacesInParens** (``SpacesInParensStyle``) :versionbadge:`clang-format 17` 
:ref:`¶ `
+  Defines in which cases spaces will be inserted after ``(`` and before
+  ``)``.
+
+  Possible values:
+
+  * ``SIPO_Never`` (in configuration: ``Never``)
+Never put a space in parentheses.
+
+.. code-block:: c++
+
+   void f() {
+ if(true) {
+   f();
+ }
+   }
+
+  * ``SIPO_Custom`` (in configuration: ``Custom``)
+Configure each individual space in parentheses in
+`SpacesInParensOptions`.
+
+
+
+.. _SpacesInParensOptions:
+
+**SpacesInParensOptions** (``SpacesInParensCustom``) 
:versionbadge:`clang-format 17` :ref:`¶ `
+  Control of individual spaces in parentheses.
+
+  If ``SpacesInParens`` is set to ``Custom``, use this to specify
+  how each individual space in parentheses case should be handled.
+  Otherwise, this is ignored.
+
+  .. code-block:: yaml
+
+# Example of usage:
+SpacesInParens: Custom
+SpacesInParensOptions:
+  InConditionalStatements: 

[PATCH] D156090: [Driver][XRay][test] Mark these tests as supported on loongarch64

2023-07-24 Thread Limin Zhang via Phabricator via cfe-commits
Ami-zhang abandoned this revision.
Ami-zhang added a comment.

Thanks @MaskRay .
05c2c09bb1f10261f6f804a2d510c55d97b1584c 
 improved 
these XRay tests.
Abandon this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156090

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


[PATCH] D155239: [clang-format] Add SpacesInParens with SpacesInParensOptions

2023-07-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:830
+- Add ``SpacesInParens`` style with ``SpacesInParensOptions`` to replace
+  ``SpacesInConditionalStatement``, ``SpacesInCStyleCastParentheses``, 
+  ``SpaceInEmptyParentheses``, and ``SpacesInParentheses``.





Comment at: clang/include/clang/Format/Format.h:4245
+SpacesInParensCustom(bool InConditionalStatements, bool InCStyleCasts,
+bool InEmptyParentheses, bool Other)
+: InConditionalStatements(InConditionalStatements),





Comment at: clang/include/clang/Format/Format.h:4247-4248
+: InConditionalStatements(InConditionalStatements),
+  InCStyleCasts(InCStyleCasts),
+  InEmptyParentheses(InEmptyParentheses),
+  Other(Other) {}





Comment at: clang/include/clang/Format/Format.h:4254-4255
+ InCStyleCasts == R.InCStyleCasts &&
+ InEmptyParentheses == R.InEmptyParentheses &&
+ Other == R.Other;
+}




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155239

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


[PATCH] D156195: [docs] Add llvm & clang release notes for LoongArch

2023-07-24 Thread Lu Weining via Phabricator via cfe-commits
SixWeining created this revision.
SixWeining added reviewers: xen0n, xry111, hev, wangleiat.
Herald added a project: All.
SixWeining requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156195

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -199,9 +199,13 @@
 Changes to the LoongArch Backend
 
 
+* Adds assembler/disassembler support for the ``LSX``, ``LASX``, ``LVZ`` and
+  ``LBT`` ISA extensions.
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal 
target.
 * A target feature ``ual`` is introduced to allow unaligned memory accesses and
   this feature is enabled by default for generic 64-bit processors.
+* Adds support for the ``large`` code model.
+* Several codegen improvements are made.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -891,6 +891,8 @@
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
   aliases ``-m[no-]strict-align``.
+- Non ``$``-prefixed GPR names (e.g. ``r4`` and ``a0``) are allowed in 
inlineasm
+  like GCC does.
 
 RISC-V Support
 ^^


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -199,9 +199,13 @@
 Changes to the LoongArch Backend
 
 
+* Adds assembler/disassembler support for the ``LSX``, ``LASX``, ``LVZ`` and
+  ``LBT`` ISA extensions.
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal target.
 * A target feature ``ual`` is introduced to allow unaligned memory accesses and
   this feature is enabled by default for generic 64-bit processors.
+* Adds support for the ``large`` code model.
+* Several codegen improvements are made.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -891,6 +891,8 @@
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or the
   aliases ``-m[no-]strict-align``.
+- Non ``$``-prefixed GPR names (e.g. ``r4`` and ``a0``) are allowed in inlineasm
+  like GCC does.
 
 RISC-V Support
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-07-24 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

@xen0n Do you have any inputs? I think supporting these options can improve 
compatibility with gcc (although there is no ScheduleModel difference among 
currently supported processors) and I hope it can be merged into LLVM17.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

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


[PATCH] D156089: [Driver][XRay][test] Convert more tests to check 'target=...' after 016785d9316d8c5abc5fdf3cdb86479095bbb677

2023-07-24 Thread Lu Weining via Phabricator via cfe-commits
SixWeining abandoned this revision.
SixWeining added a comment.

841ff7c6ca4c6fa9ff3ac6ba93e177462b7d668e 
 addresses 
this issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156089

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


[clang] 74720d1 - [clang-format] Add AlignConsecutiveShortCaseStatements

2023-07-24 Thread Owen Pan via cfe-commits

Author: Galen Elias
Date: 2023-07-24T18:39:25-07:00
New Revision: 74720d1b338efb0725dd80bf3e59069700f6e2f0

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

LOG: [clang-format] Add AlignConsecutiveShortCaseStatements

This adds a new AlignConsecutiveShortCaseStatements option in line with the
existing AlignConsecutive* options , which when
AllowShortCaseLabelsOnASingleLine is enabled will align the tokens after the
case statement's colon. This also adds a AlignCaseColons option to allow
aligning the case label colon itself rather than the token after it.

Fixes #55475.

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 7547aa2a55a71c..e85b8c0b1edc26 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -789,6 +789,104 @@ the configuration (without a prefix: ``Auto``).
   bbb >>= 2;
 
 
+.. _AlignConsecutiveShortCaseStatements:
+
+**AlignConsecutiveShortCaseStatements** 
(``ShortCaseStatementsAlignmentStyle``) :versionbadge:`clang-format 17` :ref:`¶ 
`
+  Style of aligning consecutive short case labels.
+  Only applies if ``AllowShortCaseLabelsOnASingleLine`` is ``true``.
+
+
+  .. code-block:: yaml
+
+# Example of usage:
+AlignConsecutiveShortCaseStatements:
+  Enabled: true
+  AcrossEmptyLines: true
+  AcrossComments: true
+  AlignCaseColons: false
+
+  Nested configuration flags:
+
+  Alignment options.
+
+  * ``bool Enabled`` Whether aligning is enabled.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  default:   return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info: return "info:";
+  case log::warning: return "warning:";
+  default: return "";
+  }
+
+  * ``bool AcrossEmptyLines`` Whether to align across empty lines.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+
+  default:   return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+
+  default: return "";
+  }
+
+  * ``bool AcrossComments`` Whether to align across comments.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  /* A comment. */
+  default:   return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  /* A comment. */
+  default: return "";
+  }
+
+  * ``bool AlignCaseColons`` Whether aligned case labels are aligned on the 
colon, or on the
+, or on the tokens after the colon.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info   : return "info:";
+  case log::warning: return "warning:";
+  default  : return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  default:   return "";
+  }
+
+
 .. _AlignEscapedNewlines:
 
 **AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) 
:versionbadge:`clang-format 5` :ref:`¶ `

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4f82edd0d03d14..13fb95b8767c3b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -988,6 +988,8 @@ clang-format
 - Add ``KeepEmptyLinesAtEOF`` to keep empty lines at end of file.
 - Add ``RemoveParentheses`` to remove redundant parentheses.
 - Add ``TypeNames`` to treat listed non-keyword identifiers as type names.
+- Add ``AlignConsecutiveShortCaseStatements`` which can be used to align case
+  labels in conjunction with ``AllowShortCaseLabelsOnASingleLine``.
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 8cb8dd23c19427..7b429d51d49b4b 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -299,6 +299,103 @@ struct FormatStyle {
   /// \version 3.8
   AlignConsecutiveStyle AlignConsecutiveDeclarations;
 
+  

[clang] 87ad34f - Revert "[clang-format] Add AlignConsecutiveShortCaseStatements"

2023-07-24 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-07-24T18:37:42-07:00
New Revision: 87ad34ffdcf2de99dab0ac86f148a03e4bd2dddc

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

LOG: Revert "[clang-format] Add AlignConsecutiveShortCaseStatements"

This reverts commit 4ba00844174db562d2bd8b15dab6aac605eddf57.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index e85b8c0b1edc26..7547aa2a55a71c 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -789,104 +789,6 @@ the configuration (without a prefix: ``Auto``).
   bbb >>= 2;
 
 
-.. _AlignConsecutiveShortCaseStatements:
-
-**AlignConsecutiveShortCaseStatements** 
(``ShortCaseStatementsAlignmentStyle``) :versionbadge:`clang-format 17` :ref:`¶ 
`
-  Style of aligning consecutive short case labels.
-  Only applies if ``AllowShortCaseLabelsOnASingleLine`` is ``true``.
-
-
-  .. code-block:: yaml
-
-# Example of usage:
-AlignConsecutiveShortCaseStatements:
-  Enabled: true
-  AcrossEmptyLines: true
-  AcrossComments: true
-  AlignCaseColons: false
-
-  Nested configuration flags:
-
-  Alignment options.
-
-  * ``bool Enabled`` Whether aligning is enabled.
-
-.. code-block:: c++
-
-  true:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-  default:   return "";
-  }
-
-  false:
-  switch (level) {
-  case log::info: return "info:";
-  case log::warning: return "warning:";
-  default: return "";
-  }
-
-  * ``bool AcrossEmptyLines`` Whether to align across empty lines.
-
-.. code-block:: c++
-
-  true:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-
-  default:   return "";
-  }
-
-  false:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-
-  default: return "";
-  }
-
-  * ``bool AcrossComments`` Whether to align across comments.
-
-.. code-block:: c++
-
-  true:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-  /* A comment. */
-  default:   return "";
-  }
-
-  false:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-  /* A comment. */
-  default: return "";
-  }
-
-  * ``bool AlignCaseColons`` Whether aligned case labels are aligned on the 
colon, or on the
-, or on the tokens after the colon.
-
-.. code-block:: c++
-
-  true:
-  switch (level) {
-  case log::info   : return "info:";
-  case log::warning: return "warning:";
-  default  : return "";
-  }
-
-  false:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-  default:   return "";
-  }
-
-
 .. _AlignEscapedNewlines:
 
 **AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) 
:versionbadge:`clang-format 5` :ref:`¶ `

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 13fb95b8767c3b..4f82edd0d03d14 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -988,8 +988,6 @@ clang-format
 - Add ``KeepEmptyLinesAtEOF`` to keep empty lines at end of file.
 - Add ``RemoveParentheses`` to remove redundant parentheses.
 - Add ``TypeNames`` to treat listed non-keyword identifiers as type names.
-- Add ``AlignConsecutiveShortCaseStatements`` which can be used to align case
-  labels in conjunction with ``AllowShortCaseLabelsOnASingleLine``.
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7b429d51d49b4b..8cb8dd23c19427 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -299,103 +299,6 @@ struct FormatStyle {
   /// \version 3.8
   AlignConsecutiveStyle AlignConsecutiveDeclarations;
 
-  /// Alignment options.
-  ///
-  struct ShortCaseStatementsAlignmentStyle {
-/// Whether aligning is enabled.
-/// \code
-///   true:
-///   switch (level) {
-///   case log::info:return "info:";
-///   case log::warning: return "warning:";
-///   default:   return "";
-///   }
-///
-///   

[PATCH] D155997: [Phase Ordering] Don't speculate in SimplifyCFG before PGO annotation

2023-07-24 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D155997#4529861 , @aeubanks wrote:

> the pipeline change and simplifycfg change should be split into two changes

SimplifyCFG change split into D156194 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155997

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


[PATCH] D155814: Fix the linting problems which causes `clang/utils/ci/run-buildbot check-format` to return 1.

2023-07-24 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 accepted this revision.
ziqingluo-90 added a comment.
This revision is now accepted and ready to land.

Thanks for cleaning the trailing whites.


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

https://reviews.llvm.org/D155814

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


[clang] ac6e551 - Revert "Revert "[clang-format] Add AlignConsecutiveShortCaseStatements""

2023-07-24 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-07-24T18:24:30-07:00
New Revision: ac6e55146f8c48f8ced95dfe54004142c0b36756

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

LOG: Revert "Revert "[clang-format] Add AlignConsecutiveShortCaseStatements""

This reverts commit 4f093b31669a4f8e417259583141159586a05b28.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 7547aa2a55a71c..e85b8c0b1edc26 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -789,6 +789,104 @@ the configuration (without a prefix: ``Auto``).
   bbb >>= 2;
 
 
+.. _AlignConsecutiveShortCaseStatements:
+
+**AlignConsecutiveShortCaseStatements** 
(``ShortCaseStatementsAlignmentStyle``) :versionbadge:`clang-format 17` :ref:`¶ 
`
+  Style of aligning consecutive short case labels.
+  Only applies if ``AllowShortCaseLabelsOnASingleLine`` is ``true``.
+
+
+  .. code-block:: yaml
+
+# Example of usage:
+AlignConsecutiveShortCaseStatements:
+  Enabled: true
+  AcrossEmptyLines: true
+  AcrossComments: true
+  AlignCaseColons: false
+
+  Nested configuration flags:
+
+  Alignment options.
+
+  * ``bool Enabled`` Whether aligning is enabled.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  default:   return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info: return "info:";
+  case log::warning: return "warning:";
+  default: return "";
+  }
+
+  * ``bool AcrossEmptyLines`` Whether to align across empty lines.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+
+  default:   return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+
+  default: return "";
+  }
+
+  * ``bool AcrossComments`` Whether to align across comments.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  /* A comment. */
+  default:   return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  /* A comment. */
+  default: return "";
+  }
+
+  * ``bool AlignCaseColons`` Whether aligned case labels are aligned on the 
colon, or on the
+, or on the tokens after the colon.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info   : return "info:";
+  case log::warning: return "warning:";
+  default  : return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  default:   return "";
+  }
+
+
 .. _AlignEscapedNewlines:
 
 **AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) 
:versionbadge:`clang-format 5` :ref:`¶ `

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4f82edd0d03d14..13fb95b8767c3b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -988,6 +988,8 @@ clang-format
 - Add ``KeepEmptyLinesAtEOF`` to keep empty lines at end of file.
 - Add ``RemoveParentheses`` to remove redundant parentheses.
 - Add ``TypeNames`` to treat listed non-keyword identifiers as type names.
+- Add ``AlignConsecutiveShortCaseStatements`` which can be used to align case
+  labels in conjunction with ``AllowShortCaseLabelsOnASingleLine``.
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 8cb8dd23c19427..7b429d51d49b4b 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -299,6 +299,103 @@ struct FormatStyle {
   /// \version 3.8
   AlignConsecutiveStyle AlignConsecutiveDeclarations;
 
+  /// Alignment options.
+  ///
+  struct ShortCaseStatementsAlignmentStyle {
+/// Whether aligning is enabled.
+/// \code
+///   true:
+///   switch (level) {
+///   case log::info:return "info:";
+///   case log::warning: return "warning:";
+///   default:   return "";
+///   }
+///
+

[PATCH] D156116: [Clang][LoongArch] Fix ABI handling of empty structs in C++ to match GCC behaviour

2023-07-24 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

In D156116#4530365 , @thakis wrote:

> This seems to not build: http://45.33.8.238/linux/113405/step_4.txt (?)

Thanks, I have reverted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156116

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


[clang] 4f093b3 - Revert "[clang-format] Add AlignConsecutiveShortCaseStatements"

2023-07-24 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-07-24T18:19:38-07:00
New Revision: 4f093b31669a4f8e417259583141159586a05b28

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

LOG: Revert "[clang-format] Add AlignConsecutiveShortCaseStatements"

This reverts commit 4ba00844174db562d2bd8b15dab6aac605eddf57 due to missing
authorship.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index e85b8c0b1edc26..7547aa2a55a71c 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -789,104 +789,6 @@ the configuration (without a prefix: ``Auto``).
   bbb >>= 2;
 
 
-.. _AlignConsecutiveShortCaseStatements:
-
-**AlignConsecutiveShortCaseStatements** 
(``ShortCaseStatementsAlignmentStyle``) :versionbadge:`clang-format 17` :ref:`¶ 
`
-  Style of aligning consecutive short case labels.
-  Only applies if ``AllowShortCaseLabelsOnASingleLine`` is ``true``.
-
-
-  .. code-block:: yaml
-
-# Example of usage:
-AlignConsecutiveShortCaseStatements:
-  Enabled: true
-  AcrossEmptyLines: true
-  AcrossComments: true
-  AlignCaseColons: false
-
-  Nested configuration flags:
-
-  Alignment options.
-
-  * ``bool Enabled`` Whether aligning is enabled.
-
-.. code-block:: c++
-
-  true:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-  default:   return "";
-  }
-
-  false:
-  switch (level) {
-  case log::info: return "info:";
-  case log::warning: return "warning:";
-  default: return "";
-  }
-
-  * ``bool AcrossEmptyLines`` Whether to align across empty lines.
-
-.. code-block:: c++
-
-  true:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-
-  default:   return "";
-  }
-
-  false:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-
-  default: return "";
-  }
-
-  * ``bool AcrossComments`` Whether to align across comments.
-
-.. code-block:: c++
-
-  true:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-  /* A comment. */
-  default:   return "";
-  }
-
-  false:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-  /* A comment. */
-  default: return "";
-  }
-
-  * ``bool AlignCaseColons`` Whether aligned case labels are aligned on the 
colon, or on the
-, or on the tokens after the colon.
-
-.. code-block:: c++
-
-  true:
-  switch (level) {
-  case log::info   : return "info:";
-  case log::warning: return "warning:";
-  default  : return "";
-  }
-
-  false:
-  switch (level) {
-  case log::info:return "info:";
-  case log::warning: return "warning:";
-  default:   return "";
-  }
-
-
 .. _AlignEscapedNewlines:
 
 **AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) 
:versionbadge:`clang-format 5` :ref:`¶ `

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 13fb95b8767c3b..4f82edd0d03d14 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -988,8 +988,6 @@ clang-format
 - Add ``KeepEmptyLinesAtEOF`` to keep empty lines at end of file.
 - Add ``RemoveParentheses`` to remove redundant parentheses.
 - Add ``TypeNames`` to treat listed non-keyword identifiers as type names.
-- Add ``AlignConsecutiveShortCaseStatements`` which can be used to align case
-  labels in conjunction with ``AllowShortCaseLabelsOnASingleLine``.
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7b429d51d49b4b..8cb8dd23c19427 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -299,103 +299,6 @@ struct FormatStyle {
   /// \version 3.8
   AlignConsecutiveStyle AlignConsecutiveDeclarations;
 
-  /// Alignment options.
-  ///
-  struct ShortCaseStatementsAlignmentStyle {
-/// Whether aligning is enabled.
-/// \code
-///   true:
-///   switch (level) {
-///   case log::info:return "info:";
-///   case log::warning: return "warning:";
-///   default:   return "";
-///   }

[clang] 983f248 - Revert "[Clang][LoongArch] Fix ABI handling of empty structs in C++ to match GCC behaviour"

2023-07-24 Thread Weining Lu via cfe-commits

Author: Weining Lu
Date: 2023-07-25T09:18:06+08:00
New Revision: 983f2488326e1f8034f3b0686cd44221d8697bdc

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

LOG: Revert "[Clang][LoongArch] Fix ABI handling of empty structs in C++ to 
match GCC behaviour"

This reverts commit c299efbf284fae92bb8d7d29110f76912f089daf.

Reason to revert: D142327 has been reverted which is depended by this
change.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/Targets/LoongArch.cpp
clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 45753a651e723a..13fb95b8767c3b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -891,8 +891,6 @@ LoongArch Support
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
   aliases ``-m[no-]strict-align``.
-- An ABI mismatch between GCC and Clang related to the handling of empty 
structs
-  in C++ parameter passing under ``lp64d`` ABI was fixed.
 
 RISC-V Support
 ^^

diff  --git a/clang/lib/CodeGen/Targets/LoongArch.cpp 
b/clang/lib/CodeGen/Targets/LoongArch.cpp
index 056b3946d1b33f..6391a8aeaa67cd 100644
--- a/clang/lib/CodeGen/Targets/LoongArch.cpp
+++ b/clang/lib/CodeGen/Targets/LoongArch.cpp
@@ -148,13 +148,6 @@ bool LoongArchABIInfo::detectFARsEligibleStructHelper(
   if (const ConstantArrayType *ATy = getContext().getAsConstantArrayType(Ty)) {
 uint64_t ArraySize = ATy->getSize().getZExtValue();
 QualType EltTy = ATy->getElementType();
-// Non-zero-length arrays of empty records make the struct ineligible to be
-// passed via FARs in C++.
-if (const auto *RTy = EltTy->getAs()) {
-  if (ArraySize != 0 && isa(RTy->getDecl()) &&
-  isEmptyRecord(getContext(), EltTy, true, true))
-return false;
-}
 CharUnits EltSize = getContext().getTypeSizeInChars(EltTy);
 for (uint64_t i = 0; i < ArraySize; ++i) {
   if (!detectFARsEligibleStructHelper(EltTy, CurOff, Field1Ty, Field1Off,
@@ -170,7 +163,7 @@ bool LoongArchABIInfo::detectFARsEligibleStructHelper(
 // copy constructor are not eligible for the FP calling convention.
 if (getRecordArgABI(Ty, CGT.getCXXABI()))
   return false;
-if (isEmptyRecord(getContext(), Ty, true, true))
+if (isEmptyRecord(getContext(), Ty, true))
   return true;
 const RecordDecl *RD = RTy->getDecl();
 // Unions aren't eligible unless they're empty (which is caught above).

diff  --git a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c 
b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
index b5c7916f57cd99..3a65b90e48e0e0 100644
--- a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
+++ b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d 
-target-abi lp64d -emit-llvm %s -o - -x c++ | \
 // RUN:   FileCheck --check-prefix=CHECK-CXX %s
 
+// FIXME: This isn't currently respected.
 // Fields containing empty structs or unions are ignored when flattening
 // structs to examine whether the structs can be passed via FARs, even in C++.
 // But there is an exception that non-zero-length array of empty structures are
@@ -15,7 +16,7 @@ struct empty { struct { struct { } e; }; };
 struct s1 { struct empty e; float f; };
 
 // CHECK-C: define{{.*}} float @test_s1(float {{.*}})
-// CHECK-CXX: define{{.*}} float @_Z7test_s12s1(float {{.*}})
+// CHECK-CXX: define{{.*}} i64 @_Z7test_s12s1(i64 {{.*}})
 struct s1 test_s1(struct s1 a) {
   return a;
 }
@@ -23,7 +24,7 @@ struct s1 test_s1(struct s1 a) {
 struct s2 { struct empty e; int32_t i; float f; };
 
 // CHECK-C: define{{.*}} { i32, float } @test_s2(i32 {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} { i32, float } @_Z7test_s22s2(i32 {{.*}}, float 
{{.*}})
+// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s22s2([2 x i64] {{.*}})
 struct s2 test_s2(struct s2 a) {
   return a;
 }
@@ -31,7 +32,7 @@ struct s2 test_s2(struct s2 a) {
 struct s3 { struct empty e; float f; float g; };
 
 // CHECK-C: define{{.*}} { float, float } @test_s3(float {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} { float, float } @_Z7test_s32s3(float {{.*}}, float 
{{.*}})
+// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s32s3([2 x i64] {{.*}})
 struct s3 test_s3(struct s3 a) {
   return a;
 }
@@ -39,7 +40,7 @@ struct s3 test_s3(struct s3 a) {
 struct s4 { struct empty e; float __complex__ c; };
 
 // CHECK-C: define{{.*}} { float, float } @test_s4(float {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} { float, float } @_Z7test_s42s4(float {{.*}}, float 
{{.*}})
+// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s42s4([2 x i64] {{.*}})
 

[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

2023-07-24 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4ba00844174d: [clang-format] Add 
AlignConsecutiveShortCaseStatements (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151761

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19261,6 +19261,240 @@
BracedAlign);
 }
 
+TEST_F(FormatTest, AlignConsecutiveShortCaseStatements) {
+  FormatStyle Alignment = getLLVMStyle();
+  Alignment.AllowShortCaseLabelsOnASingleLine = true;
+  Alignment.AlignConsecutiveShortCaseStatements.Enabled = true;
+
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "default:   return \"default\";\n"
+   "}",
+   Alignment);
+
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:\n"
+   "  return \"warning\";\n"
+   "}",
+   Alignment);
+
+  // Empty case statements push out the alignment, but non-short case labels
+  // don't.
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::critical:\n"
+   "case log::warning:\n"
+   "case log::severe:   return \"severe\";\n"
+   "case log::extra_severe:\n"
+   "  // comment\n"
+   "  return \"extra_severe\";\n"
+   "}",
+   Alignment);
+
+  // Verify comments and empty lines break the alignment.
+  verifyNoChange("switch (level) {\n"
+ "case log::info:return \"info\";\n"
+ "case log::warning: return \"warning\";\n"
+ "// comment\n"
+ "case log::critical: return \"critical\";\n"
+ "default:return \"default\";\n"
+ "\n"
+ "case log::severe: return \"severe\";\n"
+ "}",
+ Alignment);
+
+  // Empty case statements don't break the alignment, and potentially push it
+  // out.
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:\n"
+   "case log::critical:\n"
+   "default:return \"default\";\n"
+   "}",
+   Alignment);
+
+  // Implicit fallthrough cases can be aligned with either a comment or
+  // [[fallthrough]]
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:  // fallthrough\n"
+   "case log::error:return \"error\";\n"
+   "case log::critical: /*fallthrough*/\n"
+   "case log::severe:   return \"severe\";\n"
+   "case log::diag: [[fallthrough]];\n"
+   "default:return \"default\";\n"
+   "}",
+   Alignment);
+
+  // Verify trailing comment that needs a reflow also gets aligned properly.
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: // fallthrough\n"
+   "case log::error:   return \"error\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: //fallthrough\n"
+   "case log::error:   return \"error\";\n"
+   "}",
+   Alignment);
+
+  // Verify adjacent non-short case statements don't change the alignment, and
+  // properly break the set of consecutive statements.
+  verifyFormat("switch (level) {\n"
+   "case log::critical:\n"
+   "  // comment\n"
+   "  return \"critical\";\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "default:\n"
+   "  // comment\n"
+   "  return \"\";\n"
+   "case log::error:  return \"error\";\n"
+   "case log::severe: return \"severe\";\n"
+   "case log::extra_critical:\n"
+   "  // comment\n"
+ 

[clang] 4ba0084 - [clang-format] Add AlignConsecutiveShortCaseStatements

2023-07-24 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-07-24T18:16:21-07:00
New Revision: 4ba00844174db562d2bd8b15dab6aac605eddf57

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

LOG: [clang-format] Add AlignConsecutiveShortCaseStatements

This adds a new AlignConsecutiveShortCaseStatements option in line with the
existing AlignConsecutive* options , which when
AllowShortCaseLabelsOnASingleLine is enabled will align the tokens after the
case statement's colon. This also adds a AlignCaseColons option to allow
aligning the case label colon itself rather than the token after it.

Fixes #55475.

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 7547aa2a55a71c..e85b8c0b1edc26 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -789,6 +789,104 @@ the configuration (without a prefix: ``Auto``).
   bbb >>= 2;
 
 
+.. _AlignConsecutiveShortCaseStatements:
+
+**AlignConsecutiveShortCaseStatements** 
(``ShortCaseStatementsAlignmentStyle``) :versionbadge:`clang-format 17` :ref:`¶ 
`
+  Style of aligning consecutive short case labels.
+  Only applies if ``AllowShortCaseLabelsOnASingleLine`` is ``true``.
+
+
+  .. code-block:: yaml
+
+# Example of usage:
+AlignConsecutiveShortCaseStatements:
+  Enabled: true
+  AcrossEmptyLines: true
+  AcrossComments: true
+  AlignCaseColons: false
+
+  Nested configuration flags:
+
+  Alignment options.
+
+  * ``bool Enabled`` Whether aligning is enabled.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  default:   return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info: return "info:";
+  case log::warning: return "warning:";
+  default: return "";
+  }
+
+  * ``bool AcrossEmptyLines`` Whether to align across empty lines.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+
+  default:   return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+
+  default: return "";
+  }
+
+  * ``bool AcrossComments`` Whether to align across comments.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  /* A comment. */
+  default:   return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  /* A comment. */
+  default: return "";
+  }
+
+  * ``bool AlignCaseColons`` Whether aligned case labels are aligned on the 
colon, or on the
+, or on the tokens after the colon.
+
+.. code-block:: c++
+
+  true:
+  switch (level) {
+  case log::info   : return "info:";
+  case log::warning: return "warning:";
+  default  : return "";
+  }
+
+  false:
+  switch (level) {
+  case log::info:return "info:";
+  case log::warning: return "warning:";
+  default:   return "";
+  }
+
+
 .. _AlignEscapedNewlines:
 
 **AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) 
:versionbadge:`clang-format 5` :ref:`¶ `

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cd0d46845eb5fa..45753a651e723a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -990,6 +990,8 @@ clang-format
 - Add ``KeepEmptyLinesAtEOF`` to keep empty lines at end of file.
 - Add ``RemoveParentheses`` to remove redundant parentheses.
 - Add ``TypeNames`` to treat listed non-keyword identifiers as type names.
+- Add ``AlignConsecutiveShortCaseStatements`` which can be used to align case
+  labels in conjunction with ``AllowShortCaseLabelsOnASingleLine``.
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 8cb8dd23c19427..7b429d51d49b4b 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -299,6 +299,103 @@ struct FormatStyle {
   /// \version 3.8
   AlignConsecutiveStyle AlignConsecutiveDeclarations;
 
+  /// 

[PATCH] D156192: [-Wunsafe-buffer-usage] Stop generating incorrect fix-its for variable declarations with unsupported specifiers

2023-07-24 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision.
ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak.
Herald added a project: All.
ziqingluo-90 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We have to give up on fixing a variable declaration if it has specifiers that 
are not supported yet.  We cannot support them for now due to the combination 
of following challenges:

- Sometimes we do not have accurate source range information for the type 
specifiers of a variable declaration,  especially when cv-qualifiers are used 
(source location is not provided for type qualifiers 
).
   So it is hard to generate fix-its that only touch type specifiers for a 
declaration.
- We do not have the source range information for most declaration specifiers, 
such as storage specifiers.  So it is hard to tell whether a fix-it may quietly 
remove a specifier by accidentally overwriting it.
- When the declarator is not a trivial identifier (e.g., `int a[]` as a 
parameter decl),  we have to replace the whole declaration in order to fix it 
(e.g., to `std::span a`).  If there are other specifiers involved, they 
may be accidentally removed (e.g.,  fix `int [[some_type_attribute]] a[]` to 
`std::span a` is incorrect).

We could support these specifiers incrementally using the same approach as how 
we deal with cv-qualifiers.  If a fixing variable declaration has a storage 
specifier, instead of trying to find out the source location of the specifier 
or to avoid touching it, we add the keyword to a canonicalized place in the 
fix-it text that replaces the whole declaration.

For example, storage specifiers could be always placed at the beginning of a 
declaration. So both `const static int * x` and `static const int * x` will be 
fixed to `static std::span x`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156192

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
@@ -56,12 +56,46 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:24}:"std::span const q"
   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:25-[[@LINE-2]]:25}:"{"
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:26-[[@LINE-3]]:26}:", 10}"
+  [[deprecated]] const int * x = a;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:18-[[@LINE-1]]:33}:"std::span x"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:34-[[@LINE-2]]:34}:"{"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:35-[[@LINE-3]]:35}:", 10}"
+  const int * y [[deprecated]];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:16}:"std::span y"
+
   int tmp;
+
   tmp = p[5];
   tmp = q[5];
+  tmp = x[5];
+  tmp = y[5];
 }
 
 
+void local_variable_unsupported_specifiers() {
+  int a[10];
+  const int * p [[deprecated]] = a; //  not supported because the attribute overlaps the source range of the declaration
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+
+  static const int * q = a; //  storage specifier not supported yet
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+
+  extern int * x; //  storage specifier not supported yet
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+
+  constexpr int * y = 0; //  `constexpr` specifier not supported yet
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+
+  int tmp;
+
+  tmp = p[5];
+  tmp = q[5];
+  tmp = x[5];
+  tmp = y[5];
+}
+
+
+
 void local_array_subscript_variable_extent() {
   int n = 10;
   int tmp;
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -1381,6 +1381,26 @@
   return getRangeText({ParmIdentBeginLoc, ParmIdentEndLoc}, SM, LangOpts);
 }
 
+// We cannot fix a variable declaration if it has some other specifiers than the
+// type specifier.  Because the source ranges of those specifiers could overlap
+// with the source range that is being replaced using fix-its.  Especially when
+// we often cannot obtain accruate source ranges of cv-qualified type
+// specifiers.
+static bool hasUnsupportedSpecifiers(const VarDecl *VD,
+ const SourceManager ) {
+  // AttrRangeOverlapping: true if at least one attribute of `VD` overlaps the
+  // source range of `VD`:
+  bool AttrRangeOverlapping = llvm::any_of(VD->attrs(), [&](Attr *At) -> bool {
+return !(SM.isBeforeInTranslationUnit(At->getRange().getEnd(),
+  VD->getBeginLoc())) &&
+   

[PATCH] D156040: [AMDGPU] Add dynamic stack bit info to kernel-resource-usage Rpass output

2023-07-24 Thread Corbin Robeck via Phabricator via cfe-commits
crobeck updated this revision to Diff 543772.
crobeck edited the summary of this revision.
crobeck added a comment.

Change remark order and add static stack w/ indirect function call test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156040

Files:
  clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
  llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll

Index: llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
===
--- llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
+++ llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=obj -o /dev/null %s 2>&1 | FileCheck -check-prefix=STDERR %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=null %s 2>&1 | FileCheck -check-prefix=STDERR %s
 ; RUN: FileCheck -check-prefix=REMARK %s < %t
 
 ; STDERR: remark: foo.cl:27:0: Function Name: test_kernel
@@ -6,6 +6,7 @@
 ; STDERR-NEXT: remark: foo.cl:27:0: VGPRs: 9
 ; STDERR-NEXT: remark: foo.cl:27:0: AGPRs: 43
 ; STDERR-NEXT: remark: foo.cl:27:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:27:0: Uses Dynamic Stack: False
 ; STDERR-NEXT: remark: foo.cl:27:0: Occupancy [waves/SIMD]: 5
 ; STDERR-NEXT: remark: foo.cl:27:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:27:0: VGPRs Spill: 0
@@ -55,7 +56,16 @@
 ; REMARK-NEXT: Args:
 ; REMARK-NEXT:   - String:  'ScratchSize [bytes/lane]: '
 ; REMARK-NEXT:   - ScratchSize: '0'
-; REMARK-NEXT: ...
+; REMARK-NEXT: ..
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:UsesDynamicStack
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String: ' Uses Dynamic Stack: 
+; REMARK-NEXT:   - UsesDynamicStack: 'False' 
+; REMARK-NEXT: ..
 ; REMARK-NEXT: --- !Analysis
 ; REMARK-NEXT: Pass:kernel-resource-usage
 ; REMARK-NEXT: Name:Occupancy
@@ -108,6 +118,7 @@
 ; STDERR-NEXT: remark: foo.cl:42:0: VGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:42:0: AGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:42:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:42:0: Uses Dynamic Stack: False
 ; STDERR-NEXT: remark: foo.cl:42:0: Occupancy [waves/SIMD]: 0
 ; STDERR-NEXT: remark: foo.cl:42:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:42:0: VGPRs Spill: 0
@@ -124,6 +135,7 @@
 ; STDERR-NEXT: remark: foo.cl:8:0: VGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: AGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:8:0: Uses Dynamic Stack: False
 ; STDERR-NEXT: remark: foo.cl:8:0: Occupancy [waves/SIMD]: 8
 ; STDERR-NEXT: remark: foo.cl:8:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: VGPRs Spill: 0
@@ -137,6 +149,7 @@
 ; STDERR-NEXT: remark: foo.cl:52:0: VGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:52:0: AGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:52:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:52:0: Uses Dynamic Stack: False
 ; STDERR-NEXT: remark: foo.cl:52:0: Occupancy [waves/SIMD]: 0
 ; STDERR-NEXT: remark: foo.cl:52:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:52:0: VGPRs Spill: 0
@@ -144,8 +157,50 @@
   ret void
 }
 
+; STDERR: remark: foo.cl:64:0: Function Name: test_indirect_call
+; STDERR-NEXT: remark: foo.cl:64:0: SGPRs: 39
+; STDERR-NEXT: remark: foo.cl:64:0: VGPRs: 32
+; STDERR-NEXT: remark: foo.cl:64:0: AGPRs: 10
+; STDERR-NEXT: remark: foo.cl:64:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:64:0: Uses Dynamic Stack: True
+; STDERR-NEXT: remark: foo.cl:64:0: Occupancy [waves/SIMD]: 8
+; STDERR-NEXT: remark: foo.cl:64:0: SGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:64:0: VGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:64:0: LDS Size [bytes/block]: 0
+@gv.fptr0 = external hidden unnamed_addr addrspace(4) constant ptr, align 4
+
+define amdgpu_kernel void @test_indirect_call() !dbg !9 {
+  %fptr = load ptr, ptr addrspace(4) @gv.fptr0
+  call void %fptr()
+  ret void
+}
+
+; STDERR: remark: foo.cl:74:0: Function Name: test_indirect_w_static_stack
+; STDERR-NEXT: remark: foo.cl:74:0: SGPRs: 39
+; STDERR-NEXT: remark: foo.cl:74:0: VGPRs: 32
+; STDERR-NEXT: remark: foo.cl:74:0: AGPRs: 10
+; STDERR-NEXT: remark: foo.cl:74:0: ScratchSize [bytes/lane]: 64
+; STDERR-NEXT: remark: foo.cl:74:0: Uses Dynamic Stack: True
+; STDERR-NEXT: remark: foo.cl:74:0: Occupancy [waves/SIMD]: 8
+; 

[PATCH] D155798: [X86] Support -march=graniterapids-d and update -march=graniterapids

2023-07-24 Thread Kan Shengchen via Phabricator via cfe-commits
skan accepted this revision.
skan added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155798

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


[PATCH] D156116: [Clang][LoongArch] Fix ABI handling of empty structs in C++ to match GCC behaviour

2023-07-24 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This seems to not build: http://45.33.8.238/linux/113405/step_4.txt (?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156116

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


[PATCH] D154931: [LoongArch] Support InlineAsm for LSX and LASX

2023-07-24 Thread Lu Weining 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 rGd25c79dc7000: [LoongArch] Support InlineAsm for LSX and LASX 
(authored by chenli, committed by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154931

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/test/CodeGen/LoongArch/lasx/inline-asm-gcc-regs-error.c
  clang/test/CodeGen/LoongArch/lasx/inline-asm-gcc-regs.c
  clang/test/CodeGen/LoongArch/lasx/inline-asm-operand-modifier.c
  clang/test/CodeGen/LoongArch/lsx/inline-asm-gcc-regs-error.c
  clang/test/CodeGen/LoongArch/lsx/inline-asm-gcc-regs.c
  clang/test/CodeGen/LoongArch/lsx/inline-asm-operand-modifier.c
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/test/CodeGen/LoongArch/lasx/inline-asm-operand-modifier.ll
  llvm/test/CodeGen/LoongArch/lasx/inline-asm-reg-names.ll
  llvm/test/CodeGen/LoongArch/lsx/inline-asm-operand-modifier.ll
  llvm/test/CodeGen/LoongArch/lsx/inline-asm-reg-names.ll

Index: llvm/test/CodeGen/LoongArch/lsx/inline-asm-reg-names.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/lsx/inline-asm-reg-names.ll
@@ -0,0 +1,58 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc --mtriple=loongarch64 --mattr=+lsx < %s | FileCheck %s
+
+define void @register_vr1() nounwind {
+; CHECK-LABEL: register_vr1:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:#APP
+; CHECK-NEXT:vldi $vr1, 1
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call <2 x i64> asm sideeffect "vldi ${0:w}, 1", "={$vr1}"()
+  ret void
+}
+
+define void @register_vr7() nounwind {
+; CHECK-LABEL: register_vr7:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:#APP
+; CHECK-NEXT:vldi $vr7, 1
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call <2 x i64> asm sideeffect "vldi ${0:w}, 1", "={$vr7}"()
+  ret void
+}
+
+define void @register_vr23() nounwind {
+; CHECK-LABEL: register_vr23:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:#APP
+; CHECK-NEXT:vldi $vr23, 1
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call <2 x i64> asm sideeffect "vldi ${0:w}, 1", "={$vr23}"()
+  ret void
+}
+
+;; The lower half of the vector register '$vr31' is overlapped with
+;; the floating-point register '$f31'. And '$f31' is a callee-saved
+;; register which is preserved across calls. That's why the
+;; fst.d and fld.d instructions are emitted.
+define void @register_vr31() nounwind {
+; CHECK-LABEL: register_vr31:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:addi.d $sp, $sp, -16
+; CHECK-NEXT:fst.d $fs7, $sp, 8 # 8-byte Folded Spill
+; CHECK-NEXT:#APP
+; CHECK-NEXT:vldi $vr31, 1
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:fld.d $fs7, $sp, 8 # 8-byte Folded Reload
+; CHECK-NEXT:addi.d $sp, $sp, 16
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call <2 x i64> asm sideeffect "vldi ${0:w}, 1", "={$vr31}"()
+  ret void
+}
Index: llvm/test/CodeGen/LoongArch/lsx/inline-asm-operand-modifier.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/lsx/inline-asm-operand-modifier.ll
@@ -0,0 +1,14 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc --mtriple=loongarch64 --mattr=+lsx < %s | FileCheck %s
+
+define void @test_w() nounwind {
+; CHECK-LABEL: test_w:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:#APP
+; CHECK-NEXT:vldi $vr0, 1
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call <2 x i64> asm sideeffect "vldi ${0:w}, 1", "=f"()
+  ret void
+}
Index: llvm/test/CodeGen/LoongArch/lasx/inline-asm-reg-names.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/lasx/inline-asm-reg-names.ll
@@ -0,0 +1,58 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc --mtriple=loongarch64 --mattr=+lasx < %s | FileCheck %s
+
+define void @register_xr1() nounwind {
+; CHECK-LABEL: register_xr1:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:#APP
+; CHECK-NEXT:xvldi $xr1, 1
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call <4 x i64> asm sideeffect "xvldi ${0:u}, 1", "={$xr1}"()
+  ret void
+}
+
+define void @register_xr7() nounwind {
+; CHECK-LABEL: register_xr7:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:#APP
+; CHECK-NEXT:xvldi $xr7, 1
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call <4 x i64> asm sideeffect "xvldi ${0:u}, 1", "={$xr7}"()
+  ret void
+}
+
+define void @register_xr23() nounwind {
+; CHECK-LABEL: register_xr23:

[clang] d25c79d - [LoongArch] Support InlineAsm for LSX and LASX

2023-07-24 Thread Weining Lu via cfe-commits

Author: chenli
Date: 2023-07-25T09:02:29+08:00
New Revision: d25c79dc70008b835312e5cc7ef48b199fda3165

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

LOG: [LoongArch] Support InlineAsm for LSX and LASX

The author of the following files is licongtian :
- clang/lib/Basic/Targets/LoongArch.cpp
- llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
- llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp

The files mentioned above implement InlineAsm for LSX and LASX as follows:
- Enable clang parsing LSX/LASX register name, such as $vr0.
- Support the case which operand type is 128bit or 256bit when the
  constraints is 'f'.
- Support the way of specifying LSX/LASX register by using constraint,
  such as "={$xr0}".
- Support the operand modifiers 'u' and 'w'.
- Support and legalize the data types and register classes involved in
  LSX/LASX in the lowering process.

Reviewed By: xen0n, SixWeining

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

Added: 
clang/test/CodeGen/LoongArch/lasx/inline-asm-gcc-regs-error.c
clang/test/CodeGen/LoongArch/lasx/inline-asm-gcc-regs.c
clang/test/CodeGen/LoongArch/lasx/inline-asm-operand-modifier.c
clang/test/CodeGen/LoongArch/lsx/inline-asm-gcc-regs-error.c
clang/test/CodeGen/LoongArch/lsx/inline-asm-gcc-regs.c
clang/test/CodeGen/LoongArch/lsx/inline-asm-operand-modifier.c
llvm/test/CodeGen/LoongArch/lasx/inline-asm-operand-modifier.ll
llvm/test/CodeGen/LoongArch/lasx/inline-asm-reg-names.ll
llvm/test/CodeGen/LoongArch/lsx/inline-asm-operand-modifier.ll
llvm/test/CodeGen/LoongArch/lsx/inline-asm-reg-names.ll

Modified: 
clang/lib/Basic/Targets/LoongArch.cpp
llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/LoongArch.cpp 
b/clang/lib/Basic/Targets/LoongArch.cpp
index 9af871895f7429..6958479cd7c42d 100644
--- a/clang/lib/Basic/Targets/LoongArch.cpp
+++ b/clang/lib/Basic/Targets/LoongArch.cpp
@@ -33,7 +33,17 @@ ArrayRef LoongArchTargetInfo::getGCCRegNames() 
const {
   "$f19", "$f20", "$f21", "$f22", "$f23", "$f24", "$f25", "$f26", "$f27",
   "$f28", "$f29", "$f30", "$f31",
   // Condition flag registers.
-  "$fcc0", "$fcc1", "$fcc2", "$fcc3", "$fcc4", "$fcc5", "$fcc6", "$fcc7"};
+  "$fcc0", "$fcc1", "$fcc2", "$fcc3", "$fcc4", "$fcc5", "$fcc6", "$fcc7",
+  // 128-bit vector registers.
+  "$vr0", "$vr1", "$vr2", "$vr3", "$vr4", "$vr5", "$vr6", "$vr7", "$vr8",
+  "$vr9", "$vr10", "$vr11", "$vr12", "$vr13", "$vr14", "$vr15", "$vr16",
+  "$vr17", "$vr18", "$vr19", "$vr20", "$vr21", "$vr22", "$vr23", "$vr24",
+  "$vr25", "$vr26", "$vr27", "$vr28", "$vr29", "$vr30", "$vr31",
+  // 256-bit vector registers.
+  "$xr0", "$xr1", "$xr2", "$xr3", "$xr4", "$xr5", "$xr6", "$xr7", "$xr8",
+  "$xr9", "$xr10", "$xr11", "$xr12", "$xr13", "$xr14", "$xr15", "$xr16",
+  "$xr17", "$xr18", "$xr19", "$xr20", "$xr21", "$xr22", "$xr23", "$xr24",
+  "$xr25", "$xr26", "$xr27", "$xr28", "$xr29", "$xr30", "$xr31"};
   return llvm::ArrayRef(GCCRegNames);
 }
 

diff  --git a/clang/test/CodeGen/LoongArch/lasx/inline-asm-gcc-regs-error.c 
b/clang/test/CodeGen/LoongArch/lasx/inline-asm-gcc-regs-error.c
new file mode 100644
index 00..1fd602574b8e8d
--- /dev/null
+++ b/clang/test/CodeGen/LoongArch/lasx/inline-asm-gcc-regs-error.c
@@ -0,0 +1,10 @@
+// RUN: not %clang_cc1 -triple loongarch64 -emit-llvm -O2 %s 2>&1 -o - | 
FileCheck %s
+
+typedef signed char v32i8 __attribute__((vector_size(32), aligned(32)));
+
+void test() {
+// CHECK: :[[#@LINE+1]]:28: error: unknown register name 'xr0' in asm
+register v32i8 p0 asm ("xr0");
+// CHECK: :[[#@LINE+1]]:29: error: unknown register name '$xr32' in asm
+register v32i8 p32 asm ("$xr32");
+}

diff  --git a/clang/test/CodeGen/LoongArch/lasx/inline-asm-gcc-regs.c 
b/clang/test/CodeGen/LoongArch/lasx/inline-asm-gcc-regs.c
new file mode 100644
index 00..ed1a9660a06c9f
--- /dev/null
+++ b/clang/test/CodeGen/LoongArch/lasx/inline-asm-gcc-regs.c
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --filter "^define |tail call"
+// RUN: %clang_cc1 -triple loongarch64 -emit-llvm -O2 %s -o - | FileCheck %s
+
+typedef signed char v32i8 __attribute__((vector_size(32), aligned(32)));
+
+// CHECK-LABEL: @test_xr0(
+// CHECK:tail call void asm sideeffect "", "{$xr0}"(<32 x i8> undef) 
#[[ATTR1:[0-9]+]], !srcloc !2
+//
+void test_xr0() {
+register v32i8 a asm ("$xr0");
+asm ("" :: "f"(a));
+}
+
+// CHECK-LABEL: @test_xr7(
+// CHECK:tail call void asm sideeffect "", "{$xr7}"(<32 x i8> undef) 
#[[ATTR1]], !srcloc !3
+//
+void test_xr7() {
+

[PATCH] D156116: [Clang][LoongArch] Fix ABI handling of empty structs in C++ to match GCC behaviour

2023-07-24 Thread Lu Weining 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 rGc299efbf284f: [Clang][LoongArch] Fix ABI handling of empty 
structs in C++ to match GCC… (authored by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156116

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c


Index: clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
===
--- clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
+++ clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -3,7 +3,6 @@
 // RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d 
-target-abi lp64d -emit-llvm %s -o - -x c++ | \
 // RUN:   FileCheck --check-prefix=CHECK-CXX %s
 
-// FIXME: This isn't currently respected.
 // Fields containing empty structs or unions are ignored when flattening
 // structs to examine whether the structs can be passed via FARs, even in C++.
 // But there is an exception that non-zero-length array of empty structures are
@@ -16,7 +15,7 @@
 struct s1 { struct empty e; float f; };
 
 // CHECK-C: define{{.*}} float @test_s1(float {{.*}})
-// CHECK-CXX: define{{.*}} i64 @_Z7test_s12s1(i64 {{.*}})
+// CHECK-CXX: define{{.*}} float @_Z7test_s12s1(float {{.*}})
 struct s1 test_s1(struct s1 a) {
   return a;
 }
@@ -24,7 +23,7 @@
 struct s2 { struct empty e; int32_t i; float f; };
 
 // CHECK-C: define{{.*}} { i32, float } @test_s2(i32 {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s22s2([2 x i64] {{.*}})
+// CHECK-CXX: define{{.*}} { i32, float } @_Z7test_s22s2(i32 {{.*}}, float 
{{.*}})
 struct s2 test_s2(struct s2 a) {
   return a;
 }
@@ -32,7 +31,7 @@
 struct s3 { struct empty e; float f; float g; };
 
 // CHECK-C: define{{.*}} { float, float } @test_s3(float {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s32s3([2 x i64] {{.*}})
+// CHECK-CXX: define{{.*}} { float, float } @_Z7test_s32s3(float {{.*}}, float 
{{.*}})
 struct s3 test_s3(struct s3 a) {
   return a;
 }
@@ -40,7 +39,7 @@
 struct s4 { struct empty e; float __complex__ c; };
 
 // CHECK-C: define{{.*}} { float, float } @test_s4(float {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s42s4([2 x i64] {{.*}})
+// CHECK-CXX: define{{.*}} { float, float } @_Z7test_s42s4(float {{.*}}, float 
{{.*}})
 struct s4 test_s4(struct s4 a) {
   return a;
 }
@@ -77,7 +76,7 @@
 struct s8 { struct empty_arr0 e; float f; };
 
 // CHECK-C: define{{.*}} float @test_s8(float {{.*}})
-// CHECK-CXX: define{{.*}} i64 @_Z7test_s82s8(i64 {{.*}})
+// CHECK-CXX: define{{.*}} float @_Z7test_s82s8(float {{.*}})
 struct s8 test_s8(struct s8 a) {
   return a;
 }
Index: clang/lib/CodeGen/Targets/LoongArch.cpp
===
--- clang/lib/CodeGen/Targets/LoongArch.cpp
+++ clang/lib/CodeGen/Targets/LoongArch.cpp
@@ -148,6 +148,13 @@
   if (const ConstantArrayType *ATy = getContext().getAsConstantArrayType(Ty)) {
 uint64_t ArraySize = ATy->getSize().getZExtValue();
 QualType EltTy = ATy->getElementType();
+// Non-zero-length arrays of empty records make the struct ineligible to be
+// passed via FARs in C++.
+if (const auto *RTy = EltTy->getAs()) {
+  if (ArraySize != 0 && isa(RTy->getDecl()) &&
+  isEmptyRecord(getContext(), EltTy, true, true))
+return false;
+}
 CharUnits EltSize = getContext().getTypeSizeInChars(EltTy);
 for (uint64_t i = 0; i < ArraySize; ++i) {
   if (!detectFARsEligibleStructHelper(EltTy, CurOff, Field1Ty, Field1Off,
@@ -163,7 +170,7 @@
 // copy constructor are not eligible for the FP calling convention.
 if (getRecordArgABI(Ty, CGT.getCXXABI()))
   return false;
-if (isEmptyRecord(getContext(), Ty, true))
+if (isEmptyRecord(getContext(), Ty, true, true))
   return true;
 const RecordDecl *RD = RTy->getDecl();
 // Unions aren't eligible unless they're empty (which is caught above).
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -891,6 +891,8 @@
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
   aliases ``-m[no-]strict-align``.
+- An ABI mismatch between GCC and Clang related to the handling of empty 
structs
+  in C++ parameter passing under ``lp64d`` ABI was fixed.
 
 RISC-V Support
 ^^


Index: clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
===
--- clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
+++ clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -3,7 +3,6 @@
 // RUN: 

[clang] c299efb - [Clang][LoongArch] Fix ABI handling of empty structs in C++ to match GCC behaviour

2023-07-24 Thread Weining Lu via cfe-commits

Author: Weining Lu
Date: 2023-07-25T08:59:40+08:00
New Revision: c299efbf284fae92bb8d7d29110f76912f089daf

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

LOG: [Clang][LoongArch] Fix ABI handling of empty structs in C++ to match GCC 
behaviour

GCC doesn't ignore non-zero-length array of empty structures in C++
while clang does. What this patch did is to match GCC's behaviour
although this rule is not documented in psABI.

Similar to D142327 for RISCV.

Reviewed By: xry111, xen0n

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/Targets/LoongArch.cpp
clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4f82edd0d03d14..cd0d46845eb5fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -891,6 +891,8 @@ LoongArch Support
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
   aliases ``-m[no-]strict-align``.
+- An ABI mismatch between GCC and Clang related to the handling of empty 
structs
+  in C++ parameter passing under ``lp64d`` ABI was fixed.
 
 RISC-V Support
 ^^

diff  --git a/clang/lib/CodeGen/Targets/LoongArch.cpp 
b/clang/lib/CodeGen/Targets/LoongArch.cpp
index 6391a8aeaa67cd..056b3946d1b33f 100644
--- a/clang/lib/CodeGen/Targets/LoongArch.cpp
+++ b/clang/lib/CodeGen/Targets/LoongArch.cpp
@@ -148,6 +148,13 @@ bool LoongArchABIInfo::detectFARsEligibleStructHelper(
   if (const ConstantArrayType *ATy = getContext().getAsConstantArrayType(Ty)) {
 uint64_t ArraySize = ATy->getSize().getZExtValue();
 QualType EltTy = ATy->getElementType();
+// Non-zero-length arrays of empty records make the struct ineligible to be
+// passed via FARs in C++.
+if (const auto *RTy = EltTy->getAs()) {
+  if (ArraySize != 0 && isa(RTy->getDecl()) &&
+  isEmptyRecord(getContext(), EltTy, true, true))
+return false;
+}
 CharUnits EltSize = getContext().getTypeSizeInChars(EltTy);
 for (uint64_t i = 0; i < ArraySize; ++i) {
   if (!detectFARsEligibleStructHelper(EltTy, CurOff, Field1Ty, Field1Off,
@@ -163,7 +170,7 @@ bool LoongArchABIInfo::detectFARsEligibleStructHelper(
 // copy constructor are not eligible for the FP calling convention.
 if (getRecordArgABI(Ty, CGT.getCXXABI()))
   return false;
-if (isEmptyRecord(getContext(), Ty, true))
+if (isEmptyRecord(getContext(), Ty, true, true))
   return true;
 const RecordDecl *RD = RTy->getDecl();
 // Unions aren't eligible unless they're empty (which is caught above).

diff  --git a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c 
b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
index 3a65b90e48e0e0..b5c7916f57cd99 100644
--- a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
+++ b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -3,7 +3,6 @@
 // RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d 
-target-abi lp64d -emit-llvm %s -o - -x c++ | \
 // RUN:   FileCheck --check-prefix=CHECK-CXX %s
 
-// FIXME: This isn't currently respected.
 // Fields containing empty structs or unions are ignored when flattening
 // structs to examine whether the structs can be passed via FARs, even in C++.
 // But there is an exception that non-zero-length array of empty structures are
@@ -16,7 +15,7 @@ struct empty { struct { struct { } e; }; };
 struct s1 { struct empty e; float f; };
 
 // CHECK-C: define{{.*}} float @test_s1(float {{.*}})
-// CHECK-CXX: define{{.*}} i64 @_Z7test_s12s1(i64 {{.*}})
+// CHECK-CXX: define{{.*}} float @_Z7test_s12s1(float {{.*}})
 struct s1 test_s1(struct s1 a) {
   return a;
 }
@@ -24,7 +23,7 @@ struct s1 test_s1(struct s1 a) {
 struct s2 { struct empty e; int32_t i; float f; };
 
 // CHECK-C: define{{.*}} { i32, float } @test_s2(i32 {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s22s2([2 x i64] {{.*}})
+// CHECK-CXX: define{{.*}} { i32, float } @_Z7test_s22s2(i32 {{.*}}, float 
{{.*}})
 struct s2 test_s2(struct s2 a) {
   return a;
 }
@@ -32,7 +31,7 @@ struct s2 test_s2(struct s2 a) {
 struct s3 { struct empty e; float f; float g; };
 
 // CHECK-C: define{{.*}} { float, float } @test_s3(float {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s32s3([2 x i64] {{.*}})
+// CHECK-CXX: define{{.*}} { float, float } @_Z7test_s32s3(float {{.*}}, float 
{{.*}})
 struct s3 test_s3(struct s3 a) {
   return a;
 }
@@ -40,7 +39,7 @@ struct s3 test_s3(struct s3 a) {
 struct s4 { struct empty e; float __complex__ c; };
 
 // CHECK-C: define{{.*}} { float, float } @test_s4(float {{.*}}, float {{.*}})
-// 

[PATCH] D156114: [Clang][LoongArch] Pre-commit test for D156116

2023-07-24 Thread Lu Weining via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG669d2bbc837e: [Clang][LoongArch] Pre-commit test for D156116 
(authored by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156114

Files:
  clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c


Index: clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
===
--- /dev/null
+++ clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d 
-target-abi lp64d -emit-llvm %s -o - | \
+// RUN:   FileCheck --check-prefix=CHECK-C %s
+// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d 
-target-abi lp64d -emit-llvm %s -o - -x c++ | \
+// RUN:   FileCheck --check-prefix=CHECK-CXX %s
+
+// FIXME: This isn't currently respected.
+// Fields containing empty structs or unions are ignored when flattening
+// structs to examine whether the structs can be passed via FARs, even in C++.
+// But there is an exception that non-zero-length array of empty structures are
+// not ignored in C++. These rules are not documented in psABI 

+// but they match GCC behaviours.
+
+#include 
+
+struct empty { struct { struct { } e; }; };
+struct s1 { struct empty e; float f; };
+
+// CHECK-C: define{{.*}} float @test_s1(float {{.*}})
+// CHECK-CXX: define{{.*}} i64 @_Z7test_s12s1(i64 {{.*}})
+struct s1 test_s1(struct s1 a) {
+  return a;
+}
+
+struct s2 { struct empty e; int32_t i; float f; };
+
+// CHECK-C: define{{.*}} { i32, float } @test_s2(i32 {{.*}}, float {{.*}})
+// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s22s2([2 x i64] {{.*}})
+struct s2 test_s2(struct s2 a) {
+  return a;
+}
+
+struct s3 { struct empty e; float f; float g; };
+
+// CHECK-C: define{{.*}} { float, float } @test_s3(float {{.*}}, float {{.*}})
+// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s32s3([2 x i64] {{.*}})
+struct s3 test_s3(struct s3 a) {
+  return a;
+}
+
+struct s4 { struct empty e; float __complex__ c; };
+
+// CHECK-C: define{{.*}} { float, float } @test_s4(float {{.*}}, float {{.*}})
+// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s42s4([2 x i64] {{.*}})
+struct s4 test_s4(struct s4 a) {
+  return a;
+}
+
+// An array of empty fields isn't ignored in C++ (this isn't explicit in the
+// psABI, but matches observed g++ behaviour).
+
+struct s5 { struct empty e[1]; float f; };
+
+// CHECK-C: define{{.*}} float @test_s5(float {{.*}})
+// CHECK-CXX: define{{.*}} i64 @_Z7test_s52s5(i64 {{.*}})
+struct s5 test_s5(struct s5 a) {
+  return a;
+}
+
+struct empty_arr { struct { struct { } e[1]; }; };
+struct s6 { struct empty_arr e; float f; };
+
+// CHECK-C: define{{.*}} float @test_s6(float {{.*}})
+// CHECK-CXX: define{{.*}} i64 @_Z7test_s62s6(i64 {{.*}})
+struct s6 test_s6(struct s6 a) {
+  return a;
+}
+
+struct s7 { struct empty e[0]; float f; };
+
+// CHECK-C: define{{.*}} float @test_s7(float {{.*}})
+// CHECK-CXX: define{{.*}} float @_Z7test_s72s7(float {{.*}})
+struct s7 test_s7(struct s7 a) {
+  return a;
+}
+
+struct empty_arr0 { struct { struct { } e[0]; }; };
+struct s8 { struct empty_arr0 e; float f; };
+
+// CHECK-C: define{{.*}} float @test_s8(float {{.*}})
+// CHECK-CXX: define{{.*}} i64 @_Z7test_s82s8(i64 {{.*}})
+struct s8 test_s8(struct s8 a) {
+  return a;
+}


Index: clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
===
--- /dev/null
+++ clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - | \
+// RUN:   FileCheck --check-prefix=CHECK-C %s
+// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - -x c++ | \
+// RUN:   FileCheck --check-prefix=CHECK-CXX %s
+
+// FIXME: This isn't currently respected.
+// Fields containing empty structs or unions are ignored when flattening
+// structs to examine whether the structs can be passed via FARs, even in C++.
+// But there is an exception that non-zero-length array of empty structures are
+// not ignored in C++. These rules are not documented in psABI 
+// but they match GCC behaviours.
+
+#include 
+
+struct empty { struct { struct { } e; }; };
+struct s1 { struct empty e; float f; };
+
+// CHECK-C: define{{.*}} float @test_s1(float {{.*}})
+// CHECK-CXX: define{{.*}} i64 @_Z7test_s12s1(i64 {{.*}})
+struct s1 test_s1(struct s1 a) {
+  return a;
+}
+
+struct s2 { struct empty e; int32_t i; float f; };
+
+// CHECK-C: define{{.*}} { i32, float } 

[clang] 669d2bb - [Clang][LoongArch] Pre-commit test for D156116

2023-07-24 Thread Weining Lu via cfe-commits

Author: Weining Lu
Date: 2023-07-25T08:59:40+08:00
New Revision: 669d2bbc837ee56d6bb05d5d55615246fc8b6b5c

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

LOG: [Clang][LoongArch] Pre-commit test for D156116

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

Added: 
clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c 
b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
new file mode 100644
index 00..3a65b90e48e0e0
--- /dev/null
+++ b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d 
-target-abi lp64d -emit-llvm %s -o - | \
+// RUN:   FileCheck --check-prefix=CHECK-C %s
+// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d 
-target-abi lp64d -emit-llvm %s -o - -x c++ | \
+// RUN:   FileCheck --check-prefix=CHECK-CXX %s
+
+// FIXME: This isn't currently respected.
+// Fields containing empty structs or unions are ignored when flattening
+// structs to examine whether the structs can be passed via FARs, even in C++.
+// But there is an exception that non-zero-length array of empty structures are
+// not ignored in C++. These rules are not documented in psABI 

+// but they match GCC behaviours.
+
+#include 
+
+struct empty { struct { struct { } e; }; };
+struct s1 { struct empty e; float f; };
+
+// CHECK-C: define{{.*}} float @test_s1(float {{.*}})
+// CHECK-CXX: define{{.*}} i64 @_Z7test_s12s1(i64 {{.*}})
+struct s1 test_s1(struct s1 a) {
+  return a;
+}
+
+struct s2 { struct empty e; int32_t i; float f; };
+
+// CHECK-C: define{{.*}} { i32, float } @test_s2(i32 {{.*}}, float {{.*}})
+// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s22s2([2 x i64] {{.*}})
+struct s2 test_s2(struct s2 a) {
+  return a;
+}
+
+struct s3 { struct empty e; float f; float g; };
+
+// CHECK-C: define{{.*}} { float, float } @test_s3(float {{.*}}, float {{.*}})
+// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s32s3([2 x i64] {{.*}})
+struct s3 test_s3(struct s3 a) {
+  return a;
+}
+
+struct s4 { struct empty e; float __complex__ c; };
+
+// CHECK-C: define{{.*}} { float, float } @test_s4(float {{.*}}, float {{.*}})
+// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s42s4([2 x i64] {{.*}})
+struct s4 test_s4(struct s4 a) {
+  return a;
+}
+
+// An array of empty fields isn't ignored in C++ (this isn't explicit in the
+// psABI, but matches observed g++ behaviour).
+
+struct s5 { struct empty e[1]; float f; };
+
+// CHECK-C: define{{.*}} float @test_s5(float {{.*}})
+// CHECK-CXX: define{{.*}} i64 @_Z7test_s52s5(i64 {{.*}})
+struct s5 test_s5(struct s5 a) {
+  return a;
+}
+
+struct empty_arr { struct { struct { } e[1]; }; };
+struct s6 { struct empty_arr e; float f; };
+
+// CHECK-C: define{{.*}} float @test_s6(float {{.*}})
+// CHECK-CXX: define{{.*}} i64 @_Z7test_s62s6(i64 {{.*}})
+struct s6 test_s6(struct s6 a) {
+  return a;
+}
+
+struct s7 { struct empty e[0]; float f; };
+
+// CHECK-C: define{{.*}} float @test_s7(float {{.*}})
+// CHECK-CXX: define{{.*}} float @_Z7test_s72s7(float {{.*}})
+struct s7 test_s7(struct s7 a) {
+  return a;
+}
+
+struct empty_arr0 { struct { struct { } e[0]; }; };
+struct s8 { struct empty_arr0 e; float f; };
+
+// CHECK-C: define{{.*}} float @test_s8(float {{.*}})
+// CHECK-CXX: define{{.*}} i64 @_Z7test_s82s8(i64 {{.*}})
+struct s8 test_s8(struct s8 a) {
+  return a;
+}



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


[PATCH] D156189: [-Wunsafe-buffer-usage] Refactor to let local variable fix-its and parameter fix-its share common code

2023-07-24 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments.



Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp:242
   ptr[2] = 30;
-  auto p = new int[10];
-  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"std::span 
p"

We no longer generate fix-its for a variable declaration where the type 
specifier is just `auto`.   This is to avoid that fix-its may become incorrect 
when the adopting codebase changes.  For example,

```
int x;
auto p = 
```
If we fix the declaration of `p` to `std::span p{, 1}`,  and later `int 
x` is changed to `long x`,  the program becomes incorrect and the programmer 
may not know that the type of `p` should simply follow the type of `x`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156189

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


[PATCH] D156178: [HLSL] add pow library function

2023-07-24 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 added inline comments.



Comment at: clang/test/CodeGenHLSL/builtins/pow.hlsl:10
+// CHECK: call half @llvm.pow.f16(
+// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"(
+// NO_HALF: call float @llvm.pow.f32(

bogner wrote:
> Why check the function name in the no-half case but not the other check?
This is the pattern I've been using since starting on the upstreaming effort, 
so I've been copying this pattern. I don't see a reason why the function name 
shouldn't be included, so I'll add it here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156178

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


[PATCH] D156178: [HLSL] add pow library function

2023-07-24 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 543757.
bob80905 added a comment.

- add func name to checks, clang format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156178

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/pow.hlsl

Index: clang/test/CodeGenHLSL/builtins/pow.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/pow.hlsl
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.pow.f16(
+// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"(
+// NO_HALF: call float @llvm.pow.f32(
+half test_pow_half(half p0, half p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x half> @"?test_pow_half2@@YAT?$__vector@$f16@$01@__clang@@T12@0@Z"(
+// CHECK: call <2 x half> @llvm.pow.v2f16
+// NO_HALF: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"(
+// NO_HALF: call <2 x float> @llvm.pow.v2f32(
+half2 test_pow_half2(half2 p0, half2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x half> @"?test_pow_half3@@YAT?$__vector@$f16@$02@__clang@@T12@0@Z"(
+// CHECK: call <3 x half> @llvm.pow.v3f16
+// NO_HALF: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"(
+// NO_HALF: call <3 x float> @llvm.pow.v3f32(
+half3 test_pow_half3(half3 p0, half3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x half> @"?test_pow_half4@@YAT?$__vector@$f16@$03@__clang@@T12@0@Z"(
+// CHECK: call <4 x half> @llvm.pow.v4f16
+// NO_HALF: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"(
+// NO_HALF: call <4 x float> @llvm.pow.v4f32(
+half4 test_pow_half4(half4 p0, half4 p1)
+{
+  return pow(p0, p1);
+}
+
+// CHECK: define noundef float @"?test_pow_float@@YAMMM@Z"(
+// CHECK: call float @llvm.pow.f32(
+float test_pow_float(float p0, float p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"(
+// CHECK: call <2 x float> @llvm.pow.v2f32
+float2 test_pow_float2(float2 p0, float2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"(
+// CHECK: call <3 x float> @llvm.pow.v3f32
+float3 test_pow_float3(float3 p0, float3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"(
+// CHECK: call <4 x float> @llvm.pow.v4f32
+float4 test_pow_float4(float4 p0, float4 p1)
+{
+  return pow(p0, p1);
+}
+
+// CHECK: define noundef double @"?test_pow_double@@YANNN@Z"(
+// CHECK: call double @llvm.pow.f64(
+double test_pow_double(double p0, double p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x double> @"?test_pow_double2@@YAT?$__vector@N$01@__clang@@T12@0@Z"(
+// CHECK: call <2 x double> @llvm.pow.v2f64
+double2 test_pow_double2(double2 p0, double2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x double> @"?test_pow_double3@@YAT?$__vector@N$02@__clang@@T12@0@Z"(
+// CHECK: call <3 x double> @llvm.pow.v3f64
+double3 test_pow_double3(double3 p0, double3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x double> @"?test_pow_double4@@YAT?$__vector@N$03@__clang@@T12@0@Z"(
+// CHECK: call <4 x double> @llvm.pow.v4f64
+double4 test_pow_double4(double4 p0, double4 p1)
+{
+  return pow(p0, p1);
+}
Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h
===
--- clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -476,5 +476,35 @@
 __attribute__((clang_builtin_alias(__builtin_elementwise_min)))
 double4 min(double4, double4);
 
+// pow builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half pow(half, half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half2 pow(half2, half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half3 pow(half3, half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half4 pow(half4, half4);
+#endif
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) float
+pow(float, float);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+float2 pow(float2, float2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+float3 pow(float3, float3);

[PATCH] D156189: [-Wunsafe-buffer-usage] Refactor to let local variable fix-its and parameter fix-its share common code

2023-07-24 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision.
ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak.
Herald added a project: All.
ziqingluo-90 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Refactor the code for local variable fix-its so that it reuses the code for 
parameter fix-its, which is in general better.  For example, cv-qualifiers are 
supported.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156189

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pointer-access.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pointer-deref.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-unevaluated-context.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
@@ -80,28 +80,16 @@
   );
 }
 
-void testArraySubscriptsWithAuto(int *p, int **pp) {
+void testArraySubscriptsWithAuto() {
   int a[10];
-  auto ap1 = a;   // expected-warning{{'ap1' is an unsafe pointer used for buffer access}} \
-		 expected-note{{change type of 'ap1' to 'std::span' to preserve bounds information}}
-
+  // We do not fix a declaration if the type is `auto`. Because the actual type may change later.
+  auto ap1 = a;   // expected-warning{{'ap1' is an unsafe pointer used for buffer access}}
   foo(ap1[1]);// expected-note{{used in buffer access here}}
 
-  auto ap2 = p;   // expected-warning{{'ap2' is an unsafe pointer used for buffer access}} \
-  		 expected-note{{change type of 'ap2' to 'std::span' to preserve bounds information}}
-
+  // In case the type is `auto *`, we know it must be a pointer. We can fix it.
+  auto * ap2 = a; // expected-warning{{'ap2' is an unsafe pointer used for buffer access}} \
+ expected-note{{change type of 'ap2' to 'std::span' to preserve bounds information}}
   foo(ap2[1]);// expected-note{{used in buffer access here}}
-
-  auto ap3 = pp;  // expected-warning{{'ap3' is an unsafe pointer used for buffer access}} \
-		 expected-note{{change type of 'ap3' to 'std::span' to preserve bounds information}}
-
-  foo(ap3[1][1]); // expected-note{{used in buffer access here}}
-  // expected-warning@-1{{unsafe buffer access}}
-
-  auto ap4 = *pp; // expected-warning{{'ap4' is an unsafe pointer used for buffer access}} \
-  		 expected-note{{change type of 'ap4' to 'std::span' to preserve bounds information}}
-
-  foo(ap4[1]);// expected-note{{used in buffer access here}}
 }
 
 void testUnevaluatedContext(int * p) {// no-warning
@@ -358,8 +346,9 @@
 }
 
 void testMultiLineDeclStmt(int * p) {
-  auto
+  int
 
+  *
 
   ap1 = p;  // expected-warning{{'ap1' is an unsafe pointer used for buffer access}} \
  	   expected-note{{change type of 'ap1' to 'std::span' to preserve bounds information}}
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-unevaluated-context.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-unevaluated-context.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-unevaluated-context.cpp
@@ -15,7 +15,7 @@
 int bar(int *ptr);
 
 void uneval_context_fix_pointer_dereference() {
-  auto p = new int[10];
+  int* p = new int[10];
   // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"std::span p"
   // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:12-[[@LINE-2]]:12}:"{"
   // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-3]]:23-[[@LINE-3]]:23}:", 10}"
@@ -30,7 +30,7 @@
 }
 
 void uneval_context_fix_pointer_array_access() {
-  auto p = new int[10];
+  int* p = new int[10];
   // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"std::span p"
   // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:12-[[@LINE-2]]:12}:"{"
   // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-3]]:23-[[@LINE-3]]:23}:", 10}"
@@ -41,7 +41,7 @@
 }
 
 void uneval_context_fix_pointer_reference() {
-  auto p = new int[10];
+  int* p = new int[10];
   // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"std::span p"
   // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:12-[[@LINE-2]]:12}:"{"
   // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-3]]:23-[[@LINE-3]]:23}:", 10}"
@@ -63,7 +63,7 @@
 
 // FIXME: Emit fixits for each of the below use.
 void uneval_context_fix_pointer_dereference_not_handled() {
-  auto p = new int[10];
+  int* p = new int[10];
   int tmp = p[5];
 
   foo(sizeof(*p), sizeof(decltype(*p)));
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pointer-deref.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pointer-deref.cpp
+++ 

[PATCH] D154658: Optimize emission of `dynamic_cast` to final classes.

2023-07-24 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This caused https://github.com/llvm/llvm-project/issues/64088


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154658

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


[PATCH] D156188: Refactor and improve for parameter fix-its

2023-07-24 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision.
ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak.
Herald added a project: All.
ziqingluo-90 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Factor out the code that will be shared by both parameter and local variable 
fix-its

- Add a check to ensure that a `TypeLoc::isNull` is false before using the 
`TypeLoc`

- Remove the special check for whether a fixing variable involves unnamed 
types.  This check is unnecessary now.  Because we will give up on fixing a 
pointer type variable `v`, if we cannot obtain the source range of the pointee 
type of `v`.  Using unnamed types is just one of the many causes of such 
scenarios.  Besides, in some cases, we have no problem in referring to unnamed 
types.  Therefore, we remove the special handling since we have a more general 
solution already.

For example,

  typedef struct {int x;} UNNAMED_T;
  
  UNNAMED_T * x; //  we can refer to the unnamed struct using `UNNAMED_T`
  
  typedef struct {int x;} * UNNAMED_PTR;
  
  UNNAMED_PTR y; // we cannot obtain the source range of the pointee type of 
`y`,   so we will give up



- Move tests for cv-qualified parameters and unnamed types out of the 
"...-unsupported.cpp" test file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156188

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-unsupported.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-unsupported.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-unsupported.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-unsupported.cpp
@@ -1,34 +1,21 @@
 // RUN: %clang_cc1 -std=c++20 -Wno-all -Wunsafe-buffer-usage -fcxx-exceptions -fsafe-buffer-usage-suggestions -verify %s
 // RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fcxx-exceptions -fdiagnostics-parseable-fixits -fsafe-buffer-usage-suggestions %s 2>&1 | FileCheck %s
 
-void const_ptr(int * const x) { // expected-warning{{'x' is an unsafe pointer used for buffer access}} expected-note{{change type of 'x' to 'std::span' to preserve bounds information}}
-  // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:16-[[@LINE-1]]:29}:"std::span const x"
-  int tmp = x[5]; // expected-note{{used in buffer access here}}
-}
-// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:2-[[@LINE-1]]:2}:"\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} void const_ptr(int * const x) {return const_ptr(std::span(x, <# size #>));}\n"
-
-void const_ptr_to_const(const int * const x) {// expected-warning{{'x' is an unsafe pointer used for buffer access}} expected-note{{change type of 'x' to 'std::span' to preserve bounds information}}
-  // CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:25-[[@LINE-1]]:44}:"std::span const x"
-  int tmp = x[5]; // expected-note{{used in buffer access here}}
-}
-// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:2-[[@LINE-1]]:2}:"\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} void const_ptr_to_const(const int * const x) {return const_ptr_to_const(std::span(x, <# size #>));}\n"
+typedef int * TYPEDEF_PTR;
+#define MACRO_PTR int*
 
-typedef struct {int x;} NAMED_UNNAMED_STRUCT; // an unnamed struct type named by a typedef
-typedef struct {int x;} * PTR_TO_ANON;// pointer to an unnamed struct
-typedef NAMED_UNNAMED_STRUCT * PTR_TO_NAMED;  // pointer to a named type
+// We CANNOT fix a pointer whose type is defined in a typedef or a
+// macro. Because if the typedef is changed after the fix, the fix
+// becomes incorrect and may not be noticed.
 
-// We can fix a pointer to a named type
-void namedPointeeType(NAMED_UNNAMED_STRUCT * p) {  // expected-warning{{'p' is an unsafe pointer used for buffer access}}\ expected-note{{change type of 'p' to 'std::span' to preserve bounds information}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:23-[[@LINE-1]]:47}:"std::span p"
+// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE+1]]
+void typedefPointer(TYPEDEF_PTR p) {  // expected-warning{{'p' is an unsafe pointer used for buffer access}}
   if (++p) {  // expected-note{{used in pointer arithmetic here}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:10}:"(p = p.subspan(1)).data()"
   }
 }
-// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:2-[[@LINE-1]]:2}:"\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} void namedPointeeType(NAMED_UNNAMED_STRUCT * p) {return namedPointeeType(std::span(p, <# size #>));}\n"
 
-// We CANNOT fix a pointer to an unnamed type
-// CHECK-NOT: fix-it:
-void unnamedPointeeType(PTR_TO_ANON p) {  // expected-warning{{'p' is an unsafe pointer used for buffer access}}
+// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE+1]]
+void macroPointer(MACRO_PTR p) {  // expected-warning{{'p' is an unsafe pointer used for buffer access}}
   if (++p) {  // expected-note{{used in pointer 

[PATCH] D154123: [HIP] Start document HIP support by clang

2023-07-24 Thread Ronan Keryell via Phabricator via cfe-commits
keryell added inline comments.



Comment at: clang/docs/HIPSupport.rst:30
+
+Clang provides partial HIP support on Intel GPUs using the CHIP-Star project 
``_. CHIP-Star implements the HIP runtime 
over oneAPI Level Zero or OpenCL runtime. The Clang driver uses the HIPSPV 
toolchain to compile HIP device code into LLVM IR, which is subsequently 
translated to SPIRV via the SPIRV backend or the out-of-tree LLVM-SPIRV 
translator. The SPIRV is then bundled and embedded into the host executables.
+

Fix the spelling when we talk about the Khronos SPIR-V standard, by opposition 
to tool names.
Perhaps you can split the line in shorter ones so the diff are more obvious.



Comment at: clang/docs/HIPSupport.rst:65
+
+   clang++ --offload-arch=gfx906 -xhip sample.cpp -o sample
+

yaxunl wrote:
> arsenm wrote:
> > scchan wrote:
> > > missing --hip-link
> > What does hip-link do? Why is it needed? I never use it and it works
> It indicates HIP offloading at the linking stage and creates the HIP 
> toolchain.
> 
> For -fno-gpu-rdc mode, it locates the HIP runtime library and links it.
> 
> For -fgpu-rdc mode, it unbundles object files and does device linking and 
> embedding.
I am a little lost here.
I have the feeling that the newbie syntax (compile+link in one invocation) 
should be
```
clang++ --offload-arch=gfx906 -xhip sample.cpp -o sample
```
since it should be obvious to the Driver that we want to produce a working 
program for a GPU.
Or does this work producing a working program with another meaning?


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

https://reviews.llvm.org/D154123

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


[PATCH] D156185: [clang][ConstExprEmitter] handle ArrayToPointerDecay ImplicitCastExpr of StringLiterals

2023-07-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> so if you were concerned with arrays of string literals, we need this patch.

Ohhh that's not what I meant by StringLiterals.  I meant cases where the 
string literal is an rvalue, like `char foo[10] = "x";`.  If it's an 
lvalue, we go through ConstantLValueEmitter, which is still reasonably fast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156185

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


[PATCH] D156178: [HLSL] add pow library function

2023-07-24 Thread Justin Bogner via Phabricator via cfe-commits
bogner added a comment.

Looking at 
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-pow,
 it seems a bit underspecified, but do we need to worry about differences 
between that spec and IEEE behaviour here? For example, it says there that 
`x<0, y=any -> NaN`, but we'll only generate `NaN` for non-integer `y` in these 
cases as per https://en.cppreference.com/w/c/numeric/math/pow




Comment at: clang/test/CodeGenHLSL/builtins/pow.hlsl:10
+// CHECK: call half @llvm.pow.f16(
+// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"(
+// NO_HALF: call float @llvm.pow.f32(

Why check the function name in the no-half case but not the other check?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156178

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


[PATCH] D156185: [clang][ConstExprEmitter] handle ArrayToPointerDecay ImplicitCastExpr of StringLiterals

2023-07-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> I guess I lost focus on the "struct or array part."

Right... scalars weren't the concern for D76096 
.  They have much less overhead going through 
ExprConstant, and any evaluation of scalars isn't a regression because we 
currently don't have a codepath for that anyway.

> Some of these seem like very low hanging fruit, IMO, and probably still do 
> speed up constant evaluation.

Sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156185

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


[PATCH] D156185: [clang][ConstExprEmitter] handle ArrayToPointerDecay ImplicitCastExpr of StringLiterals

2023-07-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

For this case in this patch in particular:

  extern const char* bar;
  const char* foo [] = {
  "hello",
  "goodbye",
  bar
  };

  TranslationUnitDecl
  |-VarDecl  col:20 used bar 'const char *' extern
  `-VarDecl  line:2:13 foo 'const char *[3]' cinit
`-InitListExpr  'const char *[3]'
  |-ImplicitCastExpr  'const char *' 
  | `-ImplicitCastExpr  'char *' 
  |   `-StringLiteral  'char[6]' lvalue "hello"
  |-ImplicitCastExpr  'const char *' 
  | `-ImplicitCastExpr  'char *' 
  |   `-StringLiteral  'char[8]' lvalue "goodbye"
  `-ImplicitCastExpr  'const char *' 
`-DeclRefExpr  'const char *' lvalue Var 0x55b64410c270 'bar' 
'const char *'

so if you were concerned with arrays  
of string literals , we need this 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156185

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


[PATCH] D156175: [clang][ConstExprEmitter] handle NullToPointer ImplicitCastExpr

2023-07-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1131-1132
+case CK_NullToPointer: {
+  if (llvm::Constant *C = Visit(subExpr, destType))
+if (C->isNullValue())
+  return CGM.EmitNullConstant(destType);

nickdesaulniers wrote:
> FWIW, I would have thought these might be unnecessary, but we do trip 2 tests 
> without these guards IIRC.
The fact that the Visit can fail doesn't surprise me; you can write arbitrary 
expressions of type nullptr_t (for example, `nullptr_t f(); void* g = f();`.  I 
can't think of any reason you'd need to check C->isNullValue(), though; do you 
have a testcase for that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156175

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


[PATCH] D156185: [clang][ConstExprEmitter] handle ArrayToPointerDecay ImplicitCastExpr of StringLiterals

2023-07-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D156185#4530117 , @efriedma wrote:

> We can do a whole bunch of these, but at some point we hit diminishing 
> returns... bailing out here isn't *that* expensive.  Do you have some idea 
> how far you want to go with this?  Adding a couple obvious checks like this 
> isn't a big deal, but I don't want to build up a complete parallel 
> infrastructure for scalar expressions here.

My goal here is to land https://reviews.llvm.org/D76096. If I have to build a 
whole complete parallel infra to do so, I will.  It might even be nice to start 
converging or deleting some of the duplication.

Some of these seem like very low hanging fruit, IMO, and probably still do 
speed up constant evaluation.

My (mis?)interpretation of https://reviews.llvm.org/D76096#4523828 was "find 
places where `Evaluate()` from clang/lib/AST/ExprConstant.cpp is called instead 
of the fast path very recently committed in D151587 
.  I guess I lost focus on the "struct or 
array part."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156185

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


[PATCH] D156178: [HLSL] add pow library function

2023-07-24 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 added inline comments.



Comment at: clang/test/CodeGenHLSL/builtins/pow.hlsl:6
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+

beanz wrote:
> Does this need to set `-D__HLSL_ENABLE_16_BIT`? If 16-bit types are disabled, 
> this should result in `half` being 32-bit right?
The define is necessary (the test fails otherwise) because without the 
definition, the definition of "half4" wouldn't exist (half4 is defined in 
hlsl_intrinsics.h).
To your second question, yes, I think that's correct.



Comment at: clang/test/CodeGenHLSL/builtins/pow.hlsl:12
+// NO_HALF: call float @llvm.pow.f32(
+half test_pow_half(half p0, half p1)
+{

beanz wrote:
> nit: can you clang-format this source?
Will do


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156178

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


[PATCH] D156185: [clang][ConstExprEmitter] handle ArrayToPointerDecay ImplicitCastExpr of StringLiterals

2023-07-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

We can do a whole bunch of these, but at some point we hit diminishing 
returns... bailing out here isn't *that* expensive.  Do you have some idea how 
far you want to go with this?  Adding a couple obvious checks like this isn't a 
big deal, but I don't want to build up a complete parallel infrastructure for 
scalar expressions here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156185

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


[PATCH] D156178: [HLSL] add pow library function

2023-07-24 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/test/CodeGenHLSL/builtins/pow.hlsl:6
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+

Does this need to set `-D__HLSL_ENABLE_16_BIT`? If 16-bit types are disabled, 
this should result in `half` being 32-bit right?



Comment at: clang/test/CodeGenHLSL/builtins/pow.hlsl:12
+// NO_HALF: call float @llvm.pow.f32(
+half test_pow_half(half p0, half p1)
+{

nit: can you clang-format this source?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156178

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


[PATCH] D156154: [clang][ConstExprEmitter] handle IntegerLiterals

2023-07-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

In D156154#4529907 , @nickdesaulniers 
wrote:

> 



> Should speed up "is the below expression a constant expression?"
>
>> What kind of code do this effect?
>
>
>
>   int y = 2;
>   ^ is 2 a constant expression?

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156154

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


[PATCH] D156182: [clang][CodeGenModule] remove declaration of GetAddrOfConstantString

2023-07-24 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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156182

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


[PATCH] D156185: [clang][ConstExprEmitter] handle ArrayToPointerDecay ImplicitCastExpr of StringLiterals

2023-07-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Consider the following statement:

  const char* foo = "foo";

For the sub-AST:

  `-ImplicitCastExpr  'const char *' 
`-ImplicitCastExpr  'char *' 
  `-StringLiteral  'char[4]' lvalue "foo"

The address of the StringLiteral can be emitted as the Constant.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156185

Files:
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1133,6 +1133,10 @@
   return CGM.EmitNullConstant(destType);
   return nullptr;
 }
+case CK_ArrayToPointerDecay:
+  if (const auto *S = dyn_cast(subExpr))
+return CGM.GetAddrOfConstantStringFromLiteral(S).getPointer();
+  return nullptr;
 
 case CK_IntToOCLSampler:
   llvm_unreachable("global sampler variables are not generated");
@@ -1171,7 +1175,6 @@
 case CK_CPointerToObjCPointerCast:
 case CK_BlockPointerToObjCPointerCast:
 case CK_AnyPointerToBlockPointerCast:
-case CK_ArrayToPointerDecay:
 case CK_FunctionToPointerDecay:
 case CK_BaseToDerived:
 case CK_DerivedToBase:


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1133,6 +1133,10 @@
   return CGM.EmitNullConstant(destType);
   return nullptr;
 }
+case CK_ArrayToPointerDecay:
+  if (const auto *S = dyn_cast(subExpr))
+return CGM.GetAddrOfConstantStringFromLiteral(S).getPointer();
+  return nullptr;
 
 case CK_IntToOCLSampler:
   llvm_unreachable("global sampler variables are not generated");
@@ -1171,7 +1175,6 @@
 case CK_CPointerToObjCPointerCast:
 case CK_BlockPointerToObjCPointerCast:
 case CK_AnyPointerToBlockPointerCast:
-case CK_ArrayToPointerDecay:
 case CK_FunctionToPointerDecay:
 case CK_BaseToDerived:
 case CK_DerivedToBase:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156182: [clang][CodeGenModule] remove declaration of GetAddrOfConstantString

2023-07-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It looks like the definition was removed in cd21d541397e but the
declaration was not.  Surprisingly (to me), that doesn't seem to produce
any kind of diagnostic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156182

Files:
  clang/include/clang/CodeGen/ConstantInitBuilder.h
  clang/lib/CodeGen/CodeGenModule.h


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1019,11 +1019,6 @@
   /// Return a pointer to a constant CFString object for the given string.
   ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal);
 
-  /// Return a pointer to a constant NSString object for the given string. Or a
-  /// user defined String object as defined via
-  /// -fconstant-string-class=class_name option.
-  ConstantAddress GetAddrOfConstantString(const StringLiteral *Literal);
-
   /// Return a constant array for the given string.
   llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E);
 
Index: clang/include/clang/CodeGen/ConstantInitBuilder.h
===
--- clang/include/clang/CodeGen/ConstantInitBuilder.h
+++ clang/include/clang/CodeGen/ConstantInitBuilder.h
@@ -41,7 +41,7 @@
 ///for (auto  : widgets) {
 ///  auto widgetDesc = widgetArray.beginStruct();
 ///  widgetDesc.addInt(CGM.SizeTy, widget.getPower());
-///  widgetDesc.add(CGM.GetAddrOfConstantString(widget.getName()));
+///  
widgetDesc.add(CGM.GetAddrOfConstantStringFromLiteral(widget.getName()));
 ///  widgetDesc.add(CGM.GetAddrOfGlobal(widget.getInitializerDecl()));
 ///  widgetDesc.finishAndAddTo(widgetArray);
 ///}


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1019,11 +1019,6 @@
   /// Return a pointer to a constant CFString object for the given string.
   ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal);
 
-  /// Return a pointer to a constant NSString object for the given string. Or a
-  /// user defined String object as defined via
-  /// -fconstant-string-class=class_name option.
-  ConstantAddress GetAddrOfConstantString(const StringLiteral *Literal);
-
   /// Return a constant array for the given string.
   llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E);
 
Index: clang/include/clang/CodeGen/ConstantInitBuilder.h
===
--- clang/include/clang/CodeGen/ConstantInitBuilder.h
+++ clang/include/clang/CodeGen/ConstantInitBuilder.h
@@ -41,7 +41,7 @@
 ///for (auto  : widgets) {
 ///  auto widgetDesc = widgetArray.beginStruct();
 ///  widgetDesc.addInt(CGM.SizeTy, widget.getPower());
-///  widgetDesc.add(CGM.GetAddrOfConstantString(widget.getName()));
+///  widgetDesc.add(CGM.GetAddrOfConstantStringFromLiteral(widget.getName()));
 ///  widgetDesc.add(CGM.GetAddrOfGlobal(widget.getInitializerDecl()));
 ///  widgetDesc.finishAndAddTo(widgetArray);
 ///}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155997: [Phase Ordering] Don't speculate in SimplifyCFG before PGO annotation

2023-07-24 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll:3
 ; RUN: opt < %s -S -passes=simplifycfg 
-simplifycfg-require-and-preserve-domtree=1 -bonus-inst-threshold=10 | 
FileCheck %s
+; RUN: opt < %s -S -passes='simplifycfg' 
-simplifycfg-require-and-preserve-domtree=1 -bonus-inst-threshold=10 | 
FileCheck %s --check-prefix=NOSPECULATE
 

tejohnson wrote:
> aeubanks wrote:
> > these checks won't work for a `update_test_checks.py` test. should add 
> > tests like the one added in https://reviews.llvm.org/D153391
> Can you clarify - are you saying remove the changes from this test and add a 
> new test for this change like 
> llvm/test/Transforms/SimplifyCFG/speculate-blocks.ll, or change the checks 
> here?
revert the changes here (`update_test_checks.py` tests shouldn't have manually 
added CHECK lines) and add new function(s) to 
`llvm/test/Transforms/SimplifyCFG/speculate-blocks.ll` that show the difference 
between `speculate-blocks` and `no-speculate-blocks`



Comment at: llvm/test/Transforms/SimplifyCFG/pipeline-delay-speculation-pgo.ll:1
+;; Test that the pipelines delay simplify CFG speculation until after
+;; pgo annotation.

tejohnson wrote:
> aeubanks wrote:
> > do you have a phase ordering test instead?
> Can you clarify what you are referring to?
`llvm/test/Transforms/PhaseOrdering` has IR tests that get run through an 
entire pipeline (e.g. `thinlto-pre-link`) to verify some property of the 
entire pipeline. ideally you can get some somewhat-reduced IR that exhibits the 
problem you were seeing before the change and show that it improves with the 
pipeline change. you'll need a profile as part of that test I suppose


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155997

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


[PATCH] D155997: [Phase Ordering] Don't speculate in SimplifyCFG before PGO annotation

2023-07-24 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: llvm/lib/Passes/PassBuilderPipelines.cpp:277
 
+static cl::opt AlwaysAllowSimplifyCFGSpeculation(
+"always-allow-simplify-cfg-speculation", cl::init(false), cl::Hidden,

aeubanks wrote:
> can we just drop the flag and make this change?
Ok, I will remove.




Comment at: llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll:3
 ; RUN: opt < %s -S -passes=simplifycfg 
-simplifycfg-require-and-preserve-domtree=1 -bonus-inst-threshold=10 | 
FileCheck %s
+; RUN: opt < %s -S -passes='simplifycfg' 
-simplifycfg-require-and-preserve-domtree=1 -bonus-inst-threshold=10 | 
FileCheck %s --check-prefix=NOSPECULATE
 

aeubanks wrote:
> these checks won't work for a `update_test_checks.py` test. should add tests 
> like the one added in https://reviews.llvm.org/D153391
Can you clarify - are you saying remove the changes from this test and add a 
new test for this change like 
llvm/test/Transforms/SimplifyCFG/speculate-blocks.ll, or change the checks here?



Comment at: llvm/test/Transforms/SimplifyCFG/pipeline-delay-speculation-pgo.ll:1
+;; Test that the pipelines delay simplify CFG speculation until after
+;; pgo annotation.

aeubanks wrote:
> do you have a phase ordering test instead?
Can you clarify what you are referring to?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155997

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


[PATCH] D156178: [HLSL] add pow library function

2023-07-24 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 543731.
bob80905 added a comment.

- add eof newline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156178

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/pow.hlsl

Index: clang/test/CodeGenHLSL/builtins/pow.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/pow.hlsl
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.pow.f16(
+// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"(
+// NO_HALF: call float @llvm.pow.f32(
+half test_pow_half(half p0, half p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x half> @
+// CHECK: call <2 x half> @llvm.pow.v2f16
+// NO_HALF: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"(
+// NO_HALF: call <2 x float> @llvm.pow.v2f32(
+half2 test_pow_half2(half2 p0, half2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x half> @
+// CHECK: call <3 x half> @llvm.pow.v3f16
+// NO_HALF: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"(
+// NO_HALF: call <3 x float> @llvm.pow.v3f32(
+half3 test_pow_half3(half3 p0, half3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x half> @
+// CHECK: call <4 x half> @llvm.pow.v4f16
+// NO_HALF: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"(
+// NO_HALF: call <4 x float> @llvm.pow.v4f32(
+half4 test_pow_half4(half4 p0, half4 p1)
+{
+  return pow(p0, p1);
+}
+
+// CHECK: define noundef float @
+// CHECK: call float @llvm.pow.f32(
+float test_pow_float(float p0, float p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x float> @
+// CHECK: call <2 x float> @llvm.pow.v2f32
+float2 test_pow_float2(float2 p0, float2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x float> @
+// CHECK: call <3 x float> @llvm.pow.v3f32
+float3 test_pow_float3(float3 p0, float3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x float> @
+// CHECK: call <4 x float> @llvm.pow.v4f32
+float4 test_pow_float4(float4 p0, float4 p1)
+{
+  return pow(p0, p1);
+}
+
+// CHECK: define noundef double @
+// CHECK: call double @llvm.pow.f64(
+double test_pow_double(double p0, double p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x double> @
+// CHECK: call <2 x double> @llvm.pow.v2f64
+double2 test_pow_double2(double2 p0, double2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x double> @
+// CHECK: call <3 x double> @llvm.pow.v3f64
+double3 test_pow_double3(double3 p0, double3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x double> @
+// CHECK: call <4 x double> @llvm.pow.v4f64
+double4 test_pow_double4(double4 p0, double4 p1)
+{
+  return pow(p0, p1);
+}
Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h
===
--- clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -476,5 +476,35 @@
 __attribute__((clang_builtin_alias(__builtin_elementwise_min)))
 double4 min(double4, double4);
 
+// pow builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half pow(half, half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half2 pow(half2, half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half3 pow(half3, half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half4 pow(half4, half4);
+#endif
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) float
+pow(float, float);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+float2 pow(float2, float2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+float3 pow(float3, float3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+float4 pow(float4, float4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) double
+pow(double, double);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+double2 pow(double2, double2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+double3 pow(double3, double3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+double4 pow(double4, double4);
+
 } // namespace hlsl
 #endif //_HLSL_HLSL_INTRINSICS_H_
___
cfe-commits 

[PATCH] D156178: [HLSL] add pow library function

2023-07-24 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 543730.
bob80905 added a comment.

- remove non-floating-point func decls from header file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156178

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/pow.hlsl

Index: clang/test/CodeGenHLSL/builtins/pow.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/pow.hlsl
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.pow.f16(
+// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"(
+// NO_HALF: call float @llvm.pow.f32(
+half test_pow_half(half p0, half p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x half> @
+// CHECK: call <2 x half> @llvm.pow.v2f16
+// NO_HALF: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"(
+// NO_HALF: call <2 x float> @llvm.pow.v2f32(
+half2 test_pow_half2(half2 p0, half2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x half> @
+// CHECK: call <3 x half> @llvm.pow.v3f16
+// NO_HALF: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"(
+// NO_HALF: call <3 x float> @llvm.pow.v3f32(
+half3 test_pow_half3(half3 p0, half3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x half> @
+// CHECK: call <4 x half> @llvm.pow.v4f16
+// NO_HALF: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"(
+// NO_HALF: call <4 x float> @llvm.pow.v4f32(
+half4 test_pow_half4(half4 p0, half4 p1)
+{
+  return pow(p0, p1);
+}
+
+// CHECK: define noundef float @
+// CHECK: call float @llvm.pow.f32(
+float test_pow_float(float p0, float p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x float> @
+// CHECK: call <2 x float> @llvm.pow.v2f32
+float2 test_pow_float2(float2 p0, float2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x float> @
+// CHECK: call <3 x float> @llvm.pow.v3f32
+float3 test_pow_float3(float3 p0, float3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x float> @
+// CHECK: call <4 x float> @llvm.pow.v4f32
+float4 test_pow_float4(float4 p0, float4 p1)
+{
+  return pow(p0, p1);
+}
+
+// CHECK: define noundef double @
+// CHECK: call double @llvm.pow.f64(
+double test_pow_double(double p0, double p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x double> @
+// CHECK: call <2 x double> @llvm.pow.v2f64
+double2 test_pow_double2(double2 p0, double2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x double> @
+// CHECK: call <3 x double> @llvm.pow.v3f64
+double3 test_pow_double3(double3 p0, double3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x double> @
+// CHECK: call <4 x double> @llvm.pow.v4f64
+double4 test_pow_double4(double4 p0, double4 p1)
+{
+  return pow(p0, p1);
+}
\ No newline at end of file
Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h
===
--- clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -476,5 +476,35 @@
 __attribute__((clang_builtin_alias(__builtin_elementwise_min)))
 double4 min(double4, double4);
 
+// pow builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half pow(half, half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half2 pow(half2, half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half3 pow(half3, half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half4 pow(half4, half4);
+#endif
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) float
+pow(float, float);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+float2 pow(float2, float2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+float3 pow(float3, float3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+float4 pow(float4, float4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) double
+pow(double, double);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+double2 pow(double2, double2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+double3 pow(double3, double3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+double4 pow(double4, double4);
+
 } // namespace hlsl
 #endif 

[PATCH] D155529: [clang-format] Add SpaceInParensOption for __attribute__ keyword

2023-07-24 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 543729.
gedare added a comment.

Add a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155529

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16748,6 +16748,7 @@
   Spaces.SpacesInParensOptions = {};
   Spaces.SpacesInParensOptions.Other = true;
   Spaces.SpacesInParensOptions.InConditionalStatements = true;
+  Spaces.SpacesInParensOptions.InAttributeSpecifiers = true;
   verifyFormat("do_something( ::globalVar );", Spaces);
   verifyFormat("call( x, y, z );", Spaces);
   verifyFormat("call();", Spaces);
@@ -16822,6 +16823,12 @@
   verifyFormat("void __attribute__((naked)) foo(int bar)", Spaces);
   verifyFormat("void f( ) __attribute__((asdf));", Spaces);
 
+  Spaces.SpacesInParensOptions.InAttributeSpecifiers = true;
+  verifyFormat("SomeType *__attribute__( ( attr ) ) *a = NULL;", Spaces);
+  verifyFormat("void __attribute__( ( naked ) ) foo(int bar)", Spaces);
+  verifyFormat("void f( ) __attribute__( ( asdf ) );", Spaces);
+  Spaces.SpacesInParensOptions.InAttributeSpecifiers = false;
+
   // Run the first set of tests again with:
   Spaces.SpaceAfterCStyleCast = true;
   verifyFormat("call(x, y, z);", Spaces);
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -217,6 +217,7 @@
   CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterIfMacros);
   CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterOverloadedOperator);
   CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, BeforeNonEmptyParentheses);
+  CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InAttributeSpecifiers);
   CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InCStyleCasts);
   CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InConditionalStatements);
   CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InEmptyParentheses);
@@ -594,19 +595,23 @@
   Style.SpacesInParens = FormatStyle::SIPO_Never;
   Style.SpacesInParensOptions = {};
   CHECK_PARSE("SpacesInParentheses: true", SpacesInParensOptions,
-  FormatStyle::SpacesInParensCustom(true, false, false, true));
+  FormatStyle::SpacesInParensCustom(true, true, false, false,
+  true));
   Style.SpacesInParens = FormatStyle::SIPO_Never;
   Style.SpacesInParensOptions = {};
   CHECK_PARSE("SpacesInConditionalStatement: true", SpacesInParensOptions,
-  FormatStyle::SpacesInParensCustom(true, false, false, false));
+  FormatStyle::SpacesInParensCustom(false, true, false, false,
+  false));
   Style.SpacesInParens = FormatStyle::SIPO_Never;
   Style.SpacesInParensOptions = {};
   CHECK_PARSE("SpacesInCStyleCastParentheses: true", SpacesInParensOptions,
-  FormatStyle::SpacesInParensCustom(false, true, false, false));
+  FormatStyle::SpacesInParensCustom(false, false, true, false,
+  false));
   Style.SpacesInParens = FormatStyle::SIPO_Never;
   Style.SpacesInParensOptions = {};
   CHECK_PARSE("SpaceInEmptyParentheses: true", SpacesInParensOptions,
-  FormatStyle::SpacesInParensCustom(false, false, true, false));
+  FormatStyle::SpacesInParensCustom(false, false, false, true,
+  false));
   Style.SpacesInParens = FormatStyle::SIPO_Never;
   Style.SpacesInParensOptions = {};
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3810,10 +3810,16 @@
   }
 
   if (Left.is(tok::l_paren) || Right.is(tok::r_paren)) {
-return (Right.is(TT_CastRParen) ||
-(Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen)))
-   ? Style.SpacesInParensOptions.InCStyleCasts
-   : Style.SpacesInParensOptions.Other;
+if (Right.is(TT_CastRParen) ||
+(Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen))) {
+  return Style.SpacesInParensOptions.InCStyleCasts;
+}
+if (Left.is(TT_AttributeParen) || Right.is(TT_AttributeParen) ||
+(Left.Previous && Left.Previous->is(TT_AttributeParen)) ||
+(Right.Next && Right.Next->is(TT_AttributeParen))) {
+  return Style.SpacesInParensOptions.InAttributeSpecifiers;
+}
+return Style.SpacesInParensOptions.Other;
   }
   if (Right.isOneOf(tok::semi, tok::comma))
 return false;

[PATCH] D155239: [clang-format] Add SpacesInParens with SpacesInParensOptions

2023-07-24 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 543727.
gedare added a comment.

Add a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155239

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

Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -807,7 +807,8 @@
"  if (x)\n"
"x = x;",
Style);
-  Style.SpacesInConditionalStatement = true;
+  Style.SpacesInParens = FormatStyle::SIPO_Custom;
+  Style.SpacesInParensOptions.InConditionalStatements = true;
   verifyFormat("if ( x )\n"
"  x = x;\n"
"else if ( x )\n"
@@ -903,7 +904,8 @@
   verifyFormat("repeat (x) begin\n"
"end");
   auto Style = getDefaultStyle();
-  Style.SpacesInConditionalStatement = true;
+  Style.SpacesInParens = FormatStyle::SIPO_Custom;
+  Style.SpacesInParensOptions.InConditionalStatements = true;
   verifyFormat("foreach ( x[x] )\n"
"  x = x;",
Style);
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11031,14 +11031,16 @@
   verifyFormat("template  void operator=(T) && {}", AlignMiddle);
 
   FormatStyle Spaces = getLLVMStyle();
-  Spaces.SpacesInCStyleCastParentheses = true;
+  Spaces.SpacesInParens = FormatStyle::SIPO_Custom;
+  Spaces.SpacesInParensOptions = {};
+  Spaces.SpacesInParensOptions.InCStyleCasts = true;
   verifyFormat("Deleted =(const Deleted &) & = default;", Spaces);
   verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;", Spaces);
   verifyFormat("Deleted =(const Deleted &) &;", Spaces);
   verifyFormat("SomeType MemberFunction(const Deleted &) &;", Spaces);
 
-  Spaces.SpacesInCStyleCastParentheses = false;
-  Spaces.SpacesInParentheses = true;
+  Spaces.SpacesInParensOptions.InCStyleCasts = false;
+  Spaces.SpacesInParensOptions.Other = true;
   verifyFormat("Deleted =( const Deleted & ) & = default;", Spaces);
   verifyFormat("SomeType MemberFunction( const Deleted & ) & = delete;",
Spaces);
@@ -13674,7 +13676,8 @@
 
   FormatStyle SpaceBetweenBraces = getLLVMStyle();
   SpaceBetweenBraces.SpacesInAngles = FormatStyle::SIAS_Always;
-  SpaceBetweenBraces.SpacesInParentheses = true;
+  SpaceBetweenBraces.SpacesInParens = FormatStyle::SIPO_Custom;
+  SpaceBetweenBraces.SpacesInParensOptions.Other = true;
   SpaceBetweenBraces.SpacesInSquareBrackets = true;
   verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
   verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces);
@@ -13697,7 +13700,8 @@
 "};",
 format("vectorx{1,2,3,4,};", SpaceBetweenBraces));
   verifyFormat("vector< int > x{};", SpaceBetweenBraces);
-  SpaceBetweenBraces.SpaceInEmptyParentheses = true;
+  SpaceBetweenBraces.SpacesInParens = FormatStyle::SIPO_Custom;
+  SpaceBetweenBraces.SpacesInParensOptions.InEmptyParentheses = true;
   verifyFormat("vector< int > x{ };", SpaceBetweenBraces);
 }
 
@@ -16707,10 +16711,43 @@
   verifyFormat("! ! x", Spaces);
 }
 
-TEST_F(FormatTest, ConfigurableSpacesInParentheses) {
+TEST_F(FormatTest, ConfigurableSpacesInParens) {
   FormatStyle Spaces = getLLVMStyle();
 
-  Spaces.SpacesInParentheses = true;
+  verifyFormat("do_something(::globalVar);", Spaces);
+  verifyFormat("call(x, y, z);", Spaces);
+  verifyFormat("call();", Spaces);
+  verifyFormat("std::function callback;", Spaces);
+  verifyFormat("void inFunction() { std::function fct; }",
+   Spaces);
+  verifyFormat("while ((bool)1)\n"
+   "  continue;",
+   Spaces);
+  verifyFormat("for (;;)\n"
+   "  continue;",
+   Spaces);
+  verifyFormat("if (true)\n"
+   "  f();\n"
+   "else if (true)\n"
+   "  f();",
+   Spaces);
+  verifyFormat("do {\n"
+   "  do_something((int)i);\n"
+   "} while (something());",
+   Spaces);
+  verifyFormat("switch (x) {\n"
+   "default:\n"
+   "  break;\n"
+   "}",
+   Spaces);
+  verifyFormat("SomeType *__attribute__((attr)) *a = NULL;", Spaces);
+  verifyFormat("void __attribute__((naked)) foo(int bar)", Spaces);
+  verifyFormat("void f() __attribute__((asdf));", Spaces);
+
+  Spaces.SpacesInParens = FormatStyle::SIPO_Custom;
+  Spaces.SpacesInParensOptions = 

[PATCH] D156178: [HLSL] add pow library function

2023-07-24 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 created this revision.
bob80905 added reviewers: python3kgae, beanz.
Herald added a subscriber: Anastasia.
Herald added a project: All.
bob80905 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change exposes the pow library function for HLSL, only available for 
floating point types.
The pow function is supported for all scalar, vector, and matrix types that 
contain floating point types.

The full documentation of the HLSL pow function is available here:
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-pow


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156178

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/pow.hlsl

Index: clang/test/CodeGenHLSL/builtins/pow.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/pow.hlsl
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.pow.f16(
+// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"(
+// NO_HALF: call float @llvm.pow.f32(
+half test_pow_half(half p0, half p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x half> @
+// CHECK: call <2 x half> @llvm.pow.v2f16
+// NO_HALF: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"(
+// NO_HALF: call <2 x float> @llvm.pow.v2f32(
+half2 test_pow_half2(half2 p0, half2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x half> @
+// CHECK: call <3 x half> @llvm.pow.v3f16
+// NO_HALF: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"(
+// NO_HALF: call <3 x float> @llvm.pow.v3f32(
+half3 test_pow_half3(half3 p0, half3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x half> @
+// CHECK: call <4 x half> @llvm.pow.v4f16
+// NO_HALF: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"(
+// NO_HALF: call <4 x float> @llvm.pow.v4f32(
+half4 test_pow_half4(half4 p0, half4 p1)
+{
+  return pow(p0, p1);
+}
+
+// CHECK: define noundef float @
+// CHECK: call float @llvm.pow.f32(
+float test_pow_float(float p0, float p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x float> @
+// CHECK: call <2 x float> @llvm.pow.v2f32
+float2 test_pow_float2(float2 p0, float2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x float> @
+// CHECK: call <3 x float> @llvm.pow.v3f32
+float3 test_pow_float3(float3 p0, float3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x float> @
+// CHECK: call <4 x float> @llvm.pow.v4f32
+float4 test_pow_float4(float4 p0, float4 p1)
+{
+  return pow(p0, p1);
+}
+
+// CHECK: define noundef double @
+// CHECK: call double @llvm.pow.f64(
+double test_pow_double(double p0, double p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <2 x double> @
+// CHECK: call <2 x double> @llvm.pow.v2f64
+double2 test_pow_double2(double2 p0, double2 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <3 x double> @
+// CHECK: call <3 x double> @llvm.pow.v3f64
+double3 test_pow_double3(double3 p0, double3 p1)
+{
+  return pow(p0, p1);
+}
+// CHECK: define noundef <4 x double> @
+// CHECK: call <4 x double> @llvm.pow.v4f64
+double4 test_pow_double4(double4 p0, double4 p1)
+{
+  return pow(p0, p1);
+}
\ No newline at end of file
Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h
===
--- clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -476,5 +476,89 @@
 __attribute__((clang_builtin_alias(__builtin_elementwise_min)))
 double4 min(double4, double4);
 
+// pow builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half pow(half, half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half2 pow(half2, half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half3 pow(half3, half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half4 pow(half4, half4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+int16_t pow(int16_t, int16_t);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+int16_t2 pow(int16_t2, int16_t2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+int16_t3 pow(int16_t3, int16_t3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+int16_t4 pow(int16_t4, int16_t4);
+

[PATCH] D154550: [clang-format] Allow empty loops on a single line.

2023-07-24 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 543721.
gedare added a comment.
This revision is now accepted and ready to land.

Change option name from NonEmpty to NonNullStatement. Fix space before semi.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154550

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1380,7 +1380,8 @@
 
 TEST_F(FormatTest, FormatLoopsWithoutCompoundStatement) {
   FormatStyle AllowsMergedLoops = getLLVMStyle();
-  AllowsMergedLoops.AllowShortLoopsOnASingleLine = true;
+  AllowsMergedLoops.AllowShortLoopsOnASingleLine =
+  FormatStyle::SWFLS_NonNullStatement;
   verifyFormat("while (true) continue;", AllowsMergedLoops);
   verifyFormat("for (;;) continue;", AllowsMergedLoops);
   verifyFormat("for (int  : vec) v *= 2;", AllowsMergedLoops);
@@ -1436,6 +1437,66 @@
"  while (true);\n"
"}",
AllowsMergedLoops);
+  AllowsMergedLoops.AllowShortLoopsOnASingleLine = FormatStyle::SWFLS_All;
+  verifyFormat("while (true) continue;", AllowsMergedLoops);
+  verifyFormat("for (;;) continue;", AllowsMergedLoops);
+  verifyFormat("for (int  : vec) v *= 2;", AllowsMergedLoops);
+  verifyFormat("BOOST_FOREACH (int , vec) v *= 2;", AllowsMergedLoops);
+  verifyFormat("while (true);",
+   AllowsMergedLoops);
+  verifyFormat("for (;;);",
+   AllowsMergedLoops);
+  verifyFormat("for (;;)\n"
+   "  for (;;) continue;",
+   AllowsMergedLoops);
+  verifyFormat("for (;;)\n"
+   "  for (;;);",
+   AllowsMergedLoops);
+  verifyFormat("for (;;)\n"
+   "  while (true);",
+   AllowsMergedLoops);
+  verifyFormat("while (true)\n"
+   "  for (;;) continue;",
+   AllowsMergedLoops);
+  verifyFormat("while (true)\n"
+   "  for (;;);",
+   AllowsMergedLoops);
+  verifyFormat("BOOST_FOREACH (int , vec)\n"
+   "  for (;;);",
+   AllowsMergedLoops);
+  verifyFormat("for (;;)\n"
+   "  BOOST_FOREACH (int , vec);",
+   AllowsMergedLoops);
+  verifyFormat("for (;;) // Can't merge this\n"
+   "  ;",
+   AllowsMergedLoops);
+  verifyFormat("for (;;) /* still don't merge */\n"
+   "  ;",
+   AllowsMergedLoops);
+  verifyFormat("do a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do /* Don't merge */\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do // Don't merge\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do\n"
+   "  // Don't merge\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  // Without braces labels are interpreted differently.
+  verifyFormat("{\n"
+   "  do\n"
+   "  label:\n"
+   "a++;\n"
+   "  while (true);\n"
+   "}",
+   AllowsMergedLoops);
 }
 
 TEST_F(FormatTest, FormatShortBracedStatements) {
@@ -1443,7 +1504,8 @@
   EXPECT_EQ(AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine, false);
   EXPECT_EQ(AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine,
 FormatStyle::SIS_Never);
-  EXPECT_EQ(AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine, false);
+  EXPECT_EQ(AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine,
+FormatStyle::SWFLS_Never);
   EXPECT_EQ(AllowSimpleBracedStatements.BraceWrapping.AfterFunction, false);
   verifyFormat("for (;;) {\n"
"  f();\n"
@@ -1488,7 +1550,8 @@
   AllowSimpleBracedStatements.ColumnLimit = 40;
   AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine =
   FormatStyle::SBS_Always;
-  AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = true;
+  AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine =
+  FormatStyle::SWFLS_NonNullStatement;
   AllowSimpleBracedStatements.BreakBeforeBraces = FormatStyle::BS_Custom;
   AllowSimpleBracedStatements.BraceWrapping.AfterFunction = true;
   AllowSimpleBracedStatements.BraceWrapping.SplitEmptyRecord = false;
@@ -1605,7 +1668,8 @@
"}",
AllowSimpleBracedStatements);
 
-  AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = false;
+  AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine =
+  

[PATCH] D156175: [clang][ConstExprEmitter] handle NullToPointer ImplicitCastExpr

2023-07-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1131-1132
+case CK_NullToPointer: {
+  if (llvm::Constant *C = Visit(subExpr, destType))
+if (C->isNullValue())
+  return CGM.EmitNullConstant(destType);

FWIW, I would have thought these might be unnecessary, but we do trip 2 tests 
without these guards IIRC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156175

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


[PATCH] D156154: [clang][ConstExprEmitter] handle IntegerLiterals

2023-07-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D156154#4529889 , @shafik wrote:

> What practical effects will this have?

As of D151587 ...

From the commit message `Improves the ability of ConstExprEmitter to evaluate 
constants.` Stated another way:
Should speed up "is the below expression a constant expression?"

> What kind of code do this effect?



  int y = 2;
  ^ is 2 a constant expression?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156154

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


[PATCH] D156154: [clang][ConstExprEmitter] handle IntegerLiterals

2023-07-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

What practical effects will this have? What kind of code do this effect?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156154

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


[PATCH] D156175: [clang][ConstExprEmitter] handle NullToPointer ImplicitCastExpr

2023-07-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
Herald added a subscriber: inglorion.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Consider the following statement:

  void* foo = ((void *)0);

For the sub-AST:

  | `-ImplicitCastExpr 'const void *' 
  |   `-CStyleCastExpr 'void *' 
  | `-IntegerLiteral 'int' 0

If the subexpression of the cast is itself the NULL constant, then
ImplicitCastExpr should emit the NULL pointer constant.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156175

Files:
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1127,6 +1127,13 @@
 case CK_ConstructorConversion:
   return Visit(subExpr, destType);
 
+case CK_NullToPointer: {
+  if (llvm::Constant *C = Visit(subExpr, destType))
+if (C->isNullValue())
+  return CGM.EmitNullConstant(destType);
+  return nullptr;
+}
+
 case CK_IntToOCLSampler:
   llvm_unreachable("global sampler variables are not generated");
 
@@ -1183,7 +1190,6 @@
 case CK_IntegralComplexToFloatingComplex:
 case CK_PointerToIntegral:
 case CK_PointerToBoolean:
-case CK_NullToPointer:
 case CK_IntegralCast:
 case CK_BooleanToSignedIntegral:
 case CK_IntegralToPointer:


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1127,6 +1127,13 @@
 case CK_ConstructorConversion:
   return Visit(subExpr, destType);
 
+case CK_NullToPointer: {
+  if (llvm::Constant *C = Visit(subExpr, destType))
+if (C->isNullValue())
+  return CGM.EmitNullConstant(destType);
+  return nullptr;
+}
+
 case CK_IntToOCLSampler:
   llvm_unreachable("global sampler variables are not generated");
 
@@ -1183,7 +1190,6 @@
 case CK_IntegralComplexToFloatingComplex:
 case CK_PointerToIntegral:
 case CK_PointerToBoolean:
-case CK_NullToPointer:
 case CK_IntegralCast:
 case CK_BooleanToSignedIntegral:
 case CK_IntegralToPointer:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155997: [Phase Ordering] Don't speculate in SimplifyCFG before PGO annotation

2023-07-24 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

the pipeline change and simplifycfg change should be split into two changes




Comment at: llvm/lib/Passes/PassBuilderPipelines.cpp:277
 
+static cl::opt AlwaysAllowSimplifyCFGSpeculation(
+"always-allow-simplify-cfg-speculation", cl::init(false), cl::Hidden,

can we just drop the flag and make this change?



Comment at: llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll:3
 ; RUN: opt < %s -S -passes=simplifycfg 
-simplifycfg-require-and-preserve-domtree=1 -bonus-inst-threshold=10 | 
FileCheck %s
+; RUN: opt < %s -S -passes='simplifycfg' 
-simplifycfg-require-and-preserve-domtree=1 -bonus-inst-threshold=10 | 
FileCheck %s --check-prefix=NOSPECULATE
 

these checks won't work for a `update_test_checks.py` test. should add tests 
like the one added in https://reviews.llvm.org/D153391



Comment at: llvm/test/Transforms/SimplifyCFG/pipeline-delay-speculation-pgo.ll:1
+;; Test that the pipelines delay simplify CFG speculation until after
+;; pgo annotation.

do you have a phase ordering test instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155997

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


[PATCH] D153914: [clang-cl] Enable concatenation of predefined identifiers

2023-07-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:2010-2013
+OS << "R\"EFLPM("
+   << PredefinedExpr::ComputeName(getPredefinedExprKind(Tok.getKind()),
+  currentDecl)
+   << ")EFLPM\"";

tahonermann wrote:
> RIscRIpt wrote:
> > tahonermann wrote:
> > > "EFLPM"? I'm assuming this is an attempt to avoid an accidental clash 
> > > with the computed name. Does this suffice to ensure a clash can't happen? 
> > > If not, can we do better? Per http://eel.is/c++draft/lex.string#nt:r-char 
> > > and http://eel.is/c++draft/lex.charset#1, we have a lot of flexibility 
> > > regarding which characters to use.
> > At first I thought you were hinting me to use non-ascii characters for 
> > d-char-sequence. However, when I looked closely d-char-sequence is not as 
> > flexible as r-chars that you referenced: 
> > http://eel.is/c++draft/lex.string#nt:d-char and 
> > http://eel.is/c++draft/lex.charset#2
> > 
> > Here're my thoughts:
> > 1. I was afraid that there could be a possibility of a function name 
> > contain either quote (`"`) or a backslash (`\`) despite it seemed 
> > impossible.
> > 2. At first I used `Lexer::Stringify` to make it bullet-proof. I didn't 
> > like it, neither did you (reviewers).
> > 3. I replaced `Lexer::Stringify` with raw-string-literal (d-char-sequence 
> > was chosen as acronym of current function name).
> > 4. Current `EFLPM` looks weird and cryptic. And we are limited to 
> > [lex.charset.basic] with exceptions (space and earlier chars are not 
> > allowed). I think, using a raw-string-literal without d-char-sequence would 
> > be enough, because problem could be caused only by two consecutive 
> > characters `)"`, neither of which can appear in a function name.
> Sorry about that; you are absolutely right that `d-char-sequence` is (much) 
> more constrained than `r-char-sequence`.
> 
> For `__FUNCSIG__`, the generated text can include arbitrary text. For 
> example, given this declaration:
>   void f(decltype(sizeof("()"))*)
> the macro value is:
>   void __cdecl f(decltype(sizeof ("()")) *)
> which does contain `)"`.
> 
> I think we should do more to avoid any possibility of the resulting string 
> being unparseable because the resulting diagnostics will be completely 
> inscrutable. The best way to do that would be to avoid trying to produce a 
> parseable string literal in the first place. Based on that and given that 
> `Sema::ActOnStringLiteral()` immediately uses `StringLiteralParser` to 
> produce an expanded string literal, I think we would be better off moving 
> this expansion there such that these macros can be expanded to already cooked 
> string literals that don't need to be parsed at all. This will mean having to 
> modify the `StringLiteralParser` constructor to accept a `Decl*` pointer that 
> will be passed `getCurLocalScopeDecl()` in `Sema::ActOnStringLiteral()`. 
> `StringLiteralParser` can then assert if it ever encounters one of these 
> function local predefined tokens when it hasn't been provided a corresponding 
> `Decl*` to use with them.
I didn't think about that scenario but in that case the original idea to use 
Lexer::Stringify seems like a cleaner solution to me.
Adding that kind of logic to `LiteralSupport` creates a lot of coupling for not 
much gain that I can see.


In that light, `Lexer::Stringify` seems like the least worse option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153914

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


[PATCH] D144829: [BPF] Add a few new insns under cpu=v4

2023-07-24 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 543709.
yonghong-song added a comment.

Three major changes in this patch:

- for ldsx insns, remove 32bit ldsx insns (1-byte and 2-byte sign extension) 
since the ldsx insn expects to sign extension all the way up to 8-byte and 
normal 32bit insn (e.g. BPF_ALU) expects to zero out the top bits. Instead do a 
ldbsx/ldhsx and then take the lower 4 byte to extract 32bit value. This also 
resolved one disasm issue reported by Eduard.
- for movsx insn, for 32bit sign extenstion to 64bit. Match both "sext_inreg 
GPR:$src, i32" (left and right shifting) and "sext GPR32:$src".
- Add an internal flag to control when to generate gotol insns in 
BPFMIPeephole.cpp. This permits a simpler test for gotol insns.

With the above changes, the following change is needed:

  diff --git a/tools/testing/selftests/bpf/progs/verifier_movsx.c 
b/tools/testing/selftests/bpf/progs/verifier_movsx.c
  index 5ee7d004f8ba..e27bfa11c9b3 100644
  --- a/tools/testing/selftests/bpf/progs/verifier_movsx.c
  +++ b/tools/testing/selftests/bpf/progs/verifier_movsx.c
  @@ -59,7 +59,7 @@ __naked void mov64sx_s32(void)
   {
  asm volatile (" \
  r0 = 0xfffe;\
  -   r0 = (s32)w0;   \
  +   r0 = (s32)r0;   \
  r0 >>= 1;   \
  exit;   \
   "  ::: __clobber_all);
  @@ -181,7 +181,7 @@ __naked void mov64sx_s32_range(void)
   {
  asm volatile (" \
  call %[bpf_get_prandom_u32];\
  -   r1 = (s32)w0;   \
  +   r1 = (s32)r0;   \
  /* r1 with s32 range */ \
  if r1 s> 0x7fff goto l0_%=; \
  if r1 s< -0x8000 goto l0_%=;\

in order to compile kernel cpu v4 support (patch series v3)

  https://lore.kernel.org/bpf/2023072103.99949-1-...@fb.com/

I will update the kernel side once we resolved all llvm issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144829

Files:
  clang/lib/Basic/Targets/BPF.cpp
  clang/lib/Basic/Targets/BPF.h
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
  llvm/lib/Target/BPF/BPF.td
  llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp
  llvm/lib/Target/BPF/BPFISelLowering.cpp
  llvm/lib/Target/BPF/BPFISelLowering.h
  llvm/lib/Target/BPF/BPFInstrFormats.td
  llvm/lib/Target/BPF/BPFInstrInfo.td
  llvm/lib/Target/BPF/BPFMIPeephole.cpp
  llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp
  llvm/lib/Target/BPF/BPFSubtarget.cpp
  llvm/lib/Target/BPF/BPFSubtarget.h
  llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCFixups.h
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp
  llvm/test/CodeGen/BPF/assembler-disassembler-v4.s
  llvm/test/CodeGen/BPF/bswap.ll
  llvm/test/CodeGen/BPF/gotol.ll
  llvm/test/CodeGen/BPF/ldsx.ll
  llvm/test/CodeGen/BPF/movsx.ll
  llvm/test/CodeGen/BPF/sdiv_smod.ll

Index: llvm/test/CodeGen/BPF/sdiv_smod.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/sdiv_smod.ll
@@ -0,0 +1,44 @@
+; RUN: llc -march=bpfel -mcpu=v4 -verify-machineinstrs -show-mc-encoding < %s | FileCheck %s
+; Source:
+;  int foo(int a, int b, int c) {
+;return a/b + a%c;
+;  }
+;  long bar(long a, long b, long c) {
+;   return a/b + a%c;
+; }
+; Compilation flags:
+;   clang -target bpf -O2 -S -emit-llvm t.c
+
+; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
+define dso_local i32 @foo(i32 noundef %a, i32 noundef %b, i32 noundef %c) local_unnamed_addr #0 {
+entry:
+  %div = sdiv i32 %a, %b
+  %rem = srem i32 %a, %c
+  %add = add nsw i32 %rem, %div
+  ret i32 %add
+}
+
+; CHECK:   w0 = w1
+; CHECK-NEXT:  w1 s/= w2   # encoding: [0x3c,0x21,0x01,0x00,0x00,0x00,0x00,0x00]
+; CHECK-NEXT:  w0 s%= w3   # encoding: [0x9c,0x30,0x01,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
+define dso_local i64 @bar(i64 noundef %a, i64 noundef %b, i64 noundef %c) local_unnamed_addr #0 {
+entry:
+  %div = sdiv i64 %a, %b
+  %rem = srem i64 %a, %c
+  %add = add nsw i64 %rem, %div
+  ret i64 %add
+}
+; CHECK:   r0 = r1
+; CHECK-NEXT:  r1 s/= r2   # encoding: [0x3f,0x21,0x01,0x00,0x00,0x00,0x00,0x00]
+; CHECK-NEXT:  r0 s%= r3   # encoding: 

[PATCH] D156172: [clang][CodeGen] Emit annotations for function declarations.

2023-07-24 Thread Brendan Dahl via Phabricator via cfe-commits
brendandahl created this revision.
Herald added a project: All.
brendandahl requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously, annotations were only emitted for function definitions. With
this change annotations are also emitted for declarations. Emitting for
both also more closely matches the behavior of regular function attributes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156172

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/annotations-declaration.c
  clang/test/CodeGen/annotations-global.c
  clang/test/CodeGenCXX/attr-annotate.cpp

Index: clang/test/CodeGenCXX/attr-annotate.cpp
===
--- clang/test/CodeGenCXX/attr-annotate.cpp
+++ clang/test/CodeGenCXX/attr-annotate.cpp
@@ -1,11 +1,11 @@
 // RUN: %clang_cc1 %s -S -emit-llvm -triple x86_64-unknown-linux-gnu -o - | FileCheck %s
 
+//CHECK: @[[STR:.*]] = private unnamed_addr constant [5 x i8] c"test\00", section "llvm.metadata"
 //CHECK: @[[STR1:.*]] = private unnamed_addr constant [{{.*}} x i8] c"{{.*}}attr-annotate.cpp\00", section "llvm.metadata"
 //CHECK: @[[STR2:.*]] = private unnamed_addr constant [4 x i8] c"abc\00", align 1
-//CHECK: @[[STR:.*]] = private unnamed_addr constant [5 x i8] c"test\00", section "llvm.metadata"
 //CHECK: @[[ARGS:.*]] = private unnamed_addr constant { i32, ptr, i32 } { i32 9, ptr @[[STR2:.*]], i32 8 }, section "llvm.metadata"
-//CHECK: @[[ARGS2:.*]] = private unnamed_addr constant { %struct.Struct } { %struct.Struct { ptr @_ZN1AIjLj9EE2SVE, ptr getelementptr (i8, ptr @_ZN1AIjLj9EE2SVE, i64 4) } }, section "llvm.metadata"
-//CHECK: @llvm.global.annotations = appending global [2 x { ptr, ptr, ptr, i32, ptr }] [{ ptr, ptr, ptr, i32, ptr } { ptr @_ZN1AIjLj9EE4testILi8EEEvv, ptr @[[STR:.*]], ptr @[[STR1:.*]], i32 {{.*}}, ptr @[[ARGS:.*]] }, { ptr, ptr, ptr, i32, ptr } { ptr @_ZN1AIjLj9EE5test2Ev, ptr @.str.6, ptr @.str.1, i32 24, ptr @[[ARGS2]] }]
+//CHECK: @[[ARGS3:.*]] = private unnamed_addr constant { %struct.Struct } { %struct.Struct { ptr @_ZN1AIjLj9EE2SVE, ptr getelementptr (i8, ptr @_ZN1AIjLj9EE2SVE, i64 4) } }, section "llvm.metadata"
+//CHECK: @llvm.global.annotations = appending global [2 x { ptr, ptr, ptr, i32, ptr }] [{ ptr, ptr, ptr, i32, ptr } { ptr @_ZN1AIjLj9EE4testILi8EEEvv, ptr @[[STR:.*]], ptr @[[STR1:.*]], i32 {{.*}}, ptr @[[ARGS:.*]] }, { ptr, ptr, ptr, i32, ptr } { ptr @_ZN1AIjLj9EE5test2Ev, ptr @.str, ptr @.str.1, i32 24, ptr @[[ARGS3]] }]
 
 constexpr const char* str() {
   return "abc";
@@ -51,12 +51,12 @@
 // CHECK-NEXT:store ptr [[ARGV:%.*]], ptr [[ARGV_ADDR]], align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[ARGC_ADDR]], align 4
 // CHECK-NEXT:[[V:%.*]] = getelementptr inbounds %"struct.B::foo", ptr [[F]], i32 0, i32 0
-// CHECK-NEXT:[[TMP2:%.*]] = call ptr @llvm.ptr.annotation.p0.p0(ptr [[V]], ptr @.str, ptr @.str.1, i32 {{.*}}, ptr @.args)
-// CHECK-NEXT:[[TMP5:%.*]] = call ptr @llvm.ptr.annotation.p0.p0(ptr [[TMP2]], ptr @.str.3, ptr @.str.1, i32 {{.*}}, ptr @.args.4)
+// CHECK-NEXT:[[TMP2:%.*]] = call ptr @llvm.ptr.annotation.p0.p0(ptr [[V]], ptr @.str.4, ptr @.str.1, i32 {{.*}}, ptr @.args.5)
+// CHECK-NEXT:[[TMP5:%.*]] = call ptr @llvm.ptr.annotation.p0.p0(ptr [[TMP2]], ptr @.str.6, ptr @.str.1, i32 {{.*}}, ptr @.args.7)
 // CHECK-NEXT:store i32 [[TMP0]], ptr [[TMP5]], align 4
 // CHECK-NEXT:[[TMP7:%.*]] = load i32, ptr [[ARGC_ADDR]], align 4
-// CHECK-NEXT:[[TMP8:%.*]] = call ptr @llvm.ptr.annotation.p0.p0(ptr @_ZL2gf, ptr @.str, ptr @.str.1, i32 {{.*}}, ptr @.args.5)
-// CHECK-NEXT:[[TMP11:%.*]] = call ptr @llvm.ptr.annotation.p0.p0(ptr [[TMP8]], ptr @.str.3, ptr @.str.1, i32 {{.*}}, ptr @.args.4)
+// CHECK-NEXT:[[TMP8:%.*]] = call ptr @llvm.ptr.annotation.p0.p0(ptr @_ZL2gf, ptr @.str.4, ptr @.str.1, i32 {{.*}}, ptr @.args.8)
+// CHECK-NEXT:[[TMP11:%.*]] = call ptr @llvm.ptr.annotation.p0.p0(ptr [[TMP8]], ptr @.str.6, ptr @.str.1, i32 {{.*}}, ptr @.args.7)
 // CHECK-NEXT:store i32 [[TMP7]], ptr [[TMP11]], align 4
 // CHECK-NEXT:ret i32 0
 //
Index: clang/test/CodeGen/annotations-global.c
===
--- clang/test/CodeGen/annotations-global.c
+++ clang/test/CodeGen/annotations-global.c
@@ -31,12 +31,12 @@
 // CHECK-DAG: private unnamed_addr constant [15 x i8] c"addrspace1_ann\00", section "llvm.metadata"
 
 // CHECK: @llvm.global.annotations = appending global [11 x { ptr, ptr, ptr, i32, ptr }] [{
-// CHECK-SAME: { ptr @a.bar,
-// CHECK-SAME: { ptr @a.bar,
 // CHECK-SAME: { ptr @a,
 // CHECK-SAME: { ptr @a,
 // CHECK-SAME: { ptr @a,
 // CHECK-SAME: { ptr @a,
+// CHECK-SAME: { ptr @a.bar,
+// CHECK-SAME: { ptr @a.bar,
 // CHECK-SAME: { ptr @sfoo,
 // CHECK-SAME: { ptr @sfoo,
 // CHECK-SAME: { ptr @foo,
Index: clang/test/CodeGen/annotations-declaration.c

[PATCH] D156161: [clang-tidy] Add --enable-module-headers-parsing option

2023-07-24 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 543708.
PiotrZSL retitled this revision from "[clang-tidy] Add 
--experimental-enable-module-headers-parsing option" to "[clang-tidy] Add 
--enable-module-headers-parsing option".
PiotrZSL edited the summary of this revision.
PiotrZSL added a comment.
Herald added a subscriber: arphaman.

Merge with other change, remove experimental


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156161

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  
clang-tools-extra/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp
@@ -5,7 +5,7 @@
 // RUN: %check_clang_tidy -std=c++11 %s readability-identifier-naming %t/without-modules -- \
 // RUN:   -config="CheckOptions: [{ \
 // RUN:  key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
-// RUN:   -header-filter=.* \
+// RUN:   -header-filter=.* --enable-module-headers-parsing \
 // RUN:   -- -I %t/
 //
 // RUN: rm -rf %t
@@ -14,7 +14,7 @@
 // RUN: %check_clang_tidy -std=c++17 %s readability-identifier-naming %t/without-modules -- \
 // RUN:   -config="CheckOptions: [{ \
 // RUN:  key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
-// RUN:   -header-filter=.* \
+// RUN:   -header-filter=.* --enable-module-headers-parsing \
 // RUN:   -- -I %t/
 //
 // Run clang-tidy on a file with modular includes:
@@ -25,7 +25,7 @@
 // RUN: %check_clang_tidy -std=c++11 %s readability-identifier-naming %t/with-modules -- \
 // RUN:   -config="CheckOptions: [{ \
 // RUN:  key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
-// RUN:   -header-filter=.* \
+// RUN:   -header-filter=.* --enable-module-headers-parsing \
 // RUN:   -- -I %t/ \
 // RUN:   -fmodules -fimplicit-modules -fno-implicit-module-maps \
 // RUN:   -fmodule-map-file=%t/module.modulemap \
@@ -37,7 +37,7 @@
 // RUN: %check_clang_tidy -std=c++17 %s readability-identifier-naming %t/with-modules -- \
 // RUN:   -config="CheckOptions: [{ \
 // RUN:  key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
-// RUN:   -header-filter=.* \
+// RUN:   -header-filter=.* --enable-module-headers-parsing \
 // RUN:   -- -I %t/ \
 // RUN:   -fmodules -fimplicit-modules -fno-implicit-module-maps \
 // RUN:   -fmodule-map-file=%t/module.modulemap \
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -116,117 +116,120 @@
 
   Generic Options:
 
---help - Display available options (--help-hidden for more)
---help-list- Display list of available options (--help-list-hidden for more)
---version  - Display the version of this program
+--help  - Display available options (--help-hidden for more)
+--help-list - Display list of available options (--help-list-hidden for more)
+--version   - Display the version of this program
 
   clang-tidy options:
 
---checks=  - Comma-separated list of globs with optional '-'
- prefix. Globs are processed in order of
- appearance in the list. Globs without '-'
- prefix add checks with matching names to the
- set, globs with the '-' prefix remove checks
- with matching names from the set of enabled
- checks. This option's value is appended to the
- value of the 'Checks' option in .clang-tidy
- file, if any.
---config=  - Specifies a configuration in YAML/JSON format:
-   -config="{Checks: '*',
- CheckOptions: {x: y}}"
- When the value is empty, clang-tidy will
- attempt to find a file named .clang-tidy for
- each source file in its 

[PATCH] D156064: [SemaCXX] Recognise initializer_list injected-class-name types as initializer_lists

2023-07-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

This makes sense I see that  `isStdInitializerList(...)` is used in a lot of 
places, this makes me wonder if we need additional test coverage.

I also added some folks for more review visibility.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156064

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


[PATCH] D154790: [HIP] Use native math functions for `-fcuda-approx-transcendentals`

2023-07-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping

It passes internal CI. Also tested with Blender main branch with -ffast-math 
and no regressions were found.


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

https://reviews.llvm.org/D154790

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


[PATCH] D154893: [Clang] Fix some triviality computations

2023-07-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:1269
   /// Determine whether this class has a non-trivial copy constructor
   /// (C++ [class.copy]p6, C++11 [class.copy]p12)
   bool hasNonTrivialCopyConstructor() const {

philnik wrote:
> royjacobson wrote:
> > shafik wrote:
> > > These references looks like they need to be updated. Same below and it 
> > > looks like `hasNonTrivialCopyConstructorForCall` is missing references 
> > > all together.
> > TBH I don't think those functions actually need references to the standard? 
> > Whether the actual member functions are trivial or not is already 
> > calculated before. Do you think I can just remove it? :)
> I think it makes sense to call out that these functions represent something 
> from the standard. There are other functions with similar names, which don't 
> have an equivalent in the C++ standard, like `hasTrivialDestructorForCall`.
The point of having the reference is so folks can understand the logic behind 
why someone choose to implement the functionality as they did.

I also prefer quoting the critical text since the paragraphs, sometimes the 
stable name and wording can change and at least having text can allow us to 
track which standard it came from and hopefully which change changed the text 
and understand if it effects our compliance or not.

It can be a lot of work to figure this out from scratch if you don't know where 
to look.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154893

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


[PATCH] D156024: [clang-tidy] Add --experimental-disable-module-headers-parsing option

2023-07-24 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL abandoned this revision.
PiotrZSL added a comment.

Will be integrated into D156161 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156024

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


[PATCH] D156032: Implement CWG2137 (list-initialization from objects of the same type)

2023-07-24 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 543699.
MitalAshok added a comment.

Add CWG2311 fix too

Too much code and tests rely on elision of `T{ T_prvalue }` in C++17, so add 
change to allow that to be elided when this does not pick a initializer-list 
constructor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156032

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/drs/dr14xx.cpp
  clang/test/CXX/drs/dr21xx.cpp
  clang/test/CXX/drs/dr23xx.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -12629,7 +12629,7 @@
 https://cplusplus.github.io/CWG/issues/2137.html;>2137
 CD4
 List-initialization from object of same type
-Unknown
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/2138.html;>2138
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -5,6 +5,16 @@
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 
+namespace std {
+  __extension__ typedef __SIZE_TYPE__ size_t;
+
+  template struct initializer_list {
+const E *p; size_t n;
+initializer_list(const E *p, size_t n);
+initializer_list();
+  };
+}
+
 #if __cplusplus >= 201103L
 namespace dr2303 { // dr2303: 12
 template 
@@ -37,6 +47,38 @@
 } //namespace dr2303
 #endif
 
+namespace dr2311 {
+#if __cplusplus >= 201707L
+template
+void test() {
+  // These should all be elided (no move)
+  T a = T{T(0)};
+  T b{T(0)};
+  auto c{T(0)};
+  T d = {T(0)};
+  auto e = {T(0)};
+#if __cplusplus >= 202302L
+  auto f = auto{T(0)};
+#endif
+}
+
+struct NonMovable {
+  NonMovable(int);
+  NonMovable(NonMovable&&) = delete;
+};
+
+template void test();
+
+struct NonMovableNonApplicableIList {
+  NonMovableNonApplicableIList(int);
+  NonMovableNonApplicableIList(NonMovableNonApplicableIList&&) = delete;
+  NonMovableNonApplicableIList(std::initializer_list);
+};
+
+template void test();
+#endif
+}
+
 // dr2331: na
 
 #if __cplusplus >= 201103L
Index: clang/test/CXX/drs/dr21xx.cpp
===
--- clang/test/CXX/drs/dr21xx.cpp
+++ clang/test/CXX/drs/dr21xx.cpp
@@ -10,6 +10,16 @@
 #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
 #endif
 
+namespace std {
+  __extension__ typedef __SIZE_TYPE__ size_t;
+
+  template struct initializer_list {
+const E *p; size_t n;
+initializer_list(const E *p, size_t n);
+initializer_list();
+  };
+}
+
 namespace dr2100 { // dr2100: 12
   template struct X {};
   template struct A {
@@ -110,6 +120,36 @@
 #endif
 }
 
+namespace dr2137 { // dr2137: 17
+#if __cplusplus >= 201103L
+  struct Q {
+Q();
+Q(Q&&);
+Q(std::initializer_list) = delete; // expected-note 2 {{has been explicitly marked deleted here}}
+  };
+
+  Q x = Q { Q() }; // expected-error {{call to deleted constructor}}
+
+  int f(Q); // expected-note {{passing argument to parameter here}}
+  int y = f({ Q() }); // expected-error {{call to deleted constructor}}
+
+  struct U {
+U();
+U(const U&);
+  };
+
+  struct Derived : U {
+Derived();
+Derived(const Derived&);
+  } d;
+
+  int g(Derived);
+  int g(U(&&)[1]) = delete;
+
+  int z = g({ d });
+#endif
+}
+
 namespace dr2140 { // dr2140: 9
 #if __cplusplus >= 201103L
   union U { int a; decltype(nullptr) b; };
Index: clang/test/CXX/drs/dr14xx.cpp
===
--- clang/test/CXX/drs/dr14xx.cpp
+++ clang/test/CXX/drs/dr14xx.cpp
@@ -423,16 +423,6 @@
 }
   } // nonaggregate
 
-  namespace SelfInitIsNotListInit {
-struct S {
-  S();
-  explicit S(S &);
-  S(const S &);
-};
-S s1;
-S s2 = {s1}; // ok, not list-initialization so we pick the non-explicit constructor
-  }
-
   struct NestedInit { int a, b, c; };
   NestedInit ni[1] = {{NestedInit{1, 2, 3}}};
 
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -1465,19 +1465,36 @@
 //   called for those cases.
 if (CXXConstructorDecl *Constructor
   = dyn_cast(ICS.UserDefined.ConversionFunction)) {
-  QualType FromCanon
-= S.Context.getCanonicalType(From->getType().getUnqualifiedType());
+  QualType FromType;
+  SourceLocation FromLoc;
+  // C++ [over.ics.list]p6, per DR2137:
+  //   If C is not an initializer-list constructor and the initializer list
+  //   has a single element of type cv U, where U is 

[PATCH] D156064: [SemaCXX] Recognise initializer_list injected-class-name types as initializer_lists

2023-07-24 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 543697.
MitalAshok added a comment.

Remove now unneeded FIXME


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156064

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -12,8 +12,6 @@
 size_t n;
 initializer_list();
   };
-  // FIXME: This should probably not be necessary.
-  template initializer_list(initializer_list) -> 
initializer_list;
 }
 
 template constexpr bool has_type(...) { return false; }
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -10589,8 +10589,6 @@
   // FIXME: Perform "exact type" matching first, per CWG discussion?
   //Or implement this via an implied 'T(T) -> T' deduction guide?
 
-  // FIXME: Do we need/want a std::initializer_list special case?
-
   // Look up deduction guides, including those synthesized from constructors.
   //
   // C++1z [over.match.class.deduct]p1:
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -11703,11 +11703,17 @@
 
 Template = Specialization->getSpecializedTemplate();
 Arguments = Specialization->getTemplateArgs().data();
-  } else if (const TemplateSpecializationType *TST =
- Ty->getAs()) {
-Template = dyn_cast_or_null(
-TST->getTemplateName().getAsTemplateDecl());
-Arguments = TST->template_arguments().begin();
+  } else {
+const TemplateSpecializationType *TST = nullptr;
+if (auto *ICN = Ty->getAs())
+  TST = ICN->getInjectedTST();
+else
+  TST = Ty->getAs();
+if (TST) {
+  Template = dyn_cast_or_null(
+  TST->getTemplateName().getAsTemplateDecl());
+  Arguments = TST->template_arguments().begin();
+}
   }
   if (!Template)
 return false;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -789,6 +789,9 @@
   (`#63903 `_)
 - Fix constraint checking of non-generic lambdas.
   (`#63181 `_)
+- Fix CTAD for ``std::initializer_list``. This allows
+  ``std::initializer_list{1, 2, 3}`` to be a ``std::initializer_list``
+  as intended.
 
 Bug Fixes to AST Handling
 ^


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -12,8 +12,6 @@
 size_t n;
 initializer_list();
   };
-  // FIXME: This should probably not be necessary.
-  template initializer_list(initializer_list) -> initializer_list;
 }
 
 template constexpr bool has_type(...) { return false; }
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -10589,8 +10589,6 @@
   // FIXME: Perform "exact type" matching first, per CWG discussion?
   //Or implement this via an implied 'T(T) -> T' deduction guide?
 
-  // FIXME: Do we need/want a std::initializer_list special case?
-
   // Look up deduction guides, including those synthesized from constructors.
   //
   // C++1z [over.match.class.deduct]p1:
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -11703,11 +11703,17 @@
 
 Template = Specialization->getSpecializedTemplate();
 Arguments = Specialization->getTemplateArgs().data();
-  } else if (const TemplateSpecializationType *TST =
- Ty->getAs()) {
-Template = dyn_cast_or_null(
-TST->getTemplateName().getAsTemplateDecl());
-Arguments = TST->template_arguments().begin();
+  } else {
+const TemplateSpecializationType *TST = nullptr;
+if (auto *ICN = Ty->getAs())
+  TST = ICN->getInjectedTST();
+else
+  TST = Ty->getAs();
+if (TST) {
+  Template = dyn_cast_or_null(
+  TST->getTemplateName().getAsTemplateDecl());
+  Arguments = TST->template_arguments().begin();
+}
   }
   if (!Template)
 return false;
Index: clang/docs/ReleaseNotes.rst

[PATCH] D155794: [OpenMP][OpenMPIRBuilder] Migrate setPropertyExecutionMode() from Clang to OpenMPIRBuilder.

2023-07-24 Thread Raghu via Phabricator via cfe-commits
raghavendhra updated this revision to Diff 543696.
raghavendhra added a comment.

Addressed review comments by making setPropertyExecutionMode() to return a 
Global Value instead of void. Rebased patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155794

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CodeGenModule.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4900,6 +4900,19 @@
   emitBlock(ContBlock, CurFn, /*IsFinished=*/true);
 }
 
+GlobalVariable *OpenMPIRBuilder::setPropertyExecutionMode(StringRef Name,
+  bool IsSPMDMode) {
+  auto *GVMode = new llvm::GlobalVariable(
+  M, llvm::Type::getInt8Ty(M.getContext()), /*isConstant=*/true,
+  llvm::GlobalValue::WeakAnyLinkage,
+  llvm::ConstantInt::get(llvm::Type::getInt8Ty(M.getContext()),
+ IsSPMDMode ? OMP_TGT_EXEC_MODE_SPMD
+: OMP_TGT_EXEC_MODE_GENERIC),
+  Twine(Name, "_exec_mode"));
+  GVMode->setVisibility(llvm::GlobalVariable::ProtectedVisibility);
+  return GVMode;
+}
+
 bool OpenMPIRBuilder::checkAndEmitFlushAfterAtomic(
 const LocationDescription , llvm::AtomicOrdering AO, AtomicKind AK) {
   assert(!(AO == AtomicOrdering::NotAtomic ||
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1493,6 +1493,17 @@
   void emitIfClause(Value *Cond, BodyGenCallbackTy ThenGen,
 BodyGenCallbackTy ElseGen, InsertPointTy AllocaIP = {});
 
+  /// Create a unique global variable to indicate the execution mode of this
+  /// target region. The execution mode is either 'generic', or 'spmd' depending
+  /// on the target directive. This variable is picked up by the offload library
+  /// to setup the device appropriately before kernel launch. If the execution
+  /// mode is 'generic', the runtime reserves one warp for the master,
+  /// otherwise, all warps participate in parallel work.
+  /// \param Name The symbol name associated with the global.
+  /// \param IsSPMDMode is boolean to indicate if the kernel is an SPMD kernel
+  /// or not.
+  GlobalVariable *setPropertyExecutionMode(StringRef Name, bool IsSPMDMode);
+
   /// Create the global variable holding the offload mappings information.
   GlobalVariable *createOffloadMaptypes(SmallVectorImpl ,
 std::string VarName);
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1012,6 +1012,10 @@
 return EmittedGlobalBlocks.lookup(BE);
   }
 
+  std::vector () {
+return LLVMCompilerUsed;
+  }
+
   /// Notes that BE's global block is available via Addr. Asserts that BE
   /// isn't already emitted.
   void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr);
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -833,24 +833,6 @@
   IsInTTDRegion = false;
 }
 
-// Create a unique global variable to indicate the execution mode of this target
-// region. The execution mode is either 'generic', or 'spmd' depending on the
-// target directive. This variable is picked up by the offload library to setup
-// the device appropriately before kernel launch. If the execution mode is
-// 'generic', the runtime reserves one warp for the master, otherwise, all
-// warps participate in parallel work.
-static void setPropertyExecutionMode(CodeGenModule , StringRef Name,
- bool Mode) {
-  auto *GVMode = new llvm::GlobalVariable(
-  CGM.getModule(), CGM.Int8Ty, /*isConstant=*/true,
-  llvm::GlobalValue::WeakAnyLinkage,
-  llvm::ConstantInt::get(CGM.Int8Ty, Mode ? OMP_TGT_EXEC_MODE_SPMD
-  : OMP_TGT_EXEC_MODE_GENERIC),
-  Twine(Name, "_exec_mode"));
-  GVMode->setVisibility(llvm::GlobalVariable::ProtectedVisibility);
-  CGM.addCompilerUsedGlobal(GVMode);
-}
-
 void CGOpenMPRuntimeGPU::emitTargetOutlinedFunction(
 const OMPExecutableDirective , StringRef ParentName,
 llvm::Function *, llvm::Constant *,
@@ -868,7 +850,10 @@
 emitNonSPMDKernel(D, ParentName, OutlinedFn, OutlinedFnID, IsOffloadEntry,
   CodeGen);
 
-  setPropertyExecutionMode(CGM, 

[PATCH] D153310: clang: Add elementwise pow builtin

2023-07-24 Thread Joshua Batista via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a98e73169e1:  clang: Add elementwise pow builtin (authored 
by bob80905).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153310

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/CodeGen/strictfp-elementwise-bulitins.cpp
  clang/test/Sema/aarch64-sve-vector-pow-ops.c
  clang/test/Sema/builtins-elementwise-math.c
  clang/test/Sema/riscv-sve-vector-pow-ops.c
  clang/test/SemaCXX/builtins-elementwise-math.cpp

Index: clang/test/SemaCXX/builtins-elementwise-math.cpp
===
--- clang/test/SemaCXX/builtins-elementwise-math.cpp
+++ clang/test/SemaCXX/builtins-elementwise-math.cpp
@@ -198,3 +198,11 @@
   static_assert(!is_const::value);
   static_assert(!is_const::value);
 }
+
+void test_builtin_elementwise_pow() {
+  const double a = 2;
+  double b = 1;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
Index: clang/test/Sema/riscv-sve-vector-pow-ops.c
===
--- /dev/null
+++ clang/test/Sema/riscv-sve-vector-pow-ops.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: riscv-registered-target
+
+#include 
+
+
+vfloat32mf2_t test_pow_vv_i8mf8(vfloat32mf2_t v) {
+
+  return __builtin_elementwise_pow(v, v);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type}}
+}
Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -438,6 +438,31 @@
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
 
+void test_builtin_elementwise_pow(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) {
+  i = __builtin_elementwise_pow(p, d);
+  // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}
+
+  struct Foo foo = __builtin_elementwise_pow(i, i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_pow(i);
+  // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
+
+  i = __builtin_elementwise_pow();
+  // expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
+
+  i = __builtin_elementwise_pow(i, i, i);
+  // expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
+
+  i = __builtin_elementwise_pow(v, iv);
+  // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
+
+  i = __builtin_elementwise_pow(uv, iv);
+  // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
+  
+}
+
+
 void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_roundeven(f);
Index: clang/test/Sema/aarch64-sve-vector-pow-ops.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-vector-pow-ops.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v -target-feature +zfh  -target-feature +sve -target-feature +experimental-zvfh \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: aarch64-registered-target
+
+#include 
+
+svfloat32_t test_pow_vv_i8mf8(svfloat32_t v) {
+
+  return __builtin_elementwise_pow(v, v);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type}}
+}
Index: clang/test/CodeGen/strictfp-elementwise-bulitins.cpp
===
--- clang/test/CodeGen/strictfp-elementwise-bulitins.cpp
+++ clang/test/CodeGen/strictfp-elementwise-bulitins.cpp
@@ -217,3 +217,12 @@
   return __builtin_elementwise_fma(a, b, c);
 }
 
+// CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_powDv4_fS_
+// CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR2]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.pow.v4f32(<4 x float> [[A]], <4 x float> [[B]]) #[[ATTR4]]
+// CHECK-NEXT:ret 

[clang] 3a98e73 - clang: Add elementwise pow builtin

2023-07-24 Thread Joshua Batista via cfe-commits

Author: Joshua Batista
Date: 2023-07-24T14:03:58-07:00
New Revision: 3a98e73169e1d8e4fbb739462eea62445db1a6c8

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

LOG:  clang: Add elementwise pow builtin

Add codegen for llvm pow elementwise builtin
The pow elementwise builtin is necessary for HLSL codegen.
Tests were added to make sure that the expected errors are encountered when 
these functions are given inputs of incompatible types, or too many inputs.
The new builtin is restricted to floating point types only.

Reviewed By: arsenm

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

Added: 
clang/test/Sema/aarch64-sve-vector-pow-ops.c
clang/test/Sema/riscv-sve-vector-pow-ops.c

Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-elementwise-math.c
clang/test/CodeGen/strictfp-elementwise-bulitins.cpp
clang/test/Sema/builtins-elementwise-math.c
clang/test/SemaCXX/builtins-elementwise-math.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 6705ee176196cc..1830480b1285d7 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -639,6 +639,7 @@ Unless specified otherwise operation(±0) = ±0 and 
operation(±infinity) = ±in
  T __builtin_elementwise_log(T x)return the natural logarithm of x 
   floating point types
  T __builtin_elementwise_log2(T x)   return the base 2 logarithm of x  
   floating point types
  T __builtin_elementwise_log10(T x)  return the base 10 logarithm of x 
   floating point types
+ T __builtin_elementwise_pow(T x, T y)   return x raised to the power of y 
   floating point types
  T __builtin_elementwise_exp(T x)returns the base-e exponential, 
e^x, of the specified value  floating point types
  T __builtin_elementwise_exp2(T x)   returns the base-2 exponential, 
2^x, of the specified value  floating point types
  T __builtin_elementwise_roundeven(T x)  round x to the nearest integer 
value in floating point format,   floating point types

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d6cf96bee488d1..4f82edd0d03d14 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -961,6 +961,7 @@ Floating Point Support in Clang
 - 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.
+- Add ``__builtin_elementwise_pow`` builtin for floating point types only.
 
 AST Matchers
 

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index fe00a2f69922a1..6dad8b512bd2df 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -687,6 +687,7 @@ BUILTIN(__builtin_elementwise_floor, "v.", "nct")
 BUILTIN(__builtin_elementwise_log, "v.", "nct")
 BUILTIN(__builtin_elementwise_log2, "v.", "nct")
 BUILTIN(__builtin_elementwise_log10, "v.", "nct")
+BUILTIN(__builtin_elementwise_pow, "v.", "nct")
 BUILTIN(__builtin_elementwise_roundeven, "v.", "nct")
 BUILTIN(__builtin_elementwise_round, "v.", "nct")
 BUILTIN(__builtin_elementwise_rint, "v.", "nct")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index d5ad35c0c93602..30f5f4e7061c05 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3234,6 +3234,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_elementwise_log10:
 return RValue::get(
 emitUnaryBuiltin(*this, E, llvm::Intrinsic::log10, "elt.log10"));
+  case Builtin::BI__builtin_elementwise_pow: {
+return RValue::get(emitBinaryBuiltin(*this, E, llvm::Intrinsic::pow));
+  }
   case Builtin::BI__builtin_elementwise_cos:
 return RValue::get(
 emitUnaryBuiltin(*this, E, llvm::Intrinsic::cos, "elt.cos"));

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 17d9889da85e2d..f8e48728da6647 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2657,6 +2657,22 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   return ExprError();
 break;
   }
+
+  // These builtins restrict the element type to floating point
+  // types only, and take in two arguments.

[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-07-24 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

> Marking comments as resolved per my reply. I'm not sure if that's best 
> practice!

Yes, that is fine.




Comment at: clang/test/Lexer/case-insensitive-include-win.c:5-9
+// Note: We must use the real path here, because the logic to detect case
+// mismatch relies on resolving the real path and checking that casing differs.
+// If we use %t and we are on a substitute drive S: mapping to C:\subst,
+// then we will compare "S:\test.dir\FOO.h" to "C:\subst\test.dir\foo.h"
+// and avoid emitting the diagnostic because the structure is different.

MrTrillian wrote:
> tahonermann wrote:
> > Hmm, is it really desirable or necessary that the case mismatch logic 
> > resolve substituted drives? I wouldn't think so. This seems like another 
> > case where our common canonicalization would be desired.
> I think it is necessary as I don't see how else we can retrieve the original 
> casing of the file path. Merely making the path absolute would not do that. 
> Searching for solutions on the internet finds ideas that are worse like 
> converting to a short path then back to a long path or rebuilding the path 
> one component at a time with a series directory listing requests.
The warning this test checks for is diagnosed in 
`Preprocessor::HandleHeaderIncludeOrImport()`; search for `pp_nonportable_path` 
and/or `pp_nonportable_system_path`. I believe this warning will be issued if 
any component of the path does not match the case of the include directive. 
Since the file name differs in case, unless there is a bug in handling of the 
file name, this test isn't sensitive to case mismatches in `%t`.

From a user point of view, resolving a substitute drive doesn't seem 
desirableto me with respect to determining whether a non-portable path is being 
used; I don't think the behavior should be dependent on whether a substitute 
drive is being used or what its target is.


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

https://reviews.llvm.org/D154130

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


[PATCH] D156143: Add Adrian and David as owners for debug info

2023-07-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Sounds good, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156143

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


[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivate[ForVarInit] try ConstExprEmitter fast-path first

2023-07-24 Thread Nick Desaulniers 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 rGb54294e2c959: [clang][ConstantEmitter] have 
tryEmitPrivate[ForVarInit] try ConstExprEmitter… (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGenCXX/const-init-cxx11.cpp
  clang/test/CodeGenCXX/const-init-cxx1y.cpp
  clang/test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
+++ clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -57,7 +57,7 @@
 // CHECK: @fold_generic ={{.*}} local_unnamed_addr addrspace(1) global ptr null, align 8
 generic int *fold_generic = (global int*)(generic float*)(private char*)0;
 
-// CHECK: @fold_priv ={{.*}} local_unnamed_addr addrspace(1) global ptr addrspace(5) addrspacecast (ptr null to ptr addrspace(5)), align 4
+// CHECK: @fold_priv ={{.*}} local_unnamed_addr addrspace(1) global ptr addrspace(5) addrspacecast (ptr addrspace(1) null to ptr addrspace(5)), align 4
 private short *fold_priv = (private short*)(generic int*)(global void*)0;
 
 // CHECK: @fold_priv_arith ={{.*}} local_unnamed_addr addrspace(1) global ptr addrspace(5) inttoptr (i32 9 to ptr addrspace(5)), align 4
Index: clang/test/CodeGenCXX/const-init-cxx1y.cpp
===
--- clang/test/CodeGenCXX/const-init-cxx1y.cpp
+++ clang/test/CodeGenCXX/const-init-cxx1y.cpp
@@ -34,8 +34,8 @@
   // 'c.temporary', not the value as modified by the partial evaluation within
   // the initialization of 'c.x'.
   A c = { 10, (++c.temporary, b.x) };
-  // CHECK: @_ZGRN21ModifyStaticTemporary1cE_ = internal global i32 10
   // CHECK: @_ZN21ModifyStaticTemporary1cE ={{.*}} global {{.*}} zeroinitializer
+  // CHECK: @_ZGRN21ModifyStaticTemporary1cE_ = internal global i32 10
 }
 
 // CHECK: @_ZGRN28VariableTemplateWithConstRef1iIvEE_ = linkonce_odr constant i32 5, align 4
@@ -76,6 +76,19 @@
   S *p = <1, 2, 3, 4>;
 }
 
+
+// CHECK: @_ZGR1z_ ={{.*}} global [2 x i32] [i32 10, i32 2]
+// CHECK: @z = global { ptr, i32 } { ptr @_ZGR1z_, i32 10 }
+typedef int v[2];
+struct Z { int &, y; };
+Z z = { v{1,2}[0], z.x = 10 };
+
+// CHECK: @_ZGR2z2_ ={{.*}} global %struct.R { i64 10 }
+// @z = {{.}} global %struct.Z { ptr @_ZGR1z_, %struct.R { i64 10 } }
+struct R { mutable long x; };
+struct Z2 { const R , y; };
+Z2 z2 = { R{1}, z2.x.x = 10 };
+
 // CHECK: __cxa_atexit({{.*}} @_ZN1BD1Ev, {{.*}} @b
 
 // CHECK: define
Index: clang/test/CodeGenCXX/const-init-cxx11.cpp
===
--- clang/test/CodeGenCXX/const-init-cxx11.cpp
+++ clang/test/CodeGenCXX/const-init-cxx11.cpp
@@ -88,7 +88,7 @@
 
   struct E {};
   struct Test2 : X, X, X, X {};
-  // CHECK: @_ZN9BaseClass2t2E ={{.*}} constant {{.*}} undef
+  // CHECK: @_ZN9BaseClass2t2E ={{.*}} constant {{.*}} zeroinitializer, align 1
   extern constexpr Test2 t2 = Test2();
 
   struct __attribute((packed)) PackedD { double y = 2; };
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1215,11 +1215,6 @@
 return Visit(E->getSubExpr(), T);
   }
 
-  llvm::Constant *VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E,
-QualType T) {
-return Visit(E->getSubExpr(), T);
-  }
-
   llvm::Constant *EmitArrayInitialization(InitListExpr *ILE, QualType T) {
 auto *CAT = CGM.getContext().getAsConstantArrayType(ILE->getType());
 assert(CAT && "can't emit array init for non-constant-bound array");
@@ -1322,7 +1317,12 @@
   assert(CGM.getContext().hasSameUnqualifiedType(Ty, Arg->getType()) &&
  "argument to copy ctor is of wrong type");
 
-  return Visit(Arg, Ty);
+  // Look through the temporary; it's just converting the value to an
+  // lvalue to pass it to the constructor.
+  if (auto *MTE = dyn_cast(Arg))
+return Visit(MTE->getSubExpr(), Ty);
+  // Don't try to support arbitrary lvalue-to-rvalue conversions for now.
+  return nullptr;
 }
 
 return CGM.EmitNullConstant(Ty);
@@ -1654,29 +1654,22 @@
   InConstantContext = D.hasConstantInitialization();
 
   QualType destType = D.getType();
+  const Expr *E = D.getInit();
+  assert(E && "No initializer to emit");
+
+  if (!destType->isReferenceType()) {
+QualType nonMemoryDestType = getNonMemoryType(CGM, destType);
+if (llvm::Constant *C = ConstExprEmitter(*this).Visit(const_cast(E),
+  

[clang] b54294e - [clang][ConstantEmitter] have tryEmitPrivate[ForVarInit] try ConstExprEmitter fast-path first

2023-07-24 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2023-07-24T13:50:45-07:00
New Revision: b54294e2c9596088aaf557b221bcf471745864bc

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

LOG: [clang][ConstantEmitter] have tryEmitPrivate[ForVarInit] try 
ConstExprEmitter fast-path first

As suggested by @efriedma in:
https://reviews.llvm.org/D76096#4370369

This should speed up evaluating whether an expression is constant or
not, but due to the complexity of these two different implementations,
we may start getting different answers for edge cases for which we do
not yet have test cases in-tree (or perhaps even performance regressions
for some cases). As such, contributors have carte blanche to revert if
necessary.

For additional historical context about ExprConstant vs CGExprConstant,
here's snippets from a private conversation on discord:

  ndesaulniers:
  why do we have clang/lib/AST/ExprConstant.cpp and
  clang/lib/CodeGen/CGExprConstant.cpp? Does clang constant fold during
  ast walking/creation AND during LLVM codegen?
  efriedma:
  originally, clang needed to handle two things: integer constant
  expressions (the "5" in "int x[5];"), and constant global initializers
  (the "5" in "int x = 5;").  pre-C++11, the two could be handled mostly
  separately; so we had the code for integer constants in AST/, and the
  code for globals in CodeGen/.  C++11 constexpr sort of destroyed that
  separation, though. so now we do both kinds of constant evaluation on
  the AST, then CGExprConstant translates the result of that evaluation
  to LLVM IR.  but we kept around some bits of the old cgexprconstant to
  avoid performance/memory usage regressions on large arrays.

Reviewed By: efriedma

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

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/test/CodeGenCXX/const-init-cxx11.cpp
clang/test/CodeGenCXX/const-init-cxx1y.cpp
clang/test/CodeGenOpenCL/amdgpu-nullptr.cl

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 23aa14784cdaab..6164a419d213fd 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -3312,6 +3312,10 @@ bool Expr::isConstantInitializer(ASTContext , bool 
IsForRef,
   // kill the second parameter.
 
   if (IsForRef) {
+if (auto *EWC = dyn_cast(this))
+  return EWC->getSubExpr()->isConstantInitializer(Ctx, true, Culprit);
+if (auto *MTE = dyn_cast(this))
+  return MTE->getSubExpr()->isConstantInitializer(Ctx, false, Culprit);
 EvalResult Result;
 if (EvaluateAsLValue(Result, Ctx) && !Result.HasSideEffects)
   return true;

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index b5308ed94e5a04..f1c842e261993d 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -8391,8 +8391,8 @@ bool LValueExprEvaluator::VisitMaterializeTemporaryExpr(
   E->getSubExpr()->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments);
 
   // If we passed any comma operators, evaluate their LHSs.
-  for (unsigned I = 0, N = CommaLHSs.size(); I != N; ++I)
-if (!EvaluateIgnoredValue(Info, CommaLHSs[I]))
+  for (const Expr *E : CommaLHSs)
+if (!EvaluateIgnoredValue(Info, E))
   return false;
 
   // A materialized temporary with static storage duration can appear within 
the
@@ -8400,6 +8400,8 @@ bool LValueExprEvaluator::VisitMaterializeTemporaryExpr(
   // value for use outside this evaluation.
   APValue *Value;
   if (E->getStorageDuration() == SD_Static) {
+if (Info.EvalMode == EvalInfo::EM_ConstantFold)
+  return false;
 // FIXME: What about SD_Thread?
 Value = E->getOrCreateValue(true);
 *Value = APValue();
@@ -15475,7 +15477,7 @@ bool Expr::EvaluateAsInitializer(APValue , const 
ASTContext ,
   EStatus.Diag = 
 
   EvalInfo Info(Ctx, EStatus,
-(IsConstantInitialization && Ctx.getLangOpts().CPlusPlus11)
+(IsConstantInitialization && Ctx.getLangOpts().CPlusPlus)
 ? EvalInfo::EM_ConstantExpression
 : EvalInfo::EM_ConstantFold);
   Info.setEvaluatingDecl(VD, Value);

diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index 99b2ad855d406c..353ee56839f37e 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1215,11 +1215,6 @@ class ConstExprEmitter :
 return Visit(E->getSubExpr(), T);
   }
 
-  llvm::Constant *VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E,
-QualType T) {
-return Visit(E->getSubExpr(), T);
-  }
-
   llvm::Constant *EmitArrayInitialization(InitListExpr *ILE, QualType T) {
 auto 

[PATCH] D155991: [DWARF] Make sure file entry for artificial functions has an MD5 checksum

2023-07-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Any memory usage measurements to check this doesn't have a significant adverse 
impact by copying all the strings? (or performance by having to do string 
rather than pointer equality comparisons?)

Could/should we do the lookup on the CU filename before it goes into the DI 
metadata, and store that FileID somewhere for later use? Rather than requerying 
it later/making all queries string comparisons/storing strings, etc? (we could 
put an "expensive checks" assertion in that our queries always return in 
agreement with the pointer equality - so in case there are other things that 
trip over this issue we'll know about them sooner)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155991

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


[PATCH] D156128: [Clang][AArch64] Fix up immediate range of f64f64 mopa/mops intrinsics

2023-07-24 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc added inline comments.



Comment at: clang/include/clang/Basic/arm_sme.td:254
   [IsStreaming, IsSharedZA],
-  [ImmCheck<0, ImmCheck0_3>]>;
+  [ImmCheck<0, ImmCheck0_0>]>;
   }

Shouldn't this say `ImmCheck0_7` instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156128

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-07-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D153536#4521156 , 
@hubert.reinterpretcast wrote:

> In D153536#4512897 , @dblaikie 
> wrote:
>
>> but at least at a first blush I can't reproduce the failures shown...
>
> @dblaikie, you //did// reproduce the issue with the members. Both entries 
> have DW_AT_decl_line 2 and DW_AT_data_member_location 0 (the second entry 
> should indicate DW_AT_decl_line 3 and DW_AT_data_member_location 4):
>
>>   0x002e:   DW_TAG_structure_type
>>   DW_AT_calling_convention(DW_CC_pass_by_value)
>>   DW_AT_name  ("t1")
>>   DW_AT_byte_size (0x08)
>>   DW_AT_decl_file 
>> ("/usr/local/google/home/blaikie/dev/scratch/unused_member.cpp")
>>   DW_AT_decl_line (1)
>>   
>>   0x0034: DW_TAG_member
>> DW_AT_name("_")
>> DW_AT_type(0x0047 "int")
>> DW_AT_decl_file   
>> ("/usr/local/google/home/blaikie/dev/scratch/unused_member.cpp")
>> DW_AT_decl_line   (2)
>> DW_AT_data_member_location(0x00)
>>   
>>   0x003d: DW_TAG_member
>> DW_AT_name("_")
>> DW_AT_type(0x0047 "int")
>> DW_AT_decl_file   
>> ("/usr/local/google/home/blaikie/dev/scratch/unused_member.cpp")
>> DW_AT_decl_line   (2)
>> DW_AT_data_member_location(0x00)
>>   
>>   0x0046: NULL
>
> As for the block-scope case, I am still able to reproduce the issue (and also 
> your result that does not exhibit the issue). The key seems to be having the 
> `_`s on the same line.

Ah, fair enough - probably easy enough for you to look for some kind of map 
with inadequate key material in CGDebugInfo somewhere, I'd guess...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-07-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

> I think getting new system headers is harder for projects to deal with, so I 
> think I'm now in agreement with you that we should enable the warning as an 
> error in system headers.

Awesome - glad we're on the same page :)


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

https://reviews.llvm.org/D150226

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


  1   2   3   4   >