[PATCH] D154709: [clang][ASTImporter] Add a 'Message' member to ASTImportError and use it throughout ASTImporter

2023-07-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The goal is to have a message always in `ASTImportError`? Then probably the 
constructor without message can be removed, at least to check if really the 
message is added at all places. I found that it is missing in 
`VisitObjCImplementationDecl`.
I do not know what happens with messages passed to `FromDiag` or `ToDiag` and 
if these are available somehow to LLDB. Otherwise it would be even better to 
remove all FromDiag and ToDiag messages from `ASTImporter` and put these 
messages into `ASTImportError` and use later in the way that is needed by the 
use case. This would require to pass a message to `HandleNameConflict` but then 
we have always the detailed message. There are places where diagnostic is 
generated but there is no error, we should check if this is correct and if we 
can remove the diagnostic or make import error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154709

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


[PATCH] D154911: Enabling fstack_clash_protection for arm32 bit, thumb and thumb2 mode

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



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3460
+  } else if (EffectiveTriple.isArm() || EffectiveTriple.isThumb()) {
+CmdArgs.push_back("-mstack-probe-size=1024");
+  }

Why 1024?



Comment at: llvm/lib/Target/ARM/ARMFrameLowering.cpp:780
   emitSPUpdate(isARM, MBB, MBBI, dl, TII, -NumBytes,
MachineInstr::FrameSetup);
   DefCFAOffsetCandidates.addInst(std::prev(MBBI), NumBytes, true);

Is this relevant?  Are the other unmodified uses of emitSPUpdate() relevant?



Comment at: llvm/lib/Target/ARM/ARMFrameLowering.cpp:979
 
   if (STI.isTargetWindows() && WindowsRequiresStackProbe(MF, NumBytes)) {
 uint32_t NumWords = NumBytes >> 2;

Can we try to unify the Windows/non-Windows codepaths to some extent?  Having 
two independent codepaths each trying to decide when probing is necessary seems 
likely to lead to bugs.



Comment at: llvm/test/CodeGen/ARM/stackProbing_arm.ll:19
+; CHECK-NEXT:.pad #4096
+; CHECK-NEXT:sub sp, sp, #4096
+; CHECK-NEXT:cmp sp, r0

Going straight from the function entry to here, you've decremented the stack by 
a total of 6276 bytes; this can jump over a 4kb guard page.



Comment at: llvm/test/CodeGen/ARM/stackProbing_arm.ll:21
+; CHECK-NEXT:cmp sp, r0
+; CHECK-NEXT:str r0, [sp, #1024]
+; CHECK-NEXT:bne .LBB0_1

From a security perspective, scattering pointers to the stack onto the stack is 
maybe not the best idea.



Comment at: llvm/test/CodeGen/ARM/stackProbing_arm.ll:95
+; CHECK-NEXT:@ =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:sub sp, sp, #4096
+; CHECK-NEXT:cmp sp, r3

Again, this is too many bytes.  (At least, ignoring the stores before the loop, 
which don't appear to be intentionally inserted checks.)



Comment at: llvm/test/CodeGen/ARM/stackProbing_thumb.ll:12
+; CHECK-NEXT:ldr r0, .LCPI0_1
+; CHECK-NEXT:subs r0, r0, r0
+; CHECK-NEXT:ldr r1, .LCPI0_2

This is a very fancy way of setting a register to zero.

Have you done any testing that the generated code actually works?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154911

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


[PATCH] D153906: [clang] Allow disassembly of multi-module bitcode files

2023-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.



> [clang] Allow disassembly of multi-module bitcode files

The subject confused me as I did not recognize what disassembly means :)

> Clang currently exits with an error message if asked to disassemble a 
> multi-module bitcode file. [...]

The description is hand-waving on how Clang uses multi-module bitcode files.
You can be more specific that multi-module bitcode files are for -fsanitize=cfi 
and -fwhole-program-vtables. And it will be more useful to include an example 
in the summary.

It seems that you want to do this:

  myclang -Xclang -flto-unit -fsplit-lto-unit -flto=thin a.c -c -o a.bc
  myclang -S -emit-llvm a.bc -o b.ll
  ls b.0.ll b.1.ll

This is a bit odd as the `-o` file may no longer an output. This could be 
fixed, but is this functionality really useful?

  % rm -f a.0.ll a.1.ll; myclang -c a.bc -o a.o ; ls a.[01].ll
  a.0.ll  a.1.ll

We can just disassemble a bitcode with `llvm-dis a.bc -o -`. The nicer thing is 
that llvm-dis additionally calls `ModuleSummaryIndex::print` to print the 
module summary index (if present).
`clang -S -emit-llvm -x ir a.bc` output doesn't have this information.




Comment at: clang/test/Frontend/split-lto-ir-support.cpp:1
+// RUN: %clang -c -flto=thin %s -o %t0.bc
+// RUN: mkdir %t1.d

MaskRay wrote:
> Without -fsanitize=cfi or -fwhole-program-vtables, -fsplit-lto-unit is not 
> the default. You need to specify this option explicitly.
> 
> `%clang` is normally used for test/Driver tests. For other tests, prefer 
> `%clang_cc1`.
We need to hard code a target triple as many targets don't support LTO.


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

https://reviews.llvm.org/D153906

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


[PATCH] D152391: [Clang] Allow bitcode linking when the input is LLVM-IR

2023-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

LGTM. CC1 -mlink-bitcode-file is an interesting option from 2011: 
f1d76db466b2a50781c0754b86ac994dd07b5041
I wonder what the original use case is...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152391

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


[PATCH] D154822: [clang] Support '-fgpu-default-stream=per-thread' for NVIDIA CUDA

2023-07-10 Thread boxu.zhang via Phabricator via cfe-commits
boxu-zhang updated this revision to Diff 538904.
boxu-zhang retitled this revision from "Support 
'-fgpu-default-stream=per-thread' for NVIDIA CUDA" to "[clang] Support 
'-fgpu-default-stream=per-thread' for NVIDIA CUDA".
boxu-zhang added a comment.

Add component 'clang' in commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154822

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/CodeGenCUDA/Inputs/cuda.h
  clang/test/CodeGenCUDA/kernel-call.cu


Index: clang/test/CodeGenCUDA/kernel-call.cu
===
--- clang/test/CodeGenCUDA/kernel-call.cu
+++ clang/test/CodeGenCUDA/kernel-call.cu
@@ -2,6 +2,9 @@
 // RUN: | FileCheck %s --check-prefixes=CUDA-OLD,CHECK
 // RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=CUDA-NEW,CHECK
+// RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
+// RUN:   -fgpu-default-stream=per-thread -DCUDA_API_PER_THREAD_DEFAULT_STREAM 
\
+// RUN: | FileCheck %s --check-prefixes=CUDA-PTH,CHECK
 // RUN: %clang_cc1 -x hip -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=HIP-OLD,CHECK
 // RUN: %clang_cc1 -fhip-new-launch-api -x hip -emit-llvm %s -o - \
@@ -25,6 +28,7 @@
 // CUDA-OLD: call{{.*}}cudaLaunch
 // CUDA-NEW: call{{.*}}__cudaPopCallConfiguration
 // CUDA-NEW: call{{.*}}cudaLaunchKernel
+// CUDA-PTH: call{{.*}}cudaLaunchKernel_ptsz
 __global__ void g1(int x) {}
 
 // CHECK-LABEL: define{{.*}}main
Index: clang/test/CodeGenCUDA/Inputs/cuda.h
===
--- clang/test/CodeGenCUDA/Inputs/cuda.h
+++ clang/test/CodeGenCUDA/Inputs/cuda.h
@@ -58,6 +58,10 @@
 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
 dim3 blockDim, void **args,
 size_t sharedMem, cudaStream_t stream);
+extern "C" cudaError_t cudaLaunchKernel_ptsz(const void *func, dim3 gridDim,
+dim3 blockDim, void **args,
+size_t sharedMem, cudaStream_t stream);
+
 #endif
 
 extern "C" __device__ int printf(const char*, ...);
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -574,6 +574,9 @@
   Builder.defineMacro("__CLANG_RDC__");
 if (!LangOpts.HIP)
   Builder.defineMacro("__CUDA__");
+if (LangOpts.GPUDefaultStream ==
+LangOptions::GPUDefaultStreamKind::PerThread)
+  Builder.defineMacro("CUDA_API_PER_THREAD_DEFAULT_STREAM");
   }
   if (LangOpts.HIP) {
 Builder.defineMacro("__HIP__");
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -358,9 +358,13 @@
   TranslationUnitDecl *TUDecl = CGM.getContext().getTranslationUnitDecl();
   DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
   std::string KernelLaunchAPI = "LaunchKernel";
-  if (CGF.getLangOpts().HIP && CGF.getLangOpts().GPUDefaultStream ==
-   
LangOptions::GPUDefaultStreamKind::PerThread)
-KernelLaunchAPI = KernelLaunchAPI + "_spt";
+  if (CGF.getLangOpts().GPUDefaultStream ==
+  LangOptions::GPUDefaultStreamKind::PerThread) {
+if (CGF.getLangOpts().HIP)
+  KernelLaunchAPI = KernelLaunchAPI + "_spt";
+else if (CGF.getLangOpts().CUDA)
+  KernelLaunchAPI = KernelLaunchAPI + "_ptsz";
+  }
   auto LaunchKernelName = addPrefixToName(KernelLaunchAPI);
   IdentifierInfo  =
   CGM.getContext().Idents.get(LaunchKernelName);


Index: clang/test/CodeGenCUDA/kernel-call.cu
===
--- clang/test/CodeGenCUDA/kernel-call.cu
+++ clang/test/CodeGenCUDA/kernel-call.cu
@@ -2,6 +2,9 @@
 // RUN: | FileCheck %s --check-prefixes=CUDA-OLD,CHECK
 // RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=CUDA-NEW,CHECK
+// RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
+// RUN:   -fgpu-default-stream=per-thread -DCUDA_API_PER_THREAD_DEFAULT_STREAM \
+// RUN: | FileCheck %s --check-prefixes=CUDA-PTH,CHECK
 // RUN: %clang_cc1 -x hip -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=HIP-OLD,CHECK
 // RUN: %clang_cc1 -fhip-new-launch-api -x hip -emit-llvm %s -o - \
@@ -25,6 +28,7 @@
 // CUDA-OLD: call{{.*}}cudaLaunch
 // CUDA-NEW: call{{.*}}__cudaPopCallConfiguration
 // CUDA-NEW: call{{.*}}cudaLaunchKernel
+// CUDA-PTH: call{{.*}}cudaLaunchKernel_ptsz
 __global__ void g1(int x) {}
 
 // CHECK-LABEL: define{{.*}}main
Index: clang/test/CodeGenCUDA/Inputs/cuda.h

[PATCH] D154822: Support '-fgpu-default-stream=per-thread' for NVIDIA CUDA

2023-07-10 Thread boxu.zhang via Phabricator via cfe-commits
boxu-zhang added a comment.

Another point that I don't get is why the libcxx CI failed. Anyone know the 
reason this message?
"
Running global pre-checkout hook
Preparing working directory
Running global post-checkout hook
Running commands
$ trap 'kill -- $$' INT TERM QUIT; libcxx/utils/ci/generate-buildkite-pipeline 
| buildkite-agent pipeline upload
2023-07-11 02:36:45 INFO   Reading pipeline config from STDIN
2023-07-11 02:36:46 INFO   Updating BUILDKITE_COMMIT to 
"a297905cd83911c8a03f060cb9d96bc99aae3f8c"
2023-07-11 02:36:46 FATAL  Pipeline parsing of "(stdin)" failed (Expected 
identifier to start with a letter, got ')
 Error: The command exited with status 1
user command error: exit status 1
"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154822

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


[PATCH] D154915: [ARM][AArch64] Add ARM specific builtin for clz that is not undefined for 0 in ubsan.

2023-07-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/CodeGen/arm_acle.c:351
 //
 long test_clzl(long t) {
   return __clzl(t);

__builtin_clzl returned a signed int, but the new builtin returns an unsigned 
int so the cast changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154915

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


[PATCH] D154915: [ARM][AArch64] Add ARM specific builtin for clz that is not undefined for 0 in ubsan.

2023-07-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: dmgreen, efriedma, SjoerdMeijer, tmatheson, 
kongyi.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: clang.

D152023  made ubsan consider __builtin_clz of 
0 undefined regardless of
the target. This ensures portability and matches gcc.

This causes the ACLE intrinsics to also be considered to also be
considered to be undefined for 0 since they used the generic builtins
as their implementation.

This patch adds builtins for ARM that ubsan doesn't know about to make
the behavior defined for 0. Alternatively, I could have added a zero
check to the intrinsics, but the dedicated builtin will give better -O0
codegen.

Fixes #63113.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154915

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/include/clang/Basic/BuiltinsARM.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c

Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -344,8 +344,8 @@
 // AArch64-LABEL: @test_clzl(
 // AArch64-NEXT:  entry:
 // AArch64-NEXT:[[TMP0:%.*]] = call i64 @llvm.ctlz.i64(i64 [[T:%.*]], i1 false)
-// AArch64-NEXT:[[CAST_I:%.*]] = trunc i64 [[TMP0]] to i32
-// AArch64-NEXT:[[CONV_I:%.*]] = sext i32 [[CAST_I]] to i64
+// AArch64-NEXT:[[TMP1:%.*]] = trunc i64 [[TMP0]] to i32
+// AArch64-NEXT:[[CONV_I:%.*]] = zext i32 [[TMP1]] to i64
 // AArch64-NEXT:ret i64 [[CONV_I]]
 //
 long test_clzl(long t) {
@@ -355,8 +355,8 @@
 // ARM-LABEL: @test_clzll(
 // ARM-NEXT:  entry:
 // ARM-NEXT:[[TMP0:%.*]] = call i64 @llvm.ctlz.i64(i64 [[T:%.*]], i1 false)
-// ARM-NEXT:[[CAST_I:%.*]] = trunc i64 [[TMP0]] to i32
-// ARM-NEXT:[[CONV_I:%.*]] = sext i32 [[CAST_I]] to i64
+// ARM-NEXT:[[TMP1:%.*]] = trunc i64 [[TMP0]] to i32
+// ARM-NEXT:[[CONV_I:%.*]] = zext i32 [[TMP1]] to i64
 // ARM-NEXT:ret i64 [[CONV_I]]
 //
 uint64_t test_clzll(uint64_t t) {
Index: clang/lib/Headers/arm_acle.h
===
--- clang/lib/Headers/arm_acle.h
+++ clang/lib/Headers/arm_acle.h
@@ -140,17 +140,21 @@
 /* CLZ */
 static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
 __clz(uint32_t __t) {
-  return (uint32_t)__builtin_clz(__t);
+  return __builtin_arm_clz(__t);
 }
 
 static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
 __clzl(unsigned long __t) {
-  return (unsigned long)__builtin_clzl(__t);
+#if __SIZEOF_LONG__ == 4
+  return __builtin_arm_clz(__t);
+#else
+  return __builtin_arm_clz64(__t);
+#endif
 }
 
 static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
 __clzll(uint64_t __t) {
-  return (uint64_t)__builtin_clzll(__t);
+  return __builtin_arm_clz64(__t);
 }
 
 /* CLS */
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -7948,6 +7948,17 @@
 CGM.getIntrinsic(Intrinsic::bitreverse, Arg->getType()), Arg, "rbit");
   }
 
+  if (BuiltinID == clang::ARM::BI__builtin_arm_clz ||
+  BuiltinID == clang::ARM::BI__builtin_arm_clz64) {
+llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
+Function *F = CGM.getIntrinsic(Intrinsic::ctlz, Arg->getType());
+Value *Res = Builder.CreateCall(F, {Arg, Builder.getInt1(false)});
+if (BuiltinID == clang::ARM::BI__builtin_arm_clz64)
+  Res = Builder.CreateTrunc(Res, Builder.getInt32Ty());
+return Res;
+  }
+
+
   if (BuiltinID == clang::ARM::BI__builtin_arm_cls) {
 llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
 return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::arm_cls), Arg, "cls");
@@ -10030,6 +10041,16 @@
 CGM.getIntrinsic(Intrinsic::bitreverse, Arg->getType()), Arg, "rbit");
   }
 
+  if (BuiltinID == clang::AArch64::BI__builtin_arm_clz ||
+  BuiltinID == clang::AArch64::BI__builtin_arm_clz64) {
+llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
+Function *F = CGM.getIntrinsic(Intrinsic::ctlz, Arg->getType());
+Value *Res = Builder.CreateCall(F, {Arg, Builder.getInt1(false)});
+if (BuiltinID == clang::AArch64::BI__builtin_arm_clz64)
+  Res = Builder.CreateTrunc(Res, Builder.getInt32Ty());
+return Res;
+  }
+
   if (BuiltinID == clang::AArch64::BI__builtin_arm_cls) {
 llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
 return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::aarch64_cls), Arg,
Index: clang/include/clang/Basic/BuiltinsARM.def
===
--- clang/include/clang/Basic/BuiltinsARM.def
+++ clang/include/clang/Basic/BuiltinsARM.def
@@ -119,6 +119,8 @@
 

[PATCH] D154822: Support '-fgpu-default-stream=per-thread' for NVIDIA CUDA

2023-07-10 Thread boxu.zhang via Phabricator via cfe-commits
boxu-zhang added a comment.

In D154822#4485700 , @tra wrote:

> Looking at CUDA headers, it appears that changing only 
> compiler-generated-glue may be insufficient. A lot of other CUDA API calls 
> need to be changed to `_ptsz` variant and for that we need to have 
> `CUDA_API_PER_THREAD_DEFAULT_STREAM` defined.

CUDA_API_PER_THREAD_DEFAULT_STREAM is defined now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154822

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


[PATCH] D154822: Support '-fgpu-default-stream=per-thread' for NVIDIA CUDA

2023-07-10 Thread boxu.zhang via Phabricator via cfe-commits
boxu-zhang updated this revision to Diff 538894.
boxu-zhang added a comment.

Append 'CUDA_API_PER_THREAD_DEFAULT_STREAM' as a defined macro


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154822

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/CodeGenCUDA/Inputs/cuda.h
  clang/test/CodeGenCUDA/kernel-call.cu


Index: clang/test/CodeGenCUDA/kernel-call.cu
===
--- clang/test/CodeGenCUDA/kernel-call.cu
+++ clang/test/CodeGenCUDA/kernel-call.cu
@@ -2,6 +2,9 @@
 // RUN: | FileCheck %s --check-prefixes=CUDA-OLD,CHECK
 // RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=CUDA-NEW,CHECK
+// RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
+// RUN:   -fgpu-default-stream=per-thread -DCUDA_API_PER_THREAD_DEFAULT_STREAM 
\
+// RUN: | FileCheck %s --check-prefixes=CUDA-PTH,CHECK
 // RUN: %clang_cc1 -x hip -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=HIP-OLD,CHECK
 // RUN: %clang_cc1 -fhip-new-launch-api -x hip -emit-llvm %s -o - \
@@ -25,6 +28,7 @@
 // CUDA-OLD: call{{.*}}cudaLaunch
 // CUDA-NEW: call{{.*}}__cudaPopCallConfiguration
 // CUDA-NEW: call{{.*}}cudaLaunchKernel
+// CUDA-PTH: call{{.*}}cudaLaunchKernel_ptsz
 __global__ void g1(int x) {}
 
 // CHECK-LABEL: define{{.*}}main
Index: clang/test/CodeGenCUDA/Inputs/cuda.h
===
--- clang/test/CodeGenCUDA/Inputs/cuda.h
+++ clang/test/CodeGenCUDA/Inputs/cuda.h
@@ -58,6 +58,10 @@
 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
 dim3 blockDim, void **args,
 size_t sharedMem, cudaStream_t stream);
+extern "C" cudaError_t cudaLaunchKernel_ptsz(const void *func, dim3 gridDim,
+dim3 blockDim, void **args,
+size_t sharedMem, cudaStream_t stream);
+
 #endif
 
 extern "C" __device__ int printf(const char*, ...);
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -574,6 +574,9 @@
   Builder.defineMacro("__CLANG_RDC__");
 if (!LangOpts.HIP)
   Builder.defineMacro("__CUDA__");
+if (LangOpts.GPUDefaultStream ==
+LangOptions::GPUDefaultStreamKind::PerThread)
+  Builder.defineMacro("CUDA_API_PER_THREAD_DEFAULT_STREAM");
   }
   if (LangOpts.HIP) {
 Builder.defineMacro("__HIP__");
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -358,9 +358,13 @@
   TranslationUnitDecl *TUDecl = CGM.getContext().getTranslationUnitDecl();
   DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
   std::string KernelLaunchAPI = "LaunchKernel";
-  if (CGF.getLangOpts().HIP && CGF.getLangOpts().GPUDefaultStream ==
-   
LangOptions::GPUDefaultStreamKind::PerThread)
-KernelLaunchAPI = KernelLaunchAPI + "_spt";
+  if (CGF.getLangOpts().GPUDefaultStream ==
+  LangOptions::GPUDefaultStreamKind::PerThread) {
+if (CGF.getLangOpts().HIP)
+  KernelLaunchAPI = KernelLaunchAPI + "_spt";
+else if (CGF.getLangOpts().CUDA)
+  KernelLaunchAPI = KernelLaunchAPI + "_ptsz";
+  }
   auto LaunchKernelName = addPrefixToName(KernelLaunchAPI);
   IdentifierInfo  =
   CGM.getContext().Idents.get(LaunchKernelName);


Index: clang/test/CodeGenCUDA/kernel-call.cu
===
--- clang/test/CodeGenCUDA/kernel-call.cu
+++ clang/test/CodeGenCUDA/kernel-call.cu
@@ -2,6 +2,9 @@
 // RUN: | FileCheck %s --check-prefixes=CUDA-OLD,CHECK
 // RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=CUDA-NEW,CHECK
+// RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
+// RUN:   -fgpu-default-stream=per-thread -DCUDA_API_PER_THREAD_DEFAULT_STREAM \
+// RUN: | FileCheck %s --check-prefixes=CUDA-PTH,CHECK
 // RUN: %clang_cc1 -x hip -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=HIP-OLD,CHECK
 // RUN: %clang_cc1 -fhip-new-launch-api -x hip -emit-llvm %s -o - \
@@ -25,6 +28,7 @@
 // CUDA-OLD: call{{.*}}cudaLaunch
 // CUDA-NEW: call{{.*}}__cudaPopCallConfiguration
 // CUDA-NEW: call{{.*}}cudaLaunchKernel
+// CUDA-PTH: call{{.*}}cudaLaunchKernel_ptsz
 __global__ void g1(int x) {}
 
 // CHECK-LABEL: define{{.*}}main
Index: clang/test/CodeGenCUDA/Inputs/cuda.h
===
--- clang/test/CodeGenCUDA/Inputs/cuda.h
+++ clang/test/CodeGenCUDA/Inputs/cuda.h
@@ -58,6 +58,10 

[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

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

I tested this with our internal use cases with modules and it looks good. 
Things get compiled correctly and we saved  10% compilation time. (May be due 
to different code bases). But some local in tree tests got failed. I took some 
time to investigate them but I didn't get insights :  (


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

https://reviews.llvm.org/D41416

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


[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

2023-07-10 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/include/clang/AST/DeclTemplate.h:786-788
+uint32_t DeclID = ~0U;
+unsigned ODRHash = ~0U;
+bool IsPartial = false;

Maybe this can save some space.



Comment at: clang/lib/AST/DeclTemplate.cpp:366
+  Args,
+  TemplateParameterList 
*TPL) const {
+  CommonBase *CommonBasePtr = getMostRecentDecl()->getCommonPtr();

TPL here looks not used.



Comment at: clang/lib/Serialization/ASTWriterDecl.cpp:288
+  }
+  for (auto  : LazySpecializations) {
+Record.push_back(SpecInfo.DeclID);

v.g.vassilev wrote:
> We should not store the lazy specialization information as an array of items 
> because that makes the search slow. Instead we should use the 
> `OnDiskHashTable` approach which we use already to store the identifier data.
Do you want to implement it in this patch? Or this is a note for future 
optimizations?


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

https://reviews.llvm.org/D41416

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


[PATCH] D154902: [Driver] Default ToolChain::IsIntegratedAssemblerDefault to true

2023-07-10 Thread Brad Smith 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 rG4a1f8fd548f1: [Driver] Default 
ToolChain::IsIntegratedAssemblerDefault to true (authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154902

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Driver/ToolChains/CrossWindows.h
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/HIPSPV.h
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MinGW.h
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h
  clang/lib/Driver/ToolChains/XCore.h
  clang/lib/Driver/ToolChains/ZOS.h

Index: clang/lib/Driver/ToolChains/ZOS.h
===
--- clang/lib/Driver/ToolChains/ZOS.h
+++ clang/lib/Driver/ToolChains/ZOS.h
@@ -61,8 +61,6 @@
   }
   bool isPICDefaultForced() const override { return false; }
 
-  bool IsIntegratedAssemblerDefault() const override { return true; }
-
   void TryAddIncludeFromPath(llvm::SmallString<128> Path,
  const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const;
Index: clang/lib/Driver/ToolChains/XCore.h
===
--- clang/lib/Driver/ToolChains/XCore.h
+++ clang/lib/Driver/ToolChains/XCore.h
@@ -57,6 +57,7 @@
   Tool *buildLinker() const override;
 
 public:
+  bool IsIntegratedAssemblerDefault() const override { return false; }
   bool isPICDefault() const override;
   bool isPIEDefault(const llvm::opt::ArgList ) const override;
   bool isPICDefaultForced() const override;
Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -47,7 +47,6 @@
   bool isPICDefault() const override;
   bool isPIEDefault(const llvm::opt::ArgList ) const override;
   bool isPICDefaultForced() const override;
-  bool IsIntegratedAssemblerDefault() const override;
   bool hasBlocksRuntime() const override;
   bool SupportsProfiling() const override;
   bool HasNativeLLVMSupport() const override;
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -212,8 +212,6 @@
 
 bool WebAssembly::isPICDefaultForced() const { return false; }
 
-bool WebAssembly::IsIntegratedAssemblerDefault() const { return true; }
-
 bool WebAssembly::hasBlocksRuntime() const { return false; }
 
 // TODO: Support profiling.
Index: clang/lib/Driver/ToolChains/MinGW.h
===
--- clang/lib/Driver/ToolChains/MinGW.h
+++ clang/lib/Driver/ToolChains/MinGW.h
@@ -65,7 +65,6 @@
 
   bool HasNativeLLVMSupport() const override;
 
-  bool IsIntegratedAssemblerDefault() const override;
   UnwindTableLevel
   getDefaultUnwindTableLevel(const llvm::opt::ArgList ) const override;
   bool isPICDefault() const override;
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -518,8 +518,6 @@
   .equals_insensitive("lld");
 }
 
-bool toolchains::MinGW::IsIntegratedAssemblerDefault() const { return true; }
-
 Tool *toolchains::MinGW::getTool(Action::ActionClass AC) const {
   switch (AC) {
   case Action::PreprocessJobClass:
Index: clang/lib/Driver/ToolChains/MSVC.h
===
--- clang/lib/Driver/ToolChains/MSVC.h
+++ clang/lib/Driver/ToolChains/MSVC.h
@@ -50,7 +50,6 @@
   TranslateArgs(const llvm::opt::DerivedArgList , StringRef BoundArch,
 Action::OffloadKind DeviceOffloadKind) const override;
 
-  bool IsIntegratedAssemblerDefault() const override;
   UnwindTableLevel
   getDefaultUnwindTableLevel(const llvm::opt::ArgList ) const override;
   bool isPICDefault() const override;
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -463,10 +463,6 @@
   return nullptr;
 }
 
-bool MSVCToolChain::IsIntegratedAssemblerDefault() const {
-  return true;
-}
-
 ToolChain::UnwindTableLevel
 MSVCToolChain::getDefaultUnwindTableLevel(const ArgList ) const {
   // Don't emit unwind tables by default for MachO targets.
Index: clang/lib/Driver/ToolChains/HIPSPV.h

[clang] 4a1f8fd - [Driver] Default ToolChain::IsIntegratedAssemblerDefault to true

2023-07-10 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-07-10T22:26:12-04:00
New Revision: 4a1f8fd548f12a52f91b2856cb6880691f70190b

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

LOG: [Driver] Default ToolChain::IsIntegratedAssemblerDefault to true

Have ToolChain::IsIntegratedAssemblerDefault default to true.

Almost all of the ToolChains are using IAS nowadays. There are a few exceptions 
like
XCore, some NaCl archs, and NVPTX/XCore in 
Generic_GCC::IsIntegratedAssemblerDefault.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChains/AIX.h
clang/lib/Driver/ToolChains/CrossWindows.h
clang/lib/Driver/ToolChains/Darwin.h
clang/lib/Driver/ToolChains/Fuchsia.h
clang/lib/Driver/ToolChains/HIPSPV.h
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/MSVC.h
clang/lib/Driver/ToolChains/MinGW.cpp
clang/lib/Driver/ToolChains/MinGW.h
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/lib/Driver/ToolChains/WebAssembly.h
clang/lib/Driver/ToolChains/XCore.h
clang/lib/Driver/ToolChains/ZOS.h

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 7b5c430aacc7e1..e3fcbd9322b0e4 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -412,7 +412,7 @@ class ToolChain {
 
   /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
   /// by default.
-  virtual bool IsIntegratedAssemblerDefault() const { return false; }
+  virtual bool IsIntegratedAssemblerDefault() const { return true; }
 
   /// IsIntegratedBackendDefault - Does this tool chain enable
   /// -fintegrated-objemitter by default.

diff  --git a/clang/lib/Driver/ToolChains/AIX.h 
b/clang/lib/Driver/ToolChains/AIX.h
index 245639d60c5f25..cc74e5ea85efca 100644
--- a/clang/lib/Driver/ToolChains/AIX.h
+++ b/clang/lib/Driver/ToolChains/AIX.h
@@ -68,7 +68,6 @@ 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 ,

diff  --git a/clang/lib/Driver/ToolChains/CrossWindows.h 
b/clang/lib/Driver/ToolChains/CrossWindows.h
index 165dcdfd5d3a47..0ba17bc3e305cd 100644
--- a/clang/lib/Driver/ToolChains/CrossWindows.h
+++ b/clang/lib/Driver/ToolChains/CrossWindows.h
@@ -54,7 +54,6 @@ class LLVM_LIBRARY_VISIBILITY CrossWindowsToolChain : public 
Generic_GCC {
   CrossWindowsToolChain(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );
 
-  bool IsIntegratedAssemblerDefault() const override { return true; }
   UnwindTableLevel
   getDefaultUnwindTableLevel(const llvm::opt::ArgList ) const override;
   bool isPICDefault() const override;

diff  --git a/clang/lib/Driver/ToolChains/Darwin.h 
b/clang/lib/Driver/ToolChains/Darwin.h
index f64e7180d0af98..42b72e53be1254 100644
--- a/clang/lib/Driver/ToolChains/Darwin.h
+++ b/clang/lib/Driver/ToolChains/Darwin.h
@@ -238,10 +238,6 @@ class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain {
 // expected to use /usr/include/Block.h.
 return true;
   }
-  bool IsIntegratedAssemblerDefault() const override {
-// Default integrated assembler to on for Apple's MachO targets.
-return true;
-  }
 
   bool IsMathErrnoDefault() const override { return false; }
 

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.h 
b/clang/lib/Driver/ToolChains/Fuchsia.h
index 20fb36ce57233d..ba0ec208fb1299 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.h
+++ b/clang/lib/Driver/ToolChains/Fuchsia.h
@@ -55,7 +55,6 @@ class LLVM_LIBRARY_VISIBILITY Fuchsia : public ToolChain {
   const llvm::opt::ArgList );
 
   bool HasNativeLLVMSupport() const override { return true; }
-  bool IsIntegratedAssemblerDefault() const override { return true; }
   bool IsMathErrnoDefault() const override { return false; }
   bool useRelaxRelocations() const override { return true; };
   RuntimeLibType GetDefaultRuntimeLibType() const override {

diff  --git a/clang/lib/Driver/ToolChains/HIPSPV.h 
b/clang/lib/Driver/ToolChains/HIPSPV.h
index 8b0b30efcd34d1..1eaef432171ece 100644
--- a/clang/lib/Driver/ToolChains/HIPSPV.h
+++ b/clang/lib/Driver/ToolChains/HIPSPV.h
@@ -79,7 +79,6 @@ class LLVM_LIBRARY_VISIBILITY HIPSPVToolChain final : public 
ToolChain {
 
   void adjustDebugInfoKind(llvm::codegenoptions::DebugInfoKind ,
const llvm::opt::ArgList ) const override;
-  bool IsIntegratedAssemblerDefault() const override { return true; }
   

[PATCH] D112932: Use llvm.is_fpclass to implement FP classification functions

2023-07-10 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added a comment.

Is there any blocker for this to land?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112932

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


[PATCH] D153906: [clang] Allow disassembly of multi-module bitcode files

2023-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Frontend/split-lto-ir-support.cpp:1
+// RUN: %clang -c -flto=thin %s -o %t0.bc
+// RUN: mkdir %t1.d

Without -fsanitize=cfi or -fwhole-program-vtables, -fsplit-lto-unit is not the 
default. You need to specify this option explicitly.

`%clang` is normally used for test/Driver tests. For other tests, prefer 
`%clang_cc1`.



Comment at: clang/test/Frontend/split-lto-ir-support.cpp:15
+struct B : A {
+  virtual int c(int i) {
+return i + 3;




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

https://reviews.llvm.org/D153906

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


[PATCH] D154871: [clang] Satisfy clang v12

2023-07-10 Thread Ashay Rane 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 rG46333f71f8e0: [clang] Satisfy clang v12 (authored by ashay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154871

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1372,9 +1372,9 @@
 CharKind CK) const {
   // void *memcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is the address of the destination buffer.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   ProgramStateRef State = C.getState();
 
@@ -1387,9 +1387,9 @@
  CharKind CK) const {
   // void *mempcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is a pointer to the byte following the last written byte.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = true;
   constexpr bool IsMempcpy = true;
@@ -1401,9 +1401,9 @@
  CharKind CK) const {
   // void *memmove(void *dst, const void *src, size_t n);
   // The return value is the address of the destination buffer.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = false;
   constexpr bool IsMempcpy = false;
@@ -1413,9 +1413,9 @@
 
 void CStringChecker::evalBcopy(CheckerContext , const CallExpr *CE) const {
   // void bcopy(const void *src, void *dst, size_t n);
-  SourceArgExpr Src{CE->getArg(0), 0};
-  DestinationArgExpr Dest = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  SourceArgExpr Src{{CE->getArg(0), 0}};
+  DestinationArgExpr Dest = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = false;
   constexpr bool IsMempcpy = false;
@@ -1430,7 +1430,7 @@
 
   AnyArgExpr Left = {CE->getArg(0), 0};
   AnyArgExpr Right = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   ProgramStateRef State = C.getState();
   SValBuilder  = C.getSValBuilder();
@@ -1698,14 +1698,14 @@
   const LocationContext *LCtx = C.getLocationContext();
 
   // Check that the destination is non-null.
-  DestinationArgExpr Dst = {CE->getArg(0), 0};
+  DestinationArgExpr Dst = {{CE->getArg(0), 0}};
   SVal DstVal = state->getSVal(Dst.Expression, LCtx);
   state = checkNonNull(C, state, Dst, DstVal);
   if (!state)
 return;
 
   // Check that the source is non-null.
-  SourceArgExpr srcExpr = {CE->getArg(1), 1};
+  SourceArgExpr srcExpr = {{CE->getArg(1), 1}};
   SVal srcVal = state->getSVal(srcExpr.Expression, LCtx);
   state = checkNonNull(C, state, srcExpr, srcVal);
   if (!state)
@@ -1736,10 +1736,11 @@
 
   // FIXME: Why do we choose the srcExpr if the access has no size?
   //  Note that the 3rd argument of the call would be the size parameter.
-  SizeArgExpr SrcExprAsSizeDummy = {srcExpr.Expression, srcExpr.ArgumentIndex};
+  SizeArgExpr SrcExprAsSizeDummy = {
+  {srcExpr.Expression, srcExpr.ArgumentIndex}};
   state = CheckOverlap(
   C, state,
-  (IsBounded ? SizeArgExpr{CE->getArg(2), 2} : SrcExprAsSizeDummy), Dst,
+  (IsBounded ? SizeArgExpr{{CE->getArg(2), 2}} : SrcExprAsSizeDummy), Dst,
   srcExpr);
 
   if (!state)
@@ -1748,7 +1749,7 @@
   // If the function is strncpy, strncat, etc... it is bounded.
   if (IsBounded) {
 // Get the max number of characters to copy.
-SizeArgExpr lenExpr = {CE->getArg(2), 2};
+SizeArgExpr lenExpr = {{CE->getArg(2), 2}};
 SVal lenVal = state->getSVal(lenExpr.Expression, LCtx);
 
 // Protect against misdeclared strncpy().
@@ -,7 +2223,7 @@
 void CStringChecker::evalStrsep(CheckerContext , const CallExpr *CE) const {
   // char *strsep(char **stringp, const char *delim);
   // Verify whether the search string parameter matches the return type.
-  SourceArgExpr SearchStrPtr = {CE->getArg(0), 0};
+  SourceArgExpr SearchStrPtr = 

[clang] 46333f7 - [clang] Satisfy clang v12

2023-07-10 Thread Ashay Rane via cfe-commits

Author: Ashay Rane
Date: 2023-07-10T20:07:43-05:00
New Revision: 46333f71f8e0d6444a9b2c9e063aedb83ebb9735

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

LOG: [clang] Satisfy clang v12

Older versions of clang (for example, v12) throw an error when compiling
CStringChecker.cpp that the initializers for `SourceArgExpr`,
`DestinationArgExpr`, and `SizeArgExpr` are missing braces around
initialization of subobject.  Newer clang versions don't throw this
error.  This patch adds the initialization braces to satisfy clang.

Reviewed By: steakhal

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 51ae0506466a7d..387edd8c3b1860 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1372,9 +1372,9 @@ void CStringChecker::evalMemcpy(CheckerContext , const 
CallExpr *CE,
 CharKind CK) const {
   // void *memcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is the address of the destination buffer.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   ProgramStateRef State = C.getState();
 
@@ -1387,9 +1387,9 @@ void CStringChecker::evalMempcpy(CheckerContext , const 
CallExpr *CE,
  CharKind CK) const {
   // void *mempcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is a pointer to the byte following the last written byte.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = true;
   constexpr bool IsMempcpy = true;
@@ -1401,9 +1401,9 @@ void CStringChecker::evalMemmove(CheckerContext , const 
CallExpr *CE,
  CharKind CK) const {
   // void *memmove(void *dst, const void *src, size_t n);
   // The return value is the address of the destination buffer.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = false;
   constexpr bool IsMempcpy = false;
@@ -1413,9 +1413,9 @@ void CStringChecker::evalMemmove(CheckerContext , const 
CallExpr *CE,
 
 void CStringChecker::evalBcopy(CheckerContext , const CallExpr *CE) const {
   // void bcopy(const void *src, void *dst, size_t n);
-  SourceArgExpr Src{CE->getArg(0), 0};
-  DestinationArgExpr Dest = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  SourceArgExpr Src{{CE->getArg(0), 0}};
+  DestinationArgExpr Dest = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = false;
   constexpr bool IsMempcpy = false;
@@ -1430,7 +1430,7 @@ void CStringChecker::evalMemcmp(CheckerContext , const 
CallExpr *CE,
 
   AnyArgExpr Left = {CE->getArg(0), 0};
   AnyArgExpr Right = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   ProgramStateRef State = C.getState();
   SValBuilder  = C.getSValBuilder();
@@ -1698,14 +1698,14 @@ void CStringChecker::evalStrcpyCommon(CheckerContext 
, const CallExpr *CE,
   const LocationContext *LCtx = C.getLocationContext();
 
   // Check that the destination is non-null.
-  DestinationArgExpr Dst = {CE->getArg(0), 0};
+  DestinationArgExpr Dst = {{CE->getArg(0), 0}};
   SVal DstVal = state->getSVal(Dst.Expression, LCtx);
   state = checkNonNull(C, state, Dst, DstVal);
   if (!state)
 return;
 
   // Check that the source is non-null.
-  SourceArgExpr srcExpr = {CE->getArg(1), 1};
+  SourceArgExpr srcExpr = {{CE->getArg(1), 1}};
   SVal srcVal = state->getSVal(srcExpr.Expression, LCtx);
   state = checkNonNull(C, state, srcExpr, srcVal);
   if (!state)
@@ -1736,10 +1736,11 @@ void CStringChecker::evalStrcpyCommon(CheckerContext 
, const CallExpr *CE,
 
   // FIXME: Why do we choose the srcExpr if the access has no size?
   //  Note that the 3rd argument of the call would be the size parameter.
-  SizeArgExpr SrcExprAsSizeDummy 

[PATCH] D154911: Enabling fstack_clash_protection for arm32 bit, thumb and thumb2 mode

2023-07-10 Thread Varun Kumar E via Phabricator via cfe-commits
varunkumare99 created this revision.
varunkumare99 added reviewers: tnfchris, efriedma, kristof.beyls, 
serge-sans-paille.
Herald added a subscriber: hiraditya.
Herald added a project: All.
varunkumare99 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

adds stack probing instruction sequence for dynamic stack allocations, VLA's 
and constant arrays to protect against stack clash attacks.

Depending on the size of the stack allocation, various probing sequences are 
generated:

- straight line sequence of subtracts and stores
- A loop allocating and probing one page size per iteration, plus a single 
probe to deal with the remainder.
- A loop which moves the SP down to the target value held in a register, used 
when the allocation size is not known at compile-time

reference: https://reviews.llvm.org/D96004


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154911

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
  llvm/lib/Target/ARM/ARMFrameLowering.cpp
  llvm/lib/Target/ARM/ARMFrameLowering.h
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/lib/Target/ARM/ARMInstrInfo.td
  llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
  llvm/lib/Target/ARM/Thumb1FrameLowering.h
  llvm/test/CodeGen/ARM/stackProbing_arm.ll
  llvm/test/CodeGen/ARM/stackProbing_thumb.ll
  llvm/test/CodeGen/Thumb2/stackProbing_thumb2.ll

Index: llvm/test/CodeGen/Thumb2/stackProbing_thumb2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/stackProbing_thumb2.ll
@@ -0,0 +1,188 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc -mtriple thumbv8.1m.main-none-linux-eabi < %s -verify-machineinstrs | FileCheck %s
+; Function Attrs: noinline nounwind optnone
+define dso_local void @large_stack() "probe-stack"="inline-asm" "frame-pointer"="none" {
+; CHECK-LABEL: large_stack:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:.save {r4, r5}
+; CHECK-NEXT:push {r4, r5}
+; CHECK-NEXT:sub.w r0, sp, #79872
+; CHECK-NEXT:subs r0, #132
+; CHECK-NEXT:.pad #2180
+; CHECK-NEXT:subw sp, sp, #2180
+; CHECK-NEXT:  .LBB0_1: @ %entry
+; CHECK-NEXT:@ =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:.pad #4096
+; CHECK-NEXT:sub.w sp, sp, #4096
+; CHECK-NEXT:cmp sp, r0
+; CHECK-NEXT:str.w r0, [sp, #1024]
+; CHECK-NEXT:bne .LBB0_1
+; CHECK-NEXT:  @ %bb.2: @ %entry
+; CHECK-NEXT:movs r0, #0
+; CHECK-NEXT:add r1, sp, #4
+; CHECK-NEXT:str r0, [sp]
+; CHECK-NEXT:movw r0, #1
+; CHECK-NEXT:  .LBB0_3: @ %for.cond
+; CHECK-NEXT:@ =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:ldr r2, [sp]
+; CHECK-NEXT:cmp r2, r0
+; CHECK-NEXT:bhi .LBB0_5
+; CHECK-NEXT:  @ %bb.4: @ %for.body
+; CHECK-NEXT:@ in Loop: Header=BB0_3 Depth=1
+; CHECK-NEXT:ldr r2, [sp]
+; CHECK-NEXT:ldr r3, [sp]
+; CHECK-NEXT:str.w r2, [r1, r3, lsl #2]
+; CHECK-NEXT:ldr r2, [sp]
+; CHECK-NEXT:adds r2, #1
+; CHECK-NEXT:str r2, [sp]
+; CHECK-NEXT:b .LBB0_3
+; CHECK-NEXT:  .LBB0_5: @ %for.end
+; CHECK-NEXT:add.w sp, sp, #79872
+; CHECK-NEXT:add sp, #132
+; CHECK-NEXT:pop {r4, r5}
+; CHECK-NEXT:bx lr
+entry:
+  %stack = alloca [2 x i32], align 4
+  %i = alloca i32, align 4
+  store volatile i32 0, ptr %i, align 4
+  br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+  %0 = load volatile i32, ptr %i, align 4
+  %cmp = icmp ult i32 %0, 2
+  br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+  %1 = load volatile i32, ptr %i, align 4
+  %2 = load volatile i32, ptr %i, align 4
+  %arrayidx = getelementptr inbounds [2 x i32], ptr %stack, i32 0, i32 %2
+  store volatile i32 %1, ptr %arrayidx, align 4
+  br label %for.inc
+
+for.inc:  ; preds = %for.body
+  %3 = load volatile i32, ptr %i, align 4
+  %inc = add nsw i32 %3, 1
+  store volatile i32 %inc, ptr %i, align 4
+  br label %for.cond, !llvm.loop !6
+
+for.end:  ; preds = %for.cond
+  ret void
+}
+
+; Function Attrs: noinline nounwind optnone
+define dso_local void @vla(i32 noundef %n) "probe-stack"="inline-asm" "frame-pointer"="none" {
+; CHECK-LABEL: vla:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:.save {r4, r6, r7, lr}
+; CHECK-NEXT:push {r4, r6, r7, lr}
+; CHECK-NEXT:.setfp r7, sp, #8
+; CHECK-NEXT:add r7, sp, #8
+; CHECK-NEXT:.pad #16
+; CHECK-NEXT:sub sp, #16
+; CHECK-NEXT:movs r1, #7
+; CHECK-NEXT:str r0, [r7, #-12]
+; CHECK-NEXT:add.w r1, r1, r0, lsl #2
+; CHECK-NEXT:str sp, [r7, #-16]
+; CHECK-NEXT:bic r1, r1, #7
+; CHECK-NEXT:sub.w r1, 

[PATCH] D154910: [ARM][AArch64] Make ACLE __clzl/__clzll return unsigned int instead of unsigned long/uint64_t.

2023-07-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 538880.
craig.topper added a comment.

Update __clzl test case to pass an unsigned long instead of signed long.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154910

Files:
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c


Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -332,7 +332,7 @@
 // ARM-NEXT:[[TMP0:%.*]] = call i32 @llvm.ctlz.i32(i32 [[T:%.*]], i1 false)
 // ARM-NEXT:ret i32 [[TMP0]]
 //
-uint32_t test_clz(uint32_t t) {
+unsigned test_clz(uint32_t t) {
   return __clz(t);
 }
 
@@ -345,10 +345,9 @@
 // AArch64-NEXT:  entry:
 // AArch64-NEXT:[[TMP0:%.*]] = call i64 @llvm.ctlz.i64(i64 [[T:%.*]], i1 
false)
 // AArch64-NEXT:[[CAST_I:%.*]] = trunc i64 [[TMP0]] to i32
-// AArch64-NEXT:[[CONV_I:%.*]] = sext i32 [[CAST_I]] to i64
-// AArch64-NEXT:ret i64 [[CONV_I]]
+// AArch64-NEXT:ret i32 [[CAST_I]]
 //
-long test_clzl(long t) {
+unsigned test_clzl(unsigned long t) {
   return __clzl(t);
 }
 
@@ -356,10 +355,9 @@
 // ARM-NEXT:  entry:
 // ARM-NEXT:[[TMP0:%.*]] = call i64 @llvm.ctlz.i64(i64 [[T:%.*]], i1 false)
 // ARM-NEXT:[[CAST_I:%.*]] = trunc i64 [[TMP0]] to i32
-// ARM-NEXT:[[CONV_I:%.*]] = sext i32 [[CAST_I]] to i64
-// ARM-NEXT:ret i64 [[CONV_I]]
+// ARM-NEXT:ret i32 [[CAST_I]]
 //
-uint64_t test_clzll(uint64_t t) {
+unsigned test_clzll(uint64_t t) {
   return __clzll(t);
 }
 
Index: clang/lib/Headers/arm_acle.h
===
--- clang/lib/Headers/arm_acle.h
+++ clang/lib/Headers/arm_acle.h
@@ -138,28 +138,28 @@
 
 
 /* CLZ */
-static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __clz(uint32_t __t) {
-  return (uint32_t)__builtin_clz(__t);
+  return (unsigned int)__builtin_clz(__t);
 }
 
-static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __clzl(unsigned long __t) {
-  return (unsigned long)__builtin_clzl(__t);
+  return (unsigned int)__builtin_clzl(__t);
 }
 
-static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __clzll(uint64_t __t) {
-  return (uint64_t)__builtin_clzll(__t);
+  return (unsigned int)__builtin_clzll(__t);
 }
 
 /* CLS */
-static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __cls(uint32_t __t) {
   return __builtin_arm_cls(__t);
 }
 
-static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __clsl(unsigned long __t) {
 #if __SIZEOF_LONG__ == 4
   return __builtin_arm_cls(__t);
@@ -168,7 +168,7 @@
 #endif
 }
 
-static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __clsll(uint64_t __t) {
   return __builtin_arm_cls64(__t);
 }


Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -332,7 +332,7 @@
 // ARM-NEXT:[[TMP0:%.*]] = call i32 @llvm.ctlz.i32(i32 [[T:%.*]], i1 false)
 // ARM-NEXT:ret i32 [[TMP0]]
 //
-uint32_t test_clz(uint32_t t) {
+unsigned test_clz(uint32_t t) {
   return __clz(t);
 }
 
@@ -345,10 +345,9 @@
 // AArch64-NEXT:  entry:
 // AArch64-NEXT:[[TMP0:%.*]] = call i64 @llvm.ctlz.i64(i64 [[T:%.*]], i1 false)
 // AArch64-NEXT:[[CAST_I:%.*]] = trunc i64 [[TMP0]] to i32
-// AArch64-NEXT:[[CONV_I:%.*]] = sext i32 [[CAST_I]] to i64
-// AArch64-NEXT:ret i64 [[CONV_I]]
+// AArch64-NEXT:ret i32 [[CAST_I]]
 //
-long test_clzl(long t) {
+unsigned test_clzl(unsigned long t) {
   return __clzl(t);
 }
 
@@ -356,10 +355,9 @@
 // ARM-NEXT:  entry:
 // ARM-NEXT:[[TMP0:%.*]] = call i64 @llvm.ctlz.i64(i64 [[T:%.*]], i1 false)
 // ARM-NEXT:[[CAST_I:%.*]] = trunc i64 [[TMP0]] to i32
-// ARM-NEXT:[[CONV_I:%.*]] = sext i32 [[CAST_I]] to i64
-// ARM-NEXT:ret i64 [[CONV_I]]
+// ARM-NEXT:ret i32 [[CAST_I]]
 //
-uint64_t test_clzll(uint64_t t) {
+unsigned test_clzll(uint64_t t) {
   return __clzll(t);
 }
 
Index: clang/lib/Headers/arm_acle.h
===
--- clang/lib/Headers/arm_acle.h
+++ clang/lib/Headers/arm_acle.h
@@ -138,28 +138,28 @@
 
 
 /* CLZ */
-static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, 

[PATCH] D154910: [ARM][AArch64] Make ACLE __clzl/__clzll return unsigned int instead of unsigned long/uint64_t.

2023-07-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: dmgreen, tmatheson, compnerd, SjoerdMeijer, 
kongyi.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: clang.

Use unsigned long in place of uint32_t for both clz and cls.

As far as I can tell this matches what ACLE defines and what gcc implements.

Noticed while investigating fixing 
https://github.com/llvm/llvm-project/issues/63113


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154910

Files:
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c


Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -332,7 +332,7 @@
 // ARM-NEXT:[[TMP0:%.*]] = call i32 @llvm.ctlz.i32(i32 [[T:%.*]], i1 false)
 // ARM-NEXT:ret i32 [[TMP0]]
 //
-uint32_t test_clz(uint32_t t) {
+unsigned test_clz(uint32_t t) {
   return __clz(t);
 }
 
@@ -345,10 +345,9 @@
 // AArch64-NEXT:  entry:
 // AArch64-NEXT:[[TMP0:%.*]] = call i64 @llvm.ctlz.i64(i64 [[T:%.*]], i1 
false)
 // AArch64-NEXT:[[CAST_I:%.*]] = trunc i64 [[TMP0]] to i32
-// AArch64-NEXT:[[CONV_I:%.*]] = sext i32 [[CAST_I]] to i64
-// AArch64-NEXT:ret i64 [[CONV_I]]
+// AArch64-NEXT:ret i32 [[CAST_I]]
 //
-long test_clzl(long t) {
+unsigned test_clzl(long t) {
   return __clzl(t);
 }
 
@@ -356,10 +355,9 @@
 // ARM-NEXT:  entry:
 // ARM-NEXT:[[TMP0:%.*]] = call i64 @llvm.ctlz.i64(i64 [[T:%.*]], i1 false)
 // ARM-NEXT:[[CAST_I:%.*]] = trunc i64 [[TMP0]] to i32
-// ARM-NEXT:[[CONV_I:%.*]] = sext i32 [[CAST_I]] to i64
-// ARM-NEXT:ret i64 [[CONV_I]]
+// ARM-NEXT:ret i32 [[CAST_I]]
 //
-uint64_t test_clzll(uint64_t t) {
+unsigned test_clzll(uint64_t t) {
   return __clzll(t);
 }
 
Index: clang/lib/Headers/arm_acle.h
===
--- clang/lib/Headers/arm_acle.h
+++ clang/lib/Headers/arm_acle.h
@@ -138,28 +138,28 @@
 
 
 /* CLZ */
-static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __clz(uint32_t __t) {
-  return (uint32_t)__builtin_clz(__t);
+  return (unsigned int)__builtin_clz(__t);
 }
 
-static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __clzl(unsigned long __t) {
-  return (unsigned long)__builtin_clzl(__t);
+  return (unsigned int)__builtin_clzl(__t);
 }
 
-static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __clzll(uint64_t __t) {
-  return (uint64_t)__builtin_clzll(__t);
+  return (unsigned int)__builtin_clzll(__t);
 }
 
 /* CLS */
-static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __cls(uint32_t __t) {
   return __builtin_arm_cls(__t);
 }
 
-static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __clsl(unsigned long __t) {
 #if __SIZEOF_LONG__ == 4
   return __builtin_arm_cls(__t);
@@ -168,7 +168,7 @@
 #endif
 }
 
-static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __clsll(uint64_t __t) {
   return __builtin_arm_cls64(__t);
 }


Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -332,7 +332,7 @@
 // ARM-NEXT:[[TMP0:%.*]] = call i32 @llvm.ctlz.i32(i32 [[T:%.*]], i1 false)
 // ARM-NEXT:ret i32 [[TMP0]]
 //
-uint32_t test_clz(uint32_t t) {
+unsigned test_clz(uint32_t t) {
   return __clz(t);
 }
 
@@ -345,10 +345,9 @@
 // AArch64-NEXT:  entry:
 // AArch64-NEXT:[[TMP0:%.*]] = call i64 @llvm.ctlz.i64(i64 [[T:%.*]], i1 false)
 // AArch64-NEXT:[[CAST_I:%.*]] = trunc i64 [[TMP0]] to i32
-// AArch64-NEXT:[[CONV_I:%.*]] = sext i32 [[CAST_I]] to i64
-// AArch64-NEXT:ret i64 [[CONV_I]]
+// AArch64-NEXT:ret i32 [[CAST_I]]
 //
-long test_clzl(long t) {
+unsigned test_clzl(long t) {
   return __clzl(t);
 }
 
@@ -356,10 +355,9 @@
 // ARM-NEXT:  entry:
 // ARM-NEXT:[[TMP0:%.*]] = call i64 @llvm.ctlz.i64(i64 [[T:%.*]], i1 false)
 // ARM-NEXT:[[CAST_I:%.*]] = trunc i64 [[TMP0]] to i32
-// ARM-NEXT:[[CONV_I:%.*]] = sext i32 [[CAST_I]] to i64
-// ARM-NEXT:ret i64 [[CONV_I]]
+// ARM-NEXT:ret i32 [[CAST_I]]
 //
-uint64_t test_clzll(uint64_t t) {
+unsigned test_clzll(uint64_t t) {
   return __clzll(t);
 }
 
Index: clang/lib/Headers/arm_acle.h

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

2023-07-10 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

3. Extend lit's own test suite to cover it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154130

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


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

2023-07-10 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

If the `%>` feature is going to remain (depending on, for example, the answer 
to @tahonermann's question  about 
modulemap), please:

1. Add it to the lit documentation at 
https://llvm.org/docs/TestingGuide.html#substitutions and 
https://llvm.org/docs/CommandGuide/lit.html#substitutions.  (Aside: I wish 
someone would reconcile those lists.)
2. Consider whether there's a clearer syntax.  For example, we already have 
`%{/t:regex_replacement}`.  What about `%{t:real}` and `%{/t:real}`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154130

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


[PATCH] D154856: [MemProf] Use new option/pass for profile feedback and matching

2023-07-10 Thread Teresa Johnson 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 rGb4a82b62258c: [MemProf] Use new option/pass for profile 
feedback and matching (authored by tejohnson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154856

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/memprof.cpp
  clang/test/Driver/fmemprof.cpp
  llvm/include/llvm/Support/PGOOptions.h
  llvm/include/llvm/Transforms/Instrumentation/MemProfiler.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Support/PGOOptions.cpp
  llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/memprof.ll
  llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -176,6 +176,9 @@
   "Use sampled profile to guide PGO.")));
 static cl::opt ProfileFile("profile-file",
  cl::desc("Path to the profile."), cl::Hidden);
+static cl::opt
+MemoryProfileFile("memory-profile-file",
+  cl::desc("Path to the memory profile."), cl::Hidden);
 
 static cl::opt CSPGOKindFlag(
 "cspgo-kind", cl::init(NoCSPGO), cl::Hidden,
@@ -336,19 +339,21 @@
   std::optional P;
   switch (PGOKindFlag) {
   case InstrGen:
-P = PGOOptions(ProfileFile, "", "", FS, PGOOptions::IRInstr);
+P = PGOOptions(ProfileFile, "", "", MemoryProfileFile, FS,
+   PGOOptions::IRInstr);
 break;
   case InstrUse:
-P = PGOOptions(ProfileFile, "", ProfileRemappingFile, FS,
+P = PGOOptions(ProfileFile, "", ProfileRemappingFile, MemoryProfileFile, FS,
PGOOptions::IRUse);
 break;
   case SampleUse:
-P = PGOOptions(ProfileFile, "", ProfileRemappingFile, FS,
+P = PGOOptions(ProfileFile, "", ProfileRemappingFile, MemoryProfileFile, FS,
PGOOptions::SampleUse);
 break;
   case NoPGO:
-if (DebugInfoForProfiling || PseudoProbeForProfiling)
-  P = PGOOptions("", "", "", nullptr, PGOOptions::NoAction,
+if (DebugInfoForProfiling || PseudoProbeForProfiling ||
+!MemoryProfileFile.empty())
+  P = PGOOptions("", "", "", MemoryProfileFile, FS, PGOOptions::NoAction,
  PGOOptions::NoCSAction, DebugInfoForProfiling,
  PseudoProbeForProfiling);
 else
@@ -369,8 +374,9 @@
 P->CSAction = PGOOptions::CSIRInstr;
 P->CSProfileGenFile = CSProfileGenFile;
   } else
-P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile, FS,
-   PGOOptions::NoAction, PGOOptions::CSIRInstr);
+P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile,
+   /*MemoryProfile=*/"", FS, PGOOptions::NoAction,
+   PGOOptions::CSIRInstr);
 } else /* CSPGOKindFlag == CSInstrUse */ {
   if (!P) {
 errs() << "CSInstrUse needs to be together with InstrUse";
Index: llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
===
--- llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
+++ llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
@@ -11,7 +11,7 @@
 
 ; RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata
 
-; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.memprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s
+; RUN: opt < %s -passes='memprof-use' -pgo-warn-missing-function -S 2>&1 | FileCheck %s
 
 ; CHECK: memprof record not found for function hash {{.*}} _Z16funcnotinprofilev
 
Index: llvm/test/Transforms/PGOProfile/memprof.ll
===
--- llvm/test/Transforms/PGOProfile/memprof.ll
+++ llvm/test/Transforms/PGOProfile/memprof.ll
@@ -23,19 +23,36 @@
 ; ALL-NOT: memprof record not found for function hash
 ; ALL-NOT: no profile data available for function
 
-;; Feed back memprof-only profile
-; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.memprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY
+;; Using a memprof-only profile for memprof-use should only give memprof metadata
+; RUN: opt < %s -passes='memprof-use' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY
 ; There should not be any PGO metadata

[clang] b4a82b6 - [MemProf] Use new option/pass for profile feedback and matching

2023-07-10 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2023-07-10T16:42:56-07:00
New Revision: b4a82b62258c5f650a1cccf5b179933e6bae4867

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

LOG: [MemProf] Use new option/pass for profile feedback and matching

Previously the MemProf profile was expected to be in the same profile
file as a normal PGO profile, passed via the usual -fprofile-use=
option, and was matched in the same pass. To simplify profile
preparation, since the raw MemProf profile requires the binary for
symbolization and may be simpler to index separately from the raw PGO
profile, and also to enable providing a MemProf profile for a SamplePGO
build, separate out the MemProf feedback option and matching pass.

This patch adds the -fmemory-profile-use=${file} option, and the
provided file is passed down to LLVM and ultimately used in a new
MemProfUsePass which performs the matching of just the memory profile
contents of that file.

Note that a single profile file containing both normal PGO and MemProf
profile data is still supported, and the relevant profile data is
matched by the appropriate matching pass(es) based on which option(s)
the profile is provided with (the same profile file can be supplied to
both feedback options).

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

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/memprof.cpp
clang/test/Driver/fmemprof.cpp
llvm/include/llvm/Support/PGOOptions.h
llvm/include/llvm/Transforms/Instrumentation/MemProfiler.h
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Support/PGOOptions.cpp
llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/memprof.ll
llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index b0f22411e1ad20..fadfff48582eea 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -282,6 +282,9 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// Name of the profile file to use as output for with -fmemory-profile.
   std::string MemoryProfileOutput;
 
+  /// Name of the profile file to use as input for -fmemory-profile-use.
+  std::string MemoryProfileUsePath;
+
   /// Name of the profile file to use as input for -fprofile-instr-use
   std::string ProfileInstrumentUsePath;
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a34eab4064997a..c5230d11baeddf 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1772,6 +1772,10 @@ defm memory_profile : OptInCC1FFlag<"memory-profile", 
"Enable", "Disable", " hea
 def fmemory_profile_EQ : Joined<["-"], "fmemory-profile=">,
 Group, Flags<[CC1Option]>, MetaVarName<"">,
 HelpText<"Enable heap memory profiling and dump results into ">;
+def fmemory_profile_use_EQ : Joined<["-"], "fmemory-profile-use=">,
+Group, Flags<[CC1Option, CoreOption]>, MetaVarName<"">,
+HelpText<"Use memory profile for profile-guided memory optimization">,
+MarshallingInfoString>;
 
 // Begin sanitizer flags. These should all be core options exposed in all 
driver
 // modes.

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 458756509b3a3d..06af08023d1be9 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -762,31 +762,37 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 PGOOpt = PGOOptions(
 CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
: 
CodeGenOpts.InstrProfileOutput,
-"", "", nullptr, PGOOptions::IRInstr, PGOOptions::NoCSAction,
-CodeGenOpts.DebugInfoForProfiling);
+"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
+PGOOptions::NoCSAction, CodeGenOpts.DebugInfoForProfiling);
   else if (CodeGenOpts.hasProfileIRUse()) {
 // -fprofile-use.
 auto CSAction = CodeGenOpts.hasProfileCSIRUse() ? PGOOptions::CSIRUse
 : PGOOptions::NoCSAction;
-PGOOpt =
-PGOOptions(CodeGenOpts.ProfileInstrumentUsePath, "",
-   CodeGenOpts.ProfileRemappingFile, VFS, PGOOptions::IRUse,
-   CSAction, 

[PATCH] D153906: [clang] Allow disassembly of multi-module bitcode files

2023-07-10 Thread Matthew Voss via Phabricator via cfe-commits
ormris updated this revision to Diff 538867.
ormris added a comment.

Attempt to fix pre-merge checks.


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

https://reviews.llvm.org/D153906

Files:
  clang/include/clang/CodeGen/CodeGenAction.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/Frontend/split-lto-ir-support.cpp

Index: clang/test/Frontend/split-lto-ir-support.cpp
===
--- /dev/null
+++ clang/test/Frontend/split-lto-ir-support.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang -c -flto=thin %s -o %t0.bc
+// RUN: mkdir %t1.d
+// RUN: %clang -S -emit-llvm %t0.bc -o %t1.d/split-lto-ir-support.ll
+// RUN: FileCheck <%t1.d/split-lto-ir-support.0.ll --check-prefix M0 %s
+// RUN: FileCheck <%t1.d/split-lto-ir-support.1.ll --check-prefix M1 %s
+// RUN: rm -rf %t1.d
+// M0: @main
+// M1: anon.
+
+struct A {
+  virtual int c(int i) = 0;
+};
+
+struct B : A {
+  virtual int c(int i) {
+return i + 3;
+  }
+};
+
+int
+main(void)
+{
+  A *a = new B();
+
+  return a->c(0);
+}
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -1107,26 +1107,59 @@
   return std::move(Result);
 }
 
-std::unique_ptr
+std::vector>
 CodeGenAction::loadModule(MemoryBufferRef MBRef) {
   CompilerInstance  = getCompilerInstance();
   SourceManager  = CI.getSourceManager();
 
+  std::vector> Result;
+
+  if (!llvm::isBitcode((const unsigned char *)MBRef.getBufferStart(),
+   (const unsigned char *)MBRef.getBufferEnd())) {
+llvm::SMDiagnostic Err;
+std::unique_ptr M = parseIR(MBRef, Err, *VMContext);
+if (!M) {
+  // Translate from the diagnostic info to the SourceManager location if
+  // available.
+  // TODO: Unify this with ConvertBackendLocation()
+  SourceLocation Loc;
+  if (Err.getLineNo() > 0) {
+assert(Err.getColumnNo() >= 0);
+Loc = SM.translateFileLineCol(SM.getFileEntryForID(SM.getMainFileID()),
+  Err.getLineNo(), Err.getColumnNo() + 1);
+  }
+
+  // Strip off a leading diagnostic code if there is one.
+  StringRef Msg = Err.getMessage();
+  if (Msg.startswith("error: "))
+Msg = Msg.substr(7);
+
+  unsigned DiagID =
+  CI.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, "%0");
+
+  CI.getDiagnostics().Report(Loc, DiagID) << Msg;
+  return {};
+}
+
+Result.push_back(std::move(M));
+return Result;
+  }
+
+  auto DiagErrors = [&](Error E) -> std::vector> {
+unsigned DiagID =
+CI.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, "%0");
+handleAllErrors(std::move(E), [&](ErrorInfoBase ) {
+  CI.getDiagnostics().Report(DiagID) << EIB.message();
+});
+return {};
+  };
+
   // For ThinLTO backend invocations, ensure that the context
   // merges types based on ODR identifiers. We also need to read
   // the correct module out of a multi-module bitcode file.
   if (!CI.getCodeGenOpts().ThinLTOIndexFile.empty()) {
 VMContext->enableDebugTypeODRUniquing();
 
-auto DiagErrors = [&](Error E) -> std::unique_ptr {
-  unsigned DiagID =
-  CI.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, "%0");
-  handleAllErrors(std::move(E), [&](ErrorInfoBase ) {
-CI.getDiagnostics().Report(DiagID) << EIB.message();
-  });
-  return {};
-};
-
 Expected> BMsOrErr = getBitcodeModuleList(MBRef);
 if (!BMsOrErr)
   return DiagErrors(BMsOrErr.takeError());
@@ -1138,43 +1171,33 @@
 if (!Bm) {
   auto M = std::make_unique("empty", *VMContext);
   M->setTargetTriple(CI.getTargetOpts().Triple);
-  return M;
+  Result.push_back(std::move(M));
+  return Result;
 }
 Expected> MOrErr =
 Bm->parseModule(*VMContext);
 if (!MOrErr)
   return DiagErrors(MOrErr.takeError());
-return std::move(*MOrErr);
+Result.push_back(std::move(MOrErr.get()));
+return Result;
   }
 
   // Load bitcode modules to link with, if we need to.
   if (loadLinkModules(CI))
-return nullptr;
+return {};
 
-  llvm::SMDiagnostic Err;
-  if (std::unique_ptr M = parseIR(MBRef, Err, *VMContext))
-return M;
-
-  // Translate from the diagnostic info to the SourceManager location if
-  // available.
-  // TODO: Unify this with ConvertBackendLocation()
-  SourceLocation Loc;
-  if (Err.getLineNo() > 0) {
-assert(Err.getColumnNo() >= 0);
-Loc = SM.translateFileLineCol(SM.getFileEntryForID(SM.getMainFileID()),
-  Err.getLineNo(), Err.getColumnNo() + 1);
-  }
-
-  // Strip off a leading diagnostic code if there is one.
-  StringRef Msg = Err.getMessage();
-  if (Msg.startswith("error: "))
-Msg = Msg.substr(7);
+  Expected> BMsOrErr = getBitcodeModuleList(MBRef);
+  if (!BMsOrErr)
+return 

[PATCH] D154905: [clang] Implement `PointerLikeTraits` for `{File,Directory}EntryRef`

2023-07-10 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: clang/include/clang/Basic/DirectoryEntry.h:211
+
+  static constexpr int NumLowBitsAvailable = 3;
+};

I suggest not hard-coding it if you can get away with it; maybe 
`PointerLikeTypeTraits::NumLowBitsAvailable`? I think 3 could be wrong on a 32-bit platform for 
example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154905

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


[PATCH] D154905: [clang] Implement `PointerLikeTraits` for `{File,Directory}EntryRef`

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

Note that this enables usage of `{File,Directory}EntryRef` in other containers 
using `PointerLikeTraits` such as `SmallPtrSet`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154905

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


[PATCH] D154856: [MemProf] Use new option/pass for profile feedback and matching

2023-07-10 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish accepted this revision.
snehasish added a comment.
This revision is now accepted and ready to land.

lgtm, thanks for testing the various combinations of profiles passed to each 
option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154856

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


[PATCH] D154905: [clang] Implement `PointerLikeTraits` for `{File,Directory}EntryRef`

2023-07-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: benlangmuir.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch implements `llvm::PointerLikeTraits` and 
`llvm::PointerLikeTraits`, allowing some simplifications 
around umbrella header/directory code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154905

Files:
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/FileEntry.h
  clang/include/clang/Basic/Module.h
  clang/lib/Basic/Module.cpp
  clang/lib/Lex/ModuleMap.cpp

Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -1162,7 +1162,7 @@
 Module *Mod, FileEntryRef UmbrellaHeader, const Twine ,
 const Twine ) {
   Headers[UmbrellaHeader].push_back(KnownHeader(Mod, NormalHeader));
-  Mod->Umbrella = ();
+  Mod->Umbrella = UmbrellaHeader;
   Mod->UmbrellaAsWritten = NameAsWritten.str();
   Mod->UmbrellaRelativeToRootModuleDirectory =
   PathRelativeToRootModuleDirectory.str();
@@ -1176,7 +1176,7 @@
 void ModuleMap::setUmbrellaDirAsWritten(
 Module *Mod, DirectoryEntryRef UmbrellaDir, const Twine ,
 const Twine ) {
-  Mod->Umbrella = ();
+  Mod->Umbrella = UmbrellaDir;
   Mod->UmbrellaAsWritten = NameAsWritten.str();
   Mod->UmbrellaRelativeToRootModuleDirectory =
   PathRelativeToRootModuleDirectory.str();
Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -264,10 +264,10 @@
 }
 
 OptionalDirectoryEntryRef Module::getEffectiveUmbrellaDir() const {
-  if (const auto *ME = Umbrella.dyn_cast())
-return FileEntryRef(*ME).getDir();
-  if (const auto *ME = Umbrella.dyn_cast())
-return DirectoryEntryRef(*ME);
+  if (Umbrella && Umbrella.is())
+return Umbrella.get().getDir();
+  if (Umbrella && Umbrella.is())
+return Umbrella.get();
   return std::nullopt;
 }
 
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -156,9 +156,7 @@
   std::string PresumedModuleMapFile;
 
   /// The umbrella header or directory.
-  llvm::PointerUnion
-  Umbrella;
+  llvm::PointerUnion Umbrella;
 
   /// The module signature.
   ASTFileSignature Signature;
@@ -650,19 +648,18 @@
 
   /// Retrieve the umbrella directory as written.
   std::optional getUmbrellaDirAsWritten() const {
-if (const auto *ME =
-Umbrella.dyn_cast())
+if (Umbrella && Umbrella.is())
   return DirectoryName{UmbrellaAsWritten,
UmbrellaRelativeToRootModuleDirectory,
-   DirectoryEntryRef(*ME)};
+   Umbrella.get()};
 return std::nullopt;
   }
 
   /// Retrieve the umbrella header as written.
   std::optional getUmbrellaHeaderAsWritten() const {
-if (const auto *ME = Umbrella.dyn_cast())
+if (Umbrella && Umbrella.is())
   return Header{UmbrellaAsWritten, UmbrellaRelativeToRootModuleDirectory,
-FileEntryRef(*ME)};
+Umbrella.get()};
 return std::nullopt;
   }
 
Index: clang/include/clang/Basic/FileEntry.h
===
--- clang/include/clang/Basic/FileEntry.h
+++ clang/include/clang/Basic/FileEntry.h
@@ -234,6 +234,20 @@
 } // namespace clang
 
 namespace llvm {
+
+template <> struct PointerLikeTypeTraits {
+  static inline void *getAsVoidPointer(clang::FileEntryRef File) {
+return const_cast(());
+  }
+
+  static inline clang::FileEntryRef getFromVoidPointer(void *Ptr) {
+return clang::FileEntryRef(
+*reinterpret_cast(Ptr));
+  }
+
+  static constexpr int NumLowBitsAvailable = 3;
+};
+
 /// Specialisation of DenseMapInfo for FileEntryRef.
 template <> struct DenseMapInfo {
   static inline clang::FileEntryRef getEmptyKey() {
Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -72,7 +72,7 @@
   bool isSameRef(DirectoryEntryRef RHS) const { return ME == RHS.ME; }
 
   DirectoryEntryRef() = delete;
-  DirectoryEntryRef(const MapEntry ) : ME() {}
+  explicit DirectoryEntryRef(const MapEntry ) : ME() {}
 
   /// Allow DirectoryEntryRef to degrade into 'const DirectoryEntry*' to
   /// facilitate incremental adoption.
@@ -197,6 +197,20 @@
 } // namespace clang
 
 namespace llvm {
+
+template <> struct PointerLikeTypeTraits {
+  static inline void *getAsVoidPointer(clang::DirectoryEntryRef Dir) {
+return const_cast(());
+  }
+
+  static inline clang::DirectoryEntryRef 

[PATCH] D154902: [Driver] Default ToolChain::IsIntegratedAssemblerDefault to true

2023-07-10 Thread Brad Smith via Phabricator via cfe-commits
brad added a comment.

In D154902#4487195 , @MaskRay wrote:

> `[Driver]` seems more specific than `[Clang]`

You're right. Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154902

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


[PATCH] D154902: [Clang] Default ToolChain::IsIntegratedAssemblerDefault to true

2023-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

`[Driver]` seems more specific than `[Clang]`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154902

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


[clang] 7c7b191 - [-Wunsafe-buffer-usage] Unbreak clang-format on UnsafeBufferUsage.cpp. NFC.

2023-07-10 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2023-07-10T15:57:10-07:00
New Revision: 7c7b19143429dfa6095564d6bb9103410506c183

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

LOG: [-Wunsafe-buffer-usage] Unbreak clang-format on UnsafeBufferUsage.cpp. NFC.

Added: 


Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 685b098cfc614f..539bf389b7dd91 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -210,7 +210,7 @@ static auto 
isInUnspecifiedLvalueContext(internal::Matcher innerMatcher) {
 hasLHS(innerMatcher)
   )
 ));
-// clang-format off
+// clang-format on
 }
 
 



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


[PATCH] D154880: [-Wunsafe-buffer-usage][WIP] Add a facility for debugging low fixit coverage.

2023-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 538862.
NoQ added a comment.

Add the other missing base statement. Debugger was acting weirdly so I thought 
we had bigger problems, but it's just the other thing missing. It's likely that 
we ultimately want a better interface for that anyway.


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

https://reviews.llvm.org/D154880

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-std=c++20 -verify=expected %s
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-mllvm -debug-only=SafeBuffers \
+// RUN:-std=c++20 -verify=expected,debug %s
+
+// A generic -debug would also enable our notes. This is probably fine.
+//
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-std=c++20 -mllvm -debug \
+// RUN:-verify=expected,debug %s
+
+// This test file checks the behavior under the assumption that no fixits
+// were emitted for the test cases. If -Wunsafe-buffer-usage is improved
+// to support these cases (thus failing the test), the test should be changed
+// to showcase a different unsupported example.
+//
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-mllvm -debug-only=SafeBuffers \
+// RUN:-std=c++20 -fdiagnostics-parseable-fixits %s \
+// RUN:2>&1 | FileCheck %s
+// CHECK-NOT: fix-it:
+
+// This debugging facility is only available in debug builds.
+//
+// REQUIRES: asserts
+
+void foo() {
+  int *x = new int[10]; // expected-warning{{'x' is an unsafe pointer used for buffer access}}
+  x[5] = 10;// expected-note{{used in buffer access here}}
+  int z = x[-1];// expected-note{{used in buffer access here}} \
+// debug-note{{safe buffers debug: gadget 'ULCArraySubscript' refused to produce a fix}}
+}
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2276,6 +2276,12 @@
   for (const auto  : Fixes)
 FD << F;
 }
+
+#ifndef NDEBUG
+if (areDebugNotesRequested())
+  for (const DebugNote : DebugNotesByVar[Variable])
+S.Diag(Note.first, diag::note_safe_buffer_debug_mode) << Note.second;
+#endif
   }
 
   bool isSafeBufferOptOut(const SourceLocation ) const override {
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -319,6 +319,15 @@
 
   Kind getKind() const { return K; }
 
+#ifndef NDEBUG
+  StringRef getDebugName() const {
+switch (K) {
+#define GADGET(x) case Kind::x: return #x;
+#include "clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def"
+}
+  }
+#endif
+
   virtual bool isWarningGadget() const = 0;
   virtual const Stmt *getBaseStmt() const = 0;
 
@@ -566,7 +575,11 @@
 
   virtual std::optional getFixits(const Strategy ) const override;
 
-  virtual const Stmt *getBaseStmt() const override { return nullptr; }
+  virtual const Stmt *getBaseStmt() const override {
+// FIXME: This needs to be the entire DeclStmt, assuming that this method
+// makes sense at all on a FixableGadget.
+return PtrInitRHS;
+  }
 
   virtual DeclUseList getClaimedVarUseSites() const override {
 return DeclUseList{PtrInitRHS};
@@ -614,7 +627,11 @@
 
   virtual std::optional getFixits(const Strategy ) const override;
 
-  virtual const Stmt *getBaseStmt() const override { return nullptr; }
+  virtual const Stmt *getBaseStmt() const override {
+// FIXME: This should be the binary operator, assuming that this method
+// makes sense at all on a FixableGadget.
+return PtrLHS;
+  }
 
   virtual DeclUseList getClaimedVarUseSites() const override {
 return DeclUseList{PtrLHS, PtrRHS};
@@ -2113,6 +2130,14 @@
 for (const auto  : Fixables) {
   std::optional Fixits = F->getFixits(S);
   if (!Fixits) {
+#ifndef NDEBUG
+// FIXME: F->getBaseStmt() should never be null!
+// (Or we should build a better interface for this.)
+Handler.addDebugNoteForVar(
+VD, F->getBaseStmt()->getBeginLoc(),
+("gadget '" + F->getDebugName() + "' refused to produce a fix")
+.str());
+#endif
 ImpossibleToFix = 

[PATCH] D154903: clangd: Provide the resource dir via environment variable

2023-07-10 Thread Paul Smith via Phabricator via cfe-commits
madscientist created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
madscientist published this revision for review.
madscientist added a comment.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Ready for review please see https://github.com/clangd/clangd/issues/1695


Set an environment variable CLANGD_RESOURCE_DIR to the path of the Clang
resource directory, so that the compiler driver can (a) know it's being
invoked from clangd and (b) massage its system include paths to use the
Clang resources if it wishes to.

This addresses clangd/clangd#1695


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154903

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -982,6 +982,22 @@
 Opts.Encoding = ForceOffsetEncoding;
   setIncludeCleanerAnalyzesStdlib(IncludeCleanerStdlib);
 
+  constexpr const char *ResourceEnvVar = "CLANGD_RESOURCE_DIR";
+  std::string Resources;
+  if (!::getenv(ResourceEnvVar)) {
+if (Opts.ResourceDir)
+  Resources = *Opts.ResourceDir;
+if (Resources.empty()) {
+  static int StaticForMainAddr;
+  Resources = CompilerInvocation::GetResourcesPath(
+  "clangd", (void *));
+}
+if (!Resources.empty()) {
+  ::setenv(ResourceEnvVar, Resources.c_str(), 1);
+  log("Setting {0} to \"{1}\"", ResourceEnvVar, Resources);
+}
+  }
+
   if (CheckFile.getNumOccurrences()) {
 llvm::SmallString<256> Path;
 if (auto Error =


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -982,6 +982,22 @@
 Opts.Encoding = ForceOffsetEncoding;
   setIncludeCleanerAnalyzesStdlib(IncludeCleanerStdlib);
 
+  constexpr const char *ResourceEnvVar = "CLANGD_RESOURCE_DIR";
+  std::string Resources;
+  if (!::getenv(ResourceEnvVar)) {
+if (Opts.ResourceDir)
+  Resources = *Opts.ResourceDir;
+if (Resources.empty()) {
+  static int StaticForMainAddr;
+  Resources = CompilerInvocation::GetResourcesPath(
+  "clangd", (void *));
+}
+if (!Resources.empty()) {
+  ::setenv(ResourceEnvVar, Resources.c_str(), 1);
+  log("Setting {0} to \"{1}\"", ResourceEnvVar, Resources);
+}
+  }
+
   if (CheckFile.getNumOccurrences()) {
 llvm::SmallString<256> Path;
 if (auto Error =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154902: [Clang] Default ToolChain::IsIntegratedAssemblerDefault to true

2023-07-10 Thread Brad Smith via Phabricator via cfe-commits
brad created this revision.
brad added a reviewer: MaskRay.
brad added a project: clang.
Herald added subscribers: pmatos, asb, abrachet, mstorsjo, jgravelle-google, 
sbc100, dschuff.
Herald added a project: All.
brad requested review of this revision.
Herald added subscribers: wangpc, aheejin.

Have ToolChain::IsIntegratedAssemblerDefault default to true.

Almost all of the ToolChains are using IAS nowadays. There are a few exceptions 
like XCore, some NaCl archs, and NVPTX/XCore in 
Generic_GCC::IsIntegratedAssemblerDefault.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154902

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Driver/ToolChains/CrossWindows.h
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/HIPSPV.h
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MinGW.h
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h
  clang/lib/Driver/ToolChains/XCore.h
  clang/lib/Driver/ToolChains/ZOS.h

Index: clang/lib/Driver/ToolChains/ZOS.h
===
--- clang/lib/Driver/ToolChains/ZOS.h
+++ clang/lib/Driver/ToolChains/ZOS.h
@@ -61,8 +61,6 @@
   }
   bool isPICDefaultForced() const override { return false; }
 
-  bool IsIntegratedAssemblerDefault() const override { return true; }
-
   void TryAddIncludeFromPath(llvm::SmallString<128> Path,
  const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const;
Index: clang/lib/Driver/ToolChains/XCore.h
===
--- clang/lib/Driver/ToolChains/XCore.h
+++ clang/lib/Driver/ToolChains/XCore.h
@@ -57,6 +57,7 @@
   Tool *buildLinker() const override;
 
 public:
+  bool IsIntegratedAssemblerDefault() const override { return false; }
   bool isPICDefault() const override;
   bool isPIEDefault(const llvm::opt::ArgList ) const override;
   bool isPICDefaultForced() const override;
Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -47,7 +47,6 @@
   bool isPICDefault() const override;
   bool isPIEDefault(const llvm::opt::ArgList ) const override;
   bool isPICDefaultForced() const override;
-  bool IsIntegratedAssemblerDefault() const override;
   bool hasBlocksRuntime() const override;
   bool SupportsProfiling() const override;
   bool HasNativeLLVMSupport() const override;
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -212,8 +212,6 @@
 
 bool WebAssembly::isPICDefaultForced() const { return false; }
 
-bool WebAssembly::IsIntegratedAssemblerDefault() const { return true; }
-
 bool WebAssembly::hasBlocksRuntime() const { return false; }
 
 // TODO: Support profiling.
Index: clang/lib/Driver/ToolChains/MinGW.h
===
--- clang/lib/Driver/ToolChains/MinGW.h
+++ clang/lib/Driver/ToolChains/MinGW.h
@@ -65,7 +65,6 @@
 
   bool HasNativeLLVMSupport() const override;
 
-  bool IsIntegratedAssemblerDefault() const override;
   UnwindTableLevel
   getDefaultUnwindTableLevel(const llvm::opt::ArgList ) const override;
   bool isPICDefault() const override;
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -518,8 +518,6 @@
   .equals_insensitive("lld");
 }
 
-bool toolchains::MinGW::IsIntegratedAssemblerDefault() const { return true; }
-
 Tool *toolchains::MinGW::getTool(Action::ActionClass AC) const {
   switch (AC) {
   case Action::PreprocessJobClass:
Index: clang/lib/Driver/ToolChains/MSVC.h
===
--- clang/lib/Driver/ToolChains/MSVC.h
+++ clang/lib/Driver/ToolChains/MSVC.h
@@ -50,7 +50,6 @@
   TranslateArgs(const llvm::opt::DerivedArgList , StringRef BoundArch,
 Action::OffloadKind DeviceOffloadKind) const override;
 
-  bool IsIntegratedAssemblerDefault() const override;
   UnwindTableLevel
   getDefaultUnwindTableLevel(const llvm::opt::ArgList ) const override;
   bool isPICDefault() const override;
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -463,10 +463,6 @@
   return nullptr;
 }
 
-bool MSVCToolChain::IsIntegratedAssemblerDefault() const {
-  return true;
-}
-
 

[PATCH] D154880: [-Wunsafe-buffer-usage][WIP] Add a facility for debugging low fixit coverage.

2023-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 538852.
NoQ added a comment.

`private:` => `public:`

(for some reason it didn't complain until I did a full rebuild)


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

https://reviews.llvm.org/D154880

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-std=c++20 -verify=expected %s
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-mllvm -debug-only=SafeBuffers \
+// RUN:-std=c++20 -verify=expected,debug %s
+
+// A generic -debug would also enable our notes. This is probably fine.
+//
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-std=c++20 -mllvm -debug \
+// RUN:-verify=expected,debug %s
+
+// This test file checks the behavior under the assumption that no fixits
+// were emitted for the test cases. If -Wunsafe-buffer-usage is improved
+// to support these cases (thus failing the test), the test should be changed
+// to showcase a different unsupported example.
+//
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-mllvm -debug-only=SafeBuffers \
+// RUN:-std=c++20 -fdiagnostics-parseable-fixits %s \
+// RUN:2>&1 | FileCheck %s
+// CHECK-NOT: fix-it:
+
+// This debugging facility is only available in debug builds.
+//
+// REQUIRES: asserts
+
+void foo() {
+  int *x = new int[10]; // expected-warning{{'x' is an unsafe pointer used for buffer access}}
+  x[5] = 10;// expected-note{{used in buffer access here}}
+  int z = x[-1];// expected-note{{used in buffer access here}} \
+// debug-note{{safe buffers debug: gadget 'ULCArraySubscript' refused to produce a fix}}
+}
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2276,6 +2276,12 @@
   for (const auto  : Fixes)
 FD << F;
 }
+
+#ifndef NDEBUG
+if (areDebugNotesRequested())
+  for (const DebugNote : DebugNotesByVar[Variable])
+S.Diag(Note.first, diag::note_safe_buffer_debug_mode) << Note.second;
+#endif
   }
 
   bool isSafeBufferOptOut(const SourceLocation ) const override {
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -319,6 +319,15 @@
 
   Kind getKind() const { return K; }
 
+#ifndef NDEBUG
+  StringRef getDebugName() const {
+switch (K) {
+#define GADGET(x) case Kind::x: return #x;
+#include "clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def"
+}
+  }
+#endif
+
   virtual bool isWarningGadget() const = 0;
   virtual const Stmt *getBaseStmt() const = 0;
 
@@ -566,7 +575,7 @@
 
   virtual std::optional getFixits(const Strategy ) const override;
 
-  virtual const Stmt *getBaseStmt() const override { return nullptr; }
+  virtual const Stmt *getBaseStmt() const override { return PtrInitRHS; }
 
   virtual DeclUseList getClaimedVarUseSites() const override {
 return DeclUseList{PtrInitRHS};
@@ -2113,6 +2122,16 @@
 for (const auto  : Fixables) {
   std::optional Fixits = F->getFixits(S);
   if (!Fixits) {
+#ifndef NDEBUG
+// FIXME: F->getBaseStmt() should never be null!
+// (Or we should build a better interface for this.)
+Handler.addDebugNoteForVar(
+VD,
+F->getBaseStmt() ? F->getBaseStmt()->getBeginLoc()
+ : VD->getBeginLoc(),
+("gadget '" + F->getDebugName() + "' refused to produce a fix")
+.str());
+#endif
 ImpossibleToFix = true;
 break;
   } else {
@@ -2198,6 +2217,10 @@
 void clang::checkUnsafeBufferUsage(const Decl *D,
UnsafeBufferUsageHandler ,
bool EmitSuggestions) {
+#ifndef NDEBUG
+  Handler.clearDebugNotes();
+#endif
+
   assert(D && D->getBody());
 
   // Do not emit fixit suggestions for functions declared in an
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11841,6 +11841,12 @@
   "change type 

[PATCH] D153892: [NFC] Initialize class member pointers to nullptr.

2023-07-10 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir updated this revision to Diff 538851.
schittir marked an inline comment as done.
schittir added a comment.

Fix format per comments - indent class members and avoid indenting the class 
definition line.


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

https://reviews.llvm.org/D153892

Files:
  clang/lib/ARCMigrate/TransProperties.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Frontend/ASTConsumers.cpp
  clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -29,7 +29,7 @@
 class StackAddrEscapeChecker
 : public Checker,
  check::EndFunction> {
-  mutable IdentifierInfo *dispatch_semaphore_tII;
+  mutable IdentifierInfo *dispatch_semaphore_tII = nullptr;
   mutable std::unique_ptr BT_stackleak;
   mutable std::unique_ptr BT_returnstack;
   mutable std::unique_ptr BT_capturedstackasync;
Index: clang/lib/Frontend/ASTConsumers.cpp
===
--- clang/lib/Frontend/ASTConsumers.cpp
+++ clang/lib/Frontend/ASTConsumers.cpp
@@ -183,21 +183,20 @@
 /// ASTViewer - AST Visualization
 
 namespace {
-  class ASTViewer : public ASTConsumer {
-ASTContext *Context;
-  public:
-void Initialize(ASTContext ) override {
-  this->Context = 
-}
+class ASTViewer : public ASTConsumer {
+  ASTContext *Context = nullptr;
 
-bool HandleTopLevelDecl(DeclGroupRef D) override {
-  for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I)
-HandleTopLevelSingleDecl(*I);
-  return true;
-}
+public:
+  void Initialize(ASTContext ) override { this->Context =  }
 
-void HandleTopLevelSingleDecl(Decl *D);
-  };
+  bool HandleTopLevelDecl(DeclGroupRef D) override {
+for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I)
+  HandleTopLevelSingleDecl(*I);
+return true;
+  }
+
+  void HandleTopLevelSingleDecl(Decl *D);
+};
 }
 
 void ASTViewer::HandleTopLevelSingleDecl(Decl *D) {
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -580,7 +580,7 @@
 /// LambdaCaptureFields - Mapping from captured variables/this to
 /// corresponding data members in the closure class.
 llvm::DenseMap LambdaCaptureFields;
-FieldDecl *LambdaThisCaptureField;
+FieldDecl *LambdaThisCaptureField = nullptr;
 
 CallStackFrame(EvalInfo , SourceLocation CallLoc,
const FunctionDecl *Callee, const LValue *This,
Index: clang/lib/ARCMigrate/TransProperties.cpp
===
--- clang/lib/ARCMigrate/TransProperties.cpp
+++ clang/lib/ARCMigrate/TransProperties.cpp
@@ -45,7 +45,7 @@
 class PropertiesRewriter {
   MigrationContext 
   MigrationPass 
-  ObjCImplementationDecl *CurImplD;
+  ObjCImplementationDecl *CurImplD = nullptr;
 
   enum PropActionKind {
 PropAction_None,


Index: clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -29,7 +29,7 @@
 class StackAddrEscapeChecker
 : public Checker,
  check::EndFunction> {
-  mutable IdentifierInfo *dispatch_semaphore_tII;
+  mutable IdentifierInfo *dispatch_semaphore_tII = nullptr;
   mutable std::unique_ptr BT_stackleak;
   mutable std::unique_ptr BT_returnstack;
   mutable std::unique_ptr BT_capturedstackasync;
Index: clang/lib/Frontend/ASTConsumers.cpp
===
--- clang/lib/Frontend/ASTConsumers.cpp
+++ clang/lib/Frontend/ASTConsumers.cpp
@@ -183,21 +183,20 @@
 /// ASTViewer - AST Visualization
 
 namespace {
-  class ASTViewer : public ASTConsumer {
-ASTContext *Context;
-  public:
-void Initialize(ASTContext ) override {
-  this->Context = 
-}
+class ASTViewer : public ASTConsumer {
+  ASTContext *Context = nullptr;
 
-bool HandleTopLevelDecl(DeclGroupRef D) override {
-  for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I)
-HandleTopLevelSingleDecl(*I);
-  return true;
-}
+public:
+  void Initialize(ASTContext ) override { this->Context =  }
 
-void HandleTopLevelSingleDecl(Decl *D);
-  };
+  bool HandleTopLevelDecl(DeclGroupRef D) override {
+for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I)
+  HandleTopLevelSingleDecl(*I);
+return true;
+  }
+
+  void HandleTopLevelSingleDecl(Decl *D);
+};
 }
 
 void ASTViewer::HandleTopLevelSingleDecl(Decl *D) {
Index: 

[PATCH] D154861: [clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer.

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



Comment at: clang/lib/AST/ComputeDependence.cpp:461
 /// based on the declaration being referenced.
 ExprDependence clang::computeDependence(DeclRefExpr *E, const ASTContext ) 
{
   auto Deps = ExprDependence::None;

`computeDependence` does not feel particularly well organized, it is not clear 
to me how correct it is :-(



Comment at: clang/lib/AST/ComputeDependence.cpp:532
+
 if (Var->mightBeUsableInConstantExpressions(Ctx)) {
   if (const Expr *Init = Var->getAnyInitializer()) {

It feels like we could fold this under the `if (const Expr *Init = 
Var->getAnyInitializer(); Init ` above and not duplicate code. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154861

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


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

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

> 95% of the %>t are around clang modulemap files, because that code resolves 
> real paths in C++ by design, so I can't avoid it.

Can you link to evidence that this behavior is by design? It isn't obvious to 
me why modulemap files would demand different behavior; especially since that 
would exacerbate `MAX_PATH` problems.

I'm not fond of the `safe_abs_path` name; "safe" doesn't communicate anything 
and the implementation is no more safe than `os.path.abspath` or 
`os.path.realpath`. Suggested alternatives:

- `short_abs_path`
- `shortest_abs_path`
- `abs_path_no_subst_drive`
- `abs_path_preserve_drive`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154130

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


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

2023-07-10 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
royjacobson added a reviewer: shafik.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix #63352 and one other similar issue by slightly adjusting the computation 
for the existance of non
trivial special member functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154893

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/test/SemaCXX/constrained-special-member-functions.cpp


Index: clang/test/SemaCXX/constrained-special-member-functions.cpp
===
--- clang/test/SemaCXX/constrained-special-member-functions.cpp
+++ clang/test/SemaCXX/constrained-special-member-functions.cpp
@@ -312,3 +312,16 @@
 static_assert(__is_trivially_copyable(ExplicitTemplateArgs));
 
 }
+
+
+namespace GH63352 {
+template  class C1 { C1(const C1&) requires B; };
+template  class C2 { C2(C2&&) requires B; };
+template  class C3 { C3& operator=(const C3&) requires B; };
+template  class C4 { C4& operator=(C4&&) requires B; };
+
+static_assert(__is_trivially_copyable(C1));
+static_assert(__is_trivially_copyable(C2));
+static_assert(__is_trivially_copyable(C3));
+static_assert(__is_trivially_copyable(C4));
+}
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -1269,13 +1269,14 @@
   /// (C++ [class.copy]p6, C++11 [class.copy]p12)
   bool hasNonTrivialCopyConstructor() const {
 return data().DeclaredNonTrivialSpecialMembers & SMF_CopyConstructor ||
-   !hasTrivialCopyConstructor();
+   (needsImplicitCopyConstructor() && !hasTrivialCopyConstructor());
   }
 
   bool hasNonTrivialCopyConstructorForCall() const {
 return (data().DeclaredNonTrivialSpecialMembersForCall &
 SMF_CopyConstructor) ||
-   !hasTrivialCopyConstructorForCall();
+   (needsImplicitCopyConstructor() &&
+!hasTrivialCopyConstructorForCall());
   }
 
   /// Determine whether this class has a trivial move constructor
@@ -1315,7 +1316,7 @@
   /// operator (C++ [class.copy]p11, C++11 [class.copy]p25)
   bool hasNonTrivialCopyAssignment() const {
 return data().DeclaredNonTrivialSpecialMembers & SMF_CopyAssignment ||
-   !hasTrivialCopyAssignment();
+   (needsImplicitCopyAssignment() && !hasTrivialCopyAssignment());
   }
 
   /// Determine whether this class has a trivial move assignment operator
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -67,8 +67,9 @@
 
 ABI Changes in This Version
 ---
-- A bug in evaluating the ineligibility of some special member functions has 
been fixed. This can
-  make some classes trivially copyable that were not trivially copyable 
before. (`#62555 `_)
+- Two bug in evaluating the ineligibility of some special member functions has 
been fixed. This can
+  make some classes trivially copyable that were not trivially copyable before.
+  (`#62555 `_, `#63352 
`_)
 
 What's New in Clang |release|?
 ==


Index: clang/test/SemaCXX/constrained-special-member-functions.cpp
===
--- clang/test/SemaCXX/constrained-special-member-functions.cpp
+++ clang/test/SemaCXX/constrained-special-member-functions.cpp
@@ -312,3 +312,16 @@
 static_assert(__is_trivially_copyable(ExplicitTemplateArgs));
 
 }
+
+
+namespace GH63352 {
+template  class C1 { C1(const C1&) requires B; };
+template  class C2 { C2(C2&&) requires B; };
+template  class C3 { C3& operator=(const C3&) requires B; };
+template  class C4 { C4& operator=(C4&&) requires B; };
+
+static_assert(__is_trivially_copyable(C1));
+static_assert(__is_trivially_copyable(C2));
+static_assert(__is_trivially_copyable(C3));
+static_assert(__is_trivially_copyable(C4));
+}
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -1269,13 +1269,14 @@
   /// (C++ [class.copy]p6, C++11 [class.copy]p12)
   bool hasNonTrivialCopyConstructor() const {
 return data().DeclaredNonTrivialSpecialMembers & SMF_CopyConstructor ||
-   !hasTrivialCopyConstructor();
+   (needsImplicitCopyConstructor() && !hasTrivialCopyConstructor());
   }
 
   bool hasNonTrivialCopyConstructorForCall() const {
 return (data().DeclaredNonTrivialSpecialMembersForCall &
 SMF_CopyConstructor) ||
-   

[PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D151683#4486321 , @aaron.ballman 
wrote:

> Aside from the failing precommit CI test case in C, I think this LGTM. I've 
> added @MaskRay as the code owner for the command line option changes in case 
> he's got concerns regarding the deprecation/removal plans.



  - ``-fdouble-square-bracket-attributes`` has been deprecated. It is ignored 
now
and will be removed in CLang 18.

sounds good. (Minor case typo in `CLang`). As you said in

https://discourse.llvm.org/t/rfc-enable-c-11-c2x-attributes-in-all-standard-modes-as-an-extension-and-remove-fdouble-square-bracket-attributes/71268/2

> I’m in support of this idea. I think we should enable the extension 
> unconditionally for Clang 17 with a release note mentioning that 
> -fdouble-square-bracket-attributes will be removed in Clang 18 just as a 
> kindness to users with proprietary code bases that might be using it.

I think a clear summary/commit message should mention that this patch makes 
`[[...]]`` available to C++03 and C17 with no warning by default.

It's also worth calling out that GCC since 10 supports `[[]]` in all C language 
modes (AFAICT there is no warning even with `gcc -std=c89 -c a.c`) (there is a 
warning `-pedantic`).

  % g++ -c a.cc -std=c++03
  a.cc:2:1: error: expected unqualified-id before ‘[’ token
  2 | [[nodiscard]] int without_underscores(void);
| ^
  % myclang++ -c a.cc -std=c++03  # no warning with this patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151683

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


[PATCH] D154675: [Clang] Fix crash when emitting diagnostic for out of order designated initializers in C++

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



Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:66
   .y = 1, // override-note {{previous}}
-  .y = 1, // override-error {{overrides prior initialization}}
+  .y = 1, // override-error {{overrides prior initialization}} // reorder-note 
{{previous initialization for field 'y' is here}}
   .x = 1, // reorder-error {{declaration order}} override-error {{overrides 
prior initialization}} override-note {{previous}}

aaron.ballman wrote:
> A few questions: 1) what is this new note attached to? The only `reorder-*` 
> diagnostic I see in the test is for the initialization of `x`. 2) is the note 
> actually on the correct previous use? I would have expected this to be on the 
> assignment to `y` one line above.
It is attached to :

```
.x = 1, // reorder-error {{declaration order}}
```

We were not issuing it before b/c it was broken, in this case it was just not 
crashing but it was still broken.

We could argue the note should go on the first `.y` although I could see both 
sides since the override is a warning and not an error I think using the second 
is defensible. 




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

https://reviews.llvm.org/D154675

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


[PATCH] D154871: [clang] Satisfy clang v12

2023-07-10 Thread Ashay Rane via Phabricator via cfe-commits
ashay-github updated this revision to Diff 538816.
ashay-github added a comment.

Rebased with main to trigger rebuild


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154871

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1372,9 +1372,9 @@
 CharKind CK) const {
   // void *memcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is the address of the destination buffer.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   ProgramStateRef State = C.getState();
 
@@ -1387,9 +1387,9 @@
  CharKind CK) const {
   // void *mempcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is a pointer to the byte following the last written byte.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = true;
   constexpr bool IsMempcpy = true;
@@ -1401,9 +1401,9 @@
  CharKind CK) const {
   // void *memmove(void *dst, const void *src, size_t n);
   // The return value is the address of the destination buffer.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = false;
   constexpr bool IsMempcpy = false;
@@ -1413,9 +1413,9 @@
 
 void CStringChecker::evalBcopy(CheckerContext , const CallExpr *CE) const {
   // void bcopy(const void *src, void *dst, size_t n);
-  SourceArgExpr Src{CE->getArg(0), 0};
-  DestinationArgExpr Dest = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  SourceArgExpr Src{{CE->getArg(0), 0}};
+  DestinationArgExpr Dest = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = false;
   constexpr bool IsMempcpy = false;
@@ -1430,7 +1430,7 @@
 
   AnyArgExpr Left = {CE->getArg(0), 0};
   AnyArgExpr Right = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   ProgramStateRef State = C.getState();
   SValBuilder  = C.getSValBuilder();
@@ -1698,14 +1698,14 @@
   const LocationContext *LCtx = C.getLocationContext();
 
   // Check that the destination is non-null.
-  DestinationArgExpr Dst = {CE->getArg(0), 0};
+  DestinationArgExpr Dst = {{CE->getArg(0), 0}};
   SVal DstVal = state->getSVal(Dst.Expression, LCtx);
   state = checkNonNull(C, state, Dst, DstVal);
   if (!state)
 return;
 
   // Check that the source is non-null.
-  SourceArgExpr srcExpr = {CE->getArg(1), 1};
+  SourceArgExpr srcExpr = {{CE->getArg(1), 1}};
   SVal srcVal = state->getSVal(srcExpr.Expression, LCtx);
   state = checkNonNull(C, state, srcExpr, srcVal);
   if (!state)
@@ -1736,10 +1736,11 @@
 
   // FIXME: Why do we choose the srcExpr if the access has no size?
   //  Note that the 3rd argument of the call would be the size parameter.
-  SizeArgExpr SrcExprAsSizeDummy = {srcExpr.Expression, srcExpr.ArgumentIndex};
+  SizeArgExpr SrcExprAsSizeDummy = {
+  {srcExpr.Expression, srcExpr.ArgumentIndex}};
   state = CheckOverlap(
   C, state,
-  (IsBounded ? SizeArgExpr{CE->getArg(2), 2} : SrcExprAsSizeDummy), Dst,
+  (IsBounded ? SizeArgExpr{{CE->getArg(2), 2}} : SrcExprAsSizeDummy), Dst,
   srcExpr);
 
   if (!state)
@@ -1748,7 +1749,7 @@
   // If the function is strncpy, strncat, etc... it is bounded.
   if (IsBounded) {
 // Get the max number of characters to copy.
-SizeArgExpr lenExpr = {CE->getArg(2), 2};
+SizeArgExpr lenExpr = {{CE->getArg(2), 2}};
 SVal lenVal = state->getSVal(lenExpr.Expression, LCtx);
 
 // Protect against misdeclared strncpy().
@@ -,7 +2223,7 @@
 void CStringChecker::evalStrsep(CheckerContext , const CallExpr *CE) const {
   // char *strsep(char **stringp, const char *delim);
   // Verify whether the search string parameter matches the return type.
-  SourceArgExpr SearchStrPtr = {CE->getArg(0), 0};
+  SourceArgExpr SearchStrPtr = {{CE->getArg(0), 0}};
 
   QualType CharPtrTy = SearchStrPtr.Expression->getType()->getPointeeType();
  

[PATCH] D154635: [7/8][RISCV] Add rounding mode control variant for conversion intrinsics between floating-point and integer

2023-07-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/test/CodeGen/RISCV/rvv/ceil-vp.ll:24
 ; CHECK-NEXT:vfsgnj.vv v8, v9, v8, v0.t
+; CHECK-NEXT:fsrm a0
 ; CHECK-NEXT:ret

This is concerning. This means the `vfcvt.f.x.v` is getting the modified 
rounding mode from `fsrmi a0, 3`. I think its functionally ok due to the inputs 
involved, but it still shouldn't be happening. Is the vfcvt.f.x.v missing its 
FRM implicit dependency for DYN?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154635

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


[PATCH] D154634: [6/8][RISCV] Add rounding mode control variant for vfsqrt, vfrec7

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154634

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


[PATCH] D154884: [clang-tidy] Make MatchesAnyListedNameMatcher cope with unnamed Decl

2023-07-10 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Remove example from commit message, it's already included in patch.
Simply commit message should be properly formatted without unnecessary 
information.




Comment at: clang-tools-extra/clang-tidy/utils/Matchers.h:115
   default:
-return Regex.match(ND.getName());
+if (const IdentifierInfo *II = ND.getIdentifier(); II)
+  return Regex.match(II->getName());

Not needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154884

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


[PATCH] D154357: [Driver] Recognize powerpc-unknown-eabi as a bare-metal toolchain

2023-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D154357#4485881 , @jroelofs wrote:

> gcc docs seem to indicate that these are valid triples:
>
> https://gcc.gnu.org/install/specific.html#powerpc-x-eabi

Thanks, good to know. `powerpc-*-eabi` indicates that the eabi environment 
desginates an embedded system, regardless of the vendor.
It seems that we should remove `if (Triple.getVendor() != 
llvm::Triple::UnknownVendor)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154357

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


[PATCH] D154633: [5/8][RISCV] Add rounding mode control variant for vfwmacc, vfwnmacc, vfwmsac, vfwnmsac

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154633

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


[PATCH] D154357: [Driver] Recognize powerpc-unknown-eabi as a bare-metal toolchain

2023-07-10 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings accepted this revision.
michaelplatings added a comment.

Hi @MaskRay, thanks for the add. Yes, we've been deleting a lot of `eabi` 
recently, but that's specific to AArch64. I have no particular insight into 
PowerPC but from @jroelofs' link, I agree `eabi` seems correct here.

I've been touching `BareMetal.cpp` a lot recently, and from that point of view 
it seems reasonable to have another architecture join the party. LGTM but I 
agree with MaskRay it would be good to give folks from the PowerPC group a 
chance to comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154357

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


[PATCH] D154287: [clang-tidy] Add modernize-use-std-format check

2023-07-10 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe updated this revision to Diff 538806.
mikecrowe added a comment.

Use isOrdinary in stringLiteral() match on first argument


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154287

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
  clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
  clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
  clang-tools-extra/clang-tidy/utils/FormatStringConverter.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-custom.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format.cpp
@@ -0,0 +1,75 @@
+// RUN: %check_clang_tidy \
+// RUN:   -std=c++20 %s modernize-use-std-format %t -- \
+// RUN:   -config="{CheckOptions: [{key: StrictMode, value: true}]}" \
+// RUN:   -- -isystem %clang_tidy_headers
+// RUN: %check_clang_tidy \
+// RUN:   -std=c++20 %s modernize-use-std-format %t -- \
+// RUN:   -config="{CheckOptions: [{key: StrictMode, value: false}]}" \
+// RUN:   -- -isystem %clang_tidy_headers
+#include 
+// CHECK-FIXES: #include 
+
+namespace absl
+{
+// Use const char * for the format since the real type is hard to mock up.
+template 
+std::string StrFormat(const char *format, const Args&... args);
+} // namespace absl
+
+std::string StrFormat_simple() {
+  return absl::StrFormat("Hello");
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("Hello");
+}
+
+std::string StrFormat_complex(const char *name, double value) {
+  return absl::StrFormat("'%s'='%f'", name, value);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("'{}'='{:f}'", name, value);
+}
+
+std::string StrFormat_integer_conversions() {
+  return absl::StrFormat("int:%d int:%d char:%c char:%c", 65, 'A', 66, 'B');
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("int:{} int:{:d} char:{:c} char:{}", 65, 'A', 66, 'B');
+}
+
+// FormatConverter is capable of removing newlines from the end of the format
+// string. Ensure that isn't incorrectly happening for std::format.
+std::string StrFormat_no_newline_removal() {
+  return absl::StrFormat("a line\n");
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("a line\n");
+}
+
+// FormatConverter is capable of removing newlines from the end of the format
+// string. Ensure that isn't incorrectly happening for std::format.
+std::string StrFormat_cstr_removal(const std::string , const std::string *s2) {
+  return absl::StrFormat("%s %s %s %s", s1.c_str(), s1.data(), s2->c_str(), s2->data());
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("{} {} {} {}", s1, s1, *s2, *s2);
+}
+
+std::string StrFormat_strict_conversion() {
+  const unsigned char uc = 'A';
+  return absl::StrFormat("Integer %hhd from unsigned char\n", uc);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("Integer {} from unsigned char\n", uc);
+}
+
+std::string StrFormat_field_width_and_precision() {
+  auto s1 = absl::StrFormat("width only:%*d width and precision:%*.*f precision only:%.*f", 3, 42, 4, 2, 3.14159265358979323846, 5, 2.718);
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: std::format("width only:{:{}} width and precision:{:{}.{}f} precision only:{:.{}f}", 42, 3, 3.14159265358979323846, 4, 2, 2.718, 5);
+
+  auto s2 = absl::StrFormat("width and precision positional:%1$*2$.*3$f after", 3.14159265358979323846, 4, 2);
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: std::format("width and precision positional:{0:{1}.{2}f} after", 3.14159265358979323846, 4, 2);
+
+  const int width = 10, precision = 3;
+  

[PATCH] D154856: [MemProf] Use new option/pass for profile feedback and matching

2023-07-10 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 538805.
tejohnson added a comment.

Rebase on D154872 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154856

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/memprof.cpp
  clang/test/Driver/fmemprof.cpp
  llvm/include/llvm/Support/PGOOptions.h
  llvm/include/llvm/Transforms/Instrumentation/MemProfiler.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Support/PGOOptions.cpp
  llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/memprof.ll
  llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -176,6 +176,9 @@
   "Use sampled profile to guide PGO.")));
 static cl::opt ProfileFile("profile-file",
  cl::desc("Path to the profile."), cl::Hidden);
+static cl::opt
+MemoryProfileFile("memory-profile-file",
+  cl::desc("Path to the memory profile."), cl::Hidden);
 
 static cl::opt CSPGOKindFlag(
 "cspgo-kind", cl::init(NoCSPGO), cl::Hidden,
@@ -336,19 +339,21 @@
   std::optional P;
   switch (PGOKindFlag) {
   case InstrGen:
-P = PGOOptions(ProfileFile, "", "", FS, PGOOptions::IRInstr);
+P = PGOOptions(ProfileFile, "", "", MemoryProfileFile, FS,
+   PGOOptions::IRInstr);
 break;
   case InstrUse:
-P = PGOOptions(ProfileFile, "", ProfileRemappingFile, FS,
+P = PGOOptions(ProfileFile, "", ProfileRemappingFile, MemoryProfileFile, FS,
PGOOptions::IRUse);
 break;
   case SampleUse:
-P = PGOOptions(ProfileFile, "", ProfileRemappingFile, FS,
+P = PGOOptions(ProfileFile, "", ProfileRemappingFile, MemoryProfileFile, FS,
PGOOptions::SampleUse);
 break;
   case NoPGO:
-if (DebugInfoForProfiling || PseudoProbeForProfiling)
-  P = PGOOptions("", "", "", nullptr, PGOOptions::NoAction,
+if (DebugInfoForProfiling || PseudoProbeForProfiling ||
+!MemoryProfileFile.empty())
+  P = PGOOptions("", "", "", MemoryProfileFile, FS, PGOOptions::NoAction,
  PGOOptions::NoCSAction, DebugInfoForProfiling,
  PseudoProbeForProfiling);
 else
@@ -369,8 +374,9 @@
 P->CSAction = PGOOptions::CSIRInstr;
 P->CSProfileGenFile = CSProfileGenFile;
   } else
-P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile, FS,
-   PGOOptions::NoAction, PGOOptions::CSIRInstr);
+P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile,
+   /*MemoryProfile=*/"", FS, PGOOptions::NoAction,
+   PGOOptions::CSIRInstr);
 } else /* CSPGOKindFlag == CSInstrUse */ {
   if (!P) {
 errs() << "CSInstrUse needs to be together with InstrUse";
Index: llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
===
--- llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
+++ llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
@@ -11,7 +11,7 @@
 
 ; RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata
 
-; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.memprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s
+; RUN: opt < %s -passes='memprof-use' -pgo-warn-missing-function -S 2>&1 | FileCheck %s
 
 ; CHECK: memprof record not found for function hash {{.*}} _Z16funcnotinprofilev
 
Index: llvm/test/Transforms/PGOProfile/memprof.ll
===
--- llvm/test/Transforms/PGOProfile/memprof.ll
+++ llvm/test/Transforms/PGOProfile/memprof.ll
@@ -23,19 +23,36 @@
 ; ALL-NOT: memprof record not found for function hash
 ; ALL-NOT: no profile data available for function
 
-;; Feed back memprof-only profile
-; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.memprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY
+;; Using a memprof-only profile for memprof-use should only give memprof metadata
+; RUN: opt < %s -passes='memprof-use' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY
 ; There should not be any PGO metadata
 ; MEMPROFONLY-NOT: !prof
 
-;; Feed back pgo-only profile
-; RUN: opt < %s -passes=pgo-instr-use 

[PATCH] D151047: [clang-format] Fix indentation for selective formatting.

2023-07-10 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D151047#4449996 , @Sedeniono wrote:

> As suggested by @owenpan, I split the commits differently. The first commit 
> now contains only the fix + corresponding tests. The second commit contains 
> refactorings/asserts.

How do I select/download the two commits? I expected two separate reviews after 
you split the previous patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

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


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

2023-07-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

We had that discussion in the bug report.  Let's just increase the widths 
unconditionally; this is not such a common expression class that we need to 
worry about using an extra word.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154784

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


[PATCH] D153920: [clang] Move the clang formatting job to run-buildbot to fix the CI

2023-07-10 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 538798.
philnik added a comment.

Try to fix CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153920

Files:
  clang/utils/ci/buildkite-pipeline.yml
  clang/utils/ci/run-buildbot
  libcxx/utils/ci/buildkite-pipeline-clang.yml
  libcxx/utils/ci/generate-buildkite-pipeline

Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -11,16 +11,4 @@
 # This script generates the appropriate libc++ CI pipeline based on which project(s) were changed.
 #
 
-if git diff --name-only HEAD~1 | grep -q -E "^libcxx/|^libcxxabi/|^libunwind/|^runtimes/|^cmake/"; then
-  LIBCXX_CHANGED=true
-fi
-
-if git diff --name-only HEAD~1 | grep -q -E "^clang/"; then
-  CLANG_CHANGED=true
-fi
-
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
-  cat libcxx/utils/ci/buildkite-pipeline-clang.yml
-else
-  cat libcxx/utils/ci/buildkite-pipeline.yml
-fi
+cat clang/utils/ci/buildkite-pipeline.yml
Index: clang/utils/ci/run-buildbot
===
--- /dev/null
+++ clang/utils/ci/run-buildbot
@@ -0,0 +1,128 @@
+#!/usr/bin/env bash
+#===--===##
+#
+# 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
+#
+#===--===##
+
+set -ex
+set -o pipefail
+unset LANG
+unset LC_ALL
+unset LC_COLLATE
+
+PROGNAME="$(basename "${0}")"
+
+function usage() {
+cat <
+
+[-h|--help] Display this help and exit.
+
+--llvm-rootPath to the root of the LLVM monorepo. By default, we try
+to figure it out based on the current working directory.
+
+--build-dirThe directory to use for building the library. By default,
+this is '/build/'.
+EOF
+}
+
+if [[ $# == 0 ]]; then
+   usage
+   exit 0
+fi
+
+while [[ $# -gt 0 ]]; do
+case ${1} in
+-h|--help)
+usage
+exit 0
+;;
+--llvm-root)
+MONOREPO_ROOT="${2}"
+shift; shift
+;;
+--build-dir)
+BUILD_DIR="${2}"
+shift; shift
+;;
+*)
+BUILDER="${1}"
+shift
+;;
+esac
+done
+
+MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
+BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"
+INSTALL_DIR="${BUILD_DIR}/install"
+
+# Print the version of a few tools to aid diagnostics in some cases
+cmake --version
+ninja --version
+
+case "${BUILDER}" in
+check-format)
+! grep -rnI '[[:blank:]]$' clang/lib clang/include clang/docs
+;;
+build-clang)
+mkdir install
+# We use Release here to avoid including debug information. Otherwise, the
+# clang binary is very large, which is problematic because we need to upload
+# the artifacts for other jobs to use. This may seem like nothing, but with
+# the number of jobs we run daily, this can result in thousands of GB of
+# network I/O.
+cmake  \
+-S llvm\
+-B build   \
+-G Ninja   \
+-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
+-DCMAKE_BUILD_TYPE=Release \
+-DCMAKE_INSTALL_PREFIX=install \
+-DLLVM_ENABLE_PROJECTS="clang;compiler-rt" \
+
+ninja -C build install-clang install-clang-resource-headers
+ccache -s
+tar -cJvf install.tar.xz install/
+buildkite-agent artifact upload --debug install.tar.xz
+;;
+generic-cxx03)
+buildkite-agent artifact download install.tar.xz .
+tar -xvf install.tar.xz
+export CC=$(pwd)/install/bin/clang
+export CXX=$(pwd)/install/bin/clang++
+chmod +x install/bin/clang install/bin/clang++
+libcxx/utils/ci/run-buildbot generic-cxx03
+;;
+generic-cxx26)
+buildkite-agent artifact download install.tar.xz .
+tar -xvf install.tar.xz
+export CC=$(pwd)/install/bin/clang
+export CXX=$(pwd)/install/bin/clang++
+chmod +x install/bin/clang install/bin/clang++
+libcxx/utils/ci/run-buildbot generic-cxx26
+;;
+generic-modules)
+buildkite-agent artifact download install.tar.xz .
+tar -xvf install.tar.xz
+export CC=$(pwd)/install/bin/clang
+export 

[PATCH] D154797: [CUDA][HIP] Rename and fix `-fcuda-approx-transcendentals`

2023-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

Some nits about testing


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

https://reviews.llvm.org/D154797

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


[PATCH] D154797: [CUDA][HIP] Rename and fix `-fcuda-approx-transcendentals`

2023-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:7228
+  } else {
+Args.ClaimAllArgs(options::OPT_fgpu_approx_transcendentals);
+Args.ClaimAllArgs(options::OPT_fno_gpu_approx_transcendentals);

You can use `Args.claimAllArgs(options::OPT_fgpu_approx_transcendentals, 
options::OPT_fno_gpu_approx_transcendentals);`



Comment at: clang/test/Driver/hip-options.hip:184
+
+// APPROX: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-fgpu-approx-transcendentals"
+// APPROX: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} 
"-fgpu-approx-transcendentals"

Just test `-cc1`: `// APPROX: "-cc1"{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-fgpu-approx-transcendentals"`

Testing `clang` requires `-no-canonical-prefixes`  
https://maskray.me/blog/2021-03-28-compiler-driver-and-cross-compilation#misc



Comment at: clang/test/Driver/hip-options.hip:209
+
+// APPROXNEG-NOT: warning

If `%t` happens to be in a path with `warning` as a substring, this will 
spuriously fail.

Suggest `%clang -fdriver-only -Werror... 2>&1 | count 0` to test that there is 
no warning/error.


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

https://reviews.llvm.org/D154797

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


[PATCH] D154797: [CUDA][HIP] Rename and fix `-fcuda-approx-transcendentals`

2023-07-10 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:1294
+if (!LangOpts.HIP)
+  Builder.defineMacro("__CLANG_CUDA_APPROX_TRANSCENDENTALS__");
+Builder.defineMacro("__CLANG_GPU_APPROX_TRANSCENDENTALS__");

I think we can remove it. I don't think we need to keep the old one around. 
Internal headers have been changed and the macro was never intended for public 
use. 


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

https://reviews.llvm.org/D154797

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


[PATCH] D153659: [RISCV] Fix name mangling for LMUL!=1 vector types with attribute(rvv_vector_bits)

2023-07-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:3879
+
+  Out << "9__RVV_VLSI" << 'u' << TypeNameStr.size() << TypeNameStr << "Lj"
   << VecSizeInBits << "EE";

aaron.ballman wrote:
> CC @rjmccall for ABI review -- naïve, possibly dumb question: shouldn't we be 
> using the vendor extended builtin type encoding for this sort of thing? 
> (https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.builtin-type)
I copied what SVE did and changed to use `__RVV_VLSI` as the name. 

Here's the text from ACLE

14.2.6.3.5 C++ mangling of fixed-length SVE types Let VLST be a valid C++ type:

```
VLAT __attribute__((arm_sve_vector_bits(N)))
```

for some SVE vector type or SVE predicate type VLAT. VLST is mangled in the 
same way as a template:

```
template struct __SVE_VLS;
with the arguments:
__SVE_VLS
```

For example:
```
#if __ARM_FEATURE_SVE_BITS==512
// Mangled as 9__SVE_VLSIu11__SVInt32_tLj512EE
typedef svint32_t vec __attribute__((arm_sve_vector_bits(512)));
// Mangled as 9__SVE_VLSIu10__SVBool_tLj512EE
typedef svbool_t pred __attribute__((arm_sve_vector_bits(512)));
#endif
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153659

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


[PATCH] D154287: [clang-tidy] Add modernize-use-std-format check

2023-07-10 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp:46
+void UseStdFormatCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(argumentCountAtLeast(1), hasArgument(0, stringLiteral()),

PiotrZSL wrote:
> mikecrowe wrote:
> > This matcher also matches the `operator+` call in:
> > ```
> > std::string A(const std::string )
> > 
> > 
> > {   
> > 
> > 
> > return "_" + in;
> > 
> > 
> > }   
> > 
> > 
> > ```
> > which causes an assertion failure:
> > ```
> > clang-tidy: /home/mac/git/llvm-project/clang/include/clang/AST/Decl.h:275: 
> > llvm::StringRef clang::NamedDecl::getName() const: Assertion 
> > `Name.isIdentifier() && "Name is not a simple identifier"' failed.
> > ```
> > when the `StrFormatLikeFunctions` option is set to an unqualified name:
> > ```
> > -config="{CheckOptions: [{key: modernize-use-std-format.StrictMode, value: 
> > false}, {key: modernize-use-std-format.StrFormatLikeFunctions, value: 
> > 'strprintf'}]}"
> > ```
> > 
> > `MatchesAnyListedNameMatcher::NameMatcher::match` calls 
> > `NamedDecl.getName()` which presumably raises the assertion due to the 
> > `operator+` not having a name (that's mentioned in the source anyway.)
> > 
> > I'm unsure whether I should be narrowing the matcher here so that it 
> > guaranteed to not try calling `matchesAnyListedName` on something that 
> > lacks a name, or whether `MatchesAnyListedNameMatcher` ought to be more 
> > tolerant of being called in such situations.
> > 
> > I note that `HasNameMatcher` has rather more elaborate code for generating 
> > the name than `MatchesAnyListedNameMatcher` does.
> > 
> > This problem also affects `modernize-use-std-print`, but due to the need 
> > for there to be no return value in that check it requires somewhat-unlikely 
> > code like:
> > ```
> > void A(const std::string )
> > {
> >   "_" + in;
> > }
> > ```
> > 
> > Do you have any advice? Given that this problem affects a check that has 
> > already landed should I open a bug?
> `unless(hasName(""))` could do a trick, or create own matcher to verify first 
> if function got name.
> Probably similar issues can be with cxxConversionDecl.
> 
> Other best option would be to change 
> MatchesAnyListedNameMatcher::NameMatcher::match to verify if NamedDecl got 
> name before calling it.
> `unless(hasName(""))` could do a trick, or create own matcher to verify first 
> if function got name.

That fails with a similar assertion failure.

> Probably similar issues can be with cxxConversionDecl.

I didn't really understand that one.

> Other best option would be to change 
> MatchesAnyListedNameMatcher::NameMatcher::match to verify if NamedDecl got 
> name before calling it.

That's easy and I think it's the best solution since it saves every check 
having to defend against this. I've done that in [[ 
https://reviews.llvm.org/D154884 | D154884 ]] .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154287

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


[PATCH] D154884: [clang-tidy] Make MatchesAnyListedNameMatcher cope with unnamed Decl

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

If MatchesAnyListedNameMatcher::NameMatcher::match() is called in
MatchMode::MatchUnqualified mode with a NamedDecl that has no name then
calling NamedDecl::getName() will assert with:
 `Name.isIdentifier() && "Name is not a simple identifier"'

This situation can be reproduced by running:
 clang-tidy '-checks=-*,modernize-use-std-print' -fix -config="{CheckOptions: 
[[:] + [modernize-use-std-print.PrintfLikeFunctions,] + [value:] + ['printf']]}"
on:
 void A(const std::string )
 {

  "A" + in;

}

It seems unfair to force all matchers using
matchers::matchesAnyListedName to defend against this, particularly
since test cases are unlikely to provoke the problem. Let's just check
whether the identifier has a name before attempting to use it instead.

Add test case that reproduces the problem to the
use-std-print-custom.cpp lit check.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154884

Files:
  clang-tools-extra/clang-tidy/utils/Matchers.h
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp
@@ -3,7 +3,7 @@
 // RUN: [ \
 // RUN:  { \
 // RUN:   key: modernize-use-std-print.PrintfLikeFunctions, \
-// RUN:   value: '::myprintf; mynamespace::myprintf2' \
+// RUN:   value: 'unqualified_printf;::myprintf; 
mynamespace::myprintf2' \
 // RUN:  }, \
 // RUN:  { \
 // RUN:   key: modernize-use-std-print.FprintfLikeFunctions, \
@@ -14,7 +14,7 @@
 // RUN:   -- -isystem %clang_tidy_headers
 
 #include 
-#include 
+#include 
 
 int myprintf(const char *, ...);
 int myfprintf(FILE *fp, const char *, ...);
@@ -85,3 +85,10 @@
   // CHECK-MESSAGES-NOT: [[@LINE-1]]:10: warning: use 'std::println' instead 
of 'myprintf' [modernize-use-std-print]
   // CHECK-FIXES-NOT: std::println(stderr, "return value {}", i);
 }
+
+// Ensure that MatchesAnyListedNameMatcher::NameMatcher::match() can cope with 
a
+// NamedDecl that has no name when we're trying to match unqualified_printf.
+void no_name(const std::string )
+{
+  "A" + in;
+}
Index: clang-tools-extra/clang-tidy/utils/Matchers.h
===
--- clang-tools-extra/clang-tidy/utils/Matchers.h
+++ clang-tools-extra/clang-tidy/utils/Matchers.h
@@ -112,7 +112,9 @@
   case MatchMode::MatchFullyQualified:
 return Regex.match("::" + ND.getQualifiedNameAsString());
   default:
-return Regex.match(ND.getName());
+if (const IdentifierInfo *II = ND.getIdentifier(); II)
+  return Regex.match(II->getName());
+return false;
   }
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp
@@ -3,7 +3,7 @@
 // RUN: [ \
 // RUN:  { \
 // RUN:   key: modernize-use-std-print.PrintfLikeFunctions, \
-// RUN:   value: '::myprintf; mynamespace::myprintf2' \
+// RUN:   value: 'unqualified_printf;::myprintf; mynamespace::myprintf2' \
 // RUN:  }, \
 // RUN:  { \
 // RUN:   key: modernize-use-std-print.FprintfLikeFunctions, \
@@ -14,7 +14,7 @@
 // RUN:   -- -isystem %clang_tidy_headers
 
 #include 
-#include 
+#include 
 
 int myprintf(const char *, ...);
 int myfprintf(FILE *fp, const char *, ...);
@@ -85,3 +85,10 @@
   // CHECK-MESSAGES-NOT: [[@LINE-1]]:10: warning: use 'std::println' instead of 'myprintf' [modernize-use-std-print]
   // CHECK-FIXES-NOT: std::println(stderr, "return value {}", i);
 }
+
+// Ensure that MatchesAnyListedNameMatcher::NameMatcher::match() can cope with a
+// NamedDecl that has no name when we're trying to match unqualified_printf.
+void no_name(const std::string )
+{
+  "A" + in;
+}
Index: clang-tools-extra/clang-tidy/utils/Matchers.h
===
--- clang-tools-extra/clang-tidy/utils/Matchers.h
+++ clang-tools-extra/clang-tidy/utils/Matchers.h
@@ -112,7 +112,9 @@
   case MatchMode::MatchFullyQualified:
 return Regex.match("::" + ND.getQualifiedNameAsString());
   default:
- 

[PATCH] D154881: [HIP] Ignore host linker flags for device-only

2023-07-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4150
+ (C.getInputArgs().hasArg(options::OPT_emit_llvm))) &&
+!C.getInputArgs().hasArg(options::OPT_offload_device_only))
   LinkerInputs.push_back(Current);

The --hip-link -fgpu-rdc --offload-device-only case needs to add the linker 
inputs e.g. archive of bundled bitcodes. Need a test to make sure that still 
works.

Also you need to use Driver::offloadDeviceOnly() to check whether it is device 
compilation only


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154881

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


[PATCH] D154797: [CUDA][HIP] Rename and fix `-fcuda-approx-transcendentals`

2023-07-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 538787.
yaxunl marked 3 inline comments as done.
yaxunl edited the summary of this revision.
yaxunl added a comment.
Herald added a reviewer: jdoerfert.
Herald added subscribers: jplehr, asavonic, sstefan1.

revised by comments


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

https://reviews.llvm.org/D154797

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/lib/Driver/ToolChains/HIPSPV.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/__clang_cuda_math.h
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h
  clang/lib/Headers/__clang_hip_math.h
  clang/test/Driver/hip-macros.hip
  clang/test/Driver/hip-options.hip
  clang/test/Headers/__clang_hip_math.hip
  clang/test/Headers/nvptx_device_math_sin.c
  clang/test/Headers/nvptx_device_math_sin.cpp

Index: clang/test/Headers/nvptx_device_math_sin.cpp
===
--- clang/test/Headers/nvptx_device_math_sin.cpp
+++ clang/test/Headers/nvptx_device_math_sin.cpp
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -x c++ -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -x c++ -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=SLOW
 // RUN: %clang_cc1 -x c++ -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -ffast-math -ffp-contract=fast
-// RUN: %clang_cc1 -x c++ -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -ffast-math -ffp-contract=fast | FileCheck %s --check-prefix=FAST
+// RUN: %clang_cc1 -x c++ -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fgpu-approx-transcendentals -ffast-math -ffp-contract=fast | FileCheck %s --check-prefix=FAST
 // expected-no-diagnostics
 
 #include 
Index: clang/test/Headers/nvptx_device_math_sin.c
===
--- clang/test/Headers/nvptx_device_math_sin.c
+++ clang/test/Headers/nvptx_device_math_sin.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -x c -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -x c -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=SLOW
 // RUN: %clang_cc1 -x c -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -ffast-math -ffp-contract=fast
-// RUN: %clang_cc1 -x c -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -ffast-math -ffp-contract=fast | FileCheck %s --check-prefix=FAST
+// RUN: %clang_cc1 -x c -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fgpu-approx-transcendentals -ffast-math -ffp-contract=fast | FileCheck %s --check-prefix=FAST
 // expected-no-diagnostics
 
 #include 
Index: clang/test/Headers/__clang_hip_math.hip
===
--- clang/test/Headers/__clang_hip_math.hip
+++ 

[PATCH] D150803: [WebAssembly] Support `annotate` clang attributes for marking functions.

2023-07-10 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 accepted this revision.
sbc100 added a comment.

lgtm.  Can you update the change description now that we decided to not support 
values?

(Ironically I think have a use for values in pipeline now)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

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


[PATCH] D154797: [CUDA][HIP] Rename and fix `-fcuda-approx-transcendentals`

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



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:7221-7223
+bool UseApproxTranscendentals = false;
+if (Args.hasFlag(options::OPT_ffast_math, options::OPT_fno_fast_math,
+ false))

tra wrote:
> ```
> bool UseApproxTranscendentals = Args.hasFlag(options::OPT_ffast_math, 
> options::OPT_fno_fast_math,  false));
> ```
fixed



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:1292-1293
+  if (LangOpts.GPUDeviceApproxTranscendentals) {
+Builder.defineMacro(Twine("__CLANG_") + (LangOpts.HIP ? "HIP" : "CUDA") +
+"_APPROX_TRANSCENDENTALS__");
   }

tra wrote:
> We may want to rename the macro to `__CLANG_GPU_APPROX_TRANSCENDENTALS__`, 
> too. 
> 
will emit `__CLANG_GPU_APPROX_TRANSCENDENTALS__`



Comment at: clang/test/Driver/hip-options.hip:179
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib 
-fgpu-approx-transcendentals \
+// RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefixes=APPROX %s
+

MaskRay wrote:
> excess spaces before `%s`
> 
> ditto below
> 
> Prefer `--check-prefix=` when there is one single check.
fixed


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

https://reviews.llvm.org/D154797

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


[PATCH] D154881: [HIP] Ignore host linker flags for device-only

2023-07-10 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan created this revision.
scchan added a reviewer: yaxunl.
Herald added a project: All.
scchan requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

When compiling in device only mode (e.g. --offload-device-only), the
host linker phase would not happen and therefore, the driver should
ignore all the host linker flags.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154881

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-phases.hip


Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -229,6 +229,25 @@
 // DBIN-DAG: [[P7:[0-9]+]]: linker, {[[P6]]}, hip-fatbin, (device-hip, )
 // DBIN-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:)" 
{[[P7]]}, hip-fatbin
 // DBIN-NOT: host
+
+//
+// Test single gpu architecture with complete compilation in device-only
+// compilation mode with an unused host linker flag.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -Wl,--disable-new-dtags 
2>&1 \
+// RUN: | FileCheck -check-prefixes=HLFDBIN %s
+// HLFDBIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], 
(device-[[T]], [[ARCH:gfx803]])
+// HLFDBIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, 
(device-[[T]], [[ARCH]])
+// HLFDBIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
+// HLFDBIN-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], 
[[ARCH]])
+// HLFDBIN-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], 
[[ARCH]])
+// HLFDBIN-DAG: [[P5:[0-9]+]]: linker, {[[P4]]}, image, (device-[[T]], 
[[ARCH]])
+// HLFDBIN-DAG: [[P6:[0-9]+]]: offload, "device-[[T]] 
(amdgcn-amd-amdhsa:[[ARCH]])" {[[P5]]}, image
+// HLFDBIN-DAG: [[P7:[0-9]+]]: linker, {[[P6]]}, hip-fatbin, (device-hip, )
+// HLFDBIN-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:)" 
{[[P7]]}, hip-fatbin
+// HLFDBIN-NOT: host
+
 //
 // Test single gpu architecture up to the assemble phase in device-only
 // compilation mode.
@@ -305,6 +324,32 @@
 // DBIN2-DAG: [[P14:[0-9]+]]: linker, {[[P6]], [[P13]]}, hip-fatbin, 
(device-hip, )
 // DBIN2-DAG: [[P15:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:)" 
{[[P14]]}, hip-fatbin
 // DBIN2-NOT: host
+
+//
+// Test two gpu architectures with complete compilation in device-only
+// compilation mode with an unused host linker flag.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s --cuda-device-only 
-Wl,--disable-new-dtags \
+// RUN: 2>&1 | FileCheck -check-prefixes=HLFDBIN2 %s
+// HLFDBIN2-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], 
(device-[[T]], [[ARCH:gfx803]])
+// HLFDBIN2-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, 
(device-[[T]], [[ARCH]])
+// HLFDBIN2-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], 
[[ARCH]])
+// HLFDBIN2-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], 
[[ARCH]])
+// HLFDBIN2-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], 
[[ARCH]])
+// HLFDBIN2-DAG: [[P5:[0-9]+]]: linker, {[[P4]]}, image, (device-[[T]], 
[[ARCH]])
+// HLFDBIN2-DAG: [[P6:[0-9]+]]: offload, "device-[[T]] 
(amdgcn-amd-amdhsa:[[ARCH]])" {[[P5]]}, image
+// HLFDBIN2-DAG: [[P7:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T]], 
(device-[[T]], [[ARCH2:gfx900]])
+// HLFDBIN2-DAG: [[P8:[0-9]+]]: preprocessor, {[[P7]]}, [[T]]-cpp-output, 
(device-[[T]], [[ARCH2]])
+// HLFDBIN2-DAG: [[P9:[0-9]+]]: compiler, {[[P8]]}, ir, (device-[[T]], 
[[ARCH2]])
+// HLFDBIN2-DAG: [[P10:[0-9]+]]: backend, {[[P9]]}, assembler, (device-[[T]], 
[[ARCH2]])
+// HLFDBIN2-DAG: [[P11:[0-9]+]]: assembler, {[[P10]]}, object, (device-[[T]], 
[[ARCH2]])
+// HLFDBIN2-DAG: [[P12:[0-9]+]]: linker, {[[P11]]}, image, (device-[[T]], 
[[ARCH2]])
+// HLFDBIN2-DAG: [[P13:[0-9]+]]: offload, "device-[[T]] 
(amdgcn-amd-amdhsa:[[ARCH2]])" {[[P12]]}, image
+// HLFDBIN2-DAG: [[P14:[0-9]+]]: linker, {[[P6]], [[P13]]}, hip-fatbin, 
(device-hip, )
+// HLFDBIN2-DAG: [[P15:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:)" 
{[[P14]]}, hip-fatbin
+// HLFDBIN2-NOT: host
+
 //
 // Test two gpu architectures up to the assemble phase in device-only
 // compilation mode.
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4144,8 +4144,10 @@
   if (Phase == phases::Link) {
 assert(Phase == PL.back() && "linking must be final compilation 
step.");
 // We don't need to generate additional link commands if emitting AMD 
bitcode
+// or compiling only for the offload device
 if (!(C.getInputArgs().hasArg(options::OPT_hip_link) &&
- 

[PATCH] D154880: [-Wunsafe-buffer-usage][WIP] Add a facility for debugging low fixit coverage.

2023-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:578
 
-  virtual const Stmt *getBaseStmt() const override { return nullptr; }
+  virtual const Stmt *getBaseStmt() const override { return PtrInitRHS; }
 

I changed this to make `F->getBaseStmt()` available more often, but ran into 
more problems of this kind that were much more strange than this one. I'll 
probably investigate more.


Repository:
  rC Clang

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

https://reviews.llvm.org/D154880

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


[PATCH] D154683: [RISCV] Split __builtin_riscv_brev8 into _32 and _64 builtin.

2023-07-10 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 rG939f818a662a: [RISCV] Split __builtin_riscv_brev8 into _32 
and _64 builtin. (authored by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D154683?vs=537991=538782#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154683

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
@@ -2,7 +2,20 @@
 // RUN: %clang_cc1 -triple riscv64 -target-feature +zbkb -emit-llvm %s -o - \
 // RUN: | FileCheck %s  -check-prefix=RV64ZBKB
 
-// RV64ZBKB-LABEL: @brev8(
+// RV64ZBKB-LABEL: @brev8_32(
+// RV64ZBKB-NEXT:  entry:
+// RV64ZBKB-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZBKB-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
+// RV64ZBKB-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
+// RV64ZBKB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.brev8.i32(i32 
[[TMP0]])
+// RV64ZBKB-NEXT:ret i32 [[TMP1]]
+//
+int brev8_32(int rs1)
+{
+  return __builtin_riscv_brev8_32(rs1);
+}
+
+// RV64ZBKB-LABEL: @brev8_64(
 // RV64ZBKB-NEXT:  entry:
 // RV64ZBKB-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
 // RV64ZBKB-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
@@ -10,7 +23,7 @@
 // RV64ZBKB-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.brev8.i64(i64 
[[TMP0]])
 // RV64ZBKB-NEXT:ret i64 [[TMP1]]
 //
-long brev8(long rs1)
+long brev8_64(long rs1)
 {
-  return __builtin_riscv_brev8(rs1);
+  return __builtin_riscv_brev8_64(rs1);
 }
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
@@ -10,9 +10,9 @@
 // RV32ZBKB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.brev8.i32(i32 
[[TMP0]])
 // RV32ZBKB-NEXT:ret i32 [[TMP1]]
 //
-long brev8(long rs1)
+int brev8(int rs1)
 {
-  return __builtin_riscv_brev8(rs1);
+  return __builtin_riscv_brev8_32(rs1);
 }
 
 // RV32ZBKB-LABEL: @zip(
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -20206,7 +20206,8 @@
   case RISCV::BI__builtin_riscv_xperm4_64:
   case RISCV::BI__builtin_riscv_xperm8_32:
   case RISCV::BI__builtin_riscv_xperm8_64:
-  case RISCV::BI__builtin_riscv_brev8:
+  case RISCV::BI__builtin_riscv_brev8_32:
+  case RISCV::BI__builtin_riscv_brev8_64:
   case RISCV::BI__builtin_riscv_zip_32:
   case RISCV::BI__builtin_riscv_unzip_32: {
 switch (BuiltinID) {
@@ -20257,7 +20258,8 @@
   break;
 
 // Zbkb
-case RISCV::BI__builtin_riscv_brev8:
+case RISCV::BI__builtin_riscv_brev8_32:
+case RISCV::BI__builtin_riscv_brev8_64:
   ID = Intrinsic::riscv_brev8;
   break;
 case RISCV::BI__builtin_riscv_zip_32:
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -35,7 +35,8 @@
 TARGET_BUILTIN(__builtin_riscv_xperm8_64, "WiWiWi", "nc", "zbkx,64bit")
 
 // Zbkb extension
-TARGET_BUILTIN(__builtin_riscv_brev8, "LiLi", "nc", "zbkb")
+TARGET_BUILTIN(__builtin_riscv_brev8_32, "ii", "nc", "zbkb")
+TARGET_BUILTIN(__builtin_riscv_brev8_64, "WiWi", "nc", "zbkb,64bit")
 TARGET_BUILTIN(__builtin_riscv_zip_32, "ZiZi", "nc", "zbkb,32bit")
 TARGET_BUILTIN(__builtin_riscv_unzip_32, "ZiZi", "nc", "zbkb,32bit")
 


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
@@ -2,7 +2,20 @@
 // RUN: %clang_cc1 -triple riscv64 -target-feature +zbkb -emit-llvm %s -o - \
 // RUN: | FileCheck %s  -check-prefix=RV64ZBKB
 
-// RV64ZBKB-LABEL: @brev8(
+// RV64ZBKB-LABEL: @brev8_32(
+// RV64ZBKB-NEXT:  entry:
+// RV64ZBKB-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZBKB-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
+// RV64ZBKB-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
+// RV64ZBKB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.brev8.i32(i32 [[TMP0]])
+// RV64ZBKB-NEXT:ret i32 [[TMP1]]
+//
+int brev8_32(int rs1)
+{
+  return __builtin_riscv_brev8_32(rs1);
+}
+
+// RV64ZBKB-LABEL: 

[clang] 939f818 - [RISCV] Split __builtin_riscv_brev8 into _32 and _64 builtin.

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

Author: Craig Topper
Date: 2023-07-10T13:01:07-07:00
New Revision: 939f818a662a56a3b118e7e4b0656b6f7038adae

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

LOG: [RISCV] Split __builtin_riscv_brev8 into _32 and _64 builtin.

Allow _32 builtin on RV64 since it only brev8+sext.w.

Part of an effort to remove 'long' to mean XLen from the builtin
interface.

Matches the proposal here 
https://github.com/riscv-non-isa/riscv-c-api-doc/pull/44

Reviewed By: asb

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 5ea0b28e676910..4b4c7858d0fa7d 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -35,7 +35,8 @@ TARGET_BUILTIN(__builtin_riscv_xperm8_32, "iii", "nc", 
"zbkx,32bit")
 TARGET_BUILTIN(__builtin_riscv_xperm8_64, "WiWiWi", "nc", "zbkx,64bit")
 
 // Zbkb extension
-TARGET_BUILTIN(__builtin_riscv_brev8, "LiLi", "nc", "zbkb")
+TARGET_BUILTIN(__builtin_riscv_brev8_32, "ii", "nc", "zbkb")
+TARGET_BUILTIN(__builtin_riscv_brev8_64, "WiWi", "nc", "zbkb,64bit")
 TARGET_BUILTIN(__builtin_riscv_zip_32, "ZiZi", "nc", "zbkb,32bit")
 TARGET_BUILTIN(__builtin_riscv_unzip_32, "ZiZi", "nc", "zbkb,32bit")
 

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 97e031b9bb0618..088fb46faee5d8 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -20206,7 +20206,8 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   case RISCV::BI__builtin_riscv_xperm4_64:
   case RISCV::BI__builtin_riscv_xperm8_32:
   case RISCV::BI__builtin_riscv_xperm8_64:
-  case RISCV::BI__builtin_riscv_brev8:
+  case RISCV::BI__builtin_riscv_brev8_32:
+  case RISCV::BI__builtin_riscv_brev8_64:
   case RISCV::BI__builtin_riscv_zip_32:
   case RISCV::BI__builtin_riscv_unzip_32: {
 switch (BuiltinID) {
@@ -20257,7 +20258,8 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   break;
 
 // Zbkb
-case RISCV::BI__builtin_riscv_brev8:
+case RISCV::BI__builtin_riscv_brev8_32:
+case RISCV::BI__builtin_riscv_brev8_64:
   ID = Intrinsic::riscv_brev8;
   break;
 case RISCV::BI__builtin_riscv_zip_32:

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
index 819280d2b0165d..d255ccb2cd2a6f 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
@@ -10,9 +10,9 @@
 // RV32ZBKB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.brev8.i32(i32 
[[TMP0]])
 // RV32ZBKB-NEXT:ret i32 [[TMP1]]
 //
-long brev8(long rs1)
+int brev8(int rs1)
 {
-  return __builtin_riscv_brev8(rs1);
+  return __builtin_riscv_brev8_32(rs1);
 }
 
 // RV32ZBKB-LABEL: @zip(

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
index 84a44e6a24629f..70a05d25ae7a14 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
@@ -2,7 +2,20 @@
 // RUN: %clang_cc1 -triple riscv64 -target-feature +zbkb -emit-llvm %s -o - \
 // RUN: | FileCheck %s  -check-prefix=RV64ZBKB
 
-// RV64ZBKB-LABEL: @brev8(
+// RV64ZBKB-LABEL: @brev8_32(
+// RV64ZBKB-NEXT:  entry:
+// RV64ZBKB-NEXT:[[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZBKB-NEXT:store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4
+// RV64ZBKB-NEXT:[[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4
+// RV64ZBKB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.brev8.i32(i32 
[[TMP0]])
+// RV64ZBKB-NEXT:ret i32 [[TMP1]]
+//
+int brev8_32(int rs1)
+{
+  return __builtin_riscv_brev8_32(rs1);
+}
+
+// RV64ZBKB-LABEL: @brev8_64(
 // RV64ZBKB-NEXT:  entry:
 // RV64ZBKB-NEXT:[[RS1_ADDR:%.*]] = alloca i64, align 8
 // RV64ZBKB-NEXT:store i64 [[RS1:%.*]], ptr [[RS1_ADDR]], align 8
@@ -10,7 +23,7 @@
 // RV64ZBKB-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.brev8.i64(i64 
[[TMP0]])
 // RV64ZBKB-NEXT:ret i64 [[TMP1]]
 //
-long brev8(long rs1)
+long brev8_64(long rs1)
 {
-  return __builtin_riscv_brev8(rs1);
+  return __builtin_riscv_brev8_64(rs1);
 }



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


[PATCH] D154880: [-Wunsafe-buffer-usage][WIP] Add a facility for debugging low fixit coverage.

2023-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: jkorous, t-rasmud, ziqingluo-90, malavikasamak.
Herald added subscribers: steakhal, martong.
Herald added a project: All.
NoQ requested review of this revision.
Herald added a subscriber: wangpc.

This patch adds extra notes to `-Wunsafe-buffer-usage` warnings, which explain 
why a fixit wasn't produced. When applied to a large body of real-world code, 
it'll help us gather statistics that will help us figure out which fixable 
gadgets (or other features of the fixit machine) to "invest" into.

This is a debugging facility intended for developer use only; it is activated 
by passing `-mllvm -debug-only=SafeBuffers` to clang, so it's carefully hidden 
and undiscoverable, and it's only available in builds with assertions.

Offline we've identified the following sources of false negatives which these 
notes can help us categorize:

1. unsafe operation not performed on a supported kind of variable (eg. member 
variable);
2. use site of the unsafe variable not claimed by any fixable gadgets (so we 
need to cover it with a new fixable);
3. one of the "implicated" variables has unclaimed uses (so we can't build the 
implication graph);
4. fixit generation for the declaration of the variable has failed (eg. 
declaration is in a macro);
5. fixit generation for one of the fixable gadgets has failed (eg. the use is 
in a macro).

Currently this patch covers #5; it probably makes sense to cover all of these 
except maybe #1 (this one's usually obvious).


Repository:
  rC Clang

https://reviews.llvm.org/D154880

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-std=c++20 -verify=expected %s
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-mllvm -debug-only=SafeBuffers \
+// RUN:-std=c++20 -verify=expected,debug %s
+
+// A generic -debug would also enable our notes. This is probably fine.
+//
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-std=c++20 -mllvm -debug \
+// RUN:-verify=expected,debug %s
+
+// This test file checks the behavior under the assumption that no fixits
+// were emitted for the test cases. If -Wunsafe-buffer-usage is improved
+// to support these cases (thus failing the test), the test should be changed
+// to showcase a different unsupported example.
+//
+// RUN: %clang_cc1 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions \
+// RUN:-mllvm -debug-only=SafeBuffers \
+// RUN:-std=c++20 -fdiagnostics-parseable-fixits %s \
+// RUN:2>&1 | FileCheck %s
+// CHECK-NOT: fix-it:
+
+// This debugging facility is only available in debug builds.
+//
+// REQUIRES: asserts
+
+void foo() {
+  int *x = new int[10]; // expected-warning{{'x' is an unsafe pointer used for buffer access}}
+  x[5] = 10;// expected-note{{used in buffer access here}}
+  int z = x[-1];// expected-note{{used in buffer access here}} \
+// debug-note{{safe buffers debug: gadget 'ULCArraySubscript' refused to produce a fix}}
+}
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2276,6 +2276,12 @@
   for (const auto  : Fixes)
 FD << F;
 }
+
+#ifndef NDEBUG
+if (areDebugNotesRequested())
+  for (const DebugNote : DebugNotesByVar[Variable])
+S.Diag(Note.first, diag::note_safe_buffer_debug_mode) << Note.second;
+#endif
   }
 
   bool isSafeBufferOptOut(const SourceLocation ) const override {
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -319,6 +319,15 @@
 
   Kind getKind() const { return K; }
 
+#ifndef NDEBUG
+  StringRef getDebugName() const {
+switch (K) {
+#define GADGET(x) case Kind::x: return #x;
+#include "clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def"
+}
+  }
+#endif
+
   virtual bool isWarningGadget() const = 0;
   virtual const Stmt *getBaseStmt() const = 0;
 
@@ -566,7 +575,7 @@
 
   virtual std::optional getFixits(const Strategy ) const override;
 
-  virtual const Stmt *getBaseStmt() const override { return nullptr; }
+  virtual const Stmt *getBaseStmt() const override { return PtrInitRHS; }
 
   virtual 

[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2023-07-10 Thread Justin Cady via Phabricator via cfe-commits
justincady added subscribers: njames93, LegalizeAdulthood, justincady.
justincady added a comment.

This feature appears to have strong user support throughout this review, and a 
lot of people (including myself) seem interested in having it landed.

cc'ing some clang-tidy owners 
:
 @LegalizeAdulthood @carlosgalvezp @njames93

Is there anything blocking this from moving forward? Can we work to get it 
submitted?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D34654

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


[PATCH] D154632: [4/8][RISCV] Add rounding mode control variant for vfmacc, vfnmacc, vfmsac, vfnmsac, vfmadd, vfnmadd, vfmsub, vfnmsub

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154632

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


[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-10 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

In D154484#4483659 , @sstwcw wrote:

> Did you forget about GNU statement expressions?
>
>   if (({
> foo();
> bar();
>   })) {
>   }

I wouldn't haven forgotten it, I've never heard of it.


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

https://reviews.llvm.org/D154484

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


[PATCH] D154631: [3/8][RISCV] Add rounding mode control variant for vfmul, vfdiv, vfrdiv, vfwmul

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

LGTM




Comment at: clang/lib/Sema/SemaChecking.cpp:4824
   case RISCVVector::BI__builtin_rvv_vfwsub_wf_rm_ta:
+  case RISCVVector::BI__builtin_rvv_vfmul_vv_rm_ta:
+  case RISCVVector::BI__builtin_rvv_vfmul_vf_rm_ta:

This needs to be rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154631

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


[PATCH] D154629: [2/8][RISCV] Add rounding mode control variant for vfwadd, vfwsub

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

LGTM




Comment at: llvm/lib/Target/RISCV/RISCVInstrInfo.cpp:2515
+return nullptr;
   case CASE_WIDEOP_OPCODE_LMULS_MF4(FWADD_WV):
+  case CASE_WIDEOP_OPCODE_LMULS_MF4(FWSUB_WV): {

This conflicts with D154245


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154629

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


[PATCH] D153920: [clang] Move the clang formatting job to run-buildbot to fix the CI

2023-07-10 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

This LGTM but the CI has to pass! Also don't forget to undo the changes to 
`buildkite-pipeline.yml`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153920

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


[PATCH] D148216: [UTC] Add fallback support for specific metadata, and check their defs

2023-07-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert requested changes to this revision.
jdoerfert added a comment.
This revision now requires changes to proceed.

I might pull this later today until a fix is available. It makes updates of 
files with globals super cumbersome (you need to manually remove the 
duplicates).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D154681: [RISCV] Split __builtin_riscv_xperm4/8 into separate _32 and _64 builtins.

2023-07-10 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 rGa1b7db3e4ccc: [RISCV] Split __builtin_riscv_xperm4/8 into 
separate _32 and _64 builtins. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154681

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
@@ -15,7 +15,7 @@
 //
 long xperm8(long rs1, long rs2)
 {
-  return __builtin_riscv_xperm8(rs1, rs2);
+  return __builtin_riscv_xperm8_64(rs1, rs2);
 }
 
 // RV64ZBKX-LABEL: @xperm4(
@@ -31,5 +31,5 @@
 //
 long xperm4(long rs1, long rs2)
 {
-  return __builtin_riscv_xperm4(rs1, rs2);
+  return __builtin_riscv_xperm4_64(rs1, rs2);
 }
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
@@ -13,9 +13,9 @@
 // RV32ZBKX-NEXT:[[TMP2:%.*]] = call i32 @llvm.riscv.xperm8.i32(i32 
[[TMP0]], i32 [[TMP1]])
 // RV32ZBKX-NEXT:ret i32 [[TMP2]]
 //
-long xperm8(long rs1, long rs2)
+int xperm8(int rs1, int rs2)
 {
-  return __builtin_riscv_xperm8(rs1, rs2);
+  return __builtin_riscv_xperm8_32(rs1, rs2);
 }
 
 // RV32ZBKX-LABEL: @xperm4(
@@ -29,7 +29,7 @@
 // RV32ZBKX-NEXT:[[TMP2:%.*]] = call i32 @llvm.riscv.xperm4.i32(i32 
[[TMP0]], i32 [[TMP1]])
 // RV32ZBKX-NEXT:ret i32 [[TMP2]]
 //
-long xperm4(long rs1, long rs2)
+int xperm4(int rs1, int rs2)
 {
-  return __builtin_riscv_xperm4(rs1, rs2);
+  return __builtin_riscv_xperm4_32(rs1, rs2);
 }
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -20202,8 +20202,10 @@
   case RISCV::BI__builtin_riscv_clmul:
   case RISCV::BI__builtin_riscv_clmulh:
   case RISCV::BI__builtin_riscv_clmulr:
-  case RISCV::BI__builtin_riscv_xperm4:
-  case RISCV::BI__builtin_riscv_xperm8:
+  case RISCV::BI__builtin_riscv_xperm4_32:
+  case RISCV::BI__builtin_riscv_xperm4_64:
+  case RISCV::BI__builtin_riscv_xperm8_32:
+  case RISCV::BI__builtin_riscv_xperm8_64:
   case RISCV::BI__builtin_riscv_brev8:
   case RISCV::BI__builtin_riscv_zip_32:
   case RISCV::BI__builtin_riscv_unzip_32: {
@@ -20245,10 +20247,12 @@
   break;
 
 // Zbkx
-case RISCV::BI__builtin_riscv_xperm8:
+case RISCV::BI__builtin_riscv_xperm8_32:
+case RISCV::BI__builtin_riscv_xperm8_64:
   ID = Intrinsic::riscv_xperm8;
   break;
-case RISCV::BI__builtin_riscv_xperm4:
+case RISCV::BI__builtin_riscv_xperm4_32:
+case RISCV::BI__builtin_riscv_xperm4_64:
   ID = Intrinsic::riscv_xperm4;
   break;
 
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -29,8 +29,10 @@
 TARGET_BUILTIN(__builtin_riscv_clmulr, "LiLiLi", "nc", "zbc")
 
 // Zbkx
-TARGET_BUILTIN(__builtin_riscv_xperm4, "LiLiLi", "nc", "zbkx")
-TARGET_BUILTIN(__builtin_riscv_xperm8, "LiLiLi", "nc", "zbkx")
+TARGET_BUILTIN(__builtin_riscv_xperm4_32, "iii", "nc", "zbkx,32bit")
+TARGET_BUILTIN(__builtin_riscv_xperm4_64, "WiWiWi", "nc", "zbkx,64bit")
+TARGET_BUILTIN(__builtin_riscv_xperm8_32, "iii", "nc", "zbkx,32bit")
+TARGET_BUILTIN(__builtin_riscv_xperm8_64, "WiWiWi", "nc", "zbkx,64bit")
 
 // Zbkb extension
 TARGET_BUILTIN(__builtin_riscv_brev8, "LiLi", "nc", "zbkb")


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
@@ -15,7 +15,7 @@
 //
 long xperm8(long rs1, long rs2)
 {
-  return __builtin_riscv_xperm8(rs1, rs2);
+  return __builtin_riscv_xperm8_64(rs1, rs2);
 }
 
 // RV64ZBKX-LABEL: @xperm4(
@@ -31,5 +31,5 @@
 //
 long xperm4(long rs1, long rs2)
 {
-  return __builtin_riscv_xperm4(rs1, rs2);
+  return __builtin_riscv_xperm4_64(rs1, rs2);
 }
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
@@ -13,9 +13,9 @@
 // RV32ZBKX-NEXT:[[TMP2:%.*]] = call i32 @llvm.riscv.xperm8.i32(i32 [[TMP0]], i32 

[clang] a1b7db3 - [RISCV] Split __builtin_riscv_xperm4/8 into separate _32 and _64 builtins.

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

Author: Craig Topper
Date: 2023-07-10T12:18:20-07:00
New Revision: a1b7db3e4ccc30b32fb918f7c6c3ff49233ac03d

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

LOG: [RISCV] Split __builtin_riscv_xperm4/8 into separate _32 and _64 builtins.

Part of an effort to remove uses of 'long' to mean XLen from the builtin
interfaces.

Also makes the builtin names match 
https://github.com/riscv-non-isa/riscv-c-api-doc/pull/44.

Reviewed By: asb

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index baae5e82bc59f4..5ea0b28e676910 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -29,8 +29,10 @@ TARGET_BUILTIN(__builtin_riscv_clmulh, "LiLiLi", "nc", 
"zbc|zbkc")
 TARGET_BUILTIN(__builtin_riscv_clmulr, "LiLiLi", "nc", "zbc")
 
 // Zbkx
-TARGET_BUILTIN(__builtin_riscv_xperm4, "LiLiLi", "nc", "zbkx")
-TARGET_BUILTIN(__builtin_riscv_xperm8, "LiLiLi", "nc", "zbkx")
+TARGET_BUILTIN(__builtin_riscv_xperm4_32, "iii", "nc", "zbkx,32bit")
+TARGET_BUILTIN(__builtin_riscv_xperm4_64, "WiWiWi", "nc", "zbkx,64bit")
+TARGET_BUILTIN(__builtin_riscv_xperm8_32, "iii", "nc", "zbkx,32bit")
+TARGET_BUILTIN(__builtin_riscv_xperm8_64, "WiWiWi", "nc", "zbkx,64bit")
 
 // Zbkb extension
 TARGET_BUILTIN(__builtin_riscv_brev8, "LiLi", "nc", "zbkb")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7ea166d0cf0ee6..97e031b9bb0618 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -20202,8 +20202,10 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   case RISCV::BI__builtin_riscv_clmul:
   case RISCV::BI__builtin_riscv_clmulh:
   case RISCV::BI__builtin_riscv_clmulr:
-  case RISCV::BI__builtin_riscv_xperm4:
-  case RISCV::BI__builtin_riscv_xperm8:
+  case RISCV::BI__builtin_riscv_xperm4_32:
+  case RISCV::BI__builtin_riscv_xperm4_64:
+  case RISCV::BI__builtin_riscv_xperm8_32:
+  case RISCV::BI__builtin_riscv_xperm8_64:
   case RISCV::BI__builtin_riscv_brev8:
   case RISCV::BI__builtin_riscv_zip_32:
   case RISCV::BI__builtin_riscv_unzip_32: {
@@ -20245,10 +20247,12 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   break;
 
 // Zbkx
-case RISCV::BI__builtin_riscv_xperm8:
+case RISCV::BI__builtin_riscv_xperm8_32:
+case RISCV::BI__builtin_riscv_xperm8_64:
   ID = Intrinsic::riscv_xperm8;
   break;
-case RISCV::BI__builtin_riscv_xperm4:
+case RISCV::BI__builtin_riscv_xperm4_32:
+case RISCV::BI__builtin_riscv_xperm4_64:
   ID = Intrinsic::riscv_xperm4;
   break;
 

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
index 9634433ac9b28a..dba6b524dc3453 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
@@ -13,9 +13,9 @@
 // RV32ZBKX-NEXT:[[TMP2:%.*]] = call i32 @llvm.riscv.xperm8.i32(i32 
[[TMP0]], i32 [[TMP1]])
 // RV32ZBKX-NEXT:ret i32 [[TMP2]]
 //
-long xperm8(long rs1, long rs2)
+int xperm8(int rs1, int rs2)
 {
-  return __builtin_riscv_xperm8(rs1, rs2);
+  return __builtin_riscv_xperm8_32(rs1, rs2);
 }
 
 // RV32ZBKX-LABEL: @xperm4(
@@ -29,7 +29,7 @@ long xperm8(long rs1, long rs2)
 // RV32ZBKX-NEXT:[[TMP2:%.*]] = call i32 @llvm.riscv.xperm4.i32(i32 
[[TMP0]], i32 [[TMP1]])
 // RV32ZBKX-NEXT:ret i32 [[TMP2]]
 //
-long xperm4(long rs1, long rs2)
+int xperm4(int rs1, int rs2)
 {
-  return __builtin_riscv_xperm4(rs1, rs2);
+  return __builtin_riscv_xperm4_32(rs1, rs2);
 }

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
index 9accbaed2e31cf..95db024309c6a7 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
@@ -15,7 +15,7 @@
 //
 long xperm8(long rs1, long rs2)
 {
-  return __builtin_riscv_xperm8(rs1, rs2);
+  return __builtin_riscv_xperm8_64(rs1, rs2);
 }
 
 // RV64ZBKX-LABEL: @xperm4(
@@ -31,5 +31,5 @@ long xperm8(long rs1, long rs2)
 //
 long xperm4(long rs1, long rs2)
 {
-  return __builtin_riscv_xperm4(rs1, rs2);
+  return __builtin_riscv_xperm4_64(rs1, rs2);
 }



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


[PATCH] D153339: [clang] Support vectors in __builtin_isfpclass

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

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153339

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


[PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: MaskRay.
aaron.ballman added a comment.

Aside from the failing precommit CI test case in C, I think this LGTM. I've 
added @MaskRay as the code owner for the command line option changes in case 
he's got concerns regarding the deprecation/removal plans.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151683

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


[PATCH] D154423: [clang][analyzer] Add all success/failure messages to StdLibraryFunctionsChecker.

2023-07-10 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

In D154423#4485009 , @balazske wrote:

> It would be more simple to handle the standard streams in `StreamChecker` 
> only. [...]

That's a reasonable plan, especially if we can bring that checker out of alpha 
in the foreseeable future. I like that it avoids code duplication.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154423

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


[PATCH] D153969: [clang][ExprConstant] Fix crash on uninitialized base class subobject

2023-07-10 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:2422
+  << BS.getType();
+  Info.Note(BS.getBeginLoc(), 
diag::note_constexpr_base_inherited_here);
+  return false;

aaron.ballman wrote:
> hazohelet wrote:
> > hazohelet wrote:
> > > tbaeder wrote:
> > > > Can you pass `<< BS.getSourceRange()` here? Does that improve things?
> > > Currently, `DiagLoc` points to the variable declaration and the 
> > > `BS.getSourceRange` covers the line where the base class is inherited. 
> > > This causes distant source range and thus unnecessarily many lines of 
> > > snippet printing.
> > > e.g.
> > > ```
> > > struct Base {
> > >   Base() = delete;
> > > };
> > > struct Derived : Base {
> > >   constexpr Derived() {}
> > > };
> > > constexpr Derived dd;
> > > ```
> > > Output:
> > > ```
> > > source.cpp:7:19: error: constexpr variable 'dd' must be initialized by a 
> > > constant expression
> > > 7 | constexpr Derived dd;
> > >   |   ^~
> > > source.cpp:7:19: note: constructor of base class 'Base' is not called
> > > 7 | struct Derived : Base {
> > >   |  
> > > 8 |   constexpr Derived() {}
> > > 9 | };
> > >10 | constexpr Derived dd;
> > >   |   ^
> > > source.cpp:4:18: note: base class inherited here
> > > 4 | struct Derived : Base {
> > >   |  ^
> > > ```
> > > (The line numbers seem incorrect but is already reported in 
> > > https://github.com/llvm/llvm-project/issues/63524)
> > > 
> > > I think we don't need two notes here because the error is already 
> > > pointing to the variable declaration. Having something like the following 
> > > would be succint.
> > > ```
> > > source.cpp:7:19: error: constexpr variable 'dd' must be initialized by a 
> > > constant expression
> > > 7 | constexpr Derived dd;
> > >   |   ^~
> > > source.cpp:4:18: note: constructor of base class 'Base' is not called
> > > 4 | struct Derived : Base {
> > >   |  ^~~~
> > > ```
> > > Providing source range would be beneficial because the inherited class 
> > > often spans in a few lines (the code in the crashing report, for example)
> > Sorry, I was looking at the line above. The distant source range problem 
> > doesn't occur.
> > 
> > I tested another input
> > ```
> > struct Base {
> >   Base() = delete;
> >   constexpr Base(int){}
> > };
> > 
> > struct Derived : Base {
> >   constexpr Derived() {}
> >   constexpr Derived(int n): Base(n) {}
> > };
> > 
> > constexpr Derived darr[3] = {1, Derived(), 3};
> > ```
> > expecting that the `DiagLoc` points to the second initializer `Derived()`, 
> > but it pointed to the same location as the error, so I'm still in favor of 
> > the idea of having a single note here.
> Erich's suggestion in 
> https://github.com/llvm/llvm-project/issues/63496#issuecomment-1607415201 was 
> to continue to evaluate the constructor because there may be further 
> follow-on diagnostics that are relevant and not related to the base class 
> subobject. I tend to agree -- is there a reason why you're not doing that 
> here?
My question 
(https://github.com/llvm/llvm-project/issues/63496#issuecomment-1607177233) was 
whether or not we should utilize constant evaluator even if the evaluated 
expression is a semantically-invalid constructor like the crashing case.
So in my understanding, Erich's suggestion was that we should continue 
utilizing the constant evaluator in these cases, and stopping the evaluator 
here at uninitialized base class subobject is something else.


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

https://reviews.llvm.org/D153969

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


[PATCH] D153969: [clang][ExprConstant] Fix crash on uninitialized base class subobject

2023-07-10 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 538754.
hazohelet marked 3 inline comments as done.
hazohelet added a comment.

Address comments from aaron.ballman

- Added more tests


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

https://reviews.llvm.org/D153969

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/test/Misc/constexpr-subobj-init-source-ranges.cpp
  clang/test/SemaCXX/constexpr-subobj-initialization.cpp

Index: clang/test/SemaCXX/constexpr-subobj-initialization.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-subobj-initialization.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace baseclass_uninit {
+struct DelBase {
+  constexpr DelBase() = delete; // expected-note {{'DelBase' has been explicitly marked deleted here}}
+};
+
+struct Foo : DelBase {  // expected-note 2{{constructor of base class 'DelBase' is not called}}
+  constexpr Foo() {}; // expected-error {{call to deleted constructor of 'DelBase'}}
+};
+constexpr Foo f; // expected-error {{must be initialized by a constant expression}}
+struct Bar : Foo {
+  constexpr Bar() {};
+};
+constexpr Bar bar; // expected-error {{must be initialized by a constant expression}}
+
+struct Base {};
+struct A : Base { // expected-note {{constructor of base class 'Base' is not called}}
+  constexpr A() : value() {} // expected-error {{member initializer 'value' does not name a non-static data member or base class}}
+};
+
+constexpr A a; // expected-error {{must be initialized by a constant expression}}
+
+struct B : Base { // expected-note {{constructor of base class 'Base' is not called}}
+  constexpr B() : {} // expected-error {{expected class member or base class name}}
+};
+
+constexpr B b; // expected-error {{must be initialized by a constant expression}}
+} // namespace baseclass_uninit
+
+
+struct Foo {
+  constexpr Foo(); // expected-note 2{{declared here}}
+};
+
+constexpr Foo ff; // expected-error {{must be initialized by a constant expression}} \
+  // expected-note {{undefined constructor 'Foo' cannot be used in a constant expression}}
+
+struct Bar : protected Foo {
+  int i;
+  constexpr Bar() : i(12) {} // expected-note {{undefined constructor 'Foo' cannot be used in a constant expression}}
+};
+
+constexpr Bar bb; // expected-error {{must be initialized by a constant expression}} \
+  // expected-note {{in call to 'Bar()'}}
+
+template 
+struct Baz {
+  constexpr Baz(); // expected-note {{declared here}}
+};
+
+struct Quux : Baz, private Bar {
+  int i;
+  constexpr Quux() : i(12) {} // expected-note {{undefined constructor 'Baz' cannot be used in a constant expression}}
+};
+
+constexpr Quux qx; // expected-error {{must be initialized by a constant expression}} \
+   // expected-note {{in call to 'Quux()'}}
Index: clang/test/Misc/constexpr-subobj-init-source-ranges.cpp
===
--- /dev/null
+++ clang/test/Misc/constexpr-subobj-init-source-ranges.cpp
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+
+struct DelBase {
+  constexpr DelBase() = delete;
+};
+
+// CHECK:  :{[[@LINE+1]]:21-[[@LINE+1]]:28}
+struct Foo : public DelBase {
+  constexpr Foo() {};
+};
+constexpr Foo f;
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -2415,9 +2415,16 @@
 if (const CXXRecordDecl *CD = dyn_cast(RD)) {
   unsigned BaseIndex = 0;
   for (const CXXBaseSpecifier  : CD->bases()) {
-if (!CheckEvaluationResult(CERK, Info, DiagLoc, BS.getType(),
-   Value.getStructBase(BaseIndex), Kind,
-   /*SubobjectDecl=*/nullptr, CheckedTemps))
+const APValue  = Value.getStructBase(BaseIndex);
+if (!BaseValue.hasValue()) {
+  SourceLocation TypeBeginLoc = BS.getBaseTypeLoc();
+  Info.FFDiag(TypeBeginLoc, diag::note_constexpr_uninitialized_base)
+  << BS.getType() << SourceRange(TypeBeginLoc, BS.getEndLoc());
+  return false;
+}
+if (!CheckEvaluationResult(CERK, Info, DiagLoc, BS.getType(), BaseValue,
+   Kind, /*SubobjectDecl=*/nullptr,
+   CheckedTemps))
   return false;
 ++BaseIndex;
   }
Index: clang/include/clang/Basic/DiagnosticASTKinds.td
===
--- clang/include/clang/Basic/DiagnosticASTKinds.td
+++ clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -70,6 +70,8 @@
   "is not a constant expression">;
 def note_constexpr_uninitialized : Note<
   "subobject %0 is 

[PATCH] D154856: [MemProf] Use new option/pass for profile feedback and matching

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



Comment at: llvm/lib/Transforms/Instrumentation/MemProfiler.cpp:912
+const TargetLibraryInfo  = FAM.getResult(F);
+readMemprof(M, F, MemProfReader.get(), TLI);
+  }

tejohnson wrote:
> snehasish wrote:
> > I think we can we split this patch into two to make the changes clearer. 
> > Consider the following -- 
> > 
> > First move the readMemprof and its callees to MemProfiler.cpp and call it 
> > from the original code. Also in this step consider using Error as the 
> > return type of readMemprof, right now the bool returned is ignored. Using 
> > Error doesn't need to be fatal, we can handle it and emit a warning but it 
> > would enforce the check I think.
> > 
> > Second, add the pass to MemProfiler and all the related options/plumbing.
> > 
> > What do you think? 
> Ok let me try that. I think actually readMemprof should have a void return. 
> The only time we are returning false the error has already been handled 
> within readMemprof itself.
D154872. I will rebase this patch once that is committed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154856

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


[PATCH] D153926: [NFC] Initialize class member pointers to nullptr.

2023-07-10 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir added a comment.

Thank you for reviewing. This patch is now landed.


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

https://reviews.llvm.org/D153926

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


[clang] 5942ae8 - [NFC] Initialize class member pointers to nullptr.

2023-07-10 Thread Sindhu Chittireddy via cfe-commits

Author: Sindhu Chittireddy
Date: 2023-07-10T11:38:55-07:00
New Revision: 5942ae8681db20822ac3e0b94cf8089d30647a39

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

LOG: [NFC] Initialize class member pointers to nullptr.

Reviewed here: https://reviews.llvm.org/D153926

Added: 


Modified: 
clang/include/clang/AST/RawCommentList.h
clang/include/clang/AST/Redeclarable.h
clang/include/clang/CodeGen/CodeGenAction.h
clang/include/clang/Sema/HLSLExternalSemaSource.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ModuleFile.h
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Format/SortJavaScriptImports.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp

Removed: 




diff  --git a/clang/include/clang/AST/RawCommentList.h 
b/clang/include/clang/AST/RawCommentList.h
index a293e219e25020..2f44a77d4503d3 100644
--- a/clang/include/clang/AST/RawCommentList.h
+++ b/clang/include/clang/AST/RawCommentList.h
@@ -173,7 +173,7 @@ class RawComment {
   SourceRange Range;
 
   mutable StringRef RawText;
-  mutable const char *BriefText;
+  mutable const char *BriefText = nullptr;
 
   mutable bool RawTextValid : 1;   ///< True if RawText is valid
   mutable bool BriefTextValid : 1; ///< True if BriefText is valid

diff  --git a/clang/include/clang/AST/Redeclarable.h 
b/clang/include/clang/AST/Redeclarable.h
index 58ec07973920cb..091bb886f2d496 100644
--- a/clang/include/clang/AST/Redeclarable.h
+++ b/clang/include/clang/AST/Redeclarable.h
@@ -240,7 +240,7 @@ class Redeclarable {
   class redecl_iterator {
 /// Current - The current declaration.
 decl_type *Current = nullptr;
-decl_type *Starter;
+decl_type *Starter = nullptr;
 bool PassedFirst = false;
 
   public:

diff  --git a/clang/include/clang/CodeGen/CodeGenAction.h 
b/clang/include/clang/CodeGen/CodeGenAction.h
index 821e80919fc849..7ad2988e589eb2 100644
--- a/clang/include/clang/CodeGen/CodeGenAction.h
+++ b/clang/include/clang/CodeGen/CodeGenAction.h
@@ -83,7 +83,7 @@ class CodeGenAction : public ASTFrontendAction {
 
   CodeGenerator *getCodeGenerator() const;
 
-  BackendConsumer *BEConsumer;
+  BackendConsumer *BEConsumer = nullptr;
 };
 
 class EmitAssemblyAction : public CodeGenAction {

diff  --git a/clang/include/clang/Sema/HLSLExternalSemaSource.h 
b/clang/include/clang/Sema/HLSLExternalSemaSource.h
index 8531609bb9e0d6..4b6bc96f72e225 100644
--- a/clang/include/clang/Sema/HLSLExternalSemaSource.h
+++ b/clang/include/clang/Sema/HLSLExternalSemaSource.h
@@ -23,7 +23,7 @@ class Sema;
 class HLSLExternalSemaSource : public ExternalSemaSource {
   Sema *SemaPtr = nullptr;
   NamespaceDecl *HLSLNamespace = nullptr;
-  CXXRecordDecl *ResourceDecl;
+  CXXRecordDecl *ResourceDecl = nullptr;
 
   using CompletionFunction = std::function;
   llvm::DenseMap Completions;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6f413d1c9a6fa3..dbc071bf5cd838 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -943,7 +943,7 @@ class Sema final {
   class DelayedDiagnostics;
 
   class DelayedDiagnosticsState {
-sema::DelayedDiagnosticPool *SavedPool;
+sema::DelayedDiagnosticPool *SavedPool = nullptr;
 friend class Sema::DelayedDiagnostics;
   };
   typedef DelayedDiagnosticsState ParsingDeclState;

diff  --git a/clang/include/clang/Serialization/ModuleFile.h 
b/clang/include/clang/Serialization/ModuleFile.h
index e96f3ce06c2ceb..b632b4e3e7a7ce 100644
--- a/clang/include/clang/Serialization/ModuleFile.h
+++ b/clang/include/clang/Serialization/ModuleFile.h
@@ -196,7 +196,7 @@ class ModuleFile {
 
   /// The memory buffer that stores the data associated with
   /// this AST file, owned by the InMemoryModuleCache.
-  llvm::MemoryBuffer *Buffer;
+  llvm::MemoryBuffer *Buffer = nullptr;
 
   /// The size of this file, in bits.
   uint64_t SizeInBits = 0;

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index e52f44b61a9464..1debbbf57fe6b9 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -318,10 +318,10 @@ class CodeGenFunction : public CodeGenTypeCache {
 
   /// CurFuncDecl - Holds the Decl for the current outermost
   /// non-closure context.
-  const Decl *CurFuncDecl;
+  const Decl *CurFuncDecl = nullptr;
   /// CurCodeDecl - This is the inner-most code context, which includes blocks.
-  const Decl *CurCodeDecl;
-  const CGFunctionInfo *CurFnInfo;
+  const Decl *CurCodeDecl = nullptr;
+  const CGFunctionInfo *CurFnInfo = nullptr;
   QualType FnRetTy;
   llvm::Function *CurFn = nullptr;
 

[PATCH] D153881: Create diagnostic group for definition deprecation warning

2023-07-10 Thread Nuri Amari via Phabricator via cfe-commits
nuriamari added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:373
   (`#13920: `_)
+- A new diagnostic warning group ``deprecated-redundant-constexpr-static-def`` 
is
+  added. This is to be used to control warnings about out-of-line definitions 
of

Happy to use a better flag name, if anyone has ideas. Considered expanding to 
be more descriptive, but its already quite long.



Comment at: 
clang/test/SemaCXX/redundant-out-of-line-static-constexpr-member-def-diag.cpp:9
+  constexpr int A::n; // expected-warning{{out-of-line definition of constexpr 
static data member is redundant in C++17 and is deprecated}}
+  const int A::m; // expected-warning{{out-of-line definition of constexpr 
static data member is redundant in C++17 and is deprecated}}
+}

Unbeknownst to me, the `const` variant of this diagnostic (still about a static 
constexpr member, but defined out-of-line with const) is already controlled via 
the same diagnostic group. Is this the behavior you expect @aaron.ballman?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153881

___
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-10 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir added a comment.

Thank you all for reviewing.


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


[PATCH] D153881: Create diagnostic group for definition deprecation warning

2023-07-10 Thread Nuri Amari via Phabricator via cfe-commits
nuriamari updated this revision to Diff 538751.
nuriamari added a comment.

- Create entry in release notes
- Move test to appropriate location
- Expand test to include `const` warning controlled in the same warning group


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153881

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/SemaCXX/redundant-out-of-line-static-constexpr-member-def-diag.cpp


Index: 
clang/test/SemaCXX/redundant-out-of-line-static-constexpr-member-def-diag.cpp
===
--- /dev/null
+++ 
clang/test/SemaCXX/redundant-out-of-line-static-constexpr-member-def-diag.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s -Werror -Wdeprecated 
-Wno-error=deprecated-redundant-constexpr-static-def
+
+namespace {
+  struct A {
+static constexpr int n = 0;
+static constexpr int m = 0;
+  };
+  constexpr int A::n; // expected-warning{{out-of-line definition of constexpr 
static data member is redundant in C++17 and is deprecated}}
+  const int A::m; // expected-warning{{out-of-line definition of constexpr 
static data member is redundant in C++17 and is deprecated}}
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -450,7 +450,7 @@
 def warn_deprecated_redundant_constexpr_static_def : Warning<
   "out-of-line definition of constexpr static data member is redundant "
   "in C++17 and is deprecated">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 
 def warn_decl_shadow :
   Warning<"declaration shadows a %select{"
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -186,6 +186,7 @@
 // For compatibility with GCC.
 def : DiagGroup<"deprecated-copy-dtor", [DeprecatedCopyWithDtor]>;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
+def DeprecatedRedundantConstexprStaticDef : 
DiagGroup<"deprecated-redundant-constexpr-static-def">;
 def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
 def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">;
 def UnguardedAvailability : DiagGroup<"unguarded-availability",
@@ -224,7 +225,9 @@
   DeprecatedThisCapture,
   DeprecatedType,
   DeprecatedVolatile,
-  DeprecatedWritableStr]>,
+  DeprecatedWritableStr,
+  
DeprecatedRedundantConstexprStaticDef,
+  ]>,
  DiagCategory<"Deprecations">;
 
 def CXX20Designator : DiagGroup<"c++20-designator">;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -370,6 +370,10 @@
 - Clang now diagnoses unexpected tokens after a
   ``#pragma clang|GCC diagnostic push|pop`` directive.
   (`#13920: `_)
+- A new diagnostic warning group ``deprecated-redundant-constexpr-static-def`` 
is
+  added. This is to be used to control warnings about out-of-line definitions 
of
+  static constexpr members that are unnecessary with ``-std=C++17`` onwards. 
The
+  diagnostic was previously only controllable via `-Wdeprecated`.
 
 Bug Fixes in This Version
 -


Index: clang/test/SemaCXX/redundant-out-of-line-static-constexpr-member-def-diag.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/redundant-out-of-line-static-constexpr-member-def-diag.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s -Werror -Wdeprecated -Wno-error=deprecated-redundant-constexpr-static-def
+
+namespace {
+  struct A {
+static constexpr int n = 0;
+static constexpr int m = 0;
+  };
+  constexpr int A::n; // expected-warning{{out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated}}
+  const int A::m; // expected-warning{{out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated}}
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -450,7 +450,7 @@
 def warn_deprecated_redundant_constexpr_static_def : 

[clang] fd857f7 - [NFC] Initialize pointer fields and remove needless null check.

2023-07-10 Thread Sindhu Chittireddy via cfe-commits

Author: Sindhu Chittireddy
Date: 2023-07-10T11:32:13-07:00
New Revision: fd857f786f61620c370d132fe9ba1b5608bb4f50

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

LOG: [NFC] Initialize pointer fields and remove needless null check.

Reviewed here: https://reviews.llvm.org/D153589

Added: 


Modified: 
clang/lib/Analysis/CFG.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/lib/Lex/PPExpressions.cpp
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Removed: 




diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index b0f44ec0edcbbb..3f2367fafc88f7 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -4152,7 +4152,7 @@ CFGBlock *CFGBuilder::VisitCXXTypeidExpr(CXXTypeidExpr 
*S, AddStmtChoice asc) {
   //   operand. [...]
   // We add only potentially evaluated statements to the block to avoid
   // CFG generation for unevaluated operands.
-  if (S && !S->isTypeDependent() && S->isPotentiallyEvaluated())
+  if (!S->isTypeDependent() && S->isPotentiallyEvaluated())
 return VisitChildren(S);
 
   // Return block without CFG for unevaluated operands.

diff  --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index c7b193e34ea0a3..09b6c3ac6adf41 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -46,17 +46,13 @@ namespace {
 /// types and the function declaration into a module if they're not used, and
 /// avoids constructing the type more than once if it's used more than once.
 class LazyRuntimeFunction {
-  CodeGenModule *CGM;
-  llvm::FunctionType *FTy;
-  const char *FunctionName;
-  llvm::FunctionCallee Function;
+  CodeGenModule *CGM = nullptr;
+  llvm::FunctionType *FTy = nullptr;
+  const char *FunctionName = nullptr;
+  llvm::FunctionCallee Function = nullptr;
 
 public:
-  /// Constructor leaves this class uninitialized, because it is intended to
-  /// be used as a field in another class and not all of the types that are
-  /// used as arguments will necessarily be available at construction time.
-  LazyRuntimeFunction()
-  : CGM(nullptr), FunctionName(nullptr), Function(nullptr) {}
+  LazyRuntimeFunction() = default;
 
   /// Initialises the lazy function with the name, return type, and the types
   /// of the arguments.

diff  --git a/clang/lib/Format/UnwrappedLineParser.h 
b/clang/lib/Format/UnwrappedLineParser.h
index 9650ce1a9c1583..311d879b0a0881 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -306,7 +306,7 @@ class UnwrappedLineParser {
   // Since the next token might already be in a new unwrapped line, we need to
   // store the comments belonging to that token.
   SmallVector CommentsBeforeNextToken;
-  FormatToken *FormatTok;
+  FormatToken *FormatTok = nullptr;
   bool MustBreakBeforeNextToken;
 
   // The parsed lines. Only added to through \c CurrentLines.

diff  --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 6c935148f40726..7c41dd510d2dba 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -44,7 +44,7 @@ namespace {
 /// conditional and the source range covered by it.
 class PPValue {
   SourceRange Range;
-  IdentifierInfo *II;
+  IdentifierInfo *II = nullptr;
 
 public:
   llvm::APSInt Val;

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 1bf6592ee6d8e0..51ae0506466a7d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -84,7 +84,7 @@ class CStringChecker : public Checker< eval::Call,
   mutable std::unique_ptr BT_Null, BT_Bounds, BT_Overlap,
   BT_NotCString, BT_AdditionOverflow, BT_UninitRead;
 
-  mutable const char *CurrentFunctionDescription;
+  mutable const char *CurrentFunctionDescription = nullptr;
 
 public:
   /// The filter is used to filter out the diagnostics which are not enabled by



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


[PATCH] D152996: [RISCV][POC] Model frm control for vfadd

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

I think this conflicts with https://reviews.llvm.org/D154245


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152996

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


[clang] 9c96cc9 - Clang 17 isn't not yet released; NFC

2023-07-10 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-07-10T14:28:22-04:00
New Revision: 9c96cc96e3c2cafebdb314f19c50bdb9f63348a6

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

LOG: Clang 17 isn't not yet released; NFC

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 06fb116da9e72a..e27c0c7ed31752 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -693,7 +693,7 @@ C++20 implementation status
 
   Immediate functions (consteval)
   https://wg21.link/p1073r3;>P1073R3
-  Clang 17
+  Clang 17
 

 https://wg21.link/p1937r2;>P1937R2



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


[PATCH] D154871: [clang] Satisfy clang v12

2023-07-10 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Looks reasonable.
Unfortunate that it regresses readability by a pair of parents. Anyway LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154871

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


[PATCH] D154869: [Flang] [FlangRT] Implement FlangRT library as solution to Flang's runtime LLVM integration

2023-07-10 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 538749.
pscoro added a comment.

Comment out some code that irrelevant to current object library approach


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154869

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  flang-rt/CMakeLists.txt
  flang-rt/src/dummy.cpp
  flang/cmake/modules/AddFlang.cmake
  flang/include/flang/Runtime/float128.h
  flang/lib/Decimal/CMakeLists.txt
  flang/runtime/CMakeLists.txt
  flang/test/CMakeLists.txt
  flang/test/Driver/linker-flags.f90
  flang/test/lit.cfg.py
  lld/COFF/MinGW.cpp
  llvm/CMakeLists.txt
  runtimes/CMakeLists.txt

Index: runtimes/CMakeLists.txt
===
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -19,7 +19,7 @@
 
 # We order libraries to mirror roughly how they are layered, except that compiler-rt can depend
 # on libc++, so we put it after.
-set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp")
+set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;flang-rt")
 set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -149,7 +149,10 @@
 # As we migrate runtimes to using the bootstrapping build, the set of default runtimes
 # should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
 set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind")
-set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc")
+if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
+  set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind;flang-rt")
+endif()
+set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;flang-rt")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
 if(LLVM_ENABLE_RUNTIMES STREQUAL "all")
Index: lld/COFF/MinGW.cpp
===
--- lld/COFF/MinGW.cpp
+++ lld/COFF/MinGW.cpp
@@ -50,8 +50,7 @@
   "libc++",
   "libc++abi",
   "libFortran_main",
-  "libFortranRuntime",
-  "libFortranDecimal",
+  "libFlangRT",
   "libunwind",
   "libmsvcrt",
   "libucrtbase",
Index: flang/test/lit.cfg.py
===
--- flang/test/lit.cfg.py
+++ flang/test/lit.cfg.py
@@ -153,19 +153,16 @@
 # the C++ runtime libraries. For this we need a C compiler. If for some reason
 # we don't have one, we can just disable the test.
 if config.cc:
-libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
-libdecimal = os.path.join(config.flang_lib_dir, "libFortranDecimal.a")
+libruntime = os.path.join(config.flang_lib_dir, "libFlangRT.a")
 include = os.path.join(config.flang_src_dir, "include")
 
 if (
 os.path.isfile(libruntime)
-and os.path.isfile(libdecimal)
 and os.path.isdir(include)
 ):
 config.available_features.add("c-compiler")
 tools.append(ToolSubst("%cc", command=config.cc, unresolved="fatal"))
 tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
-tools.append(ToolSubst("%libdecimal", command=libdecimal, unresolved="fatal"))
 tools.append(ToolSubst("%include", command=include, unresolved="fatal"))
 
 # Add all the tools and their substitutions (if applicable). Use the search paths provided for
Index: flang/test/Driver/linker-flags.f90
===
--- flang/test/Driver/linker-flags.f90
+++ flang/test/Driver/linker-flags.f90
@@ -24,21 +24,18 @@
 ! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! GNU-SAME: "[[object_file]]"
 ! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
+! GNU-SAME: -lFlangRT
 ! GNU-SAME: -lm
 
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"
 ! DARWIN-SAME: -lFortran_main
-! DARWIN-SAME: -lFortranRuntime
-! DARWIN-SAME: -lFortranDecimal
+! DARWIN-SAME: -lFlangRT
 
 ! MINGW-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! MINGW-SAME: "[[object_file]]"
 ! MINGW-SAME: -lFortran_main
-! MINGW-SAME: -lFortranRuntime
-! MINGW-SAME: -lFortranDecimal
+! MINGW-SAME: -lFlangRT
 
 ! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
 !   any .exe suffix that is added when resolving to the full path of
@@ -46,7 +43,6 @@
 !   when the executable is not found or on non-Windows platforms.
 ! 

[PATCH] D152996: [RISCV][POC] Model frm control for vfadd

2023-07-10 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 538748.
eopXD added a comment.

Fix bug, should be checking MI.readsRegister(RISCV::FRM) under 
AdjustInstrPostInstrSelection.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152996

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfadd-out-of-range.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/alloca-load-store-scalable-struct.ll
  llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fmf.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/rv32-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rv64-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-masked-vops.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vfadd.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll

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


[PATCH] D154871: [clang] Satisfy clang v12

2023-07-10 Thread Ashay Rane via Phabricator via cfe-commits
ashay-github created this revision.
ashay-github added reviewers: steakhal, xazax.hun, Szelethus.
Herald added a subscriber: martong.
Herald added a reviewer: NoQ.
Herald added a project: All.
ashay-github requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Older versions of clang (for example, v12) throw an error when compiling
CStringChecker.cpp that the initializers for `SourceArgExpr`,
`DestinationArgExpr`, and `SizeArgExpr` are missing braces around
initialization of subobject.  Newer clang versions don't throw this
error.  This patch adds the initialization braces to satisfy clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154871

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1372,9 +1372,9 @@
 CharKind CK) const {
   // void *memcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is the address of the destination buffer.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   ProgramStateRef State = C.getState();
 
@@ -1387,9 +1387,9 @@
  CharKind CK) const {
   // void *mempcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is a pointer to the byte following the last written byte.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = true;
   constexpr bool IsMempcpy = true;
@@ -1401,9 +1401,9 @@
  CharKind CK) const {
   // void *memmove(void *dst, const void *src, size_t n);
   // The return value is the address of the destination buffer.
-  DestinationArgExpr Dest = {CE->getArg(0), 0};
-  SourceArgExpr Src = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  DestinationArgExpr Dest = {{CE->getArg(0), 0}};
+  SourceArgExpr Src = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = false;
   constexpr bool IsMempcpy = false;
@@ -1413,9 +1413,9 @@
 
 void CStringChecker::evalBcopy(CheckerContext , const CallExpr *CE) const {
   // void bcopy(const void *src, void *dst, size_t n);
-  SourceArgExpr Src{CE->getArg(0), 0};
-  DestinationArgExpr Dest = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  SourceArgExpr Src{{CE->getArg(0), 0}};
+  DestinationArgExpr Dest = {{CE->getArg(1), 1}};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   constexpr bool IsRestricted = false;
   constexpr bool IsMempcpy = false;
@@ -1430,7 +1430,7 @@
 
   AnyArgExpr Left = {CE->getArg(0), 0};
   AnyArgExpr Right = {CE->getArg(1), 1};
-  SizeArgExpr Size = {CE->getArg(2), 2};
+  SizeArgExpr Size = {{CE->getArg(2), 2}};
 
   ProgramStateRef State = C.getState();
   SValBuilder  = C.getSValBuilder();
@@ -1698,14 +1698,14 @@
   const LocationContext *LCtx = C.getLocationContext();
 
   // Check that the destination is non-null.
-  DestinationArgExpr Dst = {CE->getArg(0), 0};
+  DestinationArgExpr Dst = {{CE->getArg(0), 0}};
   SVal DstVal = state->getSVal(Dst.Expression, LCtx);
   state = checkNonNull(C, state, Dst, DstVal);
   if (!state)
 return;
 
   // Check that the source is non-null.
-  SourceArgExpr srcExpr = {CE->getArg(1), 1};
+  SourceArgExpr srcExpr = {{CE->getArg(1), 1}};
   SVal srcVal = state->getSVal(srcExpr.Expression, LCtx);
   state = checkNonNull(C, state, srcExpr, srcVal);
   if (!state)
@@ -1736,10 +1736,11 @@
 
   // FIXME: Why do we choose the srcExpr if the access has no size?
   //  Note that the 3rd argument of the call would be the size parameter.
-  SizeArgExpr SrcExprAsSizeDummy = {srcExpr.Expression, srcExpr.ArgumentIndex};
+  SizeArgExpr SrcExprAsSizeDummy = {
+  {srcExpr.Expression, srcExpr.ArgumentIndex}};
   state = CheckOverlap(
   C, state,
-  (IsBounded ? SizeArgExpr{CE->getArg(2), 2} : SrcExprAsSizeDummy), Dst,
+  (IsBounded ? SizeArgExpr{{CE->getArg(2), 2}} : SrcExprAsSizeDummy), Dst,
   srcExpr);
 
   if (!state)
@@ -1748,7 +1749,7 @@
   // If the function is strncpy, strncat, etc... it is bounded.
   if (IsBounded) {
 // Get the max number of characters to copy.
-SizeArgExpr lenExpr = {CE->getArg(2), 2};
+SizeArgExpr lenExpr = {{CE->getArg(2), 2}};
 SVal lenVal = state->getSVal(lenExpr.Expression, LCtx);
 

[PATCH] D154628: [1/8][RISCV] Add rounding mode control variant for vfsub, vfrsub

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154628

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


[PATCH] D154628: [1/8][RISCV] Add rounding mode control variant for vfsub, vfrsub

2023-07-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:4813
   case RISCVVector::BI__builtin_rvv_vfadd_vf_rm_ta:
+  case RISCVVector::BI__builtin_rvv_vfsub_vv_rm_ta:
+  case RISCVVector::BI__builtin_rvv_vfsub_vf_rm_ta:

This needs to rebased after removing _ta?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154628

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


[PATCH] D131533: [Flang][Driver] Enable PIC in the frontend

2023-07-10 Thread Valentin Clement via Phabricator via cfe-commits
clementval added inline comments.



Comment at: flang/test/Driver/pic-flags.f90:3
 
-! RUN: %flang -### %s --target=aarch64-linux-gnu 2>&1 | FileCheck %s 
--check-prefix=CHECK-NOPIE
-! RUN: %flang -### %s --target=aarch64-linux-gnu -fno-pie 2>&1 | FileCheck %s 
--check-prefix=CHECK-NOPIE
+! RUN: %flang -v -S -emit-llvm -o - %s --target=aarch64-linux-gnu 2>&1 | 
FileCheck %s --check-prefixes=CHECK,CHECK-PIE-LEVEL2,CHECK-PIE-LEVEL2-IR
+! RUN: %flang -v -S -emit-llvm -o - %s --target=aarch64-linux-gnu -fpie 2>&1 | 
FileCheck %s --check-prefixes=CHECK,CHECK-PIE-LEVEL1,CHECK-PIE-LEVEL1-IR

awarzynski wrote:
> clementval wrote:
> > This test has been failing on my side for very long time. Just curious why 
> > we check for PIE-LEVEL-2 when no level is given. Where is the default given?
> > 
> > On my machine I have `-mrelocation-model static` for this run line. 
> > This test has been failing on my side for very long time. 
> 
> If this is failing for you then it should also fail on one of the Flang 
> buildbots, right? Do you know what's different/special in your configuration?
> 
> > Where is the default given?
> 
> You want to check:
> * [[ 
> https://github.com/llvm/llvm-project/blob/2712b2805b47f10b3864ab19a4016ea306126ad7/clang/lib/Driver/ToolChains/Flang.cpp#L149-L168
>  | Flang::addPicOption ]] (Flang.cpp)
> * [[ 
> https://github.com/llvm/llvm-project/blob/2712b2805b47f10b3864ab19a4016ea306126ad7/clang/lib/Driver/ToolChains/CommonArgs.cpp#L1399
>  | ParsePICArgs ]] (CommonArgs.cpp)
>If this is failing for you then it should also fail on one of the Flang 
>buildbots, right? Do you know what's different/special in your configuration?

Well I probably have a config that is not in any buildbot. 

In my configuration the PICLevel is 0 for `flang-new -v -S -emit-llvm -o - 
/local/home/vclement/llvm-project/flang/test/Driver/pic-flags.f90 
--target=aarch64-linux-gnu 2>&1`

Which makes sense since no pic option is given. I'm wondering how it default to 
2 on buildbot. I'll try to investigate. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131533

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


  1   2   3   >