[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-06-29 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 536118.
FreddyYe added a comment.

changes according to the new RULE3, pls review again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c
  clang/test/CodeGen/attr-cpuspecific-cpus.c
  clang/test/CodeGen/attr-cpuspecific.c
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  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
@@ -6,16 +6,24 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i586 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i686 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentiumpro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_pro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_ii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii_no_xmm_regs 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=yonah 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=prescott 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4_sse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=lakemont 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=raptorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=meteorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -26,26 +34,39 @@
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core_2_duo_ssse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=penryn 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core_2_duo_sse4_1 2>&1 | FileCheck 

[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-06-29 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 536116.
FreddyYe added a comment.

Rebase for D154181 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c
  clang/test/CodeGen/attr-cpuspecific-cpus.c
  clang/test/CodeGen/attr-cpuspecific.c
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  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
@@ -6,16 +6,24 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i586 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i686 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentiumpro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_pro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_ii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii_no_xmm_regs 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=yonah 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=prescott 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4_sse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=lakemont 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=raptorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=meteorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -26,26 +34,39 @@
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core_2_duo_ssse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=penryn 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core_2_duo_sse4_1 2>&1 | FileCheck 

[PATCH] D154181: [x86] Add missing FeatureCMOV in frontend targets.

2023-06-29 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added a comment.

Thanks review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154181

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


[PATCH] D154181: [x86] Add missing FeatureCMOV in frontend targets.

2023-06-29 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 rGa9256a2e0450: [x86] Add missing FeatureCMOV in frontend 
targets. (authored by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154181

Files:
  clang/test/CodeGen/attr-target-clones.c
  clang/test/CodeGen/attr-target-x86.c
  clang/test/CodeGen/attr-target-x87-softfp.c
  clang/test/CodeGen/tune-cpu.c
  llvm/lib/TargetParser/X86TargetParser.cpp


Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -126,7 +126,7 @@
 
 // Pentium 2 and 3.
 constexpr FeatureBitset FeaturesPentium2 =
-FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | FeatureFXSR;
+FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | FeatureFXSR | FeatureCMOV;
 constexpr FeatureBitset FeaturesPentium3 = FeaturesPentium2 | FeatureSSE;
 
 // Pentium 4 CPUs
@@ -321,8 +321,8 @@
   { {"pentium"}, CK_Pentium, ~0U, FeatureX87 | FeatureCMPXCHG8B },
   { {"pentium-mmx"}, CK_PentiumMMX, ~0U, FeaturesPentiumMMX },
   // i686-generation processors, P6 / Pentium M microarchitecture based.
-  { {"pentiumpro"}, CK_PentiumPro, ~0U, FeatureX87 | FeatureCMPXCHG8B },
-  { {"i686"}, CK_i686, ~0U, FeatureX87 | FeatureCMPXCHG8B },
+  { {"pentiumpro"}, CK_PentiumPro, ~0U, FeatureCMOV | FeatureX87 | 
FeatureCMPXCHG8B },
+  { {"i686"}, CK_i686, ~0U, FeatureCMOV | FeatureX87 | FeatureCMPXCHG8B },
   { {"pentium2"}, CK_Pentium2, ~0U, FeaturesPentium2 },
   { {"pentium3"}, CK_Pentium3, ~0U, FeaturesPentium3 },
   { {"pentium3m"}, CK_Pentium3, ~0U, FeaturesPentium3 },
Index: clang/test/CodeGen/tune-cpu.c
===
--- clang/test/CodeGen/tune-cpu.c
+++ clang/test/CodeGen/tune-cpu.c
@@ -3,4 +3,4 @@
 int baz(int a) { return 4; }
 
 // CHECK: baz{{.*}} #0
-// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87" 
"tune-cpu"="nehalem"
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87" 
"tune-cpu"="nehalem"
Index: clang/test/CodeGen/attr-target-x87-softfp.c
===
--- clang/test/CodeGen/attr-target-x87-softfp.c
+++ clang/test/CodeGen/attr-target-x87-softfp.c
@@ -7,10 +7,10 @@
 // CHECK: foo{{.*}} #0
 // CHECK: bar{{.*}} #1
 
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
+// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
 // HARD-NOT: "use-soft-float"
 // SOFT: "use-soft-float"="true"
 
-// CHECK: #1 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,-x87"
+// CHECK: #1 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,-x87"
 // HARD-NOT: "use-soft-float"
 // SOFT: "use-soft-float"="true"
Index: clang/test/CodeGen/attr-target-x86.c
===
--- clang/test/CodeGen/attr-target-x86.c
+++ clang/test/CodeGen/attr-target-x86.c
@@ -51,22 +51,22 @@
 // CHECK: lake{{.*}} #7
 // CHECK: use_before_def{{.*}} #7
 // CHECK: walrus{{.*}} #8
-// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87" 
"tune-cpu"="i686"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87" 
"tune-cpu"="i686"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
 // CHECK-NOT: tune-cpu
-// CHECK: #2 = {{.*}}"target-cpu"="i686" 
"target-features"="+cx8,+x87,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512fp16,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint8,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop"
 "tune-cpu"="i686"
-// CHECK: #3 = {{.*}}"target-cpu"="i686" 
"target-features"="+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
 "tune-cpu"="i686"
-// CHECK: #4 = {{.*}}"target-cpu"="i686" 

[clang] a9256a2 - [x86] Add missing FeatureCMOV in frontend targets.

2023-06-29 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2023-06-30T13:19:15+08:00
New Revision: a9256a2e0450019aeb2dfcc3ad9fefb23d6d6f83

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

LOG: [x86] Add missing FeatureCMOV in frontend targets.

The missing info is gathered from X86.td.

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/test/CodeGen/attr-target-clones.c
clang/test/CodeGen/attr-target-x86.c
clang/test/CodeGen/attr-target-x87-softfp.c
clang/test/CodeGen/tune-cpu.c
llvm/lib/TargetParser/X86TargetParser.cpp

Removed: 




diff  --git a/clang/test/CodeGen/attr-target-clones.c 
b/clang/test/CodeGen/attr-target-clones.c
index 857c3991d273f6..3f0cf97fe75b0b 100644
--- a/clang/test/CodeGen/attr-target-clones.c
+++ b/clang/test/CodeGen/attr-target-clones.c
@@ -170,4 +170,4 @@ int test_foo_used_no_defn(void) {
 // CHECK: attributes #[[DEF]] =
 // Don't bother checking features, we verified it is the same as a normal 
function.
 // CHECK: attributes #[[SB]] =
-// CHECK-SAME: 
"target-features"="+avx,+crc32,+cx16,+cx8,+fxsr,+mmx,+pclmul,+popcnt,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+// CHECK-SAME: 
"target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+fxsr,+mmx,+pclmul,+popcnt,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"

diff  --git a/clang/test/CodeGen/attr-target-x86.c 
b/clang/test/CodeGen/attr-target-x86.c
index dbbbd11402349f..f22203f3ceadc5 100644
--- a/clang/test/CodeGen/attr-target-x86.c
+++ b/clang/test/CodeGen/attr-target-x86.c
@@ -51,22 +51,22 @@ void __attribute__((target("arch=x86-64-v4"))) 
x86_64_v4(void) {}
 // CHECK: lake{{.*}} #7
 // CHECK: use_before_def{{.*}} #7
 // CHECK: walrus{{.*}} #8
-// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87" 
"tune-cpu"="i686"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87" 
"tune-cpu"="i686"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
 // CHECK-NOT: tune-cpu
-// CHECK: #2 = {{.*}}"target-cpu"="i686" 
"target-features"="+cx8,+x87,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512fp16,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint8,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop"
 "tune-cpu"="i686"
-// CHECK: #3 = {{.*}}"target-cpu"="i686" 
"target-features"="+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
 "tune-cpu"="i686"
-// CHECK: #4 = {{.*}}"target-cpu"="i686" 
"target-features"="+cx8,+x87,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512fp16,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint8,-f16c,-fma,-fma4,-sse4.1,-sse4.2,-vaes,-vpclmulqdq,-xop"
 "tune-cpu"="i686"
-// CHECK: #5 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes,-vaes"
+// CHECK: #2 = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512fp16,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint8,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop"
 "tune-cpu"="i686"
+// CHECK: #3 = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
 "tune-cpu"="i686"
+// CHECK: #4 = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512fp16,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint8,-f16c,-fma,-fma4,-sse4.1,-sse4.2,-vaes,-vpclmulqdq,-xop"
 "tune-cpu"="i686"
+// CHECK: #5 = {{.*}}"target-cpu"="ivybridge" 

[PATCH] D154181: [x86] Add missing FeatureCMOV in frontend targets.

2023-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154181

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


[PATCH] D154181: [x86] Add missing FeatureCMOV in frontend targets.

2023-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/TargetParser/X86TargetParser.cpp:325
+  { {"pentiumpro"}, CK_PentiumPro, ~0U, FeatureCMOV | FeatureX87 | 
FeatureCMPXCHG8B },
+  { {"i686"}, CK_i686, ~0U, FeatureCMOV | FeatureX87 | FeatureCMPXCHG8B },
   { {"pentium2"}, CK_Pentium2, ~0U, FeaturesPentium2 },

craig.topper wrote:
> I don't think i686 is supposed to have CMOV. There are some "6th generation" 
> CPUs from Via maybe that don't have cmov.
Nevermind. I guess we have it enabled for i686. So if I am remembering the Via 
CPUs correctly, the damage is already done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154181

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


[PATCH] D154181: [x86] Add missing FeatureCMOV in frontend targets.

2023-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/TargetParser/X86TargetParser.cpp:325
+  { {"pentiumpro"}, CK_PentiumPro, ~0U, FeatureCMOV | FeatureX87 | 
FeatureCMPXCHG8B },
+  { {"i686"}, CK_i686, ~0U, FeatureCMOV | FeatureX87 | FeatureCMPXCHG8B },
   { {"pentium2"}, CK_Pentium2, ~0U, FeaturesPentium2 },

I don't think i686 is supposed to have CMOV. There are some "6th generation" 
CPUs from Via maybe that don't have cmov.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154181

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


[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-06-29 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added a comment.

> Yes, it looks like it would be best to split off and commit some of the fixes 
> (cmov / the isa changes causing the attr-cpuspecific.c diffs etc.) first, 
> before this refactor patch.

Done in https://reviews.llvm.org/D154181


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[PATCH] D154181: [x86] Add missing FeatureCMOV in frontend targets.

2023-06-29 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
FreddyYe requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

The missing info is gathered from X86.td.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154181

Files:
  clang/test/CodeGen/attr-target-clones.c
  clang/test/CodeGen/attr-target-x86.c
  clang/test/CodeGen/attr-target-x87-softfp.c
  clang/test/CodeGen/tune-cpu.c
  llvm/lib/TargetParser/X86TargetParser.cpp


Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -126,7 +126,7 @@
 
 // Pentium 2 and 3.
 constexpr FeatureBitset FeaturesPentium2 =
-FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | FeatureFXSR;
+FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | FeatureFXSR | FeatureCMOV;
 constexpr FeatureBitset FeaturesPentium3 = FeaturesPentium2 | FeatureSSE;
 
 // Pentium 4 CPUs
@@ -321,8 +321,8 @@
   { {"pentium"}, CK_Pentium, ~0U, FeatureX87 | FeatureCMPXCHG8B },
   { {"pentium-mmx"}, CK_PentiumMMX, ~0U, FeaturesPentiumMMX },
   // i686-generation processors, P6 / Pentium M microarchitecture based.
-  { {"pentiumpro"}, CK_PentiumPro, ~0U, FeatureX87 | FeatureCMPXCHG8B },
-  { {"i686"}, CK_i686, ~0U, FeatureX87 | FeatureCMPXCHG8B },
+  { {"pentiumpro"}, CK_PentiumPro, ~0U, FeatureCMOV | FeatureX87 | 
FeatureCMPXCHG8B },
+  { {"i686"}, CK_i686, ~0U, FeatureCMOV | FeatureX87 | FeatureCMPXCHG8B },
   { {"pentium2"}, CK_Pentium2, ~0U, FeaturesPentium2 },
   { {"pentium3"}, CK_Pentium3, ~0U, FeaturesPentium3 },
   { {"pentium3m"}, CK_Pentium3, ~0U, FeaturesPentium3 },
Index: clang/test/CodeGen/tune-cpu.c
===
--- clang/test/CodeGen/tune-cpu.c
+++ clang/test/CodeGen/tune-cpu.c
@@ -3,4 +3,4 @@
 int baz(int a) { return 4; }
 
 // CHECK: baz{{.*}} #0
-// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87" 
"tune-cpu"="nehalem"
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87" 
"tune-cpu"="nehalem"
Index: clang/test/CodeGen/attr-target-x87-softfp.c
===
--- clang/test/CodeGen/attr-target-x87-softfp.c
+++ clang/test/CodeGen/attr-target-x87-softfp.c
@@ -7,10 +7,10 @@
 // CHECK: foo{{.*}} #0
 // CHECK: bar{{.*}} #1
 
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
+// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
 // HARD-NOT: "use-soft-float"
 // SOFT: "use-soft-float"="true"
 
-// CHECK: #1 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,-x87"
+// CHECK: #1 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,-x87"
 // HARD-NOT: "use-soft-float"
 // SOFT: "use-soft-float"="true"
Index: clang/test/CodeGen/attr-target-x86.c
===
--- clang/test/CodeGen/attr-target-x86.c
+++ clang/test/CodeGen/attr-target-x86.c
@@ -51,22 +51,22 @@
 // CHECK: lake{{.*}} #7
 // CHECK: use_before_def{{.*}} #7
 // CHECK: walrus{{.*}} #8
-// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87" 
"tune-cpu"="i686"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87" 
"tune-cpu"="i686"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
 // CHECK-NOT: tune-cpu
-// CHECK: #2 = {{.*}}"target-cpu"="i686" 
"target-features"="+cx8,+x87,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512fp16,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint8,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop"
 "tune-cpu"="i686"
-// CHECK: #3 = {{.*}}"target-cpu"="i686" 
"target-features"="+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
 "tune-cpu"="i686"
-// CHECK: #4 = {{.*}}"target-cpu"="i686" 
"target-features"="+cx8,+x87,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512fp16,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint8,-f16c,-fma,-fma4,-sse4.1,-sse4.2,-vaes,-vpclmulqdq,-xop"
 

[PATCH] D154180: [OPENMP52] Codegen support for doacross clause.

2023-06-29 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 created this revision.
jyu2 added reviewers: ABataev, mikerice, jdoerfert.
jyu2 added a project: OpenMP.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a project: All.
jyu2 requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

This is following the ordered depend clause.
1> Using  OMPClause instead OMPDependClause in emitDoacrossOrdered to hand both

  OMPDependClause and OMPDoacrossClause.

2> Add new utility function emitRestoreIP which used for both clause.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154180

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/ordered_doacross_codegen.c

Index: clang/test/OpenMP/ordered_doacross_codegen.c
===
--- clang/test/OpenMP/ordered_doacross_codegen.c
+++ clang/test/OpenMP/ordered_doacross_codegen.c
@@ -2,13 +2,21 @@
 // RUN: %clang_cc1 -fopenmp -triple x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -triple x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NORMAL
 
+// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown -emit-llvm %s -o - -fopenmp-version=52 | FileCheck %s --check-prefixes=CHECK,CHECK-NORMAL
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -fopenmp-version=52 -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
 // RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
 
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
+
 // RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -triple x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 // expected-no-diagnostics
 
@@ -51,7 +59,11 @@
 // CHECK-NORMAL-NEXT: call void @__kmpc_doacross_post(ptr [[IDENT]], i32 [[GTID]], ptr [[TMP]])
 // CHECK-IRBUILDER-NEXT: [[GTID1:%.+]] = call i32 @__kmpc_global_thread_num(ptr [[IDENT:@.+]])
 // CHECK-IRBUILDER-NEXT: call void @__kmpc_doacross_post(ptr [[IDENT]], i32 [[GTID1]], ptr [[TMP]])
+#if _OPENMP >= 202111
+#pragma omp ordered doacross(source:)
+#else
 #pragma omp ordered depend(source)
+#endif
 c[i] = c[i] + 1;
 foo();
 // CHECK: call void @foo()
@@ -66,7 +78,11 @@
 // CHECK-NORMAL-NEXT: call void @__kmpc_doacross_wait(ptr [[IDENT]], i32 [[GTID]], ptr [[TMP]])
 // CHECK-IRBUILDER-NEXT: [[GTID2:%.+]] = call i32 @__kmpc_global_thread_num(ptr [[IDENT:@.+]])
 // CHECK-IRBUILDER-NEXT: call void @__kmpc_doacross_wait(ptr [[IDENT]], i32 [[GTID2]], ptr [[TMP]])
+#if _OPENMP >= 202111
+#pragma omp ordered doacross(sink : i - 2)
+#else
 #pragma omp ordered depend(sink : i - 2)
+#endif
 d[i] = a[i - 2];
   }
   // CHECK: call void @__kmpc_for_static_fini(
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -5839,6 +5839,33 @@
   return Fn;
 }
 
+static void emitRestoreIP(CodeGenFunction , const OMPClause *C,
+  llvm::OpenMPIRBuilder::InsertPointTy AllocaIP,
+  llvm::OpenMPIRBuilder ) {
+  auto DOC = dyn_cast(C);
+  auto DC = dyn_cast(C);
+
+  unsigned NumLoops = DC ? DC->getNumLoops() : DOC->getNumLoops();
+  QualType Int64Ty = CGF.CGM.getContext().getIntTypeForBitwidth(
+  /*DestWidth=*/64, /*Signed=*/1);
+  llvm::SmallVector StoreValues;
+  for (unsigned I = 0; I < NumLoops; I++) {

[PATCH] D154171: [RISCV] Mark zvkn* and zvks* extensions as enabled when all their subextensions are.

2023-06-29 Thread Craig Topper 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 rGb4609b4106f3: [RISCV] Mark zvkn* and zvks* extensions as 
enabled when all their subextensions… (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154171

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp


Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -1095,6 +1095,12 @@
 {{"zk"}, {ImpliedExtsZk}},
 {{"zkn"}, {ImpliedExtsZkn}},
 {{"zks"}, {ImpliedExtsZks}},
+{{"zvkn"}, {ImpliedExtsZvkn}},
+{{"zvknc"}, {ImpliedExtsZvknc}},
+{{"zvkng"}, {ImpliedExtsZvkng}},
+{{"zvks"}, {ImpliedExtsZvks}},
+{{"zvksc"}, {ImpliedExtsZvksc}},
+{{"zvksg"}, {ImpliedExtsZvksg}},
 };
 
 void RISCVISAInfo::updateCombination() {
Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -719,3 +719,55 @@
 // RUN: -march=rv64ifzvfbfwma0p6 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVFBFWMA-EXT %s
 // CHECK-ZVFBFWMA-EXT: __riscv_zvfbfwma 6000{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKN %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKN %s
+// CHECK-COMBINE-INTO-ZVKN: __riscv_zvkn 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvbc1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNC %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvbc1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNC %s
+// CHECK-COMBINE-INTO-ZVKNC: __riscv_zvkn 100{{$}}
+// CHECK-COMBINE-INTO-ZVKNC: __riscv_zvknc 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvkg1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNG %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvkg1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNG %s
+// CHECK-COMBINE-INTO-ZVKNG: __riscv_zvkn 100{{$}}
+// CHECK-COMBINE-INTO-ZVKNG: __riscv_zvkng 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKS %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKS %s
+// CHECK-COMBINE-INTO-ZVKS: __riscv_zvks 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvbc1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSC %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvbc1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSC %s
+// CHECK-COMBINE-INTO-ZVKSC: __riscv_zvks 100{{$}}
+// CHECK-COMBINE-INTO-ZVKSC: __riscv_zvksc 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvkg1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSG %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvkg1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSG %s
+// CHECK-COMBINE-INTO-ZVKSG: __riscv_zvks 100{{$}}
+// CHECK-COMBINE-INTO-ZVKSG: __riscv_zvksg 100{{$}}


Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -1095,6 +1095,12 @@
 {{"zk"}, {ImpliedExtsZk}},
 {{"zkn"}, {ImpliedExtsZkn}},
 {{"zks"}, {ImpliedExtsZks}},
+

[clang] b4609b4 - [RISCV] Mark zvkn* and zvks* extensions as enabled when all their subextensions are.

2023-06-29 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-06-29T20:58:55-07:00
New Revision: b4609b4106f3f12882434ac26d8c1c12f57d8dc7

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

LOG: [RISCV] Mark zvkn* and zvks* extensions as enabled when all their 
subextensions are.

These extensions don't contain any instructions on their own, they
are just aliases for a set of extensions. We should set the preprocessor
define anytime all the sub-extensions are supported.

Reviewed By: kito-cheng, eopXD

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

Added: 


Modified: 
clang/test/Preprocessor/riscv-target-features.c
llvm/lib/Support/RISCVISAInfo.cpp

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 70a1ff97bac886..9de44408b74f5c 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -719,3 +719,55 @@
 // RUN: -march=rv64ifzvfbfwma0p6 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVFBFWMA-EXT %s
 // CHECK-ZVFBFWMA-EXT: __riscv_zvfbfwma 6000{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKN %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKN %s
+// CHECK-COMBINE-INTO-ZVKN: __riscv_zvkn 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvbc1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNC %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvbc1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNC %s
+// CHECK-COMBINE-INTO-ZVKNC: __riscv_zvkn 100{{$}}
+// CHECK-COMBINE-INTO-ZVKNC: __riscv_zvknc 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvkg1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNG %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvkg1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNG %s
+// CHECK-COMBINE-INTO-ZVKNG: __riscv_zvkn 100{{$}}
+// CHECK-COMBINE-INTO-ZVKNG: __riscv_zvkng 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKS %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKS %s
+// CHECK-COMBINE-INTO-ZVKS: __riscv_zvks 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvbc1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSC %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvbc1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSC %s
+// CHECK-COMBINE-INTO-ZVKSC: __riscv_zvks 100{{$}}
+// CHECK-COMBINE-INTO-ZVKSC: __riscv_zvksc 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvkg1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSG %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvkg1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSG %s
+// CHECK-COMBINE-INTO-ZVKSG: __riscv_zvks 100{{$}}
+// CHECK-COMBINE-INTO-ZVKSG: __riscv_zvksg 100{{$}}

diff  --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index 3e218a59d17e2c..720ed06ecf7f65 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -1095,6 +1095,12 @@ static constexpr CombinedExtsEntry CombineIntoExts[] = {
 {{"zk"}, {ImpliedExtsZk}},
 {{"zkn"}, {ImpliedExtsZkn}},
 {{"zks"}, {ImpliedExtsZks}},
+{{"zvkn"}, {ImpliedExtsZvkn}},
+{{"zvknc"}, {ImpliedExtsZvknc}},
+

[PATCH] D153953: Revert "[AMDGPU] Mark mbcnt as convergent"

2023-06-29 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds added a comment.

In D153953#4458386 , @foad wrote:

> In D153953#4458134 , @sameerds 
> wrote:
>
>> @pravinjagtap @arsenm ... reverting the mbcnt intrinsic affects tests that 
>> were added for atomic optimizations. In particular, the mbcnt is now being 
>> moved across/into/out of control flow because it is no longer convergent. I 
>> eyeballed one example and it seemed okay to me, but a more thorough check 
>> will be useful.
>
> They are just being moved from before the loop to after the loop. This is 
> fine. It is even a bit weird that the atomic optimizer pass emits them before 
> the loop in the first place.

@foad just to respect the process, are you okay with approving the review 
again? I had set it back to "needs review".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153953

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


[PATCH] D140690: [dfsan] Support Linux loongarch64

2023-06-29 Thread Limin Zhang via Phabricator via cfe-commits
Ami-zhang updated this revision to Diff 536091.
Ami-zhang retitled this revision from "[compiler-rt][dfsan] Enable loongarch64 
and add test support" to "[dfsan] Support Linux loongarch64".
Ami-zhang edited the summary of this revision.
Ami-zhang added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140690

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/test/dfsan/lit.cfg.py
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp


Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -305,6 +305,14 @@
 };
 // NOLINTEND(readability-identifier-naming)
 
+// loongarch64 Linux
+const MemoryMapParams Linux_LoongArch64_MemoryMapParams = {
+0,  // AndMask (not used)
+0x5000, // XorMask
+0,  // ShadowBase (not used)
+0x1000, // OriginBase
+};
+
 namespace {
 
 class DFSanABIList {
@@ -1128,6 +1136,9 @@
   case Triple::x86_64:
 MapParams = _X86_64_MemoryMapParams;
 break;
+  case Triple::loongarch64:
+MapParams = _LoongArch64_MemoryMapParams;
+break;
   default:
 report_fatal_error("unsupported architecture");
   }
Index: compiler-rt/test/dfsan/lit.cfg.py
===
--- compiler-rt/test/dfsan/lit.cfg.py
+++ compiler-rt/test/dfsan/lit.cfg.py
@@ -25,5 +25,5 @@
 config.suffixes = [".c", ".cpp"]
 
 # DataFlowSanitizer tests are currently supported on Linux only.
-if not (config.host_os in ["Linux"] and config.target_arch in ["aarch64", 
"x86_64"]):
+if not (config.host_os in ["Linux"] and config.target_arch in ["aarch64", 
"x86_64", "loongarch64"]):
 config.unsupported = True
Index: compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
===
--- compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -30,7 +30,7 @@
 ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
 ${LOONGARCH64})
 set(ALL_ASAN_ABI_SUPPORTED_ARCH ${X86_64} ${ARM64})
-set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
+set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${LOONGARCH64})
 
 if(ANDROID)
   set(OS_NAME "Android")
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -795,7 +795,7 @@
   Res |= SanitizerKind::Memory;
   Res |= SanitizerKind::Vptr;
   Res |= SanitizerKind::SafeStack;
-  if (IsX86_64 || IsMIPS64 || IsAArch64)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsLoongArch64)
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64 ||
   IsRISCV64 || IsSystemZ || IsHexagon || IsLoongArch64)


Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -305,6 +305,14 @@
 };
 // NOLINTEND(readability-identifier-naming)
 
+// loongarch64 Linux
+const MemoryMapParams Linux_LoongArch64_MemoryMapParams = {
+0,  // AndMask (not used)
+0x5000, // XorMask
+0,  // ShadowBase (not used)
+0x1000, // OriginBase
+};
+
 namespace {
 
 class DFSanABIList {
@@ -1128,6 +1136,9 @@
   case Triple::x86_64:
 MapParams = _X86_64_MemoryMapParams;
 break;
+  case Triple::loongarch64:
+MapParams = _LoongArch64_MemoryMapParams;
+break;
   default:
 report_fatal_error("unsupported architecture");
   }
Index: compiler-rt/test/dfsan/lit.cfg.py
===
--- compiler-rt/test/dfsan/lit.cfg.py
+++ compiler-rt/test/dfsan/lit.cfg.py
@@ -25,5 +25,5 @@
 config.suffixes = [".c", ".cpp"]
 
 # DataFlowSanitizer tests are currently supported on Linux only.
-if not (config.host_os in ["Linux"] and config.target_arch in ["aarch64", "x86_64"]):
+if not (config.host_os in ["Linux"] and config.target_arch in ["aarch64", "x86_64", "loongarch64"]):
 config.unsupported = True
Index: compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
===
--- compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -30,7 +30,7 @@
 ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} 

[PATCH] D154070: [lld/COFF] Add /dwodir to enable DWARF fission with LTO

2023-06-29 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen added a comment.

In D154070#4461674 , @MaskRay wrote:

> I'll be away for a few days and back on July 5. Clicked "Accept" if you keep 
> just the lld/COFF part for this patch and create another patch for 
> clang/lib/Driver.
>
> I guess @mstorsjo may have some opinions.

Thank you.

Patch has been split to:
https://reviews.llvm.org/D154176


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154070

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


[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

2023-06-29 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen created this revision.
Herald added a project: All.
HaohaiWen requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Check linker earlier so that lld specific flags can be append before
inputs. Just like position of other flags.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154176

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


Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+Linker = "lld-link";
+
+  if (Linker == "lld-link")
+for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto  : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-Linker = "lld-link";
-
-  if (Linker == "lld-link")
-for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
-
   if (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install


Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+Linker = "lld-link";
+
+  if (Linker == "lld-link")
+for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto  : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-Linker = "lld-link";
-
-  if (Linker == "lld-link")
-for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
-
   if (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153674: [dataflow] Disallow implicit copy of Environment, use fork() instead

2023-06-29 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.

In D153674#4461195 , @sammccall wrote:

> Sorry about the delay, and thanks for the `.i`.
>
> It took me a while to work out what was going on, but it looks like it's just 
> a bug where GCC forgets to automatic-move.
> Fixed in 2f7d30dee8262746c3e8ee1f6f25be8c1ace9990 
> 

Thanks a lot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153674

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


[PATCH] D153114: [clangd] [C++20] [Modules] Support C++20 modules for clangd

2023-06-29 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@sammccall @nridge gentle ping~


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

https://reviews.llvm.org/D153114

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


[PATCH] D153003: [ODRHash] Fix ODR hashing of template names

2023-06-29 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

> Oh, I guess we're somehow adding a semi-resolved form of the base class type 
> of D into the ODR hash, which then includes details of the using-declaration. 
> That seems wrong -- we should either (preferably) be including only the 
> syntactic form of the base specifier (because local syntax is what the ODR 
> covers), or the canonical type (which should be the same for both 
> using-declarations).

Got it. I'll try to fix it. Thanks for the suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153003

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


[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

2023-06-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I would recommend to introduce `__AMDGCN_WAVEFRONT_SIZE__` as an alias for 
`'__AMDGCN_WAVEFRONT_SIZE` and at some point to deprecate the latter.
Otherwise, LGTM


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

https://reviews.llvm.org/D154133

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


[PATCH] D154070: [Driver][lld/COFF] Support DWARF fission when using LTO on Windows

2023-06-29 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 536084.
HaohaiWen added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Remove driver changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154070

Files:
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/COFF/LTO.cpp
  lld/COFF/Options.td
  lld/test/COFF/lto-debug-fission.ll


Index: lld/test/COFF/lto-debug-fission.ll
===
--- /dev/null
+++ lld/test/COFF/lto-debug-fission.ll
@@ -0,0 +1,18 @@
+; REQUIRES: x86
+
+; RUN: opt %s -o %t1.o
+; RUN: rm -rf %t.dir
+
+; Test to ensure that -dwodir:$DIR creates .dwo files under $DIR
+; RUN: lld-link -dwodir:%t.dir -noentry -dll %t1.o -out:%t.dll
+; RUN: llvm-readobj -h %t.dir/0.dwo | FileCheck %s
+
+; CHECK: Format: COFF-x86-64
+
+target datalayout = 
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-windows-msvc"
+
+define void @f() {
+entry:
+  ret void
+}
Index: lld/COFF/Options.td
===
--- lld/COFF/Options.td
+++ lld/COFF/Options.td
@@ -42,6 +42,8 @@
 def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
 def delayload : P<"delayload", "Delay loaded DLL name">;
 def diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
+def dwodir : P<"dwodir",
+"Directory to store .dwo files when LTO and debug fission are used">;
 def entry   : P<"entry", "Name of entry point symbol">;
 def errorlimit : P<"errorlimit",
 "Maximum number of errors to emit before stopping (0 = no limit)">;
Index: lld/COFF/LTO.cpp
===
--- lld/COFF/LTO.cpp
+++ lld/COFF/LTO.cpp
@@ -84,6 +84,7 @@
   c.DisableVerify = true;
 #endif
   c.DiagHandler = diagnosticHandler;
+  c.DwoDir = ctx.config.dwoDir.str();
   c.OptLevel = ctx.config.ltoo;
   c.CPU = getCPUStr();
   c.MAttrs = getMAttrs();
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1910,6 +1910,9 @@
 fatal("/manifestinput: requires /manifest:embed");
   }
 
+  // Handle /dwodir
+  config->dwoDir = args.getLastArgValue(OPT_dwodir);
+
   config->thinLTOEmitImportsFiles = 
args.hasArg(OPT_thinlto_emit_imports_files);
   config->thinLTOIndexOnly = args.hasArg(OPT_thinlto_index_only) ||
  args.hasArg(OPT_thinlto_index_only_arg);
Index: lld/COFF/Config.h
===
--- lld/COFF/Config.h
+++ lld/COFF/Config.h
@@ -203,6 +203,9 @@
   StringRef manifestUIAccess = "'false'";
   StringRef manifestFile;
 
+  // used for /dwodir
+  StringRef dwoDir;
+
   // Used for /aligncomm.
   std::map alignComm;
 


Index: lld/test/COFF/lto-debug-fission.ll
===
--- /dev/null
+++ lld/test/COFF/lto-debug-fission.ll
@@ -0,0 +1,18 @@
+; REQUIRES: x86
+
+; RUN: opt %s -o %t1.o
+; RUN: rm -rf %t.dir
+
+; Test to ensure that -dwodir:$DIR creates .dwo files under $DIR
+; RUN: lld-link -dwodir:%t.dir -noentry -dll %t1.o -out:%t.dll
+; RUN: llvm-readobj -h %t.dir/0.dwo | FileCheck %s
+
+; CHECK: Format: COFF-x86-64
+
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-windows-msvc"
+
+define void @f() {
+entry:
+  ret void
+}
Index: lld/COFF/Options.td
===
--- lld/COFF/Options.td
+++ lld/COFF/Options.td
@@ -42,6 +42,8 @@
 def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
 def delayload : P<"delayload", "Delay loaded DLL name">;
 def diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
+def dwodir : P<"dwodir",
+"Directory to store .dwo files when LTO and debug fission are used">;
 def entry   : P<"entry", "Name of entry point symbol">;
 def errorlimit : P<"errorlimit",
 "Maximum number of errors to emit before stopping (0 = no limit)">;
Index: lld/COFF/LTO.cpp
===
--- lld/COFF/LTO.cpp
+++ lld/COFF/LTO.cpp
@@ -84,6 +84,7 @@
   c.DisableVerify = true;
 #endif
   c.DiagHandler = diagnosticHandler;
+  c.DwoDir = ctx.config.dwoDir.str();
   c.OptLevel = ctx.config.ltoo;
   c.CPU = getCPUStr();
   c.MAttrs = getMAttrs();
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1910,6 +1910,9 @@
 fatal("/manifestinput: requires /manifest:embed");
   }
 
+  // Handle /dwodir
+  config->dwoDir = args.getLastArgValue(OPT_dwodir);
+
   config->thinLTOEmitImportsFiles = args.hasArg(OPT_thinlto_emit_imports_files);
   config->thinLTOIndexOnly = 

[PATCH] D154171: [RISCV] Mark zvkn* and zvks* extensions as enabled when all their subextensions are.

2023-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D154171#4462182 , @eopXD wrote:

> ~~Do we need to do the same for v extension?~~
>
> I didn't understand the problem fully, we don't need to care about v 
> extension here because 'v' itself adds something new to the architecture.

Correct. V has some SEW=64 multiply instructions that aren't in zve64*.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154171

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


[PATCH] D154171: [RISCV] Mark zvkn* and zvks* extensions as enabled when all their subextensions are.

2023-06-29 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154171

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


[PATCH] D152017: [DebugInfo] Add flag to only emit referenced member functions

2023-06-29 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

> we might emit member function declarations for call sites in DWARF, for 
> instance

So are you now leaning more toward wanting to emit the "used" declarations as 
well? I'm sure you don't want to implement it the way we did...

I *think* the template parameter thing has more to do with not supporting 
expressions in all their glory, although I'm fuzzy on that--last time I looked 
at that stuff was a number of years ago.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152017

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


[PATCH] D89918: Fix issue: clang-format result is not consistent if "// clang-format off" is followed by macro definition.

2023-06-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Regarding commandeering, I would wait for a couple of weeks after pinging the 
author.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89918

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


[PATCH] D153557: [clang][ExtractAPI] Add support for C++ classes

2023-06-29 Thread Erick Velez via Phabricator via cfe-commits
evelez7 added a comment.

There aren't any variables or fields in the tests currently, waiting on D154038 
 because of no semicolons in their fragments.




Comment at: clang/lib/ExtractAPI/API.cpp:19
 #include "clang/AST/RawCommentList.h"
+#include "clang/ExtractAPI/DeclarationFragments.h"
 #include "clang/Index/USRGeneration.h"

dang wrote:
> AccessControl should move into API.h so we don't need to pull in 
> DeclarationFragments.h
This include doesn't need to be here, clangd auto-included it. Using 
`FunctionSignature` would've explicitly included it in the first place. 
DeclarationFragments.h is already included in API.h.

I was following `FunctionSignature` as far as where to declare and define. 
Moving `AccessControl` would mean including API.h in DeclarationFragments.h to 
allow `DeclarationFragmentsBuilder::getAccessControl`.



Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:607
-  // correctly here.
-  Obj["accessLevel"] = "public";
   SmallVector PathComponentsNames;

dang wrote:
> We still need all symbols to have an "accessLevel" specifier. Maybe the 
> false_type overload of `serializeAccessMixin` could make "public" the default.
This is done on line 534. "public" is serialized if the returned optional is 
empty.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153557

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


[PATCH] D153557: [clang][ExtractAPI] Add support for C++ classes

2023-06-29 Thread Erick Velez via Phabricator via cfe-commits
evelez7 updated this revision to Diff 536071.
evelez7 added a comment.

Add C++ class tests, fix exception spec fragments

- Add tests for single and multiple inheritance, class methods, and functions 
with noexcept.
- Exception spec fragments had a space included in it, moved it to separate 
fragment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153557

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/class.cpp
  clang/test/ExtractAPI/function_noexcepts.cpp
  clang/test/ExtractAPI/methods.cpp
  clang/test/ExtractAPI/multiple_inheritance.cpp
  clang/test/ExtractAPI/simple_inheritance.cpp

Index: clang/test/ExtractAPI/simple_inheritance.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/simple_inheritance.cpp
@@ -0,0 +1,165 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang++ -extract-api -target arm64-apple-macosx -x c++-header \
+// RUN: %t/input.h -o %t/output.json -Xclang -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+class Foo {};
+
+class Bar : public Foo {};
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [
+{
+  "kind": "inheritsFrom",
+  "source": "c:@S@Bar",
+  "target": "c:@S@Foo",
+  "targetFallback": "Foo"
+}
+  ],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "class"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@S@Foo"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "c++.class"
+  },
+  "location": {
+"position": {
+  "character": 7,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"title": "Foo"
+  },
+  "pathComponents": [
+"Foo"
+  ]
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "class"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Bar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@S@Bar"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "c++.class"
+  },
+  "location": {
+"position": {
+  "character": 7,
+  "line": 3
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Bar"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Bar"
+  }
+],
+"title": "Bar"
+  },
+  "pathComponents": [
+"Bar"
+  ]
+}
+  ]
+}
Index: clang/test/ExtractAPI/multiple_inheritance.cpp

[PATCH] D154171: [RISCV] Mark zvkn* and zvks* extensions as enabled when all their subextensions are.

2023-06-29 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD accepted this revision.
eopXD added a comment.
This revision is now accepted and ready to land.

The change looks good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154171

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


[PATCH] D154171: [RISCV] Mark zvkn* and zvks* extensions as enabled when all their subextensions are.

2023-06-29 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

Do we need to do the same for v extension?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154171

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


[PATCH] D153883: [Clang][OpenMP] Delay emission of __kmpc_alloc_shared for escaped VLAs

2023-06-29 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 added a comment.

I have modified the patch to only do one thing rather than several things as 
the previous patch. Essentially this patch now only handles the delayed 
emission of the __kmpc_alloc_shared for the VLA which it could not emit in the 
Prolog of the function. This is now very precise in terms of which VLAs it will 
transform into __kmpc_alloc_shared i.e. only the ones that were previously 
attempted in the Prolog and could not be emitted because their size was missing 
(had not been emitted yet).

I have dropped the previous intention of emitting __kmpc_alloc_shared for 
thread local variables which have dynamic size. I am emitting dynamic allocas 
(as the test shows) which will fail in the backend as expected. This behavior 
needs to be resolved separately in the backend according to @arsenm  and any 
workaround in the frontend would have to live in a standalone patch that can be 
reverted when a fix to the backend is performed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153883

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


[PATCH] D153883: [Clang][OpenMP] Delay emission of __kmpc_alloc_shared for escaped VLAs

2023-06-29 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 updated this revision to Diff 536059.
doru1004 retitled this revision from "[Clang][OpenMP] Enable use of 
__kmpc_alloc_shared for VLAs defined in AMD GPU offloaded regions" to 
"[Clang][OpenMP] Delay emission of __kmpc_alloc_shared for escaped VLAs ".
doru1004 edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153883

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/amdgcn_target_device_vla.cpp

Index: clang/test/OpenMP/amdgcn_target_device_vla.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn_target_device_vla.cpp
@@ -0,0 +1,1260 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+int foo1() {
+  int sum = 0.0;
+  #pragma omp target map(tofrom: sum)
+  {
+int N = 10;
+int A[N];
+
+for (int i = 0; i < N; i++)
+  A[i] = i;
+
+for (int i = 0; i < N; i++)
+  sum += A[i];
+  }
+  return sum;
+}
+
+int foo2() {
+  int sum = 0.0;
+  int M = 12;
+  int result[M];
+  #pragma omp target teams distribute parallel for map(from: result[:M])
+  for (int i = 0; i < M; i++) {
+int N = 10;
+int A[N];
+result[i] = i;
+
+for (int j = 0; j < N; j++)
+  A[j] = j;
+
+for (int j = 0; j < N; j++)
+  result[i] += A[j];
+  }
+
+  for (int i = 0; i < M; i++)
+sum += result[i];
+  return sum;
+}
+
+int foo3() {
+  int sum = 0.0;
+  int M = 12;
+  int result[M];
+  #pragma omp target teams distribute map(from: result[:M])
+  for (int i = 0; i < M; i++) {
+int N = 10;
+int A[N];
+result[i] = i;
+
+#pragma omp parallel for
+for (int j = 0; j < N; j++)
+  A[j] = j;
+
+for (int j = 0; j < N; j++)
+  result[i] += A[j];
+  }
+
+  for (int i = 0; i < M; i++)
+sum += result[i];
+  return sum;
+}
+
+int foo4() {
+  int sum = 0.0;
+  int M = 12;
+  int result[M];
+  int N = 10;
+  #pragma omp target teams distribute map(from: result[:M])
+  for (int i = 0; i < M; i++) {
+int A[N];
+result[i] = i;
+
+#pragma omp parallel for
+for (int j = 0; j < N; j++)
+  A[j] = j;
+
+for (int j = 0; j < N; j++)
+  result[i] += A[j];
+  }
+
+  for (int i = 0; i < M; i++)
+sum += result[i];
+  return sum;
+}
+
+int main() {
+  return foo1() + foo2() + foo3() + foo4();
+}
+
+#endif
+// CHECK-LABEL: define {{[^@]+}}@{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}__Z4foo1v_l12
+// CHECK-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[SUM:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[SUM_ADDR:%.*]] = alloca ptr, align 8, addrspace(5)
+// CHECK-NEXT:[[N:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[__VLA_EXPR0:%.*]] = alloca i64, align 8, addrspace(5)
+// CHECK-NEXT:[[I:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[I1:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[SUM_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[SUM_ADDR]] to ptr
+// CHECK-NEXT:[[N_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N]] to ptr
+// CHECK-NEXT:[[__VLA_EXPR0_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[__VLA_EXPR0]] to ptr
+// CHECK-NEXT:[[I_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[I]] to ptr
+// CHECK-NEXT:[[I1_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[I1]] to ptr
+// CHECK-NEXT:store ptr [[SUM]], ptr [[SUM_ADDR_ASCAST]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[SUM_ADDR_ASCAST]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @__kmpc_target_init(ptr addrspacecast (ptr addrspace(1) @[[GLOB1:[0-9]+]] to ptr), i8 1, i1 true)
+// CHECK-NEXT:[[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP1]], -1
+// CHECK-NEXT:br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]]
+// CHECK:   user_code.entry:
+// CHECK-NEXT:store i32 10, ptr [[N_ASCAST]], align 4
+// CHECK-NEXT:[[TMP2:%.*]] = load i32, ptr [[N_ASCAST]], align 4
+// CHECK-NEXT:[[TMP3:%.*]] = zext i32 [[TMP2]] to i64
+// CHECK-NEXT:[[TMP4:%.*]] = mul nuw i64 [[TMP3]], 4
+// CHECK-NEXT:[[TMP5:%.*]] 

[PATCH] D154171: [RISCV] Mark zvkn* and zvks* extensions as enabled when all their subextensions are.

2023-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: 4vtomat, ego, kito-cheng, eopXD.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, 
arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, MaskRay.
Herald added projects: clang, LLVM.

These extensions don't contain any extensions on their own, they
are just aliases groups of extensions. We should set the preprocessor
define anytime all the subextensions are supported.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154171

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp


Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -1095,6 +1095,12 @@
 {{"zk"}, {ImpliedExtsZk}},
 {{"zkn"}, {ImpliedExtsZkn}},
 {{"zks"}, {ImpliedExtsZks}},
+{{"zvkn"}, {ImpliedExtsZvkn}},
+{{"zvknc"}, {ImpliedExtsZvknc}},
+{{"zvkng"}, {ImpliedExtsZvkng}},
+{{"zvks"}, {ImpliedExtsZvks}},
+{{"zvksc"}, {ImpliedExtsZvksc}},
+{{"zvksg"}, {ImpliedExtsZvksg}},
 };
 
 void RISCVISAInfo::updateCombination() {
Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -719,3 +719,55 @@
 // RUN: -march=rv64ifzvfbfwma0p6 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVFBFWMA-EXT %s
 // CHECK-ZVFBFWMA-EXT: __riscv_zvfbfwma 6000{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKN %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKN %s
+// CHECK-COMBINE-INTO-ZVKN: __riscv_zvkn 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvbc1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNC %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvbc1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNC %s
+// CHECK-COMBINE-INTO-ZVKNC: __riscv_zvkn 100{{$}}
+// CHECK-COMBINE-INTO-ZVKNC: __riscv_zvknc 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvkg1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNG %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvkg1p0_zvkned1p0_zvknhb1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKNG %s
+// CHECK-COMBINE-INTO-ZVKNG: __riscv_zvkn 100{{$}}
+// CHECK-COMBINE-INTO-ZVKNG: __riscv_zvkng 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKS %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKS %s
+// CHECK-COMBINE-INTO-ZVKS: __riscv_zvks 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvbc1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSC %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvbc1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSC %s
+// CHECK-COMBINE-INTO-ZVKSC: __riscv_zvks 100{{$}}
+// CHECK-COMBINE-INTO-ZVKSC: __riscv_zvksc 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32iv_zvbb1p0_zvkg1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSG %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64iv_zvbb1p0_zvkg1p0_zvksed1p0_zvksh1p0_zvkt1p0 -x c -E -dM 
%s -o - \
+// RUN: | FileCheck 

[PATCH] D134334: [Clang] Fix crash in isCXXDeclarationSpecifier when attempting to annotate template name

2023-06-29 Thread Shafik Yaghmour 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 rGd1fcce97a6af: [Clang] Fix crash in isCXXDeclarationSpecifier 
when attempting to annotate… (authored by shafik).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D134334?vs=527937=536040#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134334

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Parse/ParseTentative.cpp
  clang/test/Parser/cxx1z-class-template-argument-deduction.cpp


Index: clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -247,3 +247,11 @@
 };
 
 }
+
+namespace GH57495 {
+template  struct vector{};
+
+void f() {
+  GH57495::vector.d; // expected-error {{cannot use dot operator on a type}}
+}
+}
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -1656,7 +1656,10 @@
 if (getLangOpts().CPlusPlus17) {
   if (TryAnnotateTypeOrScopeToken())
 return TPResult::Error;
-  if (Tok.isNot(tok::identifier))
+  // If we annotated then the current token should not still be ::
+  // FIXME we may want to also check for tok::annot_typename but
+  // currently don't have a test case.
+  if (Tok.isNot(tok::annot_cxxscope))
 break;
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -553,6 +553,10 @@
   (`#48512 `_).
 - Fixed a failing assertion when parsing incomplete destructor.
   (`#63503 `_)
+- Fix C++17 mode assert when parsing malformed code and the compiler is
+  attempting to see if it could be type template for class template argument
+  deduction. This fixes
+  (`Issue 57495 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -247,3 +247,11 @@
 };
 
 }
+
+namespace GH57495 {
+template  struct vector{};
+
+void f() {
+  GH57495::vector.d; // expected-error {{cannot use dot operator on a type}}
+}
+}
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -1656,7 +1656,10 @@
 if (getLangOpts().CPlusPlus17) {
   if (TryAnnotateTypeOrScopeToken())
 return TPResult::Error;
-  if (Tok.isNot(tok::identifier))
+  // If we annotated then the current token should not still be ::
+  // FIXME we may want to also check for tok::annot_typename but
+  // currently don't have a test case.
+  if (Tok.isNot(tok::annot_cxxscope))
 break;
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -553,6 +553,10 @@
   (`#48512 `_).
 - Fixed a failing assertion when parsing incomplete destructor.
   (`#63503 `_)
+- Fix C++17 mode assert when parsing malformed code and the compiler is
+  attempting to see if it could be type template for class template argument
+  deduction. This fixes
+  (`Issue 57495 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d1fcce9 - [Clang] Fix crash in isCXXDeclarationSpecifier when attempting to annotate template name

2023-06-29 Thread Shafik Yaghmour via cfe-commits

Author: Shafik Yaghmour
Date: 2023-06-29T15:42:18-07:00
New Revision: d1fcce97a6af872e64b365d80d5b85eb94487dc8

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

LOG: [Clang] Fix crash in isCXXDeclarationSpecifier when attempting to annotate 
template name

When attempting to decide if in C++17 a type template for class template
argument deduction and the code is ill-formed the condition to break is
checking the current token is an identifier when it should be checking
if the next token is not ::.

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

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Parse/ParseTentative.cpp
clang/test/Parser/cxx1z-class-template-argument-deduction.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3afb4b1edb2dbd..da4ddff93c1f95 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -553,6 +553,10 @@ Bug Fixes in This Version
   (`#48512 `_).
 - Fixed a failing assertion when parsing incomplete destructor.
   (`#63503 `_)
+- Fix C++17 mode assert when parsing malformed code and the compiler is
+  attempting to see if it could be type template for class template argument
+  deduction. This fixes
+  (`Issue 57495 `_)
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Parse/ParseTentative.cpp 
b/clang/lib/Parse/ParseTentative.cpp
index 89e543f4b0900f..b7c83bbeb82ee7 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1656,7 +1656,10 @@ 
Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
 if (getLangOpts().CPlusPlus17) {
   if (TryAnnotateTypeOrScopeToken())
 return TPResult::Error;
-  if (Tok.isNot(tok::identifier))
+  // If we annotated then the current token should not still be ::
+  // FIXME we may want to also check for tok::annot_typename but
+  // currently don't have a test case.
+  if (Tok.isNot(tok::annot_cxxscope))
 break;
 }
 

diff  --git a/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp 
b/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
index fd651ad1b1b48f..2dd61baac31b3c 100644
--- a/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ b/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -247,3 +247,11 @@ struct A2 {
 };
 
 }
+
+namespace GH57495 {
+template  struct vector{};
+
+void f() {
+  GH57495::vector.d; // expected-error {{cannot use dot operator on a type}}
+}
+}



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


[clang] f78c9be - Adjust tests in 632dd6a4ca0036009f for ARM host

2023-06-29 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2023-06-29T15:35:10-07:00
New Revision: f78c9be14d739b27875004a751283c2431220ad1

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

LOG: Adjust tests in 632dd6a4ca0036009f for ARM host

size_t is unsigned int on ARM.

Added: 


Modified: 
clang/test/SemaTemplate/aggregate-deduction-candidate.cpp

Removed: 




diff  --git a/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp 
b/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
index 90794e012c6ee5..4bec1a8d4c48a6 100644
--- a/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
+++ b/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -176,7 +176,7 @@ namespace Array {
   // CHECK-LABEL: Dumping Array:::
   // CHECK: FunctionTemplateDecl {{.*}} implicit 
   // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
-  // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'size_t':'unsigned long{{( 
long)?}}' depth 0 index 1 N
+  // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'size_t':'unsigned {{.*}}' depth 
0 index 1 N
   // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  
'auto (T (&&)[N]) -> A'
   // CHECK: | `-ParmVarDecl {{.*}} 'T (&&)[N]'
   // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (int (&&)[3]) -> Array::A'
@@ -191,12 +191,12 @@ namespace Array {
   // CHECK:   `-DependentSizedArrayType {{.*}} 'T[N]' dependent
   // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
   // CHECK: | `-TemplateTypeParm {{.*}} 'T'
-  // CHECK: `-DeclRefExpr {{.*}} 'size_t':'unsigned long{{( long)?}}' 
NonTypeTemplateParm {{.*}} 'N' 'size_t':'unsigned long{{( long)?}}'
+  // CHECK: `-DeclRefExpr {{.*}} 'size_t':'unsigned {{.*}}' 
NonTypeTemplateParm {{.*}} 'N' 'size_t':'unsigned {{.*}}'
 
   // CHECK: Dumping Array:::
   // CHECK: FunctionTemplateDecl {{.*}} implicit 
   // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
-  // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'size_t':'unsigned long{{( 
long)?}}' depth 0 index 1 N
+  // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'size_t':'unsigned {{.*}}' depth 
0 index 1 N
   // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  
'auto (T (&)[N]) -> A'
   // CHECK: | `-ParmVarDecl {{.*}} 'T (&)[N]'
   // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (const char (&)[5]) -> Array::A'
@@ -212,7 +212,7 @@ namespace Array {
   // CHECK:   `-DependentSizedArrayType {{.*}} 'T[N]' dependent
   // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
   // CHECK: | `-TemplateTypeParm {{.*}} 'T'
-  // CHECK: `-DeclRefExpr {{.*}} 'size_t':'unsigned long{{( long)?}}' 
NonTypeTemplateParm {{.*}} 'N' 'size_t':'unsigned long{{( long)?}}'
+  // CHECK: `-DeclRefExpr {{.*}} 'size_t':'unsigned {{.*}}' 
NonTypeTemplateParm {{.*}} 'N' 'size_t':'unsigned {{.*}}'
 }
 
 namespace BraceElision {



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


[PATCH] D150338: [-Wunsafe-buffer-usage] Improving insertion of the [[clang::unsafe_buffer_usage]] attribute

2023-06-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks good to me! This doesn't take care of the GNU syntax 
(`__attribute__((unsafe_buffer_usage))`), but this probably isn't a big deal as 
people can simply use the modern C++ syntax in any code for which we actually 
emit these fixits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150338

___
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-06-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The fundamental problem here is the interaction with SFINAE; if we don't 
diagnose this as an error, we actually miscompile some cases.  Because of that, 
a flag wouldn't really be "turning off the warning"; it would be enabling a 
non-compliant language mode that has different rules for whether enum casts are 
legal.

If it weren't for that, I don't think anyone would be in a hurry to turn the 
warning into a hard error.


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


[PATCH] D140727: [XRay] Add initial support for loongarch64

2023-06-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/test/CodeGen/LoongArch/xray-attribute-instrumentation.ll:1
+; RUN: llc --mtriple=loongarch64 %s -o - | FileCheck %s
+; RUN: llc --mtriple=loongarch64 -filetype=obj %s -o %t

I think you want to read my recent updates to other 
`xray-attribute-instrumentation.ll`. Certain changes can make the test less 
sensitive to non-xray updates.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140727

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


[PATCH] D154145: [HIP] Fix -mllvm option for device lld linker

2023-06-29 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/ToolChains/HIPAMD.cpp:164
+StringRef ArgVal = Arg->getValue(1);
+if (ArgVal.startswith("-mllvm=")) {
+  ArgVal = ArgVal.substr(strlen("-mllvm="));

arsenm wrote:
> StringRef Prefix("-mllvm=") and then use the length instead of strlen
You could probably also do `ArgVal.split("-mllvm=").second` and push back first 
or second depending on whether or not `second` is empty.


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

https://reviews.llvm.org/D154145

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


[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

2023-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 536004.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

revised by comments


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

https://reviews.llvm.org/D154133

Files:
  clang/docs/AMDGPUSupport.rst


Index: clang/docs/AMDGPUSupport.rst
===
--- /dev/null
+++ clang/docs/AMDGPUSupport.rst
@@ -0,0 +1,61 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.part { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: part
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+AMDGPU Support
+==
+
+Clang supports OpenCL, HIP and OpenMP on amdgpu target.
+
+
+Predefined Macros
+=
+
+
+.. list-table::
+   :header-rows: 1
+
+   * - Macro
+ - Description
+   * - ``__AMDGPU__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGCN__``
+ - Defined if the GPU target is AMDGCN.
+   * - ``__R600__``
+ - Defined if the GPU target is R600.
+   * - ````
+ - Defined with the name of the architecture (e.g., ``__gfx906__`` for the 
gfx906 architecture).
+   * - ````
+ - Defines the GFX family (e.g., for gfx906, this macro would be 
``__GFX9__``).
+   * - ``__amdgcn_processor__``
+ - Defined with the processor name as a string (e.g., ``"gfx906"``).
+   * - ``__amdgcn_target_id__``
+ - Defined with the target ID as a string.
+   * - ``__amdgcn_feature___``
+ - Defined for each supported target feature. The value is 1 if the 
feature is enabled and 0 if it is disabled. Allowed feature names are sramecc 
and xnack.
+   * - ``__AMDGCN_UNSAFE_FP_ATOMICS__``
+ - Defined if unsafe floating-point atomics are allowed.
+   * - ``__HAS_FMAF__``
+ - Defined if FMAF instruction is available (deprecated).
+   * - ``__HAS_LDEXPF__``
+ - Defined if LDEXPF instruction is available (deprecated).
+   * - ``__HAS_FP64__``
+ - Defined if FP64 instruction is available (deprecated).
+   * - ``__AMDGCN_WAVEFRONT_SIZE``
+ - Defines the wavefront size. Allowed values are 32 and 64.
+   * - ``__AMDGCN_CUMODE__``
+ - Defines as 1 if the CU mode is enabled and 0 if the WGP mode is enabled.
+
+Please note that the specific architecture and feature names will vary 
depending on the GPU. Also, some macros are deprecated and may be removed in 
future releases.


Index: clang/docs/AMDGPUSupport.rst
===
--- /dev/null
+++ clang/docs/AMDGPUSupport.rst
@@ -0,0 +1,61 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.part { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: part
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+AMDGPU Support
+==
+
+Clang supports OpenCL, HIP and OpenMP on amdgpu target.
+
+
+Predefined Macros
+=
+
+
+.. list-table::
+   :header-rows: 1
+
+   * - Macro
+ - Description
+   * - ``__AMDGPU__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGCN__``
+ - Defined if the GPU target is AMDGCN.
+   * - ``__R600__``
+ - Defined if the GPU target is R600.
+   * - ````
+ - Defined with the name of the architecture (e.g., ``__gfx906__`` for the gfx906 architecture).
+   * - ````
+ - Defines the GFX family (e.g., for gfx906, this macro would be ``__GFX9__``).
+   * - ``__amdgcn_processor__``
+ - Defined with the processor name as a string (e.g., ``"gfx906"``).
+   * - ``__amdgcn_target_id__``
+ - Defined with the target ID as a string.
+   * - ``__amdgcn_feature___``
+ - Defined for each supported target feature. The value is 1 if the feature is enabled and 0 if it is disabled. Allowed feature names are sramecc and xnack.
+   * - ``__AMDGCN_UNSAFE_FP_ATOMICS__``
+ - Defined if unsafe floating-point atomics are allowed.
+   * - ``__HAS_FMAF__``
+ - Defined if FMAF instruction is available (deprecated).
+   * - ``__HAS_LDEXPF__``
+ - Defined if LDEXPF instruction is available (deprecated).
+   * - ``__HAS_FP64__``
+ - Defined if FP64 instruction is available (deprecated).
+   * - ``__AMDGCN_WAVEFRONT_SIZE``
+ - Defines the wavefront size. Allowed values are 32 and 64.
+   * - ``__AMDGCN_CUMODE__``
+ - Defines as 1 if the CU mode is enabled and 0 if the WGP mode is enabled.
+
+Please note that the specific architecture and feature names will vary depending on the GPU. Also, some macros are deprecated and may be removed in future releases.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154145: [HIP] Fix -mllvm option for device lld linker

2023-06-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/Driver/ToolChains/HIPAMD.cpp:164
+StringRef ArgVal = Arg->getValue(1);
+if (ArgVal.startswith("-mllvm=")) {
+  ArgVal = ArgVal.substr(strlen("-mllvm="));

StringRef Prefix("-mllvm=") and then use the length instead of strlen


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

https://reviews.llvm.org/D154145

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


[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

2023-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 3 inline comments as done.
yaxunl added inline comments.



Comment at: clang/docs/AMDGPUSupport.rst:33
+   * - ``__AMD__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGPU__``

jdoerfert wrote:
> FWIW, this arguably confusing use of __AMD__, and duplication of __AMDGPU__, 
> should be deprecated and removed. Or at least not advocated...
will remove from the documentation.



Comment at: clang/docs/AMDGPUSupport.rst:54
+ - Defined if FMAF instruction is available (deprecated).
+   * - ``FP_FAST_FMAF``
+ - Defined if fast FMAF instruction is available.

arsenm wrote:
> The fma macro was actually from the opencl spec but never handled in the 
> correct place
will remove


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

https://reviews.llvm.org/D154133

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


[PATCH] D154014: [SpecialCaseList] Use Globs instead of Regex

2023-06-29 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 536003.
ellis added a comment.

Fix memory bug and add TODO about a regex/glob config. Lets wait for others to 
comment before I put work into this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154014

Files:
  clang/docs/SanitizerSpecialCaseList.rst
  clang/lib/Basic/ProfileList.cpp
  clang/lib/Basic/SanitizerSpecialCaseList.cpp
  llvm/include/llvm/Support/SpecialCaseList.h
  llvm/lib/Support/SpecialCaseList.cpp
  llvm/unittests/Support/SpecialCaseListTest.cpp

Index: llvm/unittests/Support/SpecialCaseListTest.cpp
===
--- llvm/unittests/Support/SpecialCaseListTest.cpp
+++ llvm/unittests/Support/SpecialCaseListTest.cpp
@@ -10,8 +10,11 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/VirtualFileSystem.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+using testing::HasSubstr;
+using testing::StartsWith;
 using namespace llvm;
 
 namespace {
@@ -50,7 +53,8 @@
   "src:hello\n"
   "src:bye\n"
   "src:hi=category\n"
-  "src:z*=category\n");
+  "src:z*=category\n"
+  " \n");
   EXPECT_TRUE(SCL->inSection("", "src", "hello"));
   EXPECT_TRUE(SCL->inSection("", "src", "bye"));
   EXPECT_TRUE(SCL->inSection("", "src", "hi", "category"));
@@ -74,31 +78,29 @@
  "\n"
  "[not valid\n",
  Error));
-  EXPECT_TRUE(
-  ((StringRef)Error).startswith("malformed section header on line 3:"));
+  EXPECT_THAT(Error, StartsWith("malformed section header on line 3:"));
 
   EXPECT_EQ(nullptr, makeSpecialCaseList("\n\n\n"
  "[not valid\n",
  Error));
-  EXPECT_TRUE(
-  ((StringRef)Error).startswith("malformed section header on line 4:"));
+  EXPECT_THAT(Error, StartsWith("malformed section header on line 4:"));
 }
 
-TEST_F(SpecialCaseListTest, SectionRegexErrorHandling) {
+TEST_F(SpecialCaseListTest, SectionGlobErrorHandling) {
   std::string Error;
   EXPECT_EQ(makeSpecialCaseList("[address", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).startswith("malformed section header "));
+  EXPECT_THAT(Error, StartsWith("malformed section header "));
 
   EXPECT_EQ(makeSpecialCaseList("[[]", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).startswith("malformed regex for section [: "));
+  EXPECT_EQ(Error, "malformed section at line 1: '[': invalid glob pattern: [");
 
   EXPECT_EQ(makeSpecialCaseList("src:=", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).endswith("Supplied regexp was blank"));
+  EXPECT_THAT(Error, HasSubstr("Supplied glob was blank"));
 }
 
 TEST_F(SpecialCaseListTest, Section) {
   std::unique_ptr SCL = makeSpecialCaseList("src:global\n"
- "[sect1|sect2]\n"
+ "[{sect1,sect2}]\n"
  "src:test1\n"
  "[sect3*]\n"
  "src:test2\n");
@@ -154,17 +156,12 @@
   EXPECT_EQ(nullptr, makeSpecialCaseList("badline", Error));
   EXPECT_EQ("malformed line 1: 'badline'", Error);
   EXPECT_EQ(nullptr, makeSpecialCaseList("src:bad[a-", Error));
-  EXPECT_EQ("malformed regex in line 1: 'bad[a-': invalid character range",
-Error);
-  EXPECT_EQ(nullptr, makeSpecialCaseList("src:a.c\n"
-   "fun:fun(a\n",
-   Error));
-  EXPECT_EQ("malformed regex in line 2: 'fun(a': parentheses not balanced",
+  EXPECT_EQ("malformed glob in line 1: 'bad[a-': invalid glob pattern: bad[a-",
 Error);
   std::vector Files(1, "unexisting");
   EXPECT_EQ(nullptr,
 SpecialCaseList::create(Files, *vfs::getRealFileSystem(), Error));
-  EXPECT_EQ(0U, Error.find("can't open file 'unexisting':"));
+  EXPECT_THAT(Error, StartsWith("can't open file 'unexisting':"));
 }
 
 TEST_F(SpecialCaseListTest, EmptySpecialCaseList) {
@@ -191,7 +188,7 @@
 }
 
 TEST_F(SpecialCaseListTest, NoTrigramsInRules) {
-  std::unique_ptr SCL = makeSpecialCaseList("fun:b.r\n"
+  std::unique_ptr SCL = makeSpecialCaseList("fun:b?r\n"
  "fun:za*az\n");
   EXPECT_TRUE(SCL->inSection("", "fun", "bar"));
   EXPECT_FALSE(SCL->inSection("", "fun", "baz"));
Index: llvm/lib/Support/SpecialCaseList.cpp
===
--- llvm/lib/Support/SpecialCaseList.cpp
+++ 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG632dd6a4ca00: [Clang] Implements CTAD for aggregates P1816R0 
and P2082R1 (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -7372,7 +7372,7 @@
   cxxDeductionGuideDecl(hasParameter(0, hasType(asString("A");
   auto *ToD = Import(FromD, Lang_CXX17);
   ASSERT_TRUE(ToD);
-  EXPECT_TRUE(ToD->isCopyDeductionCandidate());
+  EXPECT_EQ(ToD->getDeductionCandidateKind(), DeductionCandidate::Copy);
   // Check that the deduced class template is also imported.
   EXPECT_TRUE(findFromTU(FromD)->Importer->GetAlreadyImportedOrNull(
   FromD->getDeducedTemplate()));
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,364 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | 

[clang] 632dd6a - [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2023-06-29T14:22:24-07:00
New Revision: 632dd6a4ca0036009febd55d95e4e1f93eeb412c

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

LOG: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

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

Added: 
clang/test/SemaTemplate/aggregate-deduction-candidate.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/DeclBase.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/TemplateDeduction.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 03c27a207d5e1b..3afb4b1edb2dbd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -112,6 +112,8 @@ C++20 Feature Support
 - Clang now supports `requires cplusplus20` for module maps.
 - Implemented missing parts of `P2002R1: Consistent comparison operators 
`_
 - Clang now defines `__cpp_consteval` macro.
+- Implemented `P1816R0: `_ and `P2082R1: 
`_,
+  which allows CTAD for aggregates.
 
 C++23 Feature Support
 ^

diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index eea8a111ab774f..1b99709ca90d99 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1382,6 +1382,13 @@ class DeclContextLookupResult {
   }
 };
 
+/// Only used by CXXDeductionGuideDecl.
+enum class DeductionCandidate : unsigned char {
+  Normal,
+  Copy,
+  Aggregate,
+};
+
 /// DeclContext - This is used only as base class of specific decl types that
 /// can act as declaration contexts. These decls are (only the top classes
 /// that directly derive from DeclContext are mentioned, not their subclasses):
@@ -1620,10 +1627,10 @@ class DeclContext {
   /// Stores the bits used by FunctionDecl.
   /// If modified NumFunctionDeclBits and the accessor
   /// methods in FunctionDecl and CXXDeductionGuideDecl
-  /// (for IsCopyDeductionCandidate) should be updated appropriately.
+  /// (for DeductionCandidateKind) should be updated appropriately.
   class FunctionDeclBitfields {
 friend class FunctionDecl;
-/// For IsCopyDeductionCandidate
+/// For DeductionCandidateKind
 friend class CXXDeductionGuideDecl;
 /// For the bits in DeclContextBitfields.
 uint64_t : NumDeclContextBits;
@@ -1678,10 +1685,10 @@ class DeclContext {
 /// function using attribute 'target'.
 uint64_t IsMultiVersion : 1;
 
-/// [C++17] Only used by CXXDeductionGuideDecl. Indicates that
-/// the Deduction Guide is the implicitly generated 'copy
-/// deduction candidate' (is used during overload resolution).
-uint64_t IsCopyDeductionCandidate : 1;
+/// Only used by CXXDeductionGuideDecl. Indicates the kind
+/// of the Deduction Guide that is implicitly generated
+/// (used during overload resolution).
+uint64_t DeductionCandidateKind : 2;
 
 /// Store the ODRHash after first calculation.
 uint64_t HasODRHash : 1;

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index b8e5224a0f2251..f4322e1e00f0c6 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1942,13 +1942,13 @@ class CXXDeductionGuideDecl : public FunctionDecl {
 ExplicitSpecifier ES,
 const DeclarationNameInfo , QualType T,
 TypeSourceInfo *TInfo, SourceLocation EndLocation,
-CXXConstructorDecl *Ctor)
+CXXConstructorDecl *Ctor, DeductionCandidate Kind)
   : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
  SC_None, false, false, ConstexprSpecKind::Unspecified),
 Ctor(Ctor), ExplicitSpec(ES) {
 if (EndLocation.isValid())
   setRangeEnd(EndLocation);
-setIsCopyDeductionCandidate(false);
+setDeductionCandidateKind(Kind);
   }
 
   CXXConstructorDecl *Ctor;
@@ -1963,7 +1963,8 @@ class CXXDeductionGuideDecl : public FunctionDecl {
   Create(ASTContext , DeclContext *DC, SourceLocation 

[PATCH] D154070: [Driver][lld/COFF] Support DWARF fission when using LTO on Windows

2023-06-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a subscriber: mstorsjo.
MaskRay added a comment.
This revision is now accepted and ready to land.

I'll be away for a few days and back on July 5. Clicked "Accept" if you keep 
just the lld/COFF part for this patch and create another patch for 
clang/lib/Driver.

I guess @mstorsjo may have some opinions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154070

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


[PATCH] D154070: [Driver][lld/COFF] Support DWARF fission when using LTO on Windows

2023-06-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Normally clang and lld patches are separate. You can `git log -- lld/COFF` to 
find who usually reviews lld/COFF code and add these folks as reviewers.
Not many people set subscription rules but some may appreciate if you let know 
that there is such a change.
Though, I have reviewed some lld/COFF patches and am happy to stamp this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154070

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


[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-06-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2293
+//  search of connected components.
+if (!ParmsNeedFix.empty()) {
+  auto First = ParmsNeedFix.begin(), Last = First;

ziqingluo-90 wrote:
> NoQ wrote:
> > ziqingluo-90 wrote:
> > > NoQ wrote:
> > > > ziqingluo-90 wrote:
> > > > > NoQ wrote:
> > > > > > What about the situation where params aren't seen as unsafe yet, 
> > > > > > but they're discovered to be unsafe later? Eg.
> > > > > > ```
> > > > > > void foo(int *p, int *q) {
> > > > > >   int *p2 = p;
> > > > > >   p2[5] = 7;
> > > > > >   int *q2 = q;
> > > > > >   q2[5] = 7;
> > > > > > }
> > > > > > ```
> > > > > > Will we notice that `p` and `q` need to be fixed simultaneously?
> > > > > > 
> > > > > > ---
> > > > > > 
> > > > > > I suspect that the problem of parameter grouping can't be solved by 
> > > > > > pre-populating strategy implications between all parameters. It'll 
> > > > > > either cause you to implicate all parameters (even the ones that 
> > > > > > will never need fixing), or cause you to miss connections between 
> > > > > > parameters that do need fixing (as the connection is discovered 
> > > > > > later).
> > > > > > 
> > > > > > Connection between parameters needs to be added *after* the 
> > > > > > implications algorithm has finished. And once it's there (might be 
> > > > > > already there if I missed something), then this part of code 
> > > > > > probably becomes unnecessary.
> > > > > Yes.  They will be noticed.  Here is why:
> > > > > 
> > > > > The code here first forms a ring over `p` and  `q` in the assignment 
> > > > > (directed) graph:  
> > > > > ```
> > > > > p <--> q
> > > > > ```
> > > > > Then the two initialization statements (implemented in [[ 
> > > > > https://reviews.llvm.org/D150489 | D150489 ]]) add two more edges to 
> > > > > the graph:
> > > > > ```
> > > > > p2 --> p <--> q <-- q2
> > > > > ```
> > > > > The algorithm later searches the graph starting from unsafe variables 
> > > > > `p2` and `q2`, respectively,  Starting from `p2`, the algorithm 
> > > > > discovers that `p2` and `p`, as well as `p` and `q` depend on each 
> > > > > other.  Starting from `q2`,  the algorithm discovers that `q2` and 
> > > > > `q`, as well as `p` and `q` depend on each other.   The dependency 
> > > > > graph is sort of undirected. So eventually, the four variables `p2`, 
> > > > > `p`, `q`, `q2` are in the same group.
> > > > > 
> > > > > The code here first forms a ring over `p` and  `q` in the assignment 
> > > > > (directed) graph
> > > > 
> > > > I don't think it does. The ring is formed over the `ParamsNeedFix` 
> > > > list, which is empty because none of these parameters are listed in 
> > > > `UnsafeOps.byVar`.
> > > Actually `p` and `q` will be in `ParamsNeedFix`.  Because they are 
> > > implicated by `p2` and `q2`, who are unsafe variables.   `ParamsNeedFix` 
> > > include parameters that need fix, either because they are used in unsafe 
> > > operations or they are implicated by some Gadgets.
> > > 
> > > But anyway, I now think it's not a good idea to lump parameters with 
> > > variables grouped by implication, as you pointed out that variable 
> > > implication also implies bounds propagation. 
> > > 
> > > Instead, I think it might be more appropriate to make a variable group 
> > > structured:  
> > >   - Let's call it a //connected components// for a set of variables that 
> > > need to be fixed together and sharing bounds information. (The term 
> > > //connected components// has been used in the code to refer to a group of 
> > > variables. It keeps its meaning here.)
> > >   - Let's redefine a Variable Group to be a set of mutually disjoint 
> > > //connected components//s (CCs).  If there are more than one CCs in a 
> > > variable group,  each of the CCs contains at least one parameter.
> > > 
> > > For generating fix-its for a variable group, this patch still works as it 
> > > only requires that variables in a variable group are either all fixed or 
> > > given up as a whole.
> > > For generating diagnostic messages, we now have more information about 
> > > relations among grouped variables.
> > > Actually `p` and `q` will be in ParamsNeedFix. Because they are 
> > > implicated by `p2` and `q2`, who are unsafe variables.  `ParamsNeedFix` 
> > > include parameters that need fix, either because they are used in unsafe 
> > > operations or they are implicated by some Gadgets.
> > 
> > Ohh, right, it's populated twice, I even commented on the other part but 
> > didn't notice it populates the same list!
> > 
> > But in this case you'll probably join `p` and `q` in
> > ```
> > void foo(int *p, int *q) {
> >   int *p2 = p;
> >   p2[5] = 7;
> >   int *q2 = q;
> > }
> > ```
> > right? (In this case `q` is implicated by `q2` so it gets added to the 
> > list, but `q2` itself isn't unsafe or implicated by anything, so it doesn't 
> > need fixing, but connecting 

[PATCH] D154151: [clang-tidy] Improve documentation for modernize-use-std-print check

2023-06-29 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe created this revision.
mikecrowe added a reviewer: PiotrZSL.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
mikecrowe requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Remove incorrect use of double colons so that the code blocks are
rendered correctly to HTML.

Wrap the name of another check in single backticks. Wrap the name of a
macro in double backticks.

Explain that with the default settings the check is only enabled with
C++23 or later standards.

Correct std::string_data() to std::string::data().


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154151

Files:
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst


Index: clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
@@ -9,21 +9,25 @@
 The replaced and replacement functions can be customised by configuration
 options. Each argument that is the result of a call to 
``std::string::c_str()`` and
 ``std::string::data()`` will have that now-unnecessary call removed in a
-similar manner to the readability-redundant-string-cstr check.
+similar manner to the `readability-redundant-string-cstr` check.
 
-In other words, it turns lines like::
+In other words, it turns lines like:
 
 .. code-block:: c++
 
   fprintf(stderr, "The %s is %3d\n", description.c_str(), value);
 
-into::
+into:
 
 .. code-block:: c++
 
   std::println(stderr, "The {} is {:3}", description, value);
 
-It doesn't do a bad job, but it's not perfect. In particular:
+If the `ReplacementPrintFunction` or `ReplacementPrintlnFunction` options
+are left, or assigned to their default values then this check is only
+enabled with `-std=c++23` or later.
+
+The check doesn't do a bad job, but it's not perfect. In particular:
 
 - It assumes that the format string is correct for the arguments. If you
   get any warnings when compiling with `-Wformat` then misbehaviour is
@@ -35,7 +39,7 @@
   handled. Although it's possible for the check to automatically put the
   escapes back, they may not be exactly as they were written (e.g.
   ``"\x0a"`` will become ``"\n"`` and ``"ab" "cd"`` will become
-  ``"abcd"``.) This is helpful since it means that the PRIx macros from
+  ``"abcd"``.) This is helpful since it means that the ``PRIx`` macros from
    are removed correctly.
 
 - It supports field widths, precision, positional arguments, leading zeros,
@@ -78,7 +82,7 @@
   signedness will be wrapped in an approprate ``static_cast`` if `StrictMode`
   is enabled.
 - any arguments that end in a call to ``std::string::c_str()`` or
-  ``std::string_data()`` will have that call removed.
+  ``std::string::data()`` will have that call removed.
 
 Options
 ---
@@ -99,7 +103,7 @@
 unsigned int u = 0x;
 printf("%d %u\n", i, u);
 
-  would be converted to::
+  would be converted to:
 
   .. code-block:: c++
 


Index: clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
@@ -9,21 +9,25 @@
 The replaced and replacement functions can be customised by configuration
 options. Each argument that is the result of a call to ``std::string::c_str()`` and
 ``std::string::data()`` will have that now-unnecessary call removed in a
-similar manner to the readability-redundant-string-cstr check.
+similar manner to the `readability-redundant-string-cstr` check.
 
-In other words, it turns lines like::
+In other words, it turns lines like:
 
 .. code-block:: c++
 
   fprintf(stderr, "The %s is %3d\n", description.c_str(), value);
 
-into::
+into:
 
 .. code-block:: c++
 
   std::println(stderr, "The {} is {:3}", description, value);
 
-It doesn't do a bad job, but it's not perfect. In particular:
+If the `ReplacementPrintFunction` or `ReplacementPrintlnFunction` options
+are left, or assigned to their default values then this check is only
+enabled with `-std=c++23` or later.
+
+The check doesn't do a bad job, but it's not perfect. In particular:
 
 - It assumes that the format string is correct for the arguments. If you
   get any warnings when compiling with `-Wformat` then misbehaviour is
@@ -35,7 +39,7 @@
   handled. Although it's possible for the check to automatically put the
   escapes back, they may not be exactly as they were written (e.g.
   ``"\x0a"`` will become ``"\n"`` and ``"ab" "cd"`` will become
-  ``"abcd"``.) This is helpful since it means that the PRIx macros from
+  ``"abcd"``.) This is helpful since it means that the ``PRIx`` macros from
    are 

[PATCH] D153003: [ODRHash] Fix ODR hashing of template names

2023-06-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D153003#4458323 , @ChuanqiXu wrote:

> In D153003#4456595 , @rsmith wrote:
>
>> How to we even get into the ODR hasher here? I thought we only applied it to 
>> function and class definitions (to which the ODR does apply).
>
> I think this comes from we add ODRHash for  RecordDecl.

The using-declarations in the testcase aren't inside RecordDecls.

Oh, I guess we're somehow adding a semi-resolved form of the base class type of 
`D` into the ODR hash, which then includes details of the using-declaration. 
That seems wrong -- we should either (preferably) be including only the 
syntactic form of the base specifier (because local syntax is what the ODR 
covers), or the canonical type (which should be the same for both 
using-declarations).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153003

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


[PATCH] D154036: [libc] Add support for creating wrapper headers for offloading in clang

2023-06-29 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 535983.
jhuber6 added a comment.

Add some checks to `stdlib.h` to ensure ABI compatibility for `div` functions.

Because this patch makes us always include the LLVM libc repo when offloading,
we mask off the wrappers if they were not installed by `libc`, so this is simply
a passthrough include header if the user didn't build with LLVM C library for
the GPU.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154036

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/llvm_libc_wrappers/ctype.h
  clang/lib/Headers/llvm_libc_wrappers/llvm-libc-decls/README.txt
  clang/lib/Headers/llvm_libc_wrappers/stdio.h
  clang/lib/Headers/llvm_libc_wrappers/stdlib.h
  clang/lib/Headers/llvm_libc_wrappers/string.h
  clang/test/Driver/gpu-libc-headers.c
  libc/cmake/modules/LLVMLibCHeaderRules.cmake
  libc/include/CMakeLists.txt
  libc/utils/HdrGen/Generator.cpp
  libc/utils/HdrGen/Generator.h
  libc/utils/HdrGen/Main.cpp

Index: libc/utils/HdrGen/Main.cpp
===
--- libc/utils/HdrGen/Main.cpp
+++ libc/utils/HdrGen/Main.cpp
@@ -32,6 +32,9 @@
 llvm::cl::list ReplacementValues(
 "args", llvm::cl::desc("Command separated = pairs."),
 llvm::cl::value_desc("[,name=value]"));
+llvm::cl::opt ExportDecls(
+"export-decls",
+llvm::cl::desc("Output a new header containing only the entrypoints."));
 
 void ParseArgValuePairs(std::unordered_map ) {
   for (std::string  : ReplacementValues) {
@@ -48,7 +51,10 @@
   std::unordered_map ArgMap;
   ParseArgValuePairs(ArgMap);
   Generator G(HeaderDefFile, EntrypointNamesOption, StandardHeader, ArgMap);
-  G.generate(OS, Records);
+  if (ExportDecls)
+G.generateDecls(OS, Records);
+  else
+G.generate(OS, Records);
 
   return false;
 }
Index: libc/utils/HdrGen/Generator.h
===
--- libc/utils/HdrGen/Generator.h
+++ libc/utils/HdrGen/Generator.h
@@ -52,6 +52,7 @@
 ArgMap(Map) {}
 
   void generate(llvm::raw_ostream , llvm::RecordKeeper );
+  void generateDecls(llvm::raw_ostream , llvm::RecordKeeper );
 };
 
 } // namespace llvm_libc
Index: libc/utils/HdrGen/Generator.cpp
===
--- libc/utils/HdrGen/Generator.cpp
+++ libc/utils/HdrGen/Generator.cpp
@@ -10,6 +10,7 @@
 
 #include "IncludeFileCommand.h"
 #include "PublicAPICommand.h"
+#include "utils/LibcTableGenUtil/APIIndexer.h"
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -116,4 +117,78 @@
   }
 }
 
+void Generator::generateDecls(llvm::raw_ostream ,
+  llvm::RecordKeeper ) {
+
+  OS << "//===-- C standard declarations for " << StdHeader << " "
+ << std::string(80 - (42 + StdHeader.size()), '-') << "===//\n"
+ << "//\n"
+ << "// Part of the LLVM Project, under the Apache License v2.0 with LLVM "
+"Exceptions.\n"
+ << "// See https://llvm.org/LICENSE.txt for license information.\n"
+ << "// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n"
+ << "//\n"
+ << "//"
+"===---"
+"---===//\n\n";
+
+  std::string HeaderGuard(StdHeader.size(), '\0');
+  llvm::transform(StdHeader, HeaderGuard.begin(), [](const char C) -> char {
+return !isalnum(C) ? '_' : llvm::toUpper(C);
+  });
+  OS << "#ifndef __LLVM_LIBC_DECLARATIONS_" << HeaderGuard << "\n"
+ << "#define __LLVM_LIBC_DECLARATIONS_" << HeaderGuard << "\n\n";
+
+  OS << "#ifndef __LIBC_ATTRS\n"
+ << "#define __LIBC_ATTRS\n"
+ << "#endif\n\n";
+
+  OS << "#ifdef __cplusplus\n"
+ << "extern \"C\" {\n"
+ << "#endif\n\n";
+
+  APIIndexer G(StdHeader, Records);
+  for (auto  : EntrypointNameList) {
+// Filter out functions not exported by this header.
+if (G.FunctionSpecMap.find(Name) == G.FunctionSpecMap.end())
+  continue;
+
+llvm::Record *FunctionSpec = G.FunctionSpecMap[Name];
+llvm::Record *RetValSpec = FunctionSpec->getValueAsDef("Return");
+llvm::Record *ReturnType = RetValSpec->getValueAsDef("ReturnType");
+
+OS << G.getTypeAsString(ReturnType) << " " << Name << "(";
+
+auto ArgsList = FunctionSpec->getValueAsListOfDefs("Args");
+for (size_t i = 0; i < ArgsList.size(); ++i) {
+  llvm::Record *ArgType = ArgsList[i]->getValueAsDef("ArgType");
+  OS << G.getTypeAsString(ArgType);
+  if (i < ArgsList.size() - 1)
+OS << ", ";
+}
+
+OS << ") __LIBC_ATTRS;\n\n";
+  }
+
+  // Make another pass over entrypoints to emit object declarations.
+  for (const auto  : EntrypointNameList) {
+if (G.ObjectSpecMap.find(Name) == G.ObjectSpecMap.end())
+  continue;
+llvm::Record *ObjectSpec = G.ObjectSpecMap[Name];
+auto Type = 

[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

2023-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/docs/AMDGPUSupport.rst:62
+ - Defined if fast FMA instruction is available.
+   * - ``__AMDGCN_WAVEFRONT_SIZE``
+ - Defines the wavefront size. Allowed values are 32 and 64.

jdoerfert wrote:
> Any reason this one does not end in `__`?
It is my mistake. Did not consider consistency when designing this macro.


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

https://reviews.llvm.org/D154133

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


[PATCH] D152554: [OpenMP] Migrate deviice code privatization from Clang CodeGen to OMPIRBuilder

2023-06-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

typo in the title.




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.h:1444
+/// alloca address where the runtime returns the device pointers.
+llvm::DenseMap CaptureDeviceAddrMap;
   };

If it is an alloca (for sure) use `llvm::AllocaInst`.



Comment at: clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp:418
-// CK2: [[VAL1:%.+]] = load ptr, ptr [[BP1]],
-// CK2: store ptr [[VAL1]], ptr [[PVT1:%.+]],
 // CK2: store ptr [[PVT1]], ptr [[_PVT1:%.+]],

Did we just change the order or is this non-deterministic? The latter is not 
acceptable, the former might be.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4131
+  for (auto DeviceMap : Info.DevicePtrInfoMap) {
+if (isa(DeviceMap.second.second)) {
+  auto *LI =

What else could it be here?



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4694
+  } else if (CombinedInfo.DevicePointers[I] == DeviceInfoTy::Address) {
+Info.DevicePtrInfoMap[BPVal] = {BP, BP};
+assert(DeviceAddrCB &&

What if the PointerBCOrASCast and the GEP are both no-ops, and BPVal is an 
alloca. Would that cause a problem as we later only check if the type of the 
value is an alloca. That said, it seems dangerous to only rely on the type of 
the value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152554

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


[PATCH] D150860: [OpenMP] Change clang emitTargetDataCalls to use OMPIRBuilder

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

Let's move on. I described what this should look like, just for the record.




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:10399
+DeviceID = CGF.Builder.getInt64(OMP_DEVICEID_UNDEF);
+  }
 

TIFitis wrote:
> jdoerfert wrote:
> > Move this behind the if generation and guard the emit scalar with a 
> > conditional, all is only needed if both Device is present and IfCond is not 
> > known true.
> I have moved the device generation after the if generation.
> But I am not sure what should be the guard here for emitting the scalar.
> 
> My idea was to generate something like:
> 
> 
> ```
> %new_dev = alloca ...
> if.then
> %x = load %device
> store %x %new_dev
> ...
> begin_mapper(..., %new_dev, ...)
> ...
> if.then
> ...
> end_mapper(..., %new_dev, ...)
> ```
What we should do, though I don't think it will really matter, is the following:
```
device_val = undef;
if_val = eval_if_clause();
if (id_val) {
  device_val = eval_device_clause()
  ...other clauses ...
  begin_then(... Vals ...)
} else {
  begin_else(...)
}

if (if_val) {
  end_then(... Vals ...)
} else {
  end_else(...)
}
```






Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150860

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


[PATCH] D154145: [HIP] Fix -mllvm option for device lld linker

2023-06-29 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

LG, thanks.


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

https://reviews.llvm.org/D154145

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


[PATCH] D154016: [clang][modules] Avoid serializing all diag mappings in non-deterministic order

2023-06-29 Thread Ben Langmuir via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
benlangmuir marked an inline comment as done.
Closed by commit rG1ede7b47493f: [clang][modules] Avoid serializing all diag 
mappings in non-deterministic order (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154016

Files:
  clang/include/clang/Basic/DiagnosticIDs.h
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/diag-mappings.c

Index: clang/test/Modules/diag-mappings.c
===
--- /dev/null
+++ clang/test/Modules/diag-mappings.c
@@ -0,0 +1,94 @@
+// Test that diagnostic mappings are emitted only when needed and in order of
+// diagnostic ID rather than non-deterministically. This test passes 3
+// -W options and expects exactly 3 mappings to be emitted in the pcm. The -W
+// options are chosen to be far apart in ID (see DiagnosticIDs.h) so we can
+// check they are ordered. We also intentionally trigger several other warnings
+// inside the module and ensure they do not show up in the pcm as mappings.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t/cache -triple x86_64-apple-macosx10.11.0 \
+// RUN:   %t/main.m -fdisable-module-hash \
+// RUN:   -Werror=stack-protector -Werror=empty-translation-unit -Werror=float-equal
+
+// RUN: mv %t/cache/A.pcm %t/A1.pcm
+
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t/A1.pcm | FileCheck %s
+
+// CHECK:  2000
+// CHECK-SAME: op7=[[FLOAT_EQ:[2-9][0-9][0-9][0-9]]] op8=
+
+// == Pragmas:
+// Each pragma creates a mapping table; and each copies the previous table. The
+// initial mappings are copied as well, but are not serialized since they have
+// isPragma=false.
+
+// == ignored "-Wfloat-equal"
+// CHECK-SAME: op{{[0-9]+}}=1
+// CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
+
+// == ignored "-Wstack-protector"
+// CHECK-SAME: op{{[0-9]+}}=2
+// CHECK-SAME: op{{[0-9]+}}=[[STACK_PROT]] op{{[0-9]+}}=
+// CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
+
+// == warning "-Wempty-translation-unit"
+// CHECK-SAME: op{{[0-9]+}}=3
+// CHECK-SAME: op{{[0-9]+}}=[[STACK_PROT]] op{{[0-9]+}}=
+// CHECK-SAME: op{{[0-9]+}}=[[EMPTY_TU]] op{{[0-9]+}}=
+// CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
+
+// == warning "-Wstack-protector"
+// CHECK-SAME: op{{[0-9]+}}=3
+// CHECK-SAME: op{{[0-9]+}}=[[STACK_PROT]] op{{[0-9]+}}=
+// CHECK-SAME: op{{[0-9]+}}=[[EMPTY_TU]] op{{[0-9]+}}=
+// CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t/cache -triple x86_64-apple-macosx10.11.0 \
+// RUN:   %t/main.m -fdisable-module-hash \
+// RUN:   -Werror=stack-protector -Werror=empty-translation-unit -Werror=float-equal
+
+// RUN: diff %t/cache/A.pcm %t/A1.pcm
+
+//--- module.modulemap
+module A { header "a.h" }
+
+//--- a.h
+// Lex warning
+#warning "w"
+
+static inline void f() {
+// Parse warning
+  ;
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wfloat-equal"
+#pragma clang diagnostic ignored "-Wstack-protector"
+
+static inline void g() {
+// Sema warning
+  int x;
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic warning "-Wempty-translation-unit"
+#pragma clang diagnostic warning "-Wstack-protector"
+
+#pragma clang diagnostic pop
+#pragma clang diagnostic pop
+
+//--- main.m
+#import "a.h"
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -2997,20 +2997,41 @@
 assert(Flags == EncodeDiagStateFlags(State) &&
"diag state flags vary in single AST file");
 
+// If we ever serialize non-pragma mappings outside the initial state, the
+// code below will need to consider more than getDefaultMapping.
+assert(!IncludeNonPragmaStates ||
+   State == Diag.DiagStatesByLoc.FirstDiagState);
+
 unsigned  = DiagStateIDMap[State];
 Record.push_back(DiagStateID);
 
 if (DiagStateID == 0) {
   DiagStateID = ++CurrID;
+  SmallVector> Mappings;
 
   // Add a placeholder for the number of mappings.
   auto SizeIdx = Record.size();
   Record.emplace_back();
   for (const auto  : *State) {
-if (I.second.isPragma() || IncludeNonPragmaStates) {
-  Record.push_back(I.first);
-  Record.push_back(I.second.serialize());
-}
+// Maybe skip non-pragmas.
+if (!I.second.isPragma() && !IncludeNonPragmaStates)
+  continue;
+// Skip default mappings. We have a mapping for every diagnostic ever
+// emitted, regardless of 

[clang] 1ede7b4 - [clang][modules] Avoid serializing all diag mappings in non-deterministic order

2023-06-29 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2023-06-29T13:17:24-07:00
New Revision: 1ede7b47493f8d8548202e5f4e4a150c11e070fd

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

LOG: [clang][modules] Avoid serializing all diag mappings in non-deterministic 
order

When writing a pcm, we serialize diagnostic mappings in order to
accurately reproduce the diagnostic environment inside any headers from
that module. However, the diagnostic state mapping table contains
entries for every diagnostic ID ever accessed, while we only want to
serialize the ones that are actually modified from their default value.
Futher, we need to serialize them in a deterministic order.

rdar://111477511

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

Added: 
clang/test/Modules/diag-mappings.c

Modified: 
clang/include/clang/Basic/DiagnosticIDs.h
clang/lib/Basic/Diagnostic.cpp
clang/lib/Basic/DiagnosticIDs.cpp
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticIDs.h 
b/clang/include/clang/Basic/DiagnosticIDs.h
index a59ff25fe20ebb..bf4995175ef196 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -159,6 +159,10 @@ class DiagnosticMapping {
 Result.Severity = Bits & 0x7;
 return Result;
   }
+
+  bool operator==(DiagnosticMapping Other) const {
+return serialize() == Other.serialize();
+  }
 };
 
 /// Used for handling and querying diagnostic IDs.
@@ -208,6 +212,9 @@ class DiagnosticIDs : public RefCountedBase {
   /// default.
   static bool isDefaultMappingAsError(unsigned DiagID);
 
+  /// Get the default mapping for this diagnostic.
+  static DiagnosticMapping getDefaultMapping(unsigned DiagID);
+
   /// Determine whether the given built-in diagnostic ID is a Note.
   static bool isBuiltinNote(unsigned DiagID);
 

diff  --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index b2106b0eb66118..7a54d27ef9d8ee 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -160,6 +160,18 @@ void DiagnosticsEngine::ReportDelayed() {
   Report(ID) << DelayedDiagArg1 << DelayedDiagArg2 << DelayedDiagArg3;
 }
 
+DiagnosticMapping &
+DiagnosticsEngine::DiagState::getOrAddMapping(diag::kind Diag) {
+  std::pair Result =
+  DiagMap.insert(std::make_pair(Diag, DiagnosticMapping()));
+
+  // Initialize the entry if we added it.
+  if (Result.second)
+Result.first->second = DiagnosticIDs::getDefaultMapping(Diag);
+
+  return Result.first->second;
+}
+
 void DiagnosticsEngine::DiagStateMap::appendFirst(DiagState *State) {
   assert(Files.empty() && "not first");
   FirstDiagState = CurDiagState = State;

diff  --git a/clang/lib/Basic/DiagnosticIDs.cpp 
b/clang/lib/Basic/DiagnosticIDs.cpp
index ac08e98a278db7..e5667d57f8cff1 100644
--- a/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/clang/lib/Basic/DiagnosticIDs.cpp
@@ -256,7 +256,7 @@ CATEGORY(REFACTORING, ANALYSIS)
   return Found;
 }
 
-static DiagnosticMapping GetDefaultDiagMapping(unsigned DiagID) {
+DiagnosticMapping DiagnosticIDs::getDefaultMapping(unsigned DiagID) {
   DiagnosticMapping Info = DiagnosticMapping::Make(
   diag::Severity::Fatal, /*IsUser=*/false, /*IsPragma=*/false);
 
@@ -293,21 +293,6 @@ namespace {
   };
 }
 
-// Unfortunately, the split between DiagnosticIDs and Diagnostic is not
-// particularly clean, but for now we just implement this method here so we can
-// access GetDefaultDiagMapping.
-DiagnosticMapping &
-DiagnosticsEngine::DiagState::getOrAddMapping(diag::kind Diag) {
-  std::pair Result =
-  DiagMap.insert(std::make_pair(Diag, DiagnosticMapping()));
-
-  // Initialize the entry if we added it.
-  if (Result.second)
-Result.first->second = GetDefaultDiagMapping(Diag);
-
-  return Result.first->second;
-}
-
 static const StaticDiagCategoryRec CategoryNameTable[] = {
 #define GET_CATEGORY_TABLE
 #define CATEGORY(X, ENUM) { X, STR_SIZE(X, uint8_t) },
@@ -449,7 +434,7 @@ bool DiagnosticIDs::isBuiltinExtensionDiag(unsigned DiagID,
 return false;
 
   EnabledByDefault =
-  GetDefaultDiagMapping(DiagID).getSeverity() != diag::Severity::Ignored;
+  getDefaultMapping(DiagID).getSeverity() != diag::Severity::Ignored;
   return true;
 }
 
@@ -457,7 +442,7 @@ bool DiagnosticIDs::isDefaultMappingAsError(unsigned 
DiagID) {
   if (DiagID >= diag::DIAG_UPPER_LIMIT)
 return false;
 
-  return GetDefaultDiagMapping(DiagID).getSeverity() >= diag::Severity::Error;
+  return getDefaultMapping(DiagID).getSeverity() >= diag::Severity::Error;
 }
 
 /// getDescription - Given a diagnostic ID, return a description of the

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index ca0db085d94cc9..2f73eb526641a5 100644
--- 

[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

2023-06-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/docs/AMDGPUSupport.rst:54
+ - Defined if FMAF instruction is available (deprecated).
+   * - ``FP_FAST_FMAF``
+ - Defined if fast FMAF instruction is available.

The fma macro was actually from the opencl spec but never handled in the 
correct place


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

https://reviews.llvm.org/D154133

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


[PATCH] D154145: [HIP] Fix -mllvm option for device lld linker

2023-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, jhuber6.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added a subscriber: MaskRay.

currently clang passes -mllvm options to the device lld linker plugin
when compiling HIP. This is against default clang behavior
which is only passing -mllvm options to linker plugin specified through -Wl
options. This patch lets clang only pass -Xoffload-linker -mllvm= options
to device lld linker plugin.

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


https://reviews.llvm.org/D154145

Files:
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/test/Driver/hip-toolchain-mllvm.hip


Index: clang/test/Driver/hip-toolchain-mllvm.hip
===
--- clang/test/Driver/hip-toolchain-mllvm.hip
+++ clang/test/Driver/hip-toolchain-mllvm.hip
@@ -1,30 +1,47 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
 
+// Check only -Xoffload-linker -mllvm=* options are passed
+// to device lld linker.
+// -mllvm options are passed to clang only.
+
 // RUN: %clang -### --target=x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
-// RUN:   -mllvm -amdgpu-function-calls=0 \
+// RUN:   -mllvm -unroll-count=10 \
+// RUN:   -Xoffload-linker -mllvm=-inline-threshold=100 \
 // RUN:   %s 2>&1 | FileCheck %s
 
 // RUN: %clang -### --target=x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
-// RUN:   -fgpu-rdc -mllvm -amdgpu-function-calls=0 \
-// RUN:   %s 2>&1 | FileCheck -check-prefixes=CHECK,RDC %s
+// RUN:   -mllvm -unroll-count=10 \
+// RUN:   -Xoffload-linker -mllvm=-inline-threshold=100 \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=NEG %s
+
+// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -fgpu-rdc -mllvm -unroll-count=10 \
+// RUN:   -Xoffload-linker -mllvm=-inline-threshold=100 \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -fgpu-rdc -mllvm -unroll-count=10 \
+// RUN:   -Xoffload-linker -mllvm=-inline-threshold=100 \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=NEG %s
 
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: {{.*}} "-target-cpu" "gfx803"
-// CHECK-SAME: {{.*}} "-mllvm" "-amdgpu-function-calls=0" {{.*}}
-
-// CHECK-NOT: {{".*opt"}}
-// CHECK-NOT: {{".*llc"}}
-// RDC: [[LLD:".*lld.*"]] {{.*}} "-plugin-opt=-amdgpu-function-calls=0"
+// CHECK-SAME: {{.*}} "-mllvm" "-unroll-count=10" {{.*}}
+// CHECK: [[LLD:".*lld.*"]] {{.*}}"-m" "elf64_amdgpu"{{.*}} 
"-plugin-opt=-inline-threshold=100"
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: {{.*}} "-target-cpu" "gfx900"
-// CHECK-SAME: {{.*}} "-mllvm" "-amdgpu-function-calls=0" {{.*}}
+// CHECK-SAME: {{.*}} "-mllvm" "-unroll-count=10" {{.*}}
+// CHECK: [[LLD:".*lld.*"]] {{.*}} "-plugin-opt=-inline-threshold=100"
 
-// CHECK-NOT: {{".*opt"}}
-// CHECK-NOT: {{".*llc"}}
-// RDC: [[LLD:".*lld.*"]] {{.*}} "-plugin-opt=-amdgpu-function-calls=0"
+// NEG-NOT: {{".*opt"}}
+// NEG-NOT: {{".*llc"}}
+// NEG-NOT: "-plugin-opt=-unroll-count=10"
+// NEG-NOT: "-m" "elf_x86_64"{{.*}} "-plugin-opt=-inline-threshold=100"
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -142,11 +142,6 @@
   if (IsThinLTO)
 LldArgs.push_back(Args.MakeArgString("-plugin-opt=-force-import-all"));
 
-  for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
-LldArgs.push_back(
-Args.MakeArgString(Twine("-plugin-opt=") + A->getValue(0)));
-  }
-
   if (C.getDriver().isSaveTempsEnabled())
 LldArgs.push_back("-save-temps");
 
@@ -165,7 +160,12 @@
   LldArgs.push_back("--whole-archive");
 
   for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker)) {
-LldArgs.push_back(Arg->getValue(1));
+StringRef ArgVal = Arg->getValue(1);
+if (ArgVal.startswith("-mllvm=")) {
+  ArgVal = ArgVal.substr(strlen("-mllvm="));
+  LldArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=") + ArgVal));
+} else
+  LldArgs.push_back(Args.MakeArgString(ArgVal));
 Arg->claim();
   }
 


Index: clang/test/Driver/hip-toolchain-mllvm.hip
===
--- clang/test/Driver/hip-toolchain-mllvm.hip
+++ clang/test/Driver/hip-toolchain-mllvm.hip
@@ -1,30 +1,47 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
 
+// Check only -Xoffload-linker -mllvm=* options are passed
+// to device lld linker.
+// -mllvm options are passed to clang only.
+
 // RUN: %clang -### --target=x86_64-linux-gnu \
 // 

[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

2023-06-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/docs/AMDGPUSupport.rst:33
+   * - ``__AMD__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGPU__``

FWIW, this arguably confusing use of __AMD__, and duplication of __AMDGPU__, 
should be deprecated and removed. Or at least not advocated...



Comment at: clang/docs/AMDGPUSupport.rst:62
+ - Defined if fast FMA instruction is available.
+   * - ``__AMDGCN_WAVEFRONT_SIZE``
+ - Defines the wavefront size. Allowed values are 32 and 64.

Any reason this one does not end in `__`?


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

https://reviews.llvm.org/D154133

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


[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-06-29 Thread Rashmi Mudduluru via Phabricator via cfe-commits
t-rasmud added inline comments.



Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp:251
+}
+// CHECK-NOT: fix-it:{{.*}}:{[[@LINE-1]]

Does this patch handle virtual methods? Ideally we'd like the fixed methods to 
have the same subtyping relations as the original method. Does it make sense to 
have test cases with virtual methods as part of this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153059

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


[PATCH] D89918: Fix issue: clang-format result is not consistent if "// clang-format off" is followed by macro definition.

2023-06-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D89918#4460401 , @MyDeveloperDay 
wrote:

> @owenpan @HazardyKnusperkeks @rymiel what are your feeling on how we should 
> close old clang-format reviews like this?  (@aaron.ballman any thoughts on 
> how it should be done?)
>
> we end up with lots of reviews that either get metaphorically abandoned, 
> (without actually being abandoned).. should we have some sort of rule, that 
> says reviews left for N months with no activity are automatically abandoned 
> (to do this you have to comindeer the revision, which I don't like doing)
>
> Part of me just wants to consume the unit tests (if they pass).. do you think 
> we should do anything? what about issues we effectively are saying "no to" 
> like D147969  but are then not abandoned by 
> the author?

I don't think we have any sort of community policy on how to handle this, it's 
basically a case by case basis. If someone submits a patch and then (explicitly 
or implicitly) abandons the work, I believe it is acceptable to grab changes of 
value out of the patch and apply them to the code base as you see fit (the user 
contributing the patch expected their changes to make it in to the project, so 
I doubt anyone would be upset in practice). I would recommend linking to the 
review where the code originated from when committing the changes so there's 
good attribution for the commit.

To handle the review itself, you can commandeer the patch to abandon it or you 
can resign as a reviewer from the revision, but that's about the only two ways 
I know of to address that. Both approaches have social pressure (commandeering 
or resigning are not the easiest decisions for folks to make), so my guess is 
this will be inconsistently handled which suggests that resigning from the 
revision is the better approach to prefer as that gets you the work queue you 
want without requiring others to play along consistently. But I think either 
approach is acceptable -- I've seen folks do it both ways.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89918

___
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-06-29 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

> They'd already have had a chance to deal with their code when this was a 
> warning-default-error without "ShowInSystemHeaders"? (or, if the yhaven't 
> picked up a new compiler often enough, and they go from "a warning we didn't 
> care about" to "warning-default-error-with-ShowInSystemHeaders" - they're 
> still better off than if it'd gone straight to hard error, some chance to 
> cleanup while disabling the warning/error before picking up a compiler 
> version that makes it a hard error)

+1 for this. Having no intermediate step for developers to find/fix the warning 
in system headers (short of recompiling Clang with different settings) seems 
really rough for very downstream folks.

One other thought I had was whether this should have a different way to 
suppress a "severe" warning (i.e. 
`-fno-really-I-know-I-should-fix-this-UB-hole` a la the now defunct flag for 
automatic initialization), because it is far too common for downstream 
developers of all sorts to encounter a warning once, see that they just don't 
care about that specific instance, and then slap on a `-Wno-foo` to their 
project forever. It almost seems like there should be a strongly-worded opt-out 
for these severe warning suppressions that might be behavior-changing (even if 
we later remove the ability for users to suppress them). I know that compiler 
developers don't like adding flags (let alone confusing ones for behaviors that 
we know should have been strict from the start), but it seems like there might 
be some tradeoff here that is worth it, considering how much other downstream 
cleanup might be needed for some compiler vendors.


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


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

2023-06-29 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan added inline comments.



Comment at: clang/docs/HIPSupport.rst:33
+
+   clang -c --offload-arch=gfx906 test.hip -o test.o
+

can we add -xhip to enable HIP for files without the .hip file ext?



Comment at: clang/docs/HIPSupport.rst:56
+Environment Variables
+=
+

I'd suggest adding a section to cover compiler options to pass various hip/rocm 
related paths and that using the compiler options would be a much more 
preferable alternative.



Comment at: clang/docs/HIPSupport.rst:87
+   * - ``__HIPCC__``
+ - This macro indicates that the code is being compiled using the HIP 
compiler.
+   * - ``__HIP_MEMORY_SCOPE_SINGLETHREAD``

I think this macro is essentially an alias to __HIP__?



Comment at: clang/docs/HIPSupport.rst:99
+   * - ``__HIP_DEVICE_COMPILE__``
+ - This macro is defined when the code is being compiled for a HIP device.
+   * - ``__HIP_NO_IMAGE_SUPPORT``

It might be helpful to provide more context here as to how a HIP source file 
gets compiled (once for the host and then once for each device arch).  Also I'd 
suggest moving this up closer to __HIP__ given they are related.


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] D154014: [SpecialCaseList] Use Globs instead of Regex

2023-06-29 Thread Ellis Hoag via Phabricator via cfe-commits
ellis added a comment.

In D154014#4461076 , @rupprecht wrote:

> In D154014#4457883 , @MaskRay wrote:
>
>>> This is a breaking change since some SCLs might use .* or (abc|def) which 
>>> are supported regexes but not valid globs. Since we have just cut clang 
>>> 16.x this is a good time to make this change.
>>
>> My user has some ignore lists, but there is no `^[a-z]+:.*\(` or 
>> `^[a-z]+:\.` occurrence, so this change is likely safe for us.
>
> I think I'm looking at the same lists, and I see plenty of `.*` in the 
> sanitizer exclusion lists. Also a few cases of `(abc|def|...)`. IIUC, those 
> would both be broken by this -- instead of `.*` meaning "any character any 
> number of times" (regex) it would mean "dot followed by any number of 
> characters" (glob), right? And the `(abc|...)` would just be that literal 
> text, not matching the individual parts?
>
> If my understanding of that is correct, I don't think this is a good change 
> -- there's possibly plenty of configs out there that assume this is regex, 
> and there doesn't seem to be sufficient motivation to just break those. But I 
> can see that globs are useful for the examples posted in the patch 
> description. Is it possible to have some middle ground, e.g. default to regex 
> but allow a config at the top of sanitizer lists to interpret future patterns 
> as globs instead?

If a sanitizer list currently has `.*` it will be replaced with `..*` here 

 meaning that it matches one or more characters, so those lists may already be 
broken. This is exactly the confusion we would like to avoid. And you are 
correct that `(abc|def)` will be treated as a literal with this change, the but 
fix to `{abc,def}` is trivial.

That's a nice idea to add a config at the top to specify glob or regex to give 
users more time to migrate their lists.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154014

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


[PATCH] D153556: [OPENMP52] Initial support for doacross clause.

2023-06-29 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 closed this revision.
jyu2 added a comment.

Checked in with rG085845a2acbe 



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

https://reviews.llvm.org/D153556

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


[PATCH] D153674: [dataflow] Disallow implicit copy of Environment, use fork() instead

2023-06-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Sorry about the delay, and thanks for the `.i`.

It took me a while to work out what was going on, but it looks like it's just a 
bug where GCC forgets to automatic-move.
Fixed in 2f7d30dee8262746c3e8ee1f6f25be8c1ace9990 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153674

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


[clang] 2f7d30d - [dataflow] fix compile on gcc7

2023-06-29 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-06-29T21:20:53+02:00
New Revision: 2f7d30dee8262746c3e8ee1f6f25be8c1ace9990

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

LOG: [dataflow] fix compile on gcc7

Reported on https://reviews.llvm.org/D153674
This returned expression is move-eligible, this is a bug in old GCC.

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index d2908725d79b3..9e48df1b994dc 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -583,7 +583,7 @@ runTypeErasedDataflowAnalysis(
 }
   }
 
-  return BlockStates;
+  return std::move(BlockStates);
 }
 
 } // namespace dataflow



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


[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

2023-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 535952.
yaxunl added a comment.

remove redundant text


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

https://reviews.llvm.org/D154133

Files:
  clang/docs/AMDGPUSupport.rst


Index: clang/docs/AMDGPUSupport.rst
===
--- /dev/null
+++ clang/docs/AMDGPUSupport.rst
@@ -0,0 +1,67 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.part { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: part
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+AMDGPU Support
+==
+
+Clang supports OpenCL, HIP and OpenMP on amdgpu target.
+
+
+Predefined Macros
+=
+
+
+.. list-table::
+   :header-rows: 1
+
+   * - Macro
+ - Description
+   * - ``__AMD__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGPU__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGCN__``
+ - Defined if the GPU target is AMDGCN.
+   * - ``__R600__``
+ - Defined if the GPU target is R600.
+   * - ````
+ - Defined with the name of the architecture (e.g., ``__gfx906__`` for the 
gfx906 architecture).
+   * - ````
+ - Defines the GFX family (e.g., for gfx906, this macro would be 
``__GFX9__``).
+   * - ``__amdgcn_processor__``
+ - Defined with the processor name as a string (e.g., ``"gfx906"``).
+   * - ``__amdgcn_target_id__``
+ - Defined with the target ID as a string.
+   * - ``__amdgcn_feature___``
+ - Defined for each supported target feature. The value is 1 if the 
feature is enabled and 0 if it is disabled. Allowed feature names are sramecc 
and xnack.
+   * - ``__AMDGCN_UNSAFE_FP_ATOMICS__``
+ - Defined if unsafe floating-point atomics are allowed.
+   * - ``__HAS_FMAF__``
+ - Defined if FMAF instruction is available (deprecated).
+   * - ``FP_FAST_FMAF``
+ - Defined if fast FMAF instruction is available.
+   * - ``__HAS_LDEXPF__``
+ - Defined if LDEXPF instruction is available (deprecated).
+   * - ``__HAS_FP64__``
+ - Defined if FP64 instruction is available (deprecated).
+   * - ``FP_FAST_FMA``
+ - Defined if fast FMA instruction is available.
+   * - ``__AMDGCN_WAVEFRONT_SIZE``
+ - Defines the wavefront size. Allowed values are 32 and 64.
+   * - ``__AMDGCN_CUMODE__``
+ - Defines as 1 if the CU mode is enabled and 0 if the WGP mode is enabled.
+
+Please note that the specific architecture and feature names will vary 
depending on the GPU. Also, some macros are deprecated and may be removed in 
future releases.


Index: clang/docs/AMDGPUSupport.rst
===
--- /dev/null
+++ clang/docs/AMDGPUSupport.rst
@@ -0,0 +1,67 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.part { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: part
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+AMDGPU Support
+==
+
+Clang supports OpenCL, HIP and OpenMP on amdgpu target.
+
+
+Predefined Macros
+=
+
+
+.. list-table::
+   :header-rows: 1
+
+   * - Macro
+ - Description
+   * - ``__AMD__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGPU__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGCN__``
+ - Defined if the GPU target is AMDGCN.
+   * - ``__R600__``
+ - Defined if the GPU target is R600.
+   * - ````
+ - Defined with the name of the architecture (e.g., ``__gfx906__`` for the gfx906 architecture).
+   * - ````
+ - Defines the GFX family (e.g., for gfx906, this macro would be ``__GFX9__``).
+   * - ``__amdgcn_processor__``
+ - Defined with the processor name as a string (e.g., ``"gfx906"``).
+   * - ``__amdgcn_target_id__``
+ - Defined with the target ID as a string.
+   * - ``__amdgcn_feature___``
+ - Defined for each supported target feature. The value is 1 if the feature is enabled and 0 if it is disabled. Allowed feature names are sramecc and xnack.
+   * - ``__AMDGCN_UNSAFE_FP_ATOMICS__``
+ - Defined if unsafe floating-point atomics are allowed.
+   * - ``__HAS_FMAF__``
+ - Defined if FMAF instruction is available (deprecated).
+   * - ``FP_FAST_FMAF``
+ - Defined if fast FMAF instruction is available.
+   * - ``__HAS_LDEXPF__``
+ - Defined if LDEXPF instruction is available (deprecated).
+   * - ``__HAS_FP64__``
+ - Defined if FP64 instruction is available (deprecated).
+   * - ``FP_FAST_FMA``
+ - Defined if fast FMA instruction is available.
+   * - ``__AMDGCN_WAVEFRONT_SIZE``
+ - Defines the wavefront size. Allowed values are 32 and 64.
+   * - ``__AMDGCN_CUMODE__``
+ - Defines as 1 if the CU mode is enabled and 0 if the WGP mode is enabled.
+
+Please note that the specific 

[PATCH] D154134: [clang] Fix ASTUnit working directory handling

2023-06-29 Thread Hamish Knight via Phabricator via cfe-commits
hamishknight created this revision.
hamishknight added reviewers: bnbarham, benlangmuir.
hamishknight added a project: clang.
Herald added a project: All.
hamishknight requested review of this revision.
Herald added a subscriber: cfe-commits.

Fix a couple of issues with the handling of the current working directory in 
ASTUnit:

- Use `createPhysicalFileSystem` instead of `getRealFileSystem` to avoid 
affecting the process' current working directory, and set it at the top of 
`ASTUnit::LoadFromCommandLine` such that the driver used for argument parsing 
and the ASTUnit share the same VFS. This ensures that '-working-directory' 
correctly sets the VFS working directory in addition to the FileManager working 
directory.
- Ensure we preserve the FileSystemOptions set on the FileManager when 
re-creating it (as `ASTUnit::Reparse` will clear the currently set FileManager).

rdar://110697657


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154134

Files:
  clang/lib/Frontend/ASTUnit.cpp
  clang/unittests/Frontend/ASTUnitTest.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/ReparseWorkingDirTest.cpp

Index: clang/unittests/Frontend/ReparseWorkingDirTest.cpp
===
--- /dev/null
+++ clang/unittests/Frontend/ReparseWorkingDirTest.cpp
@@ -0,0 +1,116 @@
+//-- unittests/Frontend/ReparseWorkingDirTest.cpp - FrontendAction tests =//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/FrontendOptions.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+class ReparseWorkingDirTest : public ::testing::Test {
+  IntrusiveRefCntPtr VFS;
+  std::shared_ptr PCHContainerOpts;
+
+public:
+  void SetUp() override { VFS = new vfs::InMemoryFileSystem(); }
+  void TearDown() override {}
+
+  void setWorkingDirectory(StringRef Path) {
+VFS->setCurrentWorkingDirectory(Path);
+  }
+
+  void AddFile(const std::string , const std::string ) {
+::time_t now;
+::time();
+VFS->addFile(Filename, now,
+ MemoryBuffer::getMemBufferCopy(Contents, Filename));
+  }
+
+  std::unique_ptr ParseAST(StringRef EntryFile) {
+PCHContainerOpts = std::make_shared();
+auto CI = std::make_shared();
+CI->getFrontendOpts().Inputs.push_back(FrontendInputFile(
+EntryFile, FrontendOptions::getInputKindForExtension(
+   llvm::sys::path::extension(EntryFile).substr(1;
+
+CI->getHeaderSearchOpts().AddPath("headers",
+  frontend::IncludeDirGroup::Quoted,
+  /*isFramework*/ false,
+  /*IgnoreSysRoot*/ false);
+
+CI->getFileSystemOpts().WorkingDir = *VFS->getCurrentWorkingDirectory();
+CI->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+
+IntrusiveRefCntPtr Diags(
+CompilerInstance::createDiagnostics(new DiagnosticOptions,
+new DiagnosticConsumer));
+
+FileManager *FileMgr = new FileManager(CI->getFileSystemOpts(), VFS);
+
+std::unique_ptr AST = ASTUnit::LoadFromCompilerInvocation(
+CI, PCHContainerOpts, Diags, FileMgr, false, CaptureDiagsKind::None,
+/*PrecompilePreambleAfterNParses=*/1);
+return AST;
+  }
+
+  bool ReparseAST(const std::unique_ptr ) {
+bool reparseFailed =
+AST->Reparse(PCHContainerOpts, /*RemappedFiles*/ {}, VFS);
+return !reparseFailed;
+  }
+};
+
+TEST_F(ReparseWorkingDirTest, ReparseWorkingDir) {
+  // Setup the working directory path. We use '//root/' to allow the path to be
+  // valid on both Windows and Unix. We need the trailing slash for the path
+  // to be treated as absolute.
+  SmallString<16> WorkingDir;
+  llvm::sys::path::append(WorkingDir, "//root",
+  llvm::sys::path::get_separator());
+  setWorkingDirectory(WorkingDir);
+
+  SmallString<32> Header;
+  llvm::sys::path::append(Header, WorkingDir, "headers", "header.h");
+
+  SmallString<32> MainName;
+  llvm::sys::path::append(MainName, WorkingDir, "main.cpp");
+
+  AddFile(MainName.str().str(), R"cpp(
+#include "header.h"
+int main() { return foo(); }
+)cpp");
+  AddFile(Header.str().str(), R"h(
+static int foo() { return 0; }
+)h");
+
+  // Parse the main 

[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

2023-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: b-sumner, arsenm, tra, scchan.
Herald added subscribers: kerbowa, tpr, dstuttard, jvesely, kzhuravl.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added subscribers: jplehr, sstefan1, wdng.
Herald added a reviewer: jdoerfert.

start with predefined macros


https://reviews.llvm.org/D154133

Files:
  clang/docs/AMDGPUSupport.rst


Index: clang/docs/AMDGPUSupport.rst
===
--- /dev/null
+++ clang/docs/AMDGPUSupport.rst
@@ -0,0 +1,69 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.part { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: part
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+AMDGPU Support
+==
+
+Clang supports OpenCL, HIP and OpenMP on amdgpu target.
+
+
+Predefined Macros
+=
+
+AMDGPU Predefined Macros
+
+
+.. list-table::
+   :header-rows: 1
+
+   * - Macro
+ - Description
+   * - ``__AMD__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGPU__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGCN__``
+ - Defined if the GPU target is AMDGCN.
+   * - ``__R600__``
+ - Defined if the GPU target is R600.
+   * - ````
+ - Defined with the name of the architecture (e.g., ``__gfx906__`` for the 
gfx906 architecture).
+   * - ````
+ - Defines the GFX family (e.g., for gfx906, this macro would be 
``__GFX9__``).
+   * - ``__amdgcn_processor__``
+ - Defined with the processor name as a string (e.g., ``"gfx906"``).
+   * - ``__amdgcn_target_id__``
+ - Defined with the target ID as a string.
+   * - ``__amdgcn_feature___``
+ - Defined for each supported target feature. The value is 1 if the 
feature is enabled and 0 if it is disabled. Allowed feature names are sramecc 
and xnack.
+   * - ``__AMDGCN_UNSAFE_FP_ATOMICS__``
+ - Defined if unsafe floating-point atomics are allowed.
+   * - ``__HAS_FMAF__``
+ - Defined if FMAF instruction is available (deprecated).
+   * - ``FP_FAST_FMAF``
+ - Defined if fast FMAF instruction is available.
+   * - ``__HAS_LDEXPF__``
+ - Defined if LDEXPF instruction is available (deprecated).
+   * - ``__HAS_FP64__``
+ - Defined if FP64 instruction is available (deprecated).
+   * - ``FP_FAST_FMA``
+ - Defined if fast FMA instruction is available.
+   * - ``__AMDGCN_WAVEFRONT_SIZE``
+ - Defines the wavefront size. Allowed values are 32 and 64.
+   * - ``__AMDGCN_CUMODE__``
+ - Defines as 1 if the CU mode is enabled and 0 if the WGP mode is enabled.
+
+Please note that the specific architecture and feature names will vary 
depending on the GPU. Also, some macros are deprecated and may be removed in 
future releases.


Index: clang/docs/AMDGPUSupport.rst
===
--- /dev/null
+++ clang/docs/AMDGPUSupport.rst
@@ -0,0 +1,69 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.part { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: part
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+AMDGPU Support
+==
+
+Clang supports OpenCL, HIP and OpenMP on amdgpu target.
+
+
+Predefined Macros
+=
+
+AMDGPU Predefined Macros
+
+
+.. list-table::
+   :header-rows: 1
+
+   * - Macro
+ - Description
+   * - ``__AMD__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGPU__``
+ - Indicates that the code is being compiled for an AMD GPU.
+   * - ``__AMDGCN__``
+ - Defined if the GPU target is AMDGCN.
+   * - ``__R600__``
+ - Defined if the GPU target is R600.
+   * - ````
+ - Defined with the name of the architecture (e.g., ``__gfx906__`` for the gfx906 architecture).
+   * - ````
+ - Defines the GFX family (e.g., for gfx906, this macro would be ``__GFX9__``).
+   * - ``__amdgcn_processor__``
+ - Defined with the processor name as a string (e.g., ``"gfx906"``).
+   * - ``__amdgcn_target_id__``
+ - Defined with the target ID as a string.
+   * - ``__amdgcn_feature___``
+ - Defined for each supported target feature. The value is 1 if the feature is enabled and 0 if it is disabled. Allowed feature names are sramecc and xnack.
+   * - ``__AMDGCN_UNSAFE_FP_ATOMICS__``
+ - Defined if unsafe floating-point atomics are allowed.
+   * - ``__HAS_FMAF__``
+ - Defined if FMAF instruction is available (deprecated).
+   * - ``FP_FAST_FMAF``
+ - Defined if fast FMAF instruction is available.
+   * - ``__HAS_LDEXPF__``
+ - Defined if LDEXPF instruction is available (deprecated).
+   * - ``__HAS_FP64__``
+ - Defined if FP64 instruction is available (deprecated).
+   * - ``FP_FAST_FMA``
+ - Defined 

[clang] 085845a - [OMP5.2] Initial support for doacross clause.

2023-06-29 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2023-06-29T11:58:17-07:00
New Revision: 085845a2acbefd26d5c229338225dfd76e2c2df3

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

LOG: [OMP5.2] Initial support for doacross clause.

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/ordered_ast_print.cpp
clang/test/OpenMP/ordered_messages.cpp
clang/tools/libclang/CIndex.cpp
flang/lib/Semantics/check-omp-structure.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 627e9025c11289..0bea21270692cf 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -9046,6 +9046,132 @@ class OMPXDynCGroupMemClause
   Expr *getSize() const { return getStmtAs(); }
 };
 
+/// This represents the 'doacross' clause for the '#pragma omp ordered'
+/// directive.
+///
+/// \code
+/// #pragma omp ordered doacross(sink: i-1, j-1)
+/// \endcode
+/// In this example directive '#pragma omp ordered' with clause 'doacross' with
+/// a dependence-type 'sink' and loop-iteration vector expressions i-1 and j-1.
+class OMPDoacrossClause final
+: public OMPVarListClause,
+  private llvm::TrailingObjects {
+  friend class OMPClauseReader;
+  friend OMPVarListClause;
+  friend TrailingObjects;
+
+  /// Dependence type (sink or source).
+  OpenMPDoacrossClauseModifier DepType = OMPC_DOACROSS_unknown;
+
+  /// Dependence type location.
+  SourceLocation DepLoc;
+
+  /// Colon location.
+  SourceLocation ColonLoc;
+
+  /// Number of loops, associated with the doacross clause.
+  unsigned NumLoops = 0;
+
+  /// Build clause with number of expressions \a N.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param EndLoc Ending location of the clause.
+  /// \param N Number of expressions in the clause.
+  /// \param NumLoops Number of loops associated with the clause.
+  OMPDoacrossClause(SourceLocation StartLoc, SourceLocation LParenLoc,
+SourceLocation EndLoc, unsigned N, unsigned NumLoops)
+  : OMPVarListClause(llvm::omp::OMPC_doacross, StartLoc,
+LParenLoc, EndLoc, N),
+NumLoops(NumLoops) {}
+
+  /// Build an empty clause.
+  ///
+  /// \param N Number of expressions in the clause.
+  /// \param NumLoops Number of loops associated with the clause.
+  explicit OMPDoacrossClause(unsigned N, unsigned NumLoops)
+  : OMPVarListClause(llvm::omp::OMPC_doacross,
+SourceLocation(), SourceLocation(),
+SourceLocation(), N),
+NumLoops(NumLoops) {}
+
+  /// Set dependence type.
+  void setDependenceType(OpenMPDoacrossClauseModifier M) { DepType = M; }
+
+  /// Set dependence type location.
+  void setDependenceLoc(SourceLocation Loc) { DepLoc = Loc; }
+
+  /// Set colon location.
+  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
+
+public:
+  /// Creates clause with a list of expressions \a VL.
+  ///
+  /// \param C AST context.
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param EndLoc Ending location of the clause.
+  /// \param DepType The dependence type.
+  /// \param DepLoc Location of the dependence type.
+  /// \param ColonLoc Location of ':'.
+  /// \param VL List of references to the expressions.
+  /// \param NumLoops Number of loops that associated with the clause.
+  static OMPDoacrossClause *
+  Create(const ASTContext , SourceLocation StartLoc, SourceLocation 
LParenLoc,
+ SourceLocation EndLoc, OpenMPDoacrossClauseModifier DepType,
+ SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef VL,
+ unsigned NumLoops);
+
+  /// Creates an empty clause with \a N expressions.
+  ///
+  /// \param C AST context.
+  /// \param N The number of expressions.
+  /// \param NumLoops Number of loops that is associated with this clause.
+  static OMPDoacrossClause *CreateEmpty(const ASTContext , unsigned N,
+unsigned NumLoops);
+
+  /// Get dependence type.
+  

[PATCH] D154077: [HIP] Fix version detection for old HIP-PATH

2023-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rG41a1625e07e8: [HIP] Fix version detection for old HIP-PATH 
(authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D154077?vs=535756=535945#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154077

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/hip-version.hip


Index: clang/test/Driver/hip-version.hip
===
--- clang/test/Driver/hip-version.hip
+++ clang/test/Driver/hip-version.hip
@@ -22,11 +22,17 @@
 // RUN: mkdir -p %t/Inputs
 // RUN: cp -r %S/Inputs/rocm %t/Inputs
 // RUN: mkdir -p %t/Inputs/rocm/share/hip
+// RUN: mkdir -p %t/Inputs/rocm/hip
 // RUN: mv %t/Inputs/rocm/bin/.hipVersion %t/Inputs/rocm/share/hip/version
 // RUN: %clang -v --rocm-path=%t/Inputs/rocm 2>&1 \
 // RUN:   | FileCheck -check-prefixes=FOUND %s
+// RUN: %clang -v --hip-path=%t/Inputs/rocm 2>&1 \
+// RUN:   | FileCheck -check-prefixes=FOUND %s
+// RUN: %clang -v --hip-path=%t/Inputs/rocm/hip 2>&1 \
+// RUN:   | FileCheck -check-prefixes=HIP-PATH %s
 
 // FOUND: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd
+// HIP-PATH: Found HIP installation: {{.*Inputs.*rocm.*hip}}, version 
3.6.20214-a2917cd
 
 // When --rocm-path is set and .hipVersion is not found, use default version
 
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -461,10 +461,21 @@
 SharePath = InstallPath;
 llvm::sys::path::append(SharePath, "share");
 
+// Get parent of InstallPath and append "share"
+SmallString<0> ParentSharePath = llvm::sys::path::parent_path(InstallPath);
+llvm::sys::path::append(ParentSharePath, "share");
+
+auto Append = [](SmallString<0> , const Twine , const Twine  = "",
+ const Twine  = "", const Twine  = "") {
+  SmallString<0> newpath = path;
+  llvm::sys::path::append(newpath, a, b, c, d);
+  return newpath;
+};
 // If HIP version file can be found and parsed, use HIP version from there.
 for (const auto  :
- {std::string(SharePath) + "/hip/version",
-  std::string(BinPath) + "/.hipVersion"}) {
+ {Append(SharePath, "hip", "version"),
+  Append(ParentSharePath, "hip", "version"),
+  Append(BinPath, ".hipVersion")}) {
   llvm::ErrorOr> VersionFile =
   FS.getBufferForFile(VersionFilePath);
   if (!VersionFile)


Index: clang/test/Driver/hip-version.hip
===
--- clang/test/Driver/hip-version.hip
+++ clang/test/Driver/hip-version.hip
@@ -22,11 +22,17 @@
 // RUN: mkdir -p %t/Inputs
 // RUN: cp -r %S/Inputs/rocm %t/Inputs
 // RUN: mkdir -p %t/Inputs/rocm/share/hip
+// RUN: mkdir -p %t/Inputs/rocm/hip
 // RUN: mv %t/Inputs/rocm/bin/.hipVersion %t/Inputs/rocm/share/hip/version
 // RUN: %clang -v --rocm-path=%t/Inputs/rocm 2>&1 \
 // RUN:   | FileCheck -check-prefixes=FOUND %s
+// RUN: %clang -v --hip-path=%t/Inputs/rocm 2>&1 \
+// RUN:   | FileCheck -check-prefixes=FOUND %s
+// RUN: %clang -v --hip-path=%t/Inputs/rocm/hip 2>&1 \
+// RUN:   | FileCheck -check-prefixes=HIP-PATH %s
 
 // FOUND: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd
+// HIP-PATH: Found HIP installation: {{.*Inputs.*rocm.*hip}}, version 3.6.20214-a2917cd
 
 // When --rocm-path is set and .hipVersion is not found, use default version
 
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -461,10 +461,21 @@
 SharePath = InstallPath;
 llvm::sys::path::append(SharePath, "share");
 
+// Get parent of InstallPath and append "share"
+SmallString<0> ParentSharePath = llvm::sys::path::parent_path(InstallPath);
+llvm::sys::path::append(ParentSharePath, "share");
+
+auto Append = [](SmallString<0> , const Twine , const Twine  = "",
+ const Twine  = "", const Twine  = "") {
+  SmallString<0> newpath = path;
+  llvm::sys::path::append(newpath, a, b, c, d);
+  return newpath;
+};
 // If HIP version file can be found and parsed, use HIP version from there.
 for (const auto  :
- {std::string(SharePath) + "/hip/version",
-  std::string(BinPath) + "/.hipVersion"}) {
+ {Append(SharePath, "hip", "version"),
+  Append(ParentSharePath, "hip", "version"),
+  Append(BinPath, ".hipVersion")}) {
   llvm::ErrorOr> VersionFile =
   

[clang] 41a1625 - [HIP] Fix version detection for old HIP-PATH

2023-06-29 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2023-06-29T14:57:26-04:00
New Revision: 41a1625e07e8b20dafec11f0d138031106abfad0

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

LOG: [HIP] Fix version detection for old HIP-PATH

ROCm used to install components under individual directories,
e.g. HIP installed to /opt/rocm/hip and rocblas installed to
/opt/rocm/rocblas. ROCm has transitioned to a flat directory
structure where all components are installed to /opt/rocm.
HIP-PATH and --hip-path are supposed to be /opt/rocm as
clang detect HIP version by /opt/rocm/share/hip/version.
However, some existing HIP app still uses HIP-PATH=/opt/rocm/hip.
To avoid regression, clang will also try detect share/hip/version
under the parent directory of HIP-PATH or --hip-path.
This way, the detection will work for both new HIP-PATH and
old HIP-PATH.

Reviewed by: Artem Belevich

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

Fixes: SWDEV-407757

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/test/Driver/hip-version.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index b3fb7477c793c..4684068b817b4 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -461,10 +461,21 @@ void RocmInstallationDetector::detectHIPRuntime() {
 SharePath = InstallPath;
 llvm::sys::path::append(SharePath, "share");
 
+// Get parent of InstallPath and append "share"
+SmallString<0> ParentSharePath = llvm::sys::path::parent_path(InstallPath);
+llvm::sys::path::append(ParentSharePath, "share");
+
+auto Append = [](SmallString<0> , const Twine , const Twine  = "",
+ const Twine  = "", const Twine  = "") {
+  SmallString<0> newpath = path;
+  llvm::sys::path::append(newpath, a, b, c, d);
+  return newpath;
+};
 // If HIP version file can be found and parsed, use HIP version from there.
 for (const auto  :
- {std::string(SharePath) + "/hip/version",
-  std::string(BinPath) + "/.hipVersion"}) {
+ {Append(SharePath, "hip", "version"),
+  Append(ParentSharePath, "hip", "version"),
+  Append(BinPath, ".hipVersion")}) {
   llvm::ErrorOr> VersionFile =
   FS.getBufferForFile(VersionFilePath);
   if (!VersionFile)

diff  --git a/clang/test/Driver/hip-version.hip 
b/clang/test/Driver/hip-version.hip
index 474e0f2241eaa..ccefedf816d45 100644
--- a/clang/test/Driver/hip-version.hip
+++ b/clang/test/Driver/hip-version.hip
@@ -22,11 +22,17 @@
 // RUN: mkdir -p %t/Inputs
 // RUN: cp -r %S/Inputs/rocm %t/Inputs
 // RUN: mkdir -p %t/Inputs/rocm/share/hip
+// RUN: mkdir -p %t/Inputs/rocm/hip
 // RUN: mv %t/Inputs/rocm/bin/.hipVersion %t/Inputs/rocm/share/hip/version
 // RUN: %clang -v --rocm-path=%t/Inputs/rocm 2>&1 \
 // RUN:   | FileCheck -check-prefixes=FOUND %s
+// RUN: %clang -v --hip-path=%t/Inputs/rocm 2>&1 \
+// RUN:   | FileCheck -check-prefixes=FOUND %s
+// RUN: %clang -v --hip-path=%t/Inputs/rocm/hip 2>&1 \
+// RUN:   | FileCheck -check-prefixes=HIP-PATH %s
 
 // FOUND: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd
+// HIP-PATH: Found HIP installation: {{.*Inputs.*rocm.*hip}}, version 
3.6.20214-a2917cd
 
 // When --rocm-path is set and .hipVersion is not found, use default version
 



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


[PATCH] D154014: [SpecialCaseList] Use Globs instead of Regex

2023-06-29 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

In D154014#4457883 , @MaskRay wrote:

>> This is a breaking change since some SCLs might use .* or (abc|def) which 
>> are supported regexes but not valid globs. Since we have just cut clang 16.x 
>> this is a good time to make this change.
>
> My user has some ignore lists, but there is no `^[a-z]+:.*\(` or `^[a-z]+:\.` 
> occurrence, so this change is likely safe for us.

I think I'm looking at the same lists, and I see plenty of `.*` in the 
sanitizer exclusion lists. Also a few cases of `(abc|def|...)`. IIUC, those 
would both be broken by this -- instead of `.*` meaning "any character any 
number of times" (regex) it would mean "dot followed by any number of 
characters" (glob), right? And the `(abc|...)` would just be that literal text, 
not matching the individual parts?

If my understanding of that is correct, I don't think this is a good change -- 
there's possibly plenty of configs out there that assume this is regex, and 
there doesn't seem to be sufficient motivation to just break those. But I can 
see that globs are useful for the examples posted in the patch description. Is 
it possible to have some middle ground, e.g. default to regex but allow a 
config at the top of sanitizer lists to interpret future patterns as globs 
instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154014

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


[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-06-29 Thread Rashmi Mudduluru via Phabricator via cfe-commits
t-rasmud added inline comments.



Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp:5
+
+// FIXME: what about possible diagnostic message non-determinism?
+

I have used a workaround for non-determinism by using regular expressions to 
match on the `expected-note`.  See 
https://github.com/llvm/llvm-project/commit/db3dcedb9cedcec4a9570fda7406490c642df8ae#diff-8486f0b4ae37871fc0a186f40a41adbc70e5a0ca0134dc9bba762e1f17994460R176.
This is definitely a temporary fix (but helps with passing llvm builedbot tests 
upon landing on `llvm-project\main`) and we should probably discuss and put in 
a more reliable fix (say, using ordered sets) in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153059

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


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

2023-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/docs/HIPSupport.rst:104
+ - This macro is defined when the GPU default stream kind is set to 
per-thread.
+

b-sumner wrote:
> Should we include the __gfxNNN__ or __GFXN__ macros here?  What about wave 
> size, and CU mode?  And what about unsafe FP atomics macro?
Those are not only for HIP but for all languages targeting amdgpu. I am 
thinking we probably need a separate page for amdgpu support by clang.


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] D154123: [HIP] Start document HIP support by clang

2023-06-29 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added inline comments.



Comment at: clang/docs/HIPSupport.rst:104
+ - This macro is defined when the GPU default stream kind is set to 
per-thread.
+

Should we include the __gfxNNN__ or __GFXN__ macros here?  What about wave 
size, and CU mode?  And what about unsafe FP atomics macro?


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] D153582: [SystemZ][z/OS] Add required options/macro/etc for z/os compilation step

2023-06-29 Thread Sean via Phabricator via cfe-commits
SeanP updated this revision to Diff 535937.
SeanP added a comment.

fix merge conflicts


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

https://reviews.llvm.org/D153582

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h
  clang/test/Driver/zos-comp-cxx.cpp
  clang/test/Driver/zos-comp.c
  clang/test/Driver/zos-driver-defaults.c
  clang/test/Preprocessor/init-s390x.c

Index: clang/test/Preprocessor/init-s390x.c
===
--- clang/test/Preprocessor/init-s390x.c
+++ clang/test/Preprocessor/init-s390x.c
@@ -183,17 +183,12 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
 // RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s
 
-// S390X-ZOS-GNUXX: #define _EXT 1
 // S390X-ZOS:   #define _LONG_LONG 1
-// S390X-ZOS-GNUXX: #define _MI_BUILTIN 1
-// S390X-ZOS:   #define _OPEN_DEFAULT 1
-// S390X-ZOS:   #define _UNIX03_WITHDRAWN 1
-// S390X-ZOS-GNUXX: #define _XOPEN_SOURCE 600
 // S390X-ZOS:   #define __370__ 1
 // S390X-ZOS:   #define __64BIT__ 1
 // S390X-ZOS:   #define __BFP__ 1
 // S390X-ZOS:   #define __BOOL__ 1
-// S390X-ZOS-GNUXX: #define __DLL__ 1
+// S390X-ZOS:   #define __COMPILER_VER__ 0x5000
 // S390X-ZOS:   #define __LONGNAME__ 1
 // S390X-ZOS:   #define __MVS__ 1
 // S390X-ZOS:   #define __THW_370__ 1
Index: clang/test/Driver/zos-driver-defaults.c
===
--- clang/test/Driver/zos-driver-defaults.c
+++ clang/test/Driver/zos-driver-defaults.c
@@ -1,8 +1,23 @@
-// RUN: %clang -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-SHORT-ENUMS %s
+// RUN: %clang -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck --check-prefixes=CHECK-C-MACRO,CHECK-SHORT-ENUMS %s
+// RUN: %clang -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-ZOS-INCLUDES %s
 // RUN: %clang -### --target=s390x-none-zos -fno-short-enums -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clangxx -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck --check-prefixes=CHECK-C-MACRO,CHECK-CXX-MACRO %s
+// RUN: %clang -### --target=s390x-none-zos -x c++ -fsyntax-only %s 2>&1 | FileCheck --check-prefixes=CHECK-C-MACRO,CHECK-CXX-MACRO %s
+
+//CHECK-C-MACRO: -D_UNIX03_WITHDRAWN
+//CHECK-C-MACRO: -D_OPEN_DEFAULT
+
+//CHECK-CXX-MACRO: -D_XOPEN_SOURCE=600
+//CHECK-USER-CXX-MACRO-NOT: -D_XOPEN_SOURCE=600
+//CHECK-USER-CXX-MACRO: "-D" "_XOPEN_SOURCE=700"
 
 //CHECK-SHORT-ENUMS: -fshort-enums
 //CHECK-SHORT-ENUMS: -fno-signed-char
 
+//CHECK-ZOS-INCLUDES: clang{{.*}} "-cc1" "-triple" "s390x-none-zos"
+//CHECK-ZOS-INCLUDES-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+//CHECK-ZOS-INCLUDES-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include{{(/|)}}zos_wrappers"
+//CHECK-ZOS-INCLUDES-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+//
 //CHECK-NOT: -fshort-enums
 //CHECK: -fno-signed-char
Index: clang/test/Driver/zos-comp.c
===
--- /dev/null
+++ clang/test/Driver/zos-comp.c
@@ -0,0 +1,75 @@
+// Tests that the z/OS toolchain adds system includes to its search path.
+
+// RUN: %clang -c -### %s --target=s390x-ibm-zos 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK: "-D_UNIX03_WITHDRAWN"
+// CHECK-SAME: "-D_OPEN_DEFAULT"
+// CHECK-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include{{(/|)}}zos_wrappers"
+// CHECK-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-SAME: "-internal-isystem" "/usr/include"
+// CHECK-SAME: "-fshort-enums"
+// CHECK-SAME: "-fno-signed-char"
+// CHECK-SAME: "-fno-signed-wchar"
+
+// RUN: %clang -c -### -mzos-sys-include=/ABC/DEF %s 2>&1 \
+// RUN:		--target=s390x-ibm-zos \
+// RUN:   | FileCheck --check-prefixes=CHECK2 %s
+
+// CHECK2: "-D_UNIX03_WITHDRAWN"
+// CHECK2-SAME: "-D_OPEN_DEFAULT"
+// CHECK2-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK2-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include{{(/|)}}zos_wrappers"
+// CHECK2-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK2-SAME: "-internal-isystem" "/ABC/DEF"
+// CHECK2-NOT: "-internal-isystem" "/usr/include"
+// CHECK2-SAME: "-fshort-enums"
+// CHECK2-SAME: "-fno-signed-char"
+// CHECK2-SAME: "-fno-signed-wchar"
+
+// RUN: %clang -c -### -mzos-sys-include=/ABC/DEF:/ghi/jkl %s 2>&1 \
+// RUN:		--target=s390x-ibm-zos \
+// RUN:   | FileCheck 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 535936.
ychen added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -7372,7 +7372,7 @@
   cxxDeductionGuideDecl(hasParameter(0, hasType(asString("A");
   auto *ToD = Import(FromD, Lang_CXX17);
   ASSERT_TRUE(ToD);
-  EXPECT_TRUE(ToD->isCopyDeductionCandidate());
+  EXPECT_EQ(ToD->getDeductionCandidateKind(), DeductionCandidate::Copy);
   // Check that the deduced class template is also imported.
   EXPECT_TRUE(findFromTU(FromD)->Importer->GetAlreadyImportedOrNull(
   FromD->getDeducedTemplate()));
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,364 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 

[PATCH] D154130: [lit] Avoid os.path.realpath on Windows due to MAX_PATH limitations

2023-06-29 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian created this revision.
MrTrillian added reviewers: rnk, compnerd, nlopes, Jake-Egan.
Herald added a subscriber: delcypher.
Herald added a reviewer: ributzka.
Herald added a project: All.
MrTrillian requested review of this revision.
Herald added a reviewer: dang.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Changes lit logic to:

- Use `os.path.abspath` on Windows, where MAX_PATH is a concern that we can 
work around using substitute drives, which `os.path.realpath` would resolve.
- Use `os.path.realpath` on Unix, where the current directory always has 
symlinks resolved, so it is impossible to preserve symlinks in the presence of 
relative paths, and so we must make sure that all code paths use real paths.

Unfortunately, clang has `ModuleMap::canonicalizeModuleMapPath` which resolves 
the real path, so several tests had to be made aware that modulemap paths are 
special and need resolved paths. This required adding `%>/t` to `lit` to expand 
paths and normalize directory separators.

This is an updated version of https://reviews.llvm.org/D152709

How tested: built with `-DLLVM_ENABLE_PROJECTS=clang` and built `check-all` on 
both Windows and Linux (WSL-Ubuntu)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154130

Files:
  clang/test/ClangScanDeps/diagnostics.c
  clang/test/ClangScanDeps/header-search-pruning-transitive.c
  clang/test/ClangScanDeps/modules-context-hash.c
  clang/test/ClangScanDeps/modules-dep-args.c
  clang/test/ClangScanDeps/modules-excluded-header.m
  clang/test/ClangScanDeps/modules-extern-submodule.c
  clang/test/ClangScanDeps/modules-extern-unrelated.m
  clang/test/ClangScanDeps/modules-fmodule-name-no-module-built.m
  clang/test/ClangScanDeps/modules-full.cpp
  clang/test/ClangScanDeps/modules-implementation-private.m
  clang/test/ClangScanDeps/modules-implementation-vfs.m
  clang/test/ClangScanDeps/modules-implicit-dot-private.m
  clang/test/ClangScanDeps/modules-incomplete-umbrella.c
  clang/test/ClangScanDeps/modules-inferred.m
  clang/test/ClangScanDeps/modules-no-undeclared-includes.c
  clang/test/ClangScanDeps/modules-pch-common-submodule.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
  clang/test/ClangScanDeps/modules-pch-imports.c
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/ClangScanDeps/modules-redefinition.m
  clang/test/ClangScanDeps/modules-symlink-dir-from-module.c
  clang/test/ClangScanDeps/modules-symlink-dir.c
  clang/test/ClangScanDeps/modules-transitive.c
  clang/test/ClangScanDeps/multiple-commands.c
  clang/test/ClangScanDeps/removed-args.c
  clang/test/ExtractAPI/relative_include.m
  clang/test/Lexer/case-insensitive-include-win.c
  clang/test/VFS/module-header-mismatches.m
  llvm/cmake/modules/AddLLVM.cmake
  llvm/utils/lit/lit/LitConfig.py
  llvm/utils/lit/lit/TestRunner.py
  llvm/utils/lit/lit/builtin_commands/diff.py
  llvm/utils/lit/lit/cl_arguments.py
  llvm/utils/lit/lit/discovery.py
  llvm/utils/lit/lit/util.py
  llvm/utils/lit/setup.py
  llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
  llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
  llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
  llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
  llvm/utils/lit/tests/lit.cfg
  llvm/utils/llvm-lit/llvm-lit.in

Index: llvm/utils/llvm-lit/llvm-lit.in
===
--- llvm/utils/llvm-lit/llvm-lit.in
+++ llvm/utils/llvm-lit/llvm-lit.in
@@ -8,7 +8,7 @@
 
 def map_config(source_dir, site_config):
 global config_map
-source_dir = os.path.realpath(source_dir)
+source_dir = os.path.abspath(source_dir)
 source_dir = os.path.normcase(source_dir)
 site_config = os.path.normpath(site_config)
 config_map[source_dir] = site_config
Index: llvm/utils/lit/tests/lit.cfg
===
--- llvm/utils/lit/tests/lit.cfg
+++ llvm/utils/lit/tests/lit.cfg
@@ -6,6 +6,7 @@
 import subprocess
 
 import lit.formats
+import lit.util
 from lit.llvm import llvm_config
 
 # Configuration file for the 'lit' test runner.
@@ -35,7 +36,7 @@
 lit_path = os.path.join(llvm_src_root, "utils", "lit")
 else:
 lit_path = os.path.join(config.test_source_root, "..")
-lit_path = os.path.abspath(lit_path)
+lit_path = lit.util.safe_abs_path(lit_path)
 
 # Required because some tests import the lit module
 if llvm_config:
Index: llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
===
--- llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
+++ llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
@@ -1,4 +1,5 @@
 import lit.formats
+import lit.util
 
 config.name = "use-llvm-tool"
 config.suffixes = [".txt"]
@@ -7,7 +8,7 @@
 config.test_exec_root = None
 import os.path
 
-this_dir = os.path.realpath(os.path.dirname(__file__))
+this_dir = 

[PATCH] D154077: [HIP] Fix version detection for old HIP-PATH

2023-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:471
  {std::string(SharePath) + "/hip/version",
+  std::string(ParentSharePath) + "/hip/version",
   std::string(BinPath) + "/.hipVersion"}) {

tra wrote:
> We seem to be rather inconsistent about how we handle paths.
> 
> Above, we use `llvm::sys::path::append`, but here we revert to just appending 
> a path as a string. 
> 
> I think we should be using llvm::sys::path API consistently. It's unfortunate 
> that the API does not provide a string-returning function to append elements.
> ```
> auto Append = [](SmallVectorImpl , const Twine ,
>  const Twine  = "",
>  const Twine  = "",
>  const Twine  = "") {
> SmallVectorImpl newpath = path;
> llvm::sys::path::append(newpath, a,b,c,d);
> return newpath; 
> }
> for (const auto  :
>  {Append(SharePath, "hip", "version"),
>   Append(ParentSharePath,  "hip", "version"),
>   Append(BinPath, ".hipVersion")}) {
>   ...
> }
> ```
> 
will do. thanks.


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

https://reviews.llvm.org/D154077

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


[PATCH] D154043: [CodeGen] -fsanitize={function, kcfi}: ensure align 4 if +strict-align

2023-06-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D154043#4459446 , @simon_tatham 
wrote:

> The details of this approach look good to me, but is this the best place to 
> solve it? Doing it in clang means that //every// language front end that 
> wants to use either of these sanitizers is responsible for doing this same 
> work: tagging every IR function with `align 4` if it also has `!kcfi_type` or 
> `!func_sanitize`, and perhaps also checking the target-features to decide 
> whether to do that.
>
> I'd imagined the problem being solved at a lower level, when converting the 
> IR into actual function prologues, so that all front ends generating IR would 
> benefit from the fix.



In D154043#4460665 , @efriedma wrote:

> I also think it makes sense to fix the alignment when we lower the metadata, 
> not in the frontend, unless I'm missing something.
>
> It's not clear to me how "strict-align" is relevant; if sanitizer lowering is 
> generating "align 4" loads, the relevant pointers need to be appropriately 
> aligned regardless of the cost of unaligned loads.  Misaligned loads are 
> undefined behavior in LLVM IR on all targets.  (32-bit ARM in particular has 
> cases where 32-bit unaligned loads are supported, but certain load 
> instruction variations enforce alignment.)

OK. See D154125  for the MachineFunction.cpp 
approach. If we go that direction, I'll abandon this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154043

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


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

2023-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, scchan, b-sumner, arsenm.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added a subscriber: wdng.

start with example usage, predefined macros and env vars.


https://reviews.llvm.org/D154123

Files:
  clang/docs/HIPSupport.rst

Index: clang/docs/HIPSupport.rst
===
--- /dev/null
+++ clang/docs/HIPSupport.rst
@@ -0,0 +1,104 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.part { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: part
+.. role:: good
+
+.. contents::
+   :local:
+
+===
+HIP Support
+===
+
+`HIP (Heterogeneous-Compute Interface for Portability) `_
+is a C++ Runtime API and Kernel Language that allows developers to create portable applications for
+GPUs from single source code.
+
+Clang supports HIP on `ROCm platform `_.
+
+Example Usage
+=
+
+To compile a HIP program, you can use the following command:
+
+.. code-block:: shell
+
+   clang -c --offload-arch=gfx906 test.hip -o test.o
+
+To link a HIP program, you can use this command:
+
+.. code-block:: shell
+
+   clang --hip-link --offload-arch=gfx906 test.o -o test
+
+In the above commands, ``gfx906`` is the GPU architecture that the code is being compiled for.
+The supported GPU architectures can be found in the `AMDGPU Processor Table `_.
+Alternatively, you can run the ``amdgpu-arch`` tool that comes with Clang to list the GPU architecture on your sytem:
+
+.. code-block:: shell
+
+   amdgpu-arch
+
+You can also use ``--offload-arch=native`` to let ``amdgpu-arch`` automatically detect the GPU architecture on your system:
+
+.. code-block:: shell
+
+   clang -c --offload-arch=native test.hip -o test.o
+
+Environment Variables
+=
+
+.. list-table::
+   :header-rows: 1
+
+   * - Variable
+ - Description
+ - Default Value
+   * - ``ROCM_PATH``
+ - ROCm installation path.
+ - Empty
+   * - ``HIP_PATH``
+ - HIP runtime installation path.
+ - Empty
+   * - ``HIP_DEVICE_LIB_PATH``
+ - HIP device library installation path.
+ - Empty
+
+Predefined Macros
+=
+
+.. list-table::
+   :header-rows: 1
+
+   * - Macro
+ - Description
+   * - ``__CLANG_RDC__``
+ - This macro indicates that Clang is used for relocatable device code compilation (RDC).
+   * - ``__HIP__``
+ - This macro is defined when the HIP language option is enabled. It is used to indicate that the code is being compiled for the HIP environment.
+   * - ``__HIPCC__``
+ - This macro indicates that the code is being compiled using the HIP compiler.
+   * - ``__HIP_MEMORY_SCOPE_SINGLETHREAD``
+ - This macro is set to 1 and represents the memory scope that is limited to a single thread in HIP.
+   * - ``__HIP_MEMORY_SCOPE_WAVEFRONT``
+ - This macro is set to 2 and represents the memory scope that is limited to a wavefront in HIP.
+   * - ``__HIP_MEMORY_SCOPE_WORKGROUP``
+ - This macro is set to 3 and represents the memory scope that is limited to a workgroup in HIP.
+   * - ``__HIP_MEMORY_SCOPE_AGENT``
+ - This macro is set to 4 and represents the memory scope that is limited to an agent in HIP.
+   * - ``__HIP_MEMORY_SCOPE_SYSTEM``
+ - This macro is set to 5 and represents the memory scope that is limited to the system in HIP.
+   * - ``__HIP_DEVICE_COMPILE__``
+ - This macro is defined when the code is being compiled for a HIP device.
+   * - ``__HIP_NO_IMAGE_SUPPORT``
+ - This macro is set to 1 when the target device does not support HIP image functions.
+   * - ``HIP_API_PER_THREAD_DEFAULT_STREAM``
+ - This macro is defined when the GPU default stream kind is set to per-thread.
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154016: [clang][modules] Avoid serializing all diag mappings in non-deterministic order

2023-06-29 Thread Steven Wu via Phabricator via cfe-commits
steven_wu accepted this revision.
steven_wu added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D154016

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


[PATCH] D152003: [clang] Fix `static_cast` to array of unknown bound

2023-06-29 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:8824
+  if (auto *Cast = dyn_cast(E)) {
+if (auto *SubInit = dyn_cast(Cast->getSubExpr())) {
+  const Type *InnerType = SubInit->getType().getTypePtr();

erichkeane wrote:
> Fznamznon wrote:
> > erichkeane wrote:
> > > Fznamznon wrote:
> > > > erichkeane wrote:
> > > > > I am not really sure this is the right way about this.  You're 
> > > > > supposed to be testing `T`, but this looks like it is checking the 
> > > > > type of `E`, isn't it?  I think you just need to check 
> > > > > `Cast->getType()`.
> > > > For the case I'm trying to fix, `T` is array of unknown bound, it is 
> > > > already checked before calling `completeExprArrayBound`. Right now when 
> > > > you write something like
> > > > ```
> > > > int (&)[1] = static_cast(42);
> > > > ```
> > > > Clang actually is able to realize that parenthesized initialization is 
> > > > made, so it actually generates `CXXParenListInitExpr` that has type 
> > > > int[1]. Here I'm just paranoidally double-checking that is the case 
> > > > before switching the type. Maybe I don't need this double-check at all 
> > > > then?
> > > > 
> > > That makes me wonder if this is the correct place for this?  Should when 
> > > we generate this type when we do the `CXXParenListInitExpr` fixup?
> > > 
> > > Either way, I think making this depend on that behavior (which would 
> > > possibly be fragile), we should just do it based on the type passed ot 
> > > the `static_cast`.
> > > 
> > > Another question: is this something that needs to be done for other cast 
> > > types?  Does similar behavior exist for the other casts?  Should it also 
> > > happen with 'clobber' casts (C-style) that are effectively static?
> > > That makes me wonder if this is the correct place for this? Should when 
> > > we generate this type when we do the CXXParenListInitExpr fixup?
> > 
> > The function called `completeExprArrayBound` seemed like an appropriate 
> > place for me.
> > Could you please elaborate what you mean under `CXXParenListInitExpr 
> > fixup`? 
> > 
> > > is this something that needs to be done for other cast types?
> > 
> > I'm not sure. 
> > https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1975r0.html seems 
> > to be extending only static_casts. And this was the original purpose of 
> > this bugfix.
> > gcc and msvc don't agree on that matter https://godbolt.org/z/1M3ahhsYr.
> >>Could you please elaborate what you mean under CXXParenListInitExpr fixup?
> 
> You mentioned that at a different place we set the type of the 
> `CXXParenListInitExpr` to be the 1-arity array.  I was saying that if there 
> is logic THERE based on whether its an incomplete array type it would be for 
> the same purpose, and perhaps be the correct place to do this.
> 
> >>I'm not sure. 
> >>https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1975r0.html seems 
> >>to be extending only static_casts. 
> 
> Yep, thats what I was hoping to see, thanks.
> 
> >>And this was the original purpose of this bugfix.
> 
> I was concerned that we increasing the inconsistency by only fixing 1 of the 
> types of casts.  It might seem like 'feature creep', but it is very important 
> that we make sure a patch is reasonably complete, so that it doesn't make the 
> compiler less consistent.
> 
>  I was saying that if there is logic THERE based on whether its an incomplete 
> array type it would be for the same purpose, and perhaps be the correct place 
> to do this.

Well, it seems to be happening inside of a `TryStaticImplicitCast` before the 
`CXXStaticCastExpr` created. There is initialization sequence performed, and 
the source expression comes out of as an array of 1 element. It is not very 
convenient to switch the type there since there is no cast expression itself 
yet and the destination type is passed as a copy through several functions. 
Will it be ok to check and switch the type of resulting static_cast expression 
just before/after it is created?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152003

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


[PATCH] D154077: [HIP] Fix version detection for old HIP-PATH

2023-06-29 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM in general with a minor suggestion.




Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:471
  {std::string(SharePath) + "/hip/version",
+  std::string(ParentSharePath) + "/hip/version",
   std::string(BinPath) + "/.hipVersion"}) {

We seem to be rather inconsistent about how we handle paths.

Above, we use `llvm::sys::path::append`, but here we revert to just appending a 
path as a string. 

I think we should be using llvm::sys::path API consistently. It's unfortunate 
that the API does not provide a string-returning function to append elements.
```
auto Append = [](SmallVectorImpl , const Twine ,
 const Twine  = "",
 const Twine  = "",
 const Twine  = "") {
SmallVectorImpl newpath = path;
llvm::sys::path::append(newpath, a,b,c,d);
return newpath; 
}
for (const auto  :
 {Append(SharePath, "hip", "version"),
  Append(ParentSharePath,  "hip", "version"),
  Append(BinPath, ".hipVersion")}) {
  ...
}
```



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

https://reviews.llvm.org/D154077

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


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D139837#4460664 , @cor3ntin wrote:

> Thanks a lot for working on this!
> Do you need Aaron or myself to commit this for you? If so, which name / mail 
> do you want us to use?

That's okay. I'm doing the rebase and I could commit it later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

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


[PATCH] D154043: [CodeGen] -fsanitize={function, kcfi}: ensure align 4 if +strict-align

2023-06-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I also think it makes sense to fix the alignment when we lower the metadata, 
not in the frontend, unless I'm missing something.

It's not clear to me how "strict-align" is relevant; if sanitizer lowering is 
generating "align 4" loads, the relevant pointers need to be appropriately 
aligned regardless of the cost of unaligned loads.  Misaligned loads are 
undefined behavior in LLVM IR on all targets.  (32-bit ARM in particular has 
cases where 32-bit unaligned loads are supported, but certain load instruction 
variations enforce alignment.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154043

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


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Thanks a lot for working on this!
Do you need Aaron or myself to commit this for you? If so, which name / mail do 
you want us to use?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

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


[PATCH] D154016: [clang][modules] Avoid serializing all diag mappings in non-deterministic order

2023-06-29 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir marked an inline comment as done.
benlangmuir added inline comments.



Comment at: clang/lib/Serialization/ASTWriter.cpp:3016
   for (const auto  : *State) {
-if (I.second.isPragma() || IncludeNonPragmaStates) {
-  Record.push_back(I.first);
-  Record.push_back(I.second.serialize());
-}
+// Maybe skip non-pragmas.
+if (!I.second.isPragma() && !IncludeNonPragmaStates)

steven_wu wrote:
> Is pragma in this context refer to `#pragma diagnostics push/pop`? Do we have 
> test to cover those to be deterministic?
> Is pragma in this context refer to `#pragma diagnostics push/pop`?

Yeah, this is diagnostic pragmas.

> Do we have test to cover those to be deterministic?

I extended the current test to include some pragmas as well.  It's harder to 
check them exhaustively because the encoded format gets more complex, but I 
checked the specific mappings are in order and the `diff` part of the test 
should help catch any other non-determinism there could be.


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

https://reviews.llvm.org/D154016

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


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

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


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:98
+- Implemented `P1816R0: `_ and `P2082R1: 
`_,
+  which allows CTAD for aggregates (parenthesized aggregate-initialization is 
not supported).
 

aaron.ballman wrote:
> Paren aggregate init is now supported, so this should be updated.
Thanks for catching this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

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


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 535883.
ychen marked 4 inline comments as done.
ychen added a comment.

- address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -7372,7 +7372,7 @@
   cxxDeductionGuideDecl(hasParameter(0, hasType(asString("A");
   auto *ToD = Import(FromD, Lang_CXX17);
   ASSERT_TRUE(ToD);
-  EXPECT_TRUE(ToD->isCopyDeductionCandidate());
+  EXPECT_EQ(ToD->getDeductionCandidateKind(), DeductionCandidate::Copy);
   // Check that the deduced class template is also imported.
   EXPECT_TRUE(findFromTU(FromD)->Importer->GetAlreadyImportedOrNull(
   FromD->getDeducedTemplate()));
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,364 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   

[PATCH] D154016: [clang][modules] Avoid serializing all diag mappings in non-deterministic order

2023-06-29 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir updated this revision to Diff 535882.
benlangmuir added a comment.

Extended test to include diagnostic pragmas


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

https://reviews.llvm.org/D154016

Files:
  clang/include/clang/Basic/DiagnosticIDs.h
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/diag-mappings.c

Index: clang/test/Modules/diag-mappings.c
===
--- /dev/null
+++ clang/test/Modules/diag-mappings.c
@@ -0,0 +1,94 @@
+// Test that diagnostic mappings are emitted only when needed and in order of
+// diagnostic ID rather than non-deterministically. This test passes 3
+// -W options and expects exactly 3 mappings to be emitted in the pcm. The -W
+// options are chosen to be far apart in ID (see DiagnosticIDs.h) so we can
+// check they are ordered. We also intentionally trigger several other warnings
+// inside the module and ensure they do not show up in the pcm as mappings.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t/cache -triple x86_64-apple-macosx10.11.0 \
+// RUN:   %t/main.m -fdisable-module-hash \
+// RUN:   -Werror=stack-protector -Werror=empty-translation-unit -Werror=float-equal
+
+// RUN: mv %t/cache/A.pcm %t/A1.pcm
+
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t/A1.pcm | FileCheck %s
+
+// CHECK:  2000
+// CHECK-SAME: op7=[[FLOAT_EQ:[2-9][0-9][0-9][0-9]]] op8=
+
+// == Pragmas:
+// Each pragma creates a mapping table; and each copies the previous table. The
+// initial mappings are copied as well, but are not serialized since they have
+// isPragma=false.
+
+// == ignored "-Wfloat-equal"
+// CHECK-SAME: op{{[0-9]+}}=1
+// CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
+
+// == ignored "-Wstack-protector"
+// CHECK-SAME: op{{[0-9]+}}=2
+// CHECK-SAME: op{{[0-9]+}}=[[STACK_PROT]] op{{[0-9]+}}=
+// CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
+
+// == warning "-Wempty-translation-unit"
+// CHECK-SAME: op{{[0-9]+}}=3
+// CHECK-SAME: op{{[0-9]+}}=[[STACK_PROT]] op{{[0-9]+}}=
+// CHECK-SAME: op{{[0-9]+}}=[[EMPTY_TU]] op{{[0-9]+}}=
+// CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
+
+// == warning "-Wstack-protector"
+// CHECK-SAME: op{{[0-9]+}}=3
+// CHECK-SAME: op{{[0-9]+}}=[[STACK_PROT]] op{{[0-9]+}}=
+// CHECK-SAME: op{{[0-9]+}}=[[EMPTY_TU]] op{{[0-9]+}}=
+// CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t/cache -triple x86_64-apple-macosx10.11.0 \
+// RUN:   %t/main.m -fdisable-module-hash \
+// RUN:   -Werror=stack-protector -Werror=empty-translation-unit -Werror=float-equal
+
+// RUN: diff %t/cache/A.pcm %t/A1.pcm
+
+//--- module.modulemap
+module A { header "a.h" }
+
+//--- a.h
+// Lex warning
+#warning "w"
+
+static inline void f() {
+// Parse warning
+  ;
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wfloat-equal"
+#pragma clang diagnostic ignored "-Wstack-protector"
+
+static inline void g() {
+// Sema warning
+  int x;
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic warning "-Wempty-translation-unit"
+#pragma clang diagnostic warning "-Wstack-protector"
+
+#pragma clang diagnostic pop
+#pragma clang diagnostic pop
+
+//--- main.m
+#import "a.h"
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -2997,20 +2997,41 @@
 assert(Flags == EncodeDiagStateFlags(State) &&
"diag state flags vary in single AST file");
 
+// If we ever serialize non-pragma mappings outside the initial state, the
+// code below will need to consider more than getDefaultMapping.
+assert(!IncludeNonPragmaStates ||
+   State == Diag.DiagStatesByLoc.FirstDiagState);
+
 unsigned  = DiagStateIDMap[State];
 Record.push_back(DiagStateID);
 
 if (DiagStateID == 0) {
   DiagStateID = ++CurrID;
+  SmallVector> Mappings;
 
   // Add a placeholder for the number of mappings.
   auto SizeIdx = Record.size();
   Record.emplace_back();
   for (const auto  : *State) {
-if (I.second.isPragma() || IncludeNonPragmaStates) {
-  Record.push_back(I.first);
-  Record.push_back(I.second.serialize());
-}
+// Maybe skip non-pragmas.
+if (!I.second.isPragma() && !IncludeNonPragmaStates)
+  continue;
+// Skip default mappings. We have a mapping for every diagnostic ever
+// emitted, regardless of whether it was customized.
+if (!I.second.isPragma() &&
+I.second == DiagnosticIDs::getDefaultMapping(I.first))
+  continue;
+Mappings.push_back(I);
+  }
+
+  // Sort by diag::kind for 

[PATCH] D153694: [clang][CodeGen] Remove no-op EmitCastToVoidPtr (NFC)

2023-06-29 Thread Sergei Barannikov 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 rG234890226861: [clang][CodeGen] Remove no-op 
EmitCastToVoidPtr (NFC) (authored by barannikov88).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153694

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp

Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -153,14 +153,13 @@
   bool shouldDynamicCastCallBeNullChecked(bool SrcIsPtr,
   QualType SrcRecordTy) override;
 
-  llvm::Value *EmitDynamicCastCall(CodeGenFunction , Address Value,
+  llvm::Value *emitDynamicCastCall(CodeGenFunction , Address Value,
QualType SrcRecordTy, QualType DestTy,
QualType DestRecordTy,
llvm::BasicBlock *CastEnd) override;
 
-  llvm::Value *EmitDynamicCastToVoid(CodeGenFunction , Address Value,
- QualType SrcRecordTy,
- QualType DestTy) override;
+  llvm::Value *emitDynamicCastToVoid(CodeGenFunction , Address Value,
+ QualType SrcRecordTy) override;
 
   bool EmitBadCastCall(CodeGenFunction ) override;
   bool canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const override {
@@ -1011,11 +1010,9 @@
  !getContext().getASTRecordLayout(SrcDecl).hasExtendableVFPtr();
 }
 
-llvm::Value *MicrosoftCXXABI::EmitDynamicCastCall(
-CodeGenFunction , Address This, QualType SrcRecordTy,
-QualType DestTy, QualType DestRecordTy, llvm::BasicBlock *CastEnd) {
-  llvm::Type *DestLTy = CGF.ConvertType(DestTy);
-
+llvm::Value *MicrosoftCXXABI::emitDynamicCastCall(
+CodeGenFunction , Address This, QualType SrcRecordTy, QualType DestTy,
+QualType DestRecordTy, llvm::BasicBlock *CastEnd) {
   llvm::Value *SrcRTTI =
   CGF.CGM.GetAddrOfRTTIDescriptor(SrcRecordTy.getUnqualifiedType());
   llvm::Value *DestRTTI =
@@ -1041,14 +1038,12 @@
   llvm::Value *Args[] = {
   ThisPtr, Offset, SrcRTTI, DestRTTI,
   llvm::ConstantInt::get(CGF.Int32Ty, DestTy->isReferenceType())};
-  ThisPtr = CGF.EmitRuntimeCallOrInvoke(Function, Args);
-  return CGF.Builder.CreateBitCast(ThisPtr, DestLTy);
+  return CGF.EmitRuntimeCallOrInvoke(Function, Args);
 }
 
-llvm::Value *
-MicrosoftCXXABI::EmitDynamicCastToVoid(CodeGenFunction , Address Value,
-   QualType SrcRecordTy,
-   QualType DestTy) {
+llvm::Value *MicrosoftCXXABI::emitDynamicCastToVoid(CodeGenFunction ,
+Address Value,
+QualType SrcRecordTy) {
   std::tie(Value, std::ignore, std::ignore) =
   performBaseAdjustment(CGF, Value, SrcRecordTy);
 
@@ -1582,11 +1577,8 @@
   // 1) getThisValue is currently protected
   // 2) in theory, an ABI could implement 'this' returns some other way;
   //HasThisReturn only specifies a contract, not the implementation
-  if (HasThisReturn(CGF.CurGD))
+  if (HasThisReturn(CGF.CurGD) || hasMostDerivedReturn(CGF.CurGD))
 CGF.Builder.CreateStore(getThisValue(CGF), CGF.ReturnValue);
-  else if (hasMostDerivedReturn(CGF.CurGD))
-CGF.Builder.CreateStore(CGF.EmitCastToVoidPtr(getThisValue(CGF)),
-CGF.ReturnValue);
 
   if (isa(MD) && MD->getParent()->getNumVBases()) {
 assert(getStructorImplicitParamDecl(CGF) &&
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -185,14 +185,13 @@
   bool shouldDynamicCastCallBeNullChecked(bool SrcIsPtr,
   QualType SrcRecordTy) override;
 
-  llvm::Value *EmitDynamicCastCall(CodeGenFunction , Address Value,
+  llvm::Value *emitDynamicCastCall(CodeGenFunction , Address Value,
QualType SrcRecordTy, QualType DestTy,
QualType DestRecordTy,
llvm::BasicBlock *CastEnd) override;
 
-  llvm::Value *EmitDynamicCastToVoid(CodeGenFunction , Address Value,
- QualType SrcRecordTy,
- 

[clang] 2348902 - [clang][CodeGen] Remove no-op EmitCastToVoidPtr (NFC)

2023-06-29 Thread Sergei Barannikov via cfe-commits

Author: Sergei Barannikov
Date: 2023-06-29T20:29:38+03:00
New Revision: 2348902268613a2120bc2d7f3fc8b683d4c114d7

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

LOG: [clang][CodeGen] Remove no-op EmitCastToVoidPtr (NFC)

Reviewed By: JOE1994

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

Added: 


Modified: 
clang/lib/CodeGen/CGAtomic.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCXXABI.h
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprCXX.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index f191829b41552..222b0a192c85e 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -80,23 +80,23 @@ namespace {
 AtomicSizeInBits = C.toBits(
 C.toCharUnitsFromBits(Offset + OrigBFI.Size + C.getCharWidth() - 1)
 .alignTo(lvalue.getAlignment()));
-auto VoidPtrAddr = CGF.EmitCastToVoidPtr(lvalue.getBitFieldPointer());
+llvm::Value *BitFieldPtr = lvalue.getBitFieldPointer();
 auto OffsetInChars =
 (C.toCharUnitsFromBits(OrigBFI.Offset) / lvalue.getAlignment()) *
 lvalue.getAlignment();
-VoidPtrAddr = CGF.Builder.CreateConstGEP1_64(
-CGF.Int8Ty, VoidPtrAddr, OffsetInChars.getQuantity());
-llvm::Type *IntTy = CGF.Builder.getIntNTy(AtomicSizeInBits);
-auto Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
-VoidPtrAddr, llvm::PointerType::getUnqual(CGF.getLLVMContext()),
+llvm::Value *StoragePtr = CGF.Builder.CreateConstGEP1_64(
+CGF.Int8Ty, BitFieldPtr, OffsetInChars.getQuantity());
+StoragePtr = CGF.Builder.CreateAddrSpaceCast(
+StoragePtr, llvm::PointerType::getUnqual(CGF.getLLVMContext()),
 "atomic_bitfield_base");
 BFI = OrigBFI;
 BFI.Offset = Offset;
 BFI.StorageSize = AtomicSizeInBits;
 BFI.StorageOffset += OffsetInChars;
-LVal = LValue::MakeBitfield(Address(Addr, IntTy, 
lvalue.getAlignment()),
-BFI, lvalue.getType(), 
lvalue.getBaseInfo(),
-lvalue.getTBAAInfo());
+llvm::Type *StorageTy = CGF.Builder.getIntNTy(AtomicSizeInBits);
+LVal = LValue::MakeBitfield(
+Address(StoragePtr, StorageTy, lvalue.getAlignment()), BFI,
+lvalue.getType(), lvalue.getBaseInfo(), lvalue.getTBAAInfo());
 AtomicTy = C.getIntTypeForBitwidth(AtomicSizeInBits, OrigBFI.IsSigned);
 if (AtomicTy.isNull()) {
   llvm::APInt Size(
@@ -805,8 +805,7 @@ AddDirectArgument(CodeGenFunction , CallArgList ,
 Args.add(RValue::get(Val), ValTy);
   } else {
 // Non-optimized functions always take a reference.
-Args.add(RValue::get(CGF.EmitCastToVoidPtr(Val)),
- CGF.getContext().VoidPtrTy);
+Args.add(RValue::get(Val), CGF.getContext().VoidPtrTy);
   }
 }
 
@@ -1103,8 +1102,8 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
   *this, V, AS, LangAS::opencl_generic, DestType, false);
 };
 
-Args.add(RValue::get(CastToGenericAddrSpace(
- EmitCastToVoidPtr(Ptr.getPointer()), E->getPtr()->getType())),
+Args.add(RValue::get(CastToGenericAddrSpace(Ptr.getPointer(),
+E->getPtr()->getType())),
  getContext().VoidPtrTy);
 
 std::string LibCallName;
@@ -1137,10 +1136,9 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
   LibCallName = "__atomic_compare_exchange";
   RetTy = getContext().BoolTy;
   HaveRetTy = true;
-  Args.add(
-  RValue::get(CastToGenericAddrSpace(
-  EmitCastToVoidPtr(Val1.getPointer()), E->getVal1()->getType())),
-  getContext().VoidPtrTy);
+  Args.add(RValue::get(CastToGenericAddrSpace(Val1.getPointer(),
+  E->getVal1()->getType())),
+   getContext().VoidPtrTy);
   AddDirectArgument(*this, Args, UseOptimizedLibcall, Val2.getPointer(),
 MemTy, E->getExprLoc(), TInfo.Width);
   Args.add(RValue::get(Order), getContext().IntTy);
@@ -1302,8 +1300,7 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
   } else {
 // Value is returned through parameter before the order.
 RetTy = getContext().VoidTy;
-Args.add(RValue::get(EmitCastToVoidPtr(Dest.getPointer())),
- 

[PATCH] D153898: [DebugInfo] Enable debug info emission for extern variables in C++

2023-06-29 Thread Yuze Chi via Phabricator via cfe-commits
chiyuze added a comment.

Thank you for accepting this patch!

In D153898#4457432 , @MaskRay wrote:

> I wonder whether you have ready-to-use instructions to test this for folks 
> who are not familiar with Linux kernel/eBPF. (I happened to start to read 
> eBPF one week ago, but I guess it would take some time for me to be more 
> familiar with it, even if I contributed some stuff back in 2020)



In D153898#4457436 , @MaskRay wrote:

>> This patch is required so that we can still use kconfig in such BPF programs 
>> compiled from C++.
>
> Assuming that you mean 
> https://www.kernel.org/doc/html/next/kbuild/kconfig-language.html#kconfig-language
>  , how is Kconfig (a DSL used in the build system)  relevant here?

The kconfig DSL allows extern variables to be filled in by libbpf before being 
loaded into the kernel. 
https://nakryiko.com/posts/bpf-core-reference-guide/#kconfig-extern-variables 
has more detailed explanations. In prod, we use this as a mechanism to 
flag-protect BPF features. For example, if we have `test.c` with the following 
content:

  // helpers
  #define __section(x) __attribute__((section(x)))
  #define __kconfig __attribute__((section(".kconfig")))
  #define __weak __attribute__((weak))
  // end of helpers
  
  extern const int CONFIG_ENABLE_FOO __kconfig __weak;
  __section("tc")
  int test(void* ctx) {
if (CONFIG_ENABLE_FOO > 1000) {
  return 1;
}
return 0;
  }

libbpf will fill in 0 as CONFIG_ENABLE_FOO by default, and allow us to override 
it with other values using the kconfig DSL. However, without this patch, such 
BPF programs are only functional if compiled as C:

`clang -g -O2 -target bpf -c test.c -o test.c.o; sudo bpftool prog load 
test.c.o /sys/fs/bpf/test_c` returns OK.

If we compile the same source code as C++, it won't load:

`clang -g -O2 -target bpf -x c++ -c test.c -o test.cc.o; sudo bpftool prog load 
test.cc.o /sys/fs/bpf/test_cc` gives

  libbpf: failed to find BTF for extern 'CONFIG_ENABLE_FOO': -2
  Error: failed to open object file

The reason is that the generated object is missing BTF for the extern variable:

`bpftool btf dump file test.c.o` gives

  [1] PTR '(anon)' type_id=0
  [2] FUNC_PROTO '(anon)' ret_type_id=3 vlen=1
  'ctx' type_id=1
  [3] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
  [4] FUNC 'test' type_id=2 linkage=global
  [5] CONST '(anon)' type_id=3
  [6] VAR 'CONFIG_ENABLE_FOO' type_id=5, linkage=extern
  [7] DATASEC '.kconfig' size=0 vlen=1
  type_id=6 offset=0 size=4 (VAR 'CONFIG_ENABLE_FOO')

whereas `bpftool btf dump file test.cc.o` gives

  [1] PTR '(anon)' type_id=0
  [2] FUNC_PROTO '(anon)' ret_type_id=3 vlen=1
  'ctx' type_id=1
  [3] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
  [4] FUNC 'test' type_id=2 linkage=global



In D153898#4457436 , @MaskRay wrote:

> Clang BPF supports `-mcpu=v[123]`. v1 is for a very old kernel. 
> https://pchaigno.github.io/bpf/2021/10/20/ebpf-instruction-sets.html 
> I think there are some users so we cannot remove the support. Is it happy 
> with the new behavior?

Yes. This patch does not change existing behaviors, including backend 
behaviors, upon which users already depend, since it only changes debug info 
for BPF compiled in C++. BPF & C++ is a combination that was never officially 
supported (and does not fully work).

In D153898#4457810 , @dblaikie wrote:

> (though I'd still ask a bit about the issue of declaration V definition - is 
> BPF just always "standalone" debug info generally? (is there a problem with 
> the definition coming from another translation unit with debug info?)?)

I'm not aware of such problems, but my experience may be limited to the use 
cases owned by our team. AFAIK, clang always compiles BPF as individual 
translation units. "Linking" is implemented by libbpf 
(https://lwn.net/Articles/848997/), which is not used in BPF programs owned by 
our team today (those BPF programs predate libbpf's linking support). Our plan 
is to migrate existing use cases of BPF to C++ first, before trying to support 
more general use cases (e.g. libbpf linking). This patch is our first clang 
patch towards compiling BPF from C++; we'll send more if we found them 
necessary in the future :)

In D153898#4460475 , @yonghong-song 
wrote:

> I am okay with this change. Once you used this patch and implemented the 
> mechanism inside Google. Could you send a follow-up summary on what the 
> implementation looks like in Google for the thread:
>
>   
> https://lore.kernel.org/bpf/cakh8qbt4xqbupxefqpk5ayu1rr0-h-vcjzs_0bu-987gl4w...@mail.gmail.com/
>
> This will give people a sense why this is useful/better than other 
> alternatives (like macro based approach).

Sure thing, will do!


Repository:
  rG LLVM Github Monorepo

[PATCH] D153849: [clang][Diagnostics] Fix diagnostic line numbers

2023-06-29 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

LGTM. Not sure if the `Fixes https://github.com/llvm/llvm-project/issues/63524` 
line autocloses the issue, but note that `Fixes #63524` does.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153849

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


  1   2   3   >