[PATCH] D144911: adding bf16 support to NVPTX

2023-06-08 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam updated this revision to Diff 529515.
kushanam added a comment.

updating the bf16 resigter types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144911

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp
  llvm/lib/Target/NVPTX/NVPTXMCExpr.h
  llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
  llvm/lib/Target/NVPTX/NVPTXSubtarget.h
  llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
  llvm/test/CodeGen/NVPTX/bf16-instructions.ll

Index: llvm/test/CodeGen/NVPTX/bf16-instructions.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/bf16-instructions.ll
@@ -0,0 +1,89 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck %s
+; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
+
+
+; CHECK-LABEL: test_fadd(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fadd_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fadd_param_1];
+; CHECK-NEXT: add.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fadd(bfloat %0, bfloat %1) {
+  %3 = fadd bfloat %0, %1
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_fsub(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fsub_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fsub_param_1];
+; CHECK-NEXT: sub.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fsub(bfloat %0, bfloat %1) {
+  %3 = fsub bfloat %0, %1
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_faddx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_faddx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_faddx2_param_1];
+; CHECK-NEXT: add.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_faddx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fadd <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fsubx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fsubx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fsubx2_param_1];
+; CHECK-NEXT: sub.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fsubx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fsub <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fmulx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fmulx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fmulx2_param_1];
+; CHECK-NEXT: mul.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fmul(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fmul <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fdiv(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fdiv_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fdiv_param_1];
+; CHECK-DAG:  mov.b32 {[[A0:%h[0-9]+]], [[A1:%h[0-9]+]]}, [[A]]
+; CHECK-DAG:  mov.b32 {[[B0:%h[0-9]+]], [[B1:%h[0-9]+]]}, [[B]]
+; CHECK-DAG:  cvt.f32.bf16 [[FA0:%f[0-9]+]], [[A0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FA1:%f[0-9]+]], [[A1]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB0:%f[0-9]+]], [[B0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB1:%f[0-9]+]], [[B1]];
+; CHECK-DAG:  div.rn.f32  [[FR0:%f[0-9]+]], [[FA0]], [[FB0]];
+; CHECK-DAG:  div.rn.f32  [[FR1:%f[0-9]+]], [[FA1]], [[FB1]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R0:%h[0-9]+]], [[FR0]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R1:%h[0-9]+]], [[FR1]];
+; CHECK-NEXT: mov.b32 [[R:%hh[0-9]+]], {[[R0]], [[R1]]}
+; CHECK-NEXT: st.param.b32[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define <2 x bfloat> @test_fdiv(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fdiv <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
Index: llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
+++ llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
@@ -204,6 +204,14 @@
   return {Intrinsic::fma, FTZ_MustBeOff, true};
 case Intrinsic::nvvm_fma_rn_ftz_f16x2:
   return {Intrinsic::fma, FTZ_MustBeOn, true};
+case Intrinsic::nvvm_fma_rn_bf16:
+  return {Intrinsic::fma, FTZ_

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

2023-06-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142933

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


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

2023-06-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142986

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


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

2023-06-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143059

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


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

2023-06-08 Thread Sedenion via Phabricator via cfe-commits
Sedeniono updated this revision to Diff 529517.
Sedeniono added a comment.

Reformatted comment as requested.


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

https://reviews.llvm.org/D151047

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -166,11 +166,10 @@
   const AdditionalKeywords &Keywords;
   const unsigned AdditionalIndent;
 
-  /// The indent in characters for each level.
-  /// It remembers the indent of previous lines (that are not PP directives) of
-  /// equal or lower levels. This is used to align formatted lines to the 
indent
-  /// of previous non-formatted lines. Think about the --lines parameter of
-  /// clang-format.
+  /// The indent in characters for each level. It remembers the indent of
+  /// previous lines (that are not PP directives) of equal or lower levels. 
This
+  /// is used to align formatted lines to the indent of previous non-formatted
+  /// lines. Think about the --lines parameter of clang-format.
   SmallVector IndentForLevel;
 
   /// Offset of the current line relative to the indent level.


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -166,11 +166,10 @@
   const AdditionalKeywords &Keywords;
   const unsigned AdditionalIndent;
 
-  /// The indent in characters for each level.
-  /// It remembers the indent of previous lines (that are not PP directives) of
-  /// equal or lower levels. This is used to align formatted lines to the indent
-  /// of previous non-formatted lines. Think about the --lines parameter of
-  /// clang-format.
+  /// The indent in characters for each level. It remembers the indent of
+  /// previous lines (that are not PP directives) of equal or lower levels. This
+  /// is used to align formatted lines to the indent of previous non-formatted
+  /// lines. Think about the --lines parameter of clang-format.
   SmallVector IndentForLevel;
 
   /// Offset of the current line relative to the indent level.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-06-08 Thread Sedenion via Phabricator via cfe-commits
Sedeniono marked an inline comment as done.
Sedeniono added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:80
+  // directive, since these do not terminate a code block.
+  if (!Line.InPPDirective && Line.Level < IndentForLevel.size())
+IndentForLevel.resize(Line.Level + 1, -1);

HazardyKnusperkeks wrote:
> Do we need this check? I assume `resize` has a check if it has to grow or 
> shrink, so we would check twice when the size is to be changed and once if 
> not.
The `Line.Level < IndentForLevel.size()` is not necessary because of lines 
63+64. `resize` itself can both grow and shrink the container. 
If `Line.Level >= IndentForLevel.size()` and we omit the `Line.Level < 
IndentForLevel.size()` in line 80, then the `resize()` in line 81 does nothing 
because the container already has the size `Line.Level+1`.

I just added the check in line 80 because I thought it made the intention more 
clear and explicit: Forget indent levels when going to smaller levels.
Still, I can of course remove it again. Should I?



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:169-170
 
   /// The indent in characters for each level.
+  /// It remembers the indent of previous lines (that are not PP directives) of
+  /// equal or lower levels. This is used to align formatted lines to the 
indent

HazardyKnusperkeks wrote:
> And then reformat the comment.
Done.



Comment at: clang/unittests/Format/FormatTestSelective.cpp:663
+"#define some\n" // Formatted line
+"#endif\n"   // That this line is also formatted might be a 
bug.
+"}};", // Dito: Bug?

HazardyKnusperkeks wrote:
> Have you tried to see what is causing this?
Yes: It is caused by the `ContinueFormatting` in 
`UnwrappedLineFormatter::format()`, [see 
here](https://github.com/llvm/llvm-project/blob/8abbc96885c836de6912a5f4327519c09f4e528a/clang/lib/Format/UnwrappedLineFormatter.cpp#L1332C4-L1335).
 If that flag is true, clang-format changes the formatting of lines that are 
not affected by the `--lines` option. It more or less stops this at the next 
right-brace `}`. I am guessing that `#endif` should be handled like a 
right-brace there, to stop the formatting, but I am not sure: The "continue 
formatting" was introduced in 
[this](https://github.com/llvm/llvm-project/commit/a1036e5d081dd800c71bdbdf858908b99eed03a4)
 commit (http://reviews.llvm.org/D14105). I don't fully understand the 
intention there, but I guess it is intended for situations where clang-format 
inserts new `{...}` blocks? So how does this translate to PP directives?

In any case, I think this is an entirely different issue. The main point of 
these tests is that the `#define some` line is correct, i.e. that 
`IndentForLevel` is not used for the PP directives, i.e. that the PP directives 
are not affected by the indent of `void test()`.


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] D151047: [clang-format] Fix indentation for selective formatting.

2023-06-08 Thread Sedenion via Phabricator via cfe-commits
Sedeniono marked an inline comment as done.
Sedeniono added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:169-170
 
   /// The indent in characters for each level.
+  /// It remembers the indent of previous lines (that are not PP directives) of
+  /// equal or lower levels. This is used to align formatted lines to the 
indent

Sedeniono wrote:
> HazardyKnusperkeks wrote:
> > And then reformat the comment.
> Done.
Mh, it says [that it couldn't apply the 
patch](https://reviews.llvm.org/harbormaster/build/367648/). I uploaded a patch 
containing as only change the reformatted comment, via the Web UI ("Update 
Diff" at the top right corner). Should I have uploaded a "squashed" diff, 
containing also ALL changes that I made before (the `resize` etc)? In other 
words, is Phabricator expecting individual patches and it merges and 
accumulates them itself? Or does each new uploaded patch overwrite all previous 
patches?


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] D149548: [IR] Update to use new shufflevector semantics

2023-06-08 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added subscribers: jonpa, uweigand.
qiucf added a comment.

Why this changes IR output of following case?

  // RUN: clang vecpromote.c -S -o - -O0 -target s390x-linux-gnu -fzvector 
-emit-llvm
  #include 
  
  vector int si;
  int g;
  int i;
  
  void foo() {
si = vec_promote(g, i);
  }
  
  // store <4 x i32> undef, ptr %__vec.i, align 16, !noalias !6  ; this undef 
becomes poison after this patch
  // %2 = load i32, ptr %__scalar.addr.i, align 4, !noalias !6
  // %3 = load i32, ptr %__index.addr.i, align 4, !noalias !6
  // %4 = load <4 x i32>, ptr %__vec.i, align 16, !noalias !6
  // %vecins.i = insertelement <4 x i32> %4, i32 %2, i32 %and.i

I see no PowerPC related case changes. Maybe adding SystemZ folks for comments 
@uweigand @jonpa


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149548

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


[PATCH] D142932: Multilib YAML parsing

2023-06-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

In D142932#4402981 , @michaelplatings 
wrote:

> @phosek thanks for your suggestion, that's now implemented. In practise for 
> LLVM Embedded Toolchain for Arm we haven't yet needed `NoMatchFlags` so I've 
> removed that feature.

Great, that simplifies things even further. The only other suggestion I have is 
to maybe rename `FlagMap` to `Mappings` for a better consistency with 
`Variants`, otherwise LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142932

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


[clang] d3d5cdb - [Clang] Convert some tests to opaque pointers (NFC)

2023-06-08 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-06-08T10:01:28+02:00
New Revision: d3d5cdbfa8a9f2838531466d321feb82f3c08b9d

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

LOG: [Clang] Convert some tests to opaque pointers (NFC)

Added: 


Modified: 
clang/test/CodeGenCXX/PR24289.cpp
clang/test/CodeGenCXX/arm-vaarg.cpp
clang/test/CodeGenCXX/builtin-source-location.cpp
clang/test/CodeGenCXX/cp-blocks-linetables.cpp
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
clang/test/CodeGenCXX/matrix-type.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/PR24289.cpp 
b/clang/test/CodeGenCXX/PR24289.cpp
index de52c3469be40..e466235674a35 100644
--- a/clang/test/CodeGenCXX/PR24289.cpp
+++ b/clang/test/CodeGenCXX/PR24289.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - 
-triple=x86_64-pc-linux-gnu -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu -std=c++11 | 
FileCheck %s
 
 namespace std {
 template 
@@ -24,8 +24,7 @@ void f() {
   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
 }
 
-// CHECK-DAG: @_ZZ1fvE1a = internal global %{{.*}} { %{{.*}}* getelementptr 
inbounds ([14 x %{{.*}}], [14 x %{{.*}}]
-// CHECK-DAG: * @_ZGRZ1fvE1a_, i32 0, i32 0), i64 14 }
+// CHECK-DAG: @_ZZ1fvE1a = internal global %{{.*}} { ptr @_ZGRZ1fvE1a_, i64 14 
}
 // CHECK-DAG: @_ZGRZ1fvE1a0_ = internal constant [1 x i32] zeroinitializer
 // CHECK-DAG: @_ZGRZ1fvE1a1_ = internal constant [1 x i32] zeroinitializer
 // CHECK-DAG: @_ZGRZ1fvE1a2_ = internal constant [1 x i32] zeroinitializer
@@ -40,16 +39,16 @@ void f() {
 // CHECK-DAG: @_ZGRZ1fvE1aB_ = internal constant [1 x i32] zeroinitializer
 // CHECK-DAG: @_ZGRZ1fvE1aC_ = internal constant [1 x i32] zeroinitializer
 // CHECK-DAG: @_ZGRZ1fvE1aD_ = internal constant [1 x i32] zeroinitializer
-// CHECK-DAG: @_ZGRZ1fvE1a_ = internal constant [14 x %{{.*}}] [%{{.*}} { i32* 
getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a0_, i32 0, i32 0), 
i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* 
@_ZGRZ1fvE1a1_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds 
([1 x i32], [1 x i32]* @_ZGRZ1fvE1a2_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* 
getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a3_, i32 0, i32 0), 
i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* 
@_ZGRZ1fvE1a4_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds 
([1 x i32], [1 x i32]* @_ZGRZ1fvE1a5_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* 
getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a6_, i32 0, i32 0), 
i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* 
@_ZGRZ1fvE1a7_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds 
([1 x i32], [1 x i32]* @_ZGRZ1fvE1a8_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* 
getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a9_, i32 0, i32 0), 
i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* 
@_ZGRZ1fvE1aA_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds 
([1 x i32], [1 x i32]* @_ZGRZ1fvE1aB_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* 
getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aC_, i32 0, i32 0), 
i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* 
@_ZGRZ1fvE1aD_, i32 0, i32 0), i64 1 }]
-// CHECK-DAG: @_ZZ1fvE1b = internal global %{{.*}} { %{{.*}}* getelementptr 
inbounds ([4 x %{{.*}}], [4 x %{{.*}}]*
-// CHECK-DAG: @_ZGRZ1fvE1b_, i32 0, i32 0), i64 4 }
+// CHECK-DAG: @_ZGRZ1fvE1a_ = internal constant [14 x %{{.*}}] [%{{.*}} { ptr 
@_ZGRZ1fvE1a0_, i64 1 }, %{{.*}} { ptr @_ZGRZ1fvE1a1_, i64 1 }, %{{.*}} { ptr 
@_ZGRZ1fvE1a2_, i64 1 }, %{{.*}} { ptr @_ZGRZ1fvE1a3_, i64 1 }, %{{.*}} { ptr 
@_ZGRZ1fvE1a4_, i64 1 }, %{{.*}} { ptr @_ZGRZ1fvE1a5_, i64 1 }, %{{.*}} { ptr 
@_ZGRZ1fvE1a6_, i64 1 }, %{{.*}} { ptr @_ZGRZ1fvE1a7_, i64 1 }, %{{.*}} { ptr 
@_ZGRZ1fvE1a8_, i64 1 }, %{{.*}} { ptr @_ZGRZ1fvE1a9_, i64 1 }, %{{.*}} { ptr 
@_ZGRZ1fvE1aA_, i64 1 }, %{{.*}} { ptr @_ZGRZ1fvE1aB_, i64 1 }, %{{.*}} { ptr 
@_ZGRZ1fvE1aC_, i64 1 }, %{{.*}} { ptr @_ZGRZ1fvE1aD_, i64 1 }]
+// CHECK-DAG: @_ZZ1fvE1b = internal global %{{.*}} { ptr
+// CHECK-DAG: @_ZGRZ1fvE1b_, i64 4 }
 // CHECK-DAG: @_ZGRZ1fvE1b0_ = internal constant [1 x i32] zeroinitializer
 // CHECK-DAG: @_ZGRZ1fvE1b1_ = internal constant [1 x i32] zeroinitializer
 // CHECK-DAG: @_ZGRZ1fvE1b2_ = internal constant [1 x i32] zeroinitializer
 // CHECK-DAG: @_ZGRZ1fvE1b3_ = internal constant [1 x i32] zeroinitializer
-// CHECK-DAG: @_ZGRZ1fvE1b_ = internal constant [4 x %{{.*}}] [%{{.*}} { i32* 
getel

[PATCH] D152353: [NFC][Driver] Change MultilibBuilder flags argument order

2023-06-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM thanks!




Comment at: clang/include/clang/Driver/MultilibBuilder.h:80
+  /// \p Negate defines whether the flag is negated and therefore disallowed.
+  MultilibBuilder &flag(StringRef Flag, bool Negate = false);
 

After seeing the change and specifically the comment on this fuinction, I think 
that `Disallow` might be a better name than `Negate` if it's not too much 
hassle to change it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152353

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


[PATCH] D143075: BareMetal ToolChain multilib layering

2023-06-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM




Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:236-240
+  if (!SelectedMultilibs.empty()) {
+return llvm::iterator_range<
+llvm::SmallVector::const_reverse_iterator>(
+SelectedMultilibs.rbegin(), SelectedMultilibs.rend());
+  }

It should be possible to simplify this with `llvm::reverse`.



Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:244-246
+  return llvm::iterator_range<
+  llvm::SmallVector::const_reverse_iterator>(Default.rbegin(),
+   Default.rend());

It should be possible to simplify this with `llvm::reverse`.



Comment at: clang/lib/Driver/ToolChains/BareMetal.h:76
+private:
+  llvm::iterator_range::const_reverse_iterator>
+  getOrderedMultilibs() const;

I'd define an alias for this type with `using` to avoid repeating it multiple 
times.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143075

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


[PATCH] D150446: [analyzer] Check ArraySubscriptExprs in ArrayBoundCheckerV2

2023-06-08 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Okay. I think we are aligned. I'm still uncomfortable sacrificing reports for 
fast pace development. IMO if that is the goal, then a brand new alpha checker 
is the way forward.
You can be sure that no external users depend on it as its brand new. Unlike 
with this V2 checker.
If everything goes well, after a careful evaluation we could drop V1 and V2 in 
favor of V3.
However, if let's say in a year that goal is not reached, we should probably do 
some cleanup regardless, so we not make the situation worse by having 3 
unfinished alpha oob checkers. That would be a shame.

WDYT about a new checker?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150446

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


[clang] a1e5430 - [clang] Fix consteval operators in template contexts

2023-06-08 Thread Mariya Podchishchaeva via cfe-commits

Author: Mariya Podchishchaeva
Date: 2023-06-08T04:26:45-04:00
New Revision: a1e5430b6adfe0fe19d831ab719fbec05b2cf5b7

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

LOG: [clang] Fix consteval operators in template contexts

Clang used to reject consteval operators if they're used inside a
template due to TreeTransform putting two different `DeclRefExpr`
expressions for the same reference of the same operator declaration into
`ReferenceToConsteval` set.
It seems there was an attempt to not rebuild the whole operator that
never succeeded, so this patch just removes this attempt and
problemating referencing of a `DeclRefExpr` that always ended up
discarded.

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

Reviewed By: cor3ntin

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

Added: 
clang/test/SemaCXX/consteval-operators.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/TreeTransform.h
clang/test/SemaCXX/overloaded-operator.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a30d9f8a38d7e..b17e746976573 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -485,6 +485,8 @@ Bug Fixes in This Version
 - Fix assertion and quality of diagnostic messages in a for loop
   containing multiple declarations and a range specifier
   (`#63010 `_).
+- Fix rejects-valid when consteval operator appears inside of a template.
+  (`#62886 `_).
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index bb6c0aabd0d05..f0401f080dd9f 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -3053,10 +3053,11 @@ class TreeTransform {
   /// argument-dependent lookup, etc. Subclasses may override this routine to
   /// provide 
diff erent behavior.
   ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
-  SourceLocation OpLoc,
-  Expr *Callee,
-  Expr *First,
-  Expr *Second);
+SourceLocation OpLoc,
+SourceLocation CalleeLoc,
+bool RequiresADL,
+const UnresolvedSetImpl &Functions,
+Expr *First, Expr *Second);
 
   /// Build a new C++ "named" cast expression, such as static_cast or
   /// reinterpret_cast.
@@ -11962,10 +11963,6 @@ 
TreeTransform::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
 llvm_unreachable("not an overloaded operator?");
   }
 
-  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
-  if (Callee.isInvalid())
-return ExprError();
-
   ExprResult First;
   if (E->getOperator() == OO_Amp)
 First = getDerived().TransformAddressOfOperand(E->getArg(0));
@@ -11982,23 +11979,39 @@ 
TreeTransform::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
   return ExprError();
   }
 
-  if (!getDerived().AlwaysRebuild() &&
-  Callee.get() == E->getCallee() &&
-  First.get() == E->getArg(0) &&
-  (E->getNumArgs() != 2 || Second.get() == E->getArg(1)))
-return SemaRef.MaybeBindToTemporary(E);
-
   Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
   FPOptionsOverride NewOverrides(E->getFPFeatures());
   getSema().CurFPFeatures =
   NewOverrides.applyOverrides(getSema().getLangOpts());
   getSema().FpPragmaStack.CurrentValue = NewOverrides;
 
-  return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(),
- E->getOperatorLoc(),
- Callee.get(),
- First.get(),
- Second.get());
+  Expr *Callee = E->getCallee();
+  if (UnresolvedLookupExpr *ULE = dyn_cast(Callee)) {
+LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
+   Sema::LookupOrdinaryName);
+if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
+  return ExprError();
+
+return getDerived().RebuildCXXOperatorCallExpr(
+E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
+ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
+  }
+
+  UnresolvedSet<1> Functions;
+  if (ImplicitCastExpr *ICE = dyn_cast(Callee))
+Callee = ICE->getSubExprAsWritten();
+  NamedDecl *DR = cast(Callee)->getDecl();
+ 

[PATCH] D151553: [clang] Fix consteval operators in template contexts

2023-06-08 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa1e5430b6adf: [clang] Fix consteval operators in template 
contexts (authored by Fznamznon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151553

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/consteval-operators.cpp
  clang/test/SemaCXX/overloaded-operator.cpp

Index: clang/test/SemaCXX/overloaded-operator.cpp
===
--- clang/test/SemaCXX/overloaded-operator.cpp
+++ clang/test/SemaCXX/overloaded-operator.cpp
@@ -585,3 +585,16 @@
   float &operator->*(B, B);
   template void f();
 }
+
+namespace test {
+namespace A {
+template T f(T t) {
+  T operator+(T, T);
+  return t + t;
+}
+}
+namespace B {
+  struct X {};
+}
+void g(B::X x) { A::f(x); }
+}
Index: clang/test/SemaCXX/consteval-operators.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/consteval-operators.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++2a -emit-llvm-only -Wno-unused-value %s -verify
+
+// expected-no-diagnostics
+
+struct A {
+  consteval A operator+() { return {}; }
+};
+consteval A operator~(A) { return {}; }
+consteval A operator+(A, A) { return {}; }
+
+template  void f() {
+  A a;
+  A b = ~a;
+  A c = a + a;
+  A d = +a;
+}
+template void f();
+
+template  void foo() {
+  T a;
+  T b = ~a;
+  T c = a + a;
+  T d = +a;
+}
+
+template void foo();
+
+template  struct B { DataT D; };
+
+template 
+consteval B operator+(B lhs, B rhs) {
+  return B{lhs.D + rhs.D};
+}
+
+template  consteval T template_add(T a, T b) { return a + b; }
+
+consteval B non_template_add(B a, B b) { return a + b; }
+
+void bar() {
+  constexpr B a{};
+  constexpr B b{};
+  auto constexpr c = a + b;
+}
+
+static_assert((template_add(B{7}, B{3})).D == 10);
+static_assert((non_template_add(B{7}, B{3})).D == 10);
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -3053,10 +3053,11 @@
   /// argument-dependent lookup, etc. Subclasses may override this routine to
   /// provide different behavior.
   ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
-  SourceLocation OpLoc,
-  Expr *Callee,
-  Expr *First,
-  Expr *Second);
+SourceLocation OpLoc,
+SourceLocation CalleeLoc,
+bool RequiresADL,
+const UnresolvedSetImpl &Functions,
+Expr *First, Expr *Second);
 
   /// Build a new C++ "named" cast expression, such as static_cast or
   /// reinterpret_cast.
@@ -11962,10 +11963,6 @@
 llvm_unreachable("not an overloaded operator?");
   }
 
-  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
-  if (Callee.isInvalid())
-return ExprError();
-
   ExprResult First;
   if (E->getOperator() == OO_Amp)
 First = getDerived().TransformAddressOfOperand(E->getArg(0));
@@ -11982,23 +11979,39 @@
   return ExprError();
   }
 
-  if (!getDerived().AlwaysRebuild() &&
-  Callee.get() == E->getCallee() &&
-  First.get() == E->getArg(0) &&
-  (E->getNumArgs() != 2 || Second.get() == E->getArg(1)))
-return SemaRef.MaybeBindToTemporary(E);
-
   Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
   FPOptionsOverride NewOverrides(E->getFPFeatures());
   getSema().CurFPFeatures =
   NewOverrides.applyOverrides(getSema().getLangOpts());
   getSema().FpPragmaStack.CurrentValue = NewOverrides;
 
-  return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(),
- E->getOperatorLoc(),
- Callee.get(),
- First.get(),
- Second.get());
+  Expr *Callee = E->getCallee();
+  if (UnresolvedLookupExpr *ULE = dyn_cast(Callee)) {
+LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
+   Sema::LookupOrdinaryName);
+if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
+  return ExprError();
+
+return getDerived().RebuildCXXOperatorCallExpr(
+E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
+ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
+  }
+
+  UnresolvedSet<1> Functions;
+  if (ImplicitCastExpr *ICE = dyn_cast(Callee))
+Callee = ICE->getSubExprAsWritten();
+  NamedDecl *DR = cast(Callee)->getDecl();
+  Value

[PATCH] D152353: [NFC][Driver] Change MultilibBuilder flags argument order

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

Negate->Disallow


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152353

Files:
  clang/include/clang/Driver/MultilibBuilder.h
  clang/lib/Driver/MultilibBuilder.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/unittests/Driver/MultilibBuilderTest.cpp

Index: clang/unittests/Driver/MultilibBuilderTest.cpp
===
--- clang/unittests/Driver/MultilibBuilderTest.cpp
+++ clang/unittests/Driver/MultilibBuilderTest.cpp
@@ -27,22 +27,24 @@
 
   ASSERT_TRUE(MultilibBuilder().isValid()) << "Empty multilib is not valid";
 
-  ASSERT_TRUE(MultilibBuilder().flag(true, "-foo").isValid())
+  ASSERT_TRUE(MultilibBuilder().flag("-foo").isValid())
   << "Single indicative flag is not valid";
 
-  ASSERT_TRUE(MultilibBuilder().flag(false, "-foo").isValid())
+  ASSERT_TRUE(MultilibBuilder().flag("-foo", /*Disallow=*/true).isValid())
   << "Single contraindicative flag is not valid";
 
   ASSERT_FALSE(
-  MultilibBuilder().flag(true, "-foo").flag(false, "-foo").isValid())
+  MultilibBuilder().flag("-foo").flag("-foo", /*Disallow=*/true).isValid())
   << "Conflicting flags should invalidate the Multilib";
 
-  ASSERT_TRUE(MultilibBuilder().flag(true, "-foo").flag(true, "-foo").isValid())
+  ASSERT_TRUE(MultilibBuilder().flag("-foo").flag("-foo").isValid())
   << "Multilib should be valid even if it has the same flag "
  "twice";
 
-  ASSERT_TRUE(
-  MultilibBuilder().flag(true, "-foo").flag(false, "-foobar").isValid())
+  ASSERT_TRUE(MultilibBuilder()
+  .flag("-foo")
+  .flag("-foobar", /*Disallow=*/true)
+  .isValid())
   << "Seemingly conflicting prefixes shouldn't actually conflict";
 }
 
@@ -55,7 +57,7 @@
 
 TEST(MultilibBuilderTest, Construction3) {
   MultilibBuilder M =
-  MultilibBuilder().flag(true, "-f1").flag(true, "-f2").flag(false, "-f3");
+  MultilibBuilder().flag("-f1").flag("-f2").flag("-f3", /*Disallow=*/true);
   for (const std::string &A : M.flags()) {
 ASSERT_TRUE(llvm::StringSwitch(A)
 .Cases("-f1", "-f2", "!f3", true)
@@ -66,7 +68,7 @@
 TEST(MultilibBuilderTest, SetConstruction1) {
   // Single maybe
   MultilibSet MS = MultilibSetBuilder()
-   .Maybe(MultilibBuilder("64").flag(true, "-m64"))
+   .Maybe(MultilibBuilder("64").flag("-m64"))
.makeMultilibSet();
   ASSERT_TRUE(MS.size() == 2);
   for (MultilibSet::const_iterator I = MS.begin(), E = MS.end(); I != E; ++I) {
@@ -82,8 +84,8 @@
 TEST(MultilibBuilderTest, SetConstruction2) {
   // Double maybe
   MultilibSet MS = MultilibSetBuilder()
-   .Maybe(MultilibBuilder("sof").flag(true, "-sof"))
-   .Maybe(MultilibBuilder("el").flag(true, "-EL"))
+   .Maybe(MultilibBuilder("sof").flag("-sof"))
+   .Maybe(MultilibBuilder("el").flag("-EL"))
.makeMultilibSet();
   ASSERT_TRUE(MS.size() == 4);
   for (MultilibSet::const_iterator I = MS.begin(), E = MS.end(); I != E; ++I) {
@@ -157,7 +159,7 @@
 
 TEST(MultilibBuilderTest, SetSelection1) {
   MultilibSet MS1 = MultilibSetBuilder()
-.Maybe(MultilibBuilder("64").flag(true, "-m64"))
+.Maybe(MultilibBuilder("64").flag("-m64"))
 .makeMultilibSet();
 
   Multilib::flags_list FlagM64 = {"-m64"};
@@ -177,8 +179,8 @@
 
 TEST(MultilibBuilderTest, SetSelection2) {
   MultilibSet MS2 = MultilibSetBuilder()
-.Maybe(MultilibBuilder("el").flag(true, "-EL"))
-.Maybe(MultilibBuilder("sf").flag(true, "-SF"))
+.Maybe(MultilibBuilder("el").flag("-EL"))
+.Maybe(MultilibBuilder("sf").flag("-SF"))
 .makeMultilibSet();
 
   for (unsigned I = 0; I < 4; ++I) {
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1063,38 +1063,38 @@
   // Check for Code Sourcery toolchain multilibs
   MultilibSet CSMipsMultilibs;
   {
-auto MArchMips16 =
-MultilibBuilder("/mips16").flag(true, "-m32").flag(true, "-mips16");
+auto MArchMips16 = MultilibBuilder("/mips16").flag("-m32").flag("-mips16");
 
-auto MArchMicroMips = MultilibBuilder("/micromips")
-  .flag(true, "-m32")
-  .flag(true, "-mmicromips");
+auto MArchMicroMips =
+MultilibBuilder("/micromips").flag("-m32").flag("-mmicromips");
 

[PATCH] D152429: [Clang][Type] Add static assertion to guard future expansion for BuiltinType numbering

2023-06-08 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: craig.topper, aaron.ballman, erichkeane.
Herald added a project: All.
eopXD requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Recent expansion D152070  exceeds the limit 
and I had a hard time
triaging the bug because the overflow just creates unexpected
behaviors within the compiler.

This patch adds a static assertionto keep an eye for overflows when we
expand more types in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152429

Files:
  clang/include/clang/AST/Type.h


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1539,6 +1539,8 @@
   GNUAutoType
 };
 
+static const unsigned NumOfBuiltinTypeBits = 8;
+
 /// The base class of the type hierarchy.
 ///
 /// A central concept with types is that each type always has a canonical
@@ -1649,7 +1651,7 @@
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
-unsigned Kind : 8;
+unsigned Kind : NumOfBuiltinTypeBits;
   };
 
   /// FunctionTypeBitfields store various bits belonging to FunctionProtoType.
@@ -2677,6 +2679,9 @@
   : Type(Builtin, QualType(),
  K == Dependent ? TypeDependence::DependentInstantiation
 : TypeDependence::None) {
+static_assert(Kind::LastKind < (1 << NumOfBuiltinTypeBits) &&
+  "Defined builtin type exceeds the allocated space for serial 
"
+  "numbering");
 BuiltinTypeBits.Kind = K;
   }
 


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1539,6 +1539,8 @@
   GNUAutoType
 };
 
+static const unsigned NumOfBuiltinTypeBits = 8;
+
 /// The base class of the type hierarchy.
 ///
 /// A central concept with types is that each type always has a canonical
@@ -1649,7 +1651,7 @@
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
-unsigned Kind : 8;
+unsigned Kind : NumOfBuiltinTypeBits;
   };
 
   /// FunctionTypeBitfields store various bits belonging to FunctionProtoType.
@@ -2677,6 +2679,9 @@
   : Type(Builtin, QualType(),
  K == Dependent ? TypeDependence::DependentInstantiation
 : TypeDependence::None) {
+static_assert(Kind::LastKind < (1 << NumOfBuiltinTypeBits) &&
+  "Defined builtin type exceeds the allocated space for serial "
+  "numbering");
 BuiltinTypeBits.Kind = K;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144634: [Clang][OpenMP] Support for Code Generation of loop bind clause

2023-06-08 Thread Sunil K via Phabricator via cfe-commits
koops updated this revision to Diff 529532.
koops added a comment.

1. Taken care of Alexy's comments.
2. Reverting back changes to StmtPrinter.cpp because state of AST needs to be 
shown as is to the developer of clang when -ast-print/-ast-dump is used. This 
also meant some changes to the test cases to reflect the Mapped directives 
(from "omp loop" to "omp for", "omp distribute" or "omp simd".


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

https://reviews.llvm.org/D144634

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/generic_loop_ast_print.cpp
  clang/test/OpenMP/loop_bind_codegen.cpp
  clang/test/OpenMP/loop_bind_enclosed.cpp
  clang/test/OpenMP/loop_bind_messages.cpp
  clang/test/OpenMP/nested_loop_codegen.cpp

Index: clang/test/OpenMP/nested_loop_codegen.cpp
===
--- clang/test/OpenMP/nested_loop_codegen.cpp
+++ clang/test/OpenMP/nested_loop_codegen.cpp
@@ -58,6 +58,12 @@
 // CHECK1-NEXT:[[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[I_ADDR:%.*]] = alloca ptr, align 8
+// CHECK1-NEXT:[[TMP:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_IV:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_LB:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_UB:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[K:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
@@ -66,35 +72,27 @@
 // CHECK1-NEXT:store i32 0, ptr [[TMP0]], align 4
 // CHECK1-NEXT:br label [[FOR_COND:%.*]]
 // CHECK1:   for.cond:
-// CHECK1-NEXT:[[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4
-// CHECK1-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP1]], 10
-// CHECK1-NEXT:br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END7:%.*]]
 // CHECK1:   for.body:
-// CHECK1-NEXT:store i32 0, ptr [[K]], align 4
-// CHECK1-NEXT:br label [[FOR_COND1:%.*]]
-// CHECK1:   for.cond1:
-// CHECK1-NEXT:[[TMP2:%.*]] = load i32, ptr [[K]], align 4
-// CHECK1-NEXT:[[CMP2:%.*]] = icmp slt i32 [[TMP2]], 5
-// CHECK1-NEXT:br i1 [[CMP2]], label [[FOR_BODY3:%.*]], label [[FOR_END:%.*]]
-// CHECK1:   for.body3:
-// CHECK1-NEXT:[[TMP3:%.*]] = load i32, ptr [[K]], align 4
-// CHECK1-NEXT:[[INC:%.*]] = add nsw i32 [[TMP3]], 1
-// CHECK1-NEXT:store i32 [[INC]], ptr [[K]], align 4
-// CHECK1-NEXT:br label [[FOR_INC:%.*]]
-// CHECK1:   for.inc:
-// CHECK1-NEXT:[[TMP4:%.*]] = load i32, ptr [[K]], align 4
-// CHECK1-NEXT:[[INC4:%.*]] = add nsw i32 [[TMP4]], 1
-// CHECK1-NEXT:store i32 [[INC4]], ptr [[K]], align 4
-// CHECK1-NEXT:br label [[FOR_COND1]], !llvm.loop [[LOOP3:![0-9]+]]
-// CHECK1:   for.end:
-// CHECK1-NEXT:br label [[FOR_INC5:%.*]]
-// CHECK1:   for.inc5:
-// CHECK1-NEXT:[[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
-// CHECK1-NEXT:[[INC6:%.*]] = add nsw i32 [[TMP5]], 1
-// CHECK1-NEXT:store i32 [[INC6]], ptr [[TMP0]], align 4
-// CHECK1-NEXT:br label [[FOR_COND]], !llvm.loop [[LOOP5:![0-9]+]]
-// CHECK1:   for.end7:
-// CHECK1-NEXT:ret void
+// CHECK1-NEXT [[TMP2:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
+// CHECK1-NEXT [[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4
+// CHECK1-NEXT call void @__kmpc_for_static_init_4(ptr @1, i32 [[TMP3]], i32 34, ptr [[DOTOMP_IS_LAST]], ptr [[DOTOMP_LB]], ptr [[DOTOMP_UB]], ptr [[DOTOMP_STRIDE]], i32 1, i32 1)
+//CHECK1 cond.end:
+//CHECK1 omp.inner.for.cond:
+//CHECK1 omp.inner.for.body:
+//CHECK1 omp.body.continue:
+//CHECK1 omp.inner.for.inc:
+//CHECK1 omp.inner.for.end:
+//CHECK1 omp.loop.exit:
+// CHECK1-NEXT [[TMP13:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
+// CHECK1-NEXT [[TMP14:%.*]] = load i32, ptr [[TMP12]], align 4
+// CHECK1-NEXT call void @__kmpc_for_static_fini(ptr @1, i32 [[TMP14]])
+// CHECK1-NEXT [[TMP15:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
+// CHECK1-NEXT [[TMP16:%.*]] = load i32, ptr [[TMP15]], align 4
+// CHECK1-NEXT call void @__kmpc_barrier(ptr @2, i32 [[TMP16]])
+//CHECK1 for.inc:
+//CHECK1 for.end:
+// CHECK1-NEXT ret void
+//
 //
 //
 // CHECK1-LABEL: define {{[^@]+}}@_Z11inline_declv
@@ -114,45 +112,36 @@
 // CHECK1-NEXT:[[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[I_ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[RES_ADDR:%.*]] = alloca ptr, align 8
-// CHECK1-NEXT:[[K:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBA

[clang] b4507dc - [NFC][Driver] Change MultilibBuilder flags argument order

2023-06-08 Thread Michael Platings via cfe-commits

Author: Michael Platings
Date: 2023-06-08T10:02:52+01:00
New Revision: b4507dcaeafcbd24ce793084d22d8189af685058

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

LOG: [NFC][Driver] Change MultilibBuilder flags argument order

Follow up to D151437

Reviewed By: phosek

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

Added: 


Modified: 
clang/include/clang/Driver/MultilibBuilder.h
clang/lib/Driver/MultilibBuilder.cpp
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/unittests/Driver/MultilibBuilderTest.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/MultilibBuilder.h 
b/clang/include/clang/Driver/MultilibBuilder.h
index 86f34592ba384..61596c5c573f3 100644
--- a/clang/include/clang/Driver/MultilibBuilder.h
+++ b/clang/include/clang/Driver/MultilibBuilder.h
@@ -75,9 +75,9 @@ class MultilibBuilder {
   flags_list &flags() { return Flags; }
 
   /// Add a flag to the flags list
-  /// \p Required defines whether the flag is required or disallowed.
   /// \p Flag must be a flag accepted by the driver.
-  MultilibBuilder &flag(bool Required, StringRef Flag);
+  /// \p Disallow defines whether the flag is negated and therefore disallowed.
+  MultilibBuilder &flag(StringRef Flag, bool Disallow = false);
 
   Multilib makeMultilib() const;
 

diff  --git a/clang/lib/Driver/MultilibBuilder.cpp 
b/clang/lib/Driver/MultilibBuilder.cpp
index d2a3fcb3732f6..15adf50177809 100644
--- a/clang/lib/Driver/MultilibBuilder.cpp
+++ b/clang/lib/Driver/MultilibBuilder.cpp
@@ -86,8 +86,8 @@ bool MultilibBuilder::isValid() const {
   return true;
 }
 
-MultilibBuilder &MultilibBuilder::flag(bool Required, StringRef Flag) {
-  tools::addMultilibFlag(Required, Flag, Flags);
+MultilibBuilder &MultilibBuilder::flag(StringRef Flag, bool Disallow) {
+  tools::addMultilibFlag(!Disallow, Flag, Flags);
   return *this;
 }
 
@@ -100,7 +100,7 @@ MultilibSetBuilder &MultilibSetBuilder::Maybe(const 
MultilibBuilder &M) {
   // Negate positive flags
   for (StringRef Flag : M.flags()) {
 if (Flag.front() == '-')
-  Opposite.flags().push_back(("!" + Flag.substr(1)).str());
+  Opposite.flag(Flag, /*Disallow=*/true);
   }
   return Either(M, Opposite);
 }

diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 6726ec1c9b22e..ec3571bb60ee8 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -37,12 +37,11 @@ static bool findRISCVMultilibs(const Driver &D,
   StringRef Abi = tools::riscv::getRISCVABI(Args, TargetTriple);
 
   if (TargetTriple.isRISCV64()) {
-MultilibBuilder Imac = MultilibBuilder()
-   .flag(true, "-march=rv64imac")
-   .flag(true, "-mabi=lp64");
+MultilibBuilder Imac =
+MultilibBuilder().flag("-march=rv64imac").flag("-mabi=lp64");
 MultilibBuilder Imafdc = MultilibBuilder("/rv64imafdc/lp64d")
- .flag(true, "-march=rv64imafdc")
- .flag(true, "-mabi=lp64d");
+ .flag("-march=rv64imafdc")
+ .flag("-mabi=lp64d");
 
 // Multilib reuse
 bool UseImafdc =
@@ -58,21 +57,20 @@ static bool findRISCVMultilibs(const Driver &D,
 return Result.Multilibs.select(Flags, Result.SelectedMultilib);
   }
   if (TargetTriple.isRISCV32()) {
-MultilibBuilder Imac = MultilibBuilder()
-   .flag(true, "-march=rv32imac")
-   .flag(true, "-mabi=ilp32");
+MultilibBuilder Imac =
+MultilibBuilder().flag("-march=rv32imac").flag("-mabi=ilp32");
 MultilibBuilder I = MultilibBuilder("/rv32i/ilp32")
-.flag(true, "-march=rv32i")
-.flag(true, "-mabi=ilp32");
+.flag("-march=rv32i")
+.flag("-mabi=ilp32");
 MultilibBuilder Im = MultilibBuilder("/rv32im/ilp32")
- .flag(true, "-march=rv32im")
- .flag(true, "-mabi=ilp32");
+ .flag("-march=rv32im")
+ .flag("-mabi=ilp32");
 MultilibBuilder Iac = MultilibBuilder("/rv32iac/ilp32")
-  .flag(true, "-march=rv32iac")
-  .flag(true, "-mabi=ilp32");
+  .flag("-march=rv32iac")
+  .flag("-mabi=ilp32");
 MultilibBuilder Imafc = MultilibBuilder("/rv32imafc/ilp32f")
-.flag(true, "-march=rv32imafc")
-  

[PATCH] D152353: [NFC][Driver] Change MultilibBuilder flags argument order

2023-06-08 Thread Michael Platings 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 rGb4507dcaeafc: [NFC][Driver] Change MultilibBuilder flags 
argument order (authored by michaelplatings).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152353

Files:
  clang/include/clang/Driver/MultilibBuilder.h
  clang/lib/Driver/MultilibBuilder.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/unittests/Driver/MultilibBuilderTest.cpp

Index: clang/unittests/Driver/MultilibBuilderTest.cpp
===
--- clang/unittests/Driver/MultilibBuilderTest.cpp
+++ clang/unittests/Driver/MultilibBuilderTest.cpp
@@ -27,22 +27,24 @@
 
   ASSERT_TRUE(MultilibBuilder().isValid()) << "Empty multilib is not valid";
 
-  ASSERT_TRUE(MultilibBuilder().flag(true, "-foo").isValid())
+  ASSERT_TRUE(MultilibBuilder().flag("-foo").isValid())
   << "Single indicative flag is not valid";
 
-  ASSERT_TRUE(MultilibBuilder().flag(false, "-foo").isValid())
+  ASSERT_TRUE(MultilibBuilder().flag("-foo", /*Disallow=*/true).isValid())
   << "Single contraindicative flag is not valid";
 
   ASSERT_FALSE(
-  MultilibBuilder().flag(true, "-foo").flag(false, "-foo").isValid())
+  MultilibBuilder().flag("-foo").flag("-foo", /*Disallow=*/true).isValid())
   << "Conflicting flags should invalidate the Multilib";
 
-  ASSERT_TRUE(MultilibBuilder().flag(true, "-foo").flag(true, "-foo").isValid())
+  ASSERT_TRUE(MultilibBuilder().flag("-foo").flag("-foo").isValid())
   << "Multilib should be valid even if it has the same flag "
  "twice";
 
-  ASSERT_TRUE(
-  MultilibBuilder().flag(true, "-foo").flag(false, "-foobar").isValid())
+  ASSERT_TRUE(MultilibBuilder()
+  .flag("-foo")
+  .flag("-foobar", /*Disallow=*/true)
+  .isValid())
   << "Seemingly conflicting prefixes shouldn't actually conflict";
 }
 
@@ -55,7 +57,7 @@
 
 TEST(MultilibBuilderTest, Construction3) {
   MultilibBuilder M =
-  MultilibBuilder().flag(true, "-f1").flag(true, "-f2").flag(false, "-f3");
+  MultilibBuilder().flag("-f1").flag("-f2").flag("-f3", /*Disallow=*/true);
   for (const std::string &A : M.flags()) {
 ASSERT_TRUE(llvm::StringSwitch(A)
 .Cases("-f1", "-f2", "!f3", true)
@@ -66,7 +68,7 @@
 TEST(MultilibBuilderTest, SetConstruction1) {
   // Single maybe
   MultilibSet MS = MultilibSetBuilder()
-   .Maybe(MultilibBuilder("64").flag(true, "-m64"))
+   .Maybe(MultilibBuilder("64").flag("-m64"))
.makeMultilibSet();
   ASSERT_TRUE(MS.size() == 2);
   for (MultilibSet::const_iterator I = MS.begin(), E = MS.end(); I != E; ++I) {
@@ -82,8 +84,8 @@
 TEST(MultilibBuilderTest, SetConstruction2) {
   // Double maybe
   MultilibSet MS = MultilibSetBuilder()
-   .Maybe(MultilibBuilder("sof").flag(true, "-sof"))
-   .Maybe(MultilibBuilder("el").flag(true, "-EL"))
+   .Maybe(MultilibBuilder("sof").flag("-sof"))
+   .Maybe(MultilibBuilder("el").flag("-EL"))
.makeMultilibSet();
   ASSERT_TRUE(MS.size() == 4);
   for (MultilibSet::const_iterator I = MS.begin(), E = MS.end(); I != E; ++I) {
@@ -157,7 +159,7 @@
 
 TEST(MultilibBuilderTest, SetSelection1) {
   MultilibSet MS1 = MultilibSetBuilder()
-.Maybe(MultilibBuilder("64").flag(true, "-m64"))
+.Maybe(MultilibBuilder("64").flag("-m64"))
 .makeMultilibSet();
 
   Multilib::flags_list FlagM64 = {"-m64"};
@@ -177,8 +179,8 @@
 
 TEST(MultilibBuilderTest, SetSelection2) {
   MultilibSet MS2 = MultilibSetBuilder()
-.Maybe(MultilibBuilder("el").flag(true, "-EL"))
-.Maybe(MultilibBuilder("sf").flag(true, "-SF"))
+.Maybe(MultilibBuilder("el").flag("-EL"))
+.Maybe(MultilibBuilder("sf").flag("-SF"))
 .makeMultilibSet();
 
   for (unsigned I = 0; I < 4; ++I) {
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1063,38 +1063,38 @@
   // Check for Code Sourcery toolchain multilibs
   MultilibSet CSMipsMultilibs;
   {
-auto MArchMips16 =
-MultilibBuilder("/mips16").flag(true, "-m32").flag(true, "-mips16");
+auto MArchMips16 = MultilibBuilder("/mips16").flag("-m32").flag("-mips16");
 
-auto MArchMicroMips = MultilibBuilder("/micromips")
-  .flag(true, "-m32")
-  .flag(true, "-mmicromips");
+

[PATCH] D152418: [clang] set python3 as required build dependency

2023-06-08 Thread Lu JiongJia via Phabricator via cfe-commits
Avimitin added a comment.

I can't commit this change myself, please help me commit this, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152418

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


[PATCH] D152433: [ARM,AArch64] Add a full set of -mtp= options.

2023-06-08 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: nickdesaulniers, peter.smith, kristof.beyls, 
t.p.northover, rengolin.
Herald added a subscriber: hiraditya.
Herald added a project: All.
simon_tatham requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

AArch64 has five system registers intended to be useful as thread
pointers: one for each exception level which is RW at that level and
inaccessible to lower ones, and the special TPIDRRO_EL0 which is
readable but not writable at EL0. AArch32 has three, corresponding to
the AArch64 ones that aren't specific to EL2 or EL3.

Currently clang supports only a subset of these registers, and not
even a consistent subset between AArch64 and AArch32. For AArch64,
clang permits you to choose between the four TPIDR_ELn thread
registers, but not the fifth one, TPIDRRO_EL0. In AArch32, on the
other hand, the _only_ thread register you can choose (apart from
'none, use a function call') is the one that's read-only at EL0. There
is no thread register that you can currently use in both targets!

For custom and bare-metal purposes, users might very reasonably want
to use any of these thread registers. There's no reason they shouldn't
all be supported as options, even if the default choices follow
existing practice on typical operating systems.

This commit extends the range of values acceptable to the `-mtp=`
clang option, so that you can specify any of these registers by (the
lower-case version of) their official names in the ArmARM:

- tpidr_el0, tpidrro_el0, tpidr_el1, tpidr_el2, tpidr_el3 for AArch64
- tpidrurw, tpidruro, tpidrprw for AArch32

All existing values of the option are still supported and behave the
same as before. Defaults are also unchanged. No command line that
worked already should change behaviour as a result of this.

The new values for the `-mtp=` option have been agreed with Arm's gcc
developers (although I don't know whether they plan to implement them
in the near future).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152433

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/clang-translation.c
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMInstrInfo.td
  llvm/lib/Target/ARM/ARMInstrThumb2.td
  llvm/lib/Target/ARM/ARMPredicates.td
  llvm/test/CodeGen/AArch64/arm64-builtins-linux.ll
  llvm/test/CodeGen/ARM/readtp.ll
  llvm/test/CodeGen/ARM/stack-guard-tls.ll
  llvm/test/CodeGen/ARM/thread_pointer.ll

Index: llvm/test/CodeGen/ARM/thread_pointer.ll
===
--- llvm/test/CodeGen/ARM/thread_pointer.ll
+++ llvm/test/CodeGen/ARM/thread_pointer.ll
@@ -1,7 +1,11 @@
 ; RUN: llc -mtriple arm-linux-gnueabi -o - %s | FileCheck %s -check-prefix=CHECK-SOFT
-; RUN: llc -mtriple arm-linux-gnueabi -mattr=+read-tp-hard -o - %s | FileCheck %s -check-prefix=CHECK-HARD
+; RUN: llc -mtriple arm-linux-gnueabi -mattr=+read-tp-tpidrurw -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRURW
+; RUN: llc -mtriple arm-linux-gnueabi -mattr=+read-tp-tpidruro -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRURO
+; RUN: llc -mtriple arm-linux-gnueabi -mattr=+read-tp-tpidrprw -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRPRW
 ; RUN: llc -mtriple thumbv7-linux-gnueabi -o - %s | FileCheck %s -check-prefix=CHECK-SOFT
-; RUN: llc -mtriple thumbv7-linux-gnueabi -mattr=+read-tp-hard -o - %s | FileCheck %s -check-prefix=CHECK-HARD
+; RUN: llc -mtriple thumbv7-linux-gnueabi -mattr=+read-tp-tpidrurw -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRURW
+; RUN: llc -mtriple thumbv7-linux-gnueabi -mattr=+read-tp-tpidruro -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRURO
+; RUN: llc -mtriple thumbv7-linux-gnueabi -mattr=+read-tp-tpidrprw -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRPRW
 
 declare ptr @llvm.thread.pointer()
 
@@ -11,6 +15,8 @@
   ret ptr %tmp1
 }
 
-; CHECK-SOFT: bl __aeabi_read_tp
-; CHECK-HARD: mrc p15, #0, {{r[0-9]+}}, c13, c0, #3
+; CHECK-SOFT: bl __aeabi_read_tp
+; CHECK-TPIDRURW: mrc p15, #0, {{r[0-9]+}}, c13, c0, #2
+; CHECK-TPIDRURO: mrc p15, #0, {{r[0-9]+}}, c13, c0, #3
+; CHECK-TPIDRPRW: mrc p15, #0, {{r[0-9]+}}, c13, c0, #4
 
Index: llvm/test/CodeGen/ARM/stack-guard-tls.ll
===
--- llvm/test/CodeGen/ARM/stack-guard-tls.ll
+++ llvm/test/CodeGen/ARM/stack-guard-tls.ll
@@ -1,13 +1,13 @@
 ; RUN: split-file %s %t
 ; RUN: cat %t/main.ll %t/a.ll > %t/a2.ll
 ; RUN: cat %t/main.ll %t/b.ll > %t/b2.ll
-; RUN: llc %t/a2.ll -mtriple=armv7-unknown-linux-gnueabihf -mattr=+read-tp-hard -o - | \
+; RUN: llc %t/a2.ll -mtri

[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

2023-06-08 Thread Vikram Hegde via Phabricator via cfe-commits
vikramRH updated this revision to Diff 529551.
vikramRH added a comment.

Reafactored non string arg handling into a seperate function with additional 
asserts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenHIP/default-attributes.hip
  clang/test/CodeGenHIP/printf-kind-module-flag.hip
  clang/test/CodeGenHIP/printf_nonhostcall.cpp
  clang/test/CodeGenHIP/sanitize-undefined-null.hip
  clang/test/Driver/hip-options.hip
  llvm/include/llvm/Transforms/Utils/AMDGPUEmitPrintf.h
  llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp

Index: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
===
--- llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
+++ llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
@@ -17,6 +17,9 @@
 #include "llvm/Transforms/Utils/AMDGPUEmitPrintf.h"
 #include "llvm/ADT/SparseBitVector.h"
 #include "llvm/Analysis/ValueTracking.h"
+#include "llvm/Support/DataExtractor.h"
+#include "llvm/Support/MD5.h"
+#include "llvm/Support/MathExtras.h"
 
 using namespace llvm;
 
@@ -179,11 +182,7 @@
 
 // Scan the format string to locate all specifiers, and mark the ones that
 // specify a string, i.e, the "%s" specifier with optional '*' characters.
-static void locateCStrings(SparseBitVector<8> &BV, Value *Fmt) {
-  StringRef Str;
-  if (!getConstantStringInfo(Fmt, Str) || Str.empty())
-return;
-
+static void locateCStrings(SparseBitVector<8> &BV, StringRef Str) {
   static const char ConvSpecifiers[] = "diouxXfFeEgGaAcspn";
   size_t SpecPos = 0;
   // Skip the first argument, the format string.
@@ -207,14 +206,320 @@
   }
 }
 
-Value *llvm::emitAMDGPUPrintfCall(IRBuilder<> &Builder,
-  ArrayRef Args) {
+// helper struct to package the string related data
+struct StringData {
+  StringRef Str;
+  Value *RealSize = nullptr;
+  Value *AlignedSize = nullptr;
+  bool IsConst = true;
+
+  StringData(StringRef ST, Value *RS, Value *AS, bool IC)
+  : Str(ST), RealSize(RS), AlignedSize(AS), IsConst(IC) {}
+};
+
+// Calculates frame size required for current printf expansion and allocates
+// space on printf buffer. Printf frame includes following contents
+// [ ControlDWord , format string/Hash , Arguments (each aligned to 8 byte) ]
+static Value *callBufferedPrintfStart(
+IRBuilder<> &Builder, ArrayRef Args, Value *Fmt,
+bool isConstFmtStr, SparseBitVector<8> &SpecIsCString,
+SmallVectorImpl &StringContents, Value *&ArgSize) {
+  Module *M = Builder.GetInsertBlock()->getModule();
+  Value *NonConstStrLen = nullptr;
+  Value *LenWithNull = nullptr;
+  Value *LenWithNullAligned = nullptr;
+  Value *TempAdd = nullptr;
+
+  // First 4 bytes to be reserved for control dword
+  size_t BufSize = 4;
+  if (isConstFmtStr)
+// First 8 bytes of MD5 hash
+BufSize += 8;
+  else {
+LenWithNull = getStrlenWithNull(Builder, Fmt);
+
+// Align the computed length to next 8 byte boundary
+TempAdd = Builder.CreateAdd(LenWithNull,
+ConstantInt::get(LenWithNull->getType(), 7U));
+NonConstStrLen = Builder.CreateAnd(
+TempAdd, ConstantInt::get(LenWithNull->getType(), ~7U));
+
+StringContents.push_back(
+StringData(StringRef(), LenWithNull, NonConstStrLen, false));
+  }
+
+  for (size_t i = 1; i < Args.size(); i++) {
+if (SpecIsCString.test(i)) {
+  StringRef ArgStr;
+  if (getConstantStringInfo(Args[i], ArgStr)) {
+auto alignedLen = alignTo(ArgStr.size() + 1, 8);
+StringContents.push_back(StringData(
+ArgStr,
+/*RealSize*/ nullptr, /*AlignedSize*/ nullptr, /*IsConst*/ true));
+BufSize += alignedLen;
+  } else {
+LenWithNull = getStrlenWithNull(Builder, Args[i]);
+
+// Align the computed length to next 8 byte boundary
+TempAdd = Builder.CreateAdd(
+LenWithNull, ConstantInt::get(LenWithNull->getType(), 7U));
+LenWithNullAligned = Builder.CreateAnd(
+TempAdd, ConstantInt::get(LenWithNull->getType(), ~7U));
+
+if (NonConstStrLen) {
+  auto Val = Builder.CreateAdd(LenWithNullAligned, NonConstStrLen,
+   "cumulativeAdd");
+  NonConstStrLen = Val;
+} else
+  NonConstStrLen = LenWithNullAligned;
+
+StringContents.push_back(
+StringData(StringRef(), LenWithNull, LenWithNullAligned, false));
+  }
+} else
+  // We end up expanding non string arguments to 8 bytes
+  BufSize += 8;
+  }
+
+  // calculate final size value to be passed to printf_alloc
+  Value *SizeToReserve = ConstantInt::get(Builder.getIn

[PATCH] D152433: [ARM,AArch64] Add a full set of -mtp= options.

2023-06-08 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

The only minor visible difference is the removal of `read-tp-hard` option from 
the LLVM side, which could be used by other downstream implementations.

I personally don't think this is a big deal. First, we don't promise stability 
on that layer, and second, it would be trivial to find out what the option has 
changed to.

This looks good to me, perhaps clearing the potential confusion on the commit 
message (inline comment).

Give it some time for other people to see it.

Thanks!
Renato




Comment at: clang/include/clang/Driver/Options.td:3525
+   "For AArch32: 'soft' uses a function call, or 'tpidrurw', 
'tpidruro' or 'tpidrprw' use the three CP15 registers. 'cp15' is an alias for 
'tpidruro'. "
+   "For AArch64: 'tpidr_el0', 'tpidr_el1', 'tpidr_el2', 'tpidr_el3' or 
'tpidrro_el0' use the five system registers. 'elN' is an alias for 
'tpidr_elN'.">;
 def mpure_code : Flag<["-"], "mpure-code">, Alias; // Alias for 
GCC compatibility

From your comment:

> "In AArch32, on the other hand, the _only_ thread register you can choose 
> (apart from 'none, use a function call') is the one that's read-only at EL0."

I inferred the current alias `el0` would map to the read-only version 
`tpidrro_el0`.

Looking at the implementation below (`AArch64ExpandPseudoInsts.cpp`), `EL0` 
seems to be the default when choosing the thread pointer?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152433

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


[PATCH] D152433: [ARM,AArch64] Add a full set of -mtp= options.

2023-06-08 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

In D152433#4405428 , @rengolin wrote:

> The only minor visible difference is the removal of `read-tp-hard` option 
> from the LLVM side, which could be used by other downstream implementations.

Yes. I wasn't sure how much that mattered, and like you, I came down weakly on 
the side of not worrying about the change and keeping the names logical. I'll 
change it back without complaining if anyone else has a strong opinion, though!




Comment at: clang/include/clang/Driver/Options.td:3525
+   "For AArch32: 'soft' uses a function call, or 'tpidrurw', 
'tpidruro' or 'tpidrprw' use the three CP15 registers. 'cp15' is an alias for 
'tpidruro'. "
+   "For AArch64: 'tpidr_el0', 'tpidr_el1', 'tpidr_el2', 'tpidr_el3' or 
'tpidrro_el0' use the five system registers. 'elN' is an alias for 
'tpidr_elN'.">;
 def mpure_code : Flag<["-"], "mpure-code">, Alias; // Alias for 
GCC compatibility

rengolin wrote:
> From your comment:
> 
> > "In AArch32, on the other hand, the _only_ thread register you can choose 
> > (apart from 'none, use a function call') is the one that's read-only at 
> > EL0."
> 
> I inferred the current alias `el0` would map to the read-only version 
> `tpidrro_el0`.
> 
> Looking at the implementation below (`AArch64ExpandPseudoInsts.cpp`), `EL0` 
> seems to be the default when choosing the thread pointer?
If you inferred that, then I was unclear, and should reword :-)

`el0` is a name only accepted on AArch64, and maps to the AArch64 register 
`tpidr_el0`.

The only hardware option in AArch32 (before this commit) is called `cp15` 
(unhelpfully, since all three regs are in CP15), and is an alias for 
`tpidruro`, which is the AArch32 register that's readonly at EL0 and writable 
at EL1 (and in fact aliases the bottom 32 bits of tpidrro_el0).

Yes, the current defaults are different between AArch32 and 64 (unsurprisingly, 
since no register is currently supported on both), but that makes sense, since 
Linux also seems to do things differently. On AArch32 the code generation uses 
TPIDRURO, which unprivileged code can read but not write, and on AArch64 it 
uses TPIDR_EL0 which unprivileged code can overwrite if it wants to. I don't 
know why the defaults are different, but I have no plan to change them here!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152433

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


[PATCH] D150910: [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind (implements 29138)

2023-06-08 Thread MineGame159 via Phabricator via cfe-commits
MineGame159 updated this revision to Diff 529556.
MineGame159 added a comment.

Implemented requested changes


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

https://reviews.llvm.org/D150910

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/OperationKinds.def
  clang/tools/libclang/CIndex.cpp
  clang/unittests/libclang/LibclangTest.cpp

Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -1138,6 +1138,40 @@
 "class ns1::Class1");
 }
 
+TEST_F(LibclangParseTest, BinaryOperator) {
+  std::string Main = "main.cpp";
+  WriteFile(Main, "int foo() { return 5 + 9; };");
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, nullptr,
+   0, TUFlags);
+
+  Traverse([](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_BinaryOperator) {
+  EXPECT_EQ(clang_getCursorBinaryOperatorKind(cursor),
+CXBinaryOperator_Add);
+  return CXChildVisit_Break;
+}
+
+return CXChildVisit_Recurse;
+  });
+}
+
+TEST_F(LibclangParseTest, UnaryOperator) {
+  std::string Main = "main.cpp";
+  WriteFile(Main, "int foo() { int a = 5; return a++; };");
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, nullptr,
+   0, TUFlags);
+
+  Traverse([](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_UnaryOperator) {
+  EXPECT_EQ(clang_getCursorUnaryOperatorKind(cursor),
+CXUnaryOperator_PostInc);
+  return CXChildVisit_Break;
+}
+
+return CXChildVisit_Recurse;
+  });
+}
+
 class LibclangRewriteTest : public LibclangParseTest {
 public:
   CXRewriter Rew = nullptr;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -23,8 +23,11 @@
 #include "clang-c/FatalErrorHandler.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclObjCCommon.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/OpenMPClause.h"
+#include "clang/AST/OperationKinds.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticCategories.h"
@@ -9604,3 +9607,39 @@
 OS << "--\n";
   }
 }
+
+CXString clang_getBinaryOperatorKindSpelling(enum CXBinaryOperatorKind kind) {
+  return cxstring::createRef(
+  BinaryOperator::getOpcodeStr(static_cast(kind - 1)));
+}
+
+enum CXBinaryOperatorKind clang_getCursorBinaryOperatorKind(CXCursor cursor) {
+  if (clang_isExpression(cursor.kind)) {
+const Expr *expr = getCursorExpr(cursor);
+
+if (const BinaryOperator *op = dyn_cast(expr))
+  return static_cast(op->getOpcode() + 1);
+
+if (const CXXRewrittenBinaryOperator *op =
+dyn_cast(expr))
+  return static_cast(op->getOpcode() + 1);
+  }
+
+  return CXBinaryOperator_Invalid;
+}
+
+CXString clang_getUnaryOperatorKindSpelling(enum CXUnaryOperatorKind kind) {
+  return cxstring::createRef(
+  UnaryOperator::getOpcodeStr(static_cast(kind - 1)));
+}
+
+enum CXUnaryOperatorKind clang_getCursorUnaryOperatorKind(CXCursor cursor) {
+  if (clang_isExpression(cursor.kind)) {
+const Expr *expr = getCursorExpr(cursor);
+
+if (const UnaryOperator *op = dyn_cast(expr))
+  return static_cast(op->getOpcode() + 1);
+  }
+
+  return CXUnaryOperator_Invalid;
+}
Index: clang/include/clang/AST/OperationKinds.def
===
--- clang/include/clang/AST/OperationKinds.def
+++ clang/include/clang/AST/OperationKinds.def
@@ -362,8 +362,8 @@
 
 //===- Binary Operations  -===//
 // Operators listed in order of precedence.
-// Note that additions to this should also update the StmtVisitor class and
-// BinaryOperator::getOverloadedOperator.
+// Note that additions to this should also update the StmtVisitor class,
+// BinaryOperator::getOverloadedOperator and CXBinaryOperatorKind enum.
 
 // [C++ 5.5] Pointer-to-member operators.
 BINARY_OPERATION(PtrMemD, ".*")
@@ -415,8 +415,8 @@
 
 
 //===- Unary Operations ---===//
-// Note that additions to this should also update the StmtVisitor class and
-// UnaryOperator::getOverloadedOperator.
+// Note that additions to this should also update the StmtVisitor class,
+// UnaryOperator::getOverloadedOperator and CXUnaryOperatorKind enum.
 
 // [C99 6.5.2.4] Postfix increment and decrement
 UNARY_OPERATION(PostInc, "++")
Index: clang/include/clang-c/Index.h
===

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

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

Add a better test to show that attributes are replaced and default attributes 
are added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152391

Files:
  clang/include/clang/CodeGen/CodeGenAction.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCall.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/CodeGen/link-bitcode-file.c
  clang/test/CodeGen/link-builtin-bitcode.c

Index: clang/test/CodeGen/link-builtin-bitcode.c
===
--- /dev/null
+++ clang/test/CodeGen/link-builtin-bitcode.c
@@ -0,0 +1,42 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes --check-globals --include-generated-funcs --version 2
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx803 -DBITCODE -emit-llvm-bc -o %t-lib.bc %s
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm-bc -o %t.bc %s
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm \
+// RUN:   -mlink-builtin-bitcode %t-lib.bc -o - %t.bc | FileCheck %s
+
+#ifdef BITCODE
+int foo(void) { return 42; }
+int x = 12;
+#endif
+
+extern int foo(void);
+extern int x;
+
+int bar() { return foo() + x; }
+//.
+// CHECK: @x = internal addrspace(1) global i32 12, align 4
+//.
+// CHECK: Function Attrs: noinline nounwind optnone
+// CHECK-LABEL: define dso_local i32 @bar
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
+// CHECK-NEXT:[[CALL:%.*]] = call i32 @foo()
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr addrspacecast (ptr addrspace(1) @x to ptr), align 4
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i32 [[CALL]], [[TMP0]]
+// CHECK-NEXT:ret i32 [[ADD]]
+//
+//
+// CHECK: Function Attrs: convergent noinline nounwind optnone
+// CHECK-LABEL: define internal i32 @foo
+// CHECK-SAME: () #[[ATTR1:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
+// CHECK-NEXT:ret i32 42
+//
+//.
+// CHECK: attributes #0 = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx90a" "target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
+// CHECK: attributes #1 = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx90a" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
+//.
Index: clang/test/CodeGen/link-bitcode-file.c
===
--- clang/test/CodeGen/link-bitcode-file.c
+++ clang/test/CodeGen/link-bitcode-file.c
@@ -11,6 +11,14 @@
 // RUN: not %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file no-such-file.bc \
 // RUN:-emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=CHECK-NO-FILE %s
 
+// Make sure we can perform the same options if the input is LLVM-IR
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm-bc -o %t-in.bc %s
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file %t.bc \
+// RUN: -O3 -emit-llvm -o - %t-in.bc | FileCheck -check-prefix=CHECK-NO-BC %s
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -O3 -emit-llvm -o - \
+// RUN: -mlink-bitcode-file %t.bc -mlink-bitcode-file %t-2.bc %t-in.bc \
+// RUN: | FileCheck -check-prefix=CHECK-NO-BC -check-prefix=CHECK-NO-BC2 %s
+
 int f(void);
 
 #ifdef BITCODE
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/CodeGen/CodeGenAction.h"
+#include "CGCall.h"
 #include "CodeGenModule.h"
 #include "CoverageMappingGen.h"
 #include "MacroPPCallbacks.h"
@@ -262,7 +263,7 @@
 }
 
 // Links each entry in LinkModules into our module.  Returns true on error.
-bool LinkInModules() {
+bool LinkInModules(llvm::Module *M = nullptr) {
   for (auto &LM : LinkModules) {
 assert(LM.Module && "LinkModule does not actually have a module");
 if (LM.PropagateAttrs)
@@ -271,8 +272,8 @@
 // in LLVM IR.
 if (F.isIntrinsic())
   continue;
-Gen->CGM().mergeDefaultFunctionDefinitionAttribute

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

2023-06-08 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:169-170
 
   /// The indent in characters for each level.
+  /// It remembers the indent of previous lines (that are not PP directives) of
+  /// equal or lower levels. This is used to align formatted lines to the 
indent

Sedeniono wrote:
> Sedeniono wrote:
> > HazardyKnusperkeks wrote:
> > > And then reformat the comment.
> > Done.
> Mh, it says [that it couldn't apply the 
> patch](https://reviews.llvm.org/harbormaster/build/367648/). I uploaded a 
> patch containing as only change the reformatted comment, via the Web UI 
> ("Update Diff" at the top right corner). Should I have uploaded a "squashed" 
> diff, containing also ALL changes that I made before (the `resize` etc)? In 
> other words, is Phabricator expecting individual patches and it merges and 
> accumulates them itself? Or does each new uploaded patch overwrite all 
> previous patches?
The latter


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] D152396: [clang][doc] Rescue some deleted bits of the command-line reference.

2023-06-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: jansvoboda11, MaskRay.
aaron.ballman added a comment.
Herald added a subscriber: bd1976llvm.

These changes LGTM, thank you!

@MaskRay, @jansvoboda11  -- I think we need to figure out a better strategy for 
documenting compiler options. We have documentation that lives here in 
`Options.td`, but we also have documentation in `UsersManual.rst`; it would be 
good for us to have a unified place for option documentation so users don't 
have to click around so much (and so we don't accidentally wind up with 
conflicting documentation in two places). My suggestion is that we use 
`Options.td` to generate all of the docs, and move what we've got in 
`UsersManual.rst` (and elsewhere, if we find it) into here. Additionally, I 
think we should take any long-form documentation and split it between 
`ClangOptionDocs.td` and `Options.td` similar to how we already do for 
`Attr.td` and `AttrDocs.td` or `Diagnostic*Kinds.td` and `DiagnosticDocs.td` 
(so the documentation is generated from a single source, but we don't have to 
clutter that file up with longer documentation strings). Finally, I think we 
should begin to require documentation for all new user-facing driver options as 
part of the code review process (we can even enforce this by failing a build if 
a driver option has no associated documentation, similar to how we do it for 
attributes; we use an `Undocumented` placeholder for all the existing options 
without documentation so those can be backfilled over time). WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152396

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


[PATCH] D152435: [analyzer][CStringChecker] Adjust the invalidation operation on the super region of the destination buffer during string copy

2023-06-08 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie created this revision.
OikawaKirie added reviewers: pgousseau, NoQ, steakhal, balazske, xazax.hun.
OikawaKirie added a project: clang.
Herald added subscribers: manas, ASDenysPetrov, martong, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware.
Herald added a project: All.
OikawaKirie requested review of this revision.
Herald added a subscriber: cfe-commits.

Fixing GitHub issue: https://github.com/llvm/llvm-project/issues/55019
Following the previous fix https://reviews.llvm.org/D12571 on issue 
https://github.com/llvm/llvm-project/issues/23328

The two issues report false memory leaks after calling string-copy APIs with a 
buffer field in an object as the destination.
The buffer invalidation incorrectly drops the assignment to a heap memory block 
when no overflow problems happen.
And the pointer of the dropped assignment is declared in the same object of the 
destination buffer.

The previous fix only considers the `memcpy` functions whose copy length is 
available from arguments.
In this issue, the copy length is inferable from the buffer declaration and 
string literals being copied.
Therefore, I have adjusted the previous fix to reuse the copy length computed 
before.

Besides, for APIs that never overflow (strsep) or we never know whether they 
can overflow (std::copy),
new flags have been introduced to inform CStringChecker::InvalidateBuffer 
whether or not to
invalidate the super region that encompasses the destination buffer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152435

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/issue-55019.c
  clang/test/Analysis/issue-55019.cpp
  clang/test/Analysis/pr22954.c

Index: clang/test/Analysis/pr22954.c
===
--- clang/test/Analysis/pr22954.c
+++ clang/test/Analysis/pr22954.c
@@ -557,11 +557,12 @@
   char input[] = {'a', 'b', 'c', 'd'};
   memcpy(x263.s1, input, *(len + n));
   clang_analyzer_eval(x263.s1[0] == 0); // expected-warning{{UNKNOWN}}
+  // expected-warning@-1{{Potential leak of memory pointed to by 'x263.s2'}}
   clang_analyzer_eval(x263.s1[1] == 0); // expected-warning{{UNKNOWN}}
   clang_analyzer_eval(x263.s1[2] == 0); // expected-warning{{UNKNOWN}}
   clang_analyzer_eval(x263.s1[3] == 0); // expected-warning{{UNKNOWN}}
   clang_analyzer_eval(x263.s2 == 0); // expected-warning{{UNKNOWN}}
-  return 0; // expected-warning{{Potential leak of memory pointed to by 'x263.s2'}}
+  return 0;
 }
 
 
Index: clang/test/Analysis/issue-55019.cpp
===
--- /dev/null
+++ clang/test/Analysis/issue-55019.cpp
@@ -0,0 +1,29 @@
+// Refer issue 55019 for more details.
+
+// RUN: %clang_analyze_cc1 %s -verify \
+// RUN:   -analyzer-checker=core,debug.ExprInspection
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+struct mystruct {
+  char *ptr;
+  char arr[4];
+};
+
+void clang_analyzer_dump(const void *);
+
+// CStringChecker::evalStdCopyCommon
+void fstdcopy() {
+  mystruct x;
+  x.ptr = new char;
+  clang_analyzer_dump(x.ptr); // expected-warning {{HeapSymRegion}}
+
+  const char *p = "x";
+  std::copy(p, p + 1, x.arr);
+
+  // FIXME: As we cannot know whether the copy overflows, we will invalidate the
+  // entire object. Modify the verify direction from SymRegion to HeapSymRegion
+  // when the size if modeled in CStringChecker.
+  clang_analyzer_dump(x.ptr); // expected-warning {{SymRegion}}
+  delete x.ptr;   // no-warning
+}
Index: clang/test/Analysis/issue-55019.c
===
--- /dev/null
+++ clang/test/Analysis/issue-55019.c
@@ -0,0 +1,69 @@
+// Refer issue 55019 for more details.
+
+// RUN: %clang_analyze_cc1 %s -verify -Wno-strict-prototypes \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix \
+// RUN:   -analyzer-checker=debug.ExprInspection
+
+#include "Inputs/system-header-simulator.h"
+void *malloc(size_t);
+void free(void *);
+
+#define SIZE 4
+
+struct mystruct {
+  void *ptr;
+  char arr[SIZE];
+};
+
+void clang_analyzer_dump(const void *);
+
+// CStringChecker::memsetAux
+void fmemset() {
+  struct mystruct x;
+  x.ptr = malloc(1);
+  clang_analyzer_dump(x.ptr); // expected-warning {{HeapSymRegion}}
+  memset(x.arr, 0, SIZE);
+  clang_analyzer_dump(x.ptr); // expected-warning {{HeapSymRegion}}
+  free(x.ptr);// no-warning
+}
+
+// CStringChecker::evalCopyCommon
+void fmemcpy() {
+  struct mystruct x;
+  x.ptr = malloc(1);
+  clang_analyzer_dump(x.ptr); // expected-warning {{HeapSymRegion}}
+  memcpy(x.arr, "hi", 2);
+  clang_analyzer_dump(x.ptr); // expected-warning {{HeapSymRegion}}
+  free(x.ptr);// no-warning
+}
+
+// CStringChecker::evalStrcpyCommon
+void fstrcpy() {
+  struct mystruct x;
+  x.ptr = malloc(1);
+  clang_analyzer_dump(x.p

[PATCH] D142932: Multilib YAML parsing

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

FlagMap->Mappings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142932

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

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

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

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

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142933

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

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

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

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

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142986

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

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

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

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

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143059

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

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

[PATCH] D150910: [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind (implements 29138)

2023-06-08 Thread MineGame159 via Phabricator via cfe-commits
MineGame159 added a comment.

I kinda thought the undefined reference error is just something I broke on my 
machine but guess not. Don't really know what can cause it since it can link to 
other functions from there and the function exists.


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

https://reviews.llvm.org/D150910

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


[PATCH] D143075: BareMetal ToolChain multilib layering

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

Simplify code as suggested by @phosek


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143075

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

Index: clang/test/Driver/baremetal-multilib-layered.yaml
===
--- /dev/null
+++ clang/test/Driver/baremetal-multilib-layered.yaml
@@ -0,0 +1,45 @@
+# REQUIRES: shell
+# UNSUPPORTED: system-windows
+
+# This test demonstrates "layered" multilib in which more than one
+# multilib is matched.
+# For example a multilib containing only a no-exceptions libc++ could
+# be layered on top of a multilib containing C libs. This avoids the
+# need to duplicate the C library for every libc++ variant.
+# However -fno-exceptions is not yet supported for multilib selection
+# so we use a more contrived -mfloat-abi example instead.
+
+# RUN: rm -rf %T/baremetal_multilib_layered
+# RUN: mkdir -p %T/baremetal_multilib_layered/bin
+# RUN: mkdir -p %T/baremetal_multilib_layered/lib/clang-runtimes
+# RUN: ln -s %clang %T/baremetal_multilib_layered/bin/clang
+# RUN: ln -s %s %T/baremetal_multilib_layered/lib/clang-runtimes/multilib.yaml
+
+# RUN: %T/baremetal_multilib_layered/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \
+# RUN: --target=thumbv7m-none-eabi -mfloat-abi=softfp --sysroot= \
+# RUN:   | FileCheck -DSYSROOT=%T/baremetal_multilib_layered %s
+# CHECK:  "-cc1" "-triple" "thumbv7m-none-unknown-eabi"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/softfp/include/c++/v1"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/soft/include/c++/v1"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/softfp/include"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/soft/include"
+# CHECK-NEXT: "-L[[SYSROOT]]/bin/../lib/clang-runtimes/softfp/lib"
+# CHECK-SAME: "-L[[SYSROOT]]/bin/../lib/clang-runtimes/soft/lib"
+
+# RUN: %T/baremetal_multilib_layered/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \
+# RUN: --target=arm-none-eabi -mfloat-abi=softfp --sysroot= \
+# RUN:   | FileCheck --check-prefix=CHECK-PRINT-MULTI-DIRECTORY %s
+# CHECK-PRINT-MULTI-DIRECTORY:  soft
+# CHECK-PRINT-MULTI-DIRECTORY-NEXT: softfp
+
+---
+MultilibVersion: 1.0
+Variants:
+- Dir: soft
+  Flags: [-mfloat-abi=soft]
+- Dir: softfp
+  Flags: [-mfloat-abi=softfp]
+Mappings:
+- Match: -mfloat-abi=softfp
+  Flags: [-mfloat-abi=soft]
+...
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- clang/lib/Driver/ToolChains/BareMetal.h
+++ clang/lib/Driver/ToolChains/BareMetal.h
@@ -71,6 +71,11 @@
   void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs) const;
   std::string computeSysRoot() const override;
+
+private:
+  using OrderedMultilibs =
+  llvm::iterator_range::const_reverse_iterator>;
+  OrderedMultilibs getOrderedMultilibs() const;
 };
 
 } // namespace toolchains
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -103,9 +103,12 @@
   findMultilibs(D, Triple, Args);
   SmallString<128> SysRoot(computeSysRoot());
   if (!SysRoot.empty()) {
-llvm::sys::path::append(SysRoot, "lib");
-getFilePaths().push_back(std::string(SysRoot));
-getLibraryPaths().push_back(std::string(SysRoot));
+for (const Multilib &M : getOrderedMultilibs()) {
+  SmallString<128> Dir(SysRoot);
+  llvm::sys::path::append(Dir, M.osSuffix(), "lib");
+  getFilePaths().push_back(std::string(Dir));
+  getLibraryPaths().push_back(std::string(Dir));
+}
   }
 }
 
@@ -222,10 +225,17 @@
 }
 
 std::string BareMetal::computeSysRoot() const {
-  std::string Result = computeBaseSysRoot(getDriver(), getTriple());
+  return computeBaseSysRoot(getDriver(), getTriple());
+}
+
+BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const {
+  // Get multilibs in reverse order because they're ordered most-specific last.
   if (!SelectedMultilibs.empty())
-Result += SelectedMultilibs.back().osSuffix();
-  return Result;
+return llvm::reverse(SelectedMultilibs);
+
+  // No multilibs selected so return a single default multilib.
+  static const llvm::SmallVector Default = {Multilib()};
+  return llvm::reverse(Default);
 }
 
 void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
@@ -240,10 +250,14 @@
   }
 
   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
-SmallString<128> Dir(computeSysRoot());
-if (!Dir.empty()) {
-  llvm::sys::path::a

[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-06-08 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, gamesh411, 
dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a reviewer: NoQ.
Herald added a project: All.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This checker can be good enough to move out of alpha.
I am not sure about the exact requirements, this review can be a place
for discussion about what should be fixed (if any).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152436

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/test/Analysis/PR49642.c
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/analyzer-enabled-checkers.c
  clang/test/Analysis/conversion.c
  clang/test/Analysis/errno-stdlibraryfunctions-notes.c
  clang/test/Analysis/errno-stdlibraryfunctions.c
  clang/test/Analysis/std-c-library-functions-POSIX-lookup.c
  clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c
  clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-notes.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
  clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c
  clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c
  clang/test/Analysis/std-c-library-functions-arg-weakdeps.c
  clang/test/Analysis/std-c-library-functions-eof.c
  clang/test/Analysis/std-c-library-functions-inlined.c
  clang/test/Analysis/std-c-library-functions-lookup.c
  clang/test/Analysis/std-c-library-functions-lookup.cpp
  clang/test/Analysis/std-c-library-functions-path-notes.c
  clang/test/Analysis/std-c-library-functions-restrict.c
  clang/test/Analysis/std-c-library-functions-restrict.cpp
  clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
  clang/test/Analysis/std-c-library-functions.c
  clang/test/Analysis/std-c-library-functions.cpp
  clang/test/Analysis/std-c-library-posix-crash.c
  clang/test/Analysis/stream-errno-note.c
  clang/test/Analysis/stream-errno.c
  clang/test/Analysis/stream-noopen.c
  clang/test/Analysis/stream-note.c
  clang/test/Analysis/stream-stdlibraryfunctionargs.c
  clang/test/Analysis/weak-dependencies.c

Index: clang/test/Analysis/weak-dependencies.c
===
--- clang/test/Analysis/weak-dependencies.c
+++ clang/test/Analysis/weak-dependencies.c
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 %s -verify \
-// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=unix.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=core
 
 typedef __typeof(sizeof(int)) size_t;
Index: clang/test/Analysis/stream-stdlibraryfunctionargs.c
===
--- clang/test/Analysis/stream-stdlibraryfunctionargs.c
+++ clang/test/Analysis/stream-stdlibraryfunctionargs.c
@@ -1,11 +1,11 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream,alpha.unix.StdCLibraryFunctions,debug.ExprInspection \
-// RUN:   -analyzer-config alpha.unix.StdCLibraryFunctions:ModelPOSIX=true -verify=stream,any %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream,unix.StdCLibraryFunctions,debug.ExprInspection \
+// RUN:   -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true -verify=stream,any %s
 
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream,debug.ExprInspection \
-// RUN:   -analyzer-config alpha.unix.StdCLibraryFunctions:ModelPOSIX=true -verify=stream,any %s
+// RUN:   -verify=stream,any %s
 
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.StdCLibraryFunctions,debug.ExprInspection \
-// RUN:   -analyzer-config alpha.unix.StdCLibraryFunctions:ModelPOSIX=true -verify=stdfunc,any %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.StdCLibraryFunctions,debug.ExprInspection \
+// RUN:   -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true -verify=stdfunc,any %s
 
 #include "Inputs/system-header-simulator.h"
 
Index: clang/test/Analysis/stream-note.c
===
--- clang/test/Analysis/stream-note.c
+++ clang/test/Analysis/stream-note.c
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream -analyzer-output text \
 // RUN:   -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream,alpha.unix.StdCLibraryFunctions -analyzer-output text \
-// RUN:   -analyzer-config alpha.unix.StdCLibraryFunctions:ModelPOSIX=true -verify=expected,stdargs

[PATCH] D143587: [Docs] Multilib design

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

Update docs to reflect recent changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143587

Files:
  clang/docs/Multilib.rst
  clang/docs/index.rst

Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -100,6 +100,7 @@
CodeOwners
InternalsManual
DriverInternals
+   Multilib
OffloadingDesign
PCHInternals
ItaniumMangleAbiTags
Index: clang/docs/Multilib.rst
===
--- /dev/null
+++ clang/docs/Multilib.rst
@@ -0,0 +1,310 @@
+
+Multilib
+
+
+Introduction
+
+
+This document describes how multilib is implemented in Clang.
+
+What is multilib and why might you care?
+If you're :doc:`cross compiling` then you can't use native
+system headers and libraries. To address this, you can use a combination of
+``--sysroot``, ``-isystem`` and ``-L`` options to point Clang at suitable
+directories for your target.
+However, when there are many possible directories to choose from, it's not
+necessarily obvious which one to pick.
+Multilib allows a toolchain designer to imbue the toolchain with the ability to
+pick a suitable directory automatically, based on the options the user provides
+to Clang. For example, if the user specifies
+``--target=arm-none-eabi -mcpu=cortex-m4`` the toolchain can choose a directory
+containing headers and libraries suitable for Armv7E-M, because it knows that's
+a suitable architecture for Arm Cortex-M4.
+Multilib can also choose between libraries for the same architecture based on
+other options. For example if the user specifies ``-fno-exceptions`` then a
+toolchain could select libraries built without exception support, thereby
+reducing the size of the resulting binary.
+
+Design
+==
+
+Clang supports GCC's ``-print-multi-lib`` and ``-print-multi-directory``
+options. These are described in
+`GCC Developer Options `_.
+
+There are two ways to configure multilib in Clang: hard-coded or via a
+configuration file.
+
+Hard-coded Multilib
+===
+
+The available libraries can be hard-coded in Clang. Typically this is done
+using the ``MultilibBuilder`` interface in
+``clang/include/clang/Driver/MultilibBuilder.h``.
+There are many examples of this in ``lib/Driver/ToolChains/Gnu.cpp``.
+The remainder of this document will not focus on this type of multilib.
+
+EXPERIMENTAL Multilib via configuration file
+
+
+Some Clang toolchains support loading multilib configuration from a
+``multilib.yaml`` configuration file.
+
+A ``multilib.yaml`` configuration file specifies which multilib variants are
+available, their relative location, what compilation options were used to build
+them, and the criteria by which they are selected.
+
+Multilib processing
+===
+
+Clang goes through the following steps to use multilib from a configuration
+file:
+#. Normalize command line options. Clang can accept the same
+   information via different options - for example,
+   ``--target=arm-none-eabi -march=armv7-m`` and
+   ``--target=armv7m-none-eabi`` are equivalent.
+   Clang normalizes the command line before passing them to the multilib system.
+   To see what flags are emitted for a given set of command line options, use
+   the ``-print-multi-flags-experimental`` command line option
+   along with the rest of the options you want to use.
+#. Load ``multilib.yaml`` from sysroot.
+#. Generate additional flags. ``multilib.yaml`` contains a ``FlagMap`` section,
+   which specifies how to generate additional flags based on the flags derived
+   from command line options. Flags are matched using regular expressions.
+   These regular expressions shall use the POSIX extended regular expression
+   syntax.
+#. Match flags against multilib variants. If the generated flags are a superset
+   of the flags specified for a multilib variant then the variant is considered
+   a match.
+   If more than one variant matches then a toolchain may opt to either use only
+   the *last* matching multilib variant, or may use all matching variants,
+   thereby :ref:`layering` them.
+#. Generate ``-isystem`` and ``-L`` options. Iterate in reverse order over
+   the matching multilib variants, and generate ``-isystem`` and ``-L``
+   options based on the multilib variant's directory.
+
+Multilib layering
+=
+
+When Clang selects multilib variants, it may find that more than one variant
+matches.
+
+It is up to the ToolChain subclass to decide what to do in this case.
+There are two options permitted:
+#. Use only the *last* matching multilib variant. This option exists primarily
+   for compatibility w

[PATCH] D152415: [RISCV] Add test cases to show that rvv_vector_bits attribute is not accepted for vbool or LMUL!=1 RVV types. NFC

2023-06-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM. thank you for the extra test coverage!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152415

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


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

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

I could test the checker on these projects (CTU analysis was not used):
memcached,tmux,curl,twin,vim,openssl,sqlite,ffmpeg,postgres,tinyxml2,libwebm,xerces,bitcoin,protobuf,qtbase,contour,acid

These are reports that could be improved:
link 

In this case function `fileno` returns -1 because of failure, but this is not 
indicated in a `NoteTag`. This is a correct result, only the note is missing. 
This problem can be solved if a note is displayed on every branch ("case") of 
the standard C functions. But this leads to many notes at un-interesting 
places. If the note is displayed only at "interesting" values another 
difficulty shows up: The note disappears from places where it should be shown 
because the "interestingness" is not set, for example at conditions of `if` 
statement. So the solution may require more work. This case with function 
`fileno` occurs 13 times in all the tested projects.
link 

The function `open` is not modeled in `StdCLibraryFunctionsChecker`, it should 
not return less than -1 but this information is not included now.
link 

This looks wrong, `L` should not be 0 because `len` looks > 0 (see the macros 
that set `len`). Probably the many bitwise operations cause the problem.
link 

`socket` can not return less than -1 but this function is not modeled currently.
link 

`fwrite` with 0 buffer and 0 size should not be an error, this is not checked 
now.
link 

When `file_size` is 0 `status.ok()` is probably false that is not correctly 
recognized (may work in CTU mode?).

These results look good:
link 

link 

link 

link 

link 

link 

link 


[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

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



Comment at: clang/docs/ReleaseNotes.rst:589
+  ``hostcall`` - printing happens during kernel execution via series of 
hostcalls,
+  The scheme requires the system to support pcie atomics.(default)
+  ``buffered`` - Scheme uses a debug buffer to populate printf varargs, does 
not

I thought the default was buffered, such that it would always work. Defaults 
that always work are better

Also, amdgpu-arch should probably learn to report if pcie atomics work to 
improve the autodetect



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4705-4707
+// Force compiler error on invalid conversion specifiers
+CmdArgs.push_back(
+Args.MakeArgString("-Werror=format-invalid-specifier"));

I don't see why we would special case this 



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:361
+default:
+  llvm_unreachable("unexpected Integer Type");
+}

It costs nothing to handle all types < 64. For larger just return the original 
value 



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:368
+
+  if (Ty->isHalfTy())
+return Builder.CreateFPExt(Arg, Builder.getDoubleTy());

Should avoid special casing this too, there's also bfloat to consider at a 
minimum 



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:371
+
+  llvm_unreachable("unexpected type");
+}

Safest to just return the original value



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:413
+
+for (unsigned I = 0, E = WhatToStore.size(); I != E; ++I) {
+  Value *toStore = WhatToStore[I];

Range loop, index is unused 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

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


[PATCH] D150926: [RISCV] Support LMUL!=1 for __attribute__((riscv_rvv_vector_bits(N)))

2023-06-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/Sema/SemaType.cpp:8338
   // The attribute vector size must match -mrvv-vector-bits.
-  if (VecSize != VScale->first * MinElts * EltSize) {
+  unsigned ExpectedSize = VScale->first * MinElts * EltSize;
+  if (VecSize != ExpectedSize) {

craig.topper wrote:
> aaron.ballman wrote:
> > Random thought I didn't think to ask earlier: is it possible for this 
> > multiplication to overflow (if so, we should add test coverage to make sure 
> > we don't do bad things)?
> The largest value for -mrvv-vector-bits is 65536 which makes VScale->first 
> 65536/64 == 1024. MinElts and EltSize should be small enough that it won't 
> overflow.
> 
> I'm not sure if there's any protection if someone bypasses the driver with 
> `-Xclang -mvscale-min=` and uses a larger value.
> The largest value for -mrvv-vector-bits is 65536 which makes VScale->first 
> 65536/64 == 1024. MinElts and EltSize should be small enough that it won't 
> overflow.

Fantastic, thank you!

> I'm not sure if there's any protection if someone bypasses the driver with 
> -Xclang -mvscale-min= and uses a larger value.

IMO, using cc1 options is compiler YOLO-mode, so I don't mind if this has no 
protection.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150926

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


[PATCH] D150910: [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind (implements 29138)

2023-06-08 Thread Igor Kushnir via Phabricator via cfe-commits
vedgy added a comment.

In D150910#4405536 , @MineGame159 
wrote:

> I kinda thought the undefined reference error is just something I broke on my 
> machine but guess not. Don't really know what can cause it since it can link 
> to other functions from there and the function exists.

I suspect the reason for the failed build is that you haven't updated 
`clang/tools/libclang/libclang.map`. Also `CINDEX_VERSION_MINOR` in 
`clang/include/clang-c/Index.h` needs to be incremented, unless it has been 
incremented in the targeted LLVM release version already. See e.g. 
cc929590ad305f0d068709c7c7999f5fc6118dc9 
.


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

https://reviews.llvm.org/D150910

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


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

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

One deficiency is that some filenames of test files contain the old 
**std-c-library-functions-arg** name that is not used any more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

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

Another question is if default value of `ModelPOSIX` can be changed to true?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D150446: [analyzer] Check ArraySubscriptExprs in ArrayBoundCheckerV2

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

Hmm, I agree that a new checker might be better for the situation when we'd 
sacrifice a significant amount of TPs, but after reconsidering the situation I 
think that my concerns are mostly theoretical: if the current code reports an 
issue, then it's probably not too difficult to provide a concise and useful bug 
report for it. (And if the issue is an eldritch mess that cannot be described 
in a concise manner, then it's better to ignore it...)

I might still temporarily "sacrifice" TPs or other advantages during the 
initial steps of the code reorganization (to keep the commit size more 
manageable), but I'll pay attention to compensating these in later commits 
(which may be merged at the same moment as the earlier ones).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150446

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


[PATCH] D152433: [ARM,AArch64] Add a full set of -mtp= options.

2023-06-08 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a subscriber: olista01.
rengolin added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3525
+   "For AArch32: 'soft' uses a function call, or 'tpidrurw', 
'tpidruro' or 'tpidrprw' use the three CP15 registers. 'cp15' is an alias for 
'tpidruro'. "
+   "For AArch64: 'tpidr_el0', 'tpidr_el1', 'tpidr_el2', 'tpidr_el3' or 
'tpidrro_el0' use the five system registers. 'elN' is an alias for 
'tpidr_elN'.">;
 def mpure_code : Flag<["-"], "mpure-code">, Alias; // Alias for 
GCC compatibility

simon_tatham wrote:
> rengolin wrote:
> > From your comment:
> > 
> > > "In AArch32, on the other hand, the _only_ thread register you can choose 
> > > (apart from 'none, use a function call') is the one that's read-only at 
> > > EL0."
> > 
> > I inferred the current alias `el0` would map to the read-only version 
> > `tpidrro_el0`.
> > 
> > Looking at the implementation below (`AArch64ExpandPseudoInsts.cpp`), `EL0` 
> > seems to be the default when choosing the thread pointer?
> If you inferred that, then I was unclear, and should reword :-)
> 
> `el0` is a name only accepted on AArch64, and maps to the AArch64 register 
> `tpidr_el0`.
> 
> The only hardware option in AArch32 (before this commit) is called `cp15` 
> (unhelpfully, since all three regs are in CP15), and is an alias for 
> `tpidruro`, which is the AArch32 register that's readonly at EL0 and writable 
> at EL1 (and in fact aliases the bottom 32 bits of tpidrro_el0).
> 
> Yes, the current defaults are different between AArch32 and 64 
> (unsurprisingly, since no register is currently supported on both), but that 
> makes sense, since Linux also seems to do things differently. On AArch32 the 
> code generation uses TPIDRURO, which unprivileged code can read but not 
> write, and on AArch64 it uses TPIDR_EL0 which unprivileged code can overwrite 
> if it wants to. I don't know why the defaults are different, but I have no 
> plan to change them here!
Right! The confusion was on my side on the overloaded `EL0` for both the 
register name in AArch64 and the processor state on both. I should have noticed 
the capitalisation difference. Now it makes sense, thanks!

> I don't know why the defaults are different, but I have no plan to change 
> them here!

Ack. First introduce functionality, then investigate why (on a separate patch).

@olista01 might remember something...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152433

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


[PATCH] D152303: [ExprConstant] fix ICE from Evaluate on _Atomic structs

2023-06-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak 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/D152303/new/

https://reviews.llvm.org/D152303

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


[PATCH] D152303: [ExprConstant] fix ICE from Evaluate on _Atomic structs

2023-06-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

Please add a release note for the fix, but otherwise LGTM. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152303

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


[PATCH] D152070: [2/11][Clang][RISCV] Expand all variants of RVV intrinsic tuple types

2023-06-08 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: clang/lib/Support/RISCVVIntrinsicUtils.cpp:819
-  // LMUL x NF must be less than or equal to 8.
-  if ((Log2LMUL >= 1) && (1 << Log2LMUL) * NF > 8)
-return std::nullopt;

Keep as assert?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152070

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


[PATCH] D152269: [StaticAnalyzer] Fix false negative on NilArgChecker when creating literal object

2023-06-08 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

T

In D152269#4403491 , @tripleCC wrote:

> In D152269#4403404 , @steakhal 
> wrote:
>
>> In D152269#4403282 , @tripleCC 
>> wrote:
>>
>>> Yes, your changes are aligned with my intent. It seems like you have made 
>>> excellent optimizations to this patch. 
>>> To eliminate the following two warnings, I add the `-fobjc-arc`(enable 
>>> Automatic Reference Counting) compilation option for NSContainers test .
>>>
>>>   +  MyView *view = b ? [[MyView alloc] init] : 0; // expected-warning 
>>> {{Potential leak of an object stored into 'view'}}
>>>   +  NSMutableArray *subviews = [[view subviews] mutableCopy]; // 
>>> expected-warning {{Potential leak of an object stored into 'subviews'}}
>>
>> I think we shouldn't add the `-fobj-arc` as these two new issues are 
>> considered TPs, and meaningful for the test file they are part of. It's just 
>> that they are not that meaningful in the scope of this patch, but that 
>> shouldn't hold us back from improving what the test covers and demonstrates, 
>> so I'm fine if those two appear as part of this patch.
>>
>>> I will continue to contribute more ObjC-related fixes in the future, and 
>>> currently, my work is also related to this.
>>
>> Sounds good. Thanks for clarifying.
>> If that's the case, after a few more quality patches I think it would make 
>> sense to request you commit access. Let's keep this in mind now.
>>
>>> Thank you very much for your review. Would you mind if I merge your 
>>> recommendations?
>>
>> I don't mind. You don't need to give attribution. Keep parts of the whole as 
>> you wish.
>
> Thanks.
>
> By the way , there are already other unit tests focus on leak scenarios, such 
> as the retain-release*.m test cases. Should we focus on testing container 
> issues here? Currently, Objective-C code almost always uses ARC (Automatic 
> Reference Counting).

Both makes sense. You can probably better judge this. I'm totally fine with any 
of the two options.

One note, clang-format the affected lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152269

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


[PATCH] D152051: libclang-cpp: Add external visibility attribute to all classes

2023-06-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: majnemer, rnk.
aaron.ballman added a comment.

I seem to recall this came up in the past and there were issues, so I did some 
digging around our mail archives and figured I'd share what I found:

https://discourse.llvm.org/t/big-clang-dll-plug-in-mechanism-revision/19376/5
https://discourse.llvm.org/t/distributing-libclang-cpp-dll-for-windows-in-the-pre-built-downloads/54778
https://lists.llvm.org/pipermail/llvm-dev/2017-June/113925.html

However, those concerns seem to be more around dllexport behavior on Windows, 
so LLVM_LIBRARY_VISIBILITY shouldn't matter there.

CC @rnk @majnemer @compnerd for confirmation that we shouldn't also be thinking 
about Windows symbol exports.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152051

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


[PATCH] D152051: libclang-cpp: Add external visibility attribute to all classes

2023-06-08 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

I chatted with @compnerd on Discord, and I'm going to try to update D109192 
 and get that committed and then come back to 
this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152051

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


[PATCH] D152442: [LinkerWrapper] Support linking vendor bitcode late

2023-06-08 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, tra, yaxunl, tianshilei1992, 
jdoerfert, gregrodgers, saiislam.
Herald added a subscriber: tpr.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

The GPU vendors currently provide bitcode files for their device
runtime. These files need to be handled specially as they are not built
to be linked in with a standard `llvm-link` call or through LTO linking.
This patch adds an alternative to use the existing clang handling of
these libraries that does the necessary magic to make this work.

We do this by causing the LTO backend to emit bitcode before running the
backend. We then pass this through to clang which uses the existing
support which has been fixed to support this by D152391 
. The backend
will then be run with the merged module.

This patch adds the `--builtin-bitcode==file.bc` to specify a single
file, or just `--clang-backend` to let the toolchain handle its defaults
(currently nothing for NVPTX and the ROCm device libs for AMDGPU). This may have
a performance impact due to running the optimizations again, we could
potentially disable optimizations in LTO and only do the linking if this is an
issue.

This should allow us to resolve issues when relying on the `linker-wrapper` to
do a late linking that may depend on vendor libraries.

Depends on D152391 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152442

Files:
  clang/test/Driver/linker-wrapper.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td


Index: clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
===
--- clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
+++ clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
@@ -25,9 +25,16 @@
 def bitcode_library_EQ : Joined<["--"], "bitcode-library=">,
   Flags<[WrapperOnlyOption]>, MetaVarName<"--=">,
   HelpText<"Extra bitcode library to link">;
+def builtin_bitcode_EQ : Joined<["--"], "builtin-bitcode=">,
+  Flags<[WrapperOnlyOption]>, MetaVarName<"=">,
+  HelpText<"Perform a special internalizing link on the bitcode file. "
+   "This is necessary for some vendor libraries to be linked 
correctly">;
 def device_linker_args_EQ : Joined<["--"], "device-linker=">,
   Flags<[WrapperOnlyOption]>, MetaVarName<" or =">,
   HelpText<"Arguments to pass to the device linker invocation">;
+def clang_backend : Flag<["--"], "clang-backend">,
+  Flags<[WrapperOnlyOption]>,
+  HelpText<"Run the backend using clang rather than the LTO backend">;
 def dry_run : Flag<["--"], "dry-run">,
   Flags<[WrapperOnlyOption]>,
   HelpText<"Print program arguments without running">;
Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -427,6 +427,17 @@
   for (StringRef Arg : Args.getAllArgValues(OPT_linker_arg_EQ))
 CmdArgs.push_back(Args.MakeArgString("-Wl," + Arg));
 
+  for (StringRef Arg : Args.getAllArgValues(OPT_builtin_bitcode_EQ)) {
+if (llvm::Triple(Arg.split('=').first) == Triple)
+  CmdArgs.append({"-Xclang", "-mlink-builtin-bitcode", "-Xclang",
+  Args.MakeArgString(Arg.split('=').second)});
+  }
+
+  // The OpenMPOpt pass can introduce new calls and is expensive, we do not 
want
+  // this when running CodeGen through clang.
+  if (Args.hasArg(OPT_clang_backend) || Args.hasArg(OPT_builtin_bitcode_EQ))
+CmdArgs.append({"-mllvm", "-openmp-opt-disable"});
+
   if (Error Err = executeCommands(*ClangPath, CmdArgs))
 return std::move(Err);
 
@@ -629,7 +640,7 @@
   llvm::erase_if(InputFiles, [](OffloadFile &F) { return !F.getBinary(); });
 
   // LTO Module hook to output bitcode without running the backend.
-  SmallVector BitcodeOutput;
+  SmallVector BitcodeOutput;
   auto OutputBitcode = [&](size_t, const Module &M) {
 auto TempFileOrErr = createOutputFile(sys::path::filename(ExecutableName) +
   "-jit-" + Triple.getTriple(),
@@ -648,7 +659,9 @@
 
   // We assume visibility of the whole program if every input file was bitcode.
   auto Features = getTargetFeatures(BitcodeInputFiles);
-  auto LTOBackend = Args.hasArg(OPT_embed_bitcode)
+  auto LTOBackend = Args.hasArg(OPT_embed_bitcode) ||
+Args.hasArg(OPT_builtin_bitcode_EQ) ||
+Args.hasArg(OPT_clang_backend)
 ? createLTO(Args, Features, OutputBitcode)
 : createLTO(Args, Features);
 
@@ -757,8 +770,12 @@
 return Error::success();
   }
 
-  // Append the new inputs to the 

[PATCH] D152443: Add SpaceAfterOperatorKeyword style option for clang-format

2023-06-08 Thread Alexander Hinze via Phabricator via cfe-commits
KitsuneAlex created this revision.
KitsuneAlex added reviewers: lattner, craig.topper, RKSimon, respindola.
KitsuneAlex added a project: clang-format.
Herald added projects: All, clang.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
KitsuneAlex requested review of this revision.

First of all, i apologize in advance if anything in the submission proccess was 
messed up, this is my first time contributon to the LLVM project.

This patch adds a new option 'SpaceAfterOperatorKeyword' to clang-format. 
As the name implies, this will insert a space after every operator keyword, 
effectively splitting the actual operator from the keyword, which i found is a 
missing option for my private and professional work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152443

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22907,6 +22907,12 @@
   verifyFormat("template void foo();", Style);
 }
 
+TEST_F(FormatTest, SpaceAfterOperatorKeyword) {
+  FormatStyle Style = getLLVMStyle();
+  Style.SpaceAfterOperatorKeyword = false;
+  verifyFormat("bool operator==(void*);", Style);
+}
+
 TEST_F(FormatTest, TripleAngleBrackets) {
   verifyFormat("f<<<1, 1>>>();");
   verifyFormat("f<<<1, 1, 1, s>>>();");
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -184,6 +184,7 @@
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
+  CHECK_PARSE_BOOL(SpaceAfterOperatorKeyword);
   CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
   CHECK_PARSE_BOOL(SpaceBeforeCaseColon);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3781,6 +3781,8 @@
   }
   if (Right.is(tok::less) && Left.is(tok::kw_template))
 return Style.SpaceAfterTemplateKeyword;
+  if (Left.is(tok::kw_operator))
+return Style.SpaceAfterOperatorKeyword;
   if (Left.isOneOf(tok::exclaim, tok::tilde))
 return false;
   if (Left.is(tok::at) &&
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1002,6 +1002,8 @@
 IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot);
 IO.mapOptional("SpaceAfterTemplateKeyword",
Style.SpaceAfterTemplateKeyword);
+IO.mapOptional("SpaceAfterOperatorKeyword",
+   Style.SpaceAfterOperatorKeyword);
 IO.mapOptional("SpaceAroundPointerQualifiers",
Style.SpaceAroundPointerQualifiers);
 IO.mapOptional("SpaceBeforeAssignmentOperators",
@@ -1440,6 +1442,7 @@
   LLVMStyle.SpaceAfterCStyleCast = false;
   LLVMStyle.SpaceAfterLogicalNot = false;
   LLVMStyle.SpaceAfterTemplateKeyword = true;
+  LLVMStyle.SpaceAfterOperatorKeyword = false;
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
@@ -1731,6 +1734,7 @@
   MozillaStyle.PenaltyReturnTypeOnItsOwnLine = 200;
   MozillaStyle.PointerAlignment = FormatStyle::PAS_Left;
   MozillaStyle.SpaceAfterTemplateKeyword = false;
+  MozillaStyle.SpaceAfterOperatorKeyword = false;
   return MozillaStyle;
 }
 
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3700,6 +3700,14 @@
   /// \version 4
   bool SpaceAfterTemplateKeyword;
 
+  /// If \c true, a space will be inserted after the 'operator' keyword.
+  /// \code
+  ///true:  false:
+  ///bool operator ==(...); vs. bool operator==(...);
+  /// \endcode
+  /// \version 17
+  bool SpaceAfterOperatorKeyword;
+
   /// Different ways to put a space before opening parentheses.
   enum SpaceAroundPointerQualifiersStyle : int8_t {
 /// Don't ensure spaces around pointer qualifiers and use PointerAlignment
@@ -4412,6 +4420,7 @@
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
+   SpaceAfterOperat

[PATCH] D151720: [clang][ExprConstant] Fix display of syntactically-invalid note for member function calls

2023-06-08 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

@aaron.ballman I would like to hear what's your take on this approach.


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

https://reviews.llvm.org/D151720

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


[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

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



Comment at: clang/test/CodeGenHIP/printf_nonhostcall.cpp:240
+  return printf(s, 10);
+}

Test _BitInt for small and odd types, plus i128


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

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


[PATCH] D152443: Add SpaceAfterOperatorKeyword style option for clang-format

2023-06-08 Thread Alexander Hinze via Phabricator via cfe-commits
KitsuneAlex added a comment.

I made a stupid mistake and messed up the formatting of the anonymous parameter 
in the unit test code.
Fixing this right now, don't know why it slipped through.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

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


[PATCH] D152269: [StaticAnalyzer] Fix false negative on NilArgChecker when creating literal object

2023-06-08 Thread tripleCC via Phabricator via cfe-commits
tripleCC updated this revision to Diff 529583.
tripleCC added a comment.

taking steakhal's advice


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152269

Files:
  clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  clang/test/Analysis/NSContainers.m

Index: clang/test/Analysis/NSContainers.m
===
--- clang/test/Analysis/NSContainers.m
+++ clang/test/Analysis/NSContainers.m
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1  -Wno-objc-literal-conversion -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg,osx.cocoa.Loops,debug.ExprInspection -verify -Wno-objc-root-class %s
+// RUN: %clang_analyze_cc1 -Wno-objc-literal-conversion -Wno-objc-root-class -fobjc-arc \
+// RUN:   -analyzer-checker=core,osx.cocoa,nullability \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -analyzer-checker=debug.ExprInspection -verify %s
 
 void clang_analyzer_eval(int);
 
@@ -31,13 +34,13 @@
 @end
 
 typedef struct {
-  unsigned long state;
-  id *itemsPtr;
-  unsigned long *mutationsPtr;
-  unsigned long extra[5];
+unsigned long state;
+id __unsafe_unretained _Nullable * _Nullable itemsPtr;
+unsigned long * _Nullable mutationsPtr;
+unsigned long extra[5];
 } NSFastEnumerationState;
 @protocol NSFastEnumeration
-- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len;
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained _Nullable [_Nonnull])buffer count:(NSUInteger)len;
 @end
 
 @interface NSArray : NSObject 
@@ -323,3 +326,43 @@
   // that 'obj' can be nil in this context.
   dict[obj] = getStringFromString(obj); // no-warning
 }
+
+Foo * getMightBeNullFoo();
+Foo * _Nonnull getNonnullFoo();
+Foo * _Nullable getNullableFoo();
+
+void testCreateDictionaryLiteralWithNullableArg() {
+  Foo *p1 = getMightBeNullFoo();
+  Foo *p2 = getNonnullFoo();
+  Foo *p3 = getNullableFoo();
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{UNKNOWN}}
+
+  (void)@{@"abc" : p1}; // no-warning
+  (void)@{@"abc" : p2}; // no-warning
+  (void)@{@"abc" : p3}; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null}}
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{FALSE}}
+}
+
+void testCreateArrayLiteralWithNullableArg() {
+  Foo *p1 = getMightBeNullFoo();
+  Foo *p2 = getNonnullFoo();
+  Foo *p3 = getNullableFoo();
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{UNKNOWN}}
+
+  (void)@[p1]; // no-warning
+  (void)@[p2]; // no-warning
+  (void)@[p3]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null}}
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{FALSE}}
+}
\ No newline at end of file
Index: clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
@@ -97,7 +97,8 @@
 namespace {
   class NilArgChecker : public Checker,
-   check::PostStmt > {
+   check::PostStmt,
+   EventDispatcher> {
 mutable std::unique_ptr BT;
 
 mutable llvm::SmallDenseMap StringSelectors;
@@ -139,12 +140,28 @@
 void NilArgChecker::warnIfNilExpr(const Expr *E,
   const char *Msg,
   CheckerContext &C) const {
-  ProgramStateRef State = C.getState();
-  if (State->isNull(C.getSVal(E)).isConstrainedTrue()) {
-
+  auto Location = C.getSVal(E).getAs();
+  if (!Location)
+return;
+  
+  auto [NonNull, Null] = C.getState()->assume(*Location);
+  
+  // If it's known to be null.
+  if (!NonNull && Null) {
 if (ExplodedNode *N = C.generateErrorNode()) {
   generateBugReport(N, Msg, E->getSourceRange(), E, C);
+  return;
+}
+  }
+  
+  // If it might be null, assume that it cannot after this operation.
+  if (Null) {
+// One needs to make sure the pointer is non-null to be used here.
+if (ExplodedNode *N = C.generateSink(Null, C.getPredecessor())) {
+  dispatchEvent({*Location, /*IsLoad=*/false, N, &C.getBugReporter(),
+   

[PATCH] D152269: [StaticAnalyzer] Fix false negative on NilArgChecker when creating literal object

2023-06-08 Thread tripleCC via Phabricator via cfe-commits
tripleCC updated this revision to Diff 529584.
tripleCC added a comment.

clang-format BasicObjCFoundationChecks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152269

Files:
  clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  clang/test/Analysis/NSContainers.m

Index: clang/test/Analysis/NSContainers.m
===
--- clang/test/Analysis/NSContainers.m
+++ clang/test/Analysis/NSContainers.m
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1  -Wno-objc-literal-conversion -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg,osx.cocoa.Loops,debug.ExprInspection -verify -Wno-objc-root-class %s
+// RUN: %clang_analyze_cc1 -Wno-objc-literal-conversion -Wno-objc-root-class -fobjc-arc \
+// RUN:   -analyzer-checker=core,osx.cocoa,nullability \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -analyzer-checker=debug.ExprInspection -verify %s
 
 void clang_analyzer_eval(int);
 
@@ -31,13 +34,13 @@
 @end
 
 typedef struct {
-  unsigned long state;
-  id *itemsPtr;
-  unsigned long *mutationsPtr;
-  unsigned long extra[5];
+unsigned long state;
+id __unsafe_unretained _Nullable * _Nullable itemsPtr;
+unsigned long * _Nullable mutationsPtr;
+unsigned long extra[5];
 } NSFastEnumerationState;
 @protocol NSFastEnumeration
-- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len;
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained _Nullable [_Nonnull])buffer count:(NSUInteger)len;
 @end
 
 @interface NSArray : NSObject 
@@ -323,3 +326,43 @@
   // that 'obj' can be nil in this context.
   dict[obj] = getStringFromString(obj); // no-warning
 }
+
+Foo * getMightBeNullFoo();
+Foo * _Nonnull getNonnullFoo();
+Foo * _Nullable getNullableFoo();
+
+void testCreateDictionaryLiteralWithNullableArg() {
+  Foo *p1 = getMightBeNullFoo();
+  Foo *p2 = getNonnullFoo();
+  Foo *p3 = getNullableFoo();
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{UNKNOWN}}
+
+  (void)@{@"abc" : p1}; // no-warning
+  (void)@{@"abc" : p2}; // no-warning
+  (void)@{@"abc" : p3}; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null}}
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{FALSE}}
+}
+
+void testCreateArrayLiteralWithNullableArg() {
+  Foo *p1 = getMightBeNullFoo();
+  Foo *p2 = getNonnullFoo();
+  Foo *p3 = getNullableFoo();
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{UNKNOWN}}
+
+  (void)@[p1]; // no-warning
+  (void)@[p2]; // no-warning
+  (void)@[p3]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null}}
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{FALSE}}
+}
\ No newline at end of file
Index: clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
@@ -95,56 +95,64 @@
 //===--===//
 
 namespace {
-  class NilArgChecker : public Checker,
-   check::PostStmt > {
-mutable std::unique_ptr BT;
-
-mutable llvm::SmallDenseMap StringSelectors;
-mutable Selector ArrayWithObjectSel;
-mutable Selector AddObjectSel;
-mutable Selector InsertObjectAtIndexSel;
-mutable Selector ReplaceObjectAtIndexWithObjectSel;
-mutable Selector SetObjectAtIndexedSubscriptSel;
-mutable Selector ArrayByAddingObjectSel;
-mutable Selector DictionaryWithObjectForKeySel;
-mutable Selector SetObjectForKeySel;
-mutable Selector SetObjectForKeyedSubscriptSel;
-mutable Selector RemoveObjectForKeySel;
-
-void warnIfNilExpr(const Expr *E,
-   const char *Msg,
-   CheckerContext &C) const;
-
-void warnIfNilArg(CheckerContext &C,
-  const ObjCMethodCall &msg, unsigned Arg,
-  FoundationClass Class,
-  bool CanBeSubscript = false) const;
-
-void generateBugReport(ExplodedNode *N,
-   StringRef Msg,
-   SourceRange Range,
-

[PATCH] D152443: Add SpaceAfterOperatorKeyword style option for clang-format

2023-06-08 Thread Alexander Hinze via Phabricator via cfe-commits
KitsuneAlex updated this revision to Diff 529587.
KitsuneAlex added a comment.

I removed the redundant anonymous parameter in the unit test source string. 
Locally all formatting tests passed fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22907,6 +22907,12 @@
   verifyFormat("template void foo();", Style);
 }
 
+TEST_F(FormatTest, SpaceAfterOperatorKeyword) {
+  FormatStyle Style = getLLVMStyle();
+  Style.SpaceAfterOperatorKeyword = false;
+  verifyFormat("bool operator==();", Style);
+}
+
 TEST_F(FormatTest, TripleAngleBrackets) {
   verifyFormat("f<<<1, 1>>>();");
   verifyFormat("f<<<1, 1, 1, s>>>();");
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -184,6 +184,7 @@
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
+  CHECK_PARSE_BOOL(SpaceAfterOperatorKeyword);
   CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
   CHECK_PARSE_BOOL(SpaceBeforeCaseColon);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3781,6 +3781,8 @@
   }
   if (Right.is(tok::less) && Left.is(tok::kw_template))
 return Style.SpaceAfterTemplateKeyword;
+  if (Left.is(tok::kw_operator))
+return Style.SpaceAfterOperatorKeyword;
   if (Left.isOneOf(tok::exclaim, tok::tilde))
 return false;
   if (Left.is(tok::at) &&
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1002,6 +1002,8 @@
 IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot);
 IO.mapOptional("SpaceAfterTemplateKeyword",
Style.SpaceAfterTemplateKeyword);
+IO.mapOptional("SpaceAfterOperatorKeyword",
+   Style.SpaceAfterOperatorKeyword);
 IO.mapOptional("SpaceAroundPointerQualifiers",
Style.SpaceAroundPointerQualifiers);
 IO.mapOptional("SpaceBeforeAssignmentOperators",
@@ -1440,6 +1442,7 @@
   LLVMStyle.SpaceAfterCStyleCast = false;
   LLVMStyle.SpaceAfterLogicalNot = false;
   LLVMStyle.SpaceAfterTemplateKeyword = true;
+  LLVMStyle.SpaceAfterOperatorKeyword = false;
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
@@ -1731,6 +1734,7 @@
   MozillaStyle.PenaltyReturnTypeOnItsOwnLine = 200;
   MozillaStyle.PointerAlignment = FormatStyle::PAS_Left;
   MozillaStyle.SpaceAfterTemplateKeyword = false;
+  MozillaStyle.SpaceAfterOperatorKeyword = false;
   return MozillaStyle;
 }
 
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3700,6 +3700,14 @@
   /// \version 4
   bool SpaceAfterTemplateKeyword;
 
+  /// If \c true, a space will be inserted after the 'operator' keyword.
+  /// \code
+  ///true:  false:
+  ///bool operator ==(...); vs. bool operator==(...);
+  /// \endcode
+  /// \version 17
+  bool SpaceAfterOperatorKeyword;
+
   /// Different ways to put a space before opening parentheses.
   enum SpaceAroundPointerQualifiersStyle : int8_t {
 /// Don't ensure spaces around pointer qualifiers and use PointerAlignment
@@ -4412,6 +4420,7 @@
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
+   SpaceAfterOperatorKeyword == R.SpaceAfterOperatorKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators &&
SpaceBeforeCaseColon == R.SpaceBeforeCaseColon &&
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -4714,6 +4714,16 @@
  true:   

[PATCH] D143587: [Docs] Multilib design

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

FlagMap->Mappings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143587

Files:
  clang/docs/Multilib.rst
  clang/docs/index.rst

Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -100,6 +100,7 @@
CodeOwners
InternalsManual
DriverInternals
+   Multilib
OffloadingDesign
PCHInternals
ItaniumMangleAbiTags
Index: clang/docs/Multilib.rst
===
--- /dev/null
+++ clang/docs/Multilib.rst
@@ -0,0 +1,310 @@
+
+Multilib
+
+
+Introduction
+
+
+This document describes how multilib is implemented in Clang.
+
+What is multilib and why might you care?
+If you're :doc:`cross compiling` then you can't use native
+system headers and libraries. To address this, you can use a combination of
+``--sysroot``, ``-isystem`` and ``-L`` options to point Clang at suitable
+directories for your target.
+However, when there are many possible directories to choose from, it's not
+necessarily obvious which one to pick.
+Multilib allows a toolchain designer to imbue the toolchain with the ability to
+pick a suitable directory automatically, based on the options the user provides
+to Clang. For example, if the user specifies
+``--target=arm-none-eabi -mcpu=cortex-m4`` the toolchain can choose a directory
+containing headers and libraries suitable for Armv7E-M, because it knows that's
+a suitable architecture for Arm Cortex-M4.
+Multilib can also choose between libraries for the same architecture based on
+other options. For example if the user specifies ``-fno-exceptions`` then a
+toolchain could select libraries built without exception support, thereby
+reducing the size of the resulting binary.
+
+Design
+==
+
+Clang supports GCC's ``-print-multi-lib`` and ``-print-multi-directory``
+options. These are described in
+`GCC Developer Options `_.
+
+There are two ways to configure multilib in Clang: hard-coded or via a
+configuration file.
+
+Hard-coded Multilib
+===
+
+The available libraries can be hard-coded in Clang. Typically this is done
+using the ``MultilibBuilder`` interface in
+``clang/include/clang/Driver/MultilibBuilder.h``.
+There are many examples of this in ``lib/Driver/ToolChains/Gnu.cpp``.
+The remainder of this document will not focus on this type of multilib.
+
+EXPERIMENTAL Multilib via configuration file
+
+
+Some Clang toolchains support loading multilib configuration from a
+``multilib.yaml`` configuration file.
+
+A ``multilib.yaml`` configuration file specifies which multilib variants are
+available, their relative location, what compilation options were used to build
+them, and the criteria by which they are selected.
+
+Multilib processing
+===
+
+Clang goes through the following steps to use multilib from a configuration
+file:
+#. Normalize command line options. Clang can accept the same
+   information via different options - for example,
+   ``--target=arm-none-eabi -march=armv7-m`` and
+   ``--target=armv7m-none-eabi`` are equivalent.
+   Clang normalizes the command line before passing them to the multilib system.
+   To see what flags are emitted for a given set of command line options, use
+   the ``-print-multi-flags-experimental`` command line option
+   along with the rest of the options you want to use.
+#. Load ``multilib.yaml`` from sysroot.
+#. Generate additional flags. ``multilib.yaml`` contains a ``Mappings`` section,
+   which specifies how to generate additional flags based on the flags derived
+   from command line options. Flags are matched using regular expressions.
+   These regular expressions shall use the POSIX extended regular expression
+   syntax.
+#. Match flags against multilib variants. If the generated flags are a superset
+   of the flags specified for a multilib variant then the variant is considered
+   a match.
+   If more than one variant matches then a toolchain may opt to either use only
+   the *last* matching multilib variant, or may use all matching variants,
+   thereby :ref:`layering` them.
+#. Generate ``-isystem`` and ``-L`` options. Iterate in reverse order over
+   the matching multilib variants, and generate ``-isystem`` and ``-L``
+   options based on the multilib variant's directory.
+
+Multilib layering
+=
+
+When Clang selects multilib variants, it may find that more than one variant
+matches.
+
+It is up to the ToolChain subclass to decide what to do in this case.
+There are two options permitted:
+#. Use only the *last* matching multilib variant. This option exists primarily
+   for compatibility with the previous mu

[PATCH] D144999: [Clang][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-06-08 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve added a comment.

I believe this is breaking the LLDB tests: 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/56106/changes
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/buildTimeTrend

Build 56105 was passing, and the only relevant change seems to come from this 
review.

Note that the failure is due to a test that is now passing:

  Unexpectedly Passed Tests (1):
lldb-shell :: Unwind/prefer-debug-over-eh-frame.test

Maybe we forgot to re-enable that test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


[clang] 32791f1 - [Clang] Convert some tests to opaque pointers (NFC)

2023-06-08 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-06-08T16:39:57+02:00
New Revision: 32791f19fd354f58aea9114b6c56301966bdd802

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

LOG: [Clang] Convert some tests to opaque pointers (NFC)

These tests all require some adjustments to make sure that struct
types still get generated, mostly done by stripping pointer
indirections.

Some of this may no longer test the situation it was originally
intended for, e.g. the issue from pr18962 just doesn't really
exist anymore with opaque pointers, as we no longer generate
recursive types.

Added: 


Modified: 
clang/test/CodeGenCXX/class-layout.cpp
clang/test/CodeGenCXX/member-data-pointers.cpp
clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp
clang/test/CodeGenCXX/pr18962.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/class-layout.cpp 
b/clang/test/CodeGenCXX/class-layout.cpp
index 22f38540a5670..9e2e9cd74c70f 100644
--- a/clang/test/CodeGenCXX/class-layout.cpp
+++ b/clang/test/CodeGenCXX/class-layout.cpp
@@ -1,21 +1,21 @@
-// RUN: %clang_cc1 -no-opaque-pointers %s -triple x86_64-apple-darwin10 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | 
FileCheck %s
 
 // An extra byte should be allocated for an empty class.
 namespace Test1 {
   // CHECK: %"struct.Test1::A" = type { i8 }
-  struct A { } *a;
+  struct A { } a;
 }
 
 namespace Test2 {
   // No need to add tail padding here.
-  // CHECK: %"struct.Test2::A" = type { i8*, i32 }
-  struct A { void *a; int b; } *a;
+  // CHECK: %"struct.Test2::A" = type { ptr, i32 }
+  struct A { void *a; int b; } a;
 }
 
 namespace Test3 {
   // C should have a vtable pointer.
-  // CHECK: %"struct.Test3::A" = type <{ i32 (...)**, i32, [4 x i8] }>
-  struct A { virtual void f(); int a; } *a;
+  // CHECK: %"struct.Test3::A" = type <{ ptr, i32, [4 x i8] }>
+  struct A { virtual void f(); int a; } a;
 }
 
 namespace Test4 {
@@ -30,7 +30,7 @@ namespace Test4 {
   struct B : public A {
 short d;
 double e;
-  } *b;
+  } b;
 }
 
 namespace Test5 {
@@ -43,7 +43,7 @@ namespace Test5 {
   struct B : A {
 char b : 1;
 char c;
-  } *b;
+  } b;
 }
 
 // PR10912: don't crash
@@ -83,12 +83,12 @@ namespace Test6 {
 namespace Test7 {
   #pragma pack (1)
   class A {};
-  // CHECK: %"class.Test7::B" = type <{ i32 (...)**, %"class.Test7::A" }>
+  // CHECK: %"class.Test7::B" = type <{ ptr, %"class.Test7::A" }>
   class B {
  virtual ~B();
  A a;
   };
-  B* b;
+  B test(B b) { return b; }
   #pragma pack ()
 }
 

diff  --git a/clang/test/CodeGenCXX/member-data-pointers.cpp 
b/clang/test/CodeGenCXX/member-data-pointers.cpp
index 22cc1016fa7f1..8b4e8d2797072 100644
--- a/clang/test/CodeGenCXX/member-data-pointers.cpp
+++ b/clang/test/CodeGenCXX/member-data-pointers.cpp
@@ -1,13 +1,13 @@
-// RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - 
-triple=x86_64-unknown-unknown | FileCheck -check-prefix GLOBAL-LP64 %s
-// RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - 
-triple=armv7-unknown-unknown | FileCheck -check-prefix GLOBAL-LP32 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-unknown | 
FileCheck -check-prefix GLOBAL-LP64 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | 
FileCheck -check-prefix GLOBAL-LP32 %s
 
 struct A;
 typedef int A::*param_t;
 struct {
   const char *name;
   param_t par;
-} *ptr;
+} ptr;
 void test_ptr() { (void) ptr; } // forced use
 
-// GLOBAL-LP64: type { i8*, i64 }
-// GLOBAL-LP32: type { i8*, i32 }
+// GLOBAL-LP64: type { ptr, i64 }
+// GLOBAL-LP32: type { ptr, i32 }

diff  --git a/clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp 
b/clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp
index d64fc60d15f99..2d218e2aab10d 100644
--- a/clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp
+++ b/clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp
@@ -1,20 +1,25 @@
-// RUN: %clang_cc1 -no-opaque-pointers -fms-compatibility -triple 
x86_64-windows-msvc %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -fms-compatibility -triple x86_64-windows-msvc %s 
-emit-llvm -o - | FileCheck %s
 
 // Make sure we choose the *direct* base path when doing these conversions.
 
-// CHECK: %struct.C = type { %struct.A, %struct.B }
-// CHECK: %struct.D = type { %struct.B, %struct.A }
-
 struct A { int a; };
 struct B : A { int b; };
 
 struct C : A, B { };
 extern "C" A *a_from_c(C *p) { return p; }
-// CHECK-LABEL: define dso_local %struct.A* @a_from_c(%struct.C* noundef 
%{{.*}})
-// CHECK: bitcast %struct.C* %{{.*}} to %struct.A*
+// CHECK-LABEL: define dso_local ptr @a_from_c(ptr noundef %{{.*}})
+// CHECK: [[P_ADDR:%.*]] = alloca ptr
+// CHECK-NEXT: store ptr [[P:%.*]], ptr [[P_ADDR]]
+// CHECK-NEXT: [[RET:%.*]] = load ptr

[PATCH] D152246: [clang][ThreadSafety] Analyze known function pointer values

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

> I think ideally we would get all possible values at this point and analyze 
> them all(?), but I'm not sure how to implement this.

Err, if we don't know the callee, there's not a whole lot we can do. I don't 
think we'd want to make guesses at what potentially could be stored in the 
function pointer at that point.

Overall, though, I think this direction makes sense, but I'd like to hear from 
@aaronpuchert and/or @delesley.




Comment at: clang/lib/Analysis/ThreadSafety.cpp:2066-2070
+  const auto *CD = Exp->getCalleeDecl();
+  if (!CD)
+return;
+
+  const auto *D = dyn_cast(CD);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152246

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


[clang] 15f15ab - [x86][MC] Fix movdir64b addressing

2023-06-08 Thread Akshay Khadse via cfe-commits

Author: Akshay Khadse
Date: 2023-06-08T22:41:00+08:00
New Revision: 15f15ab2c895545da70c14a72289fa7c00ed3f94

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

LOG: [x86][MC] Fix movdir64b addressing

This patch is to fix the [[ https://github.com/llvm/llvm-project/issues/63045 | 
issue 63045]].

Look at the following code:
```
int main(int argc, char *argv[]) {
int arr[1000];
__asm movdir64b rax, ZMMWORD PTR [arr]
return 0;
}
```
Compiling this code using `clang -O0 -fasm-blocks bug.c` gives the a linker 
error.

The problem seems to be in the generated assembly. Following is the out put of 
`clang -S -O0 -fasm-blocks bug.c`:
```
movq %rsi, -16(%rbp)
#APP

movdir64b arr, %rax

#NO_APP
xorl %eax, %eax
```
The symbol `arr` should be replaced with some address like `-4(%rbp)`.

This makes me believe that issue is not in the linker, but with the ASM parser.

This issue originates with patch [D145893](https://reviews.llvm.org/D145893). 
And that's why reverting it fixes the issue. More specifically, the function 
[isMem512_GR64()](https://github.com/llvm/llvm-project/blob/ff471dcf7669b1ad7903a44d0773bef4eb175eb9/llvm/lib/Target/X86/AsmParser/X86Operand.h#L404)
 within the 
[llvm/lib/Target/X86/AsmParser/X86Operand.h](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/AsmParser/X86Operand.h)
 file.

Reviewed By: skan

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

Added: 
llvm/test/CodeGen/X86/inline-asm-movdir64b-x86_64.ll
llvm/test/CodeGen/X86/inline-asm-movdir64b.ll

Modified: 
clang/test/CodeGen/ms-inline-asm-64.c
clang/test/CodeGen/ms-inline-asm.c
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Removed: 




diff  --git a/clang/test/CodeGen/ms-inline-asm-64.c 
b/clang/test/CodeGen/ms-inline-asm-64.c
index d688c10ca7080..313d380e121bc 100644
--- a/clang/test/CodeGen/ms-inline-asm-64.c
+++ b/clang/test/CodeGen/ms-inline-asm-64.c
@@ -72,3 +72,10 @@ void t5(void) {
   // CHECK-SAME: jmp ${1:P}
   // CHECK-SAME: "*m,*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(void 
(...)) @bar, ptr elementtype(void (...)) @bar)
 }
+
+void t47(void) {
+  // CHECK-LABEL: define{{.*}} void @t47
+  int arr[1000];
+  __asm movdir64b rax, zmmword ptr [arr]
+  // CHECK: call void asm sideeffect inteldialect "movdir64b rax, zmmword ptr 
$0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype([1000 x i32]) %arr)
+}

diff  --git a/clang/test/CodeGen/ms-inline-asm.c 
b/clang/test/CodeGen/ms-inline-asm.c
index 9498be1034768..c3eef9a23e166 100644
--- a/clang/test/CodeGen/ms-inline-asm.c
+++ b/clang/test/CodeGen/ms-inline-asm.c
@@ -675,6 +675,13 @@ void t46(void) {
   // CHECK: call void asm sideeffect inteldialect "add eax, [eax + $$-128]", 
"~{eax},~{flags},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void t47(void) {
+  // CHECK-LABEL: define{{.*}} void @t47
+  int arr[1000];
+  __asm movdir64b eax, zmmword ptr [arr]
+  // CHECK: call void asm sideeffect inteldialect "movdir64b eax, zmmword ptr 
$0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype([1000 x i32]) %arr)
+}
+
 void dot_operator(void){
   // CHECK-LABEL: define{{.*}} void @dot_operator
__asm { mov eax, 3[ebx]A.b}

diff  --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp 
b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 8c6ae1d1611aa..11cfe3cba751d 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1776,10 +1776,6 @@ bool X86AsmParser::CreateMemForMSInlineAsm(
  BaseReg && IndexReg));
 return false;
   }
-  // Otherwise, we set the base register to a non-zero value
-  // if we don't know the actual value at this time.  This is necessary to
-  // get the matching correct in some cases.
-  BaseReg = BaseReg ? BaseReg : 1;
   Operands.push_back(X86Operand::CreateMem(
   getPointerWidth(), SegReg, Disp, BaseReg, IndexReg, Scale, Start, End,
   Size,

diff  --git a/llvm/test/CodeGen/X86/inline-asm-movdir64b-x86_64.ll 
b/llvm/test/CodeGen/X86/inline-asm-movdir64b-x86_64.ll
new file mode 100644
index 0..c8724a3960d49
--- /dev/null
+++ b/llvm/test/CodeGen/X86/inline-asm-movdir64b-x86_64.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 2
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+movdir64b | FileCheck 
%s --check-prefix=X64
+
+define void @test_movdir64b() {
+; X64-LABEL: test_movdir64b:
+; X64:   # %bb.0: # %entry
+; X64-NEXT:subq $3880, %rsp # imm = 0xF28
+; X64-NEXT:.cfi_def_cfa_offset 3888
+; X64-NEXT:#APP
+; X64-EMPTY:
+; X64-NEXT:movdir64b -{{[0-9]+}}(%rsp), %rax
+; X64-EMPTY:
+; X64-NEXT:#NO_APP
+; X64-NEXT:addq $3880, %rsp # imm = 0xF28
+; X64-NEX

[PATCH] D151863: [x86][MC] Fix movdir64b addressing

2023-06-08 Thread Akshay Khadse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG15f15ab2c895: [x86][MC] Fix movdir64b addressing (authored 
by akshaykhadse).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151863

Files:
  clang/test/CodeGen/ms-inline-asm-64.c
  clang/test/CodeGen/ms-inline-asm.c
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/test/CodeGen/X86/inline-asm-movdir64b-x86_64.ll
  llvm/test/CodeGen/X86/inline-asm-movdir64b.ll


Index: llvm/test/CodeGen/X86/inline-asm-movdir64b.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/inline-asm-movdir64b.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 2
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+movdir64b | FileCheck %s 
--check-prefix=X86
+
+define void @test_movdir64b() {
+; X86-LABEL: test_movdir64b:
+; X86:   # %bb.0: # %entry
+; X86-NEXT:subl $4000, %esp # imm = 0xFA0
+; X86-NEXT:.cfi_def_cfa_offset 4004
+; X86-NEXT:#APP
+; X86-EMPTY:
+; X86-NEXT:movdir64b (%esp), %eax
+; X86-EMPTY:
+; X86-NEXT:#NO_APP
+; X86-NEXT:addl $4000, %esp # imm = 0xFA0
+; X86-NEXT:.cfi_def_cfa_offset 4
+; X86-NEXT:retl
+entry:
+  %arr = alloca [1000 x i32], align 4
+  call void asm sideeffect inteldialect "movdir64b eax, zmmword ptr $0", 
"*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype([1000 x i32]) %arr)
+  ret void
+}
Index: llvm/test/CodeGen/X86/inline-asm-movdir64b-x86_64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/inline-asm-movdir64b-x86_64.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 2
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+movdir64b | FileCheck 
%s --check-prefix=X64
+
+define void @test_movdir64b() {
+; X64-LABEL: test_movdir64b:
+; X64:   # %bb.0: # %entry
+; X64-NEXT:subq $3880, %rsp # imm = 0xF28
+; X64-NEXT:.cfi_def_cfa_offset 3888
+; X64-NEXT:#APP
+; X64-EMPTY:
+; X64-NEXT:movdir64b -{{[0-9]+}}(%rsp), %rax
+; X64-EMPTY:
+; X64-NEXT:#NO_APP
+; X64-NEXT:addq $3880, %rsp # imm = 0xF28
+; X64-NEXT:.cfi_def_cfa_offset 8
+; X64-NEXT:retq
+entry:
+  %arr = alloca [1000 x i32], align 16
+  call void asm sideeffect inteldialect "movdir64b rax, zmmword ptr $0", 
"*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype([1000 x i32]) %arr)
+  ret void
+}
Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1776,10 +1776,6 @@
  BaseReg && IndexReg));
 return false;
   }
-  // Otherwise, we set the base register to a non-zero value
-  // if we don't know the actual value at this time.  This is necessary to
-  // get the matching correct in some cases.
-  BaseReg = BaseReg ? BaseReg : 1;
   Operands.push_back(X86Operand::CreateMem(
   getPointerWidth(), SegReg, Disp, BaseReg, IndexReg, Scale, Start, End,
   Size,
Index: clang/test/CodeGen/ms-inline-asm.c
===
--- clang/test/CodeGen/ms-inline-asm.c
+++ clang/test/CodeGen/ms-inline-asm.c
@@ -675,6 +675,13 @@
   // CHECK: call void asm sideeffect inteldialect "add eax, [eax + $$-128]", 
"~{eax},~{flags},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void t47(void) {
+  // CHECK-LABEL: define{{.*}} void @t47
+  int arr[1000];
+  __asm movdir64b eax, zmmword ptr [arr]
+  // CHECK: call void asm sideeffect inteldialect "movdir64b eax, zmmword ptr 
$0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype([1000 x i32]) %arr)
+}
+
 void dot_operator(void){
   // CHECK-LABEL: define{{.*}} void @dot_operator
__asm { mov eax, 3[ebx]A.b}
Index: clang/test/CodeGen/ms-inline-asm-64.c
===
--- clang/test/CodeGen/ms-inline-asm-64.c
+++ clang/test/CodeGen/ms-inline-asm-64.c
@@ -72,3 +72,10 @@
   // CHECK-SAME: jmp ${1:P}
   // CHECK-SAME: "*m,*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(void 
(...)) @bar, ptr elementtype(void (...)) @bar)
 }
+
+void t47(void) {
+  // CHECK-LABEL: define{{.*}} void @t47
+  int arr[1000];
+  __asm movdir64b rax, zmmword ptr [arr]
+  // CHECK: call void asm sideeffect inteldialect "movdir64b rax, zmmword ptr 
$0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype([1000 x i32]) %arr)
+}


Index: llvm/test/CodeGen/X86/inline-asm-movdir64b.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/inline-asm-movdir64b.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc

[clang] fa6b7dd - [StaticAnalyzer] Fix false negative on NilArgChecker when creating literal object

2023-06-08 Thread Balazs Benics via cfe-commits

Author: tripleCC
Date: 2023-06-08T16:48:24+02:00
New Revision: fa6b7dd520fc175a246c943a7c9802e4808118b1

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

LOG: [StaticAnalyzer] Fix false negative on NilArgChecker when creating literal 
object

Fix false negative on NilArgChecker when creating literal object, such
as @[nullableObject].

Patch By tripleCC!

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
clang/test/Analysis/NSContainers.m

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp 
b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
index 44166aaf5b85b..f88b17d437eaa 100644
--- a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
@@ -95,56 +95,64 @@ static FoundationClass findKnownClass(const 
ObjCInterfaceDecl *ID,
 
//===--===//
 
 namespace {
-  class NilArgChecker : public Checker,
-   check::PostStmt > {
-mutable std::unique_ptr BT;
-
-mutable llvm::SmallDenseMap StringSelectors;
-mutable Selector ArrayWithObjectSel;
-mutable Selector AddObjectSel;
-mutable Selector InsertObjectAtIndexSel;
-mutable Selector ReplaceObjectAtIndexWithObjectSel;
-mutable Selector SetObjectAtIndexedSubscriptSel;
-mutable Selector ArrayByAddingObjectSel;
-mutable Selector DictionaryWithObjectForKeySel;
-mutable Selector SetObjectForKeySel;
-mutable Selector SetObjectForKeyedSubscriptSel;
-mutable Selector RemoveObjectForKeySel;
-
-void warnIfNilExpr(const Expr *E,
-   const char *Msg,
-   CheckerContext &C) const;
-
-void warnIfNilArg(CheckerContext &C,
-  const ObjCMethodCall &msg, unsigned Arg,
-  FoundationClass Class,
-  bool CanBeSubscript = false) const;
-
-void generateBugReport(ExplodedNode *N,
-   StringRef Msg,
-   SourceRange Range,
-   const Expr *Expr,
-   CheckerContext &C) const;
-
-  public:
-void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
-void checkPostStmt(const ObjCDictionaryLiteral *DL,
-   CheckerContext &C) const;
-void checkPostStmt(const ObjCArrayLiteral *AL,
-   CheckerContext &C) const;
-  };
+class NilArgChecker : public Checker,
+ check::PostStmt,
+ EventDispatcher> {
+  mutable std::unique_ptr BT;
+
+  mutable llvm::SmallDenseMap StringSelectors;
+  mutable Selector ArrayWithObjectSel;
+  mutable Selector AddObjectSel;
+  mutable Selector InsertObjectAtIndexSel;
+  mutable Selector ReplaceObjectAtIndexWithObjectSel;
+  mutable Selector SetObjectAtIndexedSubscriptSel;
+  mutable Selector ArrayByAddingObjectSel;
+  mutable Selector DictionaryWithObjectForKeySel;
+  mutable Selector SetObjectForKeySel;
+  mutable Selector SetObjectForKeyedSubscriptSel;
+  mutable Selector RemoveObjectForKeySel;
+
+  void warnIfNilExpr(const Expr *E, const char *Msg, CheckerContext &C) const;
+
+  void warnIfNilArg(CheckerContext &C, const ObjCMethodCall &msg, unsigned Arg,
+FoundationClass Class, bool CanBeSubscript = false) const;
+
+  void generateBugReport(ExplodedNode *N, StringRef Msg, SourceRange Range,
+ const Expr *Expr, CheckerContext &C) const;
+
+public:
+  void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
+  void checkPostStmt(const ObjCDictionaryLiteral *DL, CheckerContext &C) const;
+  void checkPostStmt(const ObjCArrayLiteral *AL, CheckerContext &C) const;
+};
 } // end anonymous namespace
 
 void NilArgChecker::warnIfNilExpr(const Expr *E,
   const char *Msg,
   CheckerContext &C) const {
-  ProgramStateRef State = C.getState();
-  if (State->isNull(C.getSVal(E)).isConstrainedTrue()) {
+  auto Location = C.getSVal(E).getAs();
+  if (!Location)
+return;
+
+  auto [NonNull, Null] = C.getState()->assume(*Location);
 
+  // If it's known to be null.
+  if (!NonNull && Null) {
 if (ExplodedNode *N = C.generateErrorNode()) {
   generateBugReport(N, Msg, E->getSourceRange(), E, C);
+  return;
+}
+  }
+
+  // If it might be null, assume that it cannot after this operation.
+  if (Null) {
+// One needs to make sure the pointer is non-null to be used here.
+if (ExplodedNode *N = C.

[PATCH] D152269: [StaticAnalyzer] Fix false negative on NilArgChecker when creating literal object

2023-06-08 Thread Balázs Benics via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfa6b7dd520fc: [StaticAnalyzer] Fix false negative on 
NilArgChecker when creating literal… (authored by tripleCC, committed by 
steakhal).

Changed prior to commit:
  https://reviews.llvm.org/D152269?vs=529584&id=529596#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152269

Files:
  clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  clang/test/Analysis/NSContainers.m

Index: clang/test/Analysis/NSContainers.m
===
--- clang/test/Analysis/NSContainers.m
+++ clang/test/Analysis/NSContainers.m
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1  -Wno-objc-literal-conversion -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg,osx.cocoa.Loops,debug.ExprInspection -verify -Wno-objc-root-class %s
+// RUN: %clang_analyze_cc1 -Wno-objc-literal-conversion -Wno-objc-root-class -fobjc-arc \
+// RUN:   -analyzer-checker=core,osx.cocoa,nullability \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -analyzer-checker=debug.ExprInspection -verify %s
 
 void clang_analyzer_eval(int);
 
@@ -31,13 +34,13 @@
 @end
 
 typedef struct {
-  unsigned long state;
-  id *itemsPtr;
-  unsigned long *mutationsPtr;
-  unsigned long extra[5];
+unsigned long state;
+id __unsafe_unretained _Nullable * _Nullable itemsPtr;
+unsigned long * _Nullable mutationsPtr;
+unsigned long extra[5];
 } NSFastEnumerationState;
 @protocol NSFastEnumeration
-- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len;
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained _Nullable [_Nonnull])buffer count:(NSUInteger)len;
 @end
 
 @interface NSArray : NSObject 
@@ -323,3 +326,43 @@
   // that 'obj' can be nil in this context.
   dict[obj] = getStringFromString(obj); // no-warning
 }
+
+Foo * getMightBeNullFoo();
+Foo * _Nonnull getNonnullFoo();
+Foo * _Nullable getNullableFoo();
+
+void testCreateDictionaryLiteralWithNullableArg() {
+  Foo *p1 = getMightBeNullFoo();
+  Foo *p2 = getNonnullFoo();
+  Foo *p3 = getNullableFoo();
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{UNKNOWN}}
+
+  (void)@{@"abc" : p1}; // no-warning
+  (void)@{@"abc" : p2}; // no-warning
+  (void)@{@"abc" : p3}; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null}}
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{FALSE}}
+}
+
+void testCreateArrayLiteralWithNullableArg() {
+  Foo *p1 = getMightBeNullFoo();
+  Foo *p2 = getNonnullFoo();
+  Foo *p3 = getNullableFoo();
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{UNKNOWN}}
+
+  (void)@[p1]; // no-warning
+  (void)@[p2]; // no-warning
+  (void)@[p3]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null}}
+
+  clang_analyzer_eval(p1 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p2 == nil); // expected-warning {{FALSE}}
+  clang_analyzer_eval(p3 == nil); // expected-warning {{FALSE}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
@@ -95,56 +95,64 @@
 //===--===//
 
 namespace {
-  class NilArgChecker : public Checker,
-   check::PostStmt > {
-mutable std::unique_ptr BT;
-
-mutable llvm::SmallDenseMap StringSelectors;
-mutable Selector ArrayWithObjectSel;
-mutable Selector AddObjectSel;
-mutable Selector InsertObjectAtIndexSel;
-mutable Selector ReplaceObjectAtIndexWithObjectSel;
-mutable Selector SetObjectAtIndexedSubscriptSel;
-mutable Selector ArrayByAddingObjectSel;
-mutable Selector DictionaryWithObjectForKeySel;
-mutable Selector SetObjectForKeySel;
-mutable Selector SetObjectForKeyedSubscriptSel;
-mutable Selector RemoveObjectForKeySel;
-
-void warnIfNilExpr(const Expr *E,
-   const char *Msg,
-   CheckerContext &C) const;
-
-void warnIfNilArg(CheckerContext &C,
-

[PATCH] D143984: [DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)

2023-06-08 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I think this patch broke two build bots, and now the CI is red.
https://lab.llvm.org/buildbot/#/builders/16/builds/49282
https://lab.llvm.org/buildbot/#/builders/109/builds/65904

Could you please have a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143984

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


[PATCH] D144999: [Clang][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-06-08 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo added a comment.

In D144999#4405793 , @fdeazeve wrote:

> I believe this is breaking the LLDB tests: 
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/56106/changes
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/buildTimeTrend
>
> Build 56105 was passing, and the only relevant change seems to come from this 
> review.
>
> Note that the failure is due to a test that is now passing:
>
>   Unexpectedly Passed Tests (1):
> lldb-shell :: Unwind/prefer-debug-over-eh-frame.test
>
> Maybe we forgot to re-enable that test?

The behaviour has changed - I can update the test.
Question: Do you prefer to have it set a flag that goes back to the old 
behaviour? OR change to to expect-passing?

(My vote would be on have it expect the test to pass because, from reading the 
test, this is preferring debug-frame over eh-frame, which probably isn't ideal 
in the new code beacuse all non-canonical personality symbols will now be 
eh-frame)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-06-08 Thread Zheng Qian via Phabricator via cfe-commits
qianzhen updated this revision to Diff 529601.
qianzhen added a comment.

More examples have been identified for the adaptation of IBM XL compiler's 
-qstatsym option for the hot patch use case, which was mentioned previously. 
Therefore, this option is extended to cover the following cases.

1. Function-local static variables
2. Thread-local variables

The test case is updated to add more coverage accordingly.
Since the option is now covering not only the variables with static storage 
duration, but also those with thread storage duration, the option name is 
changed to -fkeep-persistent-storage-variables. Any suggestions would be 
appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/keep-persistent-storage-variables.cpp
  clang/test/Driver/fkeep-persistent-storage-variables.c

Index: clang/test/Driver/fkeep-persistent-storage-variables.c
===
--- /dev/null
+++ clang/test/Driver/fkeep-persistent-storage-variables.c
@@ -0,0 +1,3 @@
+// RUN: %clang -fkeep-persistent-storage-variables -c %s -### 2>&1 | FileCheck %s
+
+// CHECK: "-fkeep-persistent-storage-variables"
Index: clang/test/CodeGen/keep-persistent-storage-variables.cpp
===
--- /dev/null
+++ clang/test/CodeGen/keep-persistent-storage-variables.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -fkeep-persistent-storage-variables -emit-llvm %s -o - -triple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-ELF
+// RUN: %clang_cc1 -fkeep-persistent-storage-variables -emit-llvm %s -o - -triple=powerpc64-ibm-aix-xcoff | FileCheck %s --check-prefixes=CHECK,CHECK-NON-ELF
+
+// CHECK: @_ZL2g1 = internal global i32 0, align 4
+// CHECK: @_ZL2g2 = internal global i32 1, align 4
+// CHECK: @_ZL2g3 = internal global i32 0, align 4
+// CHECK: @_ZL2g4 = internal global i32 2, align 4
+// CHECK: @tl1 = thread_local global i32 0, align 4
+// CHECK: @tl2 = thread_local global i32 3, align 4
+// CHECK: @_ZL3tl3 = internal thread_local global i32 0, align 4
+// CHECK: @_ZL3tl4 = internal thread_local global i32 4, align 4
+// CHECK: @g5 = global i32 0, align 4
+// CHECK: @g6 = global i32 6, align 4
+// CHECK: @_ZZ5test3vE2s3 = internal global i32 0, align 4
+// CHECK: @_ZN12_GLOBAL__N_12s4E = internal global i32 42, align 4
+// CHECK: @_ZZ5test5vE3tl5 = internal thread_local global i32 1, align 4
+// CHECK: @_ZN2ST2s6E = global i32 7, align 4
+// CHECK-ELF: @llvm.compiler.used = appending global [14 x ptr] [ptr @_ZL2g1, ptr @_ZL2g2, ptr @_ZL2g3, ptr @_ZL2g4, ptr @tl1, ptr @tl2, ptr @_ZL3tl3, ptr @_ZL3tl4, ptr @g5, ptr @g6, ptr @_ZZ5test3vE2s3, ptr @_ZN12_GLOBAL__N_12s4E, ptr @_ZZ5test5vE3tl5, ptr @_ZN2ST2s6E], section "llvm.metadata"
+// CHECK-NON-ELF: @llvm.used = appending global [14 x ptr] [ptr @_ZL2g1, ptr @_ZL2g2, ptr @_ZL2g3, ptr @_ZL2g4, ptr @tl1, ptr @tl2, ptr @_ZL3tl3, ptr @_ZL3tl4, ptr @g5, ptr @g6, ptr @_ZZ5test3vE2s3, ptr @_ZN12_GLOBAL__N_12s4E, ptr @_ZZ5test5vE3tl5, ptr @_ZN2ST2s6E], section "llvm.metadata"
+
+static int g1;
+static int g2 = 1;
+static int g3;
+static int g4 = 2;
+__thread int tl1;
+__thread int tl2 = 3;
+static __thread int tl3;
+static __thread int tl4 = 4;
+int g5;
+int g6 = 6;
+
+int test1() {
+  g1 = 3;
+  return g1;
+}
+
+int test2() {
+  return g2;
+}
+
+int test3() {
+  static int s3 = 0;
+  ++s3;
+  return s3;
+}
+
+namespace {
+  int s4 = 42;
+}
+void *test4() { return &s4; }
+
+int test5() {
+  static __thread int tl5 = 1;
+  ++tl5;
+  return tl5;
+}
+
+struct ST {
+  static int s6;
+};
+int ST::s6 = 7;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7294,6 +7294,8 @@
 
   Args.addOptInFlag(CmdArgs, options::OPT_fkeep_static_consts,
 options::OPT_fno_keep_static_consts);
+  Args.addOptInFlag(CmdArgs, options::OPT_fkeep_persistent_storage_variables,
+options::OPT_fno_keep_persistent_storage_variables);
   Args.addOptInFlag(CmdArgs, options::OPT_fcomplete_member_pointers,
 options::OPT_fno_complete_member_pointers);
   Args.addOptOutFlag(CmdArgs, options::OPT_fcxx_static_destructors,
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2198,12 +2198,14 @@
   if (D && D->hasAttr())
 addUsedOrCompilerUsedGlobal(GV);
 
-  if (CodeGenOpts.KeepStaticConsts && D && isa(D)) {
-const auto *VD = cast(D);
-if (VD->getType().isC

[PATCH] D152279: [Driver] Default -msmall-data-limit= to 0

2023-06-08 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

One of the key things we've been discussing on this at the LLVM call is that we 
probably want to keep the small data limit for embedded targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152279

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


[PATCH] D144999: [Clang][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-06-08 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo added a comment.

P.S: https://reviews.llvm.org/D152449


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


[PATCH] D151730: [RISCV] Support target attribute for function

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



Comment at: clang/test/CodeGen/RISCV/riscv-func-attr-target.c:2
+// REQUIRES: riscv-registered-target
+// RUN: %clang -target riscv64 -march=rv64g -S %s -o - | FileCheck %s 
--check-prefix=CHECK-ASM
+// RUN: %clang -target riscv64 -march=rv64g -emit-llvm -S %s -o - | FileCheck 
%s --check-prefix=CHECK-IR

`-target ` has been deprecated since Clang 3.x. Use `--target=` for new tests.

Prefer `%clang_cc1` for non-Driver tests. Only use `%clang` in test/Driver



Comment at: clang/test/CodeGen/RISCV/riscv-func-attr-target.c:5
+
+// clang-format off
+

We don't format tests, so this annotation is unneeded.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151730

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-06-08 Thread Zheng Qian via Phabricator via cfe-commits
qianzhen added a comment.

@erichkeane Thanks for the comments!

> How does this work with function-local statics?

This is a valid case. The function-local statics should be kept; the missing 
implementation is added now.

> What does the behavior look like in C?

The C behavior should be the same as those examples in the included C++ test 
case (except for the C++ specific ones). Do you have any special considerations 
about C in mind?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D152070: [2/11][Clang][RISCV] Expand all variants of RVV intrinsic tuple types

2023-06-08 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added inline comments.



Comment at: clang/lib/Support/RISCVVIntrinsicUtils.cpp:819
-  // LMUL x NF must be less than or equal to 8.
-  if ((Log2LMUL >= 1) && (1 << Log2LMUL) * NF > 8)
-return std::nullopt;

kito-cheng wrote:
> Keep as assert?
`computeType` already has an assertion guarding it, which is why the condition 
is removed here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152070

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


[PATCH] D152429: [Clang][Type] Add static assertion to guard future expansion for BuiltinType numbering

2023-06-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Thanks, this generally looks good but I did spot a small change to make (can 
make it when landing).




Comment at: clang/include/clang/AST/Type.h:1542
 
+static const unsigned NumOfBuiltinTypeBits = 8;
+

I think this should move down to be directly above the definition of 
`BuiltinTypeBitfields`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152429

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


[clang] 7815166 - Revert "[DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)"

2023-06-08 Thread Vladislav Dzhidzhoev via cfe-commits

Author: Vladislav Dzhidzhoev
Date: 2023-06-08T17:36:30+02:00
New Revision: 7815166b476b4184a1171ef56eed35726c1ab132

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

LOG: Revert "[DebugMetadata] Simplify handling subprogram's retainedNodes 
field. NFCI (1/7)"

This reverts commit 4418434c6de7a861e241ba2448ea4a12080cf08f.

Reverted because it breaks tests of OCaml bindings.

Added: 


Modified: 
clang/test/CodeGen/attr-btf_tag-disubprogram-callsite.c
clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
clang/test/CodeGenCXX/debug-info-cxx1y.cpp
clang/test/CodeGenCXX/debug-info-template.cpp
clang/test/CodeGenObjC/debug-info-category.m
llvm/include/llvm/IR/DIBuilder.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/IR/DIBuilder.cpp

Removed: 




diff  --git a/clang/test/CodeGen/attr-btf_tag-disubprogram-callsite.c 
b/clang/test/CodeGen/attr-btf_tag-disubprogram-callsite.c
index 5bbb05e6b8098..e3bfd71a56aad 100644
--- a/clang/test/CodeGen/attr-btf_tag-disubprogram-callsite.c
+++ b/clang/test/CodeGen/attr-btf_tag-disubprogram-callsite.c
@@ -13,7 +13,7 @@ int foo2(struct t1 *arg) {
   return foo(arg);
 }
 
-// CHECK: ![[#]] = !DISubprogram(name: "foo", scope: ![[#]], file: ![[#]], 
line: [[#]], type: ![[#]], flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, 
annotations: ![[ANNOT:[0-9]+]])
+// CHECK: ![[#]] = !DISubprogram(name: "foo", scope: ![[#]], file: ![[#]], 
line: [[#]], type: ![[#]], flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, 
retainedNodes: ![[#]], annotations: ![[ANNOT:[0-9]+]])
 // CHECK: ![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
 // CHECK: ![[TAG1]] = !{!"btf_decl_tag", !"tag1"}
 // CHECK: ![[TAG2]] = !{!"btf_decl_tag", !"tag2"}

diff  --git a/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp 
b/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
index 6453e4379ae9a..a35ca27e10d2a 100644
--- a/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
+++ b/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
@@ -52,15 +52,15 @@ X v;
 // CHECK:   ret void
 // CHECK: }
 
-// CHECK: ![[DBGVAR16]] = distinct !DISubprogram(name: 
"__cxx_global_var_init", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, type: 
!{{[0-9]+}}, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | 
DISPFlagDefinition, unit: !{{[0-9]+}})
+// CHECK: ![[DBGVAR16]] = distinct !DISubprogram(name: 
"__cxx_global_var_init", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, type: 
!{{[0-9]+}}, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | 
DISPFlagDefinition, unit: !{{[0-9]+}}, retainedNodes: !{{[0-9]+}})
 // CHECK: ![[DBGVAR19]] = !DILocation(line: 14, column: 3, scope: 
![[DBGVAR16]])
 // CHECK: ![[DBGVAR19b]] = !DILocation(line: 0, scope: ![[DBGVAR16]])
-// CHECK: ![[DBGVAR20]] = distinct !DISubprogram(name: "__dtor_v", scope: 
!{{[0-9]+}}, file: !{{[0-9]+}}, line: 14, type: !{{[0-9]+}}, scopeLine: 14, 
flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, 
unit: !{{[0-9]+}})
+// CHECK: ![[DBGVAR20]] = distinct !DISubprogram(name: "__dtor_v", scope: 
!{{[0-9]+}}, file: !{{[0-9]+}}, line: 14, type: !{{[0-9]+}}, scopeLine: 14, 
flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, 
unit: !{{[0-9]+}}, retainedNodes: !{{[0-9]+}})
 // CHECK: ![[DBGVAR21b]] = !DILocation(line: 0, scope: ![[DBGVAR20]])
 // CHECK: ![[DBGVAR21]] = !DILocation(line: 14, column: 3, scope: 
![[DBGVAR20]])
-// CHECK: ![[DBGVAR22]] = distinct !DISubprogram(linkageName: "__finalize_v", 
scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 14, type: !{{[0-9]+}}, scopeLine: 
14, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, 
unit: !{{[0-9]+}})
+// CHECK: ![[DBGVAR22]] = distinct !DISubprogram(linkageName: "__finalize_v", 
scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 14, type: !{{[0-9]+}}, scopeLine: 
14, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, 
unit: !{{[0-9]+}}, retainedNodes: !{{[0-9]+}})
 // CHECK: ![[DBGVAR24]] = !DILocation(line: 14, column: 3, scope: 
![[DBGVAR22]])
-// CHECK: ![[DBGVAR25]] = distinct !DISubprogram(linkageName: 
"_GLOBAL__sub_I__", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, type: !{{[0-9]+}}, 
flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, 
unit: !{{[0-9]+}})
+// CHECK: ![[DBGVAR25]] = distinct !DISubprogram(linkageName: 
"_GLOBAL__sub_I__", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, type: !{{[0-9]+}}, 
flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, 
unit: !{{[0-9]+}}, retainedNodes: !{{[0-9]+}})
 // CHECK: ![[DBGVAR26]] = !DILocation(line: 0, scope: ![[DBGVAR25]])
-// CHECK: ![[DBGVAR27]] = distinct !DISubprogram(linkageName: "_GLOBAL__D_a", 
scope: !{{[0-9]+}}, file: !{{[0-9]+}}, type: !{{[0-9]+}}, flags: 
DIFlagArtificia

[clang] 0f0623a - [Clang] Remove some explicit -opaque-pointers options in tests (NFC)

2023-06-08 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-06-08T17:41:27+02:00
New Revision: 0f0623ab87e9041fe0df1e788958330a2787a494

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

LOG: [Clang] Remove some explicit -opaque-pointers options in tests (NFC)

This is the default, so don't specify it explicitly, in preparation
for removing the option.

Added: 


Modified: 
clang/test/CodeGen/arithmetic-fence-builtin.cpp
clang/test/CodeGen/disable-tail-calls.c
clang/test/CodeGen/dominating-store-to-return.c
clang/test/CoverageMapping/ir.c
clang/test/Driver/arm-float-abi-lto.c
clang/test/Driver/memtag-stack_lto.c

Removed: 




diff  --git a/clang/test/CodeGen/arithmetic-fence-builtin.cpp 
b/clang/test/CodeGen/arithmetic-fence-builtin.cpp
index b0fc5ce60a602..a8f434c1d60c3 100644
--- a/clang/test/CodeGen/arithmetic-fence-builtin.cpp
+++ b/clang/test/CodeGen/arithmetic-fence-builtin.cpp
@@ -1,11 +1,11 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -mreassociate  -o - %s \
-// RUN: -opaque-pointers | FileCheck --check-prefix CHECK %s
+// RUN: | FileCheck --check-prefix CHECK %s
 
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -mreassociate  -o - %s 
\
-// RUN: -opaque-pointers | FileCheck --check-prefix CHECK %s
+// RUN: | FileCheck --check-prefix CHECK %s
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -mreassociate \
-// RUN: -fprotect-parens -ffp-contract=on -o - %s -opaque-pointers \
+// RUN: -fprotect-parens -ffp-contract=on -o - %s \
 // RUN: | FileCheck --check-prefix CHECK %s
 
 template  T addAF(T a, T b) {

diff  --git a/clang/test/CodeGen/disable-tail-calls.c 
b/clang/test/CodeGen/disable-tail-calls.c
index 11842faa1e3ba..e53c065072a46 100644
--- a/clang/test/CodeGen/disable-tail-calls.c
+++ b/clang/test/CodeGen/disable-tail-calls.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -opaque-pointers 
-emit-llvm -O2 -fno-optimize-sibling-calls -o - < %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -emit-llvm -O2 
-fno-optimize-sibling-calls -o - < %s | FileCheck %s
 
 typedef struct List {
   struct List *next;

diff  --git a/clang/test/CodeGen/dominating-store-to-return.c 
b/clang/test/CodeGen/dominating-store-to-return.c
index 42595c5296098..1c53e358cf146 100644
--- a/clang/test/CodeGen/dominating-store-to-return.c
+++ b/clang/test/CodeGen/dominating-store-to-return.c
@@ -1,6 +1,6 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -opaque-pointers -triple x86_64-unknown-unknown -emit-llvm 
%s -o - | FileCheck %s --check-prefix=NO-LIFETIME
-// RUN: %clang_cc1 -opaque-pointers -O1 -disable-llvm-optzns -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix=LIFETIME
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | 
FileCheck %s --check-prefix=NO-LIFETIME
+// RUN: %clang_cc1 -O1 -disable-llvm-optzns -triple x86_64-unknown-unknown 
-emit-llvm %s -o - | FileCheck %s --check-prefix=LIFETIME
 
 // NO-LIFETIME-LABEL: @main(
 // NO-LIFETIME-NEXT:  entry:

diff  --git a/clang/test/CoverageMapping/ir.c b/clang/test/CoverageMapping/ir.c
index 6fa9281ab70df..b08734cc35113 100644
--- a/clang/test/CoverageMapping/ir.c
+++ b/clang/test/CoverageMapping/ir.c
@@ -1,6 +1,5 @@
 // Check the data structures emitted by coverage mapping
 // RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple 
x86_64-apple-macosx10.9 -main-file-name ir.c %s -o - -emit-llvm 
-fprofile-instrument=clang -fcoverage-mapping -mllvm 
-enable-name-compression=false | FileCheck %s -check-prefixes=COMMON,DARWIN
-// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple 
x86_64-apple-macosx10.9 -main-file-name ir.c %s -o - -emit-llvm 
-fprofile-instrument=clang -fcoverage-mapping -mllvm 
-enable-name-compression=false -opaque-pointers | FileCheck %s 
-check-prefixes=COMMON,DARWIN
 // RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple 
x86_64--windows-msvc -main-file-name ir.c %s -o - -emit-llvm 
-fprofile-instrument=clang -fcoverage-mapping -mllvm 
-enable-name-compression=false | FileCheck %s -check-prefixes=COMMON,WINDOWS
 
 static inline void unused(void) {}

diff  --git a/clang/test/Driver/arm-float-abi-lto.c 
b/clang/test/Driver/arm-float-abi-lto.c
index b8788f485cbff..83c2435d97a4d 100644
--- a/clang/test/Driver/arm-float-abi-lto.c
+++ b/clang/test/Driver/arm-float-abi-lto.c
@@ -2,8 +2,8 @@
 
 // RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s 
-S -o - -emit-llvm -DCALL_LIB -DDEFINE_LIB | FileCheck %s
 
-// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s 
-Xclang -opaque-pointers -flto=full -c -o %t.call_full.bc -DCALL_LIB
-// RUN: %clang --target=arm-none-eabi -

[PATCH] D143984: [DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)

2023-06-08 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev added a comment.

In D143984#4405875 , @steakhal wrote:

> I think this patch broke two build bots, and now the CI is red.
> https://lab.llvm.org/buildbot/#/builders/16/builds/49282
> https://lab.llvm.org/buildbot/#/builders/109/builds/65904
>
> Could you please have a look?

Thank you! Reverted.
Does anyone know if there is a possibility to subscribe to buildbot emails 
related to a specific commit if you're not the author of the commit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143984

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


[PATCH] D152093: [clang][Analysis] Handle && and || against variable and its negation as tautology

2023-06-08 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/Analysis/CFG.cpp:1113-1114
+
+const BinaryOperator *LHS = dyn_cast(LHSExpr);
+const BinaryOperator *RHS = dyn_cast(RHSExpr);
 if (!LHS || !RHS)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152093

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


[PATCH] D152400: CodeGen: hand two tests to the care of update_cc_test_checks

2023-06-08 Thread Augie Fackler via Phabricator via cfe-commits
durin42 edited the summary of this revision.
durin42 updated this revision to Diff 529614.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152400

Files:
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp

Index: clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
===
--- clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
+++ clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
@@ -1,47 +1,92 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
 // RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
-// RUN: %clang_cc1 -fsanitize=alignment -fno-sanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
-// RUN: %clang_cc1 -fsanitize=alignment -fsanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
-// RUN: %clang_cc1 -fsanitize=alignment -fsanitize-trap=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
+// RUN: %clang_cc1 -fsanitize=alignment -fno-sanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE-NORECOVER
+// RUN: %clang_cc1 -fsanitize=alignment -fsanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE-RECOVER
+// RUN: %clang_cc1 -fsanitize=alignment -fsanitize-trap=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE-TRAP
 
-// CHECK-SANITIZE-ANYRECOVER: @[[CHAR:.*]] = {{.*}} c"'char **'\00" }
-// CHECK-SANITIZE-ANYRECOVER: @[[LINE_100_ALIGNMENT_ASSUMPTION:.*]] = {{.*}}, i32 100, i32 10 }, {{.*}} @[[CHAR]] }
 
 char **__attribute__((alloc_align(2)))
+// CHECK-LABEL: define dso_local noundef ptr @_Z11passthroughPPcm
+// CHECK-SAME: (ptr noundef [[X:%.*]], i64 noundef [[ALIGNMENT:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[ALIGNMENT_ADDR:%.*]] = alloca i64, align 8
+// CHECK-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8
+// CHECK-NEXT:store i64 [[ALIGNMENT]], ptr [[ALIGNMENT_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
+// CHECK-NEXT:ret ptr [[TMP0]]
+//
 passthrough(char **x, unsigned long alignment) {
-  // CHECK:  define{{.*}} ptr @[[PASSTHROUGH:.*]](ptr noundef %[[X:.*]], i64 noundef %[[ALIGNMENT:.*]])
-  // CHECK-NEXT: entry:
-  // CHECK-NEXT:   %[[X_ADDR:.*]] = alloca ptr, align 8
-  // CHECK-NEXT:   %[[ALIGNMENT_ADDR:.*]] = alloca i64, align 8
-  // CHECK-NEXT:   store ptr %[[X]], ptr %[[X_ADDR]], align 8
-  // CHECK-NEXT:   store i64 %[[ALIGNMENT]], ptr %[[ALIGNMENT_ADDR]], align 8
-  // CHECK-NEXT:   %[[X_RELOADED:.*]] = load ptr, ptr %[[X_ADDR]], align 8
-  // CHECK-NEXT:   ret ptr %[[X_RELOADED]]
-  // CHECK-NEXT: }
   return x;
 }
 
+// CHECK-NOSANITIZE-LABEL: define dso_local noundef ptr @_Z6callerPPc
+// CHECK-NOSANITIZE-SAME: (ptr noundef [[X:%.*]]) #[[ATTR0]] {
+// CHECK-NOSANITIZE-NEXT:  entry:
+// CHECK-NOSANITIZE-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NOSANITIZE-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8
+// CHECK-NOSANITIZE-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
+// CHECK-NOSANITIZE-NEXT:[[CALL:%.*]] = call noundef align 128 ptr @_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 noundef 128)
+// CHECK-NOSANITIZE-NEXT:ret ptr [[CALL]]
+//
+// CHECK-SANITIZE-NORECOVER-LABEL: define dso_local noundef ptr @_Z6callerPPc
+// CHECK-SANITIZE-NORECOVER-SAME: (ptr noundef [[X:%.*]]) #[[ATTR0]] {
+// CHECK-SANITIZE-NORECOVER-NEXT:  entry:
+// CHECK-SANITIZE-NORECOVER-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-SANITIZE-NORECOVER-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8
+// CHECK-SANITIZE-NORECOVER-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
+

[PATCH] D123085: CGExprCXX: emit allocptr attributes for operator delete

2023-06-08 Thread Augie Fackler via Phabricator via cfe-commits
durin42 updated this revision to Diff 529613.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123085

Files:
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/test/CodeGen/pr53127.cpp
  clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  clang/test/CodeGenCXX/delete-two-arg.cpp
  clang/test/CodeGenCXX/delete.cpp
  clang/test/CodeGenCXX/exceptions.cpp
  clang/test/CodeGenCXX/microsoft-abi-structors.cpp

Index: clang/test/CodeGenCXX/microsoft-abi-structors.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-structors.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-structors.cpp
@@ -56,7 +56,7 @@
 // DTORS-NEXT:   br i1 %[[CONDITION]], label %[[CONTINUE_LABEL:[0-9a-z._]+]], label %[[CALL_DELETE_LABEL:[0-9a-z._]+]]
 //
 // DTORS:  [[CALL_DELETE_LABEL]]
-// DTORS-NEXT:   call void @"??3@YAXPAX@Z"(ptr %[[THIS]])
+// DTORS-NEXT:   call void @"??3@YAXPAX@Z"(ptr allocptr %[[THIS]])
 // DTORS-NEXT:   br label %[[CONTINUE_LABEL]]
 //
 // DTORS:  [[CONTINUE_LABEL]]
@@ -114,7 +114,7 @@
 // CHECK-NEXT:   %[[PVDTOR:.*]] = getelementptr inbounds ptr, ptr %[[VTABLE]], i64 0
 // CHECK-NEXT:   %[[VDTOR:.*]] = load ptr, ptr %[[PVDTOR]]
 // CHECK-NEXT:   %[[CALL:.*]] = call x86_thiscallcc ptr %[[VDTOR]](ptr {{[^,]*}} %[[OBJ_PTR_VALUE]], i32 0)
-// CHECK-NEXT:   call void @"??3@YAXPAX@Z"(ptr %[[CALL]])
+// CHECK-NEXT:   call void @"??3@YAXPAX@Z"(ptr allocptr %[[CALL]])
 // CHECK:  ret void
 }
 
Index: clang/test/CodeGenCXX/exceptions.cpp
===
--- clang/test/CodeGenCXX/exceptions.cpp
+++ clang/test/CodeGenCXX/exceptions.cpp
@@ -36,7 +36,7 @@
 // CHECK:  [[NEW:%.*]] = call noalias nonnull ptr @_Znwm(i64 8)
 // CHECK-NEXT: invoke void @_ZN5test11AC1Ei(ptr {{[^,]*}} [[NEW]], i32 5)
 // CHECK:  ret ptr [[NEW]]
-// CHECK:  call void @_ZdlPv(ptr [[NEW]])
+// CHECK:  call void @_ZdlPv(ptr allocptr [[NEW]])
 return new A(5);
   }
 
@@ -46,7 +46,7 @@
 // CHECK-NEXT: [[FOO:%.*]] = invoke i32 @_ZN5test13fooEv()
 // CHECK:  invoke void @_ZN5test11AC1Ei(ptr {{[^,]*}} [[NEW]], i32 [[FOO]])
 // CHECK:  ret ptr [[NEW]]
-// CHECK:  call void @_ZdlPv(ptr [[NEW]])
+// CHECK:  call void @_ZdlPv(ptr allocptr [[NEW]])
 extern int foo();
 return new A(foo());
   }
@@ -71,7 +71,7 @@
 // CHECK:  ret ptr [[NEW]]
 // CHECK:  [[ISACTIVE:%.*]] = load i1, ptr [[ACTIVE]]
 // CHECK-NEXT: br i1 [[ISACTIVE]]
-// CHECK:  call void @_ZdlPv(ptr [[NEW]])
+// CHECK:  call void @_ZdlPv(ptr allocptr [[NEW]])
 return new A(B().x);
   }
 
@@ -98,7 +98,7 @@
 // CHECK:  ret ptr [[NEW]]
 // CHECK:  [[ISACTIVE:%.*]] = load i1, ptr [[ACTIVE]]
 // CHECK-NEXT: br i1 [[ISACTIVE]]
-// CHECK:  call void @_ZdlPv(ptr [[NEW]])
+// CHECK:  call void @_ZdlPv(ptr allocptr [[NEW]])
 return new A(B());
   }
 
@@ -123,7 +123,7 @@
 // CHECK:  ret ptr [[NEW]]
 // CHECK:  [[ISACTIVE:%.*]] = load i1, ptr [[ACTIVE]]
 // CHECK-NEXT: br i1 [[ISACTIVE]]
-// CHECK:  call void @_ZdlPv(ptr [[NEW]])
+// CHECK:  call void @_ZdlPv(ptr allocptr [[NEW]])
 return new A(B(), B());
   }
   A *f() {
@@ -159,7 +159,7 @@
 // CHECK:  ret ptr [[RET]]
 // CHECK:  [[ISACTIVE:%.*]] = load i1, ptr [[ACTIVE]]
 // CHECK-NEXT: br i1 [[ISACTIVE]]
-// CHECK:  call void @_ZdlPv(ptr [[NEW]])
+// CHECK:  call void @_ZdlPv(ptr allocptr [[NEW]])
 A *x;
 return (x = new A(makeB()), makeB(), x);
   }
@@ -445,7 +445,7 @@
   }
   // CHECK: define{{.*}} ptr @_ZN5test94testEv
   // CHECK: [[TEST9_NEW:%.*]] = call noalias nonnull ptr @_Znam
-  // CHECK: call void @_ZdaPv(ptr [[TEST9_NEW]])
+  // CHECK: call void @_ZdaPv(ptr allocptr [[TEST9_NEW]])
 }
 
 // In a destructor with a function-try-block, a return statement in a
Index: clang/test/CodeGenCXX/delete.cpp
===
--- clang/test/CodeGenCXX/delete.cpp
+++ clang/test/CodeGenCXX/delete.cpp
@@ -93,7 +93,7 @@
 // CHECK-NEXT: call void @_ZN5test11AD1Ev(ptr {{[^,]*}} [[CUR]])
 // CHECK-NEXT: [[ISDONE:%.*]] = icmp eq ptr [[CUR]], [[BEGIN]]
 // CHECK-NEXT: br i1 [[ISDONE]]
-// CHECK:  call void @_ZdaPv(ptr noundef [[ALLOC]])
+// CHECK:  call void @_ZdaPv(ptr allocptr noundef [[ALLOC]])
   }
 }
 
@@ -137,7 +137,7 @@
 // CHECK-NEXT: [[DTOR:%.*]] = load ptr, ptr [[T0]]
 // CHECK-NEXT: call void [[DTOR]](ptr {{[^,]*}} [[OBJ:%.*]])
 //   Call the global operator delete.
-// CHECK-NEXT: call void @_ZdlPv(ptr noundef [[ALLOCATED]]) [[NUW:#[0-9]+]]
+// CHECK-NEXT: call void @_ZdlPv(ptr allocptr noundef [[ALLOCATED]]) [[NUW:#[0-9]+]]
 ::delete xp;
   }
 }
Index: clang/test/CodeGenCXX/de

[PATCH] D119271: clang: emit allocalign to LLVM for alloc_align attributes

2023-06-08 Thread Augie Fackler via Phabricator via cfe-commits
durin42 updated this revision to Diff 529616.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119271

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/alloc-fns-alignment.c
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/CodeGenCXX/align-avx-complete-objects.cpp
  clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp

Index: clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
===
--- clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
+++ clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
@@ -27,10 +27,10 @@
 struct OVERALIGNED A { A(); int n[128]; };
 
 // CHECK-LABEL: define {{.*}} @_Z2a0v()
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @_ZnwmSt11align_val_t(i64 noundef 512, i64 allocalign noundef 32)
 // CHECK: call void @_ZdlPvSt11align_val_t(ptr allocptr noundef %[[ALLOC]], i64 noundef 32)
 // CHECK-MS-LABEL: define {{.*}} @"?a0@@YAPEAXXZ"()
-// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @"??2@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef 512, i64 noundef 32)
+// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @"??2@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef 512, i64 allocalign noundef 32)
 // CHECK-MS: cleanuppad
 // CHECK-MS: call void @"??3@YAXPEAXW4align_val_t@std@@@Z"(ptr allocptr noundef %[[ALLOC]], i64 noundef 32)
 void *a0() { return new A; }
@@ -39,13 +39,13 @@
 // The size is known.
 //
 // CHECK-LABEL: define {{.*}} @_Z2a1l(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 allocalign noundef 32)
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1AC1Ev(
 // CHECK: call void @_ZdaPvSt11align_val_t(ptr allocptr noundef %[[ALLOC]], i64 noundef 32)
 // CHECK-MS-LABEL: define {{.*}} @"?a1@@YAPEAXJ@Z"(
-// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @"??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @"??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef %{{.*}}, i64 allocalign noundef 32)
 // No array cookie.
 // CHECK-MS-NOT: store
 // CHECK-MS: invoke noundef ptr @"??0A@@QEAA@XZ"(
@@ -84,7 +84,7 @@
 void *b0() { return new B; }
 
 // CHECK-LABEL: define {{.*}} @_Z2b1l(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 allocalign noundef 32)
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1BC1Ev(
@@ -169,7 +169,7 @@
 
 #ifndef UNALIGNED
 // CHECK-LABEL: define {{.*}} @_Z2e0v(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 4 ptr @_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 4)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 4 ptr @_ZnwmSt11align_val_t(i64 noundef 512, i64 allocalign noundef 4)
 // CHECK: call void @_ZdlPvSt11align_val_t(ptr allocptr noundef %[[ALLOC]], i64 noundef 4)
 void *e0() { return new (std::align_val_t(4)) A; }
 
Index: clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
===
--- clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
+++ clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
@@ -47,7 +47,7 @@
 
 // CHECK-LABEL: define{{.*}} void @test_aligned_alloc(
 extern "C" void test_aligned_alloc() {
-  // CHECK: call noalias noundef nonnull align 4 ptr @_ZnwmSt11align_val_t(i64 noundef 4, i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
+  // CHECK: call noalias noundef nonnull align 4 ptr @_ZnwmSt11align_val_t(i64 noundef 4, i64 allocalign noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
   // CHECK: call void @_ZdlPvSt11align_val_t({{.*}}, i64 noundef 4) [[ATTR_BUILTIN_DELETE:#[^ ]*]]
   __builtin_operator_delete(__builtin_operator_new(4, std::align_val_t(4)), std::align_val_t(4));
 }
Index: clang/test/CodeGenCXX/align-avx-complete-objects.cpp
===
--- clang/test/CodeGenCXX/align-avx-complete-objects.cpp
+++ clang/test/CodeGenCXX/align-avx-complete-objects.cpp
@@ -18,7 +18,7 @@
 
 // CHECK: [[

[PATCH] D121629: clang: also check alloc_alignment claims in return

2023-06-08 Thread Augie Fackler via Phabricator via cfe-commits
durin42 updated this revision to Diff 529615.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121629

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp

Index: clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
===
--- clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
+++ clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
@@ -6,15 +6,87 @@
 
 
 char **__attribute__((alloc_align(2)))
-// CHECK-LABEL: define dso_local noundef ptr @_Z11passthroughPPcm
-// CHECK-SAME: (ptr noundef [[X:%.*]], i64 noundef [[ALIGNMENT:%.*]]) #[[ATTR0:[0-9]+]] {
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8
-// CHECK-NEXT:[[ALIGNMENT_ADDR:%.*]] = alloca i64, align 8
-// CHECK-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8
-// CHECK-NEXT:store i64 [[ALIGNMENT]], ptr [[ALIGNMENT_ADDR]], align 8
-// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
-// CHECK-NEXT:ret ptr [[TMP0]]
+// CHECK-NOSANITIZE-LABEL: define dso_local noundef ptr @_Z11passthroughPPcm
+// CHECK-NOSANITIZE-SAME: (ptr noundef [[X:%.*]], i64 noundef [[ALIGNMENT:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NOSANITIZE-NEXT:  entry:
+// CHECK-NOSANITIZE-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NOSANITIZE-NEXT:[[ALIGNMENT_ADDR:%.*]] = alloca i64, align 8
+// CHECK-NOSANITIZE-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8
+// CHECK-NOSANITIZE-NEXT:store i64 [[ALIGNMENT]], ptr [[ALIGNMENT_ADDR]], align 8
+// CHECK-NOSANITIZE-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
+// CHECK-NOSANITIZE-NEXT:ret ptr [[TMP0]]
+//
+// CHECK-SANITIZE-NORECOVER-LABEL: define dso_local noundef ptr @_Z11passthroughPPcm
+// CHECK-SANITIZE-NORECOVER-SAME: (ptr noundef [[X:%.*]], i64 noundef [[ALIGNMENT:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-SANITIZE-NORECOVER-NEXT:  entry:
+// CHECK-SANITIZE-NORECOVER-NEXT:[[RETURN_SLOC_PTR:%.*]] = alloca ptr, align 8
+// CHECK-SANITIZE-NORECOVER-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-SANITIZE-NORECOVER-NEXT:[[ALIGNMENT_ADDR:%.*]] = alloca i64, align 8
+// CHECK-SANITIZE-NORECOVER-NEXT:store ptr null, ptr [[RETURN_SLOC_PTR]], align 8
+// CHECK-SANITIZE-NORECOVER-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8
+// CHECK-SANITIZE-NORECOVER-NEXT:store i64 [[ALIGNMENT]], ptr [[ALIGNMENT_ADDR]], align 8
+// CHECK-SANITIZE-NORECOVER-NEXT:store ptr @[[GLOB0:[0-9]+]], ptr [[RETURN_SLOC_PTR]], align 8
+// CHECK-SANITIZE-NORECOVER-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
+// CHECK-SANITIZE-NORECOVER-NEXT:[[PTRINT:%.*]] = ptrtoint ptr [[TMP0]] to i64
+// CHECK-SANITIZE-NORECOVER-NEXT:[[TMP1:%.*]] = sub i64 [[ALIGNMENT]], 1
+// CHECK-SANITIZE-NORECOVER-NEXT:[[MASKEDPTR:%.*]] = and i64 [[PTRINT]], [[TMP1]]
+// CHECK-SANITIZE-NORECOVER-NEXT:[[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
+// CHECK-SANITIZE-NORECOVER-NEXT:[[TMP2:%.*]] = ptrtoint ptr [[TMP0]] to i64, !nosanitize !2
+// CHECK-SANITIZE-NORECOVER-NEXT:br i1 [[MASKCOND]], label [[CONT:%.*]], label [[HANDLER_ALIGNMENT_ASSUMPTION:%.*]], !prof [[PROF3:![0-9]+]], !nosanitize !2
+// CHECK-SANITIZE-NORECOVER:   handler.alignment_assumption:
+// CHECK-SANITIZE-NORECOVER-NEXT:call void @__ubsan_handle_alignment_assumption_abort(ptr @[[GLOB2:[0-9]+]], i64 [[TMP2]], i64 [[ALIGNMENT]], i64 0) #[[ATTR3:[0-9]+]], !nosanitize !2
+// CHECK-SANITIZE-NORECOVER-NEXT:unreachable, !nosanitize !2
+// CHECK-SANITIZE-NORECOVER:   cont:
+// CHECK-SANITIZE-NORECOVER-NEXT:call void @llvm.assume(i1 true) [ "align"(ptr [[TMP0]], i64 [[ALIGNMENT]]) ]
+// CHECK-SANITIZE-NORECOVER-NEXT:ret ptr [[TMP0]]
+//
+// CHECK-SANITIZE-RECOVER-LABEL: define dso_local noundef ptr @_Z11passthroughPPcm
+// CHECK-SANITIZE-RECOVER-SAME: (ptr noundef [[X:%.*]], i64 noundef [[ALIGNMENT:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-SANITIZE-RECOVER-NEXT:  entry:
+// CHECK-SANITIZE-RECOVER-NEXT:[[RETURN_SLOC_PTR:%.*]] = alloca ptr, align 8
+// CHECK-SANITIZE-RECOVER-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-SANITIZE-RECOVER-NEXT:[[ALIGNMENT_ADDR:%.*]] = alloca i64, align 8
+// CHECK-SANITIZE-RECOVER-NEXT:store ptr null, ptr [[RETURN_SLOC_PTR]], align 8
+// CHECK-SANITIZE-RECOVER-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8
+// CHECK-SANITIZE-RECOVER-NEXT:store i64 [[ALIGNMENT]], ptr [[ALIGNMENT_ADDR]], align 8
+// CHECK-SANITIZE-RECOVER-NEXT:store ptr @[[GLOB0:[0-9]+]], ptr [[RETURN_SLOC_PTR]], align 8
+// CHECK-SANITIZE-RECOVER-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8

[PATCH] D152401: CGExprCXX: emit family and allockind attributes

2023-06-08 Thread Augie Fackler via Phabricator via cfe-commits
durin42 edited the summary of this revision.
durin42 updated this revision to Diff 529617.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152401

Files:
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  clang/test/CodeGenCXX/new.cpp
  clang/test/CodeGenCXX/new_hot_cold.cpp
  llvm/lib/Analysis/MemoryBuiltins.cpp

Index: llvm/lib/Analysis/MemoryBuiltins.cpp
===
--- llvm/lib/Analysis/MemoryBuiltins.cpp
+++ llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -110,38 +110,6 @@
 // FIXME: certain users need more information. E.g., SimplifyLibCalls needs to
 // know which functions are nounwind, noalias, nocapture parameters, etc.
 static const std::pair AllocationFnData[] = {
-{LibFunc_Znwj,  {OpNewLike,1,  0, -1, -1, MallocFamily::CPPNew}}, // new(unsigned int)
-{LibFunc_ZnwjRKSt9nothrow_t,{MallocLike,   2,  0, -1, -1, MallocFamily::CPPNew}}, // new(unsigned int, nothrow)
-{LibFunc_ZnwjSt11align_val_t,   {OpNewLike,2,  0, -1,  1, MallocFamily::CPPNewAligned}},  // new(unsigned int, align_val_t)
-{LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t, {MallocLike,   3,  0, -1,  1, MallocFamily::CPPNewAligned}},  // new(unsigned int, align_val_t, nothrow)
-{LibFunc_Znwm,  {OpNewLike,1,  0, -1, -1, MallocFamily::CPPNew}}, // new(unsigned long)
-{LibFunc_Znwm12__hot_cold_t,  {OpNewLike,2, 0,  -1, -1, MallocFamily::CPPNew}}, // new(unsigned long, __hot_cold_t)
-{LibFunc_ZnwmRKSt9nothrow_t,{MallocLike,   2,  0, -1, -1, MallocFamily::CPPNew}}, // new(unsigned long, nothrow)
-{LibFunc_ZnwmRKSt9nothrow_t12__hot_cold_t,  {MallocLike,   3, 0,  -1, -1, MallocFamily::CPPNew}}, // new(unsigned long, nothrow, __hot_cold_t)
-{LibFunc_ZnwmSt11align_val_t,   {OpNewLike,2,  0, -1,  1, MallocFamily::CPPNewAligned}},  // new(unsigned long, align_val_t)
-{LibFunc_ZnwmSt11align_val_t12__hot_cold_t,   {OpNewLike,3, 0,  -1, 1, MallocFamily::CPPNewAligned}},   // new(unsigned long, align_val_t, __hot_cold_t)
-{LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t, {MallocLike,   3,  0, -1,  1, MallocFamily::CPPNewAligned}},  // new(unsigned long, align_val_t, nothrow)
-{LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t, {MallocLike,  4, 0,  -1, 1, MallocFamily::CPPNewAligned}},// new(unsigned long, align_val_t, nothrow, __hot_cold_t)
-{LibFunc_Znaj,  {OpNewLike,1,  0, -1, -1, MallocFamily::CPPNewArray}},// new[](unsigned int)
-{LibFunc_ZnajRKSt9nothrow_t,{MallocLike,   2,  0, -1, -1, MallocFamily::CPPNewArray}},// new[](unsigned int, nothrow)
-{LibFunc_ZnajSt11align_val_t,   {OpNewLike,2,  0, -1,  1, MallocFamily::CPPNewArrayAligned}}, // new[](unsigned int, align_val_t)
-{LibFunc_ZnajSt11align_val_tRKSt9nothrow_t, {MallocLike,   3,  0, -1,  1, MallocFamily::CPPNewArrayAligned}}, // new[](unsigned int, align_val_t, nothrow)
-{LibFunc_Znam,  {OpNewLike,1,  0, -1, -1, MallocFamily::CPPNewArray}},// new[](unsigned long)
-{LibFunc_Znam12__hot_cold_t,  {OpNewLike,2, 0,  -1, -1, MallocFamily::CPPNew}}, // new[](unsigned long, __hot_cold_t)
-{LibFunc_ZnamRKSt9nothrow_t,{MallocLike,   2,  0, -1, -1, MallocFamily::CPPNewArray}},// new[](unsigned long, nothrow)
-{LibFunc_ZnamRKSt9nothrow_t12__hot_cold_t,  {MallocLike,   3, 0,  -1, -1, MallocFamily::CPPNew}}, // new[](unsigned long, nothrow, __hot_cold_t)
-{LibFunc_ZnamSt11align_val_t,   {OpNewLike,2,  0, -1,  1, MallocFamily::CPPNewArrayAligned}}, // new[](unsigned long, align_val_t)
-{LibFunc_ZnamSt11align_val_t12__hot_cold_t,   {OpNewLike,3, 0,  -1, 1, MallocFamily::CPPNewAligned}},   // new[](unsigned long, align_val_t, __hot_cold_t)
-{LibFunc_ZnamSt11align_val_tRKSt9nothrow_t, {MallocLike,   3,  0, -1,  1, MallocFamily::CPPNewArrayAligned}}, // new[](unsigned long, align_val_t, nothrow)
-{LibFunc_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t, {MallocLike,  4, 0,  -1, 1, MallocFamily::CPPNewAligned}},// new[](unsigned long, align_val_t, nothrow, __hot_cold_t)
-{LibFunc_msvc_new_int,  {OpNewLike,1,  0, -1, -1, MallocFamily::MSVCNew}},// new(unsigned int)
-{LibFunc_msvc_new_int_nothrow,  {MallocLike,   2,  0, -1, -1, MallocFamily::MSVCNew}},// new(unsigned int, nothrow)
-{LibFunc_msvc_new_longlong,  

[clang] e4c1fa7 - [RISCV] Add test cases to show that rvv_vector_bits attribute is not accepted for vbool or LMUL!=1 RVV types. NFC

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

Author: Craig Topper
Date: 2023-06-08T08:47:59-07:00
New Revision: e4c1fa734ea7cd8f76f221e99cc727c18858183e

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

LOG: [RISCV] Add test cases to show that rvv_vector_bits attribute is not 
accepted for vbool or LMUL!=1 RVV types. NFC

The error message isn't great, but it's temporary until we support these.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/test/Sema/attr-riscv-rvv-vector-bits.c

Removed: 




diff  --git a/clang/test/Sema/attr-riscv-rvv-vector-bits.c 
b/clang/test/Sema/attr-riscv-rvv-vector-bits.c
index 846fec9e62e4e..ebc556a830313 100644
--- a/clang/test/Sema/attr-riscv-rvv-vector-bits.c
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits.c
@@ -6,6 +6,30 @@
 
 #include 
 
+typedef __rvv_bool64_t vbool64_t;
+typedef __rvv_bool32_t vbool32_t;
+typedef __rvv_bool16_t vbool16_t;
+typedef __rvv_bool8_t vbool8_t;
+typedef __rvv_bool4_t vbool4_t;
+typedef __rvv_bool2_t vbool2_t;
+typedef __rvv_bool1_t vbool1_t;
+
+typedef __rvv_int8mf8_t vint8mf8_t;
+typedef __rvv_uint8mf8_t vuint8mf8_t;
+
+typedef __rvv_int8mf4_t vint8mf4_t;
+typedef __rvv_uint8mf4_t vuint8mf4_t;
+typedef __rvv_int16mf4_t vint16mf4_t;
+typedef __rvv_uint16mf4_t vuint16mf4_t;
+
+typedef __rvv_int8mf2_t vint8mf2_t;
+typedef __rvv_uint8mf2_t vuint8mf2_t;
+typedef __rvv_int16mf2_t vint16mf2_t;
+typedef __rvv_uint16mf2_t vuint16mf2_t;
+typedef __rvv_int32mf2_t vint32mf2_t;
+typedef __rvv_uint32mf2_t vuint32mf2_t;
+typedef __rvv_float32mf2_t vfloat32mf2_t;
+
 typedef __rvv_int8m1_t vint8m1_t;
 typedef __rvv_uint8m1_t vuint8m1_t;
 typedef __rvv_int16m1_t vint16m1_t;
@@ -17,7 +41,38 @@ typedef __rvv_uint64m1_t vuint64m1_t;
 typedef __rvv_float32m1_t vfloat32m1_t;
 typedef __rvv_float64m1_t vfloat64m1_t;
 
+typedef __rvv_int8m2_t vint8m2_t;
+typedef __rvv_uint8m2_t vuint8m2_t;
+typedef __rvv_int16m2_t vint16m2_t;
+typedef __rvv_uint16m2_t vuint16m2_t;
 typedef __rvv_int32m2_t vint32m2_t;
+typedef __rvv_uint32m2_t vuint32m2_t;
+typedef __rvv_int64m2_t vint64m2_t;
+typedef __rvv_uint64m2_t vuint64m2_t;
+typedef __rvv_float32m2_t vfloat32m2_t;
+typedef __rvv_float64m2_t vfloat64m2_t;
+
+typedef __rvv_int8m4_t vint8m4_t;
+typedef __rvv_uint8m4_t vuint8m4_t;
+typedef __rvv_int16m4_t vint16m4_t;
+typedef __rvv_uint16m4_t vuint16m4_t;
+typedef __rvv_int32m4_t vint32m4_t;
+typedef __rvv_uint32m4_t vuint32m4_t;
+typedef __rvv_int64m4_t vint64m4_t;
+typedef __rvv_uint64m4_t vuint64m4_t;
+typedef __rvv_float32m4_t vfloat32m4_t;
+typedef __rvv_float64m4_t vfloat64m4_t;
+
+typedef __rvv_int8m8_t vint8m8_t;
+typedef __rvv_uint8m8_t vuint8m8_t;
+typedef __rvv_int16m8_t vint16m8_t;
+typedef __rvv_uint16m8_t vuint16m8_t;
+typedef __rvv_int32m8_t vint32m8_t;
+typedef __rvv_uint32m8_t vuint32m8_t;
+typedef __rvv_int64m8_t vint64m8_t;
+typedef __rvv_uint64m8_t vuint64m8_t;
+typedef __rvv_float32m8_t vfloat32m8_t;
+typedef __rvv_float64m8_t vfloat64m8_t;
 
 // Define valid fixed-width RVV types
 typedef vint8m1_t fixed_int8m1_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
@@ -57,6 +112,15 @@ typedef vint8m1_t two_arguments 
__attribute__((riscv_rvv_vector_bits(2, 4))); //
 typedef vint8m1_t non_int_size1 __attribute__((riscv_rvv_vector_bits(2.0)));   
// expected-error {{'riscv_rvv_vector_bits' attribute requires an integer 
constant}}
 typedef vint8m1_t non_int_size2 __attribute__((riscv_rvv_vector_bits("256"))); 
// expected-error {{'riscv_rvv_vector_bits' attribute requires an integer 
constant}}
 
+// bool types and LMUL != 1 are not supported.
+typedef vbool1_t fixed_vbool1_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error 
{{'riscv_rvv_vector_bits' attribute applied to non-RVV type 'vbool1_t'}}
+typedef vint8mf8_t fixed_int8mf8_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'vint8mf8_t'}}
+typedef vint8mf4_t fixed_int8mf4_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'vint8mf4_t'}}
+typedef vint8mf2_t fixed_int8mf2_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'vint8mf2_t'}}
+typedef vint8m2_t fixed_int8m2_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'vint8m2_t'}}
+typedef vint8m4_t fixed_int8m4_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'vint8m4_t'}}
+typedef 

[PATCH] D152415: [RISCV] Add test cases to show that rvv_vector_bits attribute is not accepted for vbool or LMUL!=1 RVV types. NFC

2023-06-08 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 rGe4c1fa734ea7: [RISCV] Add test cases to show that 
rvv_vector_bits attribute is not accepted… (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152415

Files:
  clang/test/Sema/attr-riscv-rvv-vector-bits.c


Index: clang/test/Sema/attr-riscv-rvv-vector-bits.c
===
--- clang/test/Sema/attr-riscv-rvv-vector-bits.c
+++ clang/test/Sema/attr-riscv-rvv-vector-bits.c
@@ -6,6 +6,30 @@
 
 #include 
 
+typedef __rvv_bool64_t vbool64_t;
+typedef __rvv_bool32_t vbool32_t;
+typedef __rvv_bool16_t vbool16_t;
+typedef __rvv_bool8_t vbool8_t;
+typedef __rvv_bool4_t vbool4_t;
+typedef __rvv_bool2_t vbool2_t;
+typedef __rvv_bool1_t vbool1_t;
+
+typedef __rvv_int8mf8_t vint8mf8_t;
+typedef __rvv_uint8mf8_t vuint8mf8_t;
+
+typedef __rvv_int8mf4_t vint8mf4_t;
+typedef __rvv_uint8mf4_t vuint8mf4_t;
+typedef __rvv_int16mf4_t vint16mf4_t;
+typedef __rvv_uint16mf4_t vuint16mf4_t;
+
+typedef __rvv_int8mf2_t vint8mf2_t;
+typedef __rvv_uint8mf2_t vuint8mf2_t;
+typedef __rvv_int16mf2_t vint16mf2_t;
+typedef __rvv_uint16mf2_t vuint16mf2_t;
+typedef __rvv_int32mf2_t vint32mf2_t;
+typedef __rvv_uint32mf2_t vuint32mf2_t;
+typedef __rvv_float32mf2_t vfloat32mf2_t;
+
 typedef __rvv_int8m1_t vint8m1_t;
 typedef __rvv_uint8m1_t vuint8m1_t;
 typedef __rvv_int16m1_t vint16m1_t;
@@ -17,7 +41,38 @@
 typedef __rvv_float32m1_t vfloat32m1_t;
 typedef __rvv_float64m1_t vfloat64m1_t;
 
+typedef __rvv_int8m2_t vint8m2_t;
+typedef __rvv_uint8m2_t vuint8m2_t;
+typedef __rvv_int16m2_t vint16m2_t;
+typedef __rvv_uint16m2_t vuint16m2_t;
 typedef __rvv_int32m2_t vint32m2_t;
+typedef __rvv_uint32m2_t vuint32m2_t;
+typedef __rvv_int64m2_t vint64m2_t;
+typedef __rvv_uint64m2_t vuint64m2_t;
+typedef __rvv_float32m2_t vfloat32m2_t;
+typedef __rvv_float64m2_t vfloat64m2_t;
+
+typedef __rvv_int8m4_t vint8m4_t;
+typedef __rvv_uint8m4_t vuint8m4_t;
+typedef __rvv_int16m4_t vint16m4_t;
+typedef __rvv_uint16m4_t vuint16m4_t;
+typedef __rvv_int32m4_t vint32m4_t;
+typedef __rvv_uint32m4_t vuint32m4_t;
+typedef __rvv_int64m4_t vint64m4_t;
+typedef __rvv_uint64m4_t vuint64m4_t;
+typedef __rvv_float32m4_t vfloat32m4_t;
+typedef __rvv_float64m4_t vfloat64m4_t;
+
+typedef __rvv_int8m8_t vint8m8_t;
+typedef __rvv_uint8m8_t vuint8m8_t;
+typedef __rvv_int16m8_t vint16m8_t;
+typedef __rvv_uint16m8_t vuint16m8_t;
+typedef __rvv_int32m8_t vint32m8_t;
+typedef __rvv_uint32m8_t vuint32m8_t;
+typedef __rvv_int64m8_t vint64m8_t;
+typedef __rvv_uint64m8_t vuint64m8_t;
+typedef __rvv_float32m8_t vfloat32m8_t;
+typedef __rvv_float64m8_t vfloat64m8_t;
 
 // Define valid fixed-width RVV types
 typedef vint8m1_t fixed_int8m1_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
@@ -57,6 +112,15 @@
 typedef vint8m1_t non_int_size1 __attribute__((riscv_rvv_vector_bits(2.0)));   
// expected-error {{'riscv_rvv_vector_bits' attribute requires an integer 
constant}}
 typedef vint8m1_t non_int_size2 __attribute__((riscv_rvv_vector_bits("256"))); 
// expected-error {{'riscv_rvv_vector_bits' attribute requires an integer 
constant}}
 
+// bool types and LMUL != 1 are not supported.
+typedef vbool1_t fixed_vbool1_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error 
{{'riscv_rvv_vector_bits' attribute applied to non-RVV type 'vbool1_t'}}
+typedef vint8mf8_t fixed_int8mf8_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'vint8mf8_t'}}
+typedef vint8mf4_t fixed_int8mf4_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'vint8mf4_t'}}
+typedef vint8mf2_t fixed_int8mf2_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'vint8mf2_t'}}
+typedef vint8m2_t fixed_int8m2_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'vint8m2_t'}}
+typedef vint8m4_t fixed_int8m4_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'vint8m4_t'}}
+typedef vint8m8_t fixed_int8m8_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'vint8m8_t'}}
+
 // Attribute must be attached to a single RVV vector or predicate type.
 typedef void *badtype1 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // 
expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 
'v

[clang] 066fb7a - [Clang] Remove -no-opaque-pointers cc1 flag

2023-06-08 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-06-08T17:52:20+02:00
New Revision: 066fb7a58c5a0dd518d0841ed8f32f86d9f798ec

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

LOG: [Clang] Remove -no-opaque-pointers cc1 flag

Migration of clang tests to opaque pointers is finished, so remove
the -no-opaque-pointers flag.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenAction.cpp
llvm/docs/OpaquePointers.rst

Removed: 
clang/test/CodeGen/opaque-pointers-flag.c
clang/test/CodeGenOpenCL/opaque-ptr-spirv.cl



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b17e746976573..85573dc7f466b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -254,6 +254,7 @@ Removed Compiler Flags
 - The CodeGen flag `-lower-global-dtors-via-cxa-atexit` which affects how 
global
   destructors are lowered for MachO is removed without replacement. The default
   of `-lower-global-dtors-via-cxa-atexit=true` is now the only supported way.
+- The cc1 flag ``-no-opaque-pointers`` has been removed.
 
 Attribute Changes in Clang
 --

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 53d92c4c76673..9cd911e7fce14 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -501,9 +501,6 @@ CODEGENOPT(SkipRaxSetup, 1, 0)
 ENUM_CODEGENOPT(ZeroCallUsedRegs, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
 5, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::Skip)
 
-/// Whether to use opaque pointers.
-CODEGENOPT(OpaquePointers, 1, 0)
-
 /// Modify C++ ABI to returning `this` pointer from constructors and
 /// non-deleting destructors. (No effect on Microsoft ABI.)
 CODEGENOPT(CtorDtorReturnThis, 1, 0)

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 7fad5b27fdb6e..7934afa52af84 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6029,13 +6029,6 @@ defm enable_noundef_analysis : BoolOption<"",
   PosFlag,
   NegFlag,
   BothFlags<[], " analyzing function argument and return types for mandatory 
definedness">>;
-defm opaque_pointers : BoolOption<"",
-  "opaque-pointers",
-  CodeGenOpts<"OpaquePointers">,
-  DefaultTrue,
-  PosFlag,
-  NegFlag,
-  BothFlags<[], " opaque pointers">>;
 def discard_value_names : Flag<["-"], "discard-value-names">,
   HelpText<"Discard value names in LLVM IR">,
   MarshallingInfoFlag>;

diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index b93477fdbf0aa..4aa51e956655f 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -1047,8 +1047,6 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, 
StringRef InFile) {
   if (BA != Backend_EmitNothing && !OS)
 return nullptr;
 
-  VMContext->setOpaquePointers(CI.getCodeGenOpts().OpaquePointers);
-
   // Load bitcode modules to link with, if we need to.
   if (LinkModules.empty())
 for (const CodeGenOptions::BitcodeFileToLink &F :
@@ -1106,8 +1104,6 @@ CodeGenAction::loadModule(MemoryBufferRef MBRef) {
   CompilerInstance &CI = getCompilerInstance();
   SourceManager &SM = CI.getSourceManager();
 
-  VMContext->setOpaquePointers(CI.getCodeGenOpts().OpaquePointers);
-
   // 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.

diff  --git a/clang/test/CodeGen/opaque-pointers-flag.c 
b/clang/test/CodeGen/opaque-pointers-flag.c
deleted file mode 100644
index 1fbff99f8ef60..0
--- a/clang/test/CodeGen/opaque-pointers-flag.c
+++ /dev/null
@@ -1,25 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | 
FileCheck %s -check-prefix=TYPED
-// RUN: %clang_cc1 -opaque-pointers -triple x86_64-unknown-unknown -emit-llvm 
%s -o - | FileCheck %s -check-prefix=OPAQUE
-
-// TYPED-LABEL: @test(
-// TYPED-NEXT:  entry:
-// TYPED-NEXT:[[P_ADDR:%.*]] = alloca ptr, align 8
-// TYPED-NEXT:store ptr [[P:%.*]], ptr [[P_ADDR]], align 8
-// TYPED-NEXT:[[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8
-// TYPED-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], 
i64 1
-// TYPED-NEXT:[[TMP1:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
-// TYPED-NEXT:ret i32 [[TMP1]]
-//
-// OPAQUE-LABEL: @test(
-// OPAQUE-NEXT:  entry:
-// OPAQUE-NEXT:[[P_AD

[PATCH] D152447: [Clang] Remove -no-opaque-pointers cc1 flag

2023-06-08 Thread Nikita Popov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG066fb7a58c5a: [Clang] Remove -no-opaque-pointers cc1 flag 
(authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D152447?vs=529597&id=529620#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152447

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/CodeGen/opaque-pointers-flag.c
  clang/test/CodeGenOpenCL/opaque-ptr-spirv.cl
  llvm/docs/OpaquePointers.rst

Index: llvm/docs/OpaquePointers.rst
===
--- llvm/docs/OpaquePointers.rst
+++ llvm/docs/OpaquePointers.rst
@@ -289,6 +289,8 @@
 The following typed pointer functionality has already been removed:
 
 * The ``CLANG_ENABLE_OPAQUE_POINTERS`` cmake flag is no longer supported.
+* The ``-no-opaque-pointers`` cc1 clang flag is no longer supported.
+* The ``-plugin-opt=no-opaque-pointers`` LTO flag is no longer supported.
 * C APIs that do not support opaque pointers (like ``LLVMBuildLoad``) are no
   longer supported.
 * Typed pointer IR and bitcode is implicitly upgraded to use opaque pointers,
@@ -296,6 +298,5 @@
 
 The following typed pointer functionality is still to be removed:
 
-* The ``-no-opaque-pointers`` cc1 flag, ``-opaque-pointers=0`` opt flag and
-  ``-plugin-opt=no-opaque-pointers`` lto flag.
+* The ``-opaque-pointers=0`` opt flag.
 * Support for typed pointers in LLVM libraries.
Index: clang/test/CodeGenOpenCL/opaque-ptr-spirv.cl
===
--- clang/test/CodeGenOpenCL/opaque-ptr-spirv.cl
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -o - -triple spirv64 %s | FileCheck %s
-
-// Check that we have a way to recover pointer
-// types for extern function prototypes (see PR56660).
-extern void foo(global int * ptr);
-kernel void k(global int * ptr) {
-  foo(ptr);
-}
-//CHECK: define spir_kernel void @k(i32 {{.*}}*
-//CHECK: declare spir_func void @foo(i32 {{.*}}*
Index: clang/test/CodeGen/opaque-pointers-flag.c
===
--- clang/test/CodeGen/opaque-pointers-flag.c
+++ /dev/null
@@ -1,25 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=TYPED
-// RUN: %clang_cc1 -opaque-pointers -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=OPAQUE
-
-// TYPED-LABEL: @test(
-// TYPED-NEXT:  entry:
-// TYPED-NEXT:[[P_ADDR:%.*]] = alloca ptr, align 8
-// TYPED-NEXT:store ptr [[P:%.*]], ptr [[P_ADDR]], align 8
-// TYPED-NEXT:[[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8
-// TYPED-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 1
-// TYPED-NEXT:[[TMP1:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
-// TYPED-NEXT:ret i32 [[TMP1]]
-//
-// OPAQUE-LABEL: @test(
-// OPAQUE-NEXT:  entry:
-// OPAQUE-NEXT:[[P_ADDR:%.*]] = alloca ptr, align 8
-// OPAQUE-NEXT:store ptr [[P:%.*]], ptr [[P_ADDR]], align 8
-// OPAQUE-NEXT:[[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8
-// OPAQUE-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 1
-// OPAQUE-NEXT:[[TMP1:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
-// OPAQUE-NEXT:ret i32 [[TMP1]]
-//
-int test(int *p) {
-  return p[1];
-}
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -1047,8 +1047,6 @@
   if (BA != Backend_EmitNothing && !OS)
 return nullptr;
 
-  VMContext->setOpaquePointers(CI.getCodeGenOpts().OpaquePointers);
-
   // Load bitcode modules to link with, if we need to.
   if (LinkModules.empty())
 for (const CodeGenOptions::BitcodeFileToLink &F :
@@ -1106,8 +1104,6 @@
   CompilerInstance &CI = getCompilerInstance();
   SourceManager &SM = CI.getSourceManager();
 
-  VMContext->setOpaquePointers(CI.getCodeGenOpts().OpaquePointers);
-
   // 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.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6029,13 +6029,6 @@
   PosFlag,
   NegFlag,
   BothFlags<[], " analyzing function argument and return types for mandatory definedness">>;
-defm opaque_pointers : BoolOption<"",
-  "opaque-pointers",
-  CodeGenOpts<"Op

[PATCH] D143984: [DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)

2023-06-08 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D143984#4405961 , @dzhidzhoev 
wrote:

> In D143984#4405875 , @steakhal 
> wrote:
>
>> I think this patch broke two build bots, and now the CI is red.
>> https://lab.llvm.org/buildbot/#/builders/16/builds/49282
>> https://lab.llvm.org/buildbot/#/builders/109/builds/65904
>>
>> Could you please have a look?
>
> Thank you! Reverted.
> Does anyone know if there is a possibility to subscribe to buildbot emails 
> related to a specific commit if you're not the author of the commit?

To me, it would make sense if its a shared responsibility, or at least the 
person pushing the commit to see if it needs to be reverted. IDK of any 
guidelines though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143984

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


[clang] cd18efb - [Driver] Make -G TargetSpecific

2023-06-08 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-06-08T09:02:12-07:00
New Revision: cd18efb61d759405956dbd30e4b5f2720d8e1783

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

LOG: [Driver] Make -G TargetSpecific

so that we report `unsupported option '-G' for target ...` on
unsupported targets (most targets).
This error is tested by one target in aix-err-options.c.

Follow-up to D89897 and D90063.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/aix-err-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 7934afa52af84..30e75fd02d52c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -723,7 +723,7 @@ def E : Flag<["-"], "E">, Flags<[NoXarchOption,CC1Option, 
FlangOption, FC1Option
 HelpText<"Only run the preprocessor">;
 def F : JoinedOrSeparate<["-"], "F">, Flags<[RenderJoined,CC1Option]>,
 HelpText<"Add directory to framework include search path">;
-def G : JoinedOrSeparate<["-"], "G">, Flags<[NoXarchOption]>, Group,
+def G : JoinedOrSeparate<["-"], "G">, Flags<[NoXarchOption,TargetSpecific]>, 
Group,
 MetaVarName<"">, HelpText<"Put objects of at most  bytes "
 "into small data section (MIPS / Hexagon)">;
 def G_EQ : Joined<["-"], "G=">, Flags<[NoXarchOption]>, Group, 
Alias;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index fee14ba6faabe..243aebb3bc23f 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4739,13 +4739,8 @@ void Driver::BuildJobs(Compilation &C) const {
   }
 
   const llvm::Triple &RawTriple = C.getDefaultToolChain().getTriple();
-  if (RawTriple.isOSAIX()) {
-if (Arg *A = C.getArgs().getLastArg(options::OPT_G))
-  Diag(diag::err_drv_unsupported_opt_for_target)
-  << A->getSpelling() << RawTriple.str();
-if (LTOMode == LTOK_Thin)
-  Diag(diag::err_drv_clang_unsupported) << "thinLTO on AIX";
-  }
+  if (RawTriple.isOSAIX() && LTOMode == LTOK_Thin)
+Diag(diag::err_drv_clang_unsupported) << "thinLTO on AIX";
 
   // Collect the list of architectures.
   llvm::StringSet<> ArchNames;

diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index ad7f3edeb9384..a0b036eea64ba 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -112,6 +112,11 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (!(IsArch32Bit || IsArch64Bit))
 llvm_unreachable("Unsupported bit width value.");
 
+  if (Arg *A = C.getArgs().getLastArg(options::OPT_G)) {
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getSpelling() << D.getTargetTriple();
+  }
+
   // Force static linking when "-static" is present.
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("-bnso");

diff  --git a/clang/test/Driver/aix-err-options.c 
b/clang/test/Driver/aix-err-options.c
index 935ae78dab080..45d36136e1297 100644
--- a/clang/test/Driver/aix-err-options.c
+++ b/clang/test/Driver/aix-err-options.c
@@ -4,12 +4,9 @@
 // RUN:   FileCheck --check-prefix=CHECK32 %s
 // RUN: %clang --target=powerpc-ibm-aix-xcoff -### -c -G 0 2>&1 %s | \
 // RUN:   FileCheck --check-prefix=CHECK32 %s
-// RUN: %clang --target=powerpc-ibm-aix-xcoff -### -c \
-// RUN: %S/Inputs/aix_ppc_tree/dummy0.s -G 0 2>&1 | \
-// RUN:   FileCheck --check-prefix=CHECK32 %s
-// RUN: %clang --target=powerpc-ibm-aix-xcoff -### -o dummy.so \
-// RUN: %S/Inputs/aix_ppc_tree/dummy0.o -G 0 2>&1 | \
-// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: touch %t.s %t.o
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### -c %t.s -G 0 2>&1 | 
FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### -o dummy.so %t.o -G 0 2>&1 
| FileCheck --check-prefix=CHECK32 %s
 
 // RUN: %clang --target=powerpc64-ibm-aix-xcoff -### -E -G 0 2>&1 %s | \
 // RUN:   FileCheck --check-prefix=CHECK64 %s
@@ -17,12 +14,8 @@
 // RUN:   FileCheck --check-prefix=CHECK64 %s
 // RUN: %clang --target=powerpc64-ibm-aix-xcoff -### -c -G 0 2>&1 %s | \
 // RUN:   FileCheck --check-prefix=CHECK64 %s
-// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### -c \
-// RUN: %S/Inputs/aix_ppc_tree/dummy0.s -G 0 2>&1 | \
-// RUN:   FileCheck --check-prefix=CHECK64 %s
-// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### -o dummy.so \
-// RUN: %S/Inputs/aix_ppc_tree/dummy0.o -G 0 2>&1 | \
-// RUN:   FileCheck --check-prefix=CHECK64 %s
+// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### -c %t.s -G 0 2>&1 | 
FileCheck --check-prefix=CHECK64 %s
+// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### -o dummy.so %t.o -G 0 
2>&1 

[PATCH] D152321: [clang] Replace use of Type::getPointerTo() (NFC)

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

In D152321#4403719 , @JOE1994 wrote:

> Some tests that run with `-no-opaque-pointers` began failing after I updated 
> the revision to get rid of bitcasts.
> The bitcasts are still needed if running Clang with `-no-opaque-pointers`.

I have finished migrating these tests and removed the flag in 
https://reviews.llvm.org/D152447, so this should no longer be an issue.




Comment at: clang/lib/CodeGen/CGBuilder.h:172
+auto *PtrTy = llvm::PointerType::get(Ty, Addr.getAddressSpace());
 return Address(CreateBitCast(Addr.getPointer(), PtrTy, Name), Ty,
Addr.getAlignment(), Addr.isKnownNonNull());

Can remove this bit cast.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:222
CGF.getContext().getTypeSize(T));
-  llvm::Type *IntPtrType = IntType->getPointerTo(AddrSpace);
+  llvm::Type *IntPtrType = llvm::PointerType::get(IntType, AddrSpace);
 

We should be using the overload that take as a context rather than a type, to 
create an opaque pointers. The variable name should also drop the mention of 
the specific type.

Same for other uses.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:328
   Value *Args[3];
   Args[0] = CGF.Builder.CreateBitCast(DestPtr, IntPtrType);
   Args[1] = CGF.EmitScalarExpr(E->getArg(1));

Remove bitcast



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:421
+  llvm::Type *Int128PtrTy = llvm::PointerType::getUnqual(Int128Ty);
   Destination = CGF.Builder.CreateBitCast(Destination, Int128PtrTy);
   Address ComparandResult(CGF.Builder.CreateBitCast(ComparandPtr, Int128PtrTy),

Remove bitcast



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:4668
 llvm::Value *Destination =
   Builder.CreateBitCast(EmitScalarExpr(E->getArg(0)), IntPtrType);
 

Remove bitcast (more below...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152321

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


[clang] e12aee2 - [RISCV] Update documentation for -mvscale-min/max options to mention RISC-V. NFC

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

Author: Craig Topper
Date: 2023-06-08T09:16:01-07:00
New Revision: e12aee2afeabdba3fa2229b616c3aab48e6f2a54

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

LOG: [RISCV] Update documentation for -mvscale-min/max options to mention 
RISC-V. NFC

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 30e75fd02d52c..0a17de56c74de 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3791,12 +3791,12 @@ def msve_vector_bits_EQ : Joined<["-"], 
"msve-vector-bits=">, Group,
+  HelpText<"Specify the vscale minimum. Defaults to \"1\". (AArch64/RISC-V 
only)">,
   MarshallingInfoInt>;
 def mvscale_max_EQ : Joined<["-"], "mvscale-max=">,
   Group, Flags<[NoXarchOption,CC1Option]>,
   HelpText<"Specify the vscale maximum. Defaults to the"
-   " vector length agnostic value of \"0\". (AArch64 only)">,
+   " vector length agnostic value of \"0\". (AArch64/RISC-V only)">,
   MarshallingInfoInt>;
 
 def msign_return_address_EQ : Joined<["-"], "msign-return-address=">,



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


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

2023-06-08 Thread Sedenion via Phabricator via cfe-commits
Sedeniono updated this revision to Diff 529630.
Sedeniono added a comment.

Reformatted comment, and submitting it via `arc diff --update` now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -166,11 +166,10 @@
   const AdditionalKeywords &Keywords;
   const unsigned AdditionalIndent;
 
-  /// The indent in characters for each level.
-  /// It remembers the indent of previous lines (that are not PP directives) of
-  /// equal or lower levels. This is used to align formatted lines to the 
indent
-  /// of previous non-formatted lines. Think about the --lines parameter of
-  /// clang-format.
+  /// The indent in characters for each level. It remembers the indent of
+  /// previous lines (that are not PP directives) of equal or lower levels. 
This
+  /// is used to align formatted lines to the indent of previous non-formatted
+  /// lines. Think about the --lines parameter of clang-format.
   SmallVector IndentForLevel;
 
   /// Offset of the current line relative to the indent level.


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -166,11 +166,10 @@
   const AdditionalKeywords &Keywords;
   const unsigned AdditionalIndent;
 
-  /// The indent in characters for each level.
-  /// It remembers the indent of previous lines (that are not PP directives) of
-  /// equal or lower levels. This is used to align formatted lines to the indent
-  /// of previous non-formatted lines. Think about the --lines parameter of
-  /// clang-format.
+  /// The indent in characters for each level. It remembers the indent of
+  /// previous lines (that are not PP directives) of equal or lower levels. This
+  /// is used to align formatted lines to the indent of previous non-formatted
+  /// lines. Think about the --lines parameter of clang-format.
   SmallVector IndentForLevel;
 
   /// Offset of the current line relative to the indent level.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-06-08 Thread Sedenion via Phabricator via cfe-commits
Sedeniono updated this revision to Diff 529631.
Sedeniono added a comment.

Next try at getting all changes to phabricator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTestSelective.cpp

Index: clang/unittests/Format/FormatTestSelective.cpp
===
--- clang/unittests/Format/FormatTestSelective.cpp
+++ clang/unittests/Format/FormatTestSelective.cpp
@@ -528,6 +528,26 @@
 format("  int a;\n"
"void ff() {}",
11, 0));
+
+  // https://github.com/llvm/llvm-project/issues/59178
+  Style = getMozillaStyle();
+  EXPECT_EQ("int a()\n"
+"{\n"
+"return 0;\n"
+"}\n"
+"int b()\n"
+"{\n"
+"  return 42;\n"
+"}",
+format("int a()\n"
+   "{\n"
+   "return 0;\n"
+   "}\n"
+   "int b()\n"
+   "{\n"
+   "return 42;\n" // Format this line only
+   "}",
+   32, 0));
 }
 
 TEST_F(FormatTestSelective, UnderstandsTabs) {
@@ -617,6 +637,70 @@
  "namespace ns1 { namespace ns2 {\n"
  "}}";
   EXPECT_EQ(Code, format(Code, 0, 0));
+
+  Style = getLLVMStyle();
+  Style.FixNamespaceComments = false;
+  Code = "namespace ns {\n"
+ "#define REF(alias) alias alias_var;\n"
+ "}";
+  EXPECT_EQ(Code, format(Code, 51, 1));
+}
+
+TEST_F(FormatTestSelective, FormatMacroRegardlessOfPreviousIndent) {
+  // clang-format currently does not (or should not) take into account the
+  // indent of previous unformatted lines when formatting a PP directive.
+  // Technically speaking, LevelIndentTracker::IndentForLevel is only for non-PP
+  // lines. So these tests here check that the indent of previous non-PP lines
+  // do not affect the formatting. If this requirement changes, the tests here
+  // need to be adapted.
+  Style = getLLVMStyle();
+
+  Style.IndentPPDirectives = FormatStyle::PPDirectiveIndentStyle::PPDIS_None;
+  EXPECT_EQ("  class Foo {\n"
+"void test() {\n"
+"#ifdef 1\n"
+"#define some\n" // Formatted line
+"#endif\n"   // That this line is also formatted might be a bug.
+"}};", // Dito: Bug?
+format("  class Foo {\n"
+   "void test() {\n"
+   "#ifdef 1\n"
+   "#define some\n" // format this line
+   " #endif\n"
+   "}};",
+   75, 0));
+
+  Style.IndentPPDirectives =
+  FormatStyle::PPDirectiveIndentStyle::PPDIS_BeforeHash;
+  EXPECT_EQ("  class Foo {\n"
+"void test() {\n"
+"#ifdef 1\n"
+"  #define some\n" // Formatted line
+" #endif\n"
+"}};",
+format("  class Foo {\n"
+   "void test() {\n"
+   "#ifdef 1\n"
+   "#define some\n" // format this line
+   " #endif\n"
+   "}};",
+   75, 0));
+
+  Style.IndentPPDirectives =
+  FormatStyle::PPDirectiveIndentStyle::PPDIS_AfterHash;
+  EXPECT_EQ("  class Foo {\n"
+"void test() {\n"
+"#ifdef 1\n"
+"#  define some\n" // Formatted line
+"#endif\n" // That this line is also formatted might be a bug.
+"}};",
+format("  class Foo {\n"
+   "void test() {\n"
+   "#ifdef 1\n"
+   "#define some\n" // format this line
+   " #endif\n"
+   "}};",
+   75, 0));
 }
 
 } // end namespace
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -74,6 +74,12 @@
: Line.Level * PPIndentWidth;
   Indent += AdditionalIndent;
 } else {
+  // When going to lower levels, forget previous higher levels so that we
+  // recompute future higher levels. But don't forget them if we enter a PP
+  // directive, since these do not terminate a code block.
+  if (!Line.InPPDirective && Line.Level < IndentForLevel.size())
+IndentForLevel.resize(Line.Level + 1, -1);
+
   Indent = getIndent(Line.Level);
 }
 if (static_cast(Indent) + Offset >= 0)
@@ -88,13 +94,13 @@
   /// level to the same indent.
   /// Note that \c nextLine must have been

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

2023-06-08 Thread Sedenion via Phabricator via cfe-commits
Sedeniono marked an inline comment as done.
Sedeniono added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:169-170
 
   /// The indent in characters for each level.
+  /// It remembers the indent of previous lines (that are not PP directives) of
+  /// equal or lower levels. This is used to align formatted lines to the 
indent

barannikov88 wrote:
> Sedeniono wrote:
> > Sedeniono wrote:
> > > HazardyKnusperkeks wrote:
> > > > And then reformat the comment.
> > > Done.
> > Mh, it says [that it couldn't apply the 
> > patch](https://reviews.llvm.org/harbormaster/build/367648/). I uploaded a 
> > patch containing as only change the reformatted comment, via the Web UI 
> > ("Update Diff" at the top right corner). Should I have uploaded a 
> > "squashed" diff, containing also ALL changes that I made before (the 
> > `resize` etc)? In other words, is Phabricator expecting individual patches 
> > and it merges and accumulates them itself? Or does each new uploaded patch 
> > overwrite all previous patches?
> The latter
Ok, it took me 2 tries, but it seems that I managed to upload the full list of 
changes via `arc diff` now. I had to specify the origin commit explicitly.


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] D152429: [Clang][Type] Add static assertion to guard future expansion for BuiltinType numbering

2023-06-08 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 529634.
eopXD added a comment.

Address comment from Aaron.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152429

Files:
  clang/include/clang/AST/Type.h


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1649,7 +1649,8 @@
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
-unsigned Kind : 8;
+static constexpr unsigned NumOfBuiltinTypeBits = 8;
+unsigned Kind : NumOfBuiltinTypeBits;
   };
 
   /// FunctionTypeBitfields store various bits belonging to FunctionProtoType.
@@ -2677,6 +2678,10 @@
   : Type(Builtin, QualType(),
  K == Dependent ? TypeDependence::DependentInstantiation
 : TypeDependence::None) {
+static_assert(Kind::LastKind <
+  (1 << BuiltinTypeBitfields::NumOfBuiltinTypeBits) &&
+  "Defined builtin type exceeds the allocated space for serial 
"
+  "numbering");
 BuiltinTypeBits.Kind = K;
   }
 


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1649,7 +1649,8 @@
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
-unsigned Kind : 8;
+static constexpr unsigned NumOfBuiltinTypeBits = 8;
+unsigned Kind : NumOfBuiltinTypeBits;
   };
 
   /// FunctionTypeBitfields store various bits belonging to FunctionProtoType.
@@ -2677,6 +2678,10 @@
   : Type(Builtin, QualType(),
  K == Dependent ? TypeDependence::DependentInstantiation
 : TypeDependence::None) {
+static_assert(Kind::LastKind <
+  (1 << BuiltinTypeBitfields::NumOfBuiltinTypeBits) &&
+  "Defined builtin type exceeds the allocated space for serial "
+  "numbering");
 BuiltinTypeBits.Kind = K;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152443: Add SpaceAfterOperatorKeyword style option for clang-format

2023-06-08 Thread Alexander Hinze via Phabricator via cfe-commits
KitsuneAlex updated this revision to Diff 529635.
KitsuneAlex added a comment.

I took the liberty and extended the unit tests for SpaceAfterTemplateKeyword 
and SpaceAfterOperator keyword to cover both possible cases, which lead to me 
discovering that my code was not quite right because of an early-out return 
path in a calling function.

Everything is fixed and tested now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22905,6 +22905,16 @@
   FormatStyle Style = getLLVMStyle();
   Style.SpaceAfterTemplateKeyword = false;
   verifyFormat("template void foo();", Style);
+  Style.SpaceAfterTemplateKeyword = true;
+  verifyFormat("template  void foo();", Style);
+}
+
+TEST_F(FormatTest, SpaceAfterOperatorKeyword) {
+  FormatStyle Style = getLLVMStyle();
+  Style.SpaceAfterOperatorKeyword = false;
+  verifyFormat("bool operator==();", Style);
+  Style.SpaceAfterOperatorKeyword = true;
+  verifyFormat("bool operator ==();", Style);
 }
 
 TEST_F(FormatTest, TripleAngleBrackets) {
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -184,6 +184,7 @@
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
+  CHECK_PARSE_BOOL(SpaceAfterOperatorKeyword);
   CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
   CHECK_PARSE_BOOL(SpaceBeforeCaseColon);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3759,6 +3759,7 @@
   Left.Previous->is(tok::kw_operator)) {
 return false;
   }
+
   // co_await (x), co_yield (x), co_return (x)
   if (Left.isOneOf(tok::kw_co_await, tok::kw_co_yield, tok::kw_co_return) &&
   !Right.isOneOf(tok::semi, tok::r_paren)) {
@@ -4202,7 +4203,7 @@
   return true;
 
 if (Left.is(tok::kw_operator))
-  return Right.is(tok::coloncolon);
+  return Style.SpaceAfterOperatorKeyword || Right.is(tok::coloncolon);
 if (Right.is(tok::l_brace) && Right.is(BK_BracedInit) &&
 !Left.opensScope() && Style.SpaceBeforeCpp11BracedList) {
   return true;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1002,6 +1002,8 @@
 IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot);
 IO.mapOptional("SpaceAfterTemplateKeyword",
Style.SpaceAfterTemplateKeyword);
+IO.mapOptional("SpaceAfterOperatorKeyword",
+   Style.SpaceAfterOperatorKeyword);
 IO.mapOptional("SpaceAroundPointerQualifiers",
Style.SpaceAroundPointerQualifiers);
 IO.mapOptional("SpaceBeforeAssignmentOperators",
@@ -1440,6 +1442,7 @@
   LLVMStyle.SpaceAfterCStyleCast = false;
   LLVMStyle.SpaceAfterLogicalNot = false;
   LLVMStyle.SpaceAfterTemplateKeyword = true;
+  LLVMStyle.SpaceAfterOperatorKeyword = false;
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
@@ -1731,6 +1734,7 @@
   MozillaStyle.PenaltyReturnTypeOnItsOwnLine = 200;
   MozillaStyle.PointerAlignment = FormatStyle::PAS_Left;
   MozillaStyle.SpaceAfterTemplateKeyword = false;
+  MozillaStyle.SpaceAfterOperatorKeyword = false;
   return MozillaStyle;
 }
 
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3700,6 +3700,14 @@
   /// \version 4
   bool SpaceAfterTemplateKeyword;
 
+  /// If \c true, a space will be inserted after the 'operator' keyword.
+  /// \code
+  ///true:  false:
+  ///bool operator ==(...); vs. bool operator==(...);
+  /// \endcode
+  /// \version 17
+  bool SpaceAfterOperatorKeyword;
+
   /// Different ways to put a space before opening parentheses.
   enum SpaceAroundPointerQualifiersStyle : int8_t {
 /// Don't ensure spaces around pointer qualifiers and use PointerAlignment
@@ -4412,6 +4420,7 @@
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
 

  1   2   >