[clang] d4a5673 - [AIX][clang][tests] XFail PCH/late-parsed-instantiations.cpp

2023-07-06 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2023-07-06T14:06:30+07:00
New Revision: d4a5673addd69aa2a299d9de4db8d17373be

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

LOG: [AIX][clang][tests] XFail PCH/late-parsed-instantiations.cpp

The issue: https://github.com/llvm/llvm-project/issues/63704

Added: 


Modified: 
clang/test/PCH/late-parsed-instantiations.cpp

Removed: 




diff  --git a/clang/test/PCH/late-parsed-instantiations.cpp 
b/clang/test/PCH/late-parsed-instantiations.cpp
index 7a787810a87f90..e70147dcee6166 100644
--- a/clang/test/PCH/late-parsed-instantiations.cpp
+++ b/clang/test/PCH/late-parsed-instantiations.cpp
@@ -4,6 +4,8 @@
 // RUN: %clang_cc1 -fdelayed-template-parsing -std=c++14 -emit-pch 
-fpch-instantiate-templates %s -o %t.pch -verify
 // RUN: %clang_cc1 -fdelayed-template-parsing -std=c++14 -include-pch %t.pch 
%s -verify
 
+// XFAIL: target={{.*}}-aix{{.*}}
+
 #ifndef HEADER_INCLUDED
 
 #define HEADER_INCLUDED



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


[PATCH] D154572: [RISCV] Use 'long' in aes64 Zknd/Zkne builtin tests.

2023-07-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: asb, VincentWu, kito-cheng.
Herald added subscribers: jobnoorman, luke, 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, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, eopXD, MaskRay.
Herald added a project: clang.

This matches the data type of the intrinsics. This case be seen
from the removal of sext and trunc instructions from the IR.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154572

Files:
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c

Index: clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
===
--- clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
+++ clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
@@ -5,37 +5,31 @@
 
 // RV64ZKNE-LABEL: @aes64es(
 // RV64ZKNE-NEXT:  entry:
-// RV64ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNE-NEXT:[[RS2_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNE-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNE-NEXT:store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4
-// RV64ZKNE-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNE-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNE-NEXT:[[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4
-// RV64ZKNE-NEXT:[[CONV1:%.*]] = sext i32 [[TMP1]] to i64
-// RV64ZKNE-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64es(i64 [[CONV]], i64 [[CONV1]])
-// RV64ZKNE-NEXT:[[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
-// RV64ZKNE-NEXT:ret i32 [[CONV2]]
+// RV64ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNE-NEXT:[[RS2_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNE-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNE-NEXT:store i64 [[RS2:%.*]], ptr [[RS2_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP1:%.*]] = load i64, ptr [[RS2_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64es(i64 [[TMP0]], i64 [[TMP1]])
+// RV64ZKNE-NEXT:ret i64 [[TMP2]]
 //
-int aes64es(int rs1, int rs2) {
+long aes64es(long rs1, long rs2) {
   return __builtin_riscv_aes64es_64(rs1, rs2);
 }
 
 
 // RV64ZKNE-LABEL: @aes64esm(
 // RV64ZKNE-NEXT:  entry:
-// RV64ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNE-NEXT:[[RS2_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNE-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNE-NEXT:store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4
-// RV64ZKNE-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNE-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNE-NEXT:[[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4
-// RV64ZKNE-NEXT:[[CONV1:%.*]] = sext i32 [[TMP1]] to i64
-// RV64ZKNE-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64esm(i64 [[CONV]], i64 [[CONV1]])
-// RV64ZKNE-NEXT:[[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
-// RV64ZKNE-NEXT:ret i32 [[CONV2]]
+// RV64ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNE-NEXT:[[RS2_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNE-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNE-NEXT:store i64 [[RS2:%.*]], ptr [[RS2_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP1:%.*]] = load i64, ptr [[RS2_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64esm(i64 [[TMP0]], i64 [[TMP1]])
+// RV64ZKNE-NEXT:ret i64 [[TMP2]]
 //
-int aes64esm(int rs1, int rs2) {
+long aes64esm(long rs1, long rs2) {
   return __builtin_riscv_aes64esm_64(rs1, rs2);
 }
Index: clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
===
--- clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
+++ clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
@@ -5,52 +5,44 @@
 
 // RV64ZKND-LABEL: @aes64dsm(
 // RV64ZKND-NEXT:  entry:
-// RV64ZKND-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKND-NEXT:[[RS2_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKND-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKND-NEXT:store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4
-// RV64ZKND-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKND-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKND-NEXT:[[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4
-// RV64ZKND-NEXT:[[CONV1:%.*]] = sext i32 [[TMP1]] to i64
-

[PATCH] D143241: [Clang] Reset FP options before function instantiations

2023-07-06 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D143241#4475741 , @Jake-Egan wrote:

> Hi, the following assertion is getting tripped on AIX:
>
>   Assertion failed: *FpPragmaCurrentValue == 
> SemaObj->FpPragmaStack.DefaultValue && "Expected a default pragma 
> float_control value", file  
> /scratch/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/clang/lib/Serialization/ASTReader.cpp,
>  line 8150, void clang::ASTReader::UpdateSema()()
>
> https://lab.llvm.org/buildbot/#/builders/214/builds/8309/steps/6/logs/FAIL__Clang__late-parsed-instantiations_cpp

This crash is observed only on clang-ppc64-aix buildbot. I created an issue for 
it: https://github.com/llvm/llvm-project/issues/63704 and xfailed the test on 
this platform: https://reviews.llvm.org/rGd4a5673addd6 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143241

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


[clang] 533af6e - [AIX] make integrated-as as default on AIX.

2023-07-06 Thread via cfe-commits

Author: esmeyi
Date: 2023-07-06T03:16:10-04:00
New Revision: 533af6e5c4b35b72805cdbd6229644d288e172e4

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

LOG: [AIX] make integrated-as as default on AIX.

Summary: Clang uses LLVM's integrated assembler by default on most targets, 
however non-integrated-as mode is default on AIX. Currently integrated-as mode 
on AIX has passed tests of LLVM test-suite, bootstrap and Spec2017, therefore 
this patch sets integrated-as as the default assembler mode on AIX.

Reviewed By: DiggerLin

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

Added: 
clang/test/Driver/aix-integrated-as.c

Modified: 
clang/lib/Driver/ToolChains/AIX.h
clang/test/Driver/aix-as.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.h 
b/clang/lib/Driver/ToolChains/AIX.h
index cc74e5ea85efca..245639d60c5f25 100644
--- a/clang/lib/Driver/ToolChains/AIX.h
+++ b/clang/lib/Driver/ToolChains/AIX.h
@@ -68,6 +68,7 @@ class LLVM_LIBRARY_VISIBILITY AIX : public ToolChain {
   }
   bool isPICDefaultForced() const override { return true; }
   bool HasNativeLLVMSupport() const override { return true; }
+  bool IsIntegratedAssemblerDefault() const override { return true; }
 
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,

diff  --git a/clang/test/Driver/aix-as.c b/clang/test/Driver/aix-as.c
index c6aeae4c101835..4164348b60127b 100644
--- a/clang/test/Driver/aix-as.c
+++ b/clang/test/Driver/aix-as.c
@@ -11,7 +11,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-AS32 %s
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit.
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c -fno-integrated-as 2>&1 \
 // RUN: --target=powerpc-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefixes=CHECK-AS32,CHECK-AS32-CC1 %s
 // CHECK-AS32-NOT: warning:
@@ -30,7 +30,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-AS64 %s
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c -fno-integrated-as 2>&1 \
 // RUN: --target=powerpc64-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefixes=CHECK-AS64,CHECK-AS64-CC1 %s
 // CHECK-AS64-NOT: warning:
@@ -40,7 +40,7 @@
 // CHECK-AS64: "-many"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. -Xassembler  option. 
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c -fno-integrated-as 2>&1 \
 // RUN: -Xassembler -w \
 // RUN: --target=powerpc-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefix=CHECK-AS32-Xassembler %s
@@ -52,7 +52,7 @@
 // CHECK-AS32-Xassembler: "-w"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -Wa,, option.
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c -fno-integrated-as 2>&1 \
 // RUN: -Wa,-v,-w \
 // RUN: --target=powerpc64-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefix=CHECK-AS64-Wa %s
@@ -65,7 +65,7 @@
 // CHECK-AS64-Wa: "-w"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Multiple input files.
-// RUN: %clang -### -c \
+// RUN: %clang -### -fno-integrated-as -c \
 // RUN: %S/Inputs/aix_ppc_tree/dummy0.s \
 // RUN: %S/Inputs/aix_ppc_tree/dummy1.s \
 // RUN: %S/Inputs/aix_ppc_tree/dummy2.s 2>&1 \
@@ -85,8 +85,8 @@
 // Check not passing no-integrated-as flag by default.
 // RUN: %clang %s -### -c 2>&1 --target=powerpc64-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefix=CHECK-IAS 
--implicit-check-not=-no-integrated-as %s
+// CHECK-IAS-NOT: "-a64"
 // CHECK-IAS: InstalledDir
-// CHECK-IAS: "-a64"
 
 // Check passing no-integrated-as flag if specified by user.
 // RUN: %clang %s -### -c 2>&1 --target=powerpc64-ibm-aix7.1.0.0 
-fno-integrated-as \

diff  --git a/clang/test/Driver/aix-integrated-as.c 
b/clang/test/Driver/aix-integrated-as.c
new file mode 100644
index 00..25e020c6f5a62a
--- /dev/null
+++ b/clang/test/Driver/aix-integrated-as.c
@@ -0,0 +1,15 @@
+// Test integrated-as is called by default on AIX.
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS32 %s
+// CHECK-IAS32-NOT: "-a32"
+// CHECK-IAS32: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" "-emit-obj"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS64 %s
+// CHECK-IAS64-NOT: "-a64"
+// CHECK-IAS64: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" "-emit-obj"



___
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-07-06 Thread Siva Chandra via Phabricator via cfe-commits
sivachandra added a comment.

The libc specific changes are really minimal straightforward. The GPU side, the 
clang driver changes etc. need a review by a GPU expert.




Comment at: libc/include/CMakeLists.txt:8
+if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
+  include(GetClangResourceDir)
+endif()

Where does this come from?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154036

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


[PATCH] D150758: [AIX] make integrated-as as default on AIX.

2023-07-06 Thread Esme Yi 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 rG533af6e5c4b3: [AIX] make integrated-as as default on AIX. 
(authored by Esme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150758

Files:
  clang/lib/Driver/ToolChains/AIX.h
  clang/test/Driver/aix-as.c
  clang/test/Driver/aix-integrated-as.c


Index: clang/test/Driver/aix-integrated-as.c
===
--- /dev/null
+++ clang/test/Driver/aix-integrated-as.c
@@ -0,0 +1,15 @@
+// Test integrated-as is called by default on AIX.
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS32 %s
+// CHECK-IAS32-NOT: "-a32"
+// CHECK-IAS32: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" "-emit-obj"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS64 %s
+// CHECK-IAS64-NOT: "-a64"
+// CHECK-IAS64: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" "-emit-obj"
Index: clang/test/Driver/aix-as.c
===
--- clang/test/Driver/aix-as.c
+++ clang/test/Driver/aix-as.c
@@ -11,7 +11,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-AS32 %s
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit.
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c -fno-integrated-as 2>&1 \
 // RUN: --target=powerpc-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefixes=CHECK-AS32,CHECK-AS32-CC1 %s
 // CHECK-AS32-NOT: warning:
@@ -30,7 +30,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-AS64 %s
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c -fno-integrated-as 2>&1 \
 // RUN: --target=powerpc64-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefixes=CHECK-AS64,CHECK-AS64-CC1 %s
 // CHECK-AS64-NOT: warning:
@@ -40,7 +40,7 @@
 // CHECK-AS64: "-many"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. -Xassembler  option. 
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c -fno-integrated-as 2>&1 \
 // RUN: -Xassembler -w \
 // RUN: --target=powerpc-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefix=CHECK-AS32-Xassembler %s
@@ -52,7 +52,7 @@
 // CHECK-AS32-Xassembler: "-w"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -Wa,, option.
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c -fno-integrated-as 2>&1 \
 // RUN: -Wa,-v,-w \
 // RUN: --target=powerpc64-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefix=CHECK-AS64-Wa %s
@@ -65,7 +65,7 @@
 // CHECK-AS64-Wa: "-w"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Multiple input files.
-// RUN: %clang -### -c \
+// RUN: %clang -### -fno-integrated-as -c \
 // RUN: %S/Inputs/aix_ppc_tree/dummy0.s \
 // RUN: %S/Inputs/aix_ppc_tree/dummy1.s \
 // RUN: %S/Inputs/aix_ppc_tree/dummy2.s 2>&1 \
@@ -85,8 +85,8 @@
 // Check not passing no-integrated-as flag by default.
 // RUN: %clang %s -### -c 2>&1 --target=powerpc64-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefix=CHECK-IAS 
--implicit-check-not=-no-integrated-as %s
+// CHECK-IAS-NOT: "-a64"
 // CHECK-IAS: InstalledDir
-// CHECK-IAS: "-a64"
 
 // Check passing no-integrated-as flag if specified by user.
 // RUN: %clang %s -### -c 2>&1 --target=powerpc64-ibm-aix7.1.0.0 
-fno-integrated-as \
Index: clang/lib/Driver/ToolChains/AIX.h
===
--- clang/lib/Driver/ToolChains/AIX.h
+++ clang/lib/Driver/ToolChains/AIX.h
@@ -68,6 +68,7 @@
   }
   bool isPICDefaultForced() const override { return true; }
   bool HasNativeLLVMSupport() const override { return true; }
+  bool IsIntegratedAssemblerDefault() const override { return true; }
 
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,


Index: clang/test/Driver/aix-integrated-as.c
===
--- /dev/null
+++ clang/test/Driver/aix-integrated-as.c
@@ -0,0 +1,15 @@
+// Test integrated-as is called by default on AIX.
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS32 %s
+// CHECK-IAS32-NOT: "-a32"
+// CHECK-IAS32: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" "-emit-obj"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS64 %s
+// CHECK-IAS64-NOT: "-a64"
+// CHECK-IAS64: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" "-emit-obj"
Index: clang/test/Driver/aix-as.c
=

[PATCH] D142702: [Clang][AArch64][SME] Generate target features from +(no)sme.* options

2023-07-06 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:87-90
+if (Feature == "sme") {
+  Features.push_back("+sve");
+  Features.push_back("+sve2");
+  Features.push_back("+bf16");

SME shouldn't require SVE or SVE2. You can see the dependence in AArch64.td. 
We've updated code in AArch64 target SelectionDAG with `HasSVEorSME` instead of 
`HasSVE` where needed, so that code can still compile when only using `+sme`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142702

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


[clang] 51feb1a - [RISCV] Use 'int' for return type for clz_64/clo_64 tests in riscv64-xtheadbb.c. NFC

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

Author: Craig Topper
Date: 2023-07-06T00:25:20-07:00
New Revision: 51feb1a72c5beb8f46d2f5569f3c3398f8902272

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

LOG: [RISCV] Use 'int' for return type for clz_64/clo_64 tests in 
riscv64-xtheadbb.c. NFC

This matches the definition for the underlying builtins and what
is done in the Zbb test.

Added: 


Modified: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c

Removed: 




diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c
index 3b6ef569e6b85f..70b04a66334e62 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c
@@ -29,25 +29,31 @@ int clo_32(int a) {
 
 // RV64XTHEADBB-LABEL: @clz_64(
 // RV64XTHEADBB-NEXT:  entry:
+// RV64XTHEADBB-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // RV64XTHEADBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
 // RV64XTHEADBB-NEXT:store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
 // RV64XTHEADBB-NEXT:[[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
 // RV64XTHEADBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[TMP0]], 
i1 false)
-// RV64XTHEADBB-NEXT:ret i64 [[TMP1]]
+// RV64XTHEADBB-NEXT:store i64 [[TMP1]], ptr [[RETVAL]], align 4
+// RV64XTHEADBB-NEXT:[[TMP2:%.*]] = load i32, ptr [[RETVAL]], align 4
+// RV64XTHEADBB-NEXT:ret i32 [[TMP2]]
 //
-long clz_64(long a) {
+int clz_64(long a) {
   return __builtin_riscv_clz_64(a);
 }
 
 // RV64XTHEADBB-LABEL: @clo_64(
 // RV64XTHEADBB-NEXT:  entry:
+// RV64XTHEADBB-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // RV64XTHEADBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
 // RV64XTHEADBB-NEXT:store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
 // RV64XTHEADBB-NEXT:[[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
 // RV64XTHEADBB-NEXT:[[NOT:%.*]] = xor i64 [[TMP0]], -1
 // RV64XTHEADBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[NOT]], 
i1 false)
-// RV64XTHEADBB-NEXT:ret i64 [[TMP1]]
+// RV64XTHEADBB-NEXT:store i64 [[TMP1]], ptr [[RETVAL]], align 4
+// RV64XTHEADBB-NEXT:[[TMP2:%.*]] = load i32, ptr [[RETVAL]], align 4
+// RV64XTHEADBB-NEXT:ret i32 [[TMP2]]
 //
-long clo_64(long a) {
+int clo_64(long a) {
   return __builtin_riscv_clz_64(~a);
 }



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


[clang] 7c9230c - [RISCV] Add trunc instruction to the __builtin_riscv_ctz_64/__builtin_riscv_clz_64 IR.

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

Author: Craig Topper
Date: 2023-07-06T00:55:16-07:00
New Revision: 7c9230c4f2ad267c716520fb25c4037acd2204fd

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

LOG: [RISCV] Add trunc instruction to the 
__builtin_riscv_ctz_64/__builtin_riscv_clz_64 IR.

These builtins were recently changed to return 'int' like the
similar __builtin_clz/__builtin_ctz builtins, but the IR generation
was not updated to use a truncate.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e0f3de0b8ddc41..c844aa7dfc5c38 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -20177,12 +20177,20 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 case RISCV::BI__builtin_riscv_clz_32:
 case RISCV::BI__builtin_riscv_clz_64: {
   Function *F = CGM.getIntrinsic(Intrinsic::ctlz, Ops[0]->getType());
-  return Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)});
+  Value *Result = Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)});
+  if (Result->getType() != ResultType)
+Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true,
+   "cast");
+  return Result;
 }
 case RISCV::BI__builtin_riscv_ctz_32:
 case RISCV::BI__builtin_riscv_ctz_64: {
   Function *F = CGM.getIntrinsic(Intrinsic::cttz, Ops[0]->getType());
-  return Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)});
+  Value *Result = Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)});
+  if (Result->getType() != ResultType)
+Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true,
+   "cast");
+  return Result;
 }
 
 // Zbc

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c
index 70b04a66334e62..44220627b36cf2 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c
@@ -29,14 +29,12 @@ int clo_32(int a) {
 
 // RV64XTHEADBB-LABEL: @clz_64(
 // RV64XTHEADBB-NEXT:  entry:
-// RV64XTHEADBB-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // RV64XTHEADBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
 // RV64XTHEADBB-NEXT:store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
 // RV64XTHEADBB-NEXT:[[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
 // RV64XTHEADBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[TMP0]], 
i1 false)
-// RV64XTHEADBB-NEXT:store i64 [[TMP1]], ptr [[RETVAL]], align 4
-// RV64XTHEADBB-NEXT:[[TMP2:%.*]] = load i32, ptr [[RETVAL]], align 4
-// RV64XTHEADBB-NEXT:ret i32 [[TMP2]]
+// RV64XTHEADBB-NEXT:[[CAST:%.*]] = trunc i64 [[TMP1]] to i32
+// RV64XTHEADBB-NEXT:ret i32 [[CAST]]
 //
 int clz_64(long a) {
   return __builtin_riscv_clz_64(a);
@@ -44,15 +42,13 @@ int clz_64(long a) {
 
 // RV64XTHEADBB-LABEL: @clo_64(
 // RV64XTHEADBB-NEXT:  entry:
-// RV64XTHEADBB-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // RV64XTHEADBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
 // RV64XTHEADBB-NEXT:store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
 // RV64XTHEADBB-NEXT:[[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
 // RV64XTHEADBB-NEXT:[[NOT:%.*]] = xor i64 [[TMP0]], -1
 // RV64XTHEADBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[NOT]], 
i1 false)
-// RV64XTHEADBB-NEXT:store i64 [[TMP1]], ptr [[RETVAL]], align 4
-// RV64XTHEADBB-NEXT:[[TMP2:%.*]] = load i32, ptr [[RETVAL]], align 4
-// RV64XTHEADBB-NEXT:ret i32 [[TMP2]]
+// RV64XTHEADBB-NEXT:[[CAST:%.*]] = trunc i64 [[TMP1]] to i32
+// RV64XTHEADBB-NEXT:ret i32 [[CAST]]
 //
 int clo_64(long a) {
   return __builtin_riscv_clz_64(~a);

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
index 62c5996241495b..3ca77235c2b3e9 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -40,14 +40,12 @@ int clz_32(unsigned int a) {
 
 // RV64ZBB-LABEL: @clz_64(
 // RV64ZBB-NEXT:  entry:
-// RV64ZBB-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
 // RV64ZBB-NEXT:store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
 // RV64ZBB-NEXT:[[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[TMP0]], i1 
false)
-// RV64ZBB-NEXT:store i64 [[TMP1]], ptr [[RETVAL]], align 

[PATCH] D152604: [Driver] Default -fsanitize-address-globals-dead-stripping to true for ELF

2023-07-06 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

In the realm of unintended consequences, this broke ODR violation detection 
when linking a rust static library with asan enabled because, while 
__asan_globals_registered is COMDAT in clang, for some reason, it's not in 
rust... So you end up with two asan.module_ctor that call 
__asan_register_elf_globals, each with their own __asan_globals_registered, but 
both using the same range of globals, so all globals are registered twice. 
(That's probably a bug in the rust compiler. I thought I'd mention this here in 
case someone follows the same path as I did)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152604

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


[PATCH] D154576: [RISCV] RISCV vector calling convention (1/2)

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

This is the vector calling convention based on
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/389,
the idea is to split between "scalar" callee-saved registers
and "vector" callee-saved registers. "scalar" ones remain the
original strategy, however, "vector" ones are handled together
with RVV objects.

The stack layout would be:

  |--| <-- FP
  | callee-allocated save|
  | area for register varargs|
  |--|
  | callee-saved registers   | <-- scalar callee-saved
  |(scalar)  |
  |--|
  | RVV alignment padding|
  |--|
  | callee-saved registers   | <-- vector callee-saved
  |(vector)  |
  |--|
  | RVV objects  |
  |--|
  | padding before RVV   |
  |--|
  | scalar local variables   |
  |--| <-- BP
  | variable size objects|
  |--| <-- SP

Note: This patch doesn't contain "tuple" type, e.g. vint32m1x2.

  It will be handled in future patch once the PR389 is ready.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154576

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/Specifiers.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/RISCV/riscv-vector-cc-attr.c
  llvm/include/llvm/AsmParser/LLToken.h
  llvm/include/llvm/IR/CallingConv.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/Target/RISCV/RISCVCallingConv.td
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/test/CodeGen/RISCV/rvv/callee-saved-regs.ll

Index: llvm/test/CodeGen/RISCV/rvv/callee-saved-regs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rvv/callee-saved-regs.ll
@@ -0,0 +1,222 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+m -mattr=+v -O2 < %s \
+; RUN:| FileCheck --check-prefix=SPILL-O2 %s
+
+define  @test_vector_std( %va) nounwind {
+; SPILL-O2-LABEL: test_vector_std:
+; SPILL-O2:   # %bb.0: # %entry
+; SPILL-O2-NEXT:addi sp, sp, -16
+; SPILL-O2-NEXT:csrr a0, vlenb
+; SPILL-O2-NEXT:slli a0, a0, 1
+; SPILL-O2-NEXT:sub sp, sp, a0
+; SPILL-O2-NEXT:addi a0, sp, 16
+; SPILL-O2-NEXT:vs1r.v v8, (a0) # Unknown-size Folded Spill
+; SPILL-O2-NEXT:#APP
+; SPILL-O2-NEXT:#NO_APP
+; SPILL-O2-NEXT:vl1r.v v8, (a0) # Unknown-size Folded Reload
+; SPILL-O2-NEXT:csrr a0, vlenb
+; SPILL-O2-NEXT:slli a0, a0, 1
+; SPILL-O2-NEXT:add sp, sp, a0
+; SPILL-O2-NEXT:addi sp, sp, 16
+; SPILL-O2-NEXT:ret
+entry:
+  call void asm sideeffect "",
+  "~{v0},~{v1},~{v2},~{v3},~{v4},~{v5},~{v6},~{v7},~{v8},~{v9},~{v10},~{v11},~{v12},~{v13},~{v14},~{v15},~{v16},~{v17},~{v18},~{v19},~{v20},~{v21},~{v22},~{v23},~{v24},~{v25},~{v26},~{v27},~{v28},~{v29},~{v30},~{v31}"()
+
+  ret  %va
+}
+
+define riscv_vector_cc  @test_vector_callee( %va) nounwind {
+; SPILL-O2-LABEL: test_vector_callee:
+; SPILL-O2:   # %bb.0: # %entry
+; SPILL-O2-NEXT:addi sp, sp, -16
+; SPILL-O2-NEXT:csrr a0, vlenb
+; SPILL-O2-NEXT:slli a0, a0, 4
+; SPILL-O2-NEXT:sub sp, sp, a0
+; SPILL-O2-NEXT:csrr a0, vlenb
+; SPILL-O2-NEXT:li a1, 14
+; SPILL-O2-NEXT:mul a0, a0, a1
+; SPILL-O2-NEXT:add a0, sp, a0
+; SPILL-O2-NEXT:addi a0, a0, 16
+; SPILL-O2-NEXT:vs1r.v v1, (a0) # Unknown-size Folded Spill
+; SPILL-O2-NEXT:csrr a0, vlenb
+; SPILL-O2-NEXT:li a1, 13
+; SPILL-O2-NEXT:mul a0, a0, a1
+; SPILL-O2-NEXT:add a0, sp, a0
+; SPILL-O2-NEXT:addi a0, a0, 16
+; SPILL-O2-NEXT:vs1r.v v2, (a0) # Unknown-size Folded Spill
+; SPILL-O2-NEXT:csrr a0, vlenb
+; SPILL-O2-NEXT:li a1, 12
+; SPILL-O2-NEXT:mul a0, a0, a1
+; SPILL-O2-NEXT:add a0, sp, a0
+; SPILL-O2-NEXT:addi a0, a0, 16
+; SPILL-O2-NEXT:vs1r.v v3, (a0) # Un

[PATCH] D154572: [RISCV] Use 'long' in aes64 Zknd/Zkne builtin tests. NFC

2023-07-06 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng 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/D154572/new/

https://reviews.llvm.org/D154572

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


[PATCH] D154577: [RISCV] Use 'long' in sha512 builtin tests. NFC

2023-07-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: kito-cheng, asb, VincentWu.
Herald added subscribers: jobnoorman, luke, 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, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: wangpc, eopXD, MaskRay.
Herald added a project: clang.

This matches the data type of the intrinsics. This case be seen
from the removal of sext and trunc instructions from the IR.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154577

Files:
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c


Index: clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
===
--- clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
+++ clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
@@ -5,60 +5,52 @@
 
 // RV64ZKNH-LABEL: @sha512sig0(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig0(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig0(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sig0(int rs1) {
+long sha512sig0(long rs1) {
   return __builtin_riscv_sha512sig0_64(rs1);
 }
 
 
 // RV64ZKNH-LABEL: @sha512sig1(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig1(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig1(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sig1(int rs1) {
+long sha512sig1(long rs1) {
   return __builtin_riscv_sha512sig1_64(rs1);
 }
 
 
 // RV64ZKNH-LABEL: @sha512sum0(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum0(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum0(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sum0(int rs1) {
+long sha512sum0(long rs1) {
   return __builtin_riscv_sha512sum0_64(rs1);
 }
 
 
 // RV64ZKNH-LABEL: @sha512sum1(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum1(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum1(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sum1(int rs1) {
+long sha512sum1(long rs1) {
   return __builtin_riscv_sha512sum1_64(rs1);
 }
 


Index: clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
=

[PATCH] D154576: [RISCV] RISCV vector calling convention (1/2)

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

Does this only change the calling convention when 
`__attribute__((riscv_vector_cc))` is used? The attribute should be mentioned 
in the patch description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154576

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


[clang] ac03e3f - [RISCV] Use 'long' in aes64 Zknd/Zkne builtin tests. NFC

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

Author: Craig Topper
Date: 2023-07-06T01:14:02-07:00
New Revision: ac03e3f51c271b985efeb0fe6b9782cd6928be33

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

LOG: [RISCV] Use 'long' in aes64 Zknd/Zkne builtin tests. NFC

This matches the data type of the intrinsics. This case be seen
from the removal of sext and trunc instructions from the IR.

Reviewed By: kito-cheng

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

Added: 


Modified: 
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c

Removed: 




diff  --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c 
b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
index 1132c98ef595f2..3596c451a611d9 100644
--- a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
@@ -6,32 +6,27 @@
 
 // RV64ZKND-ZKNE-LABEL: @aes64ks1i(
 // RV64ZKND-ZKNE-NEXT:  entry:
-// RV64ZKND-ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKND-ZKNE-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKND-ZKNE-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKND-ZKNE-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKND-ZKNE-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.aes64ks1i(i64 
[[CONV]], i32 0)
-// RV64ZKND-ZKNE-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKND-ZKNE-NEXT:ret i32 [[CONV1]]
+// RV64ZKND-ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKND-ZKNE-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKND-ZKNE-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKND-ZKNE-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.aes64ks1i(i64 
[[TMP0]], i32 0)
+// RV64ZKND-ZKNE-NEXT:ret i64 [[TMP1]]
 //
-int aes64ks1i(int rs1) {
+long aes64ks1i(long rs1) {
   return __builtin_riscv_aes64ks1i_64(rs1, 0);
 }
 
 // RV64ZKND-ZKNE-LABEL: @aes64ks2(
 // RV64ZKND-ZKNE-NEXT:  entry:
-// RV64ZKND-ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKND-ZKNE-NEXT:[[RS2_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKND-ZKNE-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKND-ZKNE-NEXT:store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4
-// RV64ZKND-ZKNE-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKND-ZKNE-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKND-ZKNE-NEXT:[[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4
-// RV64ZKND-ZKNE-NEXT:[[CONV1:%.*]] = sext i32 [[TMP1]] to i64
-// RV64ZKND-ZKNE-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64ks2(i64 
[[CONV]], i64 [[CONV1]])
-// RV64ZKND-ZKNE-NEXT:[[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
-// RV64ZKND-ZKNE-NEXT:ret i32 [[CONV2]]
+// RV64ZKND-ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKND-ZKNE-NEXT:[[RS2_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKND-ZKNE-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKND-ZKNE-NEXT:store i64 [[RS2:%.*]], ptr [[RS2_ADDR]], align 8
+// RV64ZKND-ZKNE-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKND-ZKNE-NEXT:[[TMP1:%.*]] = load i64, ptr [[RS2_ADDR]], align 8
+// RV64ZKND-ZKNE-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64ks2(i64 
[[TMP0]], i64 [[TMP1]])
+// RV64ZKND-ZKNE-NEXT:ret i64 [[TMP2]]
 //
-int aes64ks2(int rs1, int rs2) {
+long aes64ks2(long rs1, long rs2) {
   return __builtin_riscv_aes64ks2_64(rs1, rs2);
 }

diff  --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c 
b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
index 94a1da79badb25..379587134dd636 100644
--- a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
@@ -5,52 +5,44 @@
 
 // RV64ZKND-LABEL: @aes64dsm(
 // RV64ZKND-NEXT:  entry:
-// RV64ZKND-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKND-NEXT:[[RS2_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKND-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKND-NEXT:store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4
-// RV64ZKND-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKND-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKND-NEXT:[[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4
-// RV64ZKND-NEXT:[[CONV1:%.*]] = sext i32 [[TMP1]] to i64
-// RV64ZKND-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64dsm(i64 
[[CONV]], i64 [[CONV1]])
-// RV64ZKND-NEXT:[[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
-// RV64ZKND-NEXT:ret i32 [[CONV2]]
+// RV64ZKND-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKND-NE

[PATCH] D154572: [RISCV] Use 'long' in aes64 Zknd/Zkne builtin tests. NFC

2023-07-06 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 rGac03e3f51c27: [RISCV] Use 'long' in aes64 
Zknd/Zkne builtin tests. NFC (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154572

Files:
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c

Index: clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
===
--- clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
+++ clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
@@ -5,37 +5,31 @@
 
 // RV64ZKNE-LABEL: @aes64es(
 // RV64ZKNE-NEXT:  entry:
-// RV64ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNE-NEXT:[[RS2_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNE-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNE-NEXT:store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4
-// RV64ZKNE-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNE-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNE-NEXT:[[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4
-// RV64ZKNE-NEXT:[[CONV1:%.*]] = sext i32 [[TMP1]] to i64
-// RV64ZKNE-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64es(i64 [[CONV]], i64 [[CONV1]])
-// RV64ZKNE-NEXT:[[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
-// RV64ZKNE-NEXT:ret i32 [[CONV2]]
+// RV64ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNE-NEXT:[[RS2_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNE-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNE-NEXT:store i64 [[RS2:%.*]], ptr [[RS2_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP1:%.*]] = load i64, ptr [[RS2_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64es(i64 [[TMP0]], i64 [[TMP1]])
+// RV64ZKNE-NEXT:ret i64 [[TMP2]]
 //
-int aes64es(int rs1, int rs2) {
+long aes64es(long rs1, long rs2) {
   return __builtin_riscv_aes64es_64(rs1, rs2);
 }
 
 
 // RV64ZKNE-LABEL: @aes64esm(
 // RV64ZKNE-NEXT:  entry:
-// RV64ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNE-NEXT:[[RS2_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNE-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNE-NEXT:store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4
-// RV64ZKNE-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNE-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNE-NEXT:[[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4
-// RV64ZKNE-NEXT:[[CONV1:%.*]] = sext i32 [[TMP1]] to i64
-// RV64ZKNE-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64esm(i64 [[CONV]], i64 [[CONV1]])
-// RV64ZKNE-NEXT:[[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
-// RV64ZKNE-NEXT:ret i32 [[CONV2]]
+// RV64ZKNE-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNE-NEXT:[[RS2_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNE-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNE-NEXT:store i64 [[RS2:%.*]], ptr [[RS2_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP1:%.*]] = load i64, ptr [[RS2_ADDR]], align 8
+// RV64ZKNE-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64esm(i64 [[TMP0]], i64 [[TMP1]])
+// RV64ZKNE-NEXT:ret i64 [[TMP2]]
 //
-int aes64esm(int rs1, int rs2) {
+long aes64esm(long rs1, long rs2) {
   return __builtin_riscv_aes64esm_64(rs1, rs2);
 }
Index: clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
===
--- clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
+++ clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
@@ -5,52 +5,44 @@
 
 // RV64ZKND-LABEL: @aes64dsm(
 // RV64ZKND-NEXT:  entry:
-// RV64ZKND-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKND-NEXT:[[RS2_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKND-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKND-NEXT:store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4
-// RV64ZKND-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKND-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKND-NEXT:[[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4
-// RV64ZKND-NEXT:[[CONV1:%.*]] = sext i32 [[TMP1]] to i64
-// RV64ZKND-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.aes64dsm(i64 [[CONV]], i64 [[CONV1]])
-// RV64ZKND-NEXT:[[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
-// RV64ZKND-NEXT:ret i32 [[CONV2]]
+// RV64ZKND-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKND-NEXT:[[RS2_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKND-NEXT:store i64 [[RS1:%.*]], ptr

[PATCH] D154576: [RISCV] RISCV vector calling convention (1/2)

2023-07-06 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added a comment.

In D154576#4476291 , @craig.topper 
wrote:

> Does this only change the calling convention when 
> `__attribute__((riscv_vector_cc))` is used? The attribute should be mentioned 
> in the patch description.

Yes it only changes when __attribute__((riscv_vector_cc)) is used, thanks for 
reminding, I will mention in the description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154576

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


[PATCH] D154578: [ARM][Driver] Change float-abi warning

2023-07-06 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings created this revision.
michaelplatings added a reviewer: simon_tatham.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
michaelplatings requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously the warning stated "flag ignored" which is only partially
true - the invalid flag would prevent -feature +soft-float-abi from
being emitted which resulted in user-visible behaviour like
__ARM_PCS_VFP being defined.

Rather than attempt to coerce invalid flags into valid behaviour, don't
describe the expected behaviour.

Ideally the warning would be an error, as it is in GCC. However there
are tests in llvm-project that trigger the warning. Therefore one has to
assume that making the warning an error would break other code that
already exists in the wild.

Also apply test improvements suggested by @MaskRay on D150902 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154578

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/test/Driver/arm-no-float-regs.c


Index: clang/test/Driver/arm-no-float-regs.c
===
--- clang/test/Driver/arm-no-float-regs.c
+++ clang/test/Driver/arm-no-float-regs.c
@@ -1,7 +1,6 @@
-// REQUIRES: arm-registered-target
-
 // Check that -mfloat-abi=hard gives a warning if FP registers aren't 
available.
-// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mfloat-abi=hard -### -c 
%s 2>&1
+// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mfloat-abi=hard -### -c 
%s 2>&1 \
+// RUN:   | FileCheck %s
 
 // RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mhard-float -### -c %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=HARDFLOAT %s
@@ -20,4 +19,4 @@
 
 // CHECK: warning: '-mfloat-abi=hard': selected processor lacks floating point 
registers
 // HARDFLOAT: warning: '-mhard-float': selected processor lacks floating point 
registers
-// NOWARN-NOT: selected processor lacks floating point registers
+// NOWARN-NOT: warning:
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -418,8 +418,8 @@
   "float ABI '%0' is not supported by current library">,
   InGroup>;
 def warn_drv_no_floating_point_registers: Warning<
-  "'%0': selected processor lacks floating point registers; flag ignored">,
-  InGroup;
+  "'%0': selected processor lacks floating point registers">,
+  InGroup>;
 def warn_ignoring_ftabstop_value : Warning<
   "ignoring invalid -ftabstop value '%0', using default value %1">;
 def warn_drv_overriding_flag_option : Warning<


Index: clang/test/Driver/arm-no-float-regs.c
===
--- clang/test/Driver/arm-no-float-regs.c
+++ clang/test/Driver/arm-no-float-regs.c
@@ -1,7 +1,6 @@
-// REQUIRES: arm-registered-target
-
 // Check that -mfloat-abi=hard gives a warning if FP registers aren't available.
-// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mfloat-abi=hard -### -c %s 2>&1
+// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mfloat-abi=hard -### -c %s 2>&1 \
+// RUN:   | FileCheck %s
 
 // RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mhard-float -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=HARDFLOAT %s
@@ -20,4 +19,4 @@
 
 // CHECK: warning: '-mfloat-abi=hard': selected processor lacks floating point registers
 // HARDFLOAT: warning: '-mhard-float': selected processor lacks floating point registers
-// NOWARN-NOT: selected processor lacks floating point registers
+// NOWARN-NOT: warning:
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -418,8 +418,8 @@
   "float ABI '%0' is not supported by current library">,
   InGroup>;
 def warn_drv_no_floating_point_registers: Warning<
-  "'%0': selected processor lacks floating point registers; flag ignored">,
-  InGroup;
+  "'%0': selected processor lacks floating point registers">,
+  InGroup>;
 def warn_ignoring_ftabstop_value : Warning<
   "ignoring invalid -ftabstop value '%0', using default value %1">;
 def warn_drv_overriding_flag_option : Warning<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6b8a9ff - [clang-format] Fix RAS reference alignment when PAS is left or middle

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

Author: Gedare Bloom
Date: 2023-07-06T01:41:16-07:00
New Revision: 6b8a9ff7e74fcf00a5b37c505abcd3d290b2d3c2

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

LOG: [clang-format] Fix RAS reference alignment when PAS is left or middle

Fixes a bug with the handling of right aligned references with left/middle
alignment pointers.

Fixes #63452.

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

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index 24255522263ad1..18e9e043bc89f5 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -445,12 +445,24 @@ AlignTokenSequence(const FormatStyle &Style, unsigned 
Start, unsigned End,
   Changes[i + 1].PreviousEndOfTokenColumn += Shift;
 
 // If PointerAlignment is PAS_Right, keep *s or &s next to the token
-if (Style.PointerAlignment == FormatStyle::PAS_Right &&
+if ((Style.PointerAlignment == FormatStyle::PAS_Right ||
+ Style.ReferenceAlignment == FormatStyle::RAS_Right) &&
 Changes[i].Spaces != 0) {
+  const bool ReferenceNotRightAligned =
+  Style.ReferenceAlignment != FormatStyle::RAS_Right &&
+  Style.ReferenceAlignment != FormatStyle::RAS_Pointer;
   for (int Previous = i - 1;
Previous >= 0 &&
Changes[Previous].Tok->getType() == TT_PointerOrReference;
--Previous) {
+assert(
+Changes[Previous].Tok->isOneOf(tok::star, tok::amp, tok::ampamp));
+if (Changes[Previous].Tok->isNot(tok::star)) {
+  if (ReferenceNotRightAligned)
+continue;
+} else if (Style.PointerAlignment != FormatStyle::PAS_Right) {
+  continue;
+}
 Changes[Previous + 1].Spaces -= Shift;
 Changes[Previous].Spaces += Shift;
 Changes[Previous].StartOfTokenColumn += Shift;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index a4f2b8300a2735..e0a0a0d004d541 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2189,6 +2189,15 @@ TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
   verifyFormat("for (int a = 0, b = 0; const Foo * c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b++; const Foo * c : {1, 2, 3})", Style);
 
+  Style.AlignConsecutiveDeclarations.Enabled = true;
+  verifyFormat("Const unsigned int * c;\n"
+   "const unsigned int * d;\n"
+   "Const unsigned int  &e;\n"
+   "const unsigned int  &f;\n"
+   "const unsigned &&g;\n"
+   "Const unsigned   h;",
+   Style);
+
   // FIXME: we don't handle this yet, so output may be arbitrary until it's
   // specifically handled
   // verifyFormat("int Add2(BTree * &Root, char * szToAdd)", Style);



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


[PATCH] D153579: [clang-format] Fix RAS reference alignment when PAS is left or middle

2023-07-06 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b8a9ff7e74f: [clang-format] Fix RAS reference alignment 
when PAS is left or middle (authored by gedare, committed by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153579

Files:
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2189,6 +2189,15 @@
   verifyFormat("for (int a = 0, b = 0; const Foo * c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b++; const Foo * c : {1, 2, 3})", Style);
 
+  Style.AlignConsecutiveDeclarations.Enabled = true;
+  verifyFormat("Const unsigned int * c;\n"
+   "const unsigned int * d;\n"
+   "Const unsigned int  &e;\n"
+   "const unsigned int  &f;\n"
+   "const unsigned &&g;\n"
+   "Const unsigned   h;",
+   Style);
+
   // FIXME: we don't handle this yet, so output may be arbitrary until it's
   // specifically handled
   // verifyFormat("int Add2(BTree * &Root, char * szToAdd)", Style);
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -445,12 +445,24 @@
   Changes[i + 1].PreviousEndOfTokenColumn += Shift;
 
 // If PointerAlignment is PAS_Right, keep *s or &s next to the token
-if (Style.PointerAlignment == FormatStyle::PAS_Right &&
+if ((Style.PointerAlignment == FormatStyle::PAS_Right ||
+ Style.ReferenceAlignment == FormatStyle::RAS_Right) &&
 Changes[i].Spaces != 0) {
+  const bool ReferenceNotRightAligned =
+  Style.ReferenceAlignment != FormatStyle::RAS_Right &&
+  Style.ReferenceAlignment != FormatStyle::RAS_Pointer;
   for (int Previous = i - 1;
Previous >= 0 &&
Changes[Previous].Tok->getType() == TT_PointerOrReference;
--Previous) {
+assert(
+Changes[Previous].Tok->isOneOf(tok::star, tok::amp, tok::ampamp));
+if (Changes[Previous].Tok->isNot(tok::star)) {
+  if (ReferenceNotRightAligned)
+continue;
+} else if (Style.PointerAlignment != FormatStyle::PAS_Right) {
+  continue;
+}
 Changes[Previous + 1].Spaces -= Shift;
 Changes[Previous].Spaces += Shift;
 Changes[Previous].StartOfTokenColumn += Shift;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2189,6 +2189,15 @@
   verifyFormat("for (int a = 0, b = 0; const Foo * c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b++; const Foo * c : {1, 2, 3})", Style);
 
+  Style.AlignConsecutiveDeclarations.Enabled = true;
+  verifyFormat("Const unsigned int * c;\n"
+   "const unsigned int * d;\n"
+   "Const unsigned int  &e;\n"
+   "const unsigned int  &f;\n"
+   "const unsigned &&g;\n"
+   "Const unsigned   h;",
+   Style);
+
   // FIXME: we don't handle this yet, so output may be arbitrary until it's
   // specifically handled
   // verifyFormat("int Add2(BTree * &Root, char * szToAdd)", Style);
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -445,12 +445,24 @@
   Changes[i + 1].PreviousEndOfTokenColumn += Shift;
 
 // If PointerAlignment is PAS_Right, keep *s or &s next to the token
-if (Style.PointerAlignment == FormatStyle::PAS_Right &&
+if ((Style.PointerAlignment == FormatStyle::PAS_Right ||
+ Style.ReferenceAlignment == FormatStyle::RAS_Right) &&
 Changes[i].Spaces != 0) {
+  const bool ReferenceNotRightAligned =
+  Style.ReferenceAlignment != FormatStyle::RAS_Right &&
+  Style.ReferenceAlignment != FormatStyle::RAS_Pointer;
   for (int Previous = i - 1;
Previous >= 0 &&
Changes[Previous].Tok->getType() == TT_PointerOrReference;
--Previous) {
+assert(
+Changes[Previous].Tok->isOneOf(tok::star, tok::amp, tok::ampamp));
+if (Changes[Previous].Tok->isNot(tok::star)) {
+  if (ReferenceNotRightAligned)
+continue;
+} else if (Style.PointerAlignment != FormatStyle::PAS_Right) {
+  continue;
+}
 Changes[Previous + 1].Spaces -= Shift;
 Changes[Previous].Spaces += Shift;
 Changes[Previous].StartOfTokenColumn += Shift

[PATCH] D154580: Add missing semantic highlighing for concepts.

2023-07-06 Thread Jens Massberg via Phabricator via cfe-commits
massberg created this revision.
massberg added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
massberg requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154580

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -648,6 +648,15 @@
   void $Function_def[[bar]]($TemplateParameter[[T]] $Parameter_def[[F]]) {
 $Parameter[[F]].$Unknown_dependentName[[foo]]();
   }
+
+  struct $Class_def[[F]] {
+void $Method_def[[foo]]() {};
+  };
+  $Concept[[Fooable]] auto $Variable_def[[f]] = $Class[[F]]();
+
+  void $Function_def[[Bar]]($Concept[[Fooable]] $TemplateParameter[[auto]] 
$Parameter_def[[x]]) {}
+
+  template$Bracket[[<]]$Concept[[Fooable]] auto 
$TemplateParameter_def_readonly[[x]]$Bracket[[>]] void $Function_def[[Boo]]() {}
 )cpp",
   // Dependent template name
   R"cpp(
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -737,8 +737,10 @@
   }
 
   bool VisitAutoTypeLoc(AutoTypeLoc L) {
-if (L.isConstrained())
+if (L.isConstrained()) {
   H.addAngleBracketTokens(L.getLAngleLoc(), L.getRAngleLoc());
+  H.addToken(L.getConceptNameInfo().getLoc(), HighlightingKind::Concept);
+}
 return true;
   }
 
@@ -960,6 +962,14 @@
 // in both it and the token for the decl being dropped due to conflict.
 if (StartLoc == D->getLocation())
   return true;
+
+if (auto *TSI = D->getTypeSourceInfo()) {
+   auto ATL = TSI->getTypeLoc().getContainedAutoTypeLoc();
+   if (ATL.isConstrained()) {
+ StartLoc = ATL.getConceptNameInfo().getEndLoc().getLocWithOffset(1);
+   }
+}
+
 auto &Tok =
 H.addToken(StartLoc, *K).addModifier(HighlightingModifier::Deduced);
 const Type *Deduced = AT->getDeducedType().getTypePtrOrNull();


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -648,6 +648,15 @@
   void $Function_def[[bar]]($TemplateParameter[[T]] $Parameter_def[[F]]) {
 $Parameter[[F]].$Unknown_dependentName[[foo]]();
   }
+
+  struct $Class_def[[F]] {
+void $Method_def[[foo]]() {};
+  };
+  $Concept[[Fooable]] auto $Variable_def[[f]] = $Class[[F]]();
+
+  void $Function_def[[Bar]]($Concept[[Fooable]] $TemplateParameter[[auto]] $Parameter_def[[x]]) {}
+
+  template$Bracket[[<]]$Concept[[Fooable]] auto $TemplateParameter_def_readonly[[x]]$Bracket[[>]] void $Function_def[[Boo]]() {}
 )cpp",
   // Dependent template name
   R"cpp(
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -737,8 +737,10 @@
   }
 
   bool VisitAutoTypeLoc(AutoTypeLoc L) {
-if (L.isConstrained())
+if (L.isConstrained()) {
   H.addAngleBracketTokens(L.getLAngleLoc(), L.getRAngleLoc());
+  H.addToken(L.getConceptNameInfo().getLoc(), HighlightingKind::Concept);
+}
 return true;
   }
 
@@ -960,6 +962,14 @@
 // in both it and the token for the decl being dropped due to conflict.
 if (StartLoc == D->getLocation())
   return true;
+
+if (auto *TSI = D->getTypeSourceInfo()) {
+   auto ATL = TSI->getTypeLoc().getContainedAutoTypeLoc();
+   if (ATL.isConstrained()) {
+ StartLoc = ATL.getConceptNameInfo().getEndLoc().getLocWithOffset(1);
+   }
+}
+
 auto &Tok =
 H.addToken(StartLoc, *K).addModifier(HighlightingModifier::Deduced);
 const Type *Deduced = AT->getDeducedType().getTypePtrOrNull();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153296: [AST] Stop evaluate constant expression if the condition expression which in switch statement contains errors

2023-07-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:4921
+  // value is.
+  if (isa(E))
+return false;

aaron.ballman wrote:
> hokein wrote:
> > hokein wrote:
> > > hokein wrote:
> > > > yronglin wrote:
> > > > > yronglin wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > yronglin wrote:
> > > > > > > > hokein wrote:
> > > > > > > > > The constant evaluator is not aware of the "error" concept, 
> > > > > > > > > it is only aware of value-dependent -- the general idea 
> > > > > > > > > behind is that we treat the dependent-on-error and 
> > > > > > > > > dependent-on-template-parameters cases the same, they are 
> > > > > > > > > potentially constant (if we see an expression contains 
> > > > > > > > > errors, it could be constant depending on how the error is 
> > > > > > > > > resolved), this will give us nice recovery and avoid bogus 
> > > > > > > > > following diagnostics.
> > > > > > > > > 
> > > > > > > > > So, a `RecoveryExpr` should not result in failure when 
> > > > > > > > > checking for a potential constant expression.
> > > > > > > > > 
> > > > > > > > > I think the right fix is to remove the conditional check `if 
> > > > > > > > > (!EvaluateDependentExpr(SS->getCond(), Info))` in 
> > > > > > > > > `EvaluateSwitch`, and return `ESR_Failed` unconditionally (we 
> > > > > > > > > don't know its value, any switch-case anwser will be wrong in 
> > > > > > > > > some cases). We already do this for return-statment, 
> > > > > > > > > do-statement etc.
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > Do you mean?
> > > > > > > > ```
> > > > > > > > if (SS->getCond()->isValueDependent()) {
> > > > > > > > EvaluateDependentExpr(SS->getCond(), Info);
> > > > > > > > return ESR_Failed;
> > > > > > > > }
> > > > > > > > ```
> > > > > > > > the general idea behind is that we treat the dependent-on-error 
> > > > > > > > and dependent-on-template-parameters cases the same, they are 
> > > > > > > > potentially constant (if we see an expression contains errors, 
> > > > > > > > it could be constant depending on how the error is resolved), 
> > > > > > > > this will give us nice recovery and avoid bogus following 
> > > > > > > > diagnostics.
> > > > > > > 
> > > > > > > I could use some further education on why this is the correct 
> > > > > > > approach. For a dependent-on-template-parameters case, this makes 
> > > > > > > sense -- either the template will be instantiated (at which point 
> > > > > > > we'll know if it's a constant expression) or it won't be (at 
> > > > > > > which point it's constant expression-ness doesn't matter). But 
> > > > > > > for error recovery, we will *never* get a valid constant 
> > > > > > > expression.
> > > > > > > 
> > > > > > > I worry about the performance overhead of continuing on with 
> > > > > > > constant expression evaluation in the error case. We use these 
> > > > > > > code paths not only to get a value but to say "is this a constant 
> > > > > > > expression at all?".
> > > > > > > 
> > > > > > > I don't see why the fix should be localized to just the switch 
> > > > > > > statement condition; it seems like *any* attempt to get a 
> > > > > > > dependent value from an error recovery expression is a point at 
> > > > > > > which we can definitively say "this is not a constant expression" 
> > > > > > > and move on.
> > > > > > I understand that continuing to perform constant evaluation when an 
> > > > > > error occurs can bring more additional diagnostic information (such 
> > > > > > as jumping to the default branch to continue calculation when the 
> > > > > > condition expression evaluation of switch-statement fails), but the 
> > > > > > additional diagnostic message that is emitted is in some cases 
> > > > > > doesn't usually useful, and as Aaron said may affect performance of 
> > > > > > clang. I don't have enough experience to make a tradeoff between 
> > > > > > the two. BTW 
> > > > > > https://github.com/llvm/llvm-project/blob/843ff7581408a02e852c0f1f7ebf176cabbc7527/clang/lib/Parse/ParseStmt.cpp#L1894-L1909
> > > > > >  I don't quite understand why a RecoveryExpr is not created here, 
> > > > > > which caused to the whole do statement disappears on the 
> > > > > > AST(https://godbolt.org/z/PsPb31YKP), should we fix this? 
> > > > > Thanks a lot for your comments! @aaron.ballman 
> > > > > But for error recovery, we will *never* get a valid constant 
> > > > > expression.
> > > > 
> > > > Yeah, this is true, and we don't evaluate these error-dependent 
> > > > expressions.
> > > > 
> > > > I think the question here is that when we encounter an error-dependent 
> > > > expression during a constant expression evaluation, do we want to 
> > > > bailout the whole evaluation immediately, or just ignore the evaluation 
> > > > of this error-dependent expression and continue to proceed when 
> > > > possible?
> > > > 
> > > > We choose 2) -- this was based on the discussion w

[PATCH] D154581: [clang][Interp] Track existing InitMaps in InterpState

2023-07-06 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, cor3ntin, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

InitMaps are created for primitive arrays when the first element of the arrays 
is initialized, and they are free'd when the last element is initialized, 
leaving the array in a fully initialized state.

The initmap is also free'd in the `Descriptor`'s destructor function, which is 
called at the end of a scope.

This works fine when the execution of the program is not interrupted. However, 
when it is, we never destroy the scopes, leaving the initmaps behind.

To fix this, track the initmaps in `InterpState` and free them manually in 
`~InterpState()`, so we don't leak the memory and fail on LSan enabled builders.

(Side note: There is a similar problem with the current handling of floating 
point numbers, i.e. the `APFloat` might heap allocate some memory and we will 
leak this when the execution is interrupted).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154581

Files:
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Descriptor.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpBlock.h
  clang/lib/AST/Interp/InterpState.cpp
  clang/lib/AST/Interp/InterpState.h
  clang/lib/AST/Interp/Pointer.cpp
  clang/lib/AST/Interp/Pointer.h
  clang/test/AST/Interp/arrays.cpp

Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -350,3 +350,25 @@
   static_assert(b.f[0] == 0.0, "");
   static_assert(b.f[1] == 0.0, "");
 }
+
+namespace NoInitMapLeak {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdivision-by-zero"
+#pragma clang diagnostic ignored "-Wc++20-extensions"
+  constexpr int testLeak() { // expected-error {{never produces a constant expression}} \
+ // ref-error {{never produces a constant expression}}
+int a[2];
+a[0] = 1;
+// interrupts interpretation.
+(void)(1 / 0); // expected-note 2{{division by zero}} \
+   // ref-note 2{{division by zero}}
+
+
+return 1;
+  }
+#pragma clang diagnostic pop
+  static_assert(testLeak() == 1, ""); // expected-error {{not an integral constant expression}} \
+  // expected-note {{in call to 'testLeak()'}} \
+  // ref-error {{not an integral constant expression}} \
+  // ref-note {{in call to 'testLeak()'}}
+}
Index: clang/lib/AST/Interp/Pointer.h
===
--- clang/lib/AST/Interp/Pointer.h
+++ clang/lib/AST/Interp/Pointer.h
@@ -353,7 +353,7 @@
   }
 
   /// Initializes a field.
-  void initialize() const;
+  void initialize(InterpState &S) const;
   /// Activats a field.
   void activate() const;
   /// Deactivates an entire strurcutre.
Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -13,6 +13,7 @@
 #include "Function.h"
 #include "Integral.h"
 #include "InterpBlock.h"
+#include "InterpState.h"
 #include "PrimType.h"
 #include "Record.h"
 
@@ -177,7 +178,7 @@
   return Base == 0 || getInlineDesc()->IsInitialized;
 }
 
-void Pointer::initialize() const {
+void Pointer::initialize(InterpState &S) const {
   assert(Pointee && "Cannot initialize null pointer");
   const Descriptor *Desc = getFieldDesc();
 
@@ -192,9 +193,9 @@
 if (Map == (InitMap *)-1)
   return;
 if (Map == nullptr)
-  Map = InitMap::allocate(Desc->getNumElems());
+  Map = S.allocateInitMap(Desc->getNumElems());
 if (Map->initialize(getIndex())) {
-  free(Map);
+  S.deallocateInitMap(Map);
   Map = (InitMap *)-1;
 }
   }
Index: clang/lib/AST/Interp/InterpState.h
===
--- clang/lib/AST/Interp/InterpState.h
+++ clang/lib/AST/Interp/InterpState.h
@@ -91,6 +91,10 @@
 
   Context &getContext() const { return Ctx; }
 
+  /// InitMap handling.
+  InitMap *allocateInitMap(unsigned N);
+  void deallocateInitMap(InitMap *IM);
+
 private:
   /// AST Walker state.
   State &Parent;
@@ -98,6 +102,8 @@
   DeadBlock *DeadBlocks = nullptr;
   /// Reference to the offset-source mapping.
   SourceMapper *M;
+  /// List of known InitMaps for primitive arrays.
+  std::vector InitMaps;
 
 public:
   /// Reference to the module containing all bytecode.
Index: clang/lib/AST/Interp/InterpState.cpp
===
--- clang/lib/AST/Interp/InterpState.cpp
+++ clang/lib/AST/Interp/InterpState.cpp
@@ -31,6 +31,12 @@
 free(DeadBlocks);
 DeadBlocks = Next;
   }
+
+  // If any Init

[PATCH] D154580: [clangd][c++20]Add missing semantic highlighing for concepts.

2023-07-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:966
+
+if (auto *TSI = D->getTypeSourceInfo()) {
+   auto ATL = TSI->getTypeLoc().getContainedAutoTypeLoc();

if we add this logic it definitely needs a comment explaining that we're 
looking for the auto token (because we're not doing so directly) and why



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:969
+   if (ATL.isConstrained()) {
+ StartLoc = ATL.getConceptNameInfo().getEndLoc().getLocWithOffset(1);
+   }

getLocWithOffset(1) is just jumping one byte in the source code
why is this correct?

IIUC the intention here is to jump to the `auto` token, and the AutoTypeLoc 
doesn't actually expose this

I'd suggest:
 - for now just bailing out - this is not important enough to hack around (and 
the current hack doesn't seem robust)
 - if you have the appetite, adding this location to AutoTypeLoc seems like a 
good thing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154580

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


[PATCH] D153340: [include-cleaner] Add an IgnoreHeaders flag to the command-line tool.

2023-07-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 537631.
hokein marked 5 inline comments as done.
hokein added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153340

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  clang-tools-extra/include-cleaner/lib/Analysis.cpp
  clang-tools-extra/include-cleaner/lib/Types.cpp
  clang-tools-extra/include-cleaner/test/tool.cpp
  clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp

Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
===
--- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -14,10 +14,19 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Regex.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
+#include 
+#include 
+#include 
+#include 
 
 namespace clang {
 namespace include_cleaner {
@@ -47,6 +56,14 @@
 cl::cat(IncludeCleaner),
 };
 
+cl::opt IgnoreHeaders{
+"ignore-headers",
+cl::desc("A comma-separated list of regexes to match against suffix of a "
+ "header, and disable analysis if matched."),
+cl::init(""),
+cl::cat(IncludeCleaner),
+};
+
 enum class PrintStyle { Changes, Final };
 cl::opt Print{
 "print",
@@ -91,9 +108,15 @@
 }
 
 class Action : public clang::ASTFrontendAction {
+public:
+  Action(llvm::function_ref HeaderFilter)
+  : HeaderFilter(HeaderFilter){};
+
+private:
   RecordedAST AST;
   RecordedPP PP;
   PragmaIncludes PI;
+  llvm::function_ref HeaderFilter;
 
   bool BeginInvocation(CompilerInstance &CI) override {
 // We only perform include-cleaner analysis. So we disable diagnostics that
@@ -135,8 +158,8 @@
 assert(!Path.empty() && "Main file path not known?");
 llvm::StringRef Code = SM.getBufferData(SM.getMainFileID());
 
-auto Results =
-analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, SM, HS);
+auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, SM,
+   HS, HeaderFilter);
 if (!Insert)
   Results.Missing.clear();
 if (!Remove)
@@ -185,6 +208,43 @@
 getCompilerInstance().getPreprocessor().getHeaderSearchInfo(), &PI, OS);
   }
 };
+class ActionFactory : public tooling::FrontendActionFactory {
+public:
+  ActionFactory(llvm::function_ref HeaderFilter)
+  : HeaderFilter(HeaderFilter) {}
+
+  std::unique_ptr create() override {
+return std::make_unique(HeaderFilter);
+  }
+
+private:
+  llvm::function_ref HeaderFilter;
+};
+
+std::function headerFilter() {
+  auto FilterRegs = std::make_shared>();
+
+  llvm::SmallVector Headers;
+  llvm::StringRef(IgnoreHeaders).split(Headers, ',', -1, /*KeepEmpty=*/false);
+  for (auto HeaderPattern : Headers) {
+std::string AnchoredPattern = "(" + HeaderPattern.str() + ")$";
+llvm::Regex CompiledRegex(AnchoredPattern);
+std::string RegexError;
+if (!CompiledRegex.isValid(RegexError)) {
+  llvm::errs() << llvm::formatv("Invalid regular expression '{0}': {1}\n",
+HeaderPattern, RegexError);
+  return nullptr;
+}
+FilterRegs->push_back(std::move(CompiledRegex));
+  }
+  return [FilterRegs](llvm::StringRef Path) {
+for (const auto &F : *FilterRegs) {
+  if (F.match(Path))
+return true;
+}
+return false;
+  };
+}
 
 } // namespace
 } // namespace include_cleaner
@@ -200,7 +260,6 @@
 llvm::errs() << toString(OptionsParser.takeError());
 return 1;
   }
-
   if (OptionsParser->getSourcePathList().size() != 1) {
 std::vector IncompatibleFlags = {&HTMLReportPath, &Print};
 for (const auto *Flag : IncompatibleFlags) {
@@ -210,9 +269,10 @@
   }
 }
   }
-  auto Factory = clang::tooling::newFrontendActionFactory();
+  auto HeaderFilter = headerFilter();
+  ActionFactory Factory(HeaderFilter);
   return clang::tooling::ClangTool(OptionsParser->getCompilations(),
OptionsParser->getSourcePathList())
- .run(Factory.get()) ||
+ .run(&Factory) ||
  Errors != 0;
 }
Index: clang-tools-extra/include-cleaner/test/tool.cpp
===
--- clang-tools-extra/include-cleaner/test/tool.cpp
+++ clang-tools-extra/include-cleaner/test/tool.cpp
@@ -14,6 +14,14 @@
 //  REMOVE: - "foobar.h"
 //  REMOVE-NOT: + "foo.h"
 

[clang] a84e0b4 - [clang-format] Fix align consecutive declarations over function pointers

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

Author: Gedare Bloom
Date: 2023-07-06T02:17:32-07:00
New Revision: a84e0b4bdc872adbdaafbade8164b197784b

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

LOG: [clang-format] Fix align consecutive declarations over function pointers

Fixes a bug that prevents alignment from proceeding through a function
pointer in a list of declarations.

Fixes #63451.

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

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index 18e9e043bc89f5..03dcc31eb09aef 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -870,7 +870,7 @@ void WhitespaceManager::alignConsecutiveDeclarations() {
   AlignTokens(
   Style,
   [](Change const &C) {
-if (C.Tok->is(TT_FunctionDeclarationName))
+if (C.Tok->isOneOf(TT_FunctionDeclarationName, TT_FunctionTypeLParen))
   return true;
 if (C.Tok->isNot(TT_StartOfName))
   return false;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index e0a0a0d004d541..81f2a1361be328 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2059,6 +2059,8 @@ TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
"const unsigned int *d;\n"
"Const unsigned int &e;\n"
"const unsigned int &f;\n"
+   "int*f1(int *a, int &b, int &&c);\n"
+   "double *(*f2)(int *a, double &&b);\n"
"const unsigned&&g;\n"
"Const unsigned  h;",
Style);
@@ -2104,6 +2106,8 @@ TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
"const unsigned int* d;\n"
"Const unsigned int& e;\n"
"const unsigned int& f;\n"
+   "int*f1(int* a, int& b, int&& c);\n"
+   "double* (*f2)(int* a, double&& b);\n"
"const unsigned&&g;\n"
"Const unsigned  h;",
Style);
@@ -2129,6 +2133,8 @@ TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
"const unsigned int *d;\n"
"Const unsigned int& e;\n"
"const unsigned int& f;\n"
+   "int*f1(int *a, int& b, int&& c);\n"
+   "double *(*f2)(int *a, double&& b);\n"
"const unsigned  g;\n"
"Const unsigned  h;",
Style);
@@ -2169,6 +2175,8 @@ TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
"const unsigned int*  d;\n"
"Const unsigned int & e;\n"
"const unsigned int & f;\n"
+   "int* f1(int* a, int & b, int && c);\n"
+   "double*  (*f2)(int* a, double && b);\n"
"const unsigned &&g;\n"
"Const unsigned   h;",
Style);
@@ -2194,6 +2202,8 @@ TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
"const unsigned int * d;\n"
"Const unsigned int  &e;\n"
"const unsigned int  &f;\n"
+   "int *f1(int * a, int &b, int &&c);\n"
+   "double * (*f2)(int * a, double &&b);\n"
"const unsigned &&g;\n"
"Const unsigned   h;",
Style);



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


[PATCH] D153585: [clang-format] Fix align consecutive declarations over function pointers

2023-07-06 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa84e0b4bdc99: [clang-format] Fix align consecutive 
declarations over function pointers (authored by gedare, committed by owenpan).

Changed prior to commit:
  https://reviews.llvm.org/D153585?vs=537359&id=537633#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153585

Files:
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2059,6 +2059,8 @@
"const unsigned int *d;\n"
"Const unsigned int &e;\n"
"const unsigned int &f;\n"
+   "int*f1(int *a, int &b, int &&c);\n"
+   "double *(*f2)(int *a, double &&b);\n"
"const unsigned&&g;\n"
"Const unsigned  h;",
Style);
@@ -2104,6 +2106,8 @@
"const unsigned int* d;\n"
"Const unsigned int& e;\n"
"const unsigned int& f;\n"
+   "int*f1(int* a, int& b, int&& c);\n"
+   "double* (*f2)(int* a, double&& b);\n"
"const unsigned&&g;\n"
"Const unsigned  h;",
Style);
@@ -2129,6 +2133,8 @@
"const unsigned int *d;\n"
"Const unsigned int& e;\n"
"const unsigned int& f;\n"
+   "int*f1(int *a, int& b, int&& c);\n"
+   "double *(*f2)(int *a, double&& b);\n"
"const unsigned  g;\n"
"Const unsigned  h;",
Style);
@@ -2169,6 +2175,8 @@
"const unsigned int*  d;\n"
"Const unsigned int & e;\n"
"const unsigned int & f;\n"
+   "int* f1(int* a, int & b, int && c);\n"
+   "double*  (*f2)(int* a, double && b);\n"
"const unsigned &&g;\n"
"Const unsigned   h;",
Style);
@@ -2194,6 +2202,8 @@
"const unsigned int * d;\n"
"Const unsigned int  &e;\n"
"const unsigned int  &f;\n"
+   "int *f1(int * a, int &b, int &&c);\n"
+   "double * (*f2)(int * a, double &&b);\n"
"const unsigned &&g;\n"
"Const unsigned   h;",
Style);
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -870,7 +870,7 @@
   AlignTokens(
   Style,
   [](Change const &C) {
-if (C.Tok->is(TT_FunctionDeclarationName))
+if (C.Tok->isOneOf(TT_FunctionDeclarationName, TT_FunctionTypeLParen))
   return true;
 if (C.Tok->isNot(TT_StartOfName))
   return false;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2059,6 +2059,8 @@
"const unsigned int *d;\n"
"Const unsigned int &e;\n"
"const unsigned int &f;\n"
+   "int*f1(int *a, int &b, int &&c);\n"
+   "double *(*f2)(int *a, double &&b);\n"
"const unsigned&&g;\n"
"Const unsigned  h;",
Style);
@@ -2104,6 +2106,8 @@
"const unsigned int* d;\n"
"Const unsigned int& e;\n"
"const unsigned int& f;\n"
+   "int*f1(int* a, int& b, int&& c);\n"
+   "double* (*f2)(int* a, double&& b);\n"
"const unsigned&&g;\n"
"Const unsigned  h;",
Style);
@@ -2129,6 +2133,8 @@
"const unsigned int *d;\n"
"Const unsigned int& e;\n"
"const unsigned int& f;\n"
+   "int*f1(int *a, int& b, int&& c);\n"
+   "double *(*f2)(int *a, double&& b);\n"
"const unsigned  g;\n"
"Const unsigned  h;",
Style);
@@ -2169,6 +2175,8 @@
"const unsigned int*  d;\n"
"Const unsigned int & e;\n"
"const unsigned int & f;\n"
+   "int* f1(int* a, int & b, int && c);\n"
+   "double*  (*f2)(int* a, double && b);\n"
"cons

[PATCH] D153340: [include-cleaner] Add an IgnoreHeaders flag to the command-line tool.

2023-07-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp:231
+  }
+  return [FilterRegs](llvm::StringRef Path) {
+llvm::errs() << "Path: " << Path << "\n";

kadircet wrote:
> `FilterRegs=std::move(FilterRegs)` and drop the `shared_ptr`?
This was my first attempt, it didn't work, we're returning a lamdba function, 
which invokes a delete constructor of `llvm::Regex`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153340

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


[clang-tools-extra] 507d766 - [include-cleaner] Add an IgnoreHeaders flag to the command-line tool.

2023-07-06 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-07-06T11:18:44+02:00
New Revision: 507d766d76d873aa6e446889f93384745a0e1c0b

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

LOG: [include-cleaner] Add an IgnoreHeaders flag to the command-line tool.

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
clang-tools-extra/include-cleaner/lib/Analysis.cpp
clang-tools-extra/include-cleaner/lib/Types.cpp
clang-tools-extra/include-cleaner/test/tool.cpp
clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index dd8b5afc2a24f9..2a8499dade84c0 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -125,18 +125,6 @@ bool mayConsiderUnused(const Inclusion &Inc, ParsedAST 
&AST,
   return true;
 }
 
-llvm::StringRef getResolvedPath(const include_cleaner::Header &SymProvider) {
-  switch (SymProvider.kind()) {
-  case include_cleaner::Header::Physical:
-return SymProvider.physical()->tryGetRealPathName();
-  case include_cleaner::Header::Standard:
-return SymProvider.standard().name().trim("<>\"");
-  case include_cleaner::Header::Verbatim:
-return SymProvider.verbatim().trim("<>\"");
-  }
-  llvm_unreachable("Unknown header kind");
-}
-
 std::vector generateMissingIncludeDiagnostics(
 ParsedAST &AST, llvm::ArrayRef MissingIncludes,
 llvm::StringRef Code, HeaderFilter IgnoreHeaders) {
@@ -156,7 +144,7 @@ std::vector generateMissingIncludeDiagnostics(
  FileStyle->IncludeStyle);
   for (const auto &SymbolWithMissingInclude : MissingIncludes) {
 llvm::StringRef ResolvedPath =
-getResolvedPath(SymbolWithMissingInclude.Providers.front());
+SymbolWithMissingInclude.Providers.front().resolvedPath();
 if (isIgnored(ResolvedPath, IgnoreHeaders)) {
   dlog("IncludeCleaner: not diagnosing missing include {0}, filtered by "
"config",

diff  --git 
a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h 
b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
index 13a1cfa76c7177..547e9dd7261ca3 100644
--- a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
+++ b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
@@ -65,10 +65,16 @@ struct AnalysisResults {
 
 /// Determine which headers should be inserted or removed from the main file.
 /// This exposes conclusions but not reasons: use lower-level walkUsed for 
that.
-AnalysisResults analyze(llvm::ArrayRef ASTRoots,
-llvm::ArrayRef MacroRefs,
-const Includes &I, const PragmaIncludes *PI,
-const SourceManager &SM, const HeaderSearch &HS);
+///
+/// The HeaderFilter is a predicate that receives absolute path or spelling
+/// without quotes/brackets, when a phyiscal file doesn't exist.
+/// No analysis will be performed for headers that satisfy the predicate.
+AnalysisResults
+analyze(llvm::ArrayRef ASTRoots,
+llvm::ArrayRef MacroRefs, const Includes &I,
+const PragmaIncludes *PI, const SourceManager &SM,
+const HeaderSearch &HS,
+llvm::function_ref HeaderFilter = nullptr);
 
 /// Removes unused includes and inserts missing ones in the main file.
 /// Returns the modified main-file code.

diff  --git 
a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h 
b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
index 48b018b382ba54..b16d494e95b5c9 100644
--- a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
+++ b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
@@ -29,6 +29,7 @@
 #include "llvm/ADT/DenseMapInfoVariant.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 #include 
 #include 
@@ -133,6 +134,10 @@ struct Header {
   }
   StringRef verbatim() const { return std::get(Storage); }
 
+  /// Absolute path for the header when it's a physical file. Otherwise just
+  /// the spelling without surrounding quotes/brackets.
+  llvm::StringRef resolvedPath() const;
+
 private:
   // Order must match Kind enum!
   std::variant Storage;

diff  --git a/clang-tools-extra/include-cleaner/lib/Analysis.cpp 
b/clang-tools-extra/include-cleaner/lib/Analysis.cpp
index 3952d10a423340..616eeae43a87ee 100644
--- a/cla

[PATCH] D153340: [include-cleaner] Add an IgnoreHeaders flag to the command-line tool.

2023-07-06 Thread Haojian Wu 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 rG507d766d76d8: [include-cleaner] Add an IgnoreHeaders flag to 
the command-line tool. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D153340?vs=537631&id=537634#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153340

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  clang-tools-extra/include-cleaner/lib/Analysis.cpp
  clang-tools-extra/include-cleaner/lib/Types.cpp
  clang-tools-extra/include-cleaner/test/tool.cpp
  clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp

Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
===
--- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -14,10 +14,19 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Regex.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
+#include 
+#include 
+#include 
+#include 
 
 namespace clang {
 namespace include_cleaner {
@@ -47,6 +56,14 @@
 cl::cat(IncludeCleaner),
 };
 
+cl::opt IgnoreHeaders{
+"ignore-headers",
+cl::desc("A comma-separated list of regexes to match against suffix of a "
+ "header, and disable analysis if matched."),
+cl::init(""),
+cl::cat(IncludeCleaner),
+};
+
 enum class PrintStyle { Changes, Final };
 cl::opt Print{
 "print",
@@ -91,9 +108,15 @@
 }
 
 class Action : public clang::ASTFrontendAction {
+public:
+  Action(llvm::function_ref HeaderFilter)
+  : HeaderFilter(HeaderFilter){};
+
+private:
   RecordedAST AST;
   RecordedPP PP;
   PragmaIncludes PI;
+  llvm::function_ref HeaderFilter;
 
   bool BeginInvocation(CompilerInstance &CI) override {
 // We only perform include-cleaner analysis. So we disable diagnostics that
@@ -135,8 +158,8 @@
 assert(!Path.empty() && "Main file path not known?");
 llvm::StringRef Code = SM.getBufferData(SM.getMainFileID());
 
-auto Results =
-analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, SM, HS);
+auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, SM,
+   HS, HeaderFilter);
 if (!Insert)
   Results.Missing.clear();
 if (!Remove)
@@ -185,6 +208,43 @@
 getCompilerInstance().getPreprocessor().getHeaderSearchInfo(), &PI, OS);
   }
 };
+class ActionFactory : public tooling::FrontendActionFactory {
+public:
+  ActionFactory(llvm::function_ref HeaderFilter)
+  : HeaderFilter(HeaderFilter) {}
+
+  std::unique_ptr create() override {
+return std::make_unique(HeaderFilter);
+  }
+
+private:
+  llvm::function_ref HeaderFilter;
+};
+
+std::function headerFilter() {
+  auto FilterRegs = std::make_shared>();
+
+  llvm::SmallVector Headers;
+  llvm::StringRef(IgnoreHeaders).split(Headers, ',', -1, /*KeepEmpty=*/false);
+  for (auto HeaderPattern : Headers) {
+std::string AnchoredPattern = "(" + HeaderPattern.str() + ")$";
+llvm::Regex CompiledRegex(AnchoredPattern);
+std::string RegexError;
+if (!CompiledRegex.isValid(RegexError)) {
+  llvm::errs() << llvm::formatv("Invalid regular expression '{0}': {1}\n",
+HeaderPattern, RegexError);
+  return nullptr;
+}
+FilterRegs->push_back(std::move(CompiledRegex));
+  }
+  return [FilterRegs](llvm::StringRef Path) {
+for (const auto &F : *FilterRegs) {
+  if (F.match(Path))
+return true;
+}
+return false;
+  };
+}
 
 } // namespace
 } // namespace include_cleaner
@@ -210,9 +270,10 @@
   }
 }
   }
-  auto Factory = clang::tooling::newFrontendActionFactory();
+  auto HeaderFilter = headerFilter();
+  ActionFactory Factory(HeaderFilter);
   return clang::tooling::ClangTool(OptionsParser->getCompilations(),
OptionsParser->getSourcePathList())
- .run(Factory.get()) ||
+ .run(&Factory) ||
  Errors != 0;
 }
Index: clang-tools-extra/include-cleaner/test/tool.cpp
===
--- clang-tools-extra/include-cleaner/test/tool.cpp
+++ clang-tools-extra/include-cleaner/test/tool.cpp
@@ -14,6 +14,14 @@
 //  REMOVE: - "foobar.h"
 //  REMOVE-NOT: + "foo.h"
 
+//RUN: clang-include-cleaner -print=changes %s --i

[PATCH] D154586: [clang][dataflow] Various changes to handling of modeled fields.

2023-07-06 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Rename `getReferencedFields()` to `getModeledFields()`. Move the logic that 
returns all object fields when doing a context-sensitive analysis to here from 
`DataflowAnalysisContext::createStorageLocation()`. I think all callers of the 
previous `getReferencedFields()` should use this logic; the fact that they were 
not doing so looks like a bug.

- Make `getModeledFields()` public. I have an upcoming patch that will need to 
use this function from Transfer.cpp, and there doesn't seem to be any reason 
why this function should not be public.

- Use a `SmallSetVector` to get deterministic iteration order. I have a pending 
patch where I'm getting flaky tests because 
`Environment::createValueUnlessSelfReferential()` is non-deterministically 
populating different fields depending on the iteration order. This change fixes 
those flaky tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154586

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -169,8 +169,7 @@
 }
 
 static void
-getFieldsGlobalsAndFuncs(const Decl &D,
- llvm::DenseSet &Fields,
+getFieldsGlobalsAndFuncs(const Decl &D, FieldSet &Fields,
  llvm::DenseSet &Vars,
  llvm::DenseSet &Funcs) {
   insertIfGlobal(D, Vars);
@@ -187,8 +186,7 @@
 /// global variables and functions that are declared in or referenced from
 /// sub-statements.
 static void
-getFieldsGlobalsAndFuncs(const Stmt &S,
- llvm::DenseSet &Fields,
+getFieldsGlobalsAndFuncs(const Stmt &S, FieldSet &Fields,
  llvm::DenseSet &Vars,
  llvm::DenseSet &Funcs) {
   for (auto *Child : S.children())
@@ -221,7 +219,7 @@
 void Environment::initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl) {
   assert(FuncDecl->getBody() != nullptr);
 
-  llvm::DenseSet Fields;
+  FieldSet Fields;
   llvm::DenseSet Vars;
   llvm::DenseSet Funcs;
 
@@ -707,7 +705,7 @@
 const QualType Type = AggregateLoc.getType();
 assert(Type->isRecordType());
 
-for (const FieldDecl *Field : DACtx->getReferencedFields(Type)) {
+for (const FieldDecl *Field : DACtx->getModeledFields(Type)) {
   assert(Field != nullptr);
   StorageLocation &FieldLoc = AggregateLoc.getChild(*Field);
   MemberLocToStruct[&FieldLoc] = std::make_pair(StructVal, Field);
@@ -845,7 +843,7 @@
   if (Type->isRecordType()) {
 CreatedValuesCount++;
 llvm::DenseMap FieldValues;
-for (const FieldDecl *Field : DACtx->getReferencedFields(Type)) {
+for (const FieldDecl *Field : DACtx->getModeledFields(Type)) {
   assert(Field != nullptr);
 
   QualType FieldType = Field->getType();
Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -36,31 +36,28 @@
 namespace clang {
 namespace dataflow {
 
-void DataflowAnalysisContext::addModeledFields(
-const llvm::DenseSet &Fields) {
-  llvm::set_union(ModeledFields, Fields);
+FieldSet DataflowAnalysisContext::getModeledFields(QualType Type) {
+  // During context-sensitive analysis, a struct may be allocated in one
+  // function, but its field accessed in a function lower in the stack than
+  // the allocation. Since we only collect fields used in the function where
+  // the allocation occurs, we can't apply that filter when performing
+  // context-sensitive analysis. But, this only applies to storage locations,
+  // since field access it not allowed to fail. In contrast, field *values*
+  // don't need this allowance, since the API allows for uninitialized fields.
+  if (Opts.ContextSensitiveOpts)
+return getObjectFields(Type);
+
+  return llvm::set_intersection(getObjectFields(Type), ModeledFields);
 }
 
-llvm::DenseSet
-DataflowAnalysisContext::getReferencedFields(QualType Type) {
-  llvm::DenseSet Fields = getObjectFields(Type);
-  llvm::set_intersect(Fields, ModeledFields);
-  return Fields;
+void DataflowAnalysisContext::addModeledFields(const FieldSet &Fields) {
+  ModeledFields.set_union(Fields);
 }
 
 StorageLocation &DataflowAnalysisContext::createStorageLocation(QualType Type) {
   if (!Type.isNull() && Type->isRecordType(

[PATCH] D154580: [clangd][c++20]Add missing semantic highlighing for concepts.

2023-07-06 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 537642.
massberg added a comment.

Set correct token for deduced auto types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154580

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -648,6 +648,15 @@
   void $Function_def[[bar]]($TemplateParameter[[T]] $Parameter_def[[F]]) {
 $Parameter[[F]].$Unknown_dependentName[[foo]]();
   }
+
+  struct $Class_def[[F]] {
+void $Method_def[[foo]]() {};
+  };
+  $Concept[[Fooable]] $Class_deduced[[auto]] $Variable_def[[f]] = 
$Class[[F]]();
+
+  void $Function_def[[Bar]]($Concept[[Fooable]] $TemplateParameter[[auto]] 
$Parameter_def[[x]]) {}
+
+  template$Bracket[[<]]$Concept[[Fooable]] auto 
$TemplateParameter_def_readonly[[x]]$Bracket[[>]] void $Function_def[[Boo]]() {}
 )cpp",
   // Dependent template name
   R"cpp(
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -737,8 +737,10 @@
   }
 
   bool VisitAutoTypeLoc(AutoTypeLoc L) {
-if (L.isConstrained())
+if (L.isConstrained()) {
   H.addAngleBracketTokens(L.getLAngleLoc(), L.getRAngleLoc());
+  H.addToken(L.getConceptNameInfo().getLoc(), HighlightingKind::Concept);
+}
 return true;
   }
 
@@ -960,6 +962,11 @@
 // in both it and the token for the decl being dropped due to conflict.
 if (StartLoc == D->getLocation())
   return true;
+
+if (auto *TSI = D->getTypeSourceInfo()) {
+  StartLoc = TSI->getTypeLoc().getContainedAutoTypeLoc().getNameLoc();
+}
+
 auto &Tok =
 H.addToken(StartLoc, *K).addModifier(HighlightingModifier::Deduced);
 const Type *Deduced = AT->getDeducedType().getTypePtrOrNull();


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -648,6 +648,15 @@
   void $Function_def[[bar]]($TemplateParameter[[T]] $Parameter_def[[F]]) {
 $Parameter[[F]].$Unknown_dependentName[[foo]]();
   }
+
+  struct $Class_def[[F]] {
+void $Method_def[[foo]]() {};
+  };
+  $Concept[[Fooable]] $Class_deduced[[auto]] $Variable_def[[f]] = $Class[[F]]();
+
+  void $Function_def[[Bar]]($Concept[[Fooable]] $TemplateParameter[[auto]] $Parameter_def[[x]]) {}
+
+  template$Bracket[[<]]$Concept[[Fooable]] auto $TemplateParameter_def_readonly[[x]]$Bracket[[>]] void $Function_def[[Boo]]() {}
 )cpp",
   // Dependent template name
   R"cpp(
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -737,8 +737,10 @@
   }
 
   bool VisitAutoTypeLoc(AutoTypeLoc L) {
-if (L.isConstrained())
+if (L.isConstrained()) {
   H.addAngleBracketTokens(L.getLAngleLoc(), L.getRAngleLoc());
+  H.addToken(L.getConceptNameInfo().getLoc(), HighlightingKind::Concept);
+}
 return true;
   }
 
@@ -960,6 +962,11 @@
 // in both it and the token for the decl being dropped due to conflict.
 if (StartLoc == D->getLocation())
   return true;
+
+if (auto *TSI = D->getTypeSourceInfo()) {
+  StartLoc = TSI->getTypeLoc().getContainedAutoTypeLoc().getNameLoc();
+}
+
 auto &Tok =
 H.addToken(StartLoc, *K).addModifier(HighlightingModifier::Deduced);
 const Type *Deduced = AT->getDeducedType().getTypePtrOrNull();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154580: [clangd][c++20]Add missing semantic highlighing for concepts.

2023-07-06 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 537643.
massberg added a comment.

Directly get correct source loc in case of deduced auto types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154580

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -648,6 +648,15 @@
   void $Function_def[[bar]]($TemplateParameter[[T]] $Parameter_def[[F]]) {
 $Parameter[[F]].$Unknown_dependentName[[foo]]();
   }
+
+  struct $Class_def[[F]] {
+void $Method_def[[foo]]() {};
+  };
+  $Concept[[Fooable]] $Class_deduced[[auto]] $Variable_def[[f]] = 
$Class[[F]]();
+
+  void $Function_def[[Bar]]($Concept[[Fooable]] $TemplateParameter[[auto]] 
$Parameter_def[[x]]) {}
+
+  template$Bracket[[<]]$Concept[[Fooable]] auto 
$TemplateParameter_def_readonly[[x]]$Bracket[[>]] void $Function_def[[Boo]]() {}
 )cpp",
   // Dependent template name
   R"cpp(
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -737,8 +737,10 @@
   }
 
   bool VisitAutoTypeLoc(AutoTypeLoc L) {
-if (L.isConstrained())
+if (L.isConstrained()) {
   H.addAngleBracketTokens(L.getLAngleLoc(), L.getRAngleLoc());
+  H.addToken(L.getConceptNameInfo().getLoc(), HighlightingKind::Concept);
+}
 return true;
   }
 
@@ -953,13 +955,18 @@
 kindForType(AT->getDeducedType().getTypePtrOrNull(), H.getResolver());
 if (!K)
   return true;
-SourceLocation StartLoc = D->getTypeSpecStartLoc();
+auto *TSI = D->getTypeSourceInfo();
+if (!TSI)
+  return true;
+SourceLocation StartLoc =
+TSI->getTypeLoc().getContainedAutoTypeLoc().getNameLoc();
 // The AutoType may not have a corresponding token, e.g. in the case of
 // init-captures. In this case, StartLoc overlaps with the location
 // of the decl itself, and producing a token for the type here would result
 // in both it and the token for the decl being dropped due to conflict.
 if (StartLoc == D->getLocation())
   return true;
+
 auto &Tok =
 H.addToken(StartLoc, *K).addModifier(HighlightingModifier::Deduced);
 const Type *Deduced = AT->getDeducedType().getTypePtrOrNull();


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -648,6 +648,15 @@
   void $Function_def[[bar]]($TemplateParameter[[T]] $Parameter_def[[F]]) {
 $Parameter[[F]].$Unknown_dependentName[[foo]]();
   }
+
+  struct $Class_def[[F]] {
+void $Method_def[[foo]]() {};
+  };
+  $Concept[[Fooable]] $Class_deduced[[auto]] $Variable_def[[f]] = $Class[[F]]();
+
+  void $Function_def[[Bar]]($Concept[[Fooable]] $TemplateParameter[[auto]] $Parameter_def[[x]]) {}
+
+  template$Bracket[[<]]$Concept[[Fooable]] auto $TemplateParameter_def_readonly[[x]]$Bracket[[>]] void $Function_def[[Boo]]() {}
 )cpp",
   // Dependent template name
   R"cpp(
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -737,8 +737,10 @@
   }
 
   bool VisitAutoTypeLoc(AutoTypeLoc L) {
-if (L.isConstrained())
+if (L.isConstrained()) {
   H.addAngleBracketTokens(L.getLAngleLoc(), L.getRAngleLoc());
+  H.addToken(L.getConceptNameInfo().getLoc(), HighlightingKind::Concept);
+}
 return true;
   }
 
@@ -953,13 +955,18 @@
 kindForType(AT->getDeducedType().getTypePtrOrNull(), H.getResolver());
 if (!K)
   return true;
-SourceLocation StartLoc = D->getTypeSpecStartLoc();
+auto *TSI = D->getTypeSourceInfo();
+if (!TSI)
+  return true;
+SourceLocation StartLoc =
+TSI->getTypeLoc().getContainedAutoTypeLoc().getNameLoc();
 // The AutoType may not have a corresponding token, e.g. in the case of
 // init-captures. In this case, StartLoc overlaps with the location
 // of the decl itself, and producing a token for the type here would result
 // in both it and the token for the decl being dropped due to conflict.
 if (StartLoc == D->getLocation())
   return true;
+
 auto &Tok =
 H.addToken(Sta

[PATCH] D154580: [clangd][c++20]Add missing semantic highlighing for concepts.

2023-07-06 Thread Jens Massberg via Phabricator via cfe-commits
massberg marked 2 inline comments as done.
massberg added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:969
+   if (ATL.isConstrained()) {
+ StartLoc = ATL.getConceptNameInfo().getEndLoc().getLocWithOffset(1);
+   }

sammccall wrote:
> getLocWithOffset(1) is just jumping one byte in the source code
> why is this correct?
> 
> IIUC the intention here is to jump to the `auto` token, and the AutoTypeLoc 
> doesn't actually expose this
> 
> I'd suggest:
>  - for now just bailing out - this is not important enough to hack around 
> (and the current hack doesn't seem robust)
>  - if you have the appetite, adding this location to AutoTypeLoc seems like a 
> good thing
It seems that we can directly get the correct location, see above.
The test had been wrong before as the auto in `auto` in `Fooable auto f = ..` 
should have a class deduced token as it would have without the concept.
This is now fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154580

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


[PATCH] D153740: [llvm][Support] Deprecate llvm::writeFileAtomically API

2023-07-06 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rG7aafea001282: [llvm][Support] Deprecate 
llvm::writeFileAtomically API (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153740

Files:
  llvm/include/llvm/Support/FileUtilities.h
  llvm/lib/Support/FileUtilities.cpp
  llvm/unittests/Support/CMakeLists.txt
  llvm/unittests/Support/FileUtilitiesTest.cpp

Index: llvm/unittests/Support/FileUtilitiesTest.cpp
===
--- llvm/unittests/Support/FileUtilitiesTest.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-//===- llvm/unittest/Support/FileUtilitiesTest.cpp - unit 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 "llvm/Support/FileUtilities.h"
-#include "llvm/Support/Errc.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Testing/Support/SupportHelpers.h"
-#include "gtest/gtest.h"
-#include 
-
-using namespace llvm;
-using namespace llvm::sys;
-
-using llvm::unittest::TempDir;
-
-#define ASSERT_NO_ERROR(x) \
-  if (std::error_code ASSERT_NO_ERROR_ec = x) {\
-SmallString<128> MessageStorage;   \
-raw_svector_ostream Message(MessageStorage);   \
-Message << #x ": did not return errc::success.\n"  \
-<< "error number: " << ASSERT_NO_ERROR_ec.value() << "\n"  \
-<< "error message: " << ASSERT_NO_ERROR_ec.message() << "\n";  \
-GTEST_FATAL_FAILURE_(MessageStorage.c_str());  \
-  } else { \
-  }
-
-namespace {
-TEST(writeFileAtomicallyTest, Test) {
-  // Create unique temporary directory for these tests
-  TempDir RootTestDirectory("writeFileAtomicallyTest", /*Unique*/ true);
-
-  SmallString<128> FinalTestfilePath(RootTestDirectory.path());
-  sys::path::append(FinalTestfilePath, "foo.txt");
-  const std::string TempUniqTestFileModel =
-  std::string(FinalTestfilePath) + "-";
-  const std::string TestfileContent = "fooFOOfoo";
-
-  llvm::Error Err = llvm::writeFileAtomically(TempUniqTestFileModel, FinalTestfilePath, TestfileContent);
-  ASSERT_FALSE(static_cast(Err));
-
-  std::ifstream FinalFileStream(std::string(FinalTestfilePath.str()));
-  std::string FinalFileContent;
-  FinalFileStream >> FinalFileContent;
-  ASSERT_EQ(FinalFileContent, TestfileContent);
-}
-} // anonymous namespace
Index: llvm/unittests/Support/CMakeLists.txt
===
--- llvm/unittests/Support/CMakeLists.txt
+++ llvm/unittests/Support/CMakeLists.txt
@@ -41,7 +41,6 @@
   ExtensibleRTTITest.cpp
   FileCollectorTest.cpp
   FileOutputBufferTest.cpp
-  FileUtilitiesTest.cpp
   FormatVariadicTest.cpp
   FSUniqueIDTest.cpp
   GlobPatternTest.cpp
Index: llvm/lib/Support/FileUtilities.cpp
===
--- llvm/lib/Support/FileUtilities.cpp
+++ llvm/lib/Support/FileUtilities.cpp
@@ -267,64 +267,6 @@
   return CompareFailed;
 }
 
-void llvm::AtomicFileWriteError::log(raw_ostream &OS) const {
-  OS << "atomic_write_error: ";
-  switch (Error) {
-  case atomic_write_error::failed_to_create_uniq_file:
-OS << "failed_to_create_uniq_file";
-return;
-  case atomic_write_error::output_stream_error:
-OS << "output_stream_error";
-return;
-  case atomic_write_error::failed_to_rename_temp_file:
-OS << "failed_to_rename_temp_file";
-return;
-  }
-  llvm_unreachable("unknown atomic_write_error value in "
-   "failed_to_rename_temp_file::log()");
-}
-
-llvm::Error llvm::writeFileAtomically(StringRef TempPathModel,
-  StringRef FinalPath, StringRef Buffer) {
-  return writeFileAtomically(TempPathModel, FinalPath,
- [&Buffer](llvm::raw_ostream &OS) {
-   OS.write(Buffer.data(), Buffer.size());
-   return llvm::Error::success();
- });
-}
-
-llvm::Error llvm::writeFileAtomically(
-StringRef TempPathModel, StringRef FinalPath,
-std::function Writer) {
-  SmallString<128> GeneratedUniqPath;
-  int TempFD;
-  if (sys::fs::createUniqueFile(TempPathModel, TempFD,

[PATCH] D154591: [OpenMP][OMPIRBuilder] Rename IsEmbedded and IsTargetCodegen flags

2023-07-06 Thread Sergio Afonso via Phabricator via cfe-commits
skatrak created this revision.
skatrak added reviewers: jsjodin, jdoerfert, kiranchandramohan.
Herald added subscribers: gysit, Dinistro, bviyer, sunshaoce, Moerafaat, 
zero9178, bzcheeseman, mattd, gchakrabarti, awarzynski, sdasgup3, asavonic, 
wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, 
Kayjukh, grosul1, Joonsoo, kerbowa, liufengdb, aartbik, mgester, arpith-jacob, 
csigg, antiagainst, shauheen, rriddle, mehdi_amini, mstorsjo, guansong, 
kbarton, hiraditya, yaxunl, jvesely, nemanjai.
Herald added a reviewer: sscalpone.
Herald added a reviewer: ftynse.
Herald added a reviewer: awarzynski.
Herald added projects: Flang, All.
skatrak requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jplehr, sstefan1, 
stephenneuendorffer, nicolasvasilache, MaskRay, jholewinski.
Herald added a reviewer: nicolasvasilache.
Herald added projects: clang, MLIR, LLVM.

This patch renames the `OpenMPIRBuilderConfig` flags to reduce confusion over
their meaning. `IsTargetCodegen` becomes `IsGPU`, whereas `IsEmbedded` becomes
`IsTargetDevice`. The `-fopenmp-is-device` compiler option is also renamed to
`-fopenmp-is-target-device` and the `omp.is_device` MLIR attribute is renamed
to `omp.is_target_device`. Getters and setters of all these renamed properties
are also updated accordingly. Many unit tests have been updated to use the new
names, but an alias for the `-fopenmp-is-device` option is created so that
external programs do not stop working after the name change.

`IsGPU` is set when the target triple is AMDGCN or NVIDIA PTX, and it is also
valid if `IsTargetDevice` is specified as well. `IsTargetDevice` is set by the
`-fopenmp-is-target-device` compiler frontend option, which is only added to
the OpenMP device invocation for offloading-enabled programs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154591

Files:
  clang/docs/OffloadingDesign.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/PowerPC/ppc64le-varargs-f128.c
  clang/test/CodeGen/ibm128-unsupported.c
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/openmp-offload.c
  clang/test/Headers/__clang_hip_libdevice_declares.cpp
  clang/test/Headers/amdgcn-openmp-device-math-complex.c
  clang/test/Headers/amdgcn-openmp-device-math-complex.cpp
  clang/test/Headers/amdgcn_openmp_device_math.c
  clang/test/Headers/amdgcn_openmp_device_math_c.c
  clang/test/Headers/amdgcn_openmp_device_math_constexpr.cpp
  clang/test/Headers/nvptx_device_cmath_functions.c
  clang/test/Headers/nvptx_device_cmath_functions.cpp
  clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/Headers/nvptx_device_math_complex.cpp
  clang/test/Headers/nvptx_device_math_functions.c
  clang/test/Headers/nvptx_device_math_functions.cpp
  clang/test/Headers/nvptx_device_math_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_macro.cpp
  clang/test/Headers/nvptx_device_math_modf.cpp
  clang/test/Headers/nvptx_device_math_sin.c
  clang/test/Headers/nvptx_device_math_sin.cpp
  clang/test/Headers/nvptx_device_math_sin_cos.cpp
  clang/test/Headers/nvptx_device_math_sincos.cpp
  clang/test/Headers/openmp-device-functions-bool.c
  clang/test/Headers/openmp_device_math_isnan.cpp
  clang/test/Headers/openmp_new_nothrow.cpp
  clang/test/Headers/target_include_new.cpp
  clang/test/OpenMP/amdgcn-attributes.cpp
  clang/test/OpenMP/amdgcn_device_function_call.cpp
  clang/test/OpenMP/amdgcn_ldbl_check.cpp
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/amdgcn_target_global_constructor.cpp
  clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
  clang/test/OpenMP/amdgpu_target_with_aligned_attribute.c
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/aux-triple-macros.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_constexpr_c

[clang] 626c789 - Fix compile error in UnresolvedSetTest.cpp, hopefully the last one

2023-07-06 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2023-07-06T11:54:45+01:00
New Revision: 626c789d92bc917e7db30478e9b6d4c9b567ee17

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

LOG: Fix compile error in UnresolvedSetTest.cpp, hopefully the last one

This test is failing to compile when LLVM_ENABLE_MODULES=ON due to
NamedDecl being multiply defined. Fix this by avoiding declaring our
own NamedDecl in the test and instead cast a struct of appropriate
size and alignment to NamedDecl.

Added: 


Modified: 
clang/unittests/AST/UnresolvedSetTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/UnresolvedSetTest.cpp 
b/clang/unittests/AST/UnresolvedSetTest.cpp
index ada857e0e38260..0d01eebe07e2f5 100644
--- a/clang/unittests/AST/UnresolvedSetTest.cpp
+++ b/clang/unittests/AST/UnresolvedSetTest.cpp
@@ -1,56 +1,56 @@
 #include "clang/AST/UnresolvedSet.h"
+#include "clang/AST/Decl.h"
 #include "gtest/gtest.h"
 
-namespace clang {
-class NamedDecl {
-  // DeclAccessPair assumes that NamedDecl is at least 4-byte aligned, so we
-  // we need to have a dummy value to make this dummy NamedDecl also be 
aligned.
-  [[maybe_unused]] int dummy;
-
-public:
-  NamedDecl() {}
-};
-} // namespace clang
-
 using namespace clang;
 
 class UnresolvedSetTest : public ::testing::Test {
 protected:
-  NamedDecl n0, n1, n2, n3;
+  // For this test we don't care about the contents of the NamedDecl,
+  // so just use a dummy struct of appropriate size and alignment.
+  struct alignas(NamedDecl) DummyDecl {
+char contents[sizeof(NamedDecl)];
+  };
+  DummyDecl d0, d1, d2, d3;
+  NamedDecl *n0, *n1, *n2, *n3;
   UnresolvedSet<2> set;
 
   void SetUp() override {
-set.addDecl(&n0);
-set.addDecl(&n1);
-set.addDecl(&n2);
-set.addDecl(&n3);
+n0 = reinterpret_cast(&d0);
+n1 = reinterpret_cast(&d1);
+n2 = reinterpret_cast(&d2);
+n3 = reinterpret_cast(&d3);
+set.addDecl(n0);
+set.addDecl(n1);
+set.addDecl(n2);
+set.addDecl(n3);
   }
 };
 
 TEST_F(UnresolvedSetTest, Size) { EXPECT_EQ(set.size(), 4u); }
 
 TEST_F(UnresolvedSetTest, ArrayOperator) {
-  EXPECT_EQ(set[0].getDecl(), &n0);
-  EXPECT_EQ(set[1].getDecl(), &n1);
-  EXPECT_EQ(set[2].getDecl(), &n2);
-  EXPECT_EQ(set[3].getDecl(), &n3);
+  EXPECT_EQ(set[0].getDecl(), n0);
+  EXPECT_EQ(set[1].getDecl(), n1);
+  EXPECT_EQ(set[2].getDecl(), n2);
+  EXPECT_EQ(set[3].getDecl(), n3);
 }
 
 TEST_F(UnresolvedSetTest, EraseIntegerFromStart) {
   set.erase(0);
   EXPECT_EQ(set.size(), 3u);
-  EXPECT_EQ(set[0].getDecl(), &n3);
-  EXPECT_EQ(set[1].getDecl(), &n1);
-  EXPECT_EQ(set[2].getDecl(), &n2);
+  EXPECT_EQ(set[0].getDecl(), n3);
+  EXPECT_EQ(set[1].getDecl(), n1);
+  EXPECT_EQ(set[2].getDecl(), n2);
 
   set.erase(0);
   EXPECT_EQ(set.size(), 2u);
-  EXPECT_EQ(set[0].getDecl(), &n2);
-  EXPECT_EQ(set[1].getDecl(), &n1);
+  EXPECT_EQ(set[0].getDecl(), n2);
+  EXPECT_EQ(set[1].getDecl(), n1);
 
   set.erase(0);
   EXPECT_EQ(set.size(), 1u);
-  EXPECT_EQ(set[0].getDecl(), &n1);
+  EXPECT_EQ(set[0].getDecl(), n1);
 
   set.erase(0);
   EXPECT_EQ(set.size(), 0u);
@@ -59,18 +59,18 @@ TEST_F(UnresolvedSetTest, EraseIntegerFromStart) {
 TEST_F(UnresolvedSetTest, EraseIntegerFromEnd) {
   set.erase(3);
   EXPECT_EQ(set.size(), 3u);
-  EXPECT_EQ(set[0].getDecl(), &n0);
-  EXPECT_EQ(set[1].getDecl(), &n1);
-  EXPECT_EQ(set[2].getDecl(), &n2);
+  EXPECT_EQ(set[0].getDecl(), n0);
+  EXPECT_EQ(set[1].getDecl(), n1);
+  EXPECT_EQ(set[2].getDecl(), n2);
 
   set.erase(2);
   EXPECT_EQ(set.size(), 2u);
-  EXPECT_EQ(set[0].getDecl(), &n0);
-  EXPECT_EQ(set[1].getDecl(), &n1);
+  EXPECT_EQ(set[0].getDecl(), n0);
+  EXPECT_EQ(set[1].getDecl(), n1);
 
   set.erase(1);
   EXPECT_EQ(set.size(), 1u);
-  EXPECT_EQ(set[0].getDecl(), &n0);
+  EXPECT_EQ(set[0].getDecl(), n0);
 
   set.erase(0);
   EXPECT_EQ(set.size(), 0u);
@@ -79,18 +79,18 @@ TEST_F(UnresolvedSetTest, EraseIntegerFromEnd) {
 TEST_F(UnresolvedSetTest, EraseIteratorFromStart) {
   set.erase(set.begin());
   EXPECT_EQ(set.size(), 3u);
-  EXPECT_EQ(set[0].getDecl(), &n3);
-  EXPECT_EQ(set[1].getDecl(), &n1);
-  EXPECT_EQ(set[2].getDecl(), &n2);
+  EXPECT_EQ(set[0].getDecl(), n3);
+  EXPECT_EQ(set[1].getDecl(), n1);
+  EXPECT_EQ(set[2].getDecl(), n2);
 
   set.erase(set.begin());
   EXPECT_EQ(set.size(), 2u);
-  EXPECT_EQ(set[0].getDecl(), &n2);
-  EXPECT_EQ(set[1].getDecl(), &n1);
+  EXPECT_EQ(set[0].getDecl(), n2);
+  EXPECT_EQ(set[1].getDecl(), n1);
 
   set.erase(set.begin());
   EXPECT_EQ(set.size(), 1u);
-  EXPECT_EQ(set[0].getDecl(), &n1);
+  EXPECT_EQ(set[0].getDecl(), n1);
 
   set.erase(set.begin());
   EXPECT_EQ(set.size(), 0u);
@@ -99,18 +99,18 @@ TEST_F(UnresolvedSetTest, EraseIteratorFromStart) {
 TEST_F(UnresolvedSetTest, EraseIteratorFromEnd) {
   set.erase(--set.end());
   EXPECT_

[PATCH] D154502: [AST] Fix bug in UnresolvedSet::erase of last element

2023-07-06 Thread John Brawn via Phabricator via cfe-commits
john.brawn added inline comments.



Comment at: clang/unittests/AST/UnresolvedSetTest.cpp:11
+};
+} // namespace clang
+

jroelofs wrote:
> jroelofs wrote:
> > This ODR violation broke the build for me because it's picking up the 
> > definition from Decl.h instead of this one.
> > 
> > ```
> > /Users/jonathan_roelofs/llvm-upstream/clang/unittests/AST/UnresolvedSetTest.cpp:30:1:
> >  error: call to implicitly-deleted default constructor of 
> > 'UnresolvedSetTest'
> > TEST_F(UnresolvedSetTest, Size) { EXPECT_EQ(set.size(), 4u); }
> > ^
> > /Users/jonathan_roelofs/llvm-upstream/third-party/unittest/googletest/include/gtest/gtest.h:2368:3:
> >  note: expanded from macro 'TEST_F'
> >   GTEST_TEST_(test_fixture, test_name, test_fixture, \
> >   ^
> > /Users/jonathan_roelofs/llvm-upstream/third-party/unittest/googletest/include/gtest/internal/gtest-internal.h:1362:5:
> >  note: expanded from macro 'GTEST_TEST_'
> > GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} 
> >   \
> > ^
> > /Users/jonathan_roelofs/llvm-upstream/third-party/unittest/googletest/include/gtest/internal/gtest-internal.h:1351:3:
> >  note: expanded from macro 'GTEST_TEST_CLASS_NAME_'
> >   test_suite_name##_##test_name##_Test
> >   ^
> > :30:1: note: expanded from here
> > UnresolvedSetTest_Size_Test
> > ^
> > /Users/jonathan_roelofs/llvm-upstream/clang/unittests/AST/UnresolvedSetTest.cpp:19:13:
> >  note: default constructor of 'UnresolvedSetTest' is implicitly deleted 
> > because field 'n0' has no default constructor
> >   NamedDecl n0, n1, n2, n3;
> > ^
> > ```
> > 
> > Maybe it needs to be something like this instead?
> > 
> > ```
> > diff --git a/clang/unittests/AST/UnresolvedSetTest.cpp 
> > b/clang/unittests/AST/UnresolvedSetTest.cpp
> > index ada857e0e382..3c9077ddc3ec 100644
> > --- a/clang/unittests/AST/UnresolvedSetTest.cpp
> > +++ b/clang/unittests/AST/UnresolvedSetTest.cpp
> > @@ -1,22 +1,23 @@
> >  #include "clang/AST/UnresolvedSet.h"
> > +#include "clang/AST/Decl.h"
> >  #include "gtest/gtest.h"
> >  
> > -namespace clang {
> > -class NamedDecl {
> > +namespace dummy {
> > +class NamedDecl : public clang::NamedDecl {
> >// DeclAccessPair assumes that NamedDecl is at least 4-byte aligned, so 
> > we
> >// we need to have a dummy value to make this dummy NamedDecl also be 
> > aligned.
> >[[maybe_unused]] int dummy;
> >  
> >  public:
> > -  NamedDecl() {}
> > +  NamedDecl() : clang::NamedDecl(clang::NamedDecl::Kind(0), nullptr, 
> > clang::SourceLocation::getFromRawEncoding(0), clang::DeclarationName()) {}
> >  };
> > -} // namespace clang
> > +} // namespace dummy
> >  
> >  using namespace clang;
> >  
> >  class UnresolvedSetTest : public ::testing::Test {
> >  protected:
> > -  NamedDecl n0, n1, n2, n3;
> > +  dummy::NamedDecl n0, n1, n2, n3;
> >UnresolvedSet<2> set;
> >  
> >void SetUp() override {
> > 
> > ```
> You might need to build with `-DLLVM_ENABLE_MODULES=On` to see this.
https://reviews.llvm.org/rG626c789d92bc should fix this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154502

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


[PATCH] D154596: [RISCV] Fix required features checking with empty string

2023-07-06 Thread Jim Lin via Phabricator via cfe-commits
Jim created this revision.
Herald added subscribers: jobnoorman, VincentWu, vkmr, luismarques, 
sameer.abuasal, s.egerton, benna, psnobl, PkmX, rogfer01, shiva0217, 
kito-cheng, simoncook, arichardson.
Herald added a project: All.
Jim requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, eopXD.
Herald added a project: clang.

In our downstream, we define some intrinsics that don't require any
extension enabled. Such as

TARGET_BUILTIN(__builtin_riscv_xxx, "LiLi", "nc", "")

But `split` function's `KeepEmpty` argument isn't True. Got the error message

error: builtin requires at least one of the following extensions support to be 
enabled : ''

when we use our customized intrinsic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154596

Files:
  clang/lib/Sema/SemaChecking.cpp


Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4481,7 +4481,7 @@
   bool FeatureMissing = false;
   SmallVector ReqFeatures;
   StringRef Features = Context.BuiltinInfo.getRequiredFeatures(BuiltinID);
-  Features.split(ReqFeatures, ',');
+  Features.split(ReqFeatures, ',', -1, false);
 
   // Check if each required feature is included
   for (StringRef F : ReqFeatures) {


Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4481,7 +4481,7 @@
   bool FeatureMissing = false;
   SmallVector ReqFeatures;
   StringRef Features = Context.BuiltinInfo.getRequiredFeatures(BuiltinID);
-  Features.split(ReqFeatures, ',');
+  Features.split(ReqFeatures, ',', -1, false);
 
   // Check if each required feature is included
   for (StringRef F : ReqFeatures) {
___
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-07-06 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: libc/include/CMakeLists.txt:8
+if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
+  include(GetClangResourceDir)
+endif()

sivachandra wrote:
> Where does this come from?
It's a global CMake module that LLVM provides in 
`cmake/Modules/GetClangResourceDir.cmake`. I only expect the GPU build to be 
done in-tree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154036

___
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-07-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG with a nit




Comment at: clang/lib/CodeGen/CGDecl.cpp:19
 #include "CGOpenMPRuntime.h"
+#include "CGOpenMPRuntimeGPU.h"
 #include "CodeGenFunction.h"

You can remove this include


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] D154597: [clang][dataflow] Various refactorings to UncheckedOptionalAccessModel.

2023-07-06 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

These are intended to ease an upcoming change that will eliminate the
duplication between `AggregateStorageLocation` and `StructValue` (see
https://discourse.llvm.org/t/70086 for details), but many of the changes also
have value in their own right.

Depends On D154586 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154597

Files:
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp

Index: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
===
--- clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -255,12 +255,22 @@
 
 /// Creates a symbolic value for an `optional` value using `HasValueVal` as the
 /// symbolic value of its "has_value" property.
-StructValue &createOptionalValue(Environment &Env, BoolValue &HasValueVal) {
+StructValue &createOptionalValue(BoolValue &HasValueVal, Environment &Env) {
   auto &OptionalVal = Env.create();
   setHasValue(OptionalVal, HasValueVal);
   return OptionalVal;
 }
 
+/// Creates a symbolic value for an `optional` value at an existing storage
+/// location. Uses `HasValueVal` as the symbolic value of the "has_value"
+/// property.
+StructValue &createOptionalValue(AggregateStorageLocation &Loc,
+ BoolValue &HasValueVal, Environment &Env) {
+  StructValue &OptionalVal = createOptionalValue(HasValueVal, Env);
+  Env.setValue(Loc, OptionalVal);
+  return OptionalVal;
+}
+
 /// Returns the symbolic value that represents the "has_value" property of the
 /// optional value `OptionalVal`. Returns null if `OptionalVal` is null.
 BoolValue *getHasValue(Environment &Env, Value *OptionalVal) {
@@ -422,15 +432,6 @@
   return HasValueVal != nullptr && Env.flowConditionImplies(*HasValueVal);
 }
 
-StorageLocation *maybeSkipPointer(StorageLocation *Loc,
-  const Environment &Env) {
-  if (Loc == nullptr)
-return nullptr;
-  if (auto *Val = dyn_cast_or_null(Env.getValue(*Loc)))
-return &Val->getPointeeLoc();
-  return Loc;
-}
-
 Value *getValueBehindPossiblePointer(const Expr &E, const Environment &Env) {
   Value *Val = Env.getValue(E, SkipPast::Reference);
   if (auto *PointerVal = dyn_cast_or_null(Val))
@@ -467,7 +468,7 @@
   auto &Loc = State.Env.createStorageLocation(*E);
   State.Env.setStorageLocation(*E, Loc);
   State.Env.setValue(
-  Loc, createOptionalValue(State.Env, State.Env.getBoolLiteralValue(true)));
+  Loc, createOptionalValue(State.Env.getBoolLiteralValue(true), State.Env));
 }
 
 void transferOptionalHasValueCall(const CXXMemberCallExpr *CallExpr,
@@ -544,15 +545,12 @@
   auto &Loc = State.Env.createStorageLocation(*E);
   State.Env.setStorageLocation(*E, Loc);
   State.Env.setValue(
-  Loc, createOptionalValue(State.Env, State.Env.makeAtomicBoolValue()));
+  Loc, createOptionalValue(State.Env.makeAtomicBoolValue(), State.Env));
 }
 
-void assignOptionalValue(const Expr &E, Environment &Env,
- BoolValue &HasValueVal) {
-  if (auto *OptionalLoc = maybeSkipPointer(
-  Env.getStorageLocation(E, SkipPast::Reference), Env)) {
-Env.setValue(*OptionalLoc, createOptionalValue(Env, HasValueVal));
-  }
+void constructOptionalValue(const Expr &E, Environment &Env,
+BoolValue &HasValueVal) {
+  Env.setValueStrict(E, createOptionalValue(HasValueVal, Env));
 }
 
 /// Returns a symbolic value for the "has_value" property of an `optional`
@@ -590,25 +588,23 @@
 LatticeTransferState &State) {
   assert(E->getNumArgs() > 0);
 
-  assignOptionalValue(*E, State.Env,
-  valueOrConversionHasValue(*E->getConstructor(),
-*E->getArg(0), MatchRes,
-State));
+  constructOptionalValue(*E, State.Env,
+ valueOrConversionHasValue(*E->getConstructor(),
+   *E->getArg(0), MatchRes,
+   State));
 }
 
 void transferAssignment(const CXXOperatorCallExpr *E, BoolValue &HasValueVal,
 LatticeTransferState &State) {
   assert(E->getNumArgs() > 0);
 
-  auto *OptionalLoc =
-  State.Env.getStorageLocation(*E->getArg(0), SkipPast::Reference);
-  if (OptionalLoc == nullptr)
-return;
-
-  State.Env.setValue(*OptionalLoc, createOptionalValue(State.Env, HasValueVal));
+  if (auto *Loc = cast(
+  State.Env.getStorageLocationStrict(*E->getArg(0 {
+createOptionalValue(*Loc, HasVa

[PATCH] D154597: [clang][dataflow] Various refactorings to UncheckedOptionalAccessModel.

2023-07-06 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added inline comments.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:258
 /// symbolic value of its "has_value" property.
-StructValue &createOptionalValue(Environment &Env, BoolValue &HasValueVal) {
+StructValue &createOptionalValue(BoolValue &HasValueVal, Environment &Env) {
   auto &OptionalVal = Env.create();

Moved `Env` parameter to the end for consistency with the newly added overload 
(below); `Env` is just a "context" parameter, `HasValueVal` is the more 
important parameter and should therefore come first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154597

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


[PATCH] D154189: [clang][Interp] Implement zero-init of record types

2023-07-06 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154189

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


[PATCH] D153653: [clang][Interp] Make CXXTemporaryObjectExprs leave a value behind

2023-07-06 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D153653

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


[PATCH] D154567: [RISCV] Use ClangBuiltin in IntrinsicsRISCV.td to map some scalar crypto builtins to IR intrinsic.

2023-07-06 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb 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/D154567/new/

https://reviews.llvm.org/D154567

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


[PATCH] D154577: [RISCV] Use 'long' in sha512 builtin tests. NFC

2023-07-06 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb 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/D154577/new/

https://reviews.llvm.org/D154577

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


[PATCH] D154578: [ARM][Driver] Change float-abi warning

2023-07-06 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 537673.
michaelplatings added a comment.

Fix duplicate implicit group warning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154578

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/test/Driver/arm-no-float-regs.c


Index: clang/test/Driver/arm-no-float-regs.c
===
--- clang/test/Driver/arm-no-float-regs.c
+++ clang/test/Driver/arm-no-float-regs.c
@@ -1,7 +1,6 @@
-// REQUIRES: arm-registered-target
-
 // Check that -mfloat-abi=hard gives a warning if FP registers aren't 
available.
-// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mfloat-abi=hard -### -c 
%s 2>&1
+// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mfloat-abi=hard -### -c 
%s 2>&1 \
+// RUN:   | FileCheck %s
 
 // RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mhard-float -### -c %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=HARDFLOAT %s
@@ -20,4 +19,4 @@
 
 // CHECK: warning: '-mfloat-abi=hard': selected processor lacks floating point 
registers
 // HARDFLOAT: warning: '-mhard-float': selected processor lacks floating point 
registers
-// NOWARN-NOT: selected processor lacks floating point registers
+// NOWARN-NOT: warning:
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1349,6 +1349,8 @@
 
 def UnknownArgument : DiagGroup<"unknown-argument">;
 
+def UnsupportedABI : DiagGroup<"unsupported-abi">;
+
 // A warning group for warnings about code that clang accepts when
 // compiling OpenCL C/C++ but which is not compatible with the SPIR(-V) spec.
 def SpirCompat : DiagGroup<"spir-compat">;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -416,10 +416,10 @@
   "unknown platform, assuming -mfloat-abi=%0">;
 def warn_drv_unsupported_float_abi_by_lib : Warning<
   "float ABI '%0' is not supported by current library">,
-  InGroup>;
+  InGroup;
 def warn_drv_no_floating_point_registers: Warning<
-  "'%0': selected processor lacks floating point registers; flag ignored">,
-  InGroup;
+  "'%0': selected processor lacks floating point registers">,
+  InGroup;
 def warn_ignoring_ftabstop_value : Warning<
   "ignoring invalid -ftabstop value '%0', using default value %1">;
 def warn_drv_overriding_flag_option : Warning<


Index: clang/test/Driver/arm-no-float-regs.c
===
--- clang/test/Driver/arm-no-float-regs.c
+++ clang/test/Driver/arm-no-float-regs.c
@@ -1,7 +1,6 @@
-// REQUIRES: arm-registered-target
-
 // Check that -mfloat-abi=hard gives a warning if FP registers aren't available.
-// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mfloat-abi=hard -### -c %s 2>&1
+// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mfloat-abi=hard -### -c %s 2>&1 \
+// RUN:   | FileCheck %s
 
 // RUN: %clang --target=arm-none-eabi -mcpu=cortex-m0 -mhard-float -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=HARDFLOAT %s
@@ -20,4 +19,4 @@
 
 // CHECK: warning: '-mfloat-abi=hard': selected processor lacks floating point registers
 // HARDFLOAT: warning: '-mhard-float': selected processor lacks floating point registers
-// NOWARN-NOT: selected processor lacks floating point registers
+// NOWARN-NOT: warning:
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1349,6 +1349,8 @@
 
 def UnknownArgument : DiagGroup<"unknown-argument">;
 
+def UnsupportedABI : DiagGroup<"unsupported-abi">;
+
 // A warning group for warnings about code that clang accepts when
 // compiling OpenCL C/C++ but which is not compatible with the SPIR(-V) spec.
 def SpirCompat : DiagGroup<"spir-compat">;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -416,10 +416,10 @@
   "unknown platform, assuming -mfloat-abi=%0">;
 def warn_drv_unsupported_float_abi_by_lib : Warning<
   "float ABI '%0' is not supported by current library">,
-  InGroup>;
+  InGroup;
 def warn_drv_no_floating_point_registers: Warning<
-  "'%0': selected processor lacks floating point registers; flag ignored">,
-  InGroup;
+  "'%0': selected processor lacks floating point registers">,
+  InGroup;
 def warn_ignoring_ftabstop_value : Warning<
   "ignoring invalid -f

[PATCH] D154597: [clang][dataflow] Various refactorings to UncheckedOptionalAccessModel.

2023-07-06 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added a comment.
This revision is now accepted and ready to land.

Nice! I don't think you need a second review for this one, since it's just 
superficial (if important!) refactoring.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154597

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


[clang] f223c96 - [clang][Interp][NFC] Return a const Descriptor from a getter

2023-07-06 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-06T14:52:05+02:00
New Revision: f223c964df86b239f76946b30a1400cb9b7adaa3

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

LOG: [clang][Interp][NFC] Return a const Descriptor from a getter

They are generally immutable anyway. Also fix some doc comments.

Added: 


Modified: 
clang/lib/AST/Interp/InterpBlock.h

Removed: 




diff  --git a/clang/lib/AST/Interp/InterpBlock.h 
b/clang/lib/AST/Interp/InterpBlock.h
index edcbec232e23d8..8c95d8e122be48 100644
--- a/clang/lib/AST/Interp/InterpBlock.h
+++ b/clang/lib/AST/Interp/InterpBlock.h
@@ -48,7 +48,7 @@ enum PrimType : unsigned;
 ///
 class Block final {
 public:
-  // Creates a new block.
+  /// Creates a new block.
   Block(const std::optional &DeclID, Descriptor *Desc,
 bool IsStatic = false, bool IsExtern = false)
   : DeclID(DeclID), IsStatic(IsStatic), IsExtern(IsExtern), Desc(Desc) {}
@@ -58,7 +58,7 @@ class Block final {
 Desc(Desc) {}
 
   /// Returns the block's descriptor.
-  Descriptor *getDescriptor() const { return Desc; }
+  const Descriptor *getDescriptor() const { return Desc; }
   /// Checks if the block has any live pointers.
   bool hasPointers() const { return Pointers; }
   /// Checks if the block is extern.
@@ -104,7 +104,7 @@ class Block final {
/*isActive=*/true, Desc);
   }
 
-  // Invokes the Destructor.
+  /// Invokes the Destructor.
   void invokeDtor() {
 if (Desc->DtorFn)
   Desc->DtorFn(this, data(), Desc);



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


[clang] 9642343 - [clang][Interp][NFC] Make a local variable const

2023-07-06 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-06T14:52:05+02:00
New Revision: 9642343d3023bdf5edcb2a016a9a9cc6cfd23834

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

LOG: [clang][Interp][NFC] Make a local variable const

And add some assertions.

Added: 


Modified: 
clang/lib/AST/Interp/InterpState.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/InterpState.cpp 
b/clang/lib/AST/Interp/InterpState.cpp
index bd7daf38796ca6..abc29e059aa9f0 100644
--- a/clang/lib/AST/Interp/InterpState.cpp
+++ b/clang/lib/AST/Interp/InterpState.cpp
@@ -46,7 +46,10 @@ bool InterpState::reportOverflow(const Expr *E, const 
llvm::APSInt &Value) {
 }
 
 void InterpState::deallocate(Block *B) {
-  Descriptor *Desc = B->getDescriptor();
+  assert(B);
+  const Descriptor *Desc = B->getDescriptor();
+  assert(Desc);
+
   if (B->hasPointers()) {
 size_t Size = B->getSize();
 



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


[clang] 868aa93 - [clang][Interp][NFC] Take a const Function pointer in Context::Run()

2023-07-06 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-06T14:52:05+02:00
New Revision: 868aa9360587945146c86449cbd6c5170e1c9e2b

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

LOG: [clang][Interp][NFC] Take  a const Function pointer in Context::Run()

Added: 


Modified: 
clang/lib/AST/Interp/Context.cpp
clang/lib/AST/Interp/Context.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Context.cpp 
b/clang/lib/AST/Interp/Context.cpp
index 67fb69e6633823..9d093ba1ad65b0 100644
--- a/clang/lib/AST/Interp/Context.cpp
+++ b/clang/lib/AST/Interp/Context.cpp
@@ -139,7 +139,7 @@ const llvm::fltSemantics 
&Context::getFloatSemantics(QualType T) const {
   return Ctx.getFloatTypeSemantics(T);
 }
 
-bool Context::Run(State &Parent, Function *Func, APValue &Result) {
+bool Context::Run(State &Parent, const Function *Func, APValue &Result) {
   InterpState State(Parent, *P, Stk, *this);
   State.Current = new InterpFrame(State, Func, /*Caller=*/nullptr, {});
   if (Interpret(State, Result))

diff  --git a/clang/lib/AST/Interp/Context.h b/clang/lib/AST/Interp/Context.h
index 107bb75a46247e..8879186f7072ec 100644
--- a/clang/lib/AST/Interp/Context.h
+++ b/clang/lib/AST/Interp/Context.h
@@ -70,7 +70,7 @@ class Context final {
 
 private:
   /// Runs a function.
-  bool Run(State &Parent, Function *Func, APValue &Result);
+  bool Run(State &Parent, const Function *Func, APValue &Result);
 
   /// Checks a result from the interpreter.
   bool Check(State &Parent, llvm::Expected &&R);



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


[clang] bd59d17 - [clang][Interp][NFC] Fix some doc comment confusion

2023-07-06 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-06T14:52:05+02:00
New Revision: bd59d17e71f8c58f25fdba7f614cb0449c38d628

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

LOG: [clang][Interp][NFC] Fix some doc comment confusion

These are supposed to be regular comments.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeEmitter.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp 
b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index 3533559ac3ca4b..1a5b683a3b6955 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -131,7 +131,7 @@ void ByteCodeEmitter::emitLabel(LabelTy Label) {
 for (unsigned Reloc : It->second) {
   using namespace llvm::support;
 
-  /// Rewrite the operand of all jumps to this label.
+  // Rewrite the operand of all jumps to this label.
   void *Location = Code.data() + Reloc - align(sizeof(int32_t));
   assert(aligned(Location));
   const int32_t Offset = Target - static_cast(Reloc);
@@ -199,14 +199,14 @@ template 
 bool ByteCodeEmitter::emitOp(Opcode Op, const Tys &... Args, const SourceInfo 
&SI) {
   bool Success = true;
 
-  /// The opcode is followed by arguments. The source info is
-  /// attached to the address after the opcode.
+  // The opcode is followed by arguments. The source info is
+  // attached to the address after the opcode.
   emit(P, Code, Op, Success);
   if (SI)
 SrcMap.emplace_back(Code.size(), SI);
 
-  /// The initializer list forces the expression to be evaluated
-  /// for each argument in the variadic template, in order.
+  // The initializer list forces the expression to be evaluated
+  // for each argument in the variadic template, in order.
   (void)std::initializer_list{(emit(P, Code, Args, Success), 0)...};
 
   return Success;



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


[clang] 00c2739 - [clang][Interp][NFC] Move some declarations into the if condition

2023-07-06 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-06T14:52:05+02:00
New Revision: 00c27397dc63358bc7e5975c7af80efbf863d2c2

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

LOG: [clang][Interp][NFC] Move some declarations into the if condition

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeEmitter.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp 
b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index 1a5b683a3b6955..359e774d12716d 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -126,8 +126,9 @@ Scope::Local ByteCodeEmitter::createLocal(Descriptor *D) {
 void ByteCodeEmitter::emitLabel(LabelTy Label) {
   const size_t Target = Code.size();
   LabelOffsets.insert({Label, Target});
-  auto It = LabelRelocs.find(Label);
-  if (It != LabelRelocs.end()) {
+
+  if (auto It = LabelRelocs.find(Label);
+  It != LabelRelocs.end()) {
 for (unsigned Reloc : It->second) {
   using namespace llvm::support;
 
@@ -148,10 +149,9 @@ int32_t ByteCodeEmitter::getOffset(LabelTy Label) {
   assert(aligned(Position));
 
   // If target is known, compute jump offset.
-  auto It = LabelOffsets.find(Label);
-  if (It != LabelOffsets.end()) {
+  if (auto It = LabelOffsets.find(Label);
+  It != LabelOffsets.end())
 return It->second - Position;
-  }
 
   // Otherwise, record relocation and return dummy offset.
   LabelRelocs[Label].push_back(Position);



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


[PATCH] D152554: [OpenMP] Migrate device code privatisation from Clang CodeGen to OMPIRBuilder

2023-07-06 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 537680.
TIFitis added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152554

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4175,7 +4175,7 @@
 omp::RuntimeFunction *MapperFunc,
 function_ref
 BodyGenCB,
-function_ref DeviceAddrCB,
+function_ref DeviceAddrCB,
 function_ref CustomMapperCB, Value *SrcLocInfo) {
   if (!updateToLocation(Loc))
 return InsertPointTy();
@@ -4222,6 +4222,14 @@
 
   Builder.CreateCall(BeginMapperFunc, OffloadingArgs);
 
+  for (auto DeviceMap : Info.DevicePtrInfoMap) {
+if (isa(DeviceMap.second.second)) {
+  auto *LI =
+  Builder.CreateLoad(Builder.getPtrTy(), DeviceMap.second.first);
+  Builder.CreateStore(LI, DeviceMap.second.second);
+}
+  }
+
   // If device pointer privatization is required, emit the body of the
   // region here. It will have to be duplicated: with and without
   // privatization.
@@ -4635,7 +4643,7 @@
 void OpenMPIRBuilder::emitOffloadingArrays(
 InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
 TargetDataInfo &Info, bool IsNonContiguous,
-function_ref DeviceAddrCB,
+function_ref DeviceAddrCB,
 function_ref CustomMapperCB) {
 
   // Reset the array information.
@@ -4773,9 +4781,21 @@
 BPVal, BP, M.getDataLayout().getPrefTypeAlign(Builder.getInt8PtrTy()));
 
 if (Info.requiresDevicePointerInfo()) {
-  assert(DeviceAddrCB &&
- "DeviceAddrCB missing for DevicePtr code generation");
-  DeviceAddrCB(I, BP, BPVal);
+  if (CombinedInfo.DevicePointers[I] == DeviceInfoTy::Pointer) {
+CodeGenIP = Builder.saveIP();
+Builder.restoreIP(AllocaIP);
+Info.DevicePtrInfoMap[BPVal] = {
+BP, Builder.CreateAlloca(Builder.getPtrTy())};
+Builder.restoreIP(CodeGenIP);
+assert(DeviceAddrCB &&
+   "DeviceAddrCB missing for DevicePtr code generation");
+DeviceAddrCB(I, Info.DevicePtrInfoMap[BPVal].second);
+  } else if (CombinedInfo.DevicePointers[I] == DeviceInfoTy::Address) {
+Info.DevicePtrInfoMap[BPVal] = {BP, BP};
+assert(DeviceAddrCB &&
+   "DeviceAddrCB missing for DevicePtr code generation");
+DeviceAddrCB(I, BP);
+  }
 }
 
 Value *PVal = CombinedInfo.Pointers[I];
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1611,6 +1611,9 @@
   public:
 TargetDataRTArgs RTArgs;
 
+SmallMapVector, 4>
+DevicePtrInfoMap;
+
 /// Indicate whether any user-defined mapper exists.
 bool HasMapper = false;
 /// The total number of pointers passed to the runtime library.
@@ -1637,7 +1640,9 @@
 bool separateBeginEndCalls() { return SeparateBeginEndCalls; }
   };
 
+  enum class DeviceInfoTy { None, Pointer, Address };
   using MapValuesArrayTy = SmallVector;
+  using MapDeviceInfoArrayTy = SmallVector;
   using MapFlagsArrayTy = SmallVector;
   using MapNamesArrayTy = SmallVector;
   using MapDimArrayTy = SmallVector;
@@ -1656,6 +1661,7 @@
 };
 MapValuesArrayTy BasePointers;
 MapValuesArrayTy Pointers;
+MapDeviceInfoArrayTy DevicePointers;
 MapValuesArrayTy Sizes;
 MapFlagsArrayTy Types;
 MapNamesArrayTy Names;
@@ -1666,6 +1672,8 @@
   BasePointers.append(CurInfo.BasePointers.begin(),
   CurInfo.BasePointers.end());
   Pointers.append(CurInfo.Pointers.begin(), CurInfo.Pointers.end());
+  DevicePointers.append(CurInfo.DevicePointers.begin(),
+CurInfo.DevicePointers.end());
   Sizes.append(CurInfo.Sizes.begin(), CurInfo.Sizes.end());
   Types.append(CurInfo.Types.begin(), CurInfo.Types.end());
   Names.append(CurInfo.Names.begin(), CurInfo.Names.end());
@@ -1724,7 +1732,7 @@
   void emitOffloadingArrays(
   InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
   TargetDataInfo &Info, bool IsNonContiguous = false,
-  function_ref DeviceAddrCB = nullptr,
+  function_ref DeviceAddrCB = nullptr,
   function_ref CustomMapperCB = nullptr);
 
   /// Creates offloading entry for the provided entry ID \a ID, address \a
@@ -2111,7 +2119,7 @@

[PATCH] D154602: [clang][clangd] Don't crash/assert on -gsplit-dwarf=single without output

2023-07-06 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added reviewers: yaxunl, tra, MaskRay.
DmitryPolukhin added projects: clang, clang-tools-extra.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
DmitryPolukhin published this revision for review.
Herald added subscribers: cfe-commits, ilya-biryukov.

The crash happens in clang::driver::tools::SplitDebugName when Output is
InputInfo::Nothing. It doesn't happen with standalone clang driver because
output is created in Driver::BuildJobsForActionNoCache.

Example backtrace:

  * thread #1, name = 'clangd', stop reason = hit program assert
* frame #0: 0x75c4eacf libc.so.6`raise + 271
  frame #1: 0x75c21ea5 libc.so.6`abort + 295
  frame #2: 0x75c21d79 libc.so.6`__assert_fail_base.cold.0 + 15
  frame #3: 0x75c47426 libc.so.6`__assert_fail + 70
  frame #4: 0x5dc0923c 
clangd`clang::driver::InputInfo::getFilename(this=0x7fff9398) const at 
InputInfo.h:84:5
  frame #5: 0x5dcd0d8d 
clangd`clang::driver::tools::SplitDebugName(JA=0x5f6c6a50, 
Args=0x5f6d0b80, Input=0x7fff9678, Output=0x7fff9398) 
at CommonArgs.cpp:1275:40
  frame #6: 0x5dc955a5 
clangd`clang::driver::tools::Clang::ConstructJob(this=0x5f6c69d0, 
C=0x5f6c64a0, JA=0x5f6c6a50, Output=0x7fff9398, 
Inputs=0x7fff9668, Args=0x5f6d0b80, 
LinkingOutput=0x) const at Clang.cpp:5690:33
  frame #7: 0x5dbf6b54 
clangd`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fffb5e0,
 C=0x5f6c64a0, A=0x5f6c6a50, TC=0x5f6c4be0, 
BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
MultipleArchs=false, LinkingOutput=0x, CachedResults=size=1, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:5618:10
  frame #8: 0x5dbf4ef0 
clangd`clang::driver::Driver::BuildJobsForAction(this=0x7fffb5e0, 
C=0x5f6c64a0, A=0x5f6c6a50, TC=0x5f6c4be0, 
BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
MultipleArchs=false, LinkingOutput=0x, CachedResults=size=1, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:5306:26
  frame #9: 0x5dbeb590 
clangd`clang::driver::Driver::BuildJobs(this=0x7fffb5e0, 
C=0x5f6c64a0) const at Driver.cpp:4844:5
  frame #10: 0x5dbe6b0f 
clangd`clang::driver::Driver::BuildCompilation(this=0x7fffb5e0, 
ArgList=ArrayRef @ 0x7fffb268) at Driver.cpp:1496:3
  frame #11: 0x5b0cc0d9 
clangd`clang::createInvocation(ArgList=ArrayRef @ 
0x7fffbb38, Opts=CreateInvocationOptions @ 0x7fffbb90) at 
CreateInvocationFromCommandLine.cpp:53:52
  frame #12: 0x5b378e7b 
clangd`clang::clangd::buildCompilerInvocation(Inputs=0x7fffca58, 
D=0x7fffc158, CC1Args=size=0) at Compiler.cpp:116:44
  frame #13: 0x5895a6c8 clangd`clang::clangd::(anonymous 
namespace)::Checker::buildInvocation(this=0x7fffc760, 
TFS=0x7fffe570, Contents= Has Value=false ) at Check.cpp:212:9
  frame #14: 0x58959cec clangd`clang::clangd::check(File=(Data = 
"build/test.cpp", Length = 64), TFS=0x7fffe570, 
Opts=0x7fffe600) at Check.cpp:486:34
  frame #15: 0x5892164a clangd`main(argc=4, 
argv=0x7fffecd8) at ClangdMain.cpp:993:12
  frame #16: 0x75c3ad85 libc.so.6`__libc_start_main + 229
  frame #17: 0x585bbe9e clangd`_start + 46

Test Plan: check-clangd


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154602

Files:
  clang-tools-extra/clangd/unittests/CompilerTests.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1271,7 +1271,7 @@
 F += ".dwo";
   };
   if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ))
-if (StringRef(A->getValue()) == "single")
+if (StringRef(A->getValue()) == "single" && Output.isFilename())
   return Args.MakeArgString(Output.getFilename());
 
   SmallString<128> T;
Index: clang-tools-extra/clangd/unittests/CompilerTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompilerTests.cpp
+++ clang-tools-extra/clangd/unittests/CompilerTests.cpp
@@ -113,6 +113,13 @@
   // No crash.
   EXPECT_EQ(buildCompilerInvocation(Inputs, Diags), nullptr);
 }
+
+TEST(BuildCompilerInvocation, SplitSwarfSingleCrash) {
+  TestTU TU;
+  TU.ExtraArgs = {"-gdwarf-4", "-gsplit-dwarf=single"};
+  TU.build(); // no-crash
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
=

[PATCH] D154580: [clangd][c++20]Add missing semantic highlighing for concepts.

2023-07-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice! I forgot about the TypeLoc hierarchy, getNameLoc() isn't so obvious...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154580

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


[PATCH] D154556: [OPENMP52] Support Support omp_cur_iteration modifier for doacross clause.

2023-07-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/AST/OpenMPClause.cpp:2516-2523
+  if (DepType == OMPC_DOACROSS_source)
+OS << "source:";
+  else if (DepType == OMPC_DOACROSS_sink)
+OS << "sink:";
+  else if (DepType == OMPC_DOACROSS_source_omp_cur_iteration)
+OS << "source: omp_cur_iteration";
+  else if (DepType == OMPC_DOACROSS_sink_omp_cur_iteration)

switch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154556

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


[PATCH] D154603: [analyzer][clangsa] Add new option to alpha.security.cert.InvalidPtrChecker

2023-07-06 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a reviewer: NoQ.
Herald added a project: All.
gamesh411 requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.
Herald added a project: clang.

The invalidation of pointer pointers returned by subsequent calls to genenv is
suggested by the POSIX standard, but is too strict from a practical point of
view. A new checker option 'InvalidatingGetEnv' is introduced, and is set to a
more lax default value, which does not consider consecutive getenv calls
invalidating.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154603

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/cert/env34-c-cert-examples.c
  clang/test/Analysis/cert/env34-c.c

Index: clang/test/Analysis/cert/env34-c.c
===
--- clang/test/Analysis/cert/env34-c.c
+++ clang/test/Analysis/cert/env34-c.c
@@ -1,6 +1,11 @@
 // RUN: %clang_analyze_cc1 \
 // RUN:  -analyzer-checker=alpha.security.cert.env.InvalidPtr\
+// RUN:  -analyzer-config alpha.security.cert.env.InvalidPtr:InvalidatingGetEnv=true \
 // RUN:  -analyzer-output=text -verify -Wno-unused %s
+//
+// TODO: write test cases that follow the pattern:
+//   "getenv -> store pointer -> setenv -> use stored pointer"
+//   and not rely solely on getenv as an invalidating function
 
 #include "../Inputs/system-header-simulator.h"
 char *getenv(const char *name);
Index: clang/test/Analysis/cert/env34-c-cert-examples.c
===
--- clang/test/Analysis/cert/env34-c-cert-examples.c
+++ clang/test/Analysis/cert/env34-c-cert-examples.c
@@ -1,15 +1,49 @@
+// Default options.
 // RUN: %clang_analyze_cc1 \
 // RUN:  -analyzer-checker=core,alpha.security.cert.env.InvalidPtr \
 // RUN:  -verify -Wno-unused %s
+//
+// Test the laxer handling of getenv function (this is the default).
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,alpha.security.cert.env.InvalidPtr \
+// RUN:  -analyzer-config alpha.security.cert.env.InvalidPtr:InvalidatingGetEnv=false \
+// RUN:  -verify -Wno-unused %s
+//
+// Test the stricter handling of getenv function.
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,alpha.security.cert.env.InvalidPtr \
+// RUN:  -analyzer-config alpha.security.cert.env.InvalidPtr:InvalidatingGetEnv=true \
+// RUN:  -verify=pedantic -Wno-unused %s
 
 #include "../Inputs/system-header-simulator.h"
 char *getenv(const char *name);
+int setenv(const char *name, const char *value, int overwrite);
 int strcmp(const char*, const char*);
 char *strdup(const char*);
 void free(void *memblock);
 void *malloc(size_t size);
 
-void incorrect_usage(void) {
+void incorrect_usage_setenv_getenv_invalidation(void) {
+  char *tmpvar;
+  char *tempvar;
+
+  tmpvar = getenv("TMP");
+
+  if (!tmpvar)
+return;
+
+  setenv("TEMP", "", 1); //setenv can invalidate env
+
+  if (!tmpvar)
+return;
+
+  if (strcmp(tmpvar, "") == 0) { // body of strcmp is unknown
+// expected-warning@-1{{use of invalidated pointer 'tmpvar' in a function call}}
+// pedantic-warning@-2{{use of invalidated pointer 'tmpvar' in a function call}}
+  }
+}
+
+void incorrect_usage_double_getenv_invalidation(void) {
   char *tmpvar;
   char *tempvar;
 
@@ -18,13 +52,13 @@
   if (!tmpvar)
 return;
 
-  tempvar = getenv("TEMP");
+  tempvar = getenv("TEMP"); //getenv should not invalidate env in non-pedantic mode
 
   if (!tempvar)
 return;
 
   if (strcmp(tmpvar, tempvar) == 0) { // body of strcmp is unknown
-// expected-warning@-1{{use of invalidated pointer 'tmpvar' in a function call}}
+// pedantic-warning@-1{{use of invalidated pointer 'tmpvar' in a function call}}
   }
 }
 
Index: clang/test/Analysis/analyzer-config.c
===
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -11,6 +11,7 @@
 // CHECK-NEXT: alpha.osx.cocoa.DirectIvarAssignment:AnnotatedFunctions = false
 // CHECK-NEXT: alpha.security.MmapWriteExec:MmapProtExec = 0x04
 // CHECK-NEXT: alpha.security.MmapWriteExec:MmapProtRead = 0x01
+// CHECK-NEXT: alpha.security.cert.env.InvalidPtr:InvalidatingGetEnv = false
 // CHECK-NEXT: alpha.security.taint.TaintPropagation:Config = ""
 // CHECK-NEXT: alpha.unix.Errno:AllowErrnoReadOutsideConditionExpressions = true
 // CHECK-NEXT: alpha.unix.StdCLibraryFunctions:DisplayLoadedSummaries = false
Index: clang/lib/StaticAnalyzer/Checkers/cer

[PATCH] D135849: [llvm] Return canonical virtual path from `RedirectingFileSystem`

2023-07-06 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 537689.
jansvoboda11 added a comment.

Add unit tests, use `SmallVector`, make `clang-scan-deps` test portable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135849

Files:
  clang/lib/Lex/ModuleMap.cpp
  clang/test/ClangScanDeps/modules-canononical-module-map-case.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -2580,6 +2580,7 @@
   Lower->addSymlink("/link");
   IntrusiveRefCntPtr FS = getFromYAMLString(
   "{ 'use-external-names': false,\n"
+  "  'case-sensitive': false,\n"
   "  'roots': [\n"
   "{\n"
   "  'type': 'directory',\n"
@@ -2588,6 +2589,11 @@
   "  'type': 'file',\n"
   "  'name': 'bar',\n"
   "  'external-contents': '/link'\n"
+  "},\n"
+  "{\n"
+  "  'type': 'directory',\n"
+  "  'name': 'baz',\n"
+  "  'contents': []\n"
   "}\n"
   "  ]\n"
   "},\n"
@@ -2610,9 +2616,9 @@
   EXPECT_FALSE(FS->getRealPath("//root/bar", RealPath));
   EXPECT_EQ(RealPath.str(), "/symlink");
 
-  // Directories should fall back to the underlying file system is possible.
-  EXPECT_FALSE(FS->getRealPath("//dir/", RealPath));
-  EXPECT_EQ(RealPath.str(), "//dir/");
+  // Directories should return the virtual path as written in the definition.
+  EXPECT_FALSE(FS->getRealPath("//ROOT/baz", RealPath));
+  EXPECT_EQ(RealPath.str(), "//root/baz");
 
   // Try a non-existing file.
   EXPECT_EQ(FS->getRealPath("/non_existing", RealPath),
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -2239,6 +2239,14 @@
   }
 }
 
+void RedirectingFileSystem::LookupResult::getPath(
+llvm::SmallVectorImpl &Result) const {
+  Result.clear();
+  for (Entry *Parent : Parents)
+llvm::sys::path::append(Result, Parent->getName());
+  llvm::sys::path::append(Result, E->getName());
+}
+
 std::error_code
 RedirectingFileSystem::makeCanonical(SmallVectorImpl &Path) const {
   if (std::error_code EC = makeAbsolute(Path))
@@ -2257,11 +2265,14 @@
 RedirectingFileSystem::lookupPath(StringRef Path) const {
   sys::path::const_iterator Start = sys::path::begin(Path);
   sys::path::const_iterator End = sys::path::end(Path);
+  llvm::SmallVector Entries;
   for (const auto &Root : Roots) {
 ErrorOr Result =
-lookupPathImpl(Start, End, Root.get());
-if (Result || Result.getError() != llvm::errc::no_such_file_or_directory)
+lookupPathImpl(Start, End, Root.get(), Entries);
+if (Result || Result.getError() != llvm::errc::no_such_file_or_directory) {
+  Result->Parents = std::move(Entries);
   return Result;
+}
   }
   return make_error_code(llvm::errc::no_such_file_or_directory);
 }
@@ -2269,7 +2280,8 @@
 ErrorOr
 RedirectingFileSystem::lookupPathImpl(
 sys::path::const_iterator Start, sys::path::const_iterator End,
-RedirectingFileSystem::Entry *From) const {
+RedirectingFileSystem::Entry *From,
+llvm::SmallVectorImpl &Entries) const {
   assert(!isTraversalComponent(*Start) &&
  !isTraversalComponent(From->getName()) &&
  "Paths should not contain traversal components");
@@ -2298,10 +2310,12 @@
   auto *DE = cast(From);
   for (const std::unique_ptr &DirEntry :
llvm::make_range(DE->contents_begin(), DE->contents_end())) {
+Entries.push_back(From);
 ErrorOr Result =
-lookupPathImpl(Start, End, DirEntry.get());
+lookupPathImpl(Start, End, DirEntry.get(), Entries);
 if (Result || Result.getError() != llvm::errc::no_such_file_or_directory)
   return Result;
+Entries.pop_back();
   }
 
   return make_error_code(llvm::errc::no_such_file_or_directory);
@@ -2543,10 +2557,12 @@
 return P;
   }
 
-  // If we found a DirectoryEntry, still fallthrough to the original path if
-  // allowed, because directories don't have a single external contents path.
-  if (Redirection == RedirectKind::Fallthrough)
-return ExternalFS->getRealPath(CanonicalPath, Output);
+  // We found a DirectoryEntry, which does not have a single external contents
+  // path. Use the canonical virtual path.
+  if (Redirection == RedirectKind::Fallthrough) {
+Result->getPath(Output);
+return {};
+  }
   return llvm::errc::invalid_argument;
 }
 
Index: llvm/include/llvm/Support/VirtualFileSystem.h
===

[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-06 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.

Looks reasonable to me too.

It would be nice to have some documentation for this feature though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154295

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


[clang] d4f43e4 - [docs] Update 'please file a bug' link for clang-cl

2023-07-06 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-07-06T15:13:10+02:00
New Revision: d4f43e4293f98616057ccf00661926f540bfdfab

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

LOG: [docs] Update 'please file a bug' link for clang-cl

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 6a644eed6d32b7..da9d0d364cd03a 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -4146,7 +4146,7 @@ options are spelled with a leading ``/``, they will be 
mistaken for a filename:
 
 clang-cl.exe: error: no such file or directory: '/foobar'
 
-Please `file a bug 
`_
+Please `file a bug 
`_
 for any valid cl.exe flags that clang-cl does not understand.
 
 Execute ``clang-cl /?`` to see a list of supported options:



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


[PATCH] D154603: [analyzer][clangsa] Add new option to alpha.security.cert.InvalidPtrChecker

2023-07-06 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp:95
 // Stores the region of the environment pointer of 'main' (if present).
-REGISTER_TRAIT_WITH_PROGRAMSTATE(EnvPtrRegion, const MemRegion *)
+REGISTER_TRAIT_WITH_PROGRAMSTATE(MainEnvPtrRegion, const MemRegion *)
+

The state modelling is refined to model the env region coming from the main 
function and the getenv calls.



Comment at: clang/test/Analysis/cert/env34-c.c:6
+//
+// TODO: write test cases that follow the pattern:
+//   "getenv -> store pointer -> setenv -> use stored pointer"

This test file is incomplete.
I would welcome suggestions here as to how to test this.
Should a new file be created for the config option with different test cases, 
or is this file to be extended?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154603

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


[PATCH] D135849: [llvm][vfs] For virtual directories, use the virtual path as real path

2023-07-06 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

I think this patch should now stand on its own. Dealing with a VFS definition 
that uses the wrong case for virtual paths is not necessary for correctness. If 
Clang asks the FS for a file using the correct case, the query either fails and 
we never get far enough to need module map path canonicalization, or the query 
succeeds thanks to case-insensitivity of the VFS and canonicalizing to the VFS 
spelling means all future queries using it will succeed as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135849

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


[PATCH] D86993: Document Clang's expectations of the C standard library.

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

In D86993#4474682 , @nikic wrote:

>> I continue to think it's a mistake for us to document that Clang will not 
>> work with a conforming C standard library implementation unless we're filing 
>> issues with WG14 to alert them to the reasons why. If there's a DR filed 
>> with the committee, that gives us something to point our users to as 
>> justification. Otherwise, our users will correctly put these bugs at our 
>> feet.
>
> As you are involved with WG14, can you please take care of that? I couldn't 
> even find out how one is supposed to file a DR.

I'm happy to help with it, but I'll need some outside help as well so I get the 
technical details and justifications correct and can defend them when 
presenting to the committee. If someone could put together a super rough draft 
of what changes we'd like to see and why, I can definitely work with them to 
polish it into a final document, get it to the committee, and champion it 
there. Related question though: what do we do if the committee rejects the DR? 
I think LLVM and Clang have slightly different pressures here, so we might have 
different answers.

FWIW, you can find more info here about how to communicate with WG14: 
https://www.open-std.org/jtc1/sc22/wg14/www/contributing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86993

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


[PATCH] D154091: [clang-format] Recognize escape sequences when breaking strings

2023-07-06 Thread sstwcw via Phabricator via cfe-commits
sstwcw updated this revision to Diff 537701.
sstwcw added a comment.

- Add tests for non-whitespace sequences


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154091

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14832,6 +14832,69 @@
 "\"/and\"",
 format("\"some/tex/and\"", getLLVMStyleWithColumns(6)));
 
+  // Escape sequences should be recognized.  When the limit is 13 columns,
+  // another character can fit on the first line between the escape sequence and
+  // the closing quote.  We know the escape sequence is recognized when the
+  // program doesn't put the character following the escape sequence on the
+  // first line.
+  verifyFormat(R"(x = "some\n"
+"text";)",
+   R"(x = "some\ntext";)", getLLVMStyleWithColumns(12));
+  verifyFormat(R"(x = "some\n"
+"text";)",
+   R"(x = "some\ntext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\n"
+" text";)",
+   R"(x = "some\n text";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\t"
+"text";)",
+   R"(x = "some\ttext";)", getLLVMStyleWithColumns(12));
+  verifyFormat(R"(x = "some\t"
+"text";)",
+   R"(x = "some\ttext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\f"
+"text";)",
+   R"(x = "some\ftext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\r"
+"text";)",
+   R"(x = "some\rtext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\v"
+"text";)",
+   R"(x = "some\vtext";)", getLLVMStyleWithColumns(13));
+  // A newline outside of the column limit should not cause a break.
+  verifyFormat(R"(x = "something "
+"so\nshort";)",
+   R"(x = "something so\nshort";)", getLLVMStyleWithColumns(16));
+  verifyFormat(R"(x = "something "
+"so\nshort";)",
+   R"(x = "something so\nshort";)", getLLVMStyleWithColumns(19));
+  verifyFormat(R"(x = "something so\n"
+"short";)",
+   R"(x = "something so\nshort";)", getLLVMStyleWithColumns(20));
+  // Escape sequences for characters that are not whitespace should not be
+  // treated as whitespace.
+  verifyFormat(R"(x = "some\at"
+"ext";)",
+   R"(x = "some\atext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\bt"
+"ext";)",
+   R"(x = "some\btext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\et"
+"ext";)",
+   R"(x = "some\etext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "s\157me"
+"text";)",
+   R"(x = "s\157metext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "s\x6fme"
+"text";)",
+   R"(x = "s\x6fmetext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "s\u006fm"
+"etext";)",
+   R"(x = "s\u006fmetext";)", getLLVMStyleWithColumns(14));
+  verifyFormat(R"(x = "s\U006fm"
+"etext";)",
+   R"(x = "s\U006fmetext";)", getLLVMStyleWithColumns(18));
+
   EXPECT_EQ("variable =\n"
 "\"long string \"\n"
 "\"literal\";",
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -176,13 +176,15 @@
   if (ColumnLimit <= UsedColumns)
 return BreakableToken::Split(StringRef::npos, 0);
   unsigned MaxSplit = ColumnLimit - UsedColumns;
-  StringRef::size_type SpaceOffset = 0;
+  StringRef::size_type NewLine = 0;
+  StringRef::size_type AfterSpace = 0;
   StringRef::size_type SlashOffset = 0;
   StringRef::size_type WordStartOffset = 0;
   StringRef::size_type SplitPoint = 0;
   for (unsigned Chars = 0;;) {
 unsigned Advance;
-if (Text[0] == '\\') {
+bool EscapeSequence = Text[0] == '\\';
+if (EscapeSequence) {
   Advance = encoding::getEscapeSequenceLength(Text);
   Chars += Advance;
 } else {
@@ -194,8 +196,21 @@
 if (Chars > MaxSplit || Text.size() <= Advance)
   break;
 
+if (EscapeSequence && Advance == 2) {
+  switch (Text[1]) {
+  case 'n':
+NewLine = SplitPoint + 2;
+break;
+  case 'f':
+  case 'r':
+  case 't':
+  case 'v':
+AfterSpace = SplitPoint + 2;
+break;
+  }
+}
 if (IsBlank(Text[0]))
-  SpaceOffset = SplitPoint;
+  AfterSpace = SplitPoint + 1;
 if (Text[0] == '/')
   SlashOffset = SplitPoint;
 if (Advance == 1 && !isAlphanumeric(Text[0]))
@@ -205,8 +220,10 @@
 Text = Text.substr(Advance);
   }
 
-  if (SpaceOffset != 0)
-return BreakableToken

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

2023-07-06 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 updated this revision to Diff 537706.

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

https://reviews.llvm.org/D153883

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  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:%.*]] = add nuw i64 [[TMP4]], 3
+// CHECK-NEXT:[[TMP6:%.*]] = udiv i64 [[TMP5]], 4
+// CHECK-NEXT:[[TMP7:%.*]] = mul nuw i64 [[TMP6]], 4
+// CHECK-NEXT:[[A:%.*]] = call align 4 ptr @__kmpc_alloc_shared(i64 [[TMP7]])
+// CHECK-NEXT:store i64 [[TMP3]], ptr [[__VLA_EXPR0_ASCAST]], align 8
+// CH

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

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

@ABataev thank you for the review! I have now fixed the last nit and will 
commit the patch soon!


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


[clang] f97b61e - [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-06 Thread Haohai Wen via cfe-commits

Author: Haohai Wen
Date: 2023-07-06T22:18:58+08:00
New Revision: f97b61ed27aa6b0cef21e86e71d683feab32ce34

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

LOG: [Driver][MSVC] Support DWARF fission when using LTO on Windows

D154070 has added /dwodir to lld/COFF to tells LTO backend to create dwo
directory and files. This patch makes clang to emit /dwodir to lld when
user specify -gsplit-dwarf with LTO. This behavior is simiar to DWARF
fission with LTO for ELF.

A simple use case:
$clang-cl -c -flto -gdwarf main.c -o main.o
$clang-cl -c -flto -gdwarf a.c -o a.o
$clang-cl -flto -fuse-ld=lld -gdwarf -gsplit-dwarf main.o a.o

This'll generate a dwo file: main.exe_dwo/0.dwo

Reviewed By: mstorsjo, MaskRay, hans

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/MSVC.cpp
clang/test/Driver/lto-dwo.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 6b2eaef1f2e7d1..4a6989d113f82b 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -277,11 +277,18 @@ void visualstudio::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   else if (Linker.equals_insensitive("lld"))
 Linker = "lld-link";
 
-  if (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 (C.getDriver().isUsingLTO() &&
+Args.hasFlag(options::OPT_gsplit_dwarf, options::OPT_gno_split_dwarf,
+ false))
+  CmdArgs.push_back(Args.MakeArgString(Twine("/dwodir:") +
+   Output.getFilename() + "_dwo"));
+  }
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {

diff  --git a/clang/test/Driver/lto-dwo.c b/clang/test/Driver/lto-dwo.c
index 0bac5f25d4daac..206d4cba7f2a92 100644
--- a/clang/test/Driver/lto-dwo.c
+++ b/clang/test/Driver/lto-dwo.c
@@ -1,6 +1,9 @@
 // Confirm that -gsplit-dwarf=DIR is passed to linker
 
 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf 
-o a.out 2> %t
-// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s
+// RUN: FileCheck -check-prefix=CHECK-LINK-ELF-DWO-DIR-DEFAULT < %t %s
+// RUN: %clang_cl --target=x86_64-unknown-windows-msvc -### -fuse-ld=lld -flto 
-gsplit-dwarf -o a.out -- %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-COFF-DWO-DIR-DEFAULT < %t %s
 //
-// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-ELF-DWO-DIR-DEFAULT:  "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-COFF-DWO-DIR-DEFAULT: "/dwodir:a.out_dwo"



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


[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-06 Thread Haohai, Wen 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 rGf97b61ed27aa: [Driver][MSVC] Support DWARF fission when 
using LTO on Windows (authored by HaohaiWen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154295

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/lto-dwo.c


Index: clang/test/Driver/lto-dwo.c
===
--- clang/test/Driver/lto-dwo.c
+++ clang/test/Driver/lto-dwo.c
@@ -1,6 +1,9 @@
 // Confirm that -gsplit-dwarf=DIR is passed to linker
 
 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf 
-o a.out 2> %t
-// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s
+// RUN: FileCheck -check-prefix=CHECK-LINK-ELF-DWO-DIR-DEFAULT < %t %s
+// RUN: %clang_cl --target=x86_64-unknown-windows-msvc -### -fuse-ld=lld -flto 
-gsplit-dwarf -o a.out -- %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-COFF-DWO-DIR-DEFAULT < %t %s
 //
-// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-ELF-DWO-DIR-DEFAULT:  "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-COFF-DWO-DIR-DEFAULT: "/dwodir:a.out_dwo"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -277,11 +277,18 @@
   else if (Linker.equals_insensitive("lld"))
 Linker = "lld-link";
 
-  if (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 (C.getDriver().isUsingLTO() &&
+Args.hasFlag(options::OPT_gsplit_dwarf, options::OPT_gno_split_dwarf,
+ false))
+  CmdArgs.push_back(Args.MakeArgString(Twine("/dwodir:") +
+   Output.getFilename() + "_dwo"));
+  }
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {


Index: clang/test/Driver/lto-dwo.c
===
--- clang/test/Driver/lto-dwo.c
+++ clang/test/Driver/lto-dwo.c
@@ -1,6 +1,9 @@
 // Confirm that -gsplit-dwarf=DIR is passed to linker
 
 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf -o a.out 2> %t
-// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s
+// RUN: FileCheck -check-prefix=CHECK-LINK-ELF-DWO-DIR-DEFAULT < %t %s
+// RUN: %clang_cl --target=x86_64-unknown-windows-msvc -### -fuse-ld=lld -flto -gsplit-dwarf -o a.out -- %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-COFF-DWO-DIR-DEFAULT < %t %s
 //
-// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-ELF-DWO-DIR-DEFAULT:  "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-COFF-DWO-DIR-DEFAULT: "/dwodir:a.out_dwo"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -277,11 +277,18 @@
   else if (Linker.equals_insensitive("lld"))
 Linker = "lld-link";
 
-  if (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 (C.getDriver().isUsingLTO() &&
+Args.hasFlag(options::OPT_gsplit_dwarf, options::OPT_gno_split_dwarf,
+ false))
+  CmdArgs.push_back(Args.MakeArgString(Twine("/dwodir:") +
+   Output.getFilename() + "_dwo"));
+  }
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

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

Thanks everyone.

> It would be nice to have some documentation for this feature though.

This feature is same as Linux -gsplit-dwarf.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154295

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


[PATCH] D153296: [AST] Stop evaluate constant expression if the condition expression which in switch statement contains errors

2023-07-06 Thread Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 537714.
yronglin added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153296

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-function-recovery-crash.cpp


Index: clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
===
--- clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
+++ clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
@@ -87,6 +87,7 @@
 // We're not checking specific recovery here so don't assert diagnostics.
 TEST_EVALUATE(Switch, switch (!!){});  // expected-error + {{}}
 TEST_EVALUATE(SwitchInit, switch (auto x = !!){}); // expected-error + {{}}
+TEST_EVALUATE(SwitchCondValDep, switch (invalid_value) { default: break; });   
 // expected-error + {{}}
 TEST_EVALUATE(For, for (!!){}); // expected-error + {{}}
 // FIXME: should bail out instead of looping.
 // expected-note@-2 + {{infinite loop}}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4913,11 +4913,20 @@
 
 static bool EvaluateDependentExpr(const Expr *E, EvalInfo &Info) {
   assert(E->isValueDependent());
-  if (Info.noteSideEffect())
-return true;
+  // Note that we have a side effect that matters for constant evaluation.
+  bool SideEffects = Info.noteSideEffect();
+  // If the reason we're here is because of a recovery expression, we don't
+  // want to continue to evaluate further as we will never know what the actual
+  // value is.
+  if (isa(E))
+return false;
+
+  // Otherwise, return whether we want to continue after noting the side
+  // effects, which should only happen if the expression has errors but isn't
+  // a recovery expression on its own.
   assert(E->containsErrors() && "valid value-dependent expression should never 
"
 "reach invalid code path.");
-  return false;
+  return SideEffects;
 }
 
 /// Evaluate a condition (either a variable declaration or an expression).
@@ -5007,12 +5016,13 @@
 !EvaluateDecl(Info, SS->getConditionVariable()))
   return ESR_Failed;
 if (SS->getCond()->isValueDependent()) {
-  if (!EvaluateDependentExpr(SS->getCond(), Info))
-return ESR_Failed;
-} else {
-  if (!EvaluateInteger(SS->getCond(), Value, Info))
-return ESR_Failed;
+  // We don't know what the value is, and which branch should jump to.
+  EvaluateDependentExpr(SS->getCond(), Info);
+  return ESR_Failed;
 }
+if (!EvaluateInteger(SS->getCond(), Value, Info))
+return ESR_Failed;
+   
 if (!CondScope.destroy())
   return ESR_Failed;
   }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -568,6 +568,9 @@
 - Clang now correctly evaluates ``__has_extension (cxx_defaulted_functions)``
   and ``__has_extension (cxx_default_function_template_args)`` to 1.
   (`#61758 `_)
+- Stop evaluating a constant expression if the condition expression which in
+  switch statement contains errors.
+  (`#63453 _`)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
===
--- clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
+++ clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
@@ -87,6 +87,7 @@
 // We're not checking specific recovery here so don't assert diagnostics.
 TEST_EVALUATE(Switch, switch (!!){});  // expected-error + {{}}
 TEST_EVALUATE(SwitchInit, switch (auto x = !!){}); // expected-error + {{}}
+TEST_EVALUATE(SwitchCondValDep, switch (invalid_value) { default: break; });// expected-error + {{}}
 TEST_EVALUATE(For, for (!!){}); // expected-error + {{}}
 // FIXME: should bail out instead of looping.
 // expected-note@-2 + {{infinite loop}}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4913,11 +4913,20 @@
 
 static bool EvaluateDependentExpr(const Expr *E, EvalInfo &Info) {
   assert(E->isValueDependent());
-  if (Info.noteSideEffect())
-return true;
+  // Note that we have a side effect that matters for constant evaluation.
+  bool SideEffects = Info.noteSideEffect();
+  // If the reason we're here is because of a recovery expression, we don't
+  // w

[clang-tools-extra] 8af9a37 - Add missing semantic highlighing for concepts.

2023-07-06 Thread Jens Massberg via cfe-commits

Author: Jens Massberg
Date: 2023-07-06T16:28:57+02:00
New Revision: 8af9a373ad95ef49e2f2aa83c021b8043f848ab9

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

LOG: Add missing semantic highlighing for concepts.

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

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index f6a3f7ac66aa09..8003a3c98f0ad8 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -737,8 +737,10 @@ class CollectExtraHighlightings
   }
 
   bool VisitAutoTypeLoc(AutoTypeLoc L) {
-if (L.isConstrained())
+if (L.isConstrained()) {
   H.addAngleBracketTokens(L.getLAngleLoc(), L.getRAngleLoc());
+  H.addToken(L.getConceptNameInfo().getLoc(), HighlightingKind::Concept);
+}
 return true;
   }
 
@@ -953,13 +955,18 @@ class CollectExtraHighlightings
 kindForType(AT->getDeducedType().getTypePtrOrNull(), H.getResolver());
 if (!K)
   return true;
-SourceLocation StartLoc = D->getTypeSpecStartLoc();
+auto *TSI = D->getTypeSourceInfo();
+if (!TSI)
+  return true;
+SourceLocation StartLoc =
+TSI->getTypeLoc().getContainedAutoTypeLoc().getNameLoc();
 // The AutoType may not have a corresponding token, e.g. in the case of
 // init-captures. In this case, StartLoc overlaps with the location
 // of the decl itself, and producing a token for the type here would result
 // in both it and the token for the decl being dropped due to conflict.
 if (StartLoc == D->getLocation())
   return true;
+
 auto &Tok =
 H.addToken(StartLoc, *K).addModifier(HighlightingModifier::Deduced);
 const Type *Deduced = AT->getDeducedType().getTypePtrOrNull();

diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index ff052e6be9549c..6eee6ec30ac024 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -648,6 +648,15 @@ sizeof...($TemplateParameter[[Elements]]);
   void $Function_def[[bar]]($TemplateParameter[[T]] $Parameter_def[[F]]) {
 $Parameter[[F]].$Unknown_dependentName[[foo]]();
   }
+
+  struct $Class_def[[F]] {
+void $Method_def[[foo]]() {};
+  };
+  $Concept[[Fooable]] $Class_deduced[[auto]] $Variable_def[[f]] = 
$Class[[F]]();
+
+  void $Function_def[[Bar]]($Concept[[Fooable]] $TemplateParameter[[auto]] 
$Parameter_def[[x]]) {}
+
+  template$Bracket[[<]]$Concept[[Fooable]] auto 
$TemplateParameter_def_readonly[[x]]$Bracket[[>]] void $Function_def[[Boo]]() {}
 )cpp",
   // Dependent template name
   R"cpp(



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


[PATCH] D154580: [clangd][c++20]Add missing semantic highlighing for concepts.

2023-07-06 Thread Jens Massberg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
massberg marked an inline comment as done.
Closed by commit rG8af9a373ad95: Add missing semantic highlighing for concepts. 
(authored by massberg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154580

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -648,6 +648,15 @@
   void $Function_def[[bar]]($TemplateParameter[[T]] $Parameter_def[[F]]) {
 $Parameter[[F]].$Unknown_dependentName[[foo]]();
   }
+
+  struct $Class_def[[F]] {
+void $Method_def[[foo]]() {};
+  };
+  $Concept[[Fooable]] $Class_deduced[[auto]] $Variable_def[[f]] = 
$Class[[F]]();
+
+  void $Function_def[[Bar]]($Concept[[Fooable]] $TemplateParameter[[auto]] 
$Parameter_def[[x]]) {}
+
+  template$Bracket[[<]]$Concept[[Fooable]] auto 
$TemplateParameter_def_readonly[[x]]$Bracket[[>]] void $Function_def[[Boo]]() {}
 )cpp",
   // Dependent template name
   R"cpp(
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -737,8 +737,10 @@
   }
 
   bool VisitAutoTypeLoc(AutoTypeLoc L) {
-if (L.isConstrained())
+if (L.isConstrained()) {
   H.addAngleBracketTokens(L.getLAngleLoc(), L.getRAngleLoc());
+  H.addToken(L.getConceptNameInfo().getLoc(), HighlightingKind::Concept);
+}
 return true;
   }
 
@@ -953,13 +955,18 @@
 kindForType(AT->getDeducedType().getTypePtrOrNull(), H.getResolver());
 if (!K)
   return true;
-SourceLocation StartLoc = D->getTypeSpecStartLoc();
+auto *TSI = D->getTypeSourceInfo();
+if (!TSI)
+  return true;
+SourceLocation StartLoc =
+TSI->getTypeLoc().getContainedAutoTypeLoc().getNameLoc();
 // The AutoType may not have a corresponding token, e.g. in the case of
 // init-captures. In this case, StartLoc overlaps with the location
 // of the decl itself, and producing a token for the type here would result
 // in both it and the token for the decl being dropped due to conflict.
 if (StartLoc == D->getLocation())
   return true;
+
 auto &Tok =
 H.addToken(StartLoc, *K).addModifier(HighlightingModifier::Deduced);
 const Type *Deduced = AT->getDeducedType().getTypePtrOrNull();


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -648,6 +648,15 @@
   void $Function_def[[bar]]($TemplateParameter[[T]] $Parameter_def[[F]]) {
 $Parameter[[F]].$Unknown_dependentName[[foo]]();
   }
+
+  struct $Class_def[[F]] {
+void $Method_def[[foo]]() {};
+  };
+  $Concept[[Fooable]] $Class_deduced[[auto]] $Variable_def[[f]] = $Class[[F]]();
+
+  void $Function_def[[Bar]]($Concept[[Fooable]] $TemplateParameter[[auto]] $Parameter_def[[x]]) {}
+
+  template$Bracket[[<]]$Concept[[Fooable]] auto $TemplateParameter_def_readonly[[x]]$Bracket[[>]] void $Function_def[[Boo]]() {}
 )cpp",
   // Dependent template name
   R"cpp(
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -737,8 +737,10 @@
   }
 
   bool VisitAutoTypeLoc(AutoTypeLoc L) {
-if (L.isConstrained())
+if (L.isConstrained()) {
   H.addAngleBracketTokens(L.getLAngleLoc(), L.getRAngleLoc());
+  H.addToken(L.getConceptNameInfo().getLoc(), HighlightingKind::Concept);
+}
 return true;
   }
 
@@ -953,13 +955,18 @@
 kindForType(AT->getDeducedType().getTypePtrOrNull(), H.getResolver());
 if (!K)
   return true;
-SourceLocation StartLoc = D->getTypeSpecStartLoc();
+auto *TSI = D->getTypeSourceInfo();
+if (!TSI)
+  return true;
+SourceLocation StartLoc =
+TSI->getTypeLoc().getContainedAutoTypeLoc().getNameLoc();
 // The AutoType may not have a corresponding token, e.g. in the case of
 // init-captures. In this case, StartLoc overlaps with the location
 // of the decl itself, and producing a token for the type here would result
 // in both it and the token for the decl being dropped due to conflict.
 if (StartLoc

[PATCH] D147184: [clang][CodeGenCXX] Improve handling of itanium ABI member function alignment requirements

2023-07-06 Thread David Tenty 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 rG196c144d0bc1: [clang][CodeGenCXX] Improve handling of 
itanium ABI member function alignment… (authored by daltenty).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D147184?vs=537486&id=537718#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147184

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/member-alignment.cpp
  clang/test/Modules/cxx-irgen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_has_device_addr_codegen.cpp
  clang/test/OpenMP/target_has_device_addr_codegen_01.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen_hold.cpp
  clang/test/OpenMP/target_ompx_dyn_cgroup_mem_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_generic_loop_codegen-1.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_private_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_private_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_private_codegen.cpp
  clang/test/OpenMP/target_teams_num_teams_codegen.cpp
  clang/test/OpenMP/target_teams_thread_limit_codegen.cpp
  clang/test/OpenMP/teams_codegen.cpp
  clang/test/OpenMP/teams_distribute_codegen.cpp
  clang/test/OpenMP/teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/Open

[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-06 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D154295#4477165 , @HaohaiWen wrote:

>> It would be nice to have some documentation for this feature though.
>
> This feature is same as Linux -gsplit-dwarf.

Right, but it would be nice to document that clang-cl supports it (which is not 
obvious since it's mostly trying to be cl.exe compatible).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154295

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


[PATCH] D154221: [analyzer] Fix false negative when pass implicit cast nil to nonnull

2023-07-06 Thread Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb22a5d46179b: [analyzer] Fix false negative when pass 
implicit cast nil to nonnull (authored by songruiwang 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154221

Files:
  clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  clang/test/Analysis/nullability-arc.mm
  clang/test/Analysis/nullability.mm


Index: clang/test/Analysis/nullability.mm
===
--- clang/test/Analysis/nullability.mm
+++ clang/test/Analysis/nullability.mm
@@ -69,6 +69,7 @@
 void takesNonnull(Dummy *_Nonnull);
 void takesUnspecified(Dummy *);
 void takesNonnullBlock(void (^ _Nonnull)(void));
+void takesNonnullObject(NSObject *_Nonnull);
 
 Dummy *_Nullable returnsNullable();
 Dummy *_Nonnull returnsNonnull();
@@ -275,6 +276,17 @@
   return (Dummy * _Nonnull)0; // no-warning
 }
 
+void testImplicitCastNilToNonnull() {
+  id obj = nil;
+  takesNonnullObject(obj); // expected-warning {{nil passed to a callee that 
requires a non-null 1st parameter}}
+}
+
+void testImplicitCastNullableArgToNonnull(TestObject *_Nullable obj) {
+  if (!obj) {
+takesNonnullObject(obj); // expected-warning {{nil passed to a callee that 
requires a non-null 1st parameter}}
+  }
+}
+
 void testIndirectCastNilToNonnullAndPass() {
   Dummy *p = (Dummy * _Nonnull)0;
   // FIXME: Ideally the cast above would suppress this warning.
Index: clang/test/Analysis/nullability-arc.mm
===
--- clang/test/Analysis/nullability-arc.mm
+++ clang/test/Analysis/nullability-arc.mm
@@ -3,9 +3,6 @@
 // RUN: %clang_analyze_cc1 -w -analyzer-checker=core,nullability\
 // RUN:   -analyzer-output=text -verify %s -fobjc-arc
 
-#if !__has_feature(objc_arc)
-// expected-no-diagnostics
-#endif
 
 
 #define nil ((id)0)
@@ -24,16 +21,10 @@
 - (void)foo:(Param *)param {
   // FIXME: Why do we not emit the warning under ARC?
   [super foo:param];
-#if __has_feature(objc_arc)
-  // expected-warning@-2{{nil passed to a callee that requires a non-null 1st 
parameter}}
-  // expected-note@-3   {{nil passed to a callee that requires a non-null 1st 
parameter}}
-#endif
 
   [self foo:nil];
-#if __has_feature(objc_arc)
-  // expected-note@-2{{Calling 'foo:'}}
-  // expected-note@-3{{Passing nil object reference via 1st parameter 'param'}}
-#endif
+  // expected-warning@-1{{nil passed to a callee that requires a non-null 1st 
parameter}}
+  // expected-note@-2   {{nil passed to a callee that requires a non-null 1st 
parameter}}
 }
 @end
 
Index: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -798,7 +798,7 @@
 Nullability RequiredNullability =
 getNullabilityAnnotation(Param->getType());
 Nullability ArgExprTypeLevelNullability =
-getNullabilityAnnotation(ArgExpr->getType());
+getNullabilityAnnotation(lookThroughImplicitCasts(ArgExpr)->getType());
 
 unsigned ParamIdx = Param->getFunctionScopeIndex() + 1;
 


Index: clang/test/Analysis/nullability.mm
===
--- clang/test/Analysis/nullability.mm
+++ clang/test/Analysis/nullability.mm
@@ -69,6 +69,7 @@
 void takesNonnull(Dummy *_Nonnull);
 void takesUnspecified(Dummy *);
 void takesNonnullBlock(void (^ _Nonnull)(void));
+void takesNonnullObject(NSObject *_Nonnull);
 
 Dummy *_Nullable returnsNullable();
 Dummy *_Nonnull returnsNonnull();
@@ -275,6 +276,17 @@
   return (Dummy * _Nonnull)0; // no-warning
 }
 
+void testImplicitCastNilToNonnull() {
+  id obj = nil;
+  takesNonnullObject(obj); // expected-warning {{nil passed to a callee that requires a non-null 1st parameter}}
+}
+
+void testImplicitCastNullableArgToNonnull(TestObject *_Nullable obj) {
+  if (!obj) {
+takesNonnullObject(obj); // expected-warning {{nil passed to a callee that requires a non-null 1st parameter}}
+  }
+}
+
 void testIndirectCastNilToNonnullAndPass() {
   Dummy *p = (Dummy * _Nonnull)0;
   // FIXME: Ideally the cast above would suppress this warning.
Index: clang/test/Analysis/nullability-arc.mm
===
--- clang/test/Analysis/nullability-arc.mm
+++ clang/test/Analysis/nullability-arc.mm
@@ -3,9 +3,6 @@
 // RUN: %clang_analyze_cc1 -w -analyzer-checker=core,nullability\
 // RUN:   -analyzer-output=text -verify %s -fobjc-arc
 
-#if !__has_feature(objc_arc)
-// expected-no-diagnostics
-#endif
 
 
 #define nil ((id)0)
@@ -24,16 +21,10 @@
 - (void)foo:(Param *)param {
   // FIXME: 

[clang] a8a6a49 - [RISCV] Use 'long' in sha512 builtin tests. NFC

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

Author: Craig Topper
Date: 2023-07-06T07:37:19-07:00
New Revision: a8a6a4947439766355fb7e3dd81947d7f54f687a

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

LOG: [RISCV] Use 'long' in sha512 builtin tests. NFC

This matches the data type of the intrinsics. This case be seen
from the removal of sext and trunc instructions from the IR.

Reviewed By: asb

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

Added: 


Modified: 
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c

Removed: 




diff  --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c 
b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
index d04e09fea075a6..46cbe1867b440d 100644
--- a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
@@ -5,60 +5,52 @@
 
 // RV64ZKNH-LABEL: @sha512sig0(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig0(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig0(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sig0(int rs1) {
+long sha512sig0(long rs1) {
   return __builtin_riscv_sha512sig0_64(rs1);
 }
 
 
 // RV64ZKNH-LABEL: @sha512sig1(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig1(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig1(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sig1(int rs1) {
+long sha512sig1(long rs1) {
   return __builtin_riscv_sha512sig1_64(rs1);
 }
 
 
 // RV64ZKNH-LABEL: @sha512sum0(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum0(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum0(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sum0(int rs1) {
+long sha512sum0(long rs1) {
   return __builtin_riscv_sha512sum0_64(rs1);
 }
 
 
 // RV64ZKNH-LABEL: @sha512sum1(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum1(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum1(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sum1(int rs1) {
+long sha512sum1(long rs1) {
   return __builtin_riscv_sha512sum1_64(rs1);
 }
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.ll

[PATCH] D154577: [RISCV] Use 'long' in sha512 builtin tests. NFC

2023-07-06 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 rGa8a6a4947439: [RISCV] Use 'long' in sha512 builtin 
tests. NFC (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154577

Files:
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c


Index: clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
===
--- clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
+++ clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
@@ -5,60 +5,52 @@
 
 // RV64ZKNH-LABEL: @sha512sig0(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig0(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig0(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sig0(int rs1) {
+long sha512sig0(long rs1) {
   return __builtin_riscv_sha512sig0_64(rs1);
 }
 
 
 // RV64ZKNH-LABEL: @sha512sig1(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig1(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig1(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sig1(int rs1) {
+long sha512sig1(long rs1) {
   return __builtin_riscv_sha512sig1_64(rs1);
 }
 
 
 // RV64ZKNH-LABEL: @sha512sum0(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum0(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum0(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sum0(int rs1) {
+long sha512sum0(long rs1) {
   return __builtin_riscv_sha512sum0_64(rs1);
 }
 
 
 // RV64ZKNH-LABEL: @sha512sum1(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
-// RV64ZKNH-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum1(i64 
[[CONV]])
-// RV64ZKNH-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
-// RV64ZKNH-NEXT:ret i32 [[CONV1]]
+// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP0:%.*]] = load i64, ptr [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum1(i64 
[[TMP0]])
+// RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-int sha512sum1(int rs1) {
+long sha512sum1(long rs1) {
   return __builtin_riscv_sha512sum1_64(rs1);
 }
 


Index: clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
===
--- clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
+++ clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
@@ -5,60 +5,52 @@
 
 // RV64ZKNH-LABEL: @sha512sig0(
 // RV64ZKNH-NEXT:  entry:
-// RV64ZKNH-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
-// RV64ZKNH-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4

[PATCH] D154503: [Sema] Fix handling of functions that hide classes

2023-07-06 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 537721.
john.brawn added a comment.

Avoid doing work when we don't have both decls that can hide and decls that can 
be hidden.


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

https://reviews.llvm.org/D154503

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaCXX/using-hiding.cpp

Index: clang/test/SemaCXX/using-hiding.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-hiding.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+  class X { }; // expected-note{{candidate found by name lookup is 'A::X'}}
+}
+namespace B {
+  void X(int); // expected-note{{candidate found by name lookup is 'B::X'}}
+}
+
+// Using directive doesn't cause A::X to be hidden, so X is ambiguous.
+namespace Test1 {
+  using namespace A;
+  using namespace B;
+
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
+
+// Using declaration causes A::X to be hidden, so X is not ambiguous.
+namespace Test2 {
+  using A::X;
+  using B::X;
+
+  void f() {
+X(1);
+  }
+}
+
+// Behaviour here should be the same as including A and B directly.
+namespace Test3 {
+  namespace C {
+using A::X; // expected-note{{candidate found by name lookup is 'Test3::C::X'}}
+  }
+  namespace D {
+using B::X; // expected-note{{candidate found by name lookup is 'Test3::D::X'}}
+  }
+  using namespace C;
+  using namespace D;
+
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
+
+// using B::X inside C should hide using A::X in C but not D, so the result is ambiguous.
+namespace Test4 {
+  namespace C {
+using A::X;
+using B::X; // expected-note{{candidate found by name lookup is 'Test4::C::X'}}
+  }
+  namespace D {
+using A::X; // expected-note{{candidate found by name lookup is 'Test4::D::X'}}
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
+
+// A::X hidden in both C and D, so the result is not ambiguous.
+namespace Test5 {
+  namespace C {
+using A::X;
+using B::X;
+  }
+  namespace D {
+using A::X;
+using B::X;
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1);
+  }
+}
+
+// D declares a different class X, but it's hidden so the result is not ambiguous.
+namespace Test6 {
+  namespace C {
+using A::X;
+using B::X;
+  }
+  namespace D {
+class X { };
+using B::X;
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1);
+  }
+}
+
+// X inside C should hide X in C but not D.
+namespace Test7 {
+  namespace C {
+class X;
+void X(int); // expected-note{{candidate found by name lookup is 'Test7::C::X'}}
+  }
+  namespace D {
+class X; // expected-note{{candidate found by name lookup is 'Test7::D::X'}}
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -504,6 +504,45 @@
   // Don't do any extra resolution if we've already resolved as ambiguous.
   if (ResultKind == Ambiguous) return;
 
+  // C++ [basic.scope.hiding]p2:
+  //   A class name or enumeration name can be hidden by the name of
+  //   an object, function, or enumerator declared in the same
+  //   scope. If a class or enumeration name and an object, function,
+  //   or enumerator are declared in the same scope (in any order)
+  //   with the same name, the class or enumeration name is hidden
+  //   wherever the object, function, or enumerator name is visible.
+  if (HideTags) {
+// First collect all decls that can hide others and those that can be hidden
+std::set CanHideOther, CanBeHidden;
+for (unsigned I = 0; I < N; ++I) {
+  const NamedDecl *D = Decls[I]->getUnderlyingDecl();
+  D = cast(D->getCanonicalDecl());
+  if (isa(D))
+CanBeHidden.insert(I);
+  else if (canHideTag(D))
+CanHideOther.insert(I);
+}
+
+if (!CanBeHidden.empty() && !CanHideOther.empty()) {
+  // Collect those decls that will be hidden
+  std::set> HiddenDecls;
+  for (unsigned HiddenI : CanBeHidden) {
+for (unsigned HiderI : CanHideOther) {
+  if (getContextForScopeMatching(Decls[HiderI])
+  ->Equals(getContextForScopeMatching(Decls[HiddenI]))) {
+HiddenDecls.insert(HiddenI);
+break;
+  }
+}
+  }
+
+  // Now erase those decls that were hidden
+  for (auto I : HiddenDecls)
+Decls.erase(I);
+  N = Decls.size();
+}
+  }
+
   llvm::SmallDenseMap Unique;
   llvm::SmallDenseMap UniqueTypes;
 
@@ -514,8 +553,6 @@
 
   llvm::SmallVector EquivalentNonFunctions;
 
-  unsigned UniqueTagIndex = 0;
-
   unsigned I =

[PATCH] D154382: [ClangRepl] support code completion at a REPL

2023-07-06 Thread Fred Fu via Phabricator via cfe-commits
capfredf added inline comments.



Comment at: clang/lib/Interpreter/CodeCompletion.cpp:84
+  std::string AllCodeText =
+  MainInterp.getAllInput() + "\nvoid dummy(){\n" + Buffer.str() + "}";
+  auto Lines = std::count(AllCodeText.begin(), AllCodeText.end(), '\n') + 1;

v.g.vassilev wrote:
> I am not sure why we need to wrap this code. Can we teach the 
> `TopLevelStmtDecl` to work with the code completion logic?
I think the problem has less to do with the TopLevelStmtDecl. Usually, a 
`TopLevelStmtDecl` instance is a successful result from `ParseX`,  but when 
`CodeCompletion` is triggered during parsing, nothing meaning comes out from 
`Parse`.  

We need to wrap our input because we need `Sema::CodeCompleteOrdinaryName` to 
work on code from the REPL in a different completion context than the same code 
from a regular source file.

In a regular C++ file, 

```
int foo = 42;
f_
```

Since top-level expressions are not supported, `foo` should not be an option. 

But in a REPL session,

```
clang-repl> int foo = 42;
clang-repl> f_
```

we are allowed to use `foo` to make a statement like `foo + 84;`.

Since the argument for `CompletionContext` to `CodeCompleteOrdinaryName` is 
controlled by the parsing process, ie. there is no way to configure it from 
outside, I think faking context is a straightforward solution. 

Alternatively, we can check if the compiler is in incremental mode and call 
`CodeCompleteOrdinaryName` with the context we want in parsing. Something like:

```
if (PP.isIncrementalProcessingEnabled() {
  Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Statement);
} else {
  Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Namespace);
}
```

I personally think both solutions are extensionally equivalent, but the 
alternative is a bit intrusive. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

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


[clang] b22a5d4 - [analyzer] Fix false negative when pass implicit cast nil to nonnull

2023-07-06 Thread via cfe-commits

Author: songruiwang
Date: 2023-07-06T22:36:51+08:00
New Revision: b22a5d46179b0ec2d5350c078dc349f09177b9ed

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

LOG: [analyzer] Fix false negative when pass implicit cast nil to nonnull

We should look through implicit casts before determining the type of the 
arguments, and only allow explicit cast to _Nonnull to suppress warning

```
void foo(NSString *_Nonnull);

foo((NSString * _Nonnull)nil); // no-warning
id obj = nil;
foo(obj); // should warning here (implicit cast id to NSString *_Nonnull)

```

Reviewed By: xazax.hun, steakhal

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
clang/test/Analysis/nullability-arc.mm
clang/test/Analysis/nullability.mm

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
index 653a235b41a4fc..906f4e85a8e5b5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -798,7 +798,7 @@ void NullabilityChecker::checkPreCall(const CallEvent &Call,
 Nullability RequiredNullability =
 getNullabilityAnnotation(Param->getType());
 Nullability ArgExprTypeLevelNullability =
-getNullabilityAnnotation(ArgExpr->getType());
+getNullabilityAnnotation(lookThroughImplicitCasts(ArgExpr)->getType());
 
 unsigned ParamIdx = Param->getFunctionScopeIndex() + 1;
 

diff  --git a/clang/test/Analysis/nullability-arc.mm 
b/clang/test/Analysis/nullability-arc.mm
index 5c68dda42ed3ca..a149671bdb7300 100644
--- a/clang/test/Analysis/nullability-arc.mm
+++ b/clang/test/Analysis/nullability-arc.mm
@@ -3,9 +3,6 @@
 // RUN: %clang_analyze_cc1 -w -analyzer-checker=core,nullability\
 // RUN:   -analyzer-output=text -verify %s -fobjc-arc
 
-#if !__has_feature(objc_arc)
-// expected-no-diagnostics
-#endif
 
 
 #define nil ((id)0)
@@ -24,16 +21,10 @@ @implementation Derived
 - (void)foo:(Param *)param {
   // FIXME: Why do we not emit the warning under ARC?
   [super foo:param];
-#if __has_feature(objc_arc)
-  // expected-warning@-2{{nil passed to a callee that requires a non-null 1st 
parameter}}
-  // expected-note@-3   {{nil passed to a callee that requires a non-null 1st 
parameter}}
-#endif
 
   [self foo:nil];
-#if __has_feature(objc_arc)
-  // expected-note@-2{{Calling 'foo:'}}
-  // expected-note@-3{{Passing nil object reference via 1st parameter 'param'}}
-#endif
+  // expected-warning@-1{{nil passed to a callee that requires a non-null 1st 
parameter}}
+  // expected-note@-2   {{nil passed to a callee that requires a non-null 1st 
parameter}}
 }
 @end
 

diff  --git a/clang/test/Analysis/nullability.mm 
b/clang/test/Analysis/nullability.mm
index 5a702f86564a61..06bb9912296e32 100644
--- a/clang/test/Analysis/nullability.mm
+++ b/clang/test/Analysis/nullability.mm
@@ -69,6 +69,7 @@ - (void)takesUnspecified:(int *)p;
 void takesNonnull(Dummy *_Nonnull);
 void takesUnspecified(Dummy *);
 void takesNonnullBlock(void (^ _Nonnull)(void));
+void takesNonnullObject(NSObject *_Nonnull);
 
 Dummy *_Nullable returnsNullable();
 Dummy *_Nonnull returnsNonnull();
@@ -275,6 +276,17 @@ void testObjCPropertyReadNullability() {
   return (Dummy * _Nonnull)0; // no-warning
 }
 
+void testImplicitCastNilToNonnull() {
+  id obj = nil;
+  takesNonnullObject(obj); // expected-warning {{nil passed to a callee that 
requires a non-null 1st parameter}}
+}
+
+void testImplicitCastNullableArgToNonnull(TestObject *_Nullable obj) {
+  if (!obj) {
+takesNonnullObject(obj); // expected-warning {{nil passed to a callee that 
requires a non-null 1st parameter}}
+  }
+}
+
 void testIndirectCastNilToNonnullAndPass() {
   Dummy *p = (Dummy * _Nonnull)0;
   // FIXME: Ideally the cast above would suppress this warning.



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


[PATCH] D154493: [X86] Support some Intel CPUs for cpu_specific/dispatch feature

2023-07-06 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: llvm/lib/TargetParser/X86TargetParser.cpp:333
   { {"pentium"}, CK_Pentium, ~0U, FeatureX87 | FeatureCMPXCHG8B, 'B', false },
   { {"pentium-mmx"}, CK_PentiumMMX, ~0U, FeaturesPentiumMMX, '\0', false },
   { {"pentium_mmx"}, CK_PentiumMMX, ~0U, FeaturesPentiumMMX, 'D', true },

FreddyYe wrote:
> RKSimon wrote:
> > add this as well?
> cpu names contain '-' are not supported for cpu_specific/dispatch feature 
> since '-' is not an identifier character. The solution here is creating a new 
> name with '_' replacing and set the OnlyForCPUDispatchSpecific as `true`, 
> like `icelake-client`, `icelake-server` and `goldmont-plus`
Understood - cheers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154493

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


[PATCH] D154503: [Sema] Fix handling of functions that hide classes

2023-07-06 Thread John Brawn via Phabricator via cfe-commits
john.brawn added inline comments.



Comment at: clang/lib/Sema/SemaLookup.cpp:542
+N = Decls.size();
+  }
+

rjmccall wrote:
> This is going to fire on every single ordinary lookup that finds multiple 
> declarations, right?  I haven't fully internalized the issue you're solving 
> here, but this is a very performance-sensitive path in the compiler; there's 
> a reason this code is written to very carefully only do extra work when we've 
> detected in the loop below that we're in a hidden-declarations situation.  Is 
> there any way we can restore that basic structure?
Test4 in the added tests is an example of why we can't wait until after the 
main loop. The `using A::X` in namespace D is eliminated by the UniqueResult 
check, so the check for a declaration being hidden can only see the using 
declarations in namespace C. We also can't do it in the loop itself, as then we 
can't handle Test5: at the time we process the `using A::X` in namespace D it 
looks like it may cause ambiguity, but it's later hidden by the `using B::X` in 
the same namespace which we haven't yet processed.

I have adjusted it though so the nested loop and erasing of decls only happens 
when we both have things that hide and things that can be hidden. Doing some 
quick testing of compiling SemaOpenMP.cpp (the largest file in clang), 
LookupResult::resolveKind is called 75318 times, of which 75283 calls have 
HideTags=true, of which 56 meet this condition, i.e. 0.07%.


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

https://reviews.llvm.org/D154503

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


[PATCH] D154503: [Sema] Fix handling of functions that hide classes

2023-07-06 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 537731.
john.brawn added a comment.

Same patch as previous, but with full context.


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

https://reviews.llvm.org/D154503

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaCXX/using-hiding.cpp

Index: clang/test/SemaCXX/using-hiding.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-hiding.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+  class X { }; // expected-note{{candidate found by name lookup is 'A::X'}}
+}
+namespace B {
+  void X(int); // expected-note{{candidate found by name lookup is 'B::X'}}
+}
+
+// Using directive doesn't cause A::X to be hidden, so X is ambiguous.
+namespace Test1 {
+  using namespace A;
+  using namespace B;
+
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
+
+// Using declaration causes A::X to be hidden, so X is not ambiguous.
+namespace Test2 {
+  using A::X;
+  using B::X;
+
+  void f() {
+X(1);
+  }
+}
+
+// Behaviour here should be the same as including A and B directly.
+namespace Test3 {
+  namespace C {
+using A::X; // expected-note{{candidate found by name lookup is 'Test3::C::X'}}
+  }
+  namespace D {
+using B::X; // expected-note{{candidate found by name lookup is 'Test3::D::X'}}
+  }
+  using namespace C;
+  using namespace D;
+
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
+
+// using B::X inside C should hide using A::X in C but not D, so the result is ambiguous.
+namespace Test4 {
+  namespace C {
+using A::X;
+using B::X; // expected-note{{candidate found by name lookup is 'Test4::C::X'}}
+  }
+  namespace D {
+using A::X; // expected-note{{candidate found by name lookup is 'Test4::D::X'}}
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
+
+// A::X hidden in both C and D, so the result is not ambiguous.
+namespace Test5 {
+  namespace C {
+using A::X;
+using B::X;
+  }
+  namespace D {
+using A::X;
+using B::X;
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1);
+  }
+}
+
+// D declares a different class X, but it's hidden so the result is not ambiguous.
+namespace Test6 {
+  namespace C {
+using A::X;
+using B::X;
+  }
+  namespace D {
+class X { };
+using B::X;
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1);
+  }
+}
+
+// X inside C should hide X in C but not D.
+namespace Test7 {
+  namespace C {
+class X;
+void X(int); // expected-note{{candidate found by name lookup is 'Test7::C::X'}}
+  }
+  namespace D {
+class X; // expected-note{{candidate found by name lookup is 'Test7::D::X'}}
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -504,6 +504,45 @@
   // Don't do any extra resolution if we've already resolved as ambiguous.
   if (ResultKind == Ambiguous) return;
 
+  // C++ [basic.scope.hiding]p2:
+  //   A class name or enumeration name can be hidden by the name of
+  //   an object, function, or enumerator declared in the same
+  //   scope. If a class or enumeration name and an object, function,
+  //   or enumerator are declared in the same scope (in any order)
+  //   with the same name, the class or enumeration name is hidden
+  //   wherever the object, function, or enumerator name is visible.
+  if (HideTags) {
+// First collect all decls that can hide others and those that can be hidden
+std::set CanHideOther, CanBeHidden;
+for (unsigned I = 0; I < N; ++I) {
+  const NamedDecl *D = Decls[I]->getUnderlyingDecl();
+  D = cast(D->getCanonicalDecl());
+  if (isa(D))
+CanBeHidden.insert(I);
+  else if (canHideTag(D))
+CanHideOther.insert(I);
+}
+
+if (!CanBeHidden.empty() && !CanHideOther.empty()) {
+  // Collect those decls that will be hidden
+  std::set> HiddenDecls;
+  for (unsigned HiddenI : CanBeHidden) {
+for (unsigned HiderI : CanHideOther) {
+  if (getContextForScopeMatching(Decls[HiderI])
+  ->Equals(getContextForScopeMatching(Decls[HiddenI]))) {
+HiddenDecls.insert(HiddenI);
+break;
+  }
+}
+  }
+
+  // Now erase those decls that were hidden
+  for (auto I : HiddenDecls)
+Decls.erase(I);
+  N = Decls.size();
+}
+  }
+
   llvm::SmallDenseMap Unique;
   llvm::SmallDenseMap UniqueTypes;
 
@@ -514,8 +553,6 @@
 
   llvm::SmallVector EquivalentNonFunctions;
 
-  unsigned UniqueTagIndex = 0;
-
   unsigned I = 0;
   while (I < N) {
 const NamedDecl *

[clang] 1db5b49 - [RISCV] Use ClangBuiltin in IntrinsicsRISCV.td to map some scalar crypto builtins to IR intrinsic.

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

Author: Craig Topper
Date: 2023-07-06T07:53:31-07:00
New Revision: 1db5b49ae62a7820378d8dfb2d8fd53e1774992d

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

LOG: [RISCV] Use ClangBuiltin in IntrinsicsRISCV.td to map some scalar crypto 
builtins to IR intrinsic.

This is the way most targets do it for a simple mapping.

We can't do this for all builtins due to type overloading of the IR intrinsics.

Reviewed By: asb

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c844aa7dfc5c38..3d451bd7d140f2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -20230,45 +20230,6 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 
   // Zk builtins
 
-  // Zknd
-  case RISCV::BI__builtin_riscv_aes32dsi_32:
-ID = Intrinsic::riscv_aes32dsi;
-break;
-  case RISCV::BI__builtin_riscv_aes32dsmi_32:
-ID = Intrinsic::riscv_aes32dsmi;
-break;
-  case RISCV::BI__builtin_riscv_aes64ds_64:
-ID = Intrinsic::riscv_aes64ds;
-break;
-  case RISCV::BI__builtin_riscv_aes64dsm_64:
-ID = Intrinsic::riscv_aes64dsm;
-break;
-  case RISCV::BI__builtin_riscv_aes64im_64:
-ID = Intrinsic::riscv_aes64im;
-break;
-
-  // Zkne
-  case RISCV::BI__builtin_riscv_aes32esi_32:
-ID = Intrinsic::riscv_aes32esi;
-break;
-  case RISCV::BI__builtin_riscv_aes32esmi_32:
-ID = Intrinsic::riscv_aes32esmi;
-break;
-  case RISCV::BI__builtin_riscv_aes64es_64:
-ID = Intrinsic::riscv_aes64es;
-break;
-  case RISCV::BI__builtin_riscv_aes64esm_64:
-ID = Intrinsic::riscv_aes64esm;
-break;
-
-  // Zknd & Zkne
-  case RISCV::BI__builtin_riscv_aes64ks1i_64:
-ID = Intrinsic::riscv_aes64ks1i;
-break;
-  case RISCV::BI__builtin_riscv_aes64ks2_64:
-ID = Intrinsic::riscv_aes64ks2;
-break;
-
   // Zknh
   case RISCV::BI__builtin_riscv_sha256sig0:
 ID = Intrinsic::riscv_sha256sig0;
@@ -20286,36 +20247,6 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 ID = Intrinsic::riscv_sha256sum1;
 IntrinsicTypes = {ResultType};
 break;
-  case RISCV::BI__builtin_riscv_sha512sig0_64:
-ID = Intrinsic::riscv_sha512sig0;
-break;
-  case RISCV::BI__builtin_riscv_sha512sig0h_32:
-ID = Intrinsic::riscv_sha512sig0h;
-break;
-  case RISCV::BI__builtin_riscv_sha512sig0l_32:
-ID = Intrinsic::riscv_sha512sig0l;
-break;
-  case RISCV::BI__builtin_riscv_sha512sig1_64:
-ID = Intrinsic::riscv_sha512sig1;
-break;
-  case RISCV::BI__builtin_riscv_sha512sig1h_32:
-ID = Intrinsic::riscv_sha512sig1h;
-break;
-  case RISCV::BI__builtin_riscv_sha512sig1l_32:
-ID = Intrinsic::riscv_sha512sig1l;
-break;
-  case RISCV::BI__builtin_riscv_sha512sum0_64:
-ID = Intrinsic::riscv_sha512sum0;
-break;
-  case RISCV::BI__builtin_riscv_sha512sum0r_32:
-ID = Intrinsic::riscv_sha512sum0r;
-break;
-  case RISCV::BI__builtin_riscv_sha512sum1_64:
-ID = Intrinsic::riscv_sha512sum1;
-break;
-  case RISCV::BI__builtin_riscv_sha512sum1r_32:
-ID = Intrinsic::riscv_sha512sum1r;
-break;
 
   // Zksed
   case RISCV::BI__builtin_riscv_sm4ks:

diff  --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td 
b/llvm/include/llvm/IR/IntrinsicsRISCV.td
index 8931d6f0901545..a9cd18dd91ce10 100644
--- a/llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ -1613,27 +1613,38 @@ class ScalarCryptoByteSelectAny
 [IntrNoMem, IntrSpeculatable, 
ImmArg>]>;
 
 // Zknd
-def int_riscv_aes32dsi  : ScalarCryptoByteSelect32;
-def int_riscv_aes32dsmi : ScalarCryptoByteSelect32;
+def int_riscv_aes32dsi  : ScalarCryptoByteSelect32,
+  ClangBuiltin<"__builtin_riscv_aes32dsi_32">;
+def int_riscv_aes32dsmi : ScalarCryptoByteSelect32,
+  ClangBuiltin<"__builtin_riscv_aes32dsmi_32">;
 
-def int_riscv_aes64ds   : ScalarCryptoGprGprIntrinsic64;
-def int_riscv_aes64dsm  : ScalarCryptoGprGprIntrinsic64;
+def int_riscv_aes64ds   : ScalarCryptoGprGprIntrinsic64,
+  ClangBuiltin<"__builtin_riscv_aes64ds_64">;
+def int_riscv_aes64dsm  : ScalarCryptoGprGprIntrinsic64,
+  ClangBuiltin<"__builtin_riscv_aes64dsm_64">;
 
-def int_riscv_aes64im   : ScalarCryptoGprIntrinsic64;
+def int_riscv_aes64im   : ScalarCryptoGprIntrinsic64,
+  ClangBuiltin<"__builtin_riscv_aes64im_64">;
 
 // Zkne
-def int_riscv_aes32esi  : ScalarCryptoByteSelect32;
-def int_riscv_aes32esmi : ScalarCryptoByteSelect32;
+def int_riscv_aes32esi  : ScalarCryp

[PATCH] D154567: [RISCV] Use ClangBuiltin in IntrinsicsRISCV.td to map some scalar crypto builtins to IR intrinsic.

2023-07-06 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 rG1db5b49ae62a: [RISCV] Use ClangBuiltin in IntrinsicsRISCV.td 
to map some scalar crypto… (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154567

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td

Index: llvm/include/llvm/IR/IntrinsicsRISCV.td
===
--- llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ -1613,27 +1613,38 @@
 [IntrNoMem, IntrSpeculatable, ImmArg>]>;
 
 // Zknd
-def int_riscv_aes32dsi  : ScalarCryptoByteSelect32;
-def int_riscv_aes32dsmi : ScalarCryptoByteSelect32;
+def int_riscv_aes32dsi  : ScalarCryptoByteSelect32,
+  ClangBuiltin<"__builtin_riscv_aes32dsi_32">;
+def int_riscv_aes32dsmi : ScalarCryptoByteSelect32,
+  ClangBuiltin<"__builtin_riscv_aes32dsmi_32">;
 
-def int_riscv_aes64ds   : ScalarCryptoGprGprIntrinsic64;
-def int_riscv_aes64dsm  : ScalarCryptoGprGprIntrinsic64;
+def int_riscv_aes64ds   : ScalarCryptoGprGprIntrinsic64,
+  ClangBuiltin<"__builtin_riscv_aes64ds_64">;
+def int_riscv_aes64dsm  : ScalarCryptoGprGprIntrinsic64,
+  ClangBuiltin<"__builtin_riscv_aes64dsm_64">;
 
-def int_riscv_aes64im   : ScalarCryptoGprIntrinsic64;
+def int_riscv_aes64im   : ScalarCryptoGprIntrinsic64,
+  ClangBuiltin<"__builtin_riscv_aes64im_64">;
 
 // Zkne
-def int_riscv_aes32esi  : ScalarCryptoByteSelect32;
-def int_riscv_aes32esmi : ScalarCryptoByteSelect32;
+def int_riscv_aes32esi  : ScalarCryptoByteSelect32,
+  ClangBuiltin<"__builtin_riscv_aes32esi_32">;
+def int_riscv_aes32esmi : ScalarCryptoByteSelect32,
+  ClangBuiltin<"__builtin_riscv_aes32esmi_32">;
 
-def int_riscv_aes64es   : ScalarCryptoGprGprIntrinsic64;
-def int_riscv_aes64esm  : ScalarCryptoGprGprIntrinsic64;
+def int_riscv_aes64es   : ScalarCryptoGprGprIntrinsic64,
+  ClangBuiltin<"__builtin_riscv_aes64es_64">;
+def int_riscv_aes64esm  : ScalarCryptoGprGprIntrinsic64,
+  ClangBuiltin<"__builtin_riscv_aes64esm_64">;
 
 // Zknd & Zkne
-def int_riscv_aes64ks2  : ScalarCryptoGprGprIntrinsic64;
+def int_riscv_aes64ks2  : ScalarCryptoGprGprIntrinsic64,
+  ClangBuiltin<"__builtin_riscv_aes64ks2_64">;
 def int_riscv_aes64ks1i : DefaultAttrsIntrinsic<[llvm_i64_ty],
 [llvm_i64_ty, llvm_i32_ty],
 [IntrNoMem, IntrSpeculatable,
- ImmArg>]>;
+ ImmArg>]>,
+  ClangBuiltin<"__builtin_riscv_aes64ks1i_64">;
 
 // Zknh
 def int_riscv_sha256sig0 : ScalarCryptoGprIntrinsicAny;
@@ -1641,17 +1652,27 @@
 def int_riscv_sha256sum0 : ScalarCryptoGprIntrinsicAny;
 def int_riscv_sha256sum1 : ScalarCryptoGprIntrinsicAny;
 
-def int_riscv_sha512sig0l : ScalarCryptoGprGprIntrinsic32;
-def int_riscv_sha512sig0h : ScalarCryptoGprGprIntrinsic32;
-def int_riscv_sha512sig1l : ScalarCryptoGprGprIntrinsic32;
-def int_riscv_sha512sig1h : ScalarCryptoGprGprIntrinsic32;
-def int_riscv_sha512sum0r : ScalarCryptoGprGprIntrinsic32;
-def int_riscv_sha512sum1r : ScalarCryptoGprGprIntrinsic32;
-
-def int_riscv_sha512sig0 : ScalarCryptoGprIntrinsic64;
-def int_riscv_sha512sig1 : ScalarCryptoGprIntrinsic64;
-def int_riscv_sha512sum0 : ScalarCryptoGprIntrinsic64;
-def int_riscv_sha512sum1 : ScalarCryptoGprIntrinsic64;
+def int_riscv_sha512sig0l : ScalarCryptoGprGprIntrinsic32,
+ClangBuiltin<"__builtin_riscv_sha512sig0l_32">;
+def int_riscv_sha512sig0h : ScalarCryptoGprGprIntrinsic32,
+ClangBuiltin<"__builtin_riscv_sha512sig0h_32">;
+def int_riscv_sha512sig1l : ScalarCryptoGprGprIntrinsic32,
+ClangBuiltin<"__builtin_riscv_sha512sig1l_32">;
+def int_riscv_sha512sig1h : ScalarCryptoGprGprIntrinsic32,
+ClangBuiltin<"__builtin_riscv_sha512sig1h_32">;
+def int_riscv_sha512sum0r : ScalarCryptoGprGprIntrinsic32,
+ClangBuiltin<"__builtin_riscv_sha512sum0r_32">;
+def int_riscv_sha512sum1r : ScalarCryptoGprGprIntrinsic32,
+ClangBuiltin<"__builtin_riscv_sha512sum1r_32">;
+
+def int_riscv_sha512sig0 : ScalarCryptoGprIntrinsic64,
+   ClangBuiltin<"__builtin_riscv_sha512sig0_64">;
+def int_riscv_sha512sig1 : ScalarCryptoGprIntrinsic64,
+   ClangBuiltin<"__builtin_riscv_sha512sig1_64">;
+def int_riscv_sha512sum0 : ScalarCry

[clang] 1388887 - Enable dynamic-sized VLAs for data sharing in OpenMP offloaded target regions.

2023-07-06 Thread Doru Bercea via cfe-commits

Author: Doru Bercea
Date: 2023-07-06T10:57:10-04:00
New Revision: 1370e568dea84c4ea65fe5c01ef4f4ccc751

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

LOG: Enable dynamic-sized VLAs for data sharing in OpenMP offloaded target 
regions.

Review: https://reviews.llvm.org/D153883

Added: 
clang/test/OpenMP/amdgcn_target_device_vla.cpp

Modified: 
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index e143687479ee3e..f19006f7b291e5 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -581,6 +581,16 @@ namespace {
 }
   };
 
+  struct KmpcAllocFree final : EHScopeStack::Cleanup {
+std::pair AddrSizePair;
+KmpcAllocFree(const std::pair &AddrSizePair)
+: AddrSizePair(AddrSizePair) {}
+void Emit(CodeGenFunction &CGF, Flags EmissionFlags) override {
+  auto &RT = CGF.CGM.getOpenMPRuntime();
+  RT.getKmpcFreeShared(CGF, AddrSizePair);
+}
+  };
+
   struct ExtendGCLifetime final : EHScopeStack::Cleanup {
 const VarDecl &Var;
 ExtendGCLifetime(const VarDecl *var) : Var(*var) {}
@@ -1583,28 +1593,59 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
   } else {
 EnsureInsertPoint();
 
-if (!DidCallStackSave) {
-  // Save the stack.
-  Address Stack =
-CreateTempAlloca(Int8PtrTy, getPointerAlign(), "saved_stack");
+// Delayed globalization for variable length declarations. This ensures 
that
+// the expression representing the length has been emitted and can be used
+// by the definition of the VLA. Since this is an escaped declaration, in
+// OpenMP we have to use a call to __kmpc_alloc_shared(). The matching
+// deallocation call to __kmpc_free_shared() is emitted later.
+bool VarAllocated = false;
+if (getLangOpts().OpenMPIsDevice) {
+  auto &RT = CGM.getOpenMPRuntime();
+  if (RT.isDelayedVariableLengthDecl(*this, &D)) {
+// Emit call to __kmpc_alloc_shared() instead of the alloca.
+std::pair AddrSizePair =
+RT.getKmpcAllocShared(*this, &D);
+
+// Save the address of the allocation:
+LValue Base = MakeAddrLValue(AddrSizePair.first, D.getType(),
+ CGM.getContext().getDeclAlign(&D),
+ AlignmentSource::Decl);
+address = Base.getAddress(*this);
+
+// Push a cleanup block to emit the call to __kmpc_free_shared in the
+// appropriate location at the end of the scope of the
+// __kmpc_alloc_shared functions:
+pushKmpcAllocFree(NormalCleanup, AddrSizePair);
+
+// Mark variable as allocated:
+VarAllocated = true;
+  }
+}
 
-  llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::stacksave);
-  llvm::Value *V = Builder.CreateCall(F);
-  Builder.CreateStore(V, Stack);
+if (!VarAllocated) {
+  if (!DidCallStackSave) {
+// Save the stack.
+Address Stack =
+CreateTempAlloca(Int8PtrTy, getPointerAlign(), "saved_stack");
 
-  DidCallStackSave = true;
+llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::stacksave);
+llvm::Value *V = Builder.CreateCall(F);
+Builder.CreateStore(V, Stack);
 
-  // Push a cleanup block and restore the stack there.
-  // FIXME: in general circumstances, this should be an EH cleanup.
-  pushStackRestore(NormalCleanup, Stack);
-}
+DidCallStackSave = true;
 
-auto VlaSize = getVLASize(Ty);
-llvm::Type *llvmTy = ConvertTypeForMem(VlaSize.Type);
+// Push a cleanup block and restore the stack there.
+// FIXME: in general circumstances, this should be an EH cleanup.
+pushStackRestore(NormalCleanup, Stack);
+  }
+
+  auto VlaSize = getVLASize(Ty);
+  llvm::Type *llvmTy = ConvertTypeForMem(VlaSize.Type);
 
-// Allocate memory for the array.
-address = CreateTempAlloca(llvmTy, alignment, "vla", VlaSize.NumElts,
-   &AllocaAddr);
+  // Allocate memory for the array.
+  address = CreateTempAlloca(llvmTy, alignment, "vla", VlaSize.NumElts,
+ &AllocaAddr);
+}
 
 // If we have debug info enabled, properly describe the VLA dimensions for
 // this type by registering the vla size expression for each of the
@@ -2141,6 +2182,11 @@ void CodeGenFunction::pushStackRestore(CleanupKind Kind, 
Address SPMem) {
   EHStack.pushCleanup(Kind, SPMem);
 }
 
+void CodeGenFunction::pushKmpcAllocFree(
+CleanupKind Kind, std::

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

2023-07-06 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 closed this revision.
doru1004 added a comment.

Commit: 1370e568dea84c4ea65fe5c01ef4f4ccc751 



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] D86993: Document Clang's expectations of the C standard library.

2023-07-06 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D86993#4477080 , @aaron.ballman 
wrote:

> In D86993#4474682 , @nikic wrote:
>
>>> I continue to think it's a mistake for us to document that Clang will not 
>>> work with a conforming C standard library implementation unless we're 
>>> filing issues with WG14 to alert them to the reasons why. If there's a DR 
>>> filed with the committee, that gives us something to point our users to as 
>>> justification. Otherwise, our users will correctly put these bugs at our 
>>> feet.
>>
>> As you are involved with WG14, can you please take care of that? I couldn't 
>> even find out how one is supposed to file a DR.
>
> I'm happy to help with it, but I'll need some outside help as well so I get 
> the technical details and justifications correct and can defend them when 
> presenting to the committee. If someone could put together a super rough 
> draft of what changes we'd like to see and why, I can definitely work with 
> them to polish it into a final document, get it to the committee, and 
> champion it there. Related question though: what do we do if the committee 
> rejects the DR? I think LLVM and Clang have slightly different pressures 
> here, so we might have different answers.
>
> FWIW, you can find more info here about how to communicate with WG14: 
> https://www.open-std.org/jtc1/sc22/wg14/www/contributing

Thank you! I will prepare an initial draft and share it here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86993

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


[PATCH] D154616: [RISCV] Use unsigned instead of signed types for Zk* and Zb* builtins.

2023-07-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: asb, VincentWu, kito-cheng.
Herald added subscribers: jobnoorman, luke, 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, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, eopXD, MaskRay.
Herald added a project: clang.

Unsigned is a better representation for bitmanipulation and cryptography.w

The only exception being the return values for clz and ctz intrinsics is
a signed int. That matches the target independent clz and ctz builtins.

This is consistent with the current scalar crypto proposal
https://github.com/riscv-non-isa/riscv-c-api-doc/pull/44


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154616

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-xtheadbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknd.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zkne.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksed.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksed.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksh.c

Index: clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksh.c
===
--- clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksh.c
+++ clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksh.c
@@ -10,7 +10,7 @@
 // RV64ZKSH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sm3p0.i64(i64 [[TMP0]])
 // RV64ZKSH-NEXT:ret i64 [[TMP1]]
 //
-long sm3p0(long rs1) {
+unsigned long sm3p0(unsigned long rs1) {
   return __builtin_riscv_sm3p0(rs1);
 }
 
@@ -23,6 +23,6 @@
 // RV64ZKSH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sm3p1.i64(i64 [[TMP0]])
 // RV64ZKSH-NEXT:ret i64 [[TMP1]]
 //
-long sm3p1(long rs1) {
+unsigned long sm3p1(unsigned long rs1) {
   return __builtin_riscv_sm3p1(rs1);
 }
Index: clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksed.c
===
--- clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksed.c
+++ clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksed.c
@@ -13,7 +13,7 @@
 // RV64ZKSED-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.sm4ks.i64(i64 [[TMP0]], i64 [[TMP1]], i32 0)
 // RV64ZKSED-NEXT:ret i64 [[TMP2]]
 //
-long sm4ks(long rs1, long rs2) {
+unsigned long sm4ks(unsigned long rs1, unsigned long rs2) {
   return __builtin_riscv_sm4ks(rs1, rs2, 0);
 }
 
@@ -28,6 +28,6 @@
 // RV64ZKSED-NEXT:[[TMP2:%.*]] = call i64 @llvm.riscv.sm4ed.i64(i64 [[TMP0]], i64 [[TMP1]], i32 0)
 // RV64ZKSED-NEXT:ret i64 [[TMP2]]
 //
-long sm4ed(long rs1, long rs2) {
+unsigned long sm4ed(unsigned long rs1, unsigned long rs2) {
   return __builtin_riscv_sm4ed(rs1, rs2, 0);
 }
Index: clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
===
--- clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
+++ clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
@@ -11,7 +11,7 @@
 // RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig0(i64 [[TMP0]])
 // RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-long sha512sig0(long rs1) {
+unsigned long sha512sig0(unsigned long rs1) {
   return __builtin_riscv_sha512sig0_64(rs1);
 }
 
@@ -24,7 +24,7 @@
 // RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig1(i64 [[TMP0]])
 // RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-long sha512sig1(long rs1) {
+unsigned long sha512sig1(unsigned long rs1) {
   return __builtin_riscv_sha512sig1_64(rs1);
 }
 
@@ -37,7 +37,7 @@
 // RV64ZKNH-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum0(i64 [[TMP0]])
 // RV64ZKNH-NEXT:ret i64 [[TMP1]]
 //
-long sha512sum0(long rs1) {
+unsigned long sha512sum0(unsigned long rs1) {
   return __builtin_riscv_sha512sum0_64(rs1);
 }
 
@@ -50,7 +50,7 @

[PATCH] D154495: clang: Attach !fpmath metadata to __builtin_sqrt based on language flags

2023-07-06 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 537737.
arsenm added a comment.

Split div/sqrt handling since they have different values. Also cuda does have 
unimplemented flags to control these individually. Not sure it's worth trying 
to merge them into one function


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

https://reviews.llvm.org/D154495

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCUDA/correctly-rounded-div.cu
  clang/test/CodeGenOpenCL/fpmath.cl

Index: clang/test/CodeGenOpenCL/fpmath.cl
===
--- clang/test/CodeGenOpenCL/fpmath.cl
+++ clang/test/CodeGenOpenCL/fpmath.cl
@@ -8,7 +8,7 @@
 float spscalardiv(float a, float b) {
   // CHECK: @spscalardiv
   // CHECK: fdiv{{.*}},
-  // NODIVOPT: !fpmath ![[MD:[0-9]+]]
+  // NODIVOPT: !fpmath ![[MD_FDIV:[0-9]+]]
   // DIVOPT-NOT: !fpmath !{{[0-9]+}}
   return a / b;
 }
@@ -16,11 +16,18 @@
 float4 spvectordiv(float4 a, float4 b) {
   // CHECK: @spvectordiv
   // CHECK: fdiv{{.*}},
-  // NODIVOPT: !fpmath ![[MD]]
+  // NODIVOPT: !fpmath ![[MD_FDIV]]
   // DIVOPT-NOT: !fpmath !{{[0-9]+}}
   return a / b;
 }
 
+float spscalarsqrt(float a) {
+  // CHECK-LABEL: @spscalarsqrt
+  // NODIVOPT: call float @llvm.sqrt.f32(float %{{.+}}), !fpmath ![[MD_SQRT:[0-9]+]]
+  // DIVOPT: call float @llvm.sqrt.f32(float %{{.+}}){{$}}
+  return __builtin_sqrtf(a);
+}
+
 #if __OPENCL_C_VERSION__ >=120
 void printf(constant char* fmt, ...);
 
@@ -34,11 +41,27 @@
 
 #ifndef NOFP64
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
+typedef __attribute__(( ext_vector_type(4) )) double double4;
+
 double dpscalardiv(double a, double b) {
   // CHECK: @dpscalardiv
   // CHECK-NOT: !fpmath
   return a / b;
 }
+
+double4 dpvectordiv(double4 a, double4 b) {
+  // CHECK: @dpvectordiv
+  // CHECK-NOT: !fpmath
+  return a / b;
+}
+
+double dpscalarsqrt(double a) {
+  // CHECK-LABEL: @dpscalarsqrt
+  // CHECK: call double @llvm.sqrt.f64(double %{{.+}}){{$}}
+  return __builtin_sqrt(a);
+}
+
 #endif
 
-// NODIVOPT: ![[MD]] = !{float 2.50e+00}
+// NODIVOPT: ![[MD_FDIV]] = !{float 2.50e+00}
+// NODIVOPT: ![[MD_SQRT]] = !{float 3.00e+00}
Index: clang/test/CodeGenCUDA/correctly-rounded-div.cu
===
--- clang/test/CodeGenCUDA/correctly-rounded-div.cu
+++ clang/test/CodeGenCUDA/correctly-rounded-div.cu
@@ -32,4 +32,18 @@
   return a / b;
 }
 
-// NCRDIV: ![[MD]] = !{float 2.50e+00}
+// COMMON-LABEL: @_Z12spscalarsqrt
+// NCRDIV: call contract float @llvm.sqrt.f32(float %{{.+}}), !fpmath ![[MD:[0-9]+]]
+// CRDIV: call contract float @llvm.sqrt.f32(float %{{.+}}){{$}}
+__device__ float spscalarsqrt(float a) {
+  return __builtin_sqrtf(a);
+}
+
+// COMMON-LABEL: @_Z12dpscalarsqrt
+// COMMON: call contract double @llvm.sqrt.f64(double %{{.+}}){{$}}
+// COMMON-NOT: !fpmath
+__device__ double dpscalarsqrt(double a) {
+  return __builtin_sqrt(a);
+}
+
+// NCRSQRT: ![[MD]] = !{float 2.50e+00}
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4704,6 +4704,14 @@
   /// point operation, expressed as the maximum relative error in ulp.
   void SetFPAccuracy(llvm::Value *Val, float Accuracy);
 
+  /// Set the minimum required accuracy of the given sqrt operation
+  /// based on CodeGenOpts.
+  void SetSqrtFPAccuracy(llvm::Value *Val);
+
+  /// Set the minimum required accuracy of the given sqrt operation based on
+  /// CodeGenOpts.
+  void SetDivFPAccuracy(llvm::Value *Val);
+
   /// Set the codegen fast-math flags.
   void SetFastMathFlags(FPOptions FPFeatures);
 
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -3478,21 +3478,7 @@
 llvm::Value *Val;
 CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, Ops.FPFeatures);
 Val = Builder.CreateFDiv(Ops.LHS, Ops.RHS, "div");
-if ((CGF.getLangOpts().OpenCL &&
- !CGF.CGM.getCodeGenOpts().OpenCLCorrectlyRoundedDivSqrt) ||
-(CGF.getLangOpts().HIP && CGF.getLangOpts().CUDAIsDevice &&
- !CGF.CGM.getCodeGenOpts().HIPCorrectlyRoundedDivSqrt)) {
-  // OpenCL v1.1 s7.4: minimum accuracy of single precision / is 2.5ulp
-  // OpenCL v1.2 s5.6.4.2: The -cl-fp32-correctly-rounded-divide-sqrt
-  // build option allows an application to specify that single precision
-  // floating-point divide (x/y and 1/x) and sqrt used in the program
-  // source are correctly rounded.
-  llvm::Type *ValTy = Val->getType();
-  if (ValTy->isFloatTy() ||
-  (isa(ValTy) &&
-   cast(ValTy)->getElementType()->isFloatTy()))
-CGF.SetFPAccuracy(Val, 2.5);
-   

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

2023-07-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

OK, let's go with this. It's a fairly alarming mess localised quite closely to 
the language that requires the complexity, minimal damage to libc itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154036

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


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

2023-07-06 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 537742.
cor3ntin added a comment.

Address Hubert's feedback

- Add code and tests to properly support member initializer
- Add code and tests to support designated initializers
- Correctly hamdle members of anonymous union
- Make placeholder redeclaration in anonymous static union ill-formed, even if 
the wording fails to handle that case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/Lexer/unicode.c
  clang/test/SemaCXX/anonymous-union-export.cpp
  clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -145,7 +145,7 @@
  
   Placeholder variables with no name
   https://wg21.link/P2169R4";>P2169R4
-  No
+  Clang 17
  
 
 
Index: clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
@@ -0,0 +1,200 @@
+///
+// RUN: %clang -cc1 -fsyntax-only -verify -std=c++2c -Wunused-parameter -Wunused -Wpre-c++26-compat %s
+
+void static_var() {
+static int _; // expected-note {{previous definition is here}} \
+  // expected-note {{candidate}}
+static int _; // expected-error {{redefinition of '_'}}
+int _;// expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}} \
+  // expected-note {{candidate}}
+_++; // expected-error{{reference to '_' is ambiguous}}
+}
+
+void static_var_2() {
+int _; // expected-note {{previous definition is here}}
+static int _; // expected-error {{redefinition of '_'}}
+}
+
+void bindings() {
+int arr[4] = {0, 1, 2, 3};
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are incompatible with C++ standards before C++2c}} \
+ // expected-note 4{{placeholder declared here}}
+_ == 42; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}}
+{
+// no extension warning as we only introduce a single placeholder.
+auto [_, a, b, c] = arr; // expected-warning {{unused variable '[_, a, b, c]'}}
+}
+{
+auto [_, _, b, c] = arr; // expected-warning {{unused variable '[_, _, b, c]'}} \
+ // expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}}
+}
+{
+// There are only 3 extension warnings because the first
+// introduction of `_` is valid in all C++ standards
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are incompatible with C++ standards before C++2c}}
+}
+}
+
+void lambda() {
+(void)[_ = 0, _ = 1] { // expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}} \
+   // expected-note 4{{placeholder declared here}}
+(void)_++; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}}
+};
+
+{
+int _ = 12;
+(void)[_ = 0]{}; // no warning (different scope)
+}
+}
+
+namespace global_var {
+int _; // expected-note {{previous definition is here}}
+int _; // expected-error {{redefinition of '_'}}
+}
+
+namespace {
+int _; // expected-note {{previous definition is here}}
+int _; // expected-error {{redefinition of '_'}}
+}
+
+
+namespace global_fun {
+void _();
+void _();
+
+void _() {} // expected-note {{previous definition is here}}
+void _() {} // expected-error {{redefinition of '_'}}
+void _(int){}
+}
+
+typedef int _;
+typedef int _; // Type redeclaration, nothing to do with placeholders
+
+void extern_test() {
+extern int _;
+extern int _; // expected-note {{candidate}}
+int _; //expected-note {{candidate}}
+_++; // expected-error {{reference to '_' is ambiguous}}
+}
+
+
+struct Members {
+int _; // expected-note 2{{placeholder declared here}}
+int _; // expected-warning{{placeholder variables are incompatible with C++ standards before C++2c}} \
+   // expected-note 2

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

2023-07-06 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 537745.
cor3ntin added a comment.

Add tests for static structured bindings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/Lexer/unicode.c
  clang/test/SemaCXX/anonymous-union-export.cpp
  clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -145,7 +145,7 @@
  
   Placeholder variables with no name
   https://wg21.link/P2169R4";>P2169R4
-  No
+  Clang 17
  
 
 
Index: clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
@@ -0,0 +1,214 @@
+///
+// RUN: %clang -cc1 -fsyntax-only -verify -std=c++2c -Wunused-parameter -Wunused -Wpre-c++26-compat %s
+
+void static_var() {
+static int _; // expected-note {{previous definition is here}} \
+  // expected-note {{candidate}}
+static int _; // expected-error {{redefinition of '_'}}
+int _;// expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}} \
+  // expected-note {{candidate}}
+_++; // expected-error{{reference to '_' is ambiguous}}
+}
+
+void static_var_2() {
+int _; // expected-note {{previous definition is here}}
+static int _; // expected-error {{redefinition of '_'}}
+}
+
+void bindings() {
+int arr[4] = {0, 1, 2, 3};
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are incompatible with C++ standards before C++2c}} \
+ // expected-note 4{{placeholder declared here}}
+_ == 42; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}}
+{
+// no extension warning as we only introduce a single placeholder.
+auto [_, a, b, c] = arr; // expected-warning {{unused variable '[_, a, b, c]'}}
+}
+{
+auto [_, _, b, c] = arr; // expected-warning {{unused variable '[_, _, b, c]'}} \
+ // expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}}
+}
+{
+// There are only 3 extension warnings because the first
+// introduction of `_` is valid in all C++ standards
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are incompatible with C++ standards before C++2c}}
+}
+}
+
+namespace StaticBindings {
+
+int arr[2] = {0, 1};
+static auto [_, _] = arr; // expected-error {{redefinition of '_'}} \
+  // expected-note  {{previous definition is here}}
+
+void f() {
+int arr[2] = {0, 1};
+static auto [_, _] = arr; // expected-error {{redefinition of '_'}} \
+// expected-note  {{previous definition is here}}
+}
+
+}
+
+void lambda() {
+(void)[_ = 0, _ = 1] { // expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}} \
+   // expected-note 4{{placeholder declared here}}
+(void)_++; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}}
+};
+
+{
+int _ = 12;
+(void)[_ = 0]{}; // no warning (different scope)
+}
+}
+
+namespace global_var {
+int _; // expected-note {{previous definition is here}}
+int _; // expected-error {{redefinition of '_'}}
+}
+
+namespace {
+int _; // expected-note {{previous definition is here}}
+int _; // expected-error {{redefinition of '_'}}
+}
+
+
+namespace global_fun {
+void _();
+void _();
+
+void _() {} // expected-note {{previous definition is here}}
+void _() {} // expected-error {{redefinition of '_'}}
+void _(int){}
+}
+
+typedef int _;
+typedef int _; // Type redeclaration, nothing to do with placeholders
+
+void extern_test() {
+extern int _;
+extern int _; // expected-note {{candidate}}
+int _; //expected-note {{candidate}}
+_++; // expected-error {{reference to '_' is ambiguous}}
+}
+
+
+struct Members {
+int _; // expected-note 2{{placeholder declared here}}
+

[PATCH] D146712: [clang-tidy] Add portability-non-portable-integer-constant check

2023-07-06 Thread Whisperity via Phabricator via cfe-commits
whisperity requested changes to this revision.
whisperity added a comment.

Earlier (IIRC in March) we did an internal test of the check and the following 
results were obtained. The results are kinda //weird//, to say the least. 
Numbers are //after// CodeChecker has done a serverside uniqueing (most likely 
things such as //"if **`X`** in `H.h` is reported in the compilation/analysis 
of `A.cpp` and `B.cpp` then store **`X`** only once"//) of the bugs.

- memcache-d: 43
- tmux: 4
- curl: 283
- twin: 161
- vim: 2 206
- OpenSSL: **23 724**
- sqlite: 752
- ffmpeg: **87 121**
- postgres: **116 635**
- tinyxml2: 6
- libwebm: 34
- xerces: **48 732**
- bitcoin: 4 429
- protobuf: 1 405
- codechecker-ldlogger: 0
- ACID: 4 831
- Qt: **34 973**
- Contour v2: **14 246**
- LLVM: 6 018

No crashes (of the checker) were observed. Most of the large outlier numbers 
are attributable to heavy mathematics (ffmpeg, Qt), crypto (OpenSSL, 
PostgreSQL), or character encoding (Xerces, Postgres, Contour) operations in 
the project.

Unfortunately, this is a very significant amount of false positives to the 
point where the consumption of results is slowed down not on the mental load 
side, but also the technical side (such as triggering server hangs in 
CodeChecker and whatnot...). However, after putting some thoughts into it and 
trying to hand-clusterise some of the reports I've found a few significant 
opportunities where this check should be improved.

**Note:** These improvements might be worthwhile to implement as a //follow-up 
patch// which is merged together with this current review. **As it stands right 
now, this check is way too noisy (on maths-based projects) to be merged!**

1. Enums


One is when the literal is used to initialise an enum. So far I don't know 
whether simply just ignoring enums is good, or would it be worth to somehow 
emit a "unified" warning for the entire enum that follows the pattern as shown 
below.
F28149214: image.png 

2. `(u)?int([\d]+)_t`
-

The other are cases when the user explicitly initialises a **fixed-width** (or 
*constrained-width*) variable, such as `int64_t` or `uint16_t` with a literal. 
Right now, the implementation hard matches only the `IntegerLiteral` instances, 
i.e., lines such as `static constexpr std::uint64_t X = 0x07F00` where the 
width and characteristics of the literal might just as well *exactly* and 
*properly* match the variable it is assigned to (granted, we only match and 
silence `Decl`s for this, and lose expressivity on expressions), and do not 
report then.

3. Large arrays of magic literals
-

While this is not the silencing of a "valid" use case where the check, as of 
the current implementation, it is too verbose for, but I believe we could 
reasonably cull the noisiness of the check by simply saying that if there are 
array initialisers or //brace-init-lists// or whatever that contain multiple 
non-portable literals, then **either** we simply suck it up and do not warn for 
**any** of the elements... or for the sake of collegiality give **one** warning 
for the user. The former option would be the most silencing of all, while the 
latter would allow the user to do a single `// NOLINT` for the array instead of 
having to deal with `/* NOLINTBEGIN */ ... /* NOLINTEND */`.

Several chunks of noisy warnings come out of places like SHA-256, FFT, and 
various other "very mathematical" contexts where a large constant array is 
created with very specific proven values, all of which expressed and reported 
as "non-portable literals". It is no use to do 50 warnings for a single 
array. (This is perhaps after all the same(-ish) family as the "enum" problem.)




Comment at: 
clang-tools-extra/clang-tidy/portability/NonPortableIntegerConstantCheck.cpp:87
+  } else {
+return { StrippedLiteral, 0, 0, 10 };
+  }

(Unrealistic nit: This will consume hypothetical additional literals such as 
`0!ZZZbb=` as if they were decimal literals.)



Comment at: 
clang-tools-extra/clang-tidy/portability/NonPortableIntegerConstantCheck.cpp:153-154
+ "non-portable integer literal: integer literal with leading zeroes");
+  // Matches only the most significant bit,
+  // eg. unsigned value 0x8000.
+  } else if (IsMSBBitUsed) {

(Style nit: These lines could be joined and still fit 80-col, I think.)



Comment at: 
clang-tools-extra/clang-tidy/portability/NonPortableIntegerConstantCheck.h:16
+
+/// Finds integer literals that are being used in a non-portable manner.
+///

I am still not entirely convinced whether this one-line summary makes too much 
sense to a user who does not know the Standard out of heart... As we hunt for 
bit widths more or less perhaps we could weave this notion into the single 
sentence summary saying that integers with "non-portable representation

[PATCH] D153621: [Clang] Correctly handle $, @, and ` when represented as UCN

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

In D153621#4449244 , @aaron.ballman 
wrote:

> Changes generally LGTM, but I'll leave it to @tahonermann to do the final 
> sign-off given this is related to text.

@tahonermann Ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153621

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


[PATCH] D154556: [OPENMP52] Support Support omp_cur_iteration modifier for doacross clause.

2023-07-06 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 537749.
jyu2 added a comment.

Thanks Alexey for the review.  This is address his comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154556

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/ordered_ast_print.cpp
  clang/test/OpenMP/ordered_doacross_codegen.c
  clang/test/OpenMP/ordered_messages.cpp

Index: clang/test/OpenMP/ordered_messages.cpp
===
--- clang/test/OpenMP/ordered_messages.cpp
+++ clang/test/OpenMP/ordered_messages.cpp
@@ -132,7 +132,11 @@
 {
   foo();
 }
+#if _OPENMP >= 202111
+#pragma omp ordered doacross(source:omp_cur_iteration) // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+#else
 #pragma omp ordered depend(source) // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+#endif
   }
 #pragma omp parallel for ordered
   for (int i = 0; i < 10; ++i) {
@@ -155,6 +159,10 @@
 #pragma omp ordered doacross(sink : // omp52-error {{expected ')'}} omp52-note {{to match this '('}} omp52-error {{expected expression}} omp52-error {{expected 'i' loop iteration variable}}
 #pragma omp ordered doacross(sink : i // omp52-error {{expected ')'}} omp52-note {{to match this '('}} omp52-error {{expected 'j' loop iteration variable}}
 #pragma omp ordered doacross(sink : i) // omp52-error {{expected 'j' loop iteration variable}}
+#pragma omp ordered doacross(sink:omp_cur_iteration + 1) // omp52-error {{'doacross sink:' must be with 'omp_cur_iteration - 1'}}
+#pragma omp ordered doacross(sink:omp_cur_iteration - 2) // omp52-error {{'doacross sink:' must be with 'omp_cur_iteration - 1'}}
+#pragma omp ordered doacross(sink:omp_cur_iteration) // omp52-error {{'doacross sink:' must be with 'omp_cur_iteration - 1'}}
+#pragma omp ordered doacross(source:omp_cur_iteration - 1) // omp52-error {{'doacross source:' must be with 'omp_cur_iteration'}}
 #pragma omp ordered doacross(source:)
if (i == j)
 #pragma omp ordered doacross(source:) // omp52-error {{'#pragma omp ordered' with 'doacross' clause cannot be an immediate substatement}}
@@ -309,7 +317,11 @@
 {
   foo();
 }
+#if _OPENMP >= 202111
+#pragma omp ordered doacross(source:omp_cur_iteration) // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+#else
 #pragma omp ordered depend(source) // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+#endif
   }
 #pragma omp parallel for ordered
   for (int i = 0; i < 10; ++i) {
Index: clang/test/OpenMP/ordered_doacross_codegen.c
===
--- clang/test/OpenMP/ordered_doacross_codegen.c
+++ clang/test/OpenMP/ordered_doacross_codegen.c
@@ -84,6 +84,43 @@
 #pragma omp ordered depend(sink : i - 2)
 #endif
 d[i] = a[i - 2];
+foo();
+// CHECK: call void @foo()
+// CHECK: load i32, ptr [[I]],
+// CHECK-NEXT: sub nsw i32 %{{.+}}, 1
+// CHECK-NEXT: sub nsw i32 %{{.+}}, 0
+// CHECK-NEXT: sdiv i32 %{{.+}}, 1
+// CHECK-NEXT: sext i32 %{{.+}} to i64
+// CHECK-NEXT: [[TMP:%.+]] = getelementptr inbounds [1 x i64], ptr [[CNT:%.+]], i64 0, i64 0
+// CHECK-NEXT: store i64 %{{.+}}, ptr [[TMP]],
+// CHECK-NEXT: [[TMP:%.+]] = getelementptr inbounds [1 x i64], ptr [[CNT]], i64 0, i64 0
+// 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]])
+#ifdef OMP52
+#pragma omp ordered doacross(sink :omp_cur_iteration - 1)
+#else
+#pragma omp ordered depend(sink : i - 1)
+#endif
+d[i] = a[i - 1];
+foo();
+// CHECK: call void @foo()
+// CHECK: load i32, ptr [[I:%.+]],
+// CHECK-NEXT: sub nsw i32 %{{.+}}, 0
+// CHECK-NEXT: sdiv i32 %{{.+}}, 1
+// CHECK-NEXT: sext i32 %{{.+}} to i64
+// CHECK-NEXT: [[TMP:%.+]] = getelementptr inbounds [1 x i64], ptr [[CNT:%.+]], i64 0, i64 0
+// CHECK-NEXT: store i64 %{{.+}}, ptr [[TMP]],
+// CHECK-NEXT: [[TMP:%.+]] = getelementptr inbounds [1 x i64], ptr [[CNT]], i64 0, i64 0
+// 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 OMP52
+#pragma omp ordered doacross(source:omp_cur_iteration)
+#else
+#pragma omp ordered depend(source)
+#endif
+c[i] = c[i] + 1;
   }
   // CHECK: call void @__kmpc_for_static_fini

[PATCH] D154556: [OPENMP52] Support Support omp_cur_iteration modifier for doacross clause.

2023-07-06 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/AST/OpenMPClause.cpp:2516-2523
+  if (DepType == OMPC_DOACROSS_source)
+OS << "source:";
+  else if (DepType == OMPC_DOACROSS_sink)
+OS << "sink:";
+  else if (DepType == OMPC_DOACROSS_source_omp_cur_iteration)
+OS << "source: omp_cur_iteration";
+  else if (DepType == OMPC_DOACROSS_sink_omp_cur_iteration)

ABataev wrote:
> switch?
Thanks.  Changed!.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154556

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


[PATCH] D153589: [NFC] Initialize pointer fields and remove a needless null check.

2023-07-06 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann accepted this revision.
tahonermann added a comment.

These changes look fine to me.


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

https://reviews.llvm.org/D153589

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


  1   2   3   >